diff options
author | David Brodski <david@brodski.eu> | 2011-09-21 08:42:11 +0000 |
---|---|---|
committer | David Brodski <david@brodski.eu> | 2011-09-21 08:42:11 +0000 |
commit | e78e6833d9851df6538752cd5fc98097188e8cde (patch) | |
tree | aa1069a0576ae0b8d3afaadfe26a498e2e65d41d /src/transport/plugin_transport_wlan.c | |
parent | cfdf6645607118d33149a8b7a3b66fab4cae6ff3 (diff) | |
download | gnunet-e78e6833d9851df6538752cd5fc98097188e8cde.tar.gz gnunet-e78e6833d9851df6538752cd5fc98097188e8cde.zip |
Some Fixes
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 63ca85fe0..adbf22aeb 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -99,7 +99,7 @@ | |||
99 | /** | 99 | /** |
100 | * DEBUG switch | 100 | * DEBUG switch |
101 | */ | 101 | */ |
102 | #define DEBUG_wlan GNUNET_NO | 102 | #define DEBUG_wlan GNUNET_YES |
103 | #define DEBUG_wlan_retransmission GNUNET_NO | 103 | #define DEBUG_wlan_retransmission GNUNET_NO |
104 | #define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO | 104 | #define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO |
105 | #define DEBUG_wlan_msg_dump GNUNET_NO | 105 | #define DEBUG_wlan_msg_dump GNUNET_NO |
@@ -1407,8 +1407,7 @@ send_hello_beacon (struct Plugin *plugin) | |||
1407 | GNUNET_assert (sizeof (struct WlanHeader) + hallo_size <= WLAN_MTU); | 1407 | GNUNET_assert (sizeof (struct WlanHeader) + hallo_size <= WLAN_MTU); |
1408 | size = | 1408 | size = |
1409 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + | 1409 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + |
1410 | sizeof (struct ieee80211_frame) + sizeof (struct GNUNET_MessageHeader) + | 1410 | sizeof (struct ieee80211_frame) + hallo_size; |
1411 | hallo_size; | ||
1412 | 1411 | ||
1413 | msgheader = GNUNET_malloc (size); | 1412 | msgheader = GNUNET_malloc (size); |
1414 | msgheader->size = htons (size); | 1413 | msgheader->size = htons (size); |
@@ -1420,12 +1419,12 @@ send_hello_beacon (struct Plugin *plugin) | |||
1420 | getWlanHeader (ieeewlanheader, &bc_all_mac, plugin, size); | 1419 | getWlanHeader (ieeewlanheader, &bc_all_mac, plugin, size); |
1421 | 1420 | ||
1422 | msgheader2 = (struct GNUNET_MessageHeader *) &ieeewlanheader[1]; | 1421 | msgheader2 = (struct GNUNET_MessageHeader *) &ieeewlanheader[1]; |
1423 | msgheader2->size = | 1422 | /*msgheader2->size = |
1424 | htons (GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello) + | 1423 | htons (GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello) + |
1425 | sizeof (struct GNUNET_MessageHeader)); | 1424 | sizeof (struct GNUNET_MessageHeader)); |
1426 | 1425 | ||
1427 | msgheader2->type = htons (GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT); | 1426 | msgheader2->type = htons (GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT);*/ |
1428 | memcpy (&msgheader2[1], hello, hallo_size); | 1427 | memcpy (msgheader2, hello, hallo_size); |
1429 | 1428 | ||
1430 | bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, msgheader, size); | 1429 | bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, msgheader, size); |
1431 | 1430 | ||
@@ -2316,7 +2315,7 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2316 | struct FragmentMessage *fm2; | 2315 | struct FragmentMessage *fm2; |
2317 | 2316 | ||
2318 | //ADVERTISEMENT | 2317 | //ADVERTISEMENT |
2319 | if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT) | 2318 | if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_HELLO) |
2320 | { | 2319 | { |
2321 | 2320 | ||
2322 | //TODO better DOS protection, error handling | 2321 | //TODO better DOS protection, error handling |
@@ -2331,15 +2330,7 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2331 | mac, 6)); | 2330 | mac, 6)); |
2332 | #endif | 2331 | #endif |
2333 | 2332 | ||
2334 | if (session_light->macendpoint == NULL) | 2333 | plugin->env->receive(NULL,NULL,hdr, NULL, 0, NULL, NULL, 0); |
2335 | { | ||
2336 | session_light->macendpoint = | ||
2337 | get_macendpoint (plugin, &session_light->addr, GNUNET_NO); | ||
2338 | } | ||
2339 | GNUNET_assert (GNUNET_HELLO_get_id | ||
2340 | ((const struct GNUNET_HELLO_Message *) &hdr[1], | ||
2341 | &(session_light->session->target)) != GNUNET_SYSERR); | ||
2342 | |||
2343 | } | 2334 | } |
2344 | 2335 | ||
2345 | //FRAGMENT | 2336 | //FRAGMENT |
@@ -2581,7 +2572,7 @@ wlan_process_helper (void *cls, void *client, | |||
2581 | 2572 | ||
2582 | //call wlan_process_helper with the message inside, later with wlan: analyze signal | 2573 | //call wlan_process_helper with the message inside, later with wlan: analyze signal |
2583 | if (ntohs (hdr->size) < | 2574 | if (ntohs (hdr->size) < |
2584 | sizeof (struct ieee80211_frame) + sizeof (struct GNUNET_MessageHeader) + | 2575 | sizeof (struct ieee80211_frame) + 2*sizeof (struct GNUNET_MessageHeader) + |
2585 | sizeof (struct Radiotap_rx)) | 2576 | sizeof (struct Radiotap_rx)) |
2586 | { | 2577 | { |
2587 | #if DEBUG_wlan | 2578 | #if DEBUG_wlan |
@@ -2595,6 +2586,7 @@ wlan_process_helper (void *cls, void *client, | |||
2595 | /* FIXME: restart SUID process */ | 2586 | /* FIXME: restart SUID process */ |
2596 | return; | 2587 | return; |
2597 | } | 2588 | } |
2589 | |||
2598 | rxinfo = (struct Radiotap_rx *) &hdr[1]; | 2590 | rxinfo = (struct Radiotap_rx *) &hdr[1]; |
2599 | wlanIeeeHeader = (struct ieee80211_frame *) &rxinfo[1]; | 2591 | wlanIeeeHeader = (struct ieee80211_frame *) &rxinfo[1]; |
2600 | 2592 | ||
@@ -2633,8 +2625,18 @@ wlan_process_helper (void *cls, void *client, | |||
2633 | while (pos < datasize) | 2625 | while (pos < datasize) |
2634 | { | 2626 | { |
2635 | temp_hdr = (struct GNUNET_MessageHeader *) &wlanIeeeHeader[1] + pos; | 2627 | temp_hdr = (struct GNUNET_MessageHeader *) &wlanIeeeHeader[1] + pos; |
2636 | 2628 | if (ntohs(temp_hdr->size) <= datasize + pos) | |
2637 | wlan_data_helper (plugin, session_light, temp_hdr, rxinfo); | 2629 | { |
2630 | wlan_data_helper (plugin, session_light, temp_hdr, rxinfo); | ||
2631 | } | ||
2632 | else | ||
2633 | { | ||
2634 | #if DEBUG_wlan | ||
2635 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | ||
2636 | "Size of packet is too small; size: %u > size of packet: %u\n", | ||
2637 | ntohs(temp_hdr->size),datasize + pos); | ||
2638 | #endif | ||
2639 | } | ||
2638 | pos += ntohs (temp_hdr->size); | 2640 | pos += ntohs (temp_hdr->size); |
2639 | 2641 | ||
2640 | } | 2642 | } |