[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14858 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14858 - gnunet/src/transport |
Date: |
Mon, 4 Apr 2011 22:21:18 +0200 |
Author: brodski
Date: 2011-04-04 22:21:18 +0200 (Mon, 04 Apr 2011)
New Revision: 14858
Modified:
gnunet/src/transport/plugin_transport_wlan.c
Log:
CodeSonar errors fixed
Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c 2011-04-04 19:15:46 UTC
(rev 14857)
+++ gnunet/src/transport/plugin_transport_wlan.c 2011-04-04 20:21:18 UTC
(rev 14858)
@@ -1098,7 +1098,9 @@
if (GNUNET_TIME_absolute_get_difference(fm2->next_ack,
fm->next_ack).rel_value
== 0)
{
- break;
+
GNUNET_CONTAINER_DLL_insert_before(plugin->pending_Fragment_Messages_head,
+ plugin->pending_Fragment_Messages_tail,fm2,fm);
+ return;
}
else
{
@@ -1106,8 +1108,8 @@
}
}
- GNUNET_CONTAINER_DLL_insert_after(plugin->pending_Fragment_Messages_head,
- plugin->pending_Fragment_Messages_tail,fm2,fm);
+ GNUNET_CONTAINER_DLL_insert_tail(plugin->pending_Fragment_Messages_head,
+ plugin->pending_Fragment_Messages_tail,fm);
}
/**
@@ -1602,7 +1604,6 @@
if (bytes != finish->size)
{
- finish->plugin = plugin;
finish->msgheader = finish->msgheader + bytes;
finish->size = finish->size - bytes;
plugin->server_write_task = GNUNET_SCHEDULER_add_write_file(
@@ -1623,9 +1624,16 @@
struct Radiotap_Send * header)
{
- header->rate = session->rate;
- header->tx_power = session->tx_power;
- header->antenna = session->antenna;
+ if (session != null){
+ header->rate = session->rate;
+ header->tx_power = session->tx_power;
+ header->antenna = session->antenna;
+ } else {
+ header->rate = 255;
+ header->tx_power = 0;
+ header->antenna = 0;
+ }
+
return GNUNET_YES;
}
;
@@ -1996,10 +2004,6 @@
/* TODO check for bad addresses like multicast, broadcast, etc */
return GNUNET_OK;
}
- else
- {
- return GNUNET_SYSERR;
- }
return GNUNET_SYSERR;
}
@@ -2090,12 +2094,12 @@
insert_fragment_in_queue(struct Receive_Message_Queue * rec_message,
struct Receive_Fragment_Queue * rec_queue)
{
+ GNUNET_assert(rec_message != NULL);
+ GNUNET_assert(rec_queue != NULL);
+
struct Receive_Fragment_Queue * rec_queue2 = rec_message->frag_head;
struct WlanHeader * wlanheader = NULL;
- GNUNET_assert(rec_message != NULL);
- GNUNET_assert(rec_queue != NULL);
-
//this is the first fragment of the message (fragment id 0)
if (rec_queue->num == 0)
{
@@ -2165,6 +2169,8 @@
struct Session_light * session_light, struct Session * session,
struct Receive_Message_Queue * rec_message)
{
+ GNUNET_assert(rec_message !=NULL);
+
struct Receive_Fragment_Queue * rec_queue = rec_message->frag_head;
int packetsize = rec_message->rec_size;
int sum = 0;
@@ -2172,13 +2178,24 @@
uint64_t bitfield = 0;
char * msg;
- GNUNET_assert(rec_message !=NULL);
//check if first fragment is present
if (packetsize == MESSAGE_LENGHT_UNKNOWN)
{
return;
}
+ // test if message has at least the size of the WlanHeader and a
GNUNET_MessageHeader
+ else if (packetsize < sizeof(struct WlanHeader)
+ + sizeof(struct GNUNET_MessageHeader))
+ {
#if DEBUG_wlan
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Message not big enough\n");
+#endif
+ free_receive_message(plugin, rec_message);
+ return;
+ }
+
+#if DEBUG_wlan
check_message_fragment_bitfield(rec_message);
#endif
@@ -2278,6 +2295,13 @@
ntohs(hdr->size));
#endif
+ if (ntohs(hdr->size) < sizeof(struct WlanHeader)
+ + sizeof(struct GNUNET_MessageHeader))
+ {
+ //packet not big enought
+ return;
+ }
+
GNUNET_assert(session_light != NULL);
if (session_light->session == NULL)
{
@@ -2285,6 +2309,7 @@
}
session = session_light->session;
wlanheader = (struct WlanHeader *) hdr;
+
tempmsg = (char*) &wlanheader[1];
temp_hdr = (const struct GNUNET_MessageHeader *) &wlanheader[1];
@@ -2677,7 +2702,7 @@
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
"WLAN fragment not in fragment list with id %u of ack\n", ntohl(
- fh->message_id));
+ fah->message_id));
return;
}
@@ -2794,7 +2819,7 @@
#if DEBUG_wlan
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Func wlan_process_helper got wrong MAC: %s\n", macprinter(
- wlanIeeeHeader->i_addr1));
+ wlanIeeeHeader->i_addr1));
#endif
}
}
@@ -3005,13 +3030,29 @@
plugin->server_read_task = GNUNET_SCHEDULER_NO_TASK;
plugin->server_write_delay_task = GNUNET_SCHEDULER_NO_TASK;
- set_next_beacon_time(plugin);
+ plugin->suid_tokenizer = GNUNET_SERVER_mst_create(&wlan_process_helper,
+ plugin);
+ plugin->data_tokenizer = GNUNET_SERVER_mst_create(&process_data, plugin);
+
+ //plugin->sessions = GNUNET_malloc (sizeof (struct Sessionqueue));
+ //plugin->pending_Sessions = GNUNET_malloc (sizeof (struct Sessionqueue));
+
+ api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
+ api->cls = plugin;
+ api->send = &wlan_plugin_send;
+ api->disconnect = &wlan_plugin_disconnect;
+ api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
+ api->check_address = &wlan_plugin_address_suggested;
+ api->address_to_string = &wlan_plugin_address_to_string;
+
+ //read config
+
if (GNUNET_CONFIGURATION_have_value(env->cfg, "transport-wlan", "TESTMODE"))
{
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(env->cfg,
"transport-wlan", "TESTMODE", &testmode))
- return NULL;
+ testmode = 0; //default value
}
if (GNUNET_CONFIGURATION_have_value(env->cfg, "transport-wlan", "INTERFACE"))
@@ -3019,28 +3060,16 @@
if (GNUNET_CONFIGURATION_get_value_string(env->cfg, "transport-wlan",
"INTERFACE", &(plugin->interface)) != GNUNET_YES)
{
- libgnunet_plugin_transport_wlan_done(plugin);
+ libgnunet_plugin_transport_wlan_done(api);
return NULL;
}
}
+ //start the plugin
+ set_next_beacon_time(plugin);
+
wlan_transport_start_wlan_helper(plugin, testmode);
- plugin->suid_tokenizer = GNUNET_SERVER_mst_create(&wlan_process_helper,
- plugin);
- plugin->data_tokenizer = GNUNET_SERVER_mst_create(&process_data, plugin);
-
- //plugin->sessions = GNUNET_malloc (sizeof (struct Sessionqueue));
- //plugin->pending_Sessions = GNUNET_malloc (sizeof (struct Sessionqueue));
-
- api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
- api->cls = plugin;
- api->send = &wlan_plugin_send;
- api->disconnect = &wlan_plugin_disconnect;
- api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
- api->check_address = &wlan_plugin_address_suggested;
- api->address_to_string = &wlan_plugin_address_to_string;
-
start_next_message_id();
#if DEBUG_wlan
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14858 - gnunet/src/transport,
gnunet <=