diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-16 15:33:26 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-16 15:33:26 +0000 |
commit | c307dc2bda434d1243422a6a102ac5dbb6fa00a2 (patch) | |
tree | 99cf8710079e1f831ef866e4571c9f3e2216bf3e /src/transport/gnunet-helper-transport-wlan.c | |
parent | 4196cd3056bf6def859cdeba316cc8f5f19db05c (diff) | |
download | gnunet-c307dc2bda434d1243422a6a102ac5dbb6fa00a2.tar.gz gnunet-c307dc2bda434d1243422a6a102ac5dbb6fa00a2.zip |
-more cleanup for #1939
Diffstat (limited to 'src/transport/gnunet-helper-transport-wlan.c')
-rw-r--r-- | src/transport/gnunet-helper-transport-wlan.c | 68 |
1 files changed, 30 insertions, 38 deletions
diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c index 51b9ba32d..2ed81a24d 100644 --- a/src/transport/gnunet-helper-transport-wlan.c +++ b/src/transport/gnunet-helper-transport-wlan.c | |||
@@ -70,10 +70,10 @@ | |||
70 | * Modifications to fit into the linux IEEE 802.11 stack, | 70 | * Modifications to fit into the linux IEEE 802.11 stack, |
71 | * Mike Kershaw (dragorn@kismetwireless.net) | 71 | * Mike Kershaw (dragorn@kismetwireless.net) |
72 | */ | 72 | */ |
73 | 73 | /* | |
74 | /** | ||
75 | * parts taken from aircrack-ng, parts changend. | 74 | * parts taken from aircrack-ng, parts changend. |
76 | */ | 75 | */ |
76 | |||
77 | #define _GNU_SOURCE | 77 | #define _GNU_SOURCE |
78 | #include <sys/socket.h> | 78 | #include <sys/socket.h> |
79 | #include <sys/ioctl.h> | 79 | #include <sys/ioctl.h> |
@@ -106,10 +106,6 @@ | |||
106 | #define ARPHRD_IEEE80211_PRISM 802 | 106 | #define ARPHRD_IEEE80211_PRISM 802 |
107 | #define ARPHRD_IEEE80211_FULL 803 | 107 | #define ARPHRD_IEEE80211_FULL 803 |
108 | 108 | ||
109 | /** | ||
110 | * size of 802.11 address | ||
111 | */ | ||
112 | #define IEEE80211_ADDR_LEN 6 | ||
113 | 109 | ||
114 | /** | 110 | /** |
115 | * Maximum size of a message allowed in either direction. | 111 | * Maximum size of a message allowed in either direction. |
@@ -368,18 +364,6 @@ struct SendBuffer | |||
368 | char buf[MAXLINE * 2]; | 364 | char buf[MAXLINE * 2]; |
369 | }; | 365 | }; |
370 | 366 | ||
371 | /** | ||
372 | * Buffer for data read from stdin to be transmitted to the wirless card. | ||
373 | */ | ||
374 | static struct SendBuffer write_pout; | ||
375 | |||
376 | /** | ||
377 | * Buffer for data read from the wireless card to be transmitted to stdout. | ||
378 | */ | ||
379 | static struct SendBuffer write_std; | ||
380 | |||
381 | |||
382 | |||
383 | 367 | ||
384 | /** | 368 | /** |
385 | * struct for storing the information of the hardware | 369 | * struct for storing the information of the hardware |
@@ -458,6 +442,17 @@ struct ieee80211_radiotap_iterator | |||
458 | }; | 442 | }; |
459 | 443 | ||
460 | 444 | ||
445 | /** | ||
446 | * Buffer for data read from stdin to be transmitted to the wirless card. | ||
447 | */ | ||
448 | static struct SendBuffer write_pout; | ||
449 | |||
450 | /** | ||
451 | * Buffer for data read from the wireless card to be transmitted to stdout. | ||
452 | */ | ||
453 | static struct SendBuffer write_std; | ||
454 | |||
455 | |||
461 | 456 | ||
462 | /* specialized version of server_mst.c begins here */ | 457 | /* specialized version of server_mst.c begins here */ |
463 | 458 | ||
@@ -520,7 +515,6 @@ struct MessageStreamTokenizer | |||
520 | }; | 515 | }; |
521 | 516 | ||
522 | 517 | ||
523 | |||
524 | /** | 518 | /** |
525 | * Create a message stream tokenizer. | 519 | * Create a message stream tokenizer. |
526 | * | 520 | * |
@@ -1095,12 +1089,13 @@ linux_get_channel (const struct HardwareInfos *dev) | |||
1095 | * @param dev pointer to the struct of the wlan card | 1089 | * @param dev pointer to the struct of the wlan card |
1096 | * @param buf buffer to read to | 1090 | * @param buf buffer to read to |
1097 | * @param buf_size size of the buffer | 1091 | * @param buf_size size of the buffer |
1098 | * @param ri radiotap_rx info | 1092 | * @param ri where to write radiotap_rx info |
1099 | * @return size read from the buffer | 1093 | * @return size read from the buffer |
1100 | */ | 1094 | */ |
1101 | static ssize_t | 1095 | static ssize_t |
1102 | linux_read (struct HardwareInfos *dev, unsigned char *buf, size_t buf_size, | 1096 | linux_read (struct HardwareInfos *dev, |
1103 | struct Radiotap_rx *ri) | 1097 | unsigned char *buf, size_t buf_size, |
1098 | struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *ri) | ||
1104 | { | 1099 | { |
1105 | unsigned char tmpbuf[buf_size]; | 1100 | unsigned char tmpbuf[buf_size]; |
1106 | ssize_t caplen; | 1101 | ssize_t caplen; |
@@ -1701,33 +1696,30 @@ main (int argc, char *argv[]) | |||
1701 | 1696 | ||
1702 | if (FD_ISSET (dev.fd_raw, &rfds)) | 1697 | if (FD_ISSET (dev.fd_raw, &rfds)) |
1703 | { | 1698 | { |
1704 | struct GNUNET_MessageHeader *header; | 1699 | struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rrm; |
1705 | struct Radiotap_rx *rxinfo; | ||
1706 | struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *datastart; | ||
1707 | ssize_t ret; | 1700 | ssize_t ret; |
1708 | 1701 | ||
1709 | header = (struct GNUNET_MessageHeader *) write_std.buf; | 1702 | rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf; |
1710 | rxinfo = (struct Radiotap_rx *) &header[1]; | ||
1711 | datastart = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) &rxinfo[1]; | ||
1712 | ret = | 1703 | ret = |
1713 | linux_read (&dev, (unsigned char *) datastart, | 1704 | linux_read (&dev, (unsigned char *) &rrm->frame, |
1714 | sizeof (write_std.buf) - sizeof (struct Radiotap_rx) - | 1705 | sizeof (write_std.buf) |
1715 | sizeof (struct GNUNET_MessageHeader), rxinfo); | 1706 | - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) |
1707 | + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), | ||
1708 | rrm); | ||
1716 | if (0 > ret) | 1709 | if (0 > ret) |
1717 | { | 1710 | { |
1718 | fprintf (stderr, "Read error from raw socket: %s\n", strerror (errno)); | 1711 | fprintf (stderr, "Read error from raw socket: %s\n", strerror (errno)); |
1719 | break; | 1712 | break; |
1720 | } | 1713 | } |
1721 | if ((0 < ret) && (0 == mac_test (datastart, &dev))) | 1714 | if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev))) |
1722 | { | 1715 | { |
1723 | write_std.size = | 1716 | write_std.size = ret |
1724 | ret + sizeof (struct GNUNET_MessageHeader) + | 1717 | + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) |
1725 | sizeof (struct Radiotap_rx); | 1718 | - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame); |
1726 | header->size = htons (write_std.size); | 1719 | rrm->header.size = htons (write_std.size); |
1727 | header->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); | 1720 | rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); |
1728 | } | 1721 | } |
1729 | } | 1722 | } |
1730 | |||
1731 | } | 1723 | } |
1732 | /* Error handling, try to clean up a bit at least */ | 1724 | /* Error handling, try to clean up a bit at least */ |
1733 | mst_destroy (stdin_mst); | 1725 | mst_destroy (stdin_mst); |