aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c283
1 files changed, 92 insertions, 191 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 1dc2713ed..7b709ce9d 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -1,27 +1,28 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2010 2011 Christian Grothoff (and other contributing authors) 3 (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 */ 19*/
20 20
21/** 21/**
22 * @file transport/plugin_transport_wlan.c 22 * @file transport/plugin_transport_wlan.c
23 * @brief transport plugin for wlan 23 * @brief transport plugin for wlan
24 * @author David Brodski 24 * @author David Brodski
25 * @author Christian Grothoff
25 */ 26 */
26 27
27//TODO split rx and tx structures for better handling 28//TODO split rx and tx structures for better handling
@@ -294,7 +295,7 @@ struct Finish_send
294/** 295/**
295 * Queue of sessions, for the general session queue and the pending session queue 296 * Queue of sessions, for the general session queue and the pending session queue
296 */ 297 */
297//TODO DOXIGEN 298//TODO DOXYGEN
298struct Sessionqueue 299struct Sessionqueue
299{ 300{
300 struct Sessionqueue *next; 301 struct Sessionqueue *next;
@@ -305,10 +306,11 @@ struct Sessionqueue
305#endif 306#endif
306}; 307};
307 308
309
308/** 310/**
309 * Queue of fragmented messages, for the sending queue of the plugin 311 * Queue of fragmented messages, for the sending queue of the plugin
310 */ 312 */
311//TODO DOXIGEN 313//TODO DOXYGEN
312struct FragmentMessage_queue 314struct FragmentMessage_queue
313{ 315{
314 struct FragmentMessage_queue *next; 316 struct FragmentMessage_queue *next;
@@ -316,21 +318,24 @@ struct FragmentMessage_queue
316 struct FragmentMessage *content; 318 struct FragmentMessage *content;
317}; 319};
318 320
321
319/** 322/**
320 * Queue for the fragments received 323 * Queue for the fragments received
321 */ 324 */
322//TODO DOXIGEN 325//TODO DOXYGEN
323struct Receive_Fragment_Queue 326struct Receive_Fragment_Queue
324{ 327{
325 struct Receive_Fragment_Queue *next; 328 struct Receive_Fragment_Queue *next;
326 struct Receive_Fragment_Queue *prev; 329 struct Receive_Fragment_Queue *prev;
330
327 uint16_t num; 331 uint16_t num;
328 const char *msg; 332 // const char *msg;
329 uint16_t size; 333 // uint16_t size;
330 struct Radiotap_rx rxinfo; 334 struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rx_msg;
331}; 335};
332 336
333//TODO DOXIGEN 337
338//TODO DOXYGEN
334struct MacEndpoint_id_fragment_triple 339struct MacEndpoint_id_fragment_triple
335{ 340{
336 struct MacEndpoint *endpoint; 341 struct MacEndpoint *endpoint;
@@ -338,7 +343,7 @@ struct MacEndpoint_id_fragment_triple
338 struct FragmentMessage *fm; 343 struct FragmentMessage *fm;
339}; 344};
340 345
341//TODO DOXIGEN 346//TODO DOXYGEN
342struct Plugin_Session_pair 347struct Plugin_Session_pair
343{ 348{
344 struct Plugin *plugin; 349 struct Plugin *plugin;
@@ -354,6 +359,9 @@ GNUNET_NETWORK_STRUCT_BEGIN
354struct WlanHeader 359struct WlanHeader
355{ 360{
356 361
362 /**
363 * Message type is GNUNET_MESSAGE_TYPE_WLAN_DATA.
364 */
357 struct GNUNET_MessageHeader header; 365 struct GNUNET_MessageHeader header;
358 366
359 /** 367 /**
@@ -457,26 +465,6 @@ struct AckSendQueue
457 465
458 466
459/** 467/**
460 * Session infos gathered from a messages
461 */
462struct Session_light
463{
464 /**
465 * the session this message belongs to
466 */
467 struct Session *session;
468 /**
469 * peer mac address
470 */
471 struct GNUNET_TRANSPORT_WLAN_MacAddress addr;
472
473 /**
474 * mac endpoint
475 */
476 struct MacEndpoint *macendpoint;
477};
478
479/**
480 * Session handle for connections. 468 * Session handle for connections.
481 */ 469 */
482struct Session 470struct Session
@@ -592,7 +580,7 @@ struct MacEndpoint
592 */ 580 */
593 int fragment_messages_out_count; 581 int fragment_messages_out_count;
594 582
595 //TODO DOXIGEN 583 //TODO DOXYGEN
596 uint8_t rate; 584 uint8_t rate;
597 uint16_t tx_power; 585 uint16_t tx_power;
598 uint8_t antenna; 586 uint8_t antenna;
@@ -2573,132 +2561,82 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
2573 * Function used for to process the data received from the wlan interface 2561 * Function used for to process the data received from the wlan interface
2574 * 2562 *
2575 * @param cls the plugin handle 2563 * @param cls the plugin handle
2576 * @param session_light pointer to the struct holding known informations
2577 * @param hdr hdr of the GNUNET_MessageHeader 2564 * @param hdr hdr of the GNUNET_MessageHeader
2578 * @param rxinfo pointer to the radiotap informations got with this packet FIXME: give ATS for info 2565 * @param rxinfo pointer to the radiotap informations got with this packet FIXME: give ATS info
2579 */ 2566 */
2580static void 2567static void
2581wlan_data_helper (void *cls, struct Session_light *session_light, 2568wlan_data_helper (void *cls,
2582 const struct GNUNET_MessageHeader *hdr, 2569 const struct GNUNET_MessageHeader *hdr,
2583 const struct Radiotap_rx *rxinfo) 2570 const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rxinfo)
2584{ 2571{
2585 struct Plugin *plugin = cls; 2572 struct Plugin *plugin = cls;
2586 struct FragmentMessage *fm; 2573 struct FragmentMessage *fm;
2587 struct FragmentMessage *fm2; 2574 struct FragmentMessage *fm2;
2588 struct GNUNET_PeerIdentity tmpsource; 2575 struct GNUNET_PeerIdentity tmpsource;
2576 struct MacEndpoint *macendpoint;
2577 struct Session *session;
2589 2578
2590 GNUNET_assert (plugin != NULL); 2579 // NOTE: session_light->addr = rxinfo->frame.addr2;
2580 macendpoint = get_macendpoint (plugin, &rxinfo->frame.addr2, GNUNET_YES);
2591 2581
2592 //ADVERTISEMENT 2582 switch (ntohs (hdr->type))
2593 if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_HELLO)
2594 { 2583 {
2595 2584 case GNUNET_MESSAGE_TYPE_HELLO:
2585 //ADVERTISEMENT
2596 //TODO better DOS protection, error handling 2586 //TODO better DOS protection, error handling
2597 //TODO test first than create session 2587 //TODO test first then create session
2598 GNUNET_assert (session_light != NULL);
2599
2600 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2601 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_HELLO size: %u; %s\n",
2602 ntohs (hdr->size), wlan_plugin_address_to_string (NULL,
2603 session_light->addr.
2604 mac, 6));
2605 if (session_light->macendpoint == NULL)
2606 {
2607 session_light->macendpoint =
2608 get_macendpoint (plugin, &session_light->addr, GNUNET_YES);
2609 }
2610
2611
2612 if (GNUNET_HELLO_get_id 2588 if (GNUNET_HELLO_get_id
2613 ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource) == GNUNET_OK) 2589 ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource) == GNUNET_OK)
2614 { 2590 {
2615 session_light->session = 2591 session = search_session (plugin, macendpoint, &tmpsource);
2616 search_session (plugin, session_light->macendpoint, &tmpsource); 2592 if (session == NULL)
2617 if (session_light->session == NULL)
2618 { 2593 {
2619 session_light->session = 2594 session = create_session (plugin, macendpoint, &tmpsource);
2620 create_session (plugin, session_light->macendpoint, &tmpsource);
2621 } 2595 }
2622 GNUNET_STATISTICS_update (plugin->env->stats, 2596 GNUNET_STATISTICS_update (plugin->env->stats,
2623 _("# wlan hello messages received"), 1, 2597 _("# wlan hello messages received"), 1,
2624 GNUNET_NO); 2598 GNUNET_NO);
2625 plugin->env->receive (plugin->env->cls, &session_light->session->target, 2599 plugin->env->receive (plugin->env->cls, &session->target,
2626 hdr, NULL, 0, session_light->session, 2600 hdr, NULL, 0, session,
2627 (const char *) &session_light->session->mac->addr, 2601 (const char *) &session->mac->addr,
2628 sizeof (session_light->session->mac->addr)); 2602 sizeof (session->mac->addr));
2629 } 2603 }
2630 else 2604 else
2631 { 2605 {
2632 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, PLUGIN_LOG_NAME, 2606 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, PLUGIN_LOG_NAME,
2633 "WLAN client not in session list and hello message is not okay\n"); 2607 "WLAN client not in session list and HELLO message is not okay\n");
2634 return; 2608 return;
2635 } 2609 }
2636 } 2610 break;
2637 2611 case GNUNET_MESSAGE_TYPE_FRAGMENT:
2638 //FRAGMENT 2612 macendpoint = get_macendpoint (plugin, &rxinfo->frame.addr2, GNUNET_YES);
2639
2640 else if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_FRAGMENT)
2641 {
2642
2643 GNUNET_assert (session_light != NULL);
2644 if (session_light->macendpoint == NULL)
2645 {
2646 session_light->macendpoint =
2647 get_macendpoint (plugin, &session_light->addr, GNUNET_YES);
2648 }
2649
2650 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2651 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT with size: %u; mac endpoint %p: %s\n",
2652 ntohs (hdr->size), session_light->macendpoint,
2653 wlan_plugin_address_to_string (NULL,
2654 session_light->addr.mac,
2655 6));
2656 GNUNET_STATISTICS_update (plugin->env->stats, 2613 GNUNET_STATISTICS_update (plugin->env->stats,
2657 _("# wlan fragments received"), 1, GNUNET_NO); 2614 _("# wlan fragments received"), 1, GNUNET_NO);
2658 int ret = 2615 int ret =
2659 GNUNET_DEFRAGMENT_process_fragment (session_light->macendpoint->defrag, 2616 GNUNET_DEFRAGMENT_process_fragment (macendpoint->defrag,
2660 hdr); 2617 hdr);
2661 2618
2662 if (ret == GNUNET_NO) 2619 if (ret == GNUNET_NO)
2663 { 2620 {
2664 session_light->macendpoint->dups++; 2621 macendpoint->dups++;
2665 } 2622 }
2666 else if (ret == GNUNET_OK) 2623 else if (ret == GNUNET_OK)
2667 { 2624 {
2668 session_light->macendpoint->fragc++; 2625 macendpoint->fragc++;
2669 } 2626 }
2670 set_next_send (plugin); 2627 set_next_send (plugin);
2671 2628 break;
2672 } 2629 case GNUNET_MESSAGE_TYPE_FRAGMENT_ACK:
2673 2630 if (NULL == macendpoint)
2674 //ACK
2675
2676 else if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_FRAGMENT_ACK)
2677 {
2678 GNUNET_assert (session_light != NULL);
2679 if (session_light->macendpoint == NULL)
2680 {
2681 session_light->macendpoint =
2682 get_macendpoint (plugin, &session_light->addr, GNUNET_NO);
2683 }
2684
2685 if (session_light->macendpoint == NULL)
2686 { 2631 {
2687 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2632 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2688 "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n", 2633 "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n",
2689 ntohs (hdr->size), wlan_plugin_address_to_string (NULL, 2634 ntohs (hdr->size), wlan_plugin_address_to_string (NULL,
2690 session_light->addr.mac, 2635 &rxinfo->frame.addr2.mac,
2691 6)); 2636 6));
2692 return; 2637 return;
2693 } 2638 }
2694 2639 fm = macendpoint->sending_messages_head;
2695 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2696 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; mac endpoint: %p; %s\n",
2697 ntohs (hdr->size), session_light->macendpoint,
2698 wlan_plugin_address_to_string (NULL,
2699 session_light->addr.mac,
2700 6));
2701 fm = session_light->macendpoint->sending_messages_head;
2702 while (fm != NULL) 2640 while (fm != NULL)
2703 { 2641 {
2704 fm2 = fm->next; 2642 fm2 = fm->next;
@@ -2710,9 +2648,9 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2710 { 2648 {
2711 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2649 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2712 "Got last ack, finished fragment message %p\n", fm); 2650 "Got last ack, finished fragment message %p\n", fm);
2713 session_light->macendpoint->acks++; 2651 macendpoint->acks++;
2714 fm->session->last_activity = GNUNET_TIME_absolute_get (); 2652 fm->session->last_activity = GNUNET_TIME_absolute_get ();
2715 session_light->macendpoint->last_activity = fm->session->last_activity; 2653 macendpoint->last_activity = fm->session->last_activity;
2716 free_fragment_message (plugin, fm); 2654 free_fragment_message (plugin, fm);
2717 check_fragment_queue (plugin); 2655 check_fragment_queue (plugin);
2718 return; 2656 return;
@@ -2721,24 +2659,15 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2721 { 2659 {
2722 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2660 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2723 "Got ack for: %p\n", fm); 2661 "Got ack for: %p\n", fm);
2724 session_light->macendpoint->acks++; 2662 macendpoint->acks++;
2725 return; 2663 return;
2726 } 2664 }
2727 if (ret == GNUNET_SYSERR)
2728 {
2729
2730 }
2731
2732 fm = fm2; 2665 fm = fm2;
2733 } 2666 }
2734
2735 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2667 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2736 "WLAN fragment not in fragment list\n"); 2668 "WLAN fragment not in fragment list\n");
2737 return; 2669 return;
2738 2670 default:
2739 }
2740 else
2741 {
2742 // TODO Wrong data? 2671 // TODO Wrong data?
2743 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, 2672 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
2744 "WLAN packet inside the WLAN helper packet has not the right type: %u size: %u\n", 2673 "WLAN packet inside the WLAN helper packet has not the right type: %u size: %u\n",
@@ -2746,12 +2675,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2746 GNUNET_break (0); 2675 GNUNET_break (0);
2747 return; 2676 return;
2748 } 2677 }
2749
2750#if 0
2751 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2678 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2752 "Helper finished\n"); 2679 "Helper finished\n");
2753#endif
2754
2755} 2680}
2756 2681
2757/** 2682/**
@@ -2853,11 +2778,10 @@ wlan_process_helper (void *cls, void *client,
2853 const struct GNUNET_MessageHeader *hdr) 2778 const struct GNUNET_MessageHeader *hdr)
2854{ 2779{
2855 struct Plugin *plugin = cls; 2780 struct Plugin *plugin = cls;
2856 const struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *wlanIeeeHeader; 2781 const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rxinfo;
2857 struct Session_light *session_light = NULL; 2782 const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *cm;
2858 const struct Radiotap_rx *rxinfo;
2859 const struct GNUNET_MessageHeader *temp_hdr = NULL; 2783 const struct GNUNET_MessageHeader *temp_hdr = NULL;
2860 2784 const char *end;
2861 int datasize = 0; 2785 int datasize = 0;
2862 int pos; 2786 int pos;
2863 2787
@@ -2872,96 +2796,79 @@ wlan_process_helper (void *cls, void *client,
2872 _("# wlan WLAN_HELPER_DATA received"), 1, 2796 _("# wlan WLAN_HELPER_DATA received"), 1,
2873 GNUNET_NO); 2797 GNUNET_NO);
2874 //call wlan_process_helper with the message inside, later with wlan: analyze signal 2798 //call wlan_process_helper with the message inside, later with wlan: analyze signal
2875 if (ntohs (hdr->size) < 2799 if (ntohs (hdr->size) < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage))
2876 sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) +
2877 2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx))
2878 { 2800 {
2879 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2801 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2880 "Size of packet is too small; size: %u min size: %u\n", 2802 "Size of packet is too small; size: %u\n",
2881 ntohs (hdr->size), 2803 ntohs (hdr->size));
2882 sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) + 2804 GNUNET_break (0);
2883 sizeof (struct GNUNET_MessageHeader));
2884 //GNUNET_break (0);
2885 /* FIXME: restart SUID process */ 2805 /* FIXME: restart SUID process */
2886 return; 2806 return;
2887 } 2807 }
2888 2808
2889 rxinfo = (const struct Radiotap_rx *) &hdr[1]; 2809 rxinfo = (const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) hdr;
2890 wlanIeeeHeader = (const struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) &rxinfo[1];
2891
2892 //process only if it is an broadcast or for this computer both with the gnunet bssid 2810 //process only if it is an broadcast or for this computer both with the gnunet bssid
2893
2894 //check for bssid 2811 //check for bssid
2895 if (memcmp 2812 if (memcmp
2896 (&wlanIeeeHeader->addr3, &mac_bssid_gnunet, 2813 (&rxinfo->frame.addr3, &mac_bssid_gnunet,
2897 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) 2814 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)
2898 { 2815 {
2899 //check for broadcast or mac 2816 //check for broadcast or mac
2900 if ((memcmp 2817 if ((memcmp
2901 (&wlanIeeeHeader->addr1, &bc_all_mac, 2818 (&rxinfo->frame.addr1, &bc_all_mac,
2902 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) || 2819 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) ||
2903 (memcmp 2820 (memcmp
2904 (&wlanIeeeHeader->addr1, &(plugin->mac_address), 2821 (&rxinfo->frame.addr1, &plugin->mac_address,
2905 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)) 2822 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0))
2906 { 2823 {
2907 //if packet is from us return 2824 //if packet is from us return
2908 if ((memcmp 2825 if ((memcmp
2909 (&wlanIeeeHeader->addr2, &(plugin->mac_address), 2826 (&rxinfo->frame.addr2, &plugin->mac_address,
2910 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)) 2827 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0))
2911 { 2828 {
2829 /* not for us */
2912 return; 2830 return;
2913 } 2831 }
2914 // process the inner data 2832 datasize = ntohs (hdr->size) - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage);
2915
2916
2917 datasize =
2918 ntohs (hdr->size) - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) -
2919 sizeof (struct GNUNET_MessageHeader) - sizeof (struct Radiotap_rx);
2920
2921 session_light = GNUNET_malloc (sizeof (struct Session_light));
2922 session_light->addr = wlanIeeeHeader->addr2;
2923 //session_light->session = search_session(plugin,session_light->addr);
2924 GNUNET_STATISTICS_update (plugin->env->stats, 2833 GNUNET_STATISTICS_update (plugin->env->stats,
2925 _("# wlan messages for this client received"), 2834 _("# wlan messages for this client received"),
2926 1, GNUNET_NO); 2835 1, GNUNET_NO);
2927 2836 // FIXME: this is a job for SERVER_mst --
2837 // what we are doing here is not good for alignment...
2928 pos = 0; 2838 pos = 0;
2929 while (pos < datasize) 2839 end = (const char*) &rxinfo[1];
2840 while (pos < datasize - sizeof (struct GNUNET_MessageHeader))
2930 { 2841 {
2931 temp_hdr = (struct GNUNET_MessageHeader *) &wlanIeeeHeader[1] + pos; 2842 temp_hdr = (struct GNUNET_MessageHeader *) &end[pos];
2932 if (ntohs (temp_hdr->size) <= datasize + pos) 2843 if (ntohs (temp_hdr->size) <= datasize - pos)
2933 { 2844 {
2934 GNUNET_STATISTICS_update (plugin->env->stats, 2845 GNUNET_STATISTICS_update (plugin->env->stats,
2935 _ 2846 _
2936 ("# wlan messages inside WLAN_HELPER_DATA received"), 2847 ("# wlan messages inside WLAN_HELPER_DATA received"),
2937 1, GNUNET_NO); 2848 1, GNUNET_NO);
2938 wlan_data_helper (plugin, session_light, temp_hdr, rxinfo); 2849 wlan_data_helper (plugin, temp_hdr, rxinfo);
2939 } 2850 }
2940 else 2851 else
2941 { 2852 {
2942 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2853 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2943 "Size of packet is too small; size: %u > size of packet: %u\n", 2854 "Size of packet is too small; size: %u > size of packet: %u\n",
2944 ntohs (temp_hdr->size), datasize + pos); 2855 ntohs (temp_hdr->size), datasize - pos);
2945 } 2856 }
2946 pos += ntohs (temp_hdr->size); 2857 pos += ntohs (temp_hdr->size);
2947
2948 } 2858 }
2949
2950 //clean up
2951 GNUNET_free (session_light);
2952 } 2859 }
2953 else 2860 else
2954 { 2861 {
2955 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2862 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2956 "Func wlan_process_helper got wrong MAC: %s\n", 2863 "Func wlan_process_helper got wrong MAC: %s\n",
2957 macprinter (&wlanIeeeHeader->addr1)); 2864 macprinter (&rxinfo->frame.addr1));
2958 } 2865 }
2959 } 2866 }
2960 else 2867 else
2961 { 2868 {
2962 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2869 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2963 "Func wlan_process_helper got wrong BSSID: %s\n", 2870 "Func wlan_process_helper got wrong BSSID: %s\n",
2964 macprinter (&wlanIeeeHeader->addr2)); 2871 macprinter (&rxinfo->frame.addr2));
2965 } 2872 }
2966 break; 2873 break;
2967 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: 2874 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL:
@@ -2972,7 +2879,8 @@ wlan_process_helper (void *cls, void *client,
2972 /* FIXME: restart SUID process */ 2879 /* FIXME: restart SUID process */
2973 return; 2880 return;
2974 } 2881 }
2975 memcpy (&plugin->mac_address, &hdr[1], sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); 2882 cm = (const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *) hdr;
2883 plugin->mac_address = cm->mac;
2976 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2884 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2977 "Received WLAN_HELPER_CONTROL message with transport of address %s\n", 2885 "Received WLAN_HELPER_CONTROL message with transport of address %s\n",
2978 wlan_plugin_address_to_string (cls, &plugin->mac_address, 2886 wlan_plugin_address_to_string (cls, &plugin->mac_address,
@@ -2985,10 +2893,6 @@ wlan_process_helper (void *cls, void *client,
2985 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2893 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2986 "Func wlan_process_helper got unknown message with number %u, size %u\n", 2894 "Func wlan_process_helper got unknown message with number %u, size %u\n",
2987 ntohs (hdr->type), ntohs (hdr->size)); 2895 ntohs (hdr->type), ntohs (hdr->size));
2988
2989#if DEBUG_WLAN > 1
2990 hexdump (hdr, GNUNET_MIN (ntohs (hdr->size), 256));
2991#endif
2992 GNUNET_break (0); 2896 GNUNET_break (0);
2993 return; 2897 return;
2994 } 2898 }
@@ -3000,7 +2904,6 @@ wlan_process_helper (void *cls, void *client,
3000 * Exit point from the plugin. 2904 * Exit point from the plugin.
3001 * @param cls pointer to the api struct 2905 * @param cls pointer to the api struct
3002 */ 2906 */
3003
3004//FIXME cleanup 2907//FIXME cleanup
3005void * 2908void *
3006libgnunet_plugin_transport_wlan_done (void *cls) 2909libgnunet_plugin_transport_wlan_done (void *cls)
@@ -3029,8 +2932,6 @@ libgnunet_plugin_transport_wlan_done (void *cls)
3029 endpoint = endpoint_next; 2932 endpoint = endpoint_next;
3030 2933
3031 } 2934 }
3032
3033
3034 if (plugin->suid_tokenizer != NULL) 2935 if (plugin->suid_tokenizer != NULL)
3035 GNUNET_SERVER_mst_destroy (plugin->suid_tokenizer); 2936 GNUNET_SERVER_mst_destroy (plugin->suid_tokenizer);
3036 2937