aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/transport/plugin_transport_wlan.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c289
1 files changed, 149 insertions, 140 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 6ed367293..ad8d9a7a1 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -662,11 +662,10 @@ struct FragmentMessage
662 struct Radiotap_Send *radioHeader; 662 struct Radiotap_Send *radioHeader;
663}; 663};
664 664
665static void 665static void do_transmit (void *cls,
666do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 666 const struct GNUNET_SCHEDULER_TaskContext *tc);
667static void 667static void free_session (struct Plugin *plugin, struct Sessionqueue *queue,
668free_session (struct Plugin *plugin, struct Sessionqueue *queue, 668 int do_free_macendpoint);
669 int do_free_macendpoint);
670static struct MacEndpoint *create_macendpoint (struct Plugin *plugin, 669static struct MacEndpoint *create_macendpoint (struct Plugin *plugin,
671 const struct MacAddress *addr); 670 const struct MacAddress *addr);
672 671
@@ -773,8 +772,9 @@ search_session (struct Plugin *plugin, const struct MacEndpoint *endpoint,
773 while (queue != NULL) 772 while (queue != NULL)
774 { 773 {
775 GNUNET_assert (queue->content != NULL); 774 GNUNET_assert (queue->content != NULL);
776 if (memcmp (peer, &queue->content->target, 775 if (memcmp
777 sizeof (struct GNUNET_PeerIdentity)) == 0) 776 (peer, &queue->content->target,
777 sizeof (struct GNUNET_PeerIdentity)) == 0)
778 return queue->content; /* session found */ 778 return queue->content; /* session found */
779 queue = queue->next; 779 queue = queue->next;
780 } 780 }
@@ -974,27 +974,29 @@ set_next_beacon_time (struct Plugin *const plugin)
974 //under 10 known peers: once a second 974 //under 10 known peers: once a second
975 if (plugin->mac_count < 10) 975 if (plugin->mac_count < 10)
976 { 976 {
977 plugin->beacon_time = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), 977 plugin->beacon_time =
978 GNUNET_TIME_relative_multiply 978 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
979 (GNUNET_TIME_UNIT_SECONDS, 979 GNUNET_TIME_relative_multiply
980 HALLO_BEACON_SCALING_FACTOR)); 980 (GNUNET_TIME_UNIT_SECONDS,
981 HALLO_BEACON_SCALING_FACTOR));
981 } 982 }
982 //under 30 known peers: every 10 seconds 983 //under 30 known peers: every 10 seconds
983 else if (plugin->mac_count < 30) 984 else if (plugin->mac_count < 30)
984 { 985 {
985 plugin->beacon_time = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), 986 plugin->beacon_time =
986 GNUNET_TIME_relative_multiply 987 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
987 (GNUNET_TIME_UNIT_SECONDS, 988 GNUNET_TIME_relative_multiply
988 10 * 989 (GNUNET_TIME_UNIT_SECONDS,
989 HALLO_BEACON_SCALING_FACTOR)); 990 10 * HALLO_BEACON_SCALING_FACTOR));
990 } 991 }
991 //over 30 known peers: once a minute 992 //over 30 known peers: once a minute
992 else 993 else
993 { 994 {
994 plugin->beacon_time = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), 995 plugin->beacon_time =
995 GNUNET_TIME_relative_multiply 996 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
996 (GNUNET_TIME_UNIT_MINUTES, 997 GNUNET_TIME_relative_multiply
997 HALLO_BEACON_SCALING_FACTOR)); 998 (GNUNET_TIME_UNIT_MINUTES,
999 HALLO_BEACON_SCALING_FACTOR));
998 } 1000 }
999} 1001}
1000 1002
@@ -1094,10 +1096,10 @@ get_next_queue_session (struct Plugin *plugin)
1094 if (GNUNET_TIME_absolute_get_remaining (pm->timeout).rel_value > 0) 1096 if (GNUNET_TIME_absolute_get_remaining (pm->timeout).rel_value > 0)
1095 { 1097 {
1096 //check if session has no message in the fragment queue 1098 //check if session has no message in the fragment queue
1097 if ((session->mac->fragment_messages_out_count 1099 if ((session->mac->fragment_messages_out_count <
1098 < FRAGMENT_QUEUE_MESSAGES_OUT_PER_MACENDPOINT) 1100 FRAGMENT_QUEUE_MESSAGES_OUT_PER_MACENDPOINT) &&
1099 && (session->fragment_messages_out_count 1101 (session->fragment_messages_out_count <
1100 < FRAGMENT_QUEUE_MESSAGES_OUT_PER_SESSION)) 1102 FRAGMENT_QUEUE_MESSAGES_OUT_PER_SESSION))
1101 { 1103 {
1102 plugin->pendingsessions--; 1104 plugin->pendingsessions--;
1103 GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head, 1105 GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head,
@@ -1335,8 +1337,9 @@ add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr)
1335 fm, fm->session, endpoint); 1337 fm, fm->session, endpoint);
1336#endif 1338#endif
1337 1339
1338 size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) 1340 size =
1339 + sizeof (struct ieee80211_frame) + ntohs (hdr->size); 1341 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) +
1342 sizeof (struct ieee80211_frame) + ntohs (hdr->size);
1340 fm->frag = GNUNET_malloc (size); 1343 fm->frag = GNUNET_malloc (size);
1341 fm->size = size; 1344 fm->size = size;
1342 1345
@@ -1382,9 +1385,10 @@ send_hello_beacon (struct Plugin *plugin)
1382 hello = plugin->env->get_our_hello (); 1385 hello = plugin->env->get_our_hello ();
1383 hallo_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); 1386 hallo_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
1384 GNUNET_assert (sizeof (struct WlanHeader) + hallo_size <= WLAN_MTU); 1387 GNUNET_assert (sizeof (struct WlanHeader) + hallo_size <= WLAN_MTU);
1385 size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) 1388 size =
1386 + sizeof (struct ieee80211_frame) + sizeof (struct GNUNET_MessageHeader) 1389 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) +
1387 + hallo_size; 1390 sizeof (struct ieee80211_frame) + sizeof (struct GNUNET_MessageHeader) +
1391 hallo_size;
1388 1392
1389 msgheader = GNUNET_malloc (size); 1393 msgheader = GNUNET_malloc (size);
1390 msgheader->size = htons (size); 1394 msgheader->size = htons (size);
@@ -1443,16 +1447,18 @@ add_ack_for_send (void *cls, uint32_t msg_id,
1443 struct GNUNET_MessageHeader *msgheader2; 1447 struct GNUNET_MessageHeader *msgheader2;
1444 uint16_t size; 1448 uint16_t size;
1445 1449
1446 size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) 1450 size =
1447 + sizeof (struct ieee80211_frame) + ntohs (hdr->size) 1451 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) +
1448 + sizeof (struct AckSendQueue); 1452 sizeof (struct ieee80211_frame) + ntohs (hdr->size) +
1453 sizeof (struct AckSendQueue);
1449 1454
1450 ack = GNUNET_malloc (size); 1455 ack = GNUNET_malloc (size);
1451 ack->message_id = msg_id; 1456 ack->message_id = msg_id;
1452 ack->endpoint = endpoint; 1457 ack->endpoint = endpoint;
1453 1458
1454 size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) 1459 size =
1455 + sizeof (struct ieee80211_frame) + ntohs (hdr->size); 1460 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) +
1461 sizeof (struct ieee80211_frame) + ntohs (hdr->size);
1456 1462
1457 msgheader = (struct GNUNET_MessageHeader *) &ack[1]; 1463 msgheader = (struct GNUNET_MessageHeader *) &ack[1];
1458 ack->hdr = (struct GNUNET_MessageHeader *) &ack[1]; 1464 ack->hdr = (struct GNUNET_MessageHeader *) &ack[1];
@@ -1528,13 +1534,12 @@ check_fragment_queue (struct Plugin *plugin)
1528 fm->session = session; 1534 fm->session = session;
1529 fm->timeout.abs_value = pm->timeout.abs_value; 1535 fm->timeout.abs_value = pm->timeout.abs_value;
1530 fm->frag = NULL; 1536 fm->frag = NULL;
1531 fm->fragcontext = GNUNET_FRAGMENT_context_create (plugin->env->stats, 1537 fm->fragcontext =
1532 WLAN_MTU, 1538 GNUNET_FRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
1533 &plugin->tracker, 1539 &plugin->tracker,
1534 GNUNET_TIME_UNIT_SECONDS, 1540 GNUNET_TIME_UNIT_SECONDS,
1535 &(pm->msg->header), 1541 &(pm->msg->header),
1536 &add_message_for_send, 1542 &add_message_for_send, fm);
1537 fm);
1538 fm->timeout_task = 1543 fm->timeout_task =
1539 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining 1544 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
1540 (fm->timeout), fragmentmessage_timeout, 1545 (fm->timeout), fragmentmessage_timeout,
@@ -1596,8 +1601,9 @@ send_ack (struct Plugin *plugin, struct AckSendQueue *ack)
1596 getWlanHeader (ack->ieeewlanheader, &ack->endpoint->addr, plugin, 1601 getWlanHeader (ack->ieeewlanheader, &ack->endpoint->addr, plugin,
1597 ntohs (ack->hdr->size)); 1602 ntohs (ack->hdr->size));
1598 1603
1599 bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, ack->hdr, 1604 bytes =
1600 ntohs (ack->hdr->size)); 1605 GNUNET_DISK_file_write (plugin->server_stdin_handle, ack->hdr,
1606 ntohs (ack->hdr->size));
1601 if (bytes == GNUNET_SYSERR) 1607 if (bytes == GNUNET_SYSERR)
1602 { 1608 {
1603 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1609 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
@@ -1632,8 +1638,9 @@ finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1632 GNUNET_free (finish); 1638 GNUNET_free (finish);
1633 return; 1639 return;
1634 } 1640 }
1635 bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, 1641 bytes =
1636 finish->msgheader, finish->size); 1642 GNUNET_DISK_file_write (plugin->server_stdin_handle, finish->msgheader,
1643 finish->size);
1637 GNUNET_assert (bytes != GNUNET_SYSERR); 1644 GNUNET_assert (bytes != GNUNET_SYSERR);
1638 1645
1639 if (bytes != finish->size) 1646 if (bytes != finish->size)
@@ -1713,8 +1720,9 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1713 getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin, 1720 getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin,
1714 fm->size); 1721 fm->size);
1715 1722
1716 bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, fm->frag, 1723 bytes =
1717 fm->size); 1724 GNUNET_DISK_file_write (plugin->server_stdin_handle, fm->frag,
1725 fm->size);
1718 if (bytes == GNUNET_SYSERR) 1726 if (bytes == GNUNET_SYSERR)
1719 { 1727 {
1720 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1728 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
@@ -1852,9 +1860,8 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
1852 newmsg = session->pending_message_head; 1860 newmsg = session->pending_message_head;
1853 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1861 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
1854 "wlan_plugin_send: a pending message is already in the queue for this client\n remaining time to send this message is %u, queued fragment messages for this mac connection %u\n", 1862 "wlan_plugin_send: a pending message is already in the queue for this client\n remaining time to send this message is %u, queued fragment messages for this mac connection %u\n",
1855 GNUNET_TIME_absolute_get_remaining (newmsg-> 1863 GNUNET_TIME_absolute_get_remaining (newmsg->timeout).
1856 timeout).rel_value, 1864 rel_value, session->mac->fragment_messages_out_count);
1857 session->mac->fragment_messages_out_count);
1858 } 1865 }
1859 1866
1860 newmsg = GNUNET_malloc (sizeof (struct PendingMessage)); 1867 newmsg = GNUNET_malloc (sizeof (struct PendingMessage));
@@ -1992,8 +1999,8 @@ free_session (struct Plugin *plugin, struct Sessionqueue *queue,
1992 pm = queue->content->pending_message_head; 1999 pm = queue->content->pending_message_head;
1993 } 2000 }
1994 2001
1995 GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, 2002 GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, endpoint->sessions_tail,
1996 endpoint->sessions_tail, queue); 2003 queue);
1997 2004
1998 if (endpoint->sessions_head == NULL && do_free_macendpoint == GNUNET_YES) 2005 if (endpoint->sessions_head == NULL && do_free_macendpoint == GNUNET_YES)
1999 { 2006 {
@@ -2033,8 +2040,9 @@ wlan_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
2033 // content is never NULL 2040 // content is never NULL
2034 GNUNET_assert (queue->content != NULL); 2041 GNUNET_assert (queue->content != NULL);
2035 queue_next = queue->next; 2042 queue_next = queue->next;
2036 if (memcmp (target, &(queue->content->target), 2043 if (memcmp
2037 sizeof (struct GNUNET_PeerIdentity)) == 0) 2044 (target, &(queue->content->target),
2045 sizeof (struct GNUNET_PeerIdentity)) == 0)
2038 { 2046 {
2039 free_session (plugin, queue, GNUNET_YES); 2047 free_session (plugin, queue, GNUNET_YES);
2040 } 2048 }
@@ -2113,8 +2121,8 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2113 ntohs (hdr->size)); 2121 ntohs (hdr->size));
2114#endif 2122#endif
2115 2123
2116 if (ntohs (hdr->size) < sizeof (struct WlanHeader) 2124 if (ntohs (hdr->size) <
2117 + sizeof (struct GNUNET_MessageHeader)) 2125 sizeof (struct WlanHeader) + sizeof (struct GNUNET_MessageHeader))
2118 { 2126 {
2119 //packet not big enought 2127 //packet not big enought
2120 return; 2128 return;
@@ -2149,13 +2157,14 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2149 sizeof (struct WlanHeader)); 2157 sizeof (struct WlanHeader));
2150#endif 2158#endif
2151 //try if it is a hello message 2159 //try if it is a hello message
2152 if (ntohs (wlanheader->header.size) >= ntohs (temp_hdr->size) 2160 if (ntohs (wlanheader->header.size) >=
2153 + sizeof (struct WlanHeader)) 2161 ntohs (temp_hdr->size) + sizeof (struct WlanHeader))
2154 { 2162 {
2155 if (ntohs (temp_hdr->type) == GNUNET_MESSAGE_TYPE_HELLO) 2163 if (ntohs (temp_hdr->type) == GNUNET_MESSAGE_TYPE_HELLO)
2156 { 2164 {
2157 if (GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) 2165 if (GNUNET_HELLO_get_id
2158 temp_hdr, &tmpsource) == GNUNET_OK) 2166 ((const struct GNUNET_HELLO_Message *) temp_hdr,
2167 &tmpsource) == GNUNET_OK)
2159 { 2168 {
2160 session = create_session (plugin, endpoint, &tmpsource); 2169 session = create_session (plugin, endpoint, &tmpsource);
2161 } 2170 }
@@ -2186,8 +2195,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2186 2195
2187 //"receive" the message 2196 //"receive" the message
2188 2197
2189 if (memcmp (&wlanheader->source, &session->target, 2198 if (memcmp
2190 sizeof (struct GNUNET_PeerIdentity)) != 0) 2199 (&wlanheader->source, &session->target,
2200 sizeof (struct GNUNET_PeerIdentity)) != 0)
2191 { 2201 {
2192 //wrong peer id 2202 //wrong peer id
2193#if DEBUG_wlan 2203#if DEBUG_wlan
@@ -2198,8 +2208,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2198 return; 2208 return;
2199 } 2209 }
2200 2210
2201 if (memcmp (&wlanheader->target, plugin->env->my_identity, 2211 if (memcmp
2202 sizeof (struct GNUNET_PeerIdentity)) != 0) 2212 (&wlanheader->target, plugin->env->my_identity,
2213 sizeof (struct GNUNET_PeerIdentity)) != 0)
2203 { 2214 {
2204 //wrong peer id 2215 //wrong peer id
2205#if DEBUG_wlan 2216#if DEBUG_wlan
@@ -2252,8 +2263,8 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
2252 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2263 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2253 "Calling plugin->env->receive for session %p; %s; size: %u\n", 2264 "Calling plugin->env->receive for session %p; %s; size: %u\n",
2254 session, wlan_plugin_address_to_string (NULL, 2265 session, wlan_plugin_address_to_string (NULL,
2255 session->mac-> 2266 session->mac->addr.
2256 addr.mac, 6), 2267 mac, 6),
2257 htons (hdr->size)); 2268 htons (hdr->size));
2258#endif 2269#endif
2259 2270
@@ -2291,22 +2302,20 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2291#if DEBUG_wlan 2302#if DEBUG_wlan
2292 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2303 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2293 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT size: %u; %s\n", 2304 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT size: %u; %s\n",
2294 ntohs (hdr->size), 2305 ntohs (hdr->size), wlan_plugin_address_to_string (NULL,
2295 wlan_plugin_address_to_string (NULL, 2306 session_light->
2296 session_light->addr.mac, 2307 addr.mac,
2297 6)); 2308 6));
2298#endif 2309#endif
2299 2310
2300 if (session_light->macendpoint == NULL) 2311 if (session_light->macendpoint == NULL)
2301 { 2312 {
2302 session_light->macendpoint = get_macendpoint (plugin, 2313 session_light->macendpoint =
2303 &session_light->addr, 2314 get_macendpoint (plugin, &session_light->addr, GNUNET_NO);
2304 GNUNET_NO);
2305 } 2315 }
2306 GNUNET_assert (GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) 2316 GNUNET_assert (GNUNET_HELLO_get_id
2307 &hdr[1], 2317 ((const struct GNUNET_HELLO_Message *) &hdr[1],
2308 &(session_light->session->target)) != 2318 &(session_light->session->target)) != GNUNET_SYSERR);
2309 GNUNET_SYSERR);
2310 2319
2311 } 2320 }
2312 2321
@@ -2318,9 +2327,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2318 GNUNET_assert (session_light != NULL); 2327 GNUNET_assert (session_light != NULL);
2319 if (session_light->macendpoint == NULL) 2328 if (session_light->macendpoint == NULL)
2320 { 2329 {
2321 session_light->macendpoint = get_macendpoint (plugin, 2330 session_light->macendpoint =
2322 &session_light->addr, 2331 get_macendpoint (plugin, &session_light->addr, GNUNET_YES);
2323 GNUNET_YES);
2324 } 2332 }
2325 2333
2326#if DEBUG_wlan 2334#if DEBUG_wlan
@@ -2355,9 +2363,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2355 GNUNET_assert (session_light != NULL); 2363 GNUNET_assert (session_light != NULL);
2356 if (session_light->macendpoint == NULL) 2364 if (session_light->macendpoint == NULL)
2357 { 2365 {
2358 session_light->macendpoint = get_macendpoint (plugin, 2366 session_light->macendpoint =
2359 &session_light->addr, 2367 get_macendpoint (plugin, &session_light->addr, GNUNET_NO);
2360 GNUNET_NO);
2361 } 2368 }
2362 2369
2363 if (session_light->macendpoint == NULL) 2370 if (session_light->macendpoint == NULL)
@@ -2365,10 +2372,11 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2365#if DEBUG_wlan 2372#if DEBUG_wlan
2366 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2373 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2367 "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n", 2374 "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n",
2368 ntohs (hdr->size), 2375 ntohs (hdr->size), wlan_plugin_address_to_string (NULL,
2369 wlan_plugin_address_to_string (NULL, 2376 session_light->
2370 session_light->addr.mac, 2377 addr.
2371 6)); 2378 mac,
2379 6));
2372#endif 2380#endif
2373 return; 2381 return;
2374 } 2382 }
@@ -2469,16 +2477,16 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2469 return; 2477 return;
2470 } 2478 }
2471 if (GNUNET_TIME_absolute_get_remaining 2479 if (GNUNET_TIME_absolute_get_remaining
2472 (GNUNET_TIME_absolute_add 2480 (GNUNET_TIME_absolute_add (endpoint->last_activity, MACENDPOINT_TIMEOUT)).
2473 (endpoint->last_activity, MACENDPOINT_TIMEOUT)).rel_value == 0) 2481 rel_value == 0)
2474 { 2482 {
2475 free_macendpoint (endpoint->plugin, endpoint); 2483 free_macendpoint (endpoint->plugin, endpoint);
2476 } 2484 }
2477 else 2485 else
2478 { 2486 {
2479 endpoint->timeout_task = GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, 2487 endpoint->timeout_task =
2480 &macendpoint_timeout, 2488 GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
2481 endpoint); 2489 endpoint);
2482 } 2490 }
2483} 2491}
2484 2492
@@ -2497,16 +2505,15 @@ create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr)
2497 newend->plugin = plugin; 2505 newend->plugin = plugin;
2498 newend->addr = *addr; 2506 newend->addr = *addr;
2499 newend->fragment_messages_out_count = 0; 2507 newend->fragment_messages_out_count = 0;
2500 newend->defrag = GNUNET_DEFRAGMENT_context_create (plugin->env->stats, 2508 newend->defrag =
2501 WLAN_MTU, 2509 GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
2502 MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, 2510 MESSAGES_IN_DEFRAG_QUEUE_PER_MAC,
2503 newend, 2511 newend, &wlan_data_message_handler,
2504 &wlan_data_message_handler, 2512 &add_ack_for_send);
2505 &add_ack_for_send);
2506 newend->last_activity = GNUNET_TIME_absolute_get (); 2513 newend->last_activity = GNUNET_TIME_absolute_get ();
2507 newend->timeout_task = GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, 2514 newend->timeout_task =
2508 &macendpoint_timeout, 2515 GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
2509 newend); 2516 newend);
2510 2517
2511 plugin->mac_count++; 2518 plugin->mac_count++;
2512 GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend); 2519 GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend);
@@ -2548,15 +2555,16 @@ wlan_process_helper (void *cls, void *client,
2548#endif 2555#endif
2549 2556
2550 //call wlan_process_helper with the message inside, later with wlan: analyze signal 2557 //call wlan_process_helper with the message inside, later with wlan: analyze signal
2551 if (ntohs (hdr->size) < sizeof (struct ieee80211_frame) 2558 if (ntohs (hdr->size) <
2552 + sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx)) 2559 sizeof (struct ieee80211_frame) + sizeof (struct GNUNET_MessageHeader) +
2560 sizeof (struct Radiotap_rx))
2553 { 2561 {
2554#if DEBUG_wlan 2562#if DEBUG_wlan
2555 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2563 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2556 "Size of packet is too small; size: %u min size: %u\n", 2564 "Size of packet is too small; size: %u min size: %u\n",
2557 ntohs (hdr->size), 2565 ntohs (hdr->size),
2558 sizeof (struct ieee80211_frame) 2566 sizeof (struct ieee80211_frame) +
2559 + sizeof (struct GNUNET_MessageHeader)); 2567 sizeof (struct GNUNET_MessageHeader));
2560#endif 2568#endif
2561 //GNUNET_break (0); 2569 //GNUNET_break (0);
2562 /* FIXME: restart SUID process */ 2570 /* FIXME: restart SUID process */
@@ -2568,12 +2576,14 @@ wlan_process_helper (void *cls, void *client,
2568 //process only if it is an broadcast or for this computer both with the gnunet bssid 2576 //process only if it is an broadcast or for this computer both with the gnunet bssid
2569 2577
2570 //check for bssid 2578 //check for bssid
2571 if (memcmp (&(wlanIeeeHeader->i_addr3), &mac_bssid, 2579 if (memcmp
2572 sizeof (struct MacAddress)) == 0) 2580 (&(wlanIeeeHeader->i_addr3), &mac_bssid,
2581 sizeof (struct MacAddress)) == 0)
2573 { 2582 {
2574 //check for broadcast or mac 2583 //check for broadcast or mac
2575 if (memcmp (&(wlanIeeeHeader->i_addr1), &bc_all_mac, 2584 if (memcmp
2576 sizeof (struct MacAddress) == 0) || 2585 (&(wlanIeeeHeader->i_addr1), &bc_all_mac,
2586 sizeof (struct MacAddress) == 0) ||
2577 memcmp (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address), 2587 memcmp (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address),
2578 sizeof (struct MacAddress)) == 0) 2588 sizeof (struct MacAddress)) == 0)
2579 { 2589 {
@@ -2581,9 +2591,9 @@ wlan_process_helper (void *cls, void *client,
2581 // process the inner data 2591 // process the inner data
2582 2592
2583 2593
2584 datasize = ntohs (hdr->size) - sizeof (struct ieee80211_frame) 2594 datasize =
2585 - sizeof (struct GNUNET_MessageHeader) 2595 ntohs (hdr->size) - sizeof (struct ieee80211_frame) -
2586 - sizeof (struct Radiotap_rx); 2596 sizeof (struct GNUNET_MessageHeader) - sizeof (struct Radiotap_rx);
2587 2597
2588 session_light = GNUNET_malloc (sizeof (struct Session_light)); 2598 session_light = GNUNET_malloc (sizeof (struct Session_light));
2589 memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2), 2599 memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2),
@@ -2670,8 +2680,9 @@ wlan_plugin_helper_read (void *cls,
2670 char mybuf[WLAN_MTU + sizeof (struct GNUNET_MessageHeader)]; 2680 char mybuf[WLAN_MTU + sizeof (struct GNUNET_MessageHeader)];
2671 ssize_t bytes; 2681 ssize_t bytes;
2672 2682
2673 bytes = GNUNET_DISK_file_read (plugin->server_stdout_handle, mybuf, 2683 bytes =
2674 sizeof (mybuf)); 2684 GNUNET_DISK_file_read (plugin->server_stdout_handle, mybuf,
2685 sizeof (mybuf));
2675 if (bytes <= 0) 2686 if (bytes <= 0)
2676 { 2687 {
2677#if DEBUG_wlan 2688#if DEBUG_wlan
@@ -2724,10 +2735,10 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode)
2724 filenamehw, plugin->interface, testmode); 2735 filenamehw, plugin->interface, testmode);
2725#endif 2736#endif
2726 2737
2727 plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, 2738 plugin->server_proc =
2728 plugin->server_stdout, 2739 GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
2729 filenamehw, filenamehw, 2740 filenamehw, filenamehw, plugin->interface,
2730 plugin->interface, NULL); 2741 NULL);
2731 } 2742 }
2732 else if (testmode == 1) 2743 else if (testmode == 1)
2733 { 2744 {
@@ -2738,10 +2749,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode)
2738 filenameloopback, plugin->interface, testmode); 2749 filenameloopback, plugin->interface, testmode);
2739#endif 2750#endif
2740 2751
2741 plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, 2752 plugin->server_proc =
2742 plugin->server_stdout, 2753 GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
2743 filenameloopback, 2754 filenameloopback, filenameloopback, "1", NULL);
2744 filenameloopback, "1", NULL);
2745 } 2755 }
2746 else if (testmode == 2) 2756 else if (testmode == 2)
2747 { 2757 {
@@ -2750,10 +2760,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode)
2750 "Starting gnunet-wlan-helper loopback 2 process cmd: %s %s %i\n", 2760 "Starting gnunet-wlan-helper loopback 2 process cmd: %s %s %i\n",
2751 filenameloopback, plugin->interface, testmode); 2761 filenameloopback, plugin->interface, testmode);
2752#endif 2762#endif
2753 plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, 2763 plugin->server_proc =
2754 plugin->server_stdout, 2764 GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
2755 filenameloopback, 2765 filenameloopback, filenameloopback, "2", NULL);
2756 filenameloopback, "2", NULL);
2757 } 2766 }
2758 if (plugin->server_proc == NULL) 2767 if (plugin->server_proc == NULL)
2759 { 2768 {
@@ -2771,10 +2780,12 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode)
2771 /* Close the read end of the write pipe */ 2780 /* Close the read end of the write pipe */
2772 GNUNET_DISK_pipe_close_end (plugin->server_stdin, GNUNET_DISK_PIPE_END_READ); 2781 GNUNET_DISK_pipe_close_end (plugin->server_stdin, GNUNET_DISK_PIPE_END_READ);
2773 2782
2774 plugin->server_stdout_handle = GNUNET_DISK_pipe_handle (plugin->server_stdout, 2783 plugin->server_stdout_handle =
2775 GNUNET_DISK_PIPE_END_READ); 2784 GNUNET_DISK_pipe_handle (plugin->server_stdout,
2776 plugin->server_stdin_handle = GNUNET_DISK_pipe_handle (plugin->server_stdin, 2785 GNUNET_DISK_PIPE_END_READ);
2777 GNUNET_DISK_PIPE_END_WRITE); 2786 plugin->server_stdin_handle =
2787 GNUNET_DISK_pipe_handle (plugin->server_stdin,
2788 GNUNET_DISK_PIPE_END_WRITE);
2778 2789
2779 GNUNET_assert (plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK); 2790 GNUNET_assert (plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK);
2780 2791
@@ -2880,8 +2891,8 @@ libgnunet_plugin_transport_wlan_init (void *cls)
2880 GNUNET_BANDWIDTH_value_init (100 * 1024 * 2891 GNUNET_BANDWIDTH_value_init (100 * 1024 *
2881 1024 / 8), 100); 2892 1024 / 8), 100);
2882 2893
2883 plugin->suid_tokenizer = GNUNET_SERVER_mst_create (&wlan_process_helper, 2894 plugin->suid_tokenizer =
2884 plugin); 2895 GNUNET_SERVER_mst_create (&wlan_process_helper, plugin);
2885 2896
2886 plugin->data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); 2897 plugin->data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
2887 2898
@@ -2899,19 +2910,17 @@ libgnunet_plugin_transport_wlan_init (void *cls)
2899 2910
2900 if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE")) 2911 if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE"))
2901 { 2912 {
2902 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (env->cfg, 2913 if (GNUNET_SYSERR ==
2903 "transport-wlan", 2914 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan",
2904 "TESTMODE", 2915 "TESTMODE", &testmode))
2905 &testmode))
2906 testmode = 0; //default value 2916 testmode = 0; //default value
2907 } 2917 }
2908 2918
2909 if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "INTERFACE")) 2919 if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "INTERFACE"))
2910 { 2920 {
2911 if (GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-wlan", 2921 if (GNUNET_CONFIGURATION_get_value_string
2912 "INTERFACE", 2922 (env->cfg, "transport-wlan", "INTERFACE",
2913 &(plugin->interface)) != 2923 &(plugin->interface)) != GNUNET_YES)
2914 GNUNET_YES)
2915 { 2924 {
2916 libgnunet_plugin_transport_wlan_done (api); 2925 libgnunet_plugin_transport_wlan_done (api);
2917 return NULL; 2926 return NULL;