aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-04-01 08:53:19 +0000
committerChristian Grothoff <christian@grothoff.org>2011-04-01 08:53:19 +0000
commit18cfb2152564651d88f00ed7792b3549362da68a (patch)
treebc10815c50ce72ef522c433145f035a01400a0a9 /src/transport
parent64113c89817a0a4b885da241f1445fee977d1718 (diff)
downloadgnunet-18cfb2152564651d88f00ed7792b3549362da68a.tar.gz
gnunet-18cfb2152564651d88f00ed7792b3549362da68a.zip
fixes
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/Makefile.am2
-rw-r--r--src/transport/gnunet-service-transport.c4
-rw-r--r--src/transport/plugin_transport_wlan.c132
-rw-r--r--src/transport/plugin_transport_wlan.h2
4 files changed, 71 insertions, 69 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index ce1a8b8b5..dab362675 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -84,7 +84,7 @@ bin_SCRIPTS = \
84gnunet_nat_server_SOURCES = \ 84gnunet_nat_server_SOURCES = \
85 $(NATSERVER) 85 $(NATSERVER)
86 86
87 87
88gnunet_transport_wlan_helper_SOURCES = \ 88gnunet_transport_wlan_helper_SOURCES = \
89 wlan/radiotap-parser.c \ 89 wlan/radiotap-parser.c \
90 wlan/helper_common.c \ 90 wlan/helper_common.c \
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index e88d256bc..927e18d61 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -2248,7 +2248,8 @@ plugin_env_notify_address (void *cls,
2248 al = p->addresses; 2248 al = p->addresses;
2249 while (al != NULL) 2249 while (al != NULL)
2250 { 2250 {
2251 if ((addrlen == al->addrlen) && (0 == memcmp (addr, &al[1], addrlen))) 2251 if ( (addrlen == al->addrlen) &&
2252 (0 == memcmp (addr, &al[1], addrlen)) )
2252 { 2253 {
2253 al->expires = abex; 2254 al->expires = abex;
2254 update_addresses (p, GNUNET_NO); 2255 update_addresses (p, GNUNET_NO);
@@ -2256,7 +2257,6 @@ plugin_env_notify_address (void *cls,
2256 } 2257 }
2257 al = al->next; 2258 al = al->next;
2258 } 2259 }
2259
2260 al = GNUNET_malloc (sizeof (struct OwnAddressList) + addrlen); 2260 al = GNUNET_malloc (sizeof (struct OwnAddressList) + addrlen);
2261 al->next = p->addresses; 2261 al->next = p->addresses;
2262 p->addresses = al; 2262 p->addresses = al;
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 245f0d795..aaf5cb588 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -974,8 +974,6 @@ check_next_fragment_timeout(struct Plugin * const plugin)
974 struct FragmentMessage * fm; 974 struct FragmentMessage * fm;
975 struct GNUNET_TIME_Relative next_send; 975 struct GNUNET_TIME_Relative next_send;
976 976
977 next_send = GNUNET_TIME_absolute_get_remaining(plugin->beacon_time);
978
979 //cancel old task 977 //cancel old task
980 if (plugin->server_write_delay_task != GNUNET_SCHEDULER_NO_TASK) 978 if (plugin->server_write_delay_task != GNUNET_SCHEDULER_NO_TASK)
981 { 979 {
@@ -989,13 +987,17 @@ check_next_fragment_timeout(struct Plugin * const plugin)
989 //check if some acks are in the queue 987 //check if some acks are in the queue
990 if (plugin->ack_send_queue_head != NULL) 988 if (plugin->ack_send_queue_head != NULL)
991 { 989 {
992 next_send = GNUNET_TIME_relative_get_zero(); 990 next_send = GNUNET_TIME_UNIT_ZERO;
993 } 991 }
994 //check if there are some fragments in the queue 992 //check if there are some fragments in the queue
995 else if (fm != NULL) 993 else
996 { 994 {
997 next_send 995 next_send = GNUNET_TIME_absolute_get_remaining(plugin->beacon_time);
998 = GNUNET_TIME_relative_min(next_send, get_next_frag_timeout(fm)); 996 if (fm != NULL)
997 {
998 next_send
999 = GNUNET_TIME_relative_min(next_send, get_next_frag_timeout(fm));
1000 }
999 } 1001 }
1000 plugin->server_write_delay_task = GNUNET_SCHEDULER_add_delayed(next_send, 1002 plugin->server_write_delay_task = GNUNET_SCHEDULER_add_delayed(next_send,
1001 &delay_fragment_task, plugin); 1003 &delay_fragment_task, plugin);
@@ -2014,22 +2016,25 @@ wlan_plugin_address_suggested(void *cls, const void *addr, size_t addrlen)
2014 * @return string representing the same address 2016 * @return string representing the same address
2015 */ 2017 */
2016static const char* 2018static const char*
2017wlan_plugin_address_to_string(void *cls, const void *addr, size_t addrlen) 2019wlan_plugin_address_to_string (void *cls,
2020 const void *addr,
2021 size_t addrlen)
2018{ 2022{
2019 static char ret[40]; 2023 static char ret[40];
2020 const unsigned char * input; 2024 const struct MacAddress *mac;
2021 2025
2022 //GNUNET_assert(cls !=NULL); 2026 if (addrlen != sizeof (struct MacAddress))
2023 if (addrlen != 6)
2024 { 2027 {
2025 /* invalid address (MAC addresses have 6 bytes) */
2026 GNUNET_break (0); 2028 GNUNET_break (0);
2027 return NULL; 2029 return NULL;
2028 } 2030 }
2029 input = (const unsigned char*) addr; 2031 mac = addr;
2030 GNUNET_snprintf(ret, sizeof(ret), 2032 GNUNET_snprintf(ret, sizeof(ret),
2031 "%s Mac-Address %02X:%02X:%02X:%02X:%02X:%02X", PROTOCOL_PREFIX, 2033 "%s Mac-Address %X:%X:%X:%X:%X:%X",
2032 input[0], input[1], input[2], input[3], input[4], input[5]); 2034 PROTOCOL_PREFIX,
2035 mac->mac[0], mac->mac[1],
2036 mac->mac[2], mac->mac[3],
2037 mac->mac[4], mac->mac[5]);
2033 return ret; 2038 return ret;
2034} 2039}
2035 2040
@@ -2692,15 +2697,21 @@ wlan_data_helper(void *cls, struct Session_light * session_light,
2692 2697
2693} 2698}
2694 2699
2695char * 2700
2696macprinter(u_int8_t * mac) 2701const char *
2702macprinter(const u_int8_t * mac)
2697{ 2703{
2698 static char macstr[20]; 2704 static char macstr[20];
2699 sprintf(macstr, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", mac[0], mac[1], mac[2], 2705
2700 mac[3], mac[4], mac[5]); 2706 GNUNET_snprintf (macstr,
2707 sizeof (macstr),
2708 "%X:%X:%X:%X:%X:%X",
2709 mac[0], mac[1], mac[2],
2710 mac[3], mac[4], mac[5]);
2701 return macstr; 2711 return macstr;
2702} 2712}
2703 2713
2714
2704/** 2715/**
2705 * Function used for to process the data from the suid process 2716 * Function used for to process the data from the suid process
2706 * 2717 *
@@ -2708,10 +2719,10 @@ macprinter(u_int8_t * mac)
2708 * @param client client that send the data (not used) 2719 * @param client client that send the data (not used)
2709 * @param hdr header of the GNUNET_MessageHeader 2720 * @param hdr header of the GNUNET_MessageHeader
2710 */ 2721 */
2711
2712static void 2722static void
2713wlan_process_helper(void *cls, void *client, 2723wlan_process_helper (void *cls,
2714 const struct GNUNET_MessageHeader *hdr) 2724 void *client,
2725 const struct GNUNET_MessageHeader *hdr)
2715{ 2726{
2716 struct Plugin *plugin = cls; 2727 struct Plugin *plugin = cls;
2717 struct ieee80211_frame * wlanIeeeHeader = NULL; 2728 struct ieee80211_frame * wlanIeeeHeader = NULL;
@@ -2721,17 +2732,22 @@ wlan_process_helper(void *cls, void *client,
2721 int datasize = 0; 2732 int datasize = 0;
2722 int pos = 0; 2733 int pos = 0;
2723 2734
2724 if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA) 2735 switch (ntohs(hdr->type))
2725 { 2736 {
2737 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA:
2726#if DEBUG_wlan 2738#if DEBUG_wlan
2727 GNUNET_log( 2739 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2728 GNUNET_ERROR_TYPE_DEBUG, 2740 "Func wlan_process_helper got GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA size: %u\n",
2729 "Func wlan_process_helper got GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA size: %u\n", 2741 ntohs(hdr->size));
2730 ntohs(hdr->size));
2731#endif 2742#endif
2732 2743
2733 //call wlan_process_helper with the message inside, later with wlan: analyze signal 2744 //call wlan_process_helper with the message inside, later with wlan: analyze signal
2734 GNUNET_assert(ntohs(hdr->size) >= sizeof(struct ieee80211_frame) + sizeof(struct GNUNET_MessageHeader)); 2745 if (ntohs(hdr->size) < sizeof(struct ieee80211_frame) + sizeof(struct GNUNET_MessageHeader))
2746 {
2747 GNUNET_break (0);
2748 /* FIXME: restart SUID process */
2749 return;
2750 }
2735 wlanIeeeHeader = (struct ieee80211_frame *) &hdr[1]; 2751 wlanIeeeHeader = (struct ieee80211_frame *) &hdr[1];
2736 2752
2737 //process only if it is an broadcast or for this computer both with the gnunet bssid 2753 //process only if it is an broadcast or for this computer both with the gnunet bssid
@@ -2790,50 +2806,37 @@ wlan_process_helper(void *cls, void *client,
2790 wlanIeeeHeader->i_addr2)); 2806 wlanIeeeHeader->i_addr2));
2791#endif 2807#endif
2792 } 2808 }
2793 2809 break;
2794 } 2810 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL:
2795
2796 else if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL)
2797 {
2798
2799#if DEBUG_wlan
2800 GNUNET_log(
2801 GNUNET_ERROR_TYPE_DEBUG,
2802 "Func wlan_process_helper got GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL size: %u\n",
2803 ntohs(hdr->size));
2804#endif
2805
2806 //TODO more control messages 2811 //TODO more control messages
2807 //TODO use struct wlan_helper_control 2812 //TODO use struct wlan_helper_control
2808 if (ntohs(hdr->size) == sizeof(struct Wlan_Helper_Control_Message)) 2813 if (ntohs(hdr->size) != sizeof(struct Wlan_Helper_Control_Message))
2809 { 2814 {
2810 //plugin->mac_address = GNUNET_malloc(sizeof(struct MacAddress)); 2815 GNUNET_break (0);
2811 memcpy(&(plugin->mac_address), &hdr[1], sizeof(struct MacAddress)); 2816 /* FIXME: restart SUID process */
2812 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2817 return;
2813 "Notifying transport of address %s\n", 2818 }
2814 wlan_plugin_address_to_string(cls, &(plugin->mac_address), ntohs( 2819 memcpy (&plugin->mac_address,
2815 hdr->size) - sizeof(struct GNUNET_MessageHeader))); 2820 &hdr[1],
2816 plugin->env->notify_address(plugin->env->cls, "wlan", 2821 sizeof(struct MacAddress));
2817 &plugin->mac_address.mac, sizeof(struct MacAddress), 2822#if DEBUG_WLAN
2818 GNUNET_TIME_UNIT_FOREVER_REL); 2823 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2819 } 2824 "Received WLAN_HELPER_CONTROL message with transport of address %s\n",
2820 else 2825 wlan_plugin_address_to_string (cls,
2821 { 2826 &plugin->mac_address,
2822 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Wrong wlan mac address %s\n", 2827 sizeof (struct MacAddress)));
2823 macprinter(plugin->mac_address.mac)); 2828#endif
2824 } 2829 plugin->env->notify_address(plugin->env->cls, "wlan",
2825 2830 &plugin->mac_address, sizeof(struct MacAddress),
2826 } 2831 GNUNET_TIME_UNIT_FOREVER_REL);
2827 2832 break;
2828 else 2833 default:
2829 { 2834 GNUNET_break (0);
2830 // TODO Wrong data?
2831 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
2832 "WLAN helper packet has not the right type\n");
2833 return; 2835 return;
2834 } 2836 }
2835} 2837}
2836 2838
2839
2837/** 2840/**
2838 * We have been notified that wlan-helper has written something to stdout. 2841 * We have been notified that wlan-helper has written something to stdout.
2839 * Handle the output, then reschedule this function to be called again once 2842 * Handle the output, then reschedule this function to be called again once
@@ -2842,7 +2845,6 @@ wlan_process_helper(void *cls, void *client,
2842 * @param cls the plugin handle 2845 * @param cls the plugin handle
2843 * @param tc the scheduling context 2846 * @param tc the scheduling context
2844 */ 2847 */
2845
2846static void 2848static void
2847wlan_plugin_helper_read(void *cls, 2849wlan_plugin_helper_read(void *cls,
2848 const struct GNUNET_SCHEDULER_TaskContext *tc) 2850 const struct GNUNET_SCHEDULER_TaskContext *tc)
diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h
index 2f811809f..d03bacd82 100644
--- a/src/transport/plugin_transport_wlan.h
+++ b/src/transport/plugin_transport_wlan.h
@@ -40,7 +40,7 @@ struct MacAddress
40struct Wlan_Helper_Control_Message 40struct Wlan_Helper_Control_Message
41{ 41{
42 struct GNUNET_MessageHeader hdr; 42 struct GNUNET_MessageHeader hdr;
43 struct MacAddress mac ; 43 struct MacAddress mac;
44}; 44};
45 45
46 46