diff options
author | David Brodski <david@brodski.eu> | 2011-09-21 18:02:39 +0000 |
---|---|---|
committer | David Brodski <david@brodski.eu> | 2011-09-21 18:02:39 +0000 |
commit | 7e8a0c80d5c74bb682be8933c1dd1d71dcb2a099 (patch) | |
tree | 9ca4cf8845791a92b891cf45ebc33c3eccb28ca0 /src/transport/plugin_transport_wlan.c | |
parent | 4d01c2817b780a2d63e89cde8ed5a0400af8cbc2 (diff) | |
download | gnunet-7e8a0c80d5c74bb682be8933c1dd1d71dcb2a099.tar.gz gnunet-7e8a0c80d5c74bb682be8933c1dd1d71dcb2a099.zip |
Cleanup, fixed pretty_printer, fixed session not created when beacon received
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 71 |
1 files changed, 59 insertions, 12 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index adbf22aeb..1c65f5bcf 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -817,6 +817,11 @@ wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
817 | GNUNET_snprintf (ret, sizeof (ret), "%s Mac-Address %X:%X:%X:%X:%X:%X", | 817 | GNUNET_snprintf (ret, sizeof (ret), "%s Mac-Address %X:%X:%X:%X:%X:%X", |
818 | PROTOCOL_PREFIX, mac->mac[0], mac->mac[1], mac->mac[2], | 818 | PROTOCOL_PREFIX, mac->mac[0], mac->mac[1], mac->mac[2], |
819 | mac->mac[3], mac->mac[4], mac->mac[5]); | 819 | mac->mac[3], mac->mac[4], mac->mac[5]); |
820 | #if DEBUG_wlan | ||
821 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | ||
822 | "Func wlan_plugin_address_to_string made string: %s\n", | ||
823 | ret); | ||
824 | #endif | ||
820 | return ret; | 825 | return ret; |
821 | } | 826 | } |
822 | 827 | ||
@@ -1808,9 +1813,16 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
1808 | if (addrlen == 6) | 1813 | if (addrlen == 6) |
1809 | { | 1814 | { |
1810 | /* TODO check for bad addresses like multicast, broadcast, etc */ | 1815 | /* TODO check for bad addresses like multicast, broadcast, etc */ |
1816 | #if DEBUG_wlan | ||
1817 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | ||
1818 | "wlan_plugin_address_suggested got good address, size %u!\n", addrlen); | ||
1819 | #endif | ||
1811 | return GNUNET_OK; | 1820 | return GNUNET_OK; |
1812 | } | 1821 | } |
1813 | 1822 | #if DEBUG_wlan | |
1823 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | ||
1824 | "wlan_plugin_address_suggested got bad address, size %u!\n", addrlen); | ||
1825 | #endif | ||
1814 | return GNUNET_SYSERR; | 1826 | return GNUNET_SYSERR; |
1815 | } | 1827 | } |
1816 | 1828 | ||
@@ -2097,24 +2109,39 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type, | |||
2097 | GNUNET_TRANSPORT_AddressStringCallback asc, | 2109 | GNUNET_TRANSPORT_AddressStringCallback asc, |
2098 | void *asc_cls) | 2110 | void *asc_cls) |
2099 | { | 2111 | { |
2100 | char ret[92]; | 2112 | char *ret; |
2101 | const unsigned char *input; | 2113 | const unsigned char *input; |
2102 | 2114 | ||
2103 | //GNUNET_assert(cls !=NULL); | 2115 | //GNUNET_assert(cls !=NULL); |
2104 | if (addrlen != 6) | 2116 | if (addrlen != sizeof(struct MacAddress)) |
2105 | { | 2117 | { |
2106 | /* invalid address (MAC addresses have 6 bytes) */ GNUNET_break (0); | 2118 | /* invalid address (MAC addresses have 6 bytes) */ |
2107 | asc (asc_cls, NULL); | 2119 | //GNUNET_break (0); |
2120 | #if DEBUG_wlan | ||
2121 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | ||
2122 | "Func wlan_plugin_address_pretty_printer got size: %u, worng size!\n", | ||
2123 | addrlen); | ||
2124 | #endif | ||
2125 | asc(asc_cls, NULL); | ||
2108 | return; | 2126 | return; |
2109 | } | 2127 | } |
2110 | input = (const unsigned char *) addr; | 2128 | input = (const unsigned char *) addr; |
2111 | GNUNET_snprintf (ret, sizeof (ret), | 2129 | GNUNET_asprintf (&ret, |
2112 | "%s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 2130 | "Transport %s: %s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X",type, |
2113 | PROTOCOL_PREFIX, input[0], input[1], input[2], input[3], | 2131 | PROTOCOL_PREFIX, input[0], input[1], input[2], input[3], |
2114 | input[4], input[5]); | 2132 | input[4], input[5]); |
2115 | asc (asc_cls, ret); | 2133 | #if DEBUG_wlan |
2134 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | ||
2135 | "Func wlan_plugin_address_pretty_printer got size: %u, nummeric %u, type %s; made string: %s\n", | ||
2136 | addrlen, numeric, type, ret); | ||
2137 | #endif | ||
2138 | asc ( asc_cls, ret); | ||
2139 | //only one mac address per plugin | ||
2140 | asc ( asc_cls, NULL); | ||
2116 | } | 2141 | } |
2117 | 2142 | ||
2143 | |||
2144 | |||
2118 | /** | 2145 | /** |
2119 | * handels the data after all fragments are put together | 2146 | * handels the data after all fragments are put together |
2120 | * @param cls macendpoint this messages belongs to | 2147 | * @param cls macendpoint this messages belongs to |
@@ -2128,7 +2155,6 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2128 | struct WlanHeader *wlanheader; | 2155 | struct WlanHeader *wlanheader; |
2129 | struct Session *session; | 2156 | struct Session *session; |
2130 | 2157 | ||
2131 | //const char * tempmsg; | ||
2132 | const struct GNUNET_MessageHeader *temp_hdr; | 2158 | const struct GNUNET_MessageHeader *temp_hdr; |
2133 | struct GNUNET_PeerIdentity tmpsource; | 2159 | struct GNUNET_PeerIdentity tmpsource; |
2134 | int crc; | 2160 | int crc; |
@@ -2153,7 +2179,6 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2153 | 2179 | ||
2154 | session = search_session (plugin, endpoint, &wlanheader->source); | 2180 | session = search_session (plugin, endpoint, &wlanheader->source); |
2155 | 2181 | ||
2156 | //tempmsg = (char*) &wlanheader[1]; | ||
2157 | temp_hdr = (const struct GNUNET_MessageHeader *) &wlanheader[1]; | 2182 | temp_hdr = (const struct GNUNET_MessageHeader *) &wlanheader[1]; |
2158 | crc = ntohl (wlanheader->crc); | 2183 | crc = ntohl (wlanheader->crc); |
2159 | wlanheader->crc = 0; | 2184 | wlanheader->crc = 0; |
@@ -2313,6 +2338,7 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2313 | struct Plugin *plugin = cls; | 2338 | struct Plugin *plugin = cls; |
2314 | struct FragmentMessage *fm; | 2339 | struct FragmentMessage *fm; |
2315 | struct FragmentMessage *fm2; | 2340 | struct FragmentMessage *fm2; |
2341 | struct GNUNET_PeerIdentity tmpsource; | ||
2316 | 2342 | ||
2317 | //ADVERTISEMENT | 2343 | //ADVERTISEMENT |
2318 | if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_HELLO) | 2344 | if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_HELLO) |
@@ -2324,13 +2350,34 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2324 | 2350 | ||
2325 | #if DEBUG_wlan | 2351 | #if DEBUG_wlan |
2326 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2352 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2327 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT size: %u; %s\n", | 2353 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_HELLO size: %u; %s\n", |
2328 | ntohs (hdr->size), wlan_plugin_address_to_string (NULL, | 2354 | ntohs (hdr->size), wlan_plugin_address_to_string (NULL, |
2329 | session_light->addr. | 2355 | session_light->addr. |
2330 | mac, 6)); | 2356 | mac, 6)); |
2331 | #endif | 2357 | #endif |
2332 | 2358 | ||
2333 | plugin->env->receive(NULL,NULL,hdr, NULL, 0, NULL, NULL, 0); | 2359 | if (session_light->macendpoint == NULL) |
2360 | { | ||
2361 | session_light->macendpoint = | ||
2362 | get_macendpoint (plugin, &session_light->addr, GNUNET_YES); | ||
2363 | } | ||
2364 | |||
2365 | |||
2366 | if (GNUNET_HELLO_get_id | ||
2367 | ((const struct GNUNET_HELLO_Message *) hdr, | ||
2368 | &tmpsource) == GNUNET_OK) | ||
2369 | { | ||
2370 | session_light->session = create_session (plugin, session_light->macendpoint, &tmpsource); | ||
2371 | plugin->env->receive(plugin->env->cls,&session_light->session->target,hdr, NULL, 0, session_light->session, | ||
2372 | (const char *) &session_light->session->mac->addr, | ||
2373 | sizeof (session_light->session->mac->addr)); | ||
2374 | } | ||
2375 | else | ||
2376 | { | ||
2377 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, PLUGIN_LOG_NAME, | ||
2378 | "WLAN client not in session list and hello message is not okay\n"); | ||
2379 | return; | ||
2380 | } | ||
2334 | } | 2381 | } |
2335 | 2382 | ||
2336 | //FRAGMENT | 2383 | //FRAGMENT |