diff options
author | David Brodski <david@brodski.eu> | 2011-03-01 09:27:20 +0000 |
---|---|---|
committer | David Brodski <david@brodski.eu> | 2011-03-01 09:27:20 +0000 |
commit | 8d0a6978280aaa039f48c1d59969d2ea0d3d1e5b (patch) | |
tree | 6f2d5d5379fd2bbb8f478147b87e7c06e1d6f635 /src/transport/plugin_transport_wlan.c | |
parent | 5d275099239802e3c79f6685dd6cda3104d2624a (diff) | |
download | gnunet-8d0a6978280aaa039f48c1d59969d2ea0d3d1e5b.tar.gz gnunet-8d0a6978280aaa039f48c1d59969d2ea0d3d1e5b.zip |
Spelling errors corrected and some minor fixes
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 78 |
1 files changed, 48 insertions, 30 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index c0e062aa1..bb55058ff 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -599,6 +599,9 @@ wlan_data_massage_handler(struct Plugin * plugin, | |||
599 | struct Session_light * session_light, | 599 | struct Session_light * session_light, |
600 | const struct GNUNET_MessageHeader * hdr); | 600 | const struct GNUNET_MessageHeader * hdr); |
601 | 601 | ||
602 | static const char * | ||
603 | wlan_plugin_address_to_string(void *cls, const void *addr, size_t addrlen); | ||
604 | |||
602 | /** | 605 | /** |
603 | * get the next message number, at the moment just a random one | 606 | * get the next message number, at the moment just a random one |
604 | * @return returns the next valid message-number for sending packets | 607 | * @return returns the next valid message-number for sending packets |
@@ -674,6 +677,12 @@ create_session(struct Plugin *plugin, const uint8_t * addr) | |||
674 | queue->content->rec_size = NO_MESSAGE_OR_MESSAGE_FINISHED; | 677 | queue->content->rec_size = NO_MESSAGE_OR_MESSAGE_FINISHED; |
675 | 678 | ||
676 | plugin->session_count++; | 679 | plugin->session_count++; |
680 | |||
681 | #if DEBUG_wlan | ||
682 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
683 | "New session %p with %s\n", queue->content ,wlan_plugin_address_to_string(NULL,addr, 6)); | ||
684 | #endif | ||
685 | |||
677 | return queue->content; | 686 | return queue->content; |
678 | } | 687 | } |
679 | 688 | ||
@@ -1030,13 +1039,13 @@ check_fragment_queue(struct Plugin * plugin) | |||
1030 | pm->transmit_cont(pm->transmit_cont_cls, &pid, | 1039 | pm->transmit_cont(pm->transmit_cont_cls, &pid, |
1031 | GNUNET_OK); | 1040 | GNUNET_OK); |
1032 | #if DEBUG_wlan | 1041 | #if DEBUG_wlan |
1033 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "called pm->transmit_cont\n"); | 1042 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "called pm->transmit_cont for %p\n", session); |
1034 | #endif | 1043 | #endif |
1035 | } | 1044 | } |
1036 | else | 1045 | else |
1037 | { | 1046 | { |
1038 | #if DEBUG_wlan | 1047 | #if DEBUG_wlan |
1039 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "no pm->transmit_cont\n"); | 1048 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "no pm->transmit_cont for %p\n", session); |
1040 | #endif | 1049 | #endif |
1041 | } | 1050 | } |
1042 | GNUNET_free(pm); | 1051 | GNUNET_free(pm); |
@@ -1753,7 +1762,7 @@ wlan_plugin_address_pretty_printer(void *cls, const char *type, | |||
1753 | char ret[92]; | 1762 | char ret[92]; |
1754 | const unsigned char * input; | 1763 | const unsigned char * input; |
1755 | 1764 | ||
1756 | GNUNET_assert(cls !=NULL); | 1765 | //GNUNET_assert(cls !=NULL); |
1757 | if (addrlen != 6) | 1766 | if (addrlen != 6) |
1758 | { | 1767 | { |
1759 | /* invalid address (MAC addresses have 6 bytes) */ | 1768 | /* invalid address (MAC addresses have 6 bytes) */ |
@@ -1762,7 +1771,7 @@ wlan_plugin_address_pretty_printer(void *cls, const char *type, | |||
1762 | return; | 1771 | return; |
1763 | } | 1772 | } |
1764 | input = (const unsigned char*) addr; | 1773 | input = (const unsigned char*) addr; |
1765 | GNUNET_snprintf(ret, sizeof(ret), "%s Mac-Adress %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 1774 | GNUNET_snprintf(ret, sizeof(ret), "%s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
1766 | PROTOCOL_PREFIX, input[0], input[1], input[2], input[3], input[4], | 1775 | PROTOCOL_PREFIX, input[0], input[1], input[2], input[3], input[4], |
1767 | input[5]); | 1776 | input[5]); |
1768 | asc(asc_cls, ret); | 1777 | asc(asc_cls, ret); |
@@ -1791,7 +1800,7 @@ wlan_plugin_address_suggested(void *cls, const void *addr, size_t addrlen) | |||
1791 | 1800 | ||
1792 | GNUNET_assert(cls !=NULL); | 1801 | GNUNET_assert(cls !=NULL); |
1793 | //FIXME mitm is not checked | 1802 | //FIXME mitm is not checked |
1794 | //Mac Adress has 6 bytes | 1803 | //Mac Address has 6 bytes |
1795 | if (addrlen == 6) | 1804 | if (addrlen == 6) |
1796 | { | 1805 | { |
1797 | /* TODO check for bad addresses like multicast, broadcast, etc */ | 1806 | /* TODO check for bad addresses like multicast, broadcast, etc */ |
@@ -1822,7 +1831,7 @@ wlan_plugin_address_to_string(void *cls, const void *addr, size_t addrlen) | |||
1822 | static char ret[40]; | 1831 | static char ret[40]; |
1823 | const unsigned char * input; | 1832 | const unsigned char * input; |
1824 | 1833 | ||
1825 | GNUNET_assert(cls !=NULL); | 1834 | //GNUNET_assert(cls !=NULL); |
1826 | if (addrlen != 6) | 1835 | if (addrlen != 6) |
1827 | { | 1836 | { |
1828 | /* invalid address (MAC addresses have 6 bytes) */ | 1837 | /* invalid address (MAC addresses have 6 bytes) */ |
@@ -1830,7 +1839,7 @@ wlan_plugin_address_to_string(void *cls, const void *addr, size_t addrlen) | |||
1830 | return NULL; | 1839 | return NULL; |
1831 | } | 1840 | } |
1832 | input = (const unsigned char*) addr; | 1841 | input = (const unsigned char*) addr; |
1833 | GNUNET_snprintf(ret, sizeof(ret), "%s Mac-Adress %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 1842 | GNUNET_snprintf(ret, sizeof(ret), "%s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
1834 | PROTOCOL_PREFIX, input[0], input[1], input[2], input[3], input[4], | 1843 | PROTOCOL_PREFIX, input[0], input[1], input[2], input[3], input[4], |
1835 | input[5]); | 1844 | input[5]); |
1836 | return ret; | 1845 | return ret; |
@@ -1960,7 +1969,7 @@ check_rec_finished_msg(struct Plugin* plugin, | |||
1960 | 1969 | ||
1961 | #if DEBUG_wlan | 1970 | #if DEBUG_wlan |
1962 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1971 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1963 | "check_rec_finished_msg: A message with fragments is complete\n"); | 1972 | "check_rec_finished_msg: A message for %p is complete\n", session); |
1964 | #endif | 1973 | #endif |
1965 | 1974 | ||
1966 | //copy fragments together | 1975 | //copy fragments together |
@@ -2082,9 +2091,9 @@ wlan_data_massage_handler(struct Plugin * plugin, | |||
2082 | distance[1].value = htonl(0); | 2091 | distance[1].value = htonl(0); |
2083 | 2092 | ||
2084 | #if DEBUG_wlan | 2093 | #if DEBUG_wlan |
2085 | GNUNET_log( | 2094 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2086 | GNUNET_ERROR_TYPE_DEBUG, | 2095 | "Calling plugin->env->receive for session %p; %s\n", session, |
2087 | "Calling plugin->env->receive\n"); | 2096 | wlan_plugin_address_to_string(NULL, session->addr, 6)); |
2088 | #endif | 2097 | #endif |
2089 | plugin->env->receive(plugin->env->cls, &(session->target), temp_hdr, | 2098 | plugin->env->receive(plugin->env->cls, &(session->target), temp_hdr, |
2090 | (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2, | 2099 | (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2, |
@@ -2152,15 +2161,18 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2152 | //ADVERTISEMENT | 2161 | //ADVERTISEMENT |
2153 | if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT) | 2162 | if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT) |
2154 | { | 2163 | { |
2164 | |||
2165 | //TODO better DOS protection, error handling | ||
2166 | //TODO test first than create session | ||
2167 | GNUNET_assert(session_light != NULL); | ||
2168 | |||
2155 | #if DEBUG_wlan | 2169 | #if DEBUG_wlan |
2156 | GNUNET_log( | 2170 | GNUNET_log( |
2157 | GNUNET_ERROR_TYPE_DEBUG, | 2171 | GNUNET_ERROR_TYPE_DEBUG, |
2158 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT size: %u\n", | 2172 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT size: %u; %s\n", |
2159 | ntohs(hdr->size)); | 2173 | ntohs(hdr->size), wlan_plugin_address_to_string(NULL,session_light->addr, 6)); |
2160 | #endif | 2174 | #endif |
2161 | 2175 | ||
2162 | //TODO better DOS protection, error handling | ||
2163 | GNUNET_assert(session_light != NULL); | ||
2164 | if (session_light->session == NULL) | 2176 | if (session_light->session == NULL) |
2165 | { | 2177 | { |
2166 | session_light->session = get_Session(plugin, session_light->addr); | 2178 | session_light->session = get_Session(plugin, session_light->addr); |
@@ -2188,9 +2200,9 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2188 | #if DEBUG_wlan | 2200 | #if DEBUG_wlan |
2189 | GNUNET_log( | 2201 | GNUNET_log( |
2190 | GNUNET_ERROR_TYPE_DEBUG, | 2202 | GNUNET_ERROR_TYPE_DEBUG, |
2191 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT with message_id %u with fragment number %i, size: %u\n", | 2203 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT with message_id %u with fragment number %i, size: %u; %s\n", |
2192 | ntohl(fh->message_id), ntohs(fh->fragment_off_or_num), ntohs( | 2204 | ntohl(fh->message_id), ntohs(fh->fragment_off_or_num), ntohs( |
2193 | hdr->size)); | 2205 | hdr->size), wlan_plugin_address_to_string(NULL,session_light->addr, 6)); |
2194 | #endif | 2206 | #endif |
2195 | 2207 | ||
2196 | if (getcrc16(tempmsg, ntohs(fh->header.size)) != ntohs(fh->message_crc)) | 2208 | if (getcrc16(tempmsg, ntohs(fh->header.size)) != ntohs(fh->message_crc)) |
@@ -2272,8 +2284,8 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2272 | #if DEBUG_wlan | 2284 | #if DEBUG_wlan |
2273 | GNUNET_log( | 2285 | GNUNET_log( |
2274 | GNUNET_ERROR_TYPE_DEBUG, | 2286 | GNUNET_ERROR_TYPE_DEBUG, |
2275 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT_ACK size: %u\n", | 2287 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT_ACK size: %u; %s\n", |
2276 | ntohs(hdr->size)); | 2288 | ntohs(hdr->size), wlan_plugin_address_to_string(NULL,session_light->addr, 6)); |
2277 | #endif | 2289 | #endif |
2278 | 2290 | ||
2279 | GNUNET_assert(session_light != NULL); | 2291 | GNUNET_assert(session_light != NULL); |
@@ -2367,8 +2379,8 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2367 | * Function used for to process the data from the suid process | 2379 | * Function used for to process the data from the suid process |
2368 | * | 2380 | * |
2369 | * @param cls the plugin handle | 2381 | * @param cls the plugin handle |
2370 | * @param client which send the data (not used) | 2382 | * @param client client that send the data (not used) |
2371 | * @param hdr of the GNUNET_MessageHeader | 2383 | * @param hdr header of the GNUNET_MessageHeader |
2372 | */ | 2384 | */ |
2373 | 2385 | ||
2374 | static void | 2386 | static void |
@@ -2395,13 +2407,6 @@ wlan_process_helper(void *cls, void *client, | |||
2395 | //call wlan_process_helper with the message inside, later with wlan: analyze signal | 2407 | //call wlan_process_helper with the message inside, later with wlan: analyze signal |
2396 | GNUNET_assert(ntohs(hdr->size) >= sizeof(struct IeeeHeader) + sizeof(struct GNUNET_MessageHeader)); | 2408 | GNUNET_assert(ntohs(hdr->size) >= sizeof(struct IeeeHeader) + sizeof(struct GNUNET_MessageHeader)); |
2397 | wlanIeeeHeader = (struct IeeeHeader *) &hdr[1]; | 2409 | wlanIeeeHeader = (struct IeeeHeader *) &hdr[1]; |
2398 | datasize = ntohs(hdr->size) - sizeof(struct IeeeHeader) | ||
2399 | - sizeof(struct GNUNET_MessageHeader); | ||
2400 | |||
2401 | session_light = GNUNET_malloc(sizeof(struct Session_light)); | ||
2402 | memcpy(session_light->addr, &(wlanIeeeHeader->mac3), | ||
2403 | sizeof(struct MacAddress)); | ||
2404 | session_light->session = search_session(plugin, session_light->addr); | ||
2405 | 2410 | ||
2406 | //process only if it is an broadcast or for this computer both with the gnunet bssid | 2411 | //process only if it is an broadcast or for this computer both with the gnunet bssid |
2407 | 2412 | ||
@@ -2415,7 +2420,18 @@ wlan_process_helper(void *cls, void *client, | |||
2415 | &(wlanIeeeHeader->mac1), &(plugin->mac_address), | 2420 | &(wlanIeeeHeader->mac1), &(plugin->mac_address), |
2416 | sizeof(struct MacAddress)) == 0) | 2421 | sizeof(struct MacAddress)) == 0) |
2417 | { | 2422 | { |
2423 | |||
2418 | // process the inner data | 2424 | // process the inner data |
2425 | |||
2426 | |||
2427 | datasize = ntohs(hdr->size) - sizeof(struct IeeeHeader) | ||
2428 | - sizeof(struct GNUNET_MessageHeader); | ||
2429 | |||
2430 | session_light = GNUNET_malloc(sizeof(struct Session_light)); | ||
2431 | memcpy(session_light->addr, &(wlanIeeeHeader->mac3), | ||
2432 | sizeof(struct MacAddress)); | ||
2433 | //session_light->session = search_session(plugin,session_light->addr); | ||
2434 | |||
2419 | pos = 0; | 2435 | pos = 0; |
2420 | temp_hdr = (struct GNUNET_MessageHeader *) &wlanIeeeHeader[1]; | 2436 | temp_hdr = (struct GNUNET_MessageHeader *) &wlanIeeeHeader[1]; |
2421 | while (pos < datasize) | 2437 | while (pos < datasize) |
@@ -2427,6 +2443,9 @@ wlan_process_helper(void *cls, void *client, | |||
2427 | pos += ntohs(temp_hdr->size); | 2443 | pos += ntohs(temp_hdr->size); |
2428 | 2444 | ||
2429 | } | 2445 | } |
2446 | |||
2447 | //clean up | ||
2448 | GNUNET_free(session_light); | ||
2430 | } | 2449 | } |
2431 | else | 2450 | else |
2432 | { | 2451 | { |
@@ -2446,8 +2465,7 @@ wlan_process_helper(void *cls, void *client, | |||
2446 | #endif | 2465 | #endif |
2447 | } | 2466 | } |
2448 | 2467 | ||
2449 | //clean up | 2468 | |
2450 | GNUNET_free(session_light); | ||
2451 | 2469 | ||
2452 | } | 2470 | } |
2453 | 2471 | ||