diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-02-28 16:19:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-02-28 16:19:04 +0000 |
commit | 0e90e90f510428a7d3ed92add2cb4bf93595a6cf (patch) | |
tree | c24132b58679740328cc98e128602fc85f01d5c5 /src/transport | |
parent | 2f4b20ea2c334ce412dbc1fe29253cc110765205 (diff) | |
download | gnunet-0e90e90f510428a7d3ed92add2cb4bf93595a6cf.tar.gz gnunet-0e90e90f510428a7d3ed92add2cb4bf93595a6cf.zip |
-some code cleanup
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-helper-transport-wlan-dummy.c | 6 | ||||
-rw-r--r-- | src/transport/gnunet-helper-transport-wlan.c | 324 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 183 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.h | 17 |
4 files changed, 219 insertions, 311 deletions
diff --git a/src/transport/gnunet-helper-transport-wlan-dummy.c b/src/transport/gnunet-helper-transport-wlan-dummy.c index c18216b1c..6fff758c5 100644 --- a/src/transport/gnunet-helper-transport-wlan-dummy.c +++ b/src/transport/gnunet-helper-transport-wlan-dummy.c | |||
@@ -59,12 +59,12 @@ sigfunc (int sig) | |||
59 | * @return number of bytes written | 59 | * @return number of bytes written |
60 | */ | 60 | */ |
61 | static int | 61 | static int |
62 | send_mac_to_plugin (char *buffer, struct MacAddress *mac) | 62 | send_mac_to_plugin (char *buffer, struct GNUNET_TRANSPORT_WLAN_MacAddress *mac) |
63 | { | 63 | { |
64 | 64 | ||
65 | struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg; | 65 | struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg; |
66 | 66 | ||
67 | memcpy (&macmsg.mac, (char *) mac, sizeof (struct MacAddress)); | 67 | memcpy (&macmsg.mac, (char *) mac, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); |
68 | macmsg.hdr.size = htons (sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage)); | 68 | macmsg.hdr.size = htons (sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage)); |
69 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); | 69 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); |
70 | 70 | ||
@@ -165,7 +165,7 @@ main (int argc, char *argv[]) | |||
165 | int retval; | 165 | int retval; |
166 | struct GNUNET_SERVER_MessageStreamTokenizer *stdin_mst; | 166 | struct GNUNET_SERVER_MessageStreamTokenizer *stdin_mst; |
167 | struct GNUNET_SERVER_MessageStreamTokenizer *file_in_mst; | 167 | struct GNUNET_SERVER_MessageStreamTokenizer *file_in_mst; |
168 | struct MacAddress macaddr; | 168 | struct GNUNET_TRANSPORT_WLAN_MacAddress macaddr; |
169 | 169 | ||
170 | if (2 != argc) | 170 | if (2 != argc) |
171 | { | 171 | { |
diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c index 25b94677f..582df7cf5 100644 --- a/src/transport/gnunet-helper-transport-wlan.c +++ b/src/transport/gnunet-helper-transport-wlan.c | |||
@@ -19,6 +19,16 @@ | |||
19 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | /** | ||
23 | * @file src/transport/gnunet-helper-transport-wlan.c | ||
24 | * @brief wlan layer two server; must run as root (SUID will do) | ||
25 | * This code will work under GNU/Linux only. | ||
26 | * @author David Brodski | ||
27 | * | ||
28 | * This program serves as the mediator between the wlan interface and | ||
29 | * gnunet | ||
30 | */ | ||
31 | |||
22 | /*- | 32 | /*- |
23 | * we use our local copy of ieee80211_radiotap.h | 33 | * we use our local copy of ieee80211_radiotap.h |
24 | * | 34 | * |
@@ -62,16 +72,6 @@ | |||
62 | */ | 72 | */ |
63 | 73 | ||
64 | /** | 74 | /** |
65 | * @file src/transport/gnunet-helper-transport-wlan.c | ||
66 | * @brief wlan layer two server; must run as root (SUID will do) | ||
67 | * This code will work under GNU/Linux only. | ||
68 | * @author David Brodski | ||
69 | * | ||
70 | * This program serves as the mediator between the wlan interface and | ||
71 | * gnunet | ||
72 | */ | ||
73 | |||
74 | /** | ||
75 | * parts taken from aircrack-ng, parts changend. | 75 | * parts taken from aircrack-ng, parts changend. |
76 | */ | 76 | */ |
77 | #define _GNU_SOURCE | 77 | #define _GNU_SOURCE |
@@ -111,8 +111,12 @@ | |||
111 | */ | 111 | */ |
112 | #define IEEE80211_ADDR_LEN 6 | 112 | #define IEEE80211_ADDR_LEN 6 |
113 | 113 | ||
114 | /** | ||
115 | * Maximum size of a message allowed in either direction. | ||
116 | */ | ||
114 | #define MAXLINE 4096 | 117 | #define MAXLINE 4096 |
115 | 118 | ||
119 | |||
116 | #define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK 0x80000000 | 120 | #define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK 0x80000000 |
117 | 121 | ||
118 | 122 | ||
@@ -309,25 +313,68 @@ struct ieee80211_radiotap_header | |||
309 | uint32_t it_present; | 313 | uint32_t it_present; |
310 | }; | 314 | }; |
311 | 315 | ||
316 | /** | ||
317 | * | ||
318 | */ | ||
312 | struct RadioTapheader | 319 | struct RadioTapheader |
313 | { | 320 | { |
321 | /** | ||
322 | * | ||
323 | */ | ||
314 | struct ieee80211_radiotap_header header; | 324 | struct ieee80211_radiotap_header header; |
325 | |||
326 | /** | ||
327 | * | ||
328 | */ | ||
315 | uint8_t rate; | 329 | uint8_t rate; |
330 | |||
331 | /** | ||
332 | * | ||
333 | */ | ||
316 | uint8_t pad1; | 334 | uint8_t pad1; |
335 | |||
336 | /** | ||
337 | * | ||
338 | */ | ||
317 | uint16_t txflags; | 339 | uint16_t txflags; |
318 | }; | 340 | }; |
319 | 341 | ||
320 | 342 | ||
321 | /** | 343 | /** |
322 | * FIXME. | 344 | * IO buffer used for buffering data in transit (to wireless or to stdout). |
323 | */ | 345 | */ |
324 | struct SendBuffer | 346 | struct SendBuffer |
325 | { | 347 | { |
326 | unsigned int pos; | 348 | /** |
327 | unsigned int size; | 349 | * How many bytes of data are stored in 'buf' for transmission right now? |
350 | * Data always starts at offset 0 and extends to 'size'. | ||
351 | */ | ||
352 | size_t size; | ||
353 | |||
354 | /** | ||
355 | * How many bytes that were stored in 'buf' did we already write to the | ||
356 | * destination? Always smaller than 'size'. | ||
357 | */ | ||
358 | size_t pos; | ||
359 | |||
360 | /** | ||
361 | * Buffered data; twice the maximum allowed message size as we add some | ||
362 | * headers. | ||
363 | */ | ||
328 | char buf[MAXLINE * 2]; | 364 | char buf[MAXLINE * 2]; |
329 | }; | 365 | }; |
330 | 366 | ||
367 | /** | ||
368 | * Buffer for data read from stdin to be transmitted to the wirless card. | ||
369 | */ | ||
370 | static struct SendBuffer write_pout; | ||
371 | |||
372 | /** | ||
373 | * Buffer for data read from the wireless card to be transmitted to stdout. | ||
374 | */ | ||
375 | static struct SendBuffer write_std; | ||
376 | |||
377 | |||
331 | GNUNET_NETWORK_STRUCT_BEGIN | 378 | GNUNET_NETWORK_STRUCT_BEGIN |
332 | 379 | ||
333 | /** | 380 | /** |
@@ -346,6 +393,7 @@ struct ieee80211_frame | |||
346 | } GNUNET_PACKED; | 393 | } GNUNET_PACKED; |
347 | GNUNET_NETWORK_STRUCT_END | 394 | GNUNET_NETWORK_STRUCT_END |
348 | 395 | ||
396 | |||
349 | /** | 397 | /** |
350 | * struct for storing the information of the hardware | 398 | * struct for storing the information of the hardware |
351 | */ | 399 | */ |
@@ -353,15 +401,14 @@ struct HardwareInfos | |||
353 | { | 401 | { |
354 | 402 | ||
355 | /** | 403 | /** |
356 | * send buffer | ||
357 | */ | ||
358 | struct SendBuffer write_pout; | ||
359 | |||
360 | /** | ||
361 | * file descriptor for the raw socket | 404 | * file descriptor for the raw socket |
362 | */ | 405 | */ |
363 | int fd_raw; | 406 | int fd_raw; |
364 | 407 | ||
408 | /** | ||
409 | * Which format has the header that we're getting when receiving packets? | ||
410 | * Some ARPHRD_IEEE80211_XXX-value. | ||
411 | */ | ||
365 | int arptype_in; | 412 | int arptype_in; |
366 | 413 | ||
367 | /** | 414 | /** |
@@ -369,39 +416,16 @@ struct HardwareInfos | |||
369 | */ | 416 | */ |
370 | char iface[IFNAMSIZ]; | 417 | char iface[IFNAMSIZ]; |
371 | 418 | ||
372 | struct MacAddress pl_mac; | 419 | /** |
420 | * MAC address of our own WLAN interface. | ||
421 | */ | ||
422 | struct GNUNET_TRANSPORT_WLAN_MacAddress pl_mac; | ||
373 | }; | 423 | }; |
374 | 424 | ||
375 | 425 | ||
376 | |||
377 | |||
378 | /* *INDENT-OFF* */ | ||
379 | #define ___my_swab16(x) \ | ||
380 | ((u_int16_t)( \ | ||
381 | (((u_int16_t)(x) & (u_int16_t)0x00ffU) << 8) | \ | ||
382 | (((u_int16_t)(x) & (u_int16_t)0xff00U) >> 8) )) | ||
383 | |||
384 | #define ___my_swab32(x) \ | ||
385 | ((u_int32_t)( \ | ||
386 | (((u_int32_t)(x) & (u_int32_t)0x000000ffUL) << 24) | \ | ||
387 | (((u_int32_t)(x) & (u_int32_t)0x0000ff00UL) << 8) | \ | ||
388 | (((u_int32_t)(x) & (u_int32_t)0x00ff0000UL) >> 8) | \ | ||
389 | (((u_int32_t)(x) & (u_int32_t)0xff000000UL) >> 24) )) | ||
390 | #define ___my_swab64(x) \ | ||
391 | ((u_int64_t)( \ | ||
392 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000000000ffULL) << 56) | \ | ||
393 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000000000ff00ULL) << 40) | \ | ||
394 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000000000ff0000ULL) << 24) | \ | ||
395 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000ff000000ULL) << 8) | \ | ||
396 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000ff00000000ULL) >> 8) | \ | ||
397 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000ff0000000000ULL) >> 24) | \ | ||
398 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00ff000000000000ULL) >> 40) | \ | ||
399 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0xff00000000000000ULL) >> 56) )) | ||
400 | /* *INDENT-ON* */ | ||
401 | |||
402 | |||
403 | /** | 426 | /** |
404 | * struct ieee80211_radiotap_iterator - tracks walk through present radiotap args | 427 | * struct ieee80211_radiotap_iterator - tracks walk through present radiotap arguments |
428 | * in the radiotap header. | ||
405 | */ | 429 | */ |
406 | struct ieee80211_radiotap_iterator | 430 | struct ieee80211_radiotap_iterator |
407 | { | 431 | { |
@@ -922,25 +946,6 @@ next_entry: | |||
922 | 946 | ||
923 | 947 | ||
924 | /** | 948 | /** |
925 | * function to create GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL message for plugin | ||
926 | * @param buffer pointer to buffer for the message | ||
927 | * @param mac pointer to the mac address | ||
928 | * @return number of bytes written | ||
929 | */ | ||
930 | static int | ||
931 | send_mac_to_plugin (char *buffer, struct MacAddress *mac) | ||
932 | { | ||
933 | struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg; | ||
934 | |||
935 | memcpy (&macmsg.mac, (char *) mac, sizeof (struct MacAddress)); | ||
936 | macmsg.hdr.size = htons (sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage)); | ||
937 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); | ||
938 | memcpy (buffer, &macmsg, sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage)); | ||
939 | return sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage); | ||
940 | } | ||
941 | |||
942 | |||
943 | /** | ||
944 | * Return the channel from the frequency (in Mhz) | 949 | * Return the channel from the frequency (in Mhz) |
945 | * @param frequency of the channel | 950 | * @param frequency of the channel |
946 | * @return number of the channel | 951 | * @return number of the channel |
@@ -960,6 +965,7 @@ get_channel_from_frequency (int frequency) | |||
960 | 965 | ||
961 | /** | 966 | /** |
962 | * function to calculate the crc, the start of the calculation | 967 | * function to calculate the crc, the start of the calculation |
968 | * | ||
963 | * @param buf buffer to calc the crc | 969 | * @param buf buffer to calc the crc |
964 | * @param len len of the buffer | 970 | * @param len len of the buffer |
965 | * @return crc sum | 971 | * @return crc sum |
@@ -1043,10 +1049,12 @@ calc_crc_osdep (const unsigned char *buf, size_t len) | |||
1043 | 1049 | ||
1044 | 1050 | ||
1045 | /** | 1051 | /** |
1046 | * Function to check crc of the wlan packet | 1052 | * Function to calculate and check crc of the wlan packet |
1047 | * @param buf buffer of the packet | 1053 | * |
1048 | * @param len len of the data | 1054 | * @param buf buffer of the packet, with len + 4 bytes of data, |
1049 | * @return crc sum of the data | 1055 | * the last 4 bytes being the checksum |
1056 | * @param len length of the payload in data | ||
1057 | * @return 0 on success (checksum matches), 1 on error | ||
1050 | */ | 1058 | */ |
1051 | static int | 1059 | static int |
1052 | check_crc_buf_osdep (const unsigned char *buf, size_t len) | 1060 | check_crc_buf_osdep (const unsigned char *buf, size_t len) |
@@ -1055,15 +1063,18 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
1055 | 1063 | ||
1056 | crc = calc_crc_osdep (buf, len); | 1064 | crc = calc_crc_osdep (buf, len); |
1057 | buf += len; | 1065 | buf += len; |
1058 | return (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && | 1066 | if (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && |
1059 | ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]); | 1067 | ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]) |
1068 | return 0; | ||
1069 | return 1; | ||
1060 | } | 1070 | } |
1061 | 1071 | ||
1062 | 1072 | ||
1063 | /** | 1073 | /** |
1064 | * function to get the channel of a specific wlan card | 1074 | * Get the channel used by our WLAN interface. |
1075 | * | ||
1065 | * @param dev pointer to the dev struct of the card | 1076 | * @param dev pointer to the dev struct of the card |
1066 | * @return channel number | 1077 | * @return channel number, -1 on error |
1067 | */ | 1078 | */ |
1068 | static int | 1079 | static int |
1069 | linux_get_channel (const struct HardwareInfos *dev) | 1080 | linux_get_channel (const struct HardwareInfos *dev) |
@@ -1272,7 +1283,7 @@ linux_read (struct HardwareInfos *dev, unsigned char *buf, size_t buf_size, | |||
1272 | caplen -= n; | 1283 | caplen -= n; |
1273 | 1284 | ||
1274 | //detect fcs at the end, even if the flag wasn't set and remove it | 1285 | //detect fcs at the end, even if the flag wasn't set and remove it |
1275 | if ((0 == fcs_removed) && (1 == check_crc_buf_osdep (tmpbuf + n, caplen - 4))) | 1286 | if ((0 == fcs_removed) && (0 == check_crc_buf_osdep (tmpbuf + n, caplen - 4))) |
1276 | { | 1287 | { |
1277 | caplen -= 4; | 1288 | caplen -= 4; |
1278 | } | 1289 | } |
@@ -1285,7 +1296,8 @@ linux_read (struct HardwareInfos *dev, unsigned char *buf, size_t buf_size, | |||
1285 | 1296 | ||
1286 | 1297 | ||
1287 | /** | 1298 | /** |
1288 | * function to open the device for read/write | 1299 | * Open the wireless network interface for reading/writing. |
1300 | * | ||
1289 | * @param dev pointer to the device struct | 1301 | * @param dev pointer to the device struct |
1290 | * @return 0 on success | 1302 | * @return 0 on success |
1291 | */ | 1303 | */ |
@@ -1398,26 +1410,19 @@ open_device_raw (struct HardwareInfos *dev) | |||
1398 | 1410 | ||
1399 | 1411 | ||
1400 | /** | 1412 | /** |
1401 | * function to prepare the helper, e.g. sockets, device... | 1413 | * Test if the given interface name really corresponds to a wireless |
1402 | * @param dev struct for the device | 1414 | * device. |
1415 | * | ||
1403 | * @param iface name of the interface | 1416 | * @param iface name of the interface |
1404 | * @return 0 on success | 1417 | * @return 0 on success, 1 on error |
1405 | */ | 1418 | */ |
1406 | static int | 1419 | static int |
1407 | wlan_initialize (struct HardwareInfos *dev, const char *iface) | 1420 | test_wlan_interface (const char *iface) |
1408 | { | 1421 | { |
1409 | char strbuf[512]; | 1422 | char strbuf[512]; |
1410 | struct stat sbuf; | 1423 | struct stat sbuf; |
1411 | int ret; | 1424 | int ret; |
1412 | 1425 | ||
1413 | if (dev->fd_raw >= FD_SETSIZE) | ||
1414 | { | ||
1415 | fprintf (stderr, "File descriptor too large for select (%d > %d)\n", | ||
1416 | dev->fd_raw, FD_SETSIZE); | ||
1417 | close (dev->fd_raw); | ||
1418 | return 1; | ||
1419 | } | ||
1420 | |||
1421 | /* mac80211 stack detection */ | 1426 | /* mac80211 stack detection */ |
1422 | ret = | 1427 | ret = |
1423 | snprintf (strbuf, sizeof (strbuf), "/sys/class/net/%s/phy80211/subsystem", | 1428 | snprintf (strbuf, sizeof (strbuf), "/sys/class/net/%s/phy80211/subsystem", |
@@ -1425,13 +1430,6 @@ wlan_initialize (struct HardwareInfos *dev, const char *iface) | |||
1425 | if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) | 1430 | if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) |
1426 | { | 1431 | { |
1427 | fprintf (stderr, "Did not find 802.11 interface `%s'. Exiting.\n", iface); | 1432 | fprintf (stderr, "Did not find 802.11 interface `%s'. Exiting.\n", iface); |
1428 | close (dev->fd_raw); | ||
1429 | return 1; | ||
1430 | } | ||
1431 | strncpy (dev->iface, iface, IFNAMSIZ); | ||
1432 | if (0 != open_device_raw (dev)) | ||
1433 | { | ||
1434 | close (dev->fd_raw); | ||
1435 | return 1; | 1433 | return 1; |
1436 | } | 1434 | } |
1437 | return 0; | 1435 | return 0; |
@@ -1484,7 +1482,6 @@ static void | |||
1484 | stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | 1482 | stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) |
1485 | { | 1483 | { |
1486 | struct HardwareInfos *dev = cls; | 1484 | struct HardwareInfos *dev = cls; |
1487 | struct SendBuffer *write_pout = &dev->write_pout; | ||
1488 | struct Radiotap_Send *header = (struct Radiotap_Send *) &hdr[1]; | 1485 | struct Radiotap_Send *header = (struct Radiotap_Send *) &hdr[1]; |
1489 | struct ieee80211_frame *wlanheader; | 1486 | struct ieee80211_frame *wlanheader; |
1490 | size_t sendsize; | 1487 | size_t sendsize; |
@@ -1521,56 +1518,61 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1521 | 1518 | ||
1522 | rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader)); | 1519 | rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader)); |
1523 | rtheader.rate = header->rate; | 1520 | rtheader.rate = header->rate; |
1524 | memcpy (write_pout->buf, &rtheader, sizeof (rtheader)); | 1521 | memcpy (write_pout.buf, &rtheader, sizeof (rtheader)); |
1525 | memcpy (write_pout->buf + sizeof (rtheader), &header[1], sendsize); | 1522 | memcpy (write_pout.buf + sizeof (rtheader), &header[1], sendsize); |
1526 | /* payload contains MAC address, but we don't trust it, so we'll | 1523 | /* payload contains MAC address, but we don't trust it, so we'll |
1527 | * overwrite it with OUR MAC address again to prevent mischief */ | 1524 | * overwrite it with OUR MAC address again to prevent mischief */ |
1528 | wlanheader = (struct ieee80211_frame *) (write_pout->buf + sizeof (rtheader)); | 1525 | wlanheader = (struct ieee80211_frame *) (write_pout.buf + sizeof (rtheader)); |
1529 | mac_set (wlanheader, dev); | 1526 | mac_set (wlanheader, dev); |
1530 | write_pout->size = sendsize + sizeof (rtheader); | 1527 | write_pout.size = sendsize + sizeof (rtheader); |
1531 | } | 1528 | } |
1532 | 1529 | ||
1533 | 1530 | ||
1534 | /** | 1531 | /** |
1535 | * main function of the helper | 1532 | * Main function of the helper. This code accesses a WLAN interface |
1536 | * @param argc number of arguments | 1533 | * in monitoring mode (layer 2) and then forwards traffic in both |
1537 | * @param argv arguments | 1534 | * directions between the WLAN interface and stdin/stdout of this |
1538 | * @return 0 on success, 1 on error | 1535 | * process. Error messages are written to stdout. |
1536 | * | ||
1537 | * @param argc number of arguments, must be 2 | ||
1538 | * @param argv arguments only argument is the name of the interface (i.e. 'mon0') | ||
1539 | * @return 0 on success (never happens, as we don't return unless aborted), 1 on error | ||
1539 | */ | 1540 | */ |
1540 | int | 1541 | int |
1541 | main (int argc, char *argv[]) | 1542 | main (int argc, char *argv[]) |
1542 | { | 1543 | { |
1543 | uid_t uid; | ||
1544 | struct HardwareInfos dev; | 1544 | struct HardwareInfos dev; |
1545 | char readbuf[MAXLINE]; | 1545 | char readbuf[MAXLINE]; |
1546 | struct SendBuffer write_std; | ||
1547 | ssize_t ret; | ||
1548 | int maxfd; | 1546 | int maxfd; |
1549 | fd_set rfds; | 1547 | fd_set rfds; |
1550 | fd_set wfds; | 1548 | fd_set wfds; |
1551 | int retval; | ||
1552 | int stdin_open; | 1549 | int stdin_open; |
1553 | struct MessageStreamTokenizer *stdin_mst; | 1550 | struct MessageStreamTokenizer *stdin_mst; |
1554 | int raw_eno; | 1551 | int raw_eno; |
1555 | 1552 | ||
1553 | memset (&dev, 0, sizeof (dev)); | ||
1556 | dev.fd_raw = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL)); | 1554 | dev.fd_raw = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL)); |
1557 | raw_eno = errno; /* remember for later */ | 1555 | raw_eno = errno; /* remember for later */ |
1558 | uid = getuid (); | 1556 | |
1559 | #ifdef HAVE_SETRESUID | 1557 | /* drop privs */ |
1560 | if (0 != setresuid (uid, uid, uid)) | ||
1561 | { | 1558 | { |
1562 | fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno)); | 1559 | uid_t uid = getuid (); |
1563 | if (-1 != dev.fd_raw) | 1560 | #ifdef HAVE_SETRESUID |
1564 | (void) close (dev.fd_raw); | 1561 | if (0 != setresuid (uid, uid, uid)) |
1565 | return 1; | 1562 | { |
1566 | } | 1563 | fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno)); |
1564 | if (-1 != dev.fd_raw) | ||
1565 | (void) close (dev.fd_raw); | ||
1566 | return 1; | ||
1567 | } | ||
1567 | #else | 1568 | #else |
1568 | if (0 != (setuid (uid) | seteuid (uid))) | 1569 | if (0 != (setuid (uid) | seteuid (uid))) |
1569 | { | 1570 | { |
1570 | fprintf (stderr, "Failed to setuid: %s\n", strerror (errno)); | 1571 | fprintf (stderr, "Failed to setuid: %s\n", strerror (errno)); |
1571 | if (-1 != dev.fd_raw) | 1572 | if (-1 != dev.fd_raw) |
1572 | (void) close (dev.fd_raw); | 1573 | (void) close (dev.fd_raw); |
1573 | return 1; | 1574 | return 1; |
1575 | } | ||
1574 | } | 1576 | } |
1575 | #endif | 1577 | #endif |
1576 | 1578 | ||
@@ -1589,22 +1591,43 @@ main (int argc, char *argv[]) | |||
1589 | fprintf (stderr, "Failed to create raw socket: %s\n", strerror (raw_eno)); | 1591 | fprintf (stderr, "Failed to create raw socket: %s\n", strerror (raw_eno)); |
1590 | return 1; | 1592 | return 1; |
1591 | } | 1593 | } |
1592 | if (0 != wlan_initialize (&dev, argv[1])) | 1594 | if (dev.fd_raw >= FD_SETSIZE) |
1595 | { | ||
1596 | fprintf (stderr, "File descriptor too large for select (%d > %d)\n", | ||
1597 | dev.fd_raw, FD_SETSIZE); | ||
1598 | (void) close (dev.fd_raw); | ||
1593 | return 1; | 1599 | return 1; |
1594 | dev.write_pout.size = 0; | 1600 | } |
1595 | dev.write_pout.pos = 0; | 1601 | if (0 != test_wlan_interface (argv[1])) |
1596 | stdin_mst = mst_create (&stdin_send_hw, &dev); | 1602 | { |
1603 | (void) close (dev.fd_raw); | ||
1604 | return 1; | ||
1605 | } | ||
1606 | strncpy (dev.iface, argv[1], IFNAMSIZ); | ||
1607 | if (0 != open_device_raw (&dev)) | ||
1608 | { | ||
1609 | (void) close (dev.fd_raw); | ||
1610 | return 1; | ||
1611 | } | ||
1597 | 1612 | ||
1598 | /* send mac to STDOUT first */ | 1613 | /* send MAC address of the WLAN interface to STDOUT first */ |
1599 | write_std.pos = 0; | 1614 | { |
1600 | write_std.size = send_mac_to_plugin ((char *) &write_std.buf, &dev.pl_mac); | 1615 | struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg; |
1601 | stdin_open = 1; | 1616 | |
1617 | macmsg.hdr.size = htons (sizeof (macmsg)); | ||
1618 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); | ||
1619 | memcpy (&macmsg.mac, &dev.pl_mac, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); | ||
1620 | memcpy (write_std.buf, &macmsg, sizeof (macmsg)); | ||
1621 | write_std.size = sizeof (macmsg); | ||
1622 | } | ||
1602 | 1623 | ||
1624 | stdin_mst = mst_create (&stdin_send_hw, &dev); | ||
1625 | stdin_open = 1; | ||
1603 | while (1) | 1626 | while (1) |
1604 | { | 1627 | { |
1605 | maxfd = -1; | 1628 | maxfd = -1; |
1606 | FD_ZERO (&rfds); | 1629 | FD_ZERO (&rfds); |
1607 | if ((0 == dev.write_pout.size) && (1 == stdin_open)) | 1630 | if ((0 == write_pout.size) && (1 == stdin_open)) |
1608 | { | 1631 | { |
1609 | FD_SET (STDIN_FILENO, &rfds); | 1632 | FD_SET (STDIN_FILENO, &rfds); |
1610 | maxfd = MAX (maxfd, STDIN_FILENO); | 1633 | maxfd = MAX (maxfd, STDIN_FILENO); |
@@ -1620,22 +1643,24 @@ main (int argc, char *argv[]) | |||
1620 | FD_SET (STDOUT_FILENO, &wfds); | 1643 | FD_SET (STDOUT_FILENO, &wfds); |
1621 | maxfd = MAX (maxfd, STDOUT_FILENO); | 1644 | maxfd = MAX (maxfd, STDOUT_FILENO); |
1622 | } | 1645 | } |
1623 | if (0 < dev.write_pout.size) | 1646 | if (0 < write_pout.size) |
1624 | { | 1647 | { |
1625 | FD_SET (dev.fd_raw, &wfds); | 1648 | FD_SET (dev.fd_raw, &wfds); |
1626 | maxfd = MAX (maxfd, dev.fd_raw); | 1649 | maxfd = MAX (maxfd, dev.fd_raw); |
1627 | } | 1650 | } |
1628 | retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL); | ||
1629 | if ((-1 == retval) && (EINTR == errno)) | ||
1630 | continue; | ||
1631 | if (0 > retval) | ||
1632 | { | 1651 | { |
1633 | fprintf (stderr, "select failed: %s\n", strerror (errno)); | 1652 | int retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL); |
1634 | break; | 1653 | if ((-1 == retval) && (EINTR == errno)) |
1654 | continue; | ||
1655 | if (0 > retval) | ||
1656 | { | ||
1657 | fprintf (stderr, "select failed: %s\n", strerror (errno)); | ||
1658 | break; | ||
1659 | } | ||
1635 | } | 1660 | } |
1636 | if (FD_ISSET (STDOUT_FILENO, &wfds)) | 1661 | if (FD_ISSET (STDOUT_FILENO, &wfds)) |
1637 | { | 1662 | { |
1638 | ret = | 1663 | ssize_t ret = |
1639 | write (STDOUT_FILENO, write_std.buf + write_std.pos, | 1664 | write (STDOUT_FILENO, write_std.buf + write_std.pos, |
1640 | write_std.size - write_std.pos); | 1665 | write_std.size - write_std.pos); |
1641 | if (0 > ret) | 1666 | if (0 > ret) |
@@ -1652,31 +1677,35 @@ main (int argc, char *argv[]) | |||
1652 | } | 1677 | } |
1653 | if (FD_ISSET (dev.fd_raw, &wfds)) | 1678 | if (FD_ISSET (dev.fd_raw, &wfds)) |
1654 | { | 1679 | { |
1655 | ret = write (dev.fd_raw, dev.write_pout.buf, dev.write_pout.size); | 1680 | ssize_t ret = |
1681 | write (dev.fd_raw, write_pout.buf + write_std.pos, | ||
1682 | write_pout.size - write_pout.pos); | ||
1656 | if (0 > ret) | 1683 | if (0 > ret) |
1657 | { | 1684 | { |
1658 | fprintf (stderr, "Failed to write to WLAN device: %s\n", | 1685 | fprintf (stderr, "Failed to write to WLAN device: %s\n", |
1659 | strerror (errno)); | 1686 | strerror (errno)); |
1660 | break; | 1687 | break; |
1661 | } | 1688 | } |
1662 | dev.write_pout.pos += ret; | 1689 | write_pout.pos += ret; |
1663 | if ((dev.write_pout.pos != dev.write_pout.size) && (ret != 0)) | 1690 | if ((write_pout.pos != write_pout.size) && (0 != ret)) |
1664 | { | 1691 | { |
1665 | /* we should not get partial sends with packet-oriented devices... */ | 1692 | /* we should not get partial sends with packet-oriented devices... */ |
1666 | fprintf (stderr, "Write error, partial send: %u/%u\n", | 1693 | fprintf (stderr, "Write error, partial send: %u/%u\n", |
1667 | dev.write_pout.pos, dev.write_pout.size); | 1694 | (unsigned int) write_pout.pos, |
1695 | (unsigned int) write_pout.size); | ||
1668 | break; | 1696 | break; |
1669 | } | 1697 | } |
1670 | if (dev.write_pout.pos == dev.write_pout.size) | 1698 | if (write_pout.pos == write_pout.size) |
1671 | { | 1699 | { |
1672 | dev.write_pout.pos = 0; | 1700 | write_pout.pos = 0; |
1673 | dev.write_pout.size = 0; | 1701 | write_pout.size = 0; |
1674 | } | 1702 | } |
1675 | } | 1703 | } |
1676 | 1704 | ||
1677 | if (FD_ISSET (STDIN_FILENO, &rfds)) | 1705 | if (FD_ISSET (STDIN_FILENO, &rfds)) |
1678 | { | 1706 | { |
1679 | ret = read (STDIN_FILENO, readbuf, sizeof (readbuf)); | 1707 | ssize_t ret = |
1708 | read (STDIN_FILENO, readbuf, sizeof (readbuf)); | ||
1680 | if (0 > ret) | 1709 | if (0 > ret) |
1681 | { | 1710 | { |
1682 | fprintf (stderr, "Read error from STDIN: %s\n", strerror (errno)); | 1711 | fprintf (stderr, "Read error from STDIN: %s\n", strerror (errno)); |
@@ -1695,6 +1724,7 @@ main (int argc, char *argv[]) | |||
1695 | struct GNUNET_MessageHeader *header; | 1724 | struct GNUNET_MessageHeader *header; |
1696 | struct Radiotap_rx *rxinfo; | 1725 | struct Radiotap_rx *rxinfo; |
1697 | struct ieee80211_frame *datastart; | 1726 | struct ieee80211_frame *datastart; |
1727 | ssize_t ret; | ||
1698 | 1728 | ||
1699 | header = (struct GNUNET_MessageHeader *) write_std.buf; | 1729 | header = (struct GNUNET_MessageHeader *) write_std.buf; |
1700 | rxinfo = (struct Radiotap_rx *) &header[1]; | 1730 | rxinfo = (struct Radiotap_rx *) &header[1]; |
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 4510ae12c..08f9c5833 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -39,7 +39,11 @@ | |||
39 | #include "gnunet_fragmentation_lib.h" | 39 | #include "gnunet_fragmentation_lib.h" |
40 | #include "gnunet_constants.h" | 40 | #include "gnunet_constants.h" |
41 | 41 | ||
42 | #include <string.h> | 42 | /** |
43 | * DEBUG switch | ||
44 | */ | ||
45 | #define DEBUG_WLAN GNUNET_EXTRA_LOGGING | ||
46 | |||
43 | 47 | ||
44 | #define PROTOCOL_PREFIX "wlan" | 48 | #define PROTOCOL_PREFIX "wlan" |
45 | 49 | ||
@@ -100,15 +104,6 @@ | |||
100 | #define WLAN_LLC_SSAP_FIELD 0x1f | 104 | #define WLAN_LLC_SSAP_FIELD 0x1f |
101 | 105 | ||
102 | 106 | ||
103 | /** | ||
104 | * DEBUG switch | ||
105 | */ | ||
106 | #define DEBUG_wlan GNUNET_EXTRA_LOGGING | ||
107 | #define DEBUG_wlan_retransmission GNUNET_EXTRA_LOGGING | ||
108 | #define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO | ||
109 | #define DEBUG_wlan_msg_dump GNUNET_EXTRA_LOGGING | ||
110 | |||
111 | |||
112 | #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ | 107 | #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ |
113 | 108 | ||
114 | #define IEEE80211_FC0_VERSION_MASK 0x03 | 109 | #define IEEE80211_FC0_VERSION_MASK 0x03 |
@@ -225,7 +220,7 @@ struct Plugin | |||
225 | /** | 220 | /** |
226 | * The mac_address of the wlan card given to us by the helper. | 221 | * The mac_address of the wlan card given to us by the helper. |
227 | */ | 222 | */ |
228 | struct MacAddress mac_address; | 223 | struct GNUNET_TRANSPORT_WLAN_MacAddress mac_address; |
229 | 224 | ||
230 | /** | 225 | /** |
231 | * Sessions currently pending for transmission | 226 | * Sessions currently pending for transmission |
@@ -488,7 +483,7 @@ struct Session_light | |||
488 | /** | 483 | /** |
489 | * peer mac address | 484 | * peer mac address |
490 | */ | 485 | */ |
491 | struct MacAddress addr; | 486 | struct GNUNET_TRANSPORT_WLAN_MacAddress addr; |
492 | 487 | ||
493 | /** | 488 | /** |
494 | * mac endpoint | 489 | * mac endpoint |
@@ -595,7 +590,7 @@ struct MacEndpoint | |||
595 | /** | 590 | /** |
596 | * peer mac address | 591 | * peer mac address |
597 | */ | 592 | */ |
598 | struct MacAddress addr; | 593 | struct GNUNET_TRANSPORT_WLAN_MacAddress addr; |
599 | 594 | ||
600 | /** | 595 | /** |
601 | * Defrag context for this mac endpoint | 596 | * Defrag context for this mac endpoint |
@@ -704,7 +699,7 @@ free_session (struct Plugin *plugin, struct Sessionqueue *queue, | |||
704 | int do_free_macendpoint); | 699 | int do_free_macendpoint); |
705 | 700 | ||
706 | static struct MacEndpoint * | 701 | static struct MacEndpoint * |
707 | create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr); | 702 | create_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr); |
708 | 703 | ||
709 | static void | 704 | static void |
710 | finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 705 | finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
@@ -771,7 +766,7 @@ hexdump (const void *mem, unsigned length) | |||
771 | * @return | 766 | * @return |
772 | */ | 767 | */ |
773 | static struct MacEndpoint * | 768 | static struct MacEndpoint * |
774 | get_macendpoint (struct Plugin *plugin, const struct MacAddress *addr, | 769 | get_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr, |
775 | int create_new) | 770 | int create_new) |
776 | { | 771 | { |
777 | struct MacEndpoint *queue = plugin->mac_head; | 772 | struct MacEndpoint *queue = plugin->mac_head; |
@@ -779,7 +774,7 @@ get_macendpoint (struct Plugin *plugin, const struct MacAddress *addr, | |||
779 | while (queue != NULL) | 774 | while (queue != NULL) |
780 | { | 775 | { |
781 | //GNUNET_assert (queue->sessions_head != NULL); | 776 | //GNUNET_assert (queue->sessions_head != NULL); |
782 | if (memcmp (addr, &queue->addr, sizeof (struct MacAddress)) == 0) | 777 | if (memcmp (addr, &queue->addr, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) |
783 | return queue; /* session found */ | 778 | return queue; /* session found */ |
784 | queue = queue->next; | 779 | queue = queue->next; |
785 | } | 780 | } |
@@ -837,9 +832,9 @@ static const char * | |||
837 | wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | 832 | wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) |
838 | { | 833 | { |
839 | static char ret[40]; | 834 | static char ret[40]; |
840 | const struct MacAddress *mac; | 835 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac; |
841 | 836 | ||
842 | if (addrlen != sizeof (struct MacAddress)) | 837 | if (addrlen != sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) |
843 | { | 838 | { |
844 | GNUNET_break (0); | 839 | GNUNET_break (0); |
845 | return NULL; | 840 | return NULL; |
@@ -916,14 +911,11 @@ create_session (struct Plugin *plugin, struct MacEndpoint *endpoint, | |||
916 | queue->content->timeout_task = | 911 | queue->content->timeout_task = |
917 | GNUNET_SCHEDULER_add_delayed (SESSION_TIMEOUT, &session_timeout, queue); | 912 | GNUNET_SCHEDULER_add_delayed (SESSION_TIMEOUT, &session_timeout, queue); |
918 | 913 | ||
919 | #if DEBUG_wlan | ||
920 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 914 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
921 | "New session %p with endpoint %p: %s\n", queue->content, | 915 | "New session %p with endpoint %p: %s\n", queue->content, |
922 | endpoint, wlan_plugin_address_to_string (NULL, | 916 | endpoint, wlan_plugin_address_to_string (NULL, |
923 | endpoint->addr.mac, | 917 | endpoint->addr.mac, |
924 | 6)); | 918 | 6)); |
925 | #endif | ||
926 | |||
927 | return queue->content; | 919 | return queue->content; |
928 | } | 920 | } |
929 | 921 | ||
@@ -936,7 +928,7 @@ create_session (struct Plugin *plugin, struct MacEndpoint *endpoint, | |||
936 | * @return returns the session | 928 | * @return returns the session |
937 | */ | 929 | */ |
938 | static struct Session * | 930 | static struct Session * |
939 | get_session (struct Plugin *plugin, const struct MacAddress *addr, | 931 | get_session (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr, |
940 | const struct GNUNET_PeerIdentity *peer) | 932 | const struct GNUNET_PeerIdentity *peer) |
941 | { | 933 | { |
942 | struct MacEndpoint *mac; | 934 | struct MacEndpoint *mac; |
@@ -1090,11 +1082,8 @@ set_next_send (struct Plugin *const plugin) | |||
1090 | next_send = GNUNET_TIME_absolute_get_remaining (plugin->beacon_time); | 1082 | next_send = GNUNET_TIME_absolute_get_remaining (plugin->beacon_time); |
1091 | } | 1083 | } |
1092 | 1084 | ||
1093 | #if DEBUG_wlan | ||
1094 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1085 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1095 | "Next packet is send in: %u\n", next_send.rel_value); | 1086 | "Next packet is send in: %u\n", next_send.rel_value); |
1096 | #endif | ||
1097 | |||
1098 | if (next_send.rel_value == GNUNET_TIME_UNIT_ZERO.rel_value) | 1087 | if (next_send.rel_value == GNUNET_TIME_UNIT_ZERO.rel_value) |
1099 | { | 1088 | { |
1100 | if (plugin->server_write_task == GNUNET_SCHEDULER_NO_TASK) | 1089 | if (plugin->server_write_task == GNUNET_SCHEDULER_NO_TASK) |
@@ -1140,11 +1129,9 @@ get_next_queue_session (struct Plugin *plugin) | |||
1140 | 1129 | ||
1141 | if (pm == NULL) | 1130 | if (pm == NULL) |
1142 | { | 1131 | { |
1143 | #if DEBUG_wlan | ||
1144 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, | 1132 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
1145 | "pending message is empty, should not happen. session %p\n", | 1133 | "pending message is empty, should not happen. session %p\n", |
1146 | session); | 1134 | session); |
1147 | #endif | ||
1148 | sessionqueue_alt = sessionqueue; | 1135 | sessionqueue_alt = sessionqueue; |
1149 | sessionqueue = sessionqueue->next; | 1136 | sessionqueue = sessionqueue->next; |
1150 | plugin->pendingsessions--; | 1137 | plugin->pendingsessions--; |
@@ -1257,11 +1244,9 @@ free_fragment_message (struct Plugin *plugin, struct FragmentMessage *fm) | |||
1257 | GNUNET_free (fm); | 1244 | GNUNET_free (fm); |
1258 | 1245 | ||
1259 | queue_session (plugin, session); | 1246 | queue_session (plugin, session); |
1260 | #if DEBUG_wlan | ||
1261 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1247 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1262 | "Free pending fragment messages %p, session %p\n", fm, | 1248 | "Free pending fragment messages %p, session %p\n", fm, |
1263 | session); | 1249 | session); |
1264 | #endif | ||
1265 | } | 1250 | } |
1266 | 1251 | ||
1267 | /** | 1252 | /** |
@@ -1302,7 +1287,7 @@ getRadiotapHeader (struct Plugin *plugin, struct MacEndpoint *endpoint, | |||
1302 | */ | 1287 | */ |
1303 | static int | 1288 | static int |
1304 | getWlanHeader (struct ieee80211_frame *Header, | 1289 | getWlanHeader (struct ieee80211_frame *Header, |
1305 | const struct MacAddress *to_mac_addr, struct Plugin *plugin, | 1290 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, struct Plugin *plugin, |
1306 | unsigned int size) | 1291 | unsigned int size) |
1307 | { | 1292 | { |
1308 | uint16_t *tmp16; | 1293 | uint16_t *tmp16; |
@@ -1313,7 +1298,7 @@ getWlanHeader (struct ieee80211_frame *Header, | |||
1313 | memcpy (&Header->i_addr3, &mac_bssid_gnunet, sizeof (mac_bssid_gnunet)); | 1298 | memcpy (&Header->i_addr3, &mac_bssid_gnunet, sizeof (mac_bssid_gnunet)); |
1314 | memcpy (&Header->i_addr2, plugin->mac_address.mac, | 1299 | memcpy (&Header->i_addr2, plugin->mac_address.mac, |
1315 | sizeof (plugin->mac_address)); | 1300 | sizeof (plugin->mac_address)); |
1316 | memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct MacAddress)); | 1301 | memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); |
1317 | 1302 | ||
1318 | tmp16 = (uint16_t *) Header->i_dur; | 1303 | tmp16 = (uint16_t *) Header->i_dur; |
1319 | *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290); | 1304 | *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290); |
@@ -1344,12 +1329,9 @@ add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1344 | struct GNUNET_MessageHeader *msgheader2; | 1329 | struct GNUNET_MessageHeader *msgheader2; |
1345 | uint16_t size; | 1330 | uint16_t size; |
1346 | 1331 | ||
1347 | #if DEBUG_wlan_retransmission > 1 | ||
1348 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1332 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1349 | "Adding fragment of message %p to send, session %p, endpoint %p, type %u\n", | 1333 | "Adding fragment of message %p to send, session %p, endpoint %p, type %u\n", |
1350 | fm, fm->session, endpoint, hdr->type); | 1334 | fm, fm->session, endpoint, hdr->type); |
1351 | #endif | ||
1352 | |||
1353 | size = | 1335 | size = |
1354 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + | 1336 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + |
1355 | sizeof (struct ieee80211_frame) + ntohs (hdr->size); | 1337 | sizeof (struct ieee80211_frame) + ntohs (hdr->size); |
@@ -1401,12 +1383,10 @@ wlan_plugin_helper_read (void *cls, | |||
1401 | sizeof (mybuf)); | 1383 | sizeof (mybuf)); |
1402 | if (bytes <= 0) | 1384 | if (bytes <= 0) |
1403 | { | 1385 | { |
1404 | #if DEBUG_wlan | ||
1405 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1386 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1406 | _ | 1387 | _ |
1407 | ("Finished reading from gnunet-helper-transport-wlan stdout with code: %d\n"), | 1388 | ("Finished reading from gnunet-helper-transport-wlan stdout with code: %d\n"), |
1408 | bytes); | 1389 | bytes); |
1409 | #endif | ||
1410 | return; | 1390 | return; |
1411 | } | 1391 | } |
1412 | GNUNET_SERVER_mst_receive (plugin->suid_tokenizer, NULL, mybuf, bytes, | 1392 | GNUNET_SERVER_mst_receive (plugin->suid_tokenizer, NULL, mybuf, bytes, |
@@ -1434,10 +1414,8 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin) | |||
1434 | 1414 | ||
1435 | if (plugin->helper_is_running == GNUNET_YES) | 1415 | if (plugin->helper_is_running == GNUNET_YES) |
1436 | { | 1416 | { |
1437 | #if DEBUG_wlan | ||
1438 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1417 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1439 | "wlan_transport_start_wlan_helper not needed, helper already running!"); | 1418 | "wlan_transport_start_wlan_helper not needed, helper already running!"); |
1440 | #endif | ||
1441 | return GNUNET_YES; | 1419 | return GNUNET_YES; |
1442 | } | 1420 | } |
1443 | 1421 | ||
@@ -1478,12 +1456,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin) | |||
1478 | if (plugin->testmode == 0) | 1456 | if (plugin->testmode == 0) |
1479 | { | 1457 | { |
1480 | 1458 | ||
1481 | #if DEBUG_wlan | ||
1482 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1459 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1483 | "Starting gnunet-helper-transport-wlan process cmd: %s %s %i\n", | 1460 | "Starting gnunet-helper-transport-wlan process cmd: %s %s %i\n", |
1484 | filenamehw, plugin->interface, plugin->testmode); | 1461 | filenamehw, plugin->interface, plugin->testmode); |
1485 | #endif | ||
1486 | |||
1487 | if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_YES) | 1462 | if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_YES) |
1488 | { | 1463 | { |
1489 | plugin->server_proc = | 1464 | plugin->server_proc = |
@@ -1508,11 +1483,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin) | |||
1508 | else if (plugin->testmode == 1) | 1483 | else if (plugin->testmode == 1) |
1509 | { | 1484 | { |
1510 | 1485 | ||
1511 | #if DEBUG_wlan | ||
1512 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, | 1486 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, |
1513 | "Starting gnunet-helper-transport-wlan-dummy loopback 1 process cmd: %s %s %i\n", | 1487 | "Starting gnunet-helper-transport-wlan-dummy loopback 1 process cmd: %s %s %i\n", |
1514 | absolute_filename, plugin->interface, plugin->testmode); | 1488 | absolute_filename, plugin->interface, plugin->testmode); |
1515 | #endif | ||
1516 | plugin->server_proc = | 1489 | plugin->server_proc = |
1517 | GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout, | 1490 | GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout, |
1518 | absolute_filename, absolute_filename, "1", | 1491 | absolute_filename, absolute_filename, "1", |
@@ -1527,12 +1500,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin) | |||
1527 | } | 1500 | } |
1528 | else if (plugin->testmode == 2) | 1501 | else if (plugin->testmode == 2) |
1529 | { | 1502 | { |
1530 | #if DEBUG_wlan | ||
1531 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, | 1503 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, |
1532 | "Starting gnunet-helper-transport-wlan-dummy loopback 2 process cmd: %s %s %i\n", | 1504 | "Starting gnunet-helper-transport-wlan-dummy loopback 2 process cmd: %s %s %i\n", |
1533 | absolute_filename, plugin->interface, plugin->testmode); | 1505 | absolute_filename, plugin->interface, plugin->testmode); |
1534 | #endif | ||
1535 | |||
1536 | plugin->server_proc = | 1506 | plugin->server_proc = |
1537 | GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout, | 1507 | GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout, |
1538 | absolute_filename, absolute_filename, "2", | 1508 | absolute_filename, absolute_filename, "2", |
@@ -1549,10 +1519,8 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin) | |||
1549 | GNUNET_free (absolute_filename); | 1519 | GNUNET_free (absolute_filename); |
1550 | if (plugin->server_proc == NULL) | 1520 | if (plugin->server_proc == NULL) |
1551 | { | 1521 | { |
1552 | #if DEBUG_wlan | ||
1553 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1522 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1554 | "Failed to start gnunet-helper-transport-wlan process\n"); | 1523 | "Failed to start gnunet-helper-transport-wlan process\n"); |
1555 | #endif | ||
1556 | return GNUNET_SYSERR; | 1524 | return GNUNET_SYSERR; |
1557 | } | 1525 | } |
1558 | 1526 | ||
@@ -1574,11 +1542,8 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin) | |||
1574 | 1542 | ||
1575 | GNUNET_assert (plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK); | 1543 | GNUNET_assert (plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK); |
1576 | 1544 | ||
1577 | #if DEBUG_wlan | ||
1578 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1545 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1579 | "Adding server_read_task for the gnunet-helper-transport-wlan\n"); | 1546 | "Adding server_read_task for the gnunet-helper-transport-wlan\n"); |
1580 | #endif | ||
1581 | |||
1582 | plugin->server_read_task = | 1547 | plugin->server_read_task = |
1583 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 1548 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
1584 | plugin->server_stdout_handle, | 1549 | plugin->server_stdout_handle, |
@@ -1597,17 +1562,13 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin) | |||
1597 | static int | 1562 | static int |
1598 | wlan_transport_stop_wlan_helper (struct Plugin *plugin) | 1563 | wlan_transport_stop_wlan_helper (struct Plugin *plugin) |
1599 | { | 1564 | { |
1600 | #if DEBUG_wlan | ||
1601 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1565 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1602 | "Stoping WLAN helper process\n"); | 1566 | "Stoping WLAN helper process\n"); |
1603 | #endif | ||
1604 | 1567 | ||
1605 | if (plugin->helper_is_running == GNUNET_NO) | 1568 | if (plugin->helper_is_running == GNUNET_NO) |
1606 | { | 1569 | { |
1607 | #if DEBUG_wlan | ||
1608 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1570 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1609 | "wlan_transport_stop_wlan_helper not needed, helper already stopped!"); | 1571 | "wlan_transport_stop_wlan_helper not needed, helper already stopped!"); |
1610 | #endif | ||
1611 | return GNUNET_YES; | 1572 | return GNUNET_YES; |
1612 | } | 1573 | } |
1613 | 1574 | ||
@@ -1753,12 +1714,6 @@ finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1753 | static void | 1714 | static void |
1754 | send_hello_beacon (struct Plugin *plugin) | 1715 | send_hello_beacon (struct Plugin *plugin) |
1755 | { | 1716 | { |
1756 | |||
1757 | #if DEBUG_wlan | ||
1758 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | ||
1759 | "Sending hello beacon\n"); | ||
1760 | #endif | ||
1761 | |||
1762 | uint16_t size; | 1717 | uint16_t size; |
1763 | ssize_t bytes; | 1718 | ssize_t bytes; |
1764 | uint16_t hello_size; | 1719 | uint16_t hello_size; |
@@ -1769,6 +1724,9 @@ send_hello_beacon (struct Plugin *plugin) | |||
1769 | const struct GNUNET_MessageHeader *hello; | 1724 | const struct GNUNET_MessageHeader *hello; |
1770 | struct Finish_send *finish; | 1725 | struct Finish_send *finish; |
1771 | 1726 | ||
1727 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | ||
1728 | "Sending hello beacon\n"); | ||
1729 | |||
1772 | GNUNET_assert (plugin != NULL); | 1730 | GNUNET_assert (plugin != NULL); |
1773 | 1731 | ||
1774 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"), | 1732 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"), |
@@ -1874,12 +1832,9 @@ add_ack_for_send (void *cls, uint32_t msg_id, | |||
1874 | GNUNET_CONTAINER_DLL_insert_tail (plugin->ack_send_queue_head, | 1832 | GNUNET_CONTAINER_DLL_insert_tail (plugin->ack_send_queue_head, |
1875 | plugin->ack_send_queue_tail, ack); | 1833 | plugin->ack_send_queue_tail, ack); |
1876 | 1834 | ||
1877 | #if DEBUG_wlan_retransmission > 1 | ||
1878 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1835 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1879 | "Adding ack with message id %u to send, AckSendQueue %p, endpoint %p\n", | 1836 | "Adding ack with message id %u to send, AckSendQueue %p, endpoint %p\n", |
1880 | msg_id, ack, endpoint); | 1837 | msg_id, ack, endpoint); |
1881 | #endif | ||
1882 | |||
1883 | set_next_send (plugin); | 1838 | set_next_send (plugin); |
1884 | } | 1839 | } |
1885 | 1840 | ||
@@ -1955,17 +1910,13 @@ check_fragment_queue (struct Plugin *plugin) | |||
1955 | { | 1910 | { |
1956 | pid = session->target; | 1911 | pid = session->target; |
1957 | pm->transmit_cont (pm->transmit_cont_cls, &pid, GNUNET_OK); | 1912 | pm->transmit_cont (pm->transmit_cont_cls, &pid, GNUNET_OK); |
1958 | #if DEBUG_wlan | ||
1959 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1913 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1960 | "called pm->transmit_cont for %p\n", session); | 1914 | "called pm->transmit_cont for %p\n", session); |
1961 | #endif | ||
1962 | } | 1915 | } |
1963 | else | 1916 | else |
1964 | { | 1917 | { |
1965 | #if DEBUG_wlan | ||
1966 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1918 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1967 | "no pm->transmit_cont for %p\n", session); | 1919 | "no pm->transmit_cont for %p\n", session); |
1968 | #endif | ||
1969 | } | 1920 | } |
1970 | GNUNET_free (pm); | 1921 | GNUNET_free (pm); |
1971 | 1922 | ||
@@ -1995,15 +1946,10 @@ send_ack (struct Plugin *plugin) | |||
1995 | struct Finish_send *finish; | 1946 | struct Finish_send *finish; |
1996 | 1947 | ||
1997 | ack = plugin->ack_send_queue_head; | 1948 | ack = plugin->ack_send_queue_head; |
1998 | |||
1999 | |||
2000 | #if DEBUG_wlan | ||
2001 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1949 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2002 | "Sending ack for message_id %u for mac endpoint %p, size %u\n", | 1950 | "Sending ack for message_id %u for mac endpoint %p, size %u\n", |
2003 | ack->message_id, ack->endpoint, | 1951 | ack->message_id, ack->endpoint, |
2004 | ntohs (ack->hdr->size) - sizeof (struct Radiotap_Send)); | 1952 | ntohs (ack->hdr->size) - sizeof (struct Radiotap_Send)); |
2005 | #endif | ||
2006 | |||
2007 | GNUNET_assert (plugin != NULL); | 1953 | GNUNET_assert (plugin != NULL); |
2008 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1, | 1954 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1, |
2009 | GNUNET_NO); | 1955 | GNUNET_NO); |
@@ -2087,13 +2033,9 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2087 | 2033 | ||
2088 | session = fm->session; | 2034 | session = fm->session; |
2089 | GNUNET_assert (session != NULL); | 2035 | GNUNET_assert (session != NULL); |
2090 | |||
2091 | #if DEBUG_wlan | ||
2092 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2036 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2093 | "Sending GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT for fragment message %p, size: %u\n", | 2037 | "Sending GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT for fragment message %p, size: %u\n", |
2094 | fm, fm->size); | 2038 | fm, fm->size); |
2095 | #endif | ||
2096 | |||
2097 | getRadiotapHeader (plugin, session->mac, fm->radioHeader); | 2039 | getRadiotapHeader (plugin, session->mac, fm->radioHeader); |
2098 | getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin, | 2040 | getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin, |
2099 | fm->size); | 2041 | fm->size); |
@@ -2176,18 +2118,14 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
2176 | if (addrlen == 6) | 2118 | if (addrlen == 6) |
2177 | { | 2119 | { |
2178 | /* TODO check for bad addresses like multicast, broadcast, etc */ | 2120 | /* TODO check for bad addresses like multicast, broadcast, etc */ |
2179 | #if DEBUG_wlan | ||
2180 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2121 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2181 | "wlan_plugin_address_suggested got good address, size %u!\n", | 2122 | "wlan_plugin_address_suggested got good address, size %u!\n", |
2182 | addrlen); | 2123 | addrlen); |
2183 | #endif | ||
2184 | return GNUNET_OK; | 2124 | return GNUNET_OK; |
2185 | } | 2125 | } |
2186 | #if DEBUG_wlan | ||
2187 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2126 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2188 | "wlan_plugin_address_suggested got bad address, size %u!\n", | 2127 | "wlan_plugin_address_suggested got bad address, size %u!\n", |
2189 | addrlen); | 2128 | addrlen); |
2190 | #endif | ||
2191 | return GNUNET_SYSERR; | 2129 | return GNUNET_SYSERR; |
2192 | } | 2130 | } |
2193 | 2131 | ||
@@ -2311,12 +2249,10 @@ wlan_plugin_send (void *cls, | |||
2311 | GNUNET_CONTAINER_DLL_insert_tail (session->pending_message_head, | 2249 | GNUNET_CONTAINER_DLL_insert_tail (session->pending_message_head, |
2312 | session->pending_message_tail, newmsg); | 2250 | session->pending_message_tail, newmsg); |
2313 | 2251 | ||
2314 | #if DEBUG_wlan | ||
2315 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2252 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2316 | "New message for %p with size (incl wlan header) %u added\n", | 2253 | "New message for %p with size (incl wlan header) %u added\n", |
2317 | session, newmsg->message_size); | 2254 | session, newmsg->message_size); |
2318 | #endif | 2255 | #if DEBUG_WLAN > 1 |
2319 | #if DEBUG_wlan_msg_dump > 1 | ||
2320 | hexdump (msgbuf, GNUNET_MIN (msgbuf_size, 256)); | 2256 | hexdump (msgbuf, GNUNET_MIN (msgbuf_size, 256)); |
2321 | #endif | 2257 | #endif |
2322 | //queue session | 2258 | //queue session |
@@ -2519,15 +2455,13 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type, | |||
2519 | const unsigned char *input; | 2455 | const unsigned char *input; |
2520 | 2456 | ||
2521 | //GNUNET_assert(cls !=NULL); | 2457 | //GNUNET_assert(cls !=NULL); |
2522 | if (addrlen != sizeof (struct MacAddress)) | 2458 | if (addrlen != sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) |
2523 | { | 2459 | { |
2524 | /* invalid address (MAC addresses have 6 bytes) */ | 2460 | /* invalid address (MAC addresses have 6 bytes) */ |
2525 | //GNUNET_break (0); | 2461 | //GNUNET_break (0); |
2526 | #if DEBUG_wlan | ||
2527 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2462 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2528 | "Func wlan_plugin_address_pretty_printer got size: %u, worng size!\n", | 2463 | "Func wlan_plugin_address_pretty_printer got size: %u, worng size!\n", |
2529 | addrlen); | 2464 | addrlen); |
2530 | #endif | ||
2531 | asc (asc_cls, NULL); | 2465 | asc (asc_cls, NULL); |
2532 | return; | 2466 | return; |
2533 | } | 2467 | } |
@@ -2536,11 +2470,9 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type, | |||
2536 | "Transport %s: %s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 2470 | "Transport %s: %s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
2537 | type, PROTOCOL_PREFIX, input[0], input[1], input[2], | 2471 | type, PROTOCOL_PREFIX, input[0], input[1], input[2], |
2538 | input[3], input[4], input[5]); | 2472 | input[3], input[4], input[5]); |
2539 | #if DEBUG_wlan | ||
2540 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2473 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2541 | "Func wlan_plugin_address_pretty_printer got size: %u, nummeric %u, type %s; made string: %s\n", | 2474 | "Func wlan_plugin_address_pretty_printer got size: %u, nummeric %u, type %s; made string: %s\n", |
2542 | addrlen, numeric, type, ret); | 2475 | addrlen, numeric, type, ret); |
2543 | #endif | ||
2544 | asc (asc_cls, ret); | 2476 | asc (asc_cls, ret); |
2545 | //only one mac address per plugin | 2477 | //only one mac address per plugin |
2546 | asc (asc_cls, NULL); | 2478 | asc (asc_cls, NULL); |
@@ -2570,11 +2502,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2570 | if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_DATA) | 2502 | if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_DATA) |
2571 | { | 2503 | { |
2572 | 2504 | ||
2573 | #if DEBUG_wlan | ||
2574 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2505 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2575 | "Func wlan_data_message_handler got GNUNET_MESSAGE_TYPE_WLAN_DATA size: %u\n", | 2506 | "Func wlan_data_message_handler got GNUNET_MESSAGE_TYPE_WLAN_DATA size: %u\n", |
2576 | ntohs (hdr->size)); | 2507 | ntohs (hdr->size)); |
2577 | #endif | ||
2578 | 2508 | ||
2579 | if (ntohs (hdr->size) < | 2509 | if (ntohs (hdr->size) < |
2580 | sizeof (struct WlanHeader) + sizeof (struct GNUNET_MessageHeader)) | 2510 | sizeof (struct WlanHeader) + sizeof (struct GNUNET_MessageHeader)) |
@@ -2609,12 +2539,10 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2609 | //if not in session list | 2539 | //if not in session list |
2610 | if (session == NULL) | 2540 | if (session == NULL) |
2611 | { | 2541 | { |
2612 | #if DEBUG_wlan | ||
2613 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2542 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2614 | "WLAN client not in session list: packet size = %u, inner size = %u, header size = %u\n", | 2543 | "WLAN client not in session list: packet size = %u, inner size = %u, header size = %u\n", |
2615 | ntohs (wlanheader->header.size), ntohs (temp_hdr->size), | 2544 | ntohs (wlanheader->header.size), ntohs (temp_hdr->size), |
2616 | sizeof (struct WlanHeader)); | 2545 | sizeof (struct WlanHeader)); |
2617 | #endif | ||
2618 | //try if it is a hello message | 2546 | //try if it is a hello message |
2619 | if (ntohs (wlanheader->header.size) >= | 2547 | if (ntohs (wlanheader->header.size) >= |
2620 | ntohs (temp_hdr->size) + sizeof (struct WlanHeader)) | 2548 | ntohs (temp_hdr->size) + sizeof (struct WlanHeader)) |
@@ -2659,11 +2587,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2659 | sizeof (struct GNUNET_PeerIdentity)) != 0) | 2587 | sizeof (struct GNUNET_PeerIdentity)) != 0) |
2660 | { | 2588 | { |
2661 | //wrong peer id | 2589 | //wrong peer id |
2662 | #if DEBUG_wlan | ||
2663 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2590 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2664 | "WLAN peer source id doesn't match packet peer source id: session %p\n", | 2591 | "WLAN peer source id doesn't match packet peer source id: session %p\n", |
2665 | session); | 2592 | session); |
2666 | #endif | ||
2667 | return; | 2593 | return; |
2668 | } | 2594 | } |
2669 | 2595 | ||
@@ -2672,11 +2598,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2672 | sizeof (struct GNUNET_PeerIdentity)) != 0) | 2598 | sizeof (struct GNUNET_PeerIdentity)) != 0) |
2673 | { | 2599 | { |
2674 | //wrong peer id | 2600 | //wrong peer id |
2675 | #if DEBUG_wlan | ||
2676 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2601 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2677 | "WLAN peer target id doesn't match our peer id: session %p\n", | 2602 | "WLAN peer target id doesn't match our peer id: session %p\n", |
2678 | session); | 2603 | session); |
2679 | #endif | ||
2680 | return; | 2604 | return; |
2681 | } | 2605 | } |
2682 | 2606 | ||
@@ -2718,15 +2642,12 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
2718 | ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); | 2642 | ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); |
2719 | ats[1].value = htonl (GNUNET_ATS_NET_WLAN); | 2643 | ats[1].value = htonl (GNUNET_ATS_NET_WLAN); |
2720 | 2644 | ||
2721 | #if DEBUG_wlan | ||
2722 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2645 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2723 | "Calling plugin->env->receive for session %p; %s; size: %u\n", | 2646 | "Calling plugin->env->receive for session %p; %s; size: %u\n", |
2724 | session, wlan_plugin_address_to_string (NULL, | 2647 | session, wlan_plugin_address_to_string (NULL, |
2725 | session->mac-> | 2648 | session->mac-> |
2726 | addr.mac, 6), | 2649 | addr.mac, 6), |
2727 | htons (hdr->size)); | 2650 | htons (hdr->size)); |
2728 | #endif | ||
2729 | |||
2730 | plugin->env->receive (plugin->env->cls, &(session->target), hdr, | 2651 | plugin->env->receive (plugin->env->cls, &(session->target), hdr, |
2731 | (const struct GNUNET_ATS_Information *) &ats, 2, | 2652 | (const struct GNUNET_ATS_Information *) &ats, 2, |
2732 | session, (const char *) &session->mac->addr, | 2653 | session, (const char *) &session->mac->addr, |
@@ -2761,14 +2682,11 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2761 | //TODO test first than create session | 2682 | //TODO test first than create session |
2762 | GNUNET_assert (session_light != NULL); | 2683 | GNUNET_assert (session_light != NULL); |
2763 | 2684 | ||
2764 | #if DEBUG_wlan | ||
2765 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2685 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2766 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_HELLO size: %u; %s\n", | 2686 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_HELLO size: %u; %s\n", |
2767 | ntohs (hdr->size), wlan_plugin_address_to_string (NULL, | 2687 | ntohs (hdr->size), wlan_plugin_address_to_string (NULL, |
2768 | session_light->addr. | 2688 | session_light->addr. |
2769 | mac, 6)); | 2689 | mac, 6)); |
2770 | #endif | ||
2771 | |||
2772 | if (session_light->macendpoint == NULL) | 2690 | if (session_light->macendpoint == NULL) |
2773 | { | 2691 | { |
2774 | session_light->macendpoint = | 2692 | session_light->macendpoint = |
@@ -2814,15 +2732,12 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2814 | get_macendpoint (plugin, &session_light->addr, GNUNET_YES); | 2732 | get_macendpoint (plugin, &session_light->addr, GNUNET_YES); |
2815 | } | 2733 | } |
2816 | 2734 | ||
2817 | #if DEBUG_wlan | ||
2818 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2735 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2819 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT with size: %u; mac endpoint %p: %s\n", | 2736 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT with size: %u; mac endpoint %p: %s\n", |
2820 | ntohs (hdr->size), session_light->macendpoint, | 2737 | ntohs (hdr->size), session_light->macendpoint, |
2821 | wlan_plugin_address_to_string (NULL, | 2738 | wlan_plugin_address_to_string (NULL, |
2822 | session_light->addr.mac, | 2739 | session_light->addr.mac, |
2823 | 6)); | 2740 | 6)); |
2824 | #endif | ||
2825 | |||
2826 | GNUNET_STATISTICS_update (plugin->env->stats, | 2741 | GNUNET_STATISTICS_update (plugin->env->stats, |
2827 | _("# wlan fragments received"), 1, GNUNET_NO); | 2742 | _("# wlan fragments received"), 1, GNUNET_NO); |
2828 | int ret = | 2743 | int ret = |
@@ -2854,24 +2769,20 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2854 | 2769 | ||
2855 | if (session_light->macendpoint == NULL) | 2770 | if (session_light->macendpoint == NULL) |
2856 | { | 2771 | { |
2857 | #if DEBUG_wlan | ||
2858 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2772 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2859 | "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n", | 2773 | "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n", |
2860 | ntohs (hdr->size), wlan_plugin_address_to_string (NULL, | 2774 | ntohs (hdr->size), wlan_plugin_address_to_string (NULL, |
2861 | session_light->addr.mac, | 2775 | session_light->addr.mac, |
2862 | 6)); | 2776 | 6)); |
2863 | #endif | ||
2864 | return; | 2777 | return; |
2865 | } | 2778 | } |
2866 | 2779 | ||
2867 | #if DEBUG_wlan | ||
2868 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2780 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2869 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; mac endpoint: %p; %s\n", | 2781 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; mac endpoint: %p; %s\n", |
2870 | ntohs (hdr->size), session_light->macendpoint, | 2782 | ntohs (hdr->size), session_light->macendpoint, |
2871 | wlan_plugin_address_to_string (NULL, | 2783 | wlan_plugin_address_to_string (NULL, |
2872 | session_light->addr.mac, | 2784 | session_light->addr.mac, |
2873 | 6)); | 2785 | 6)); |
2874 | #endif | ||
2875 | fm = session_light->macendpoint->sending_messages_head; | 2786 | fm = session_light->macendpoint->sending_messages_head; |
2876 | while (fm != NULL) | 2787 | while (fm != NULL) |
2877 | { | 2788 | { |
@@ -2882,10 +2793,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2882 | 2793 | ||
2883 | if (ret == GNUNET_OK) | 2794 | if (ret == GNUNET_OK) |
2884 | { | 2795 | { |
2885 | #if DEBUG_wlan_retransmission > 1 | ||
2886 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2796 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2887 | "Got last ack, finished fragment message %p\n", fm); | 2797 | "Got last ack, finished fragment message %p\n", fm); |
2888 | #endif | ||
2889 | session_light->macendpoint->acks++; | 2798 | session_light->macendpoint->acks++; |
2890 | fm->session->last_activity = GNUNET_TIME_absolute_get (); | 2799 | fm->session->last_activity = GNUNET_TIME_absolute_get (); |
2891 | session_light->macendpoint->last_activity = fm->session->last_activity; | 2800 | session_light->macendpoint->last_activity = fm->session->last_activity; |
@@ -2895,10 +2804,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2895 | } | 2804 | } |
2896 | if (ret == GNUNET_NO) | 2805 | if (ret == GNUNET_NO) |
2897 | { | 2806 | { |
2898 | #if DEBUG_wlan_retransmission > 1 | ||
2899 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2807 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2900 | "Got ack for: %p\n", fm); | 2808 | "Got ack for: %p\n", fm); |
2901 | #endif | ||
2902 | session_light->macendpoint->acks++; | 2809 | session_light->macendpoint->acks++; |
2903 | return; | 2810 | return; |
2904 | } | 2811 | } |
@@ -2910,10 +2817,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2910 | fm = fm2; | 2817 | fm = fm2; |
2911 | } | 2818 | } |
2912 | 2819 | ||
2913 | #if DEBUG_wlan_retransmission > 1 | ||
2914 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2820 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2915 | "WLAN fragment not in fragment list\n"); | 2821 | "WLAN fragment not in fragment list\n"); |
2916 | #endif | ||
2917 | return; | 2822 | return; |
2918 | 2823 | ||
2919 | } | 2824 | } |
@@ -2934,7 +2839,6 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2934 | 2839 | ||
2935 | } | 2840 | } |
2936 | 2841 | ||
2937 | #if DEBUG_wlan | ||
2938 | /** | 2842 | /** |
2939 | * Function to print mac addresses nice * | 2843 | * Function to print mac addresses nice * |
2940 | * @param pointer to 6 byte with the mac address | 2844 | * @param pointer to 6 byte with the mac address |
@@ -2949,7 +2853,6 @@ macprinter (const u_int8_t * mac) | |||
2949 | mac[2], mac[3], mac[4], mac[5]); | 2853 | mac[2], mac[3], mac[4], mac[5]); |
2950 | return macstr; | 2854 | return macstr; |
2951 | } | 2855 | } |
2952 | #endif | ||
2953 | 2856 | ||
2954 | /** | 2857 | /** |
2955 | * Function for the scheduler if a mac endpoint times out | 2858 | * Function for the scheduler if a mac endpoint times out |
@@ -2991,7 +2894,7 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2991 | * @return returns a macendpoint | 2894 | * @return returns a macendpoint |
2992 | */ | 2895 | */ |
2993 | static struct MacEndpoint * | 2896 | static struct MacEndpoint * |
2994 | create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr) | 2897 | create_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr) |
2995 | { | 2898 | { |
2996 | struct MacEndpoint *newend = GNUNET_malloc (sizeof (struct MacEndpoint)); | 2899 | struct MacEndpoint *newend = GNUNET_malloc (sizeof (struct MacEndpoint)); |
2997 | 2900 | ||
@@ -3016,11 +2919,9 @@ create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr) | |||
3016 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan mac endpoints"), | 2919 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan mac endpoints"), |
3017 | plugin->mac_count, GNUNET_NO); | 2920 | plugin->mac_count, GNUNET_NO); |
3018 | GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend); | 2921 | GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend); |
3019 | #if DEBUG_wlan | ||
3020 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2922 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3021 | "New Mac Endpoint %p: %s\n", newend, | 2923 | "New Mac Endpoint %p: %s\n", newend, |
3022 | wlan_plugin_address_to_string (NULL, newend->addr.mac, 6)); | 2924 | wlan_plugin_address_to_string (NULL, newend->addr.mac, 6)); |
3023 | #endif | ||
3024 | return newend; | 2925 | return newend; |
3025 | } | 2926 | } |
3026 | 2927 | ||
@@ -3048,12 +2949,9 @@ wlan_process_helper (void *cls, void *client, | |||
3048 | switch (ntohs (hdr->type)) | 2949 | switch (ntohs (hdr->type)) |
3049 | { | 2950 | { |
3050 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA: | 2951 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA: |
3051 | #if DEBUG_wlan | ||
3052 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2952 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3053 | "Func wlan_process_helper got GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA size: %u\n", | 2953 | "Func wlan_process_helper got GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA size: %u\n", |
3054 | ntohs (hdr->size)); | 2954 | ntohs (hdr->size)); |
3055 | #endif | ||
3056 | |||
3057 | GNUNET_STATISTICS_update (plugin->env->stats, | 2955 | GNUNET_STATISTICS_update (plugin->env->stats, |
3058 | _("# wlan WLAN_HELPER_DATA received"), 1, | 2956 | _("# wlan WLAN_HELPER_DATA received"), 1, |
3059 | GNUNET_NO); | 2957 | GNUNET_NO); |
@@ -3062,13 +2960,11 @@ wlan_process_helper (void *cls, void *client, | |||
3062 | sizeof (struct ieee80211_frame) + | 2960 | sizeof (struct ieee80211_frame) + |
3063 | 2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx)) | 2961 | 2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx)) |
3064 | { | 2962 | { |
3065 | #if DEBUG_wlan | ||
3066 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2963 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3067 | "Size of packet is too small; size: %u min size: %u\n", | 2964 | "Size of packet is too small; size: %u min size: %u\n", |
3068 | ntohs (hdr->size), | 2965 | ntohs (hdr->size), |
3069 | sizeof (struct ieee80211_frame) + | 2966 | sizeof (struct ieee80211_frame) + |
3070 | sizeof (struct GNUNET_MessageHeader)); | 2967 | sizeof (struct GNUNET_MessageHeader)); |
3071 | #endif | ||
3072 | //GNUNET_break (0); | 2968 | //GNUNET_break (0); |
3073 | /* FIXME: restart SUID process */ | 2969 | /* FIXME: restart SUID process */ |
3074 | return; | 2970 | return; |
@@ -3082,20 +2978,20 @@ wlan_process_helper (void *cls, void *client, | |||
3082 | //check for bssid | 2978 | //check for bssid |
3083 | if (memcmp | 2979 | if (memcmp |
3084 | (&(wlanIeeeHeader->i_addr3), &mac_bssid_gnunet, | 2980 | (&(wlanIeeeHeader->i_addr3), &mac_bssid_gnunet, |
3085 | sizeof (struct MacAddress)) == 0) | 2981 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) |
3086 | { | 2982 | { |
3087 | //check for broadcast or mac | 2983 | //check for broadcast or mac |
3088 | if ((memcmp | 2984 | if ((memcmp |
3089 | (&(wlanIeeeHeader->i_addr1), &bc_all_mac, | 2985 | (&(wlanIeeeHeader->i_addr1), &bc_all_mac, |
3090 | sizeof (struct MacAddress)) == 0) || | 2986 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) || |
3091 | (memcmp | 2987 | (memcmp |
3092 | (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address), | 2988 | (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address), |
3093 | sizeof (struct MacAddress)) == 0)) | 2989 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)) |
3094 | { | 2990 | { |
3095 | //if packet is from us return | 2991 | //if packet is from us return |
3096 | if ((memcmp | 2992 | if ((memcmp |
3097 | (&(wlanIeeeHeader->i_addr2), &(plugin->mac_address), | 2993 | (&(wlanIeeeHeader->i_addr2), &(plugin->mac_address), |
3098 | sizeof (struct MacAddress)) == 0)) | 2994 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)) |
3099 | { | 2995 | { |
3100 | return; | 2996 | return; |
3101 | } | 2997 | } |
@@ -3108,7 +3004,7 @@ wlan_process_helper (void *cls, void *client, | |||
3108 | 3004 | ||
3109 | session_light = GNUNET_malloc (sizeof (struct Session_light)); | 3005 | session_light = GNUNET_malloc (sizeof (struct Session_light)); |
3110 | memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2), | 3006 | memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2), |
3111 | sizeof (struct MacAddress)); | 3007 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); |
3112 | //session_light->session = search_session(plugin,session_light->addr); | 3008 | //session_light->session = search_session(plugin,session_light->addr); |
3113 | GNUNET_STATISTICS_update (plugin->env->stats, | 3009 | GNUNET_STATISTICS_update (plugin->env->stats, |
3114 | _("# wlan messages for this client received"), | 3010 | _("# wlan messages for this client received"), |
@@ -3128,11 +3024,9 @@ wlan_process_helper (void *cls, void *client, | |||
3128 | } | 3024 | } |
3129 | else | 3025 | else |
3130 | { | 3026 | { |
3131 | #if DEBUG_wlan | ||
3132 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 3027 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3133 | "Size of packet is too small; size: %u > size of packet: %u\n", | 3028 | "Size of packet is too small; size: %u > size of packet: %u\n", |
3134 | ntohs (temp_hdr->size), datasize + pos); | 3029 | ntohs (temp_hdr->size), datasize + pos); |
3135 | #endif | ||
3136 | } | 3030 | } |
3137 | pos += ntohs (temp_hdr->size); | 3031 | pos += ntohs (temp_hdr->size); |
3138 | 3032 | ||
@@ -3143,20 +3037,16 @@ wlan_process_helper (void *cls, void *client, | |||
3143 | } | 3037 | } |
3144 | else | 3038 | else |
3145 | { | 3039 | { |
3146 | #if DEBUG_wlan | ||
3147 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 3040 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3148 | "Func wlan_process_helper got wrong MAC: %s\n", | 3041 | "Func wlan_process_helper got wrong MAC: %s\n", |
3149 | macprinter (wlanIeeeHeader->i_addr1)); | 3042 | macprinter (wlanIeeeHeader->i_addr1)); |
3150 | #endif | ||
3151 | } | 3043 | } |
3152 | } | 3044 | } |
3153 | else | 3045 | else |
3154 | { | 3046 | { |
3155 | #if DEBUG_wlan | ||
3156 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 3047 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3157 | "Func wlan_process_helper got wrong BSSID: %s\n", | 3048 | "Func wlan_process_helper got wrong BSSID: %s\n", |
3158 | macprinter (wlanIeeeHeader->i_addr2)); | 3049 | macprinter (wlanIeeeHeader->i_addr2)); |
3159 | #endif | ||
3160 | } | 3050 | } |
3161 | break; | 3051 | break; |
3162 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: | 3052 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: |
@@ -3167,26 +3057,21 @@ wlan_process_helper (void *cls, void *client, | |||
3167 | /* FIXME: restart SUID process */ | 3057 | /* FIXME: restart SUID process */ |
3168 | return; | 3058 | return; |
3169 | } | 3059 | } |
3170 | memcpy (&plugin->mac_address, &hdr[1], sizeof (struct MacAddress)); | 3060 | memcpy (&plugin->mac_address, &hdr[1], sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); |
3171 | #if DEBUG_wlan | ||
3172 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 3061 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3173 | "Received WLAN_HELPER_CONTROL message with transport of address %s\n", | 3062 | "Received WLAN_HELPER_CONTROL message with transport of address %s\n", |
3174 | wlan_plugin_address_to_string (cls, &plugin->mac_address, | 3063 | wlan_plugin_address_to_string (cls, &plugin->mac_address, |
3175 | sizeof (struct | 3064 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))); |
3176 | MacAddress))); | ||
3177 | #endif | ||
3178 | plugin->env->notify_address (plugin->env->cls, GNUNET_YES, | 3065 | plugin->env->notify_address (plugin->env->cls, GNUNET_YES, |
3179 | &plugin->mac_address, | 3066 | &plugin->mac_address, |
3180 | sizeof (struct MacAddress)); | 3067 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); |
3181 | break; | 3068 | break; |
3182 | default: | 3069 | default: |
3183 | #if DEBUG_wlan | ||
3184 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 3070 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3185 | "Func wlan_process_helper got unknown message with number %u, size %u\n", | 3071 | "Func wlan_process_helper got unknown message with number %u, size %u\n", |
3186 | ntohs (hdr->type), ntohs (hdr->size)); | 3072 | ntohs (hdr->type), ntohs (hdr->size)); |
3187 | 3073 | ||
3188 | #endif | 3074 | #if DEBUG_WLAN > 1 |
3189 | #if DEBUG_wlan_msg_dump > 1 | ||
3190 | hexdump (hdr, GNUNET_MIN (ntohs (hdr->size), 256)); | 3075 | hexdump (hdr, GNUNET_MIN (ntohs (hdr->size), 256)); |
3191 | #endif | 3076 | #endif |
3192 | GNUNET_break (0); | 3077 | GNUNET_break (0); |
@@ -3208,11 +3093,8 @@ libgnunet_plugin_transport_wlan_done (void *cls) | |||
3208 | struct MacEndpoint *endpoint = plugin->mac_head; | 3093 | struct MacEndpoint *endpoint = plugin->mac_head; |
3209 | struct MacEndpoint *endpoint_next; | 3094 | struct MacEndpoint *endpoint_next; |
3210 | 3095 | ||
3211 | #if DEBUG_wlan | ||
3212 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 3096 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3213 | "libgnunet_plugin_transport_wlan_done started\n"); | 3097 | "libgnunet_plugin_transport_wlan_done started\n"); |
3214 | #endif | ||
3215 | |||
3216 | wlan_transport_stop_wlan_helper (plugin); | 3098 | wlan_transport_stop_wlan_helper (plugin); |
3217 | 3099 | ||
3218 | GNUNET_assert (cls != NULL); | 3100 | GNUNET_assert (cls != NULL); |
@@ -3311,11 +3193,8 @@ libgnunet_plugin_transport_wlan_init (void *cls) | |||
3311 | wlan_transport_start_wlan_helper (plugin); | 3193 | wlan_transport_start_wlan_helper (plugin); |
3312 | set_next_beacon_time (plugin); | 3194 | set_next_beacon_time (plugin); |
3313 | set_next_send (plugin); | 3195 | set_next_send (plugin); |
3314 | #if DEBUG_wlan | ||
3315 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 3196 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3316 | "wlan init finished\n"); | 3197 | "wlan init finished\n"); |
3317 | #endif | ||
3318 | |||
3319 | return api; | 3198 | return api; |
3320 | } | 3199 | } |
3321 | 3200 | ||
diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h index b0b8b966a..9e1bc4f22 100644 --- a/src/transport/plugin_transport_wlan.h +++ b/src/transport/plugin_transport_wlan.h | |||
@@ -34,38 +34,37 @@ | |||
34 | */ | 34 | */ |
35 | #define MAC_ADDR_SIZE 6 | 35 | #define MAC_ADDR_SIZE 6 |
36 | 36 | ||
37 | GNUNET_NETWORK_STRUCT_BEGIN | ||
37 | /** | 38 | /** |
38 | * A MAC Address. | 39 | * A MAC Address. |
39 | */ | 40 | */ |
40 | struct MacAddress | 41 | struct GNUNET_TRANSPORT_WLAN_MacAddress |
41 | { | 42 | { |
42 | uint8_t mac[MAC_ADDR_SIZE]; | 43 | uint8_t mac[MAC_ADDR_SIZE]; |
43 | }; | 44 | }; |
44 | 45 | ||
45 | |||
46 | GNUNET_NETWORK_STRUCT_BEGIN | ||
47 | |||
48 | /** | 46 | /** |
49 | * Format of a WLAN Control Message. | 47 | * Format of a WLAN Control Message. |
50 | */ | 48 | */ |
51 | struct GNUNET_TRANSPORT_WLAN_HelperControlMessage | 49 | struct GNUNET_TRANSPORT_WLAN_HelperControlMessage |
52 | { | 50 | { |
53 | /** | 51 | /** |
54 | * Message header. FIXME: type? | 52 | * Message header. Type is |
53 | * GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL | ||
55 | */ | 54 | */ |
56 | struct GNUNET_MessageHeader hdr; | 55 | struct GNUNET_MessageHeader hdr; |
57 | 56 | ||
58 | /** | 57 | /** |
59 | * MAC Address. FIXME: of what? | 58 | * MAC Address of the local WLAN interface. |
60 | */ | 59 | */ |
61 | struct MacAddress mac; | 60 | struct GNUNET_TRANSPORT_WLAN_MacAddress mac; |
62 | }; | 61 | }; |
63 | GNUNET_NETWORK_STRUCT_END | 62 | GNUNET_NETWORK_STRUCT_END |
64 | 63 | ||
65 | /** | 64 | /** |
66 | * GNUnet bssid | 65 | * GNUnet bssid |
67 | */ | 66 | */ |
68 | static const struct MacAddress mac_bssid_gnunet = { | 67 | static const struct GNUNET_TRANSPORT_WLAN_MacAddress mac_bssid_gnunet = { |
69 | {0x13, 0x22, 0x33, 0x44, 0x55, 0x66} | 68 | {0x13, 0x22, 0x33, 0x44, 0x55, 0x66} |
70 | }; | 69 | }; |
71 | 70 | ||
@@ -73,7 +72,7 @@ static const struct MacAddress mac_bssid_gnunet = { | |||
73 | /** | 72 | /** |
74 | * Broadcast MAC | 73 | * Broadcast MAC |
75 | */ | 74 | */ |
76 | static const struct MacAddress bc_all_mac = { | 75 | static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac = { |
77 | {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} | 76 | {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} |
78 | }; | 77 | }; |
79 | 78 | ||