diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-25 09:18:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-25 09:18:53 +0000 |
commit | bd4822b448a18c28b07754efff1d962630a0da31 (patch) | |
tree | acc3f6657d374038bee5aac68c731487925a6d1a /src/transport | |
parent | a26f62fb03c3570f7792d3a94c177cb40ade9297 (diff) | |
download | gnunet-bd4822b448a18c28b07754efff1d962630a0da31.tar.gz gnunet-bd4822b448a18c28b07754efff1d962630a0da31.zip |
inlining files from wlan, preparing to obsolete wlan subdirectory
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/Makefile.am | 11 | ||||
-rw-r--r-- | src/transport/gnunet-transport-wlan-helper-dummy.c | 59 | ||||
-rw-r--r-- | src/transport/gnunet-transport-wlan-helper.c | 1087 | ||||
-rw-r--r-- | src/transport/gnunet-transport-wlan-helper.h | 60 | ||||
-rw-r--r-- | src/transport/wlan/helper_common.c | 48 | ||||
-rw-r--r-- | src/transport/wlan/helper_common.h | 24 | ||||
-rw-r--r-- | src/transport/wlan/loopback_helper.h | 26 |
7 files changed, 1074 insertions, 241 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 3334607fa..b836812ff 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -109,20 +109,11 @@ gnunet_transport_certificate_creation_LDADD = \ | |||
109 | $(top_builddir)/src/util/libgnunetutil.la | 109 | $(top_builddir)/src/util/libgnunetutil.la |
110 | 110 | ||
111 | gnunet_transport_wlan_helper_SOURCES = \ | 111 | gnunet_transport_wlan_helper_SOURCES = \ |
112 | wlan/byteorder.h \ | 112 | gnunet-transport-wlan-helper.c |
113 | wlan/crctable_osdep.h \ | ||
114 | wlan/helper_common.c wlan/helper_common.h \ | ||
115 | wlan/ieee80211.h \ | ||
116 | wlan/ieee80211_radiotap.h \ | ||
117 | wlan/loopback_helper.h \ | ||
118 | wlan/radiotap-parser.c wlan/radiotap-parser.h \ | ||
119 | gnunet-transport-wlan-helper.c gnunet-transport-wlan-helper.h | ||
120 | gnunet_transport_wlan_helper_LDADD = \ | 113 | gnunet_transport_wlan_helper_LDADD = \ |
121 | $(top_builddir)/src/util/libgnunetutil.la | 114 | $(top_builddir)/src/util/libgnunetutil.la |
122 | 115 | ||
123 | gnunet_transport_wlan_helper_dummy_SOURCES = \ | 116 | gnunet_transport_wlan_helper_dummy_SOURCES = \ |
124 | wlan/radiotap-parser.c \ | ||
125 | wlan/helper_common.c \ | ||
126 | gnunet-transport-wlan-helper-dummy.c | 117 | gnunet-transport-wlan-helper-dummy.c |
127 | gnunet_transport_wlan_helper_dummy_LDADD = \ | 118 | gnunet_transport_wlan_helper_dummy_LDADD = \ |
128 | $(top_builddir)/src/util/libgnunetutil.la | 119 | $(top_builddir)/src/util/libgnunetutil.la |
diff --git a/src/transport/gnunet-transport-wlan-helper-dummy.c b/src/transport/gnunet-transport-wlan-helper-dummy.c index d4c300d25..6a884efc1 100644 --- a/src/transport/gnunet-transport-wlan-helper-dummy.c +++ b/src/transport/gnunet-transport-wlan-helper-dummy.c | |||
@@ -18,27 +18,10 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file transport/test_transport_wlan_dummy.c | 21 | * @file transport/gnunet-transport-wlan-helper-dummy.c |
22 | * @brief helper for the testcases for plugin_transport_wlan.c | 22 | * @brief helper for the testcases for plugin_transport_wlan.c |
23 | * @author David Brodski | 23 | * @author David Brodski |
24 | */ | 24 | */ |
25 | |||
26 | #include <sys/socket.h> | ||
27 | #include <sys/ioctl.h> | ||
28 | #include <sys/types.h> | ||
29 | #include <sys/wait.h> | ||
30 | #include <sys/time.h> | ||
31 | #include <sys/stat.h> | ||
32 | #include <stdio.h> | ||
33 | #include <stdlib.h> | ||
34 | |||
35 | #include <errno.h> | ||
36 | #include <resolv.h> | ||
37 | #include <string.h> | ||
38 | #include <utime.h> | ||
39 | #include <unistd.h> | ||
40 | #include <getopt.h> | ||
41 | |||
42 | #include "platform.h" | 25 | #include "platform.h" |
43 | #include "gnunet_constants.h" | 26 | #include "gnunet_constants.h" |
44 | #include "gnunet_os_lib.h" | 27 | #include "gnunet_os_lib.h" |
@@ -47,13 +30,24 @@ | |||
47 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
48 | #include "plugin_transport_wlan.h" | 31 | #include "plugin_transport_wlan.h" |
49 | #include "gnunet_common.h" | 32 | #include "gnunet_common.h" |
50 | //#include "gnunet-transport-wlan-helper.h" | ||
51 | #include "gnunet_crypto_lib.h" | 33 | #include "gnunet_crypto_lib.h" |
52 | #include "wlan/loopback_helper.h" | 34 | |
53 | #include "wlan/helper_common.h" | 35 | #define FIFO_FILE1 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_in" |
36 | #define FIFO_FILE2 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_out" | ||
37 | |||
38 | #define MAXLINE 4096 | ||
39 | |||
40 | struct sendbuf | ||
41 | { | ||
42 | unsigned int pos; | ||
43 | unsigned int size; | ||
44 | char buf[MAXLINE * 2]; | ||
45 | }; | ||
54 | 46 | ||
55 | static int first; | 47 | static int first; |
56 | 48 | ||
49 | static int closeprog; | ||
50 | |||
57 | static void | 51 | static void |
58 | sigfunc (int sig) | 52 | sigfunc (int sig) |
59 | { | 53 | { |
@@ -62,6 +56,26 @@ sigfunc (int sig) | |||
62 | (void) unlink (FIFO_FILE2); | 56 | (void) unlink (FIFO_FILE2); |
63 | } | 57 | } |
64 | 58 | ||
59 | /** | ||
60 | * function to create GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL message for plugin | ||
61 | * @param buffer pointer to buffer for the message | ||
62 | * @param mac pointer to the mac address | ||
63 | * @return number of bytes written | ||
64 | */ | ||
65 | int | ||
66 | send_mac_to_plugin (char *buffer, struct MacAddress *mac) | ||
67 | { | ||
68 | |||
69 | struct Wlan_Helper_Control_Message macmsg; | ||
70 | |||
71 | memcpy (&macmsg.mac, (char *) mac, sizeof (struct MacAddress)); | ||
72 | macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message)); | ||
73 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); | ||
74 | |||
75 | memcpy (buffer, &macmsg, sizeof (struct Wlan_Helper_Control_Message)); | ||
76 | return sizeof (struct Wlan_Helper_Control_Message); | ||
77 | } | ||
78 | |||
65 | static void | 79 | static void |
66 | stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | 80 | stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) |
67 | { | 81 | { |
@@ -132,7 +146,6 @@ file_in_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
132 | write_std->size += sendsize; | 146 | write_std->size += sendsize; |
133 | } | 147 | } |
134 | 148 | ||
135 | int closeprog; | ||
136 | 149 | ||
137 | 150 | ||
138 | int | 151 | int |
@@ -284,7 +297,7 @@ testmode (int argc, char *argv[]) | |||
284 | macaddr.mac[4] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 256); | 297 | macaddr.mac[4] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 256); |
285 | macaddr.mac[5] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 256); | 298 | macaddr.mac[5] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 256); |
286 | 299 | ||
287 | write_std.size = send_mac_to_plugin (write_std.buf, macaddr.mac); | 300 | write_std.size = send_mac_to_plugin (write_std.buf, &macaddr); |
288 | 301 | ||
289 | while (0 == closeprog) | 302 | while (0 == closeprog) |
290 | { | 303 | { |
diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c index 25e55e510..d86af27de 100644 --- a/src/transport/gnunet-transport-wlan-helper.c +++ b/src/transport/gnunet-transport-wlan-helper.c | |||
@@ -1,21 +1,64 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2010, 2011 Christian Grothoff (and other contributing authors) | 3 | (C) 2010, 2011 Christian Grothoff (and other contributing authors) |
4 | 4 | Copyright (c) 2007, 2008, Andy Green <andy@warmcat.com> | |
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | Copyright (C) 2009 Thomas d'Otreppe |
6 | it under the terms of the GNU General Public License as published | 6 | |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | GNUnet is free software; you can redistribute it and/or modify |
8 | option) any later version. | 8 | it under the terms of the GNU General Public License as published |
9 | 9 | by the Free Software Foundation; either version 3, or (at your | |
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | option) any later version. |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | GNUnet is distributed in the hope that it will be useful, but |
13 | General Public License for more details. | 13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | You should have received a copy of the GNU General Public License | 15 | General Public License for more details. |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | |
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | You should have received a copy of the GNU General Public License |
18 | Boston, MA 02111-1307, USA. | 18 | along with GNUnet; see the file COPYING. If not, write to the |
19 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
20 | Boston, MA 02111-1307, USA. | ||
21 | */ | ||
22 | /*- | ||
23 | * we use our local copy of ieee80211_radiotap.h | ||
24 | * | ||
25 | * - since we can't support extensions we don't understand | ||
26 | * - since linux does not include it in userspace headers | ||
27 | * | ||
28 | * Portions of this code were taken from the ieee80211_radiotap.h header, | ||
29 | * which is | ||
30 | * | ||
31 | * Copyright (c) 2003, 2004 David Young. All rights reserved. | ||
32 | * | ||
33 | * Redistribution and use in source and binary forms, with or without | ||
34 | * modification, are permitted provided that the following conditions | ||
35 | * are met: | ||
36 | * 1. Redistributions of source code must retain the above copyright | ||
37 | * notice, this list of conditions and the following disclaimer. | ||
38 | * 2. Redistributions in binary form must reproduce the above copyright | ||
39 | * notice, this list of conditions and the following disclaimer in the | ||
40 | * documentation and/or other materials provided with the distribution. | ||
41 | * 3. The name of David Young may not be used to endorse or promote | ||
42 | * products derived from this software without specific prior | ||
43 | * written permission. | ||
44 | * | ||
45 | * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY | ||
46 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
47 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
48 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID | ||
49 | * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
50 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | ||
51 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
52 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
53 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
54 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
55 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
56 | * OF SUCH DAMAGE. | ||
57 | */ | ||
58 | |||
59 | /* | ||
60 | * Modifications to fit into the linux IEEE 802.11 stack, | ||
61 | * Mike Kershaw (dragorn@kismetwireless.net) | ||
19 | */ | 62 | */ |
20 | 63 | ||
21 | /** | 64 | /** |
@@ -31,7 +74,6 @@ | |||
31 | /** | 74 | /** |
32 | * parts taken from aircrack-ng, parts changend. | 75 | * parts taken from aircrack-ng, parts changend. |
33 | */ | 76 | */ |
34 | |||
35 | #define _GNU_SOURCE | 77 | #define _GNU_SOURCE |
36 | #include <sys/socket.h> | 78 | #include <sys/socket.h> |
37 | #include <sys/ioctl.h> | 79 | #include <sys/ioctl.h> |
@@ -53,40 +95,949 @@ | |||
53 | #include <fcntl.h> | 95 | #include <fcntl.h> |
54 | #include <errno.h> | 96 | #include <errno.h> |
55 | #include <dirent.h> | 97 | #include <dirent.h> |
56 | //#include <sys/utsname.h> | ||
57 | #include <sys/param.h> | 98 | #include <sys/param.h> |
99 | #include "gnunet_protocols.h" | ||
100 | #include "gnunet_server_lib.h" | ||
101 | #include "plugin_transport_wlan.h" | ||
102 | |||
103 | typedef uint64_t u64; | ||
104 | typedef uint32_t u32; | ||
105 | typedef uint16_t u16; | ||
106 | typedef uint8_t u8; | ||
107 | |||
108 | |||
109 | |||
110 | /* Radiotap header version (from official NetBSD feed) */ | ||
111 | #define IEEE80211RADIOTAP_VERSION "1.5" | ||
112 | /* Base version of the radiotap packet header data */ | ||
113 | #define PKTHDR_RADIOTAP_VERSION 0 | ||
114 | |||
115 | /* A generic radio capture format is desirable. There is one for | ||
116 | * Linux, but it is neither rigidly defined (there were not even | ||
117 | * units given for some fields) nor easily extensible. | ||
118 | * | ||
119 | * I suggest the following extensible radio capture format. It is | ||
120 | * based on a bitmap indicating which fields are present. | ||
121 | * | ||
122 | * I am trying to describe precisely what the application programmer | ||
123 | * should expect in the following, and for that reason I tell the | ||
124 | * units and origin of each measurement (where it applies), or else I | ||
125 | * use sufficiently weaselly language ("is a monotonically nondecreasing | ||
126 | * function of...") that I cannot set false expectations for lawyerly | ||
127 | * readers. | ||
128 | */ | ||
129 | |||
130 | /* XXX tcpdump/libpcap do not tolerate variable-length headers, | ||
131 | * yet, so we pad every radiotap header to 64 bytes. Ugh. | ||
132 | */ | ||
133 | #define IEEE80211_RADIOTAP_HDRLEN 64 | ||
134 | |||
135 | /* The radio capture header precedes the 802.11 header. | ||
136 | * All data in the header is little endian on all platforms. | ||
137 | */ | ||
138 | struct ieee80211_radiotap_header | ||
139 | { | ||
140 | u8 it_version; /* Version 0. Only increases | ||
141 | * for drastic changes, | ||
142 | * introduction of compatible | ||
143 | * new fields does not count. | ||
144 | */ | ||
145 | u8 it_pad; | ||
146 | u16 it_len; /* length of the whole | ||
147 | * header in bytes, including | ||
148 | * it_version, it_pad, | ||
149 | * it_len, and data fields. | ||
150 | */ | ||
151 | u32 it_present; /* A bitmap telling which | ||
152 | * fields are present. Set bit 31 | ||
153 | * (0x80000000) to extend the | ||
154 | * bitmap by another 32 bits. | ||
155 | * Additional extensions are made | ||
156 | * by setting bit 31. | ||
157 | */ | ||
158 | }; | ||
159 | |||
160 | #define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK 0x80000000 | ||
161 | |||
162 | /* Name Data type Units | ||
163 | * ---- --------- ----- | ||
164 | * | ||
165 | * IEEE80211_RADIOTAP_TSFT __le64 microseconds | ||
166 | * | ||
167 | * Value in microseconds of the MAC's 64-bit 802.11 Time | ||
168 | * Synchronization Function timer when the first bit of the | ||
169 | * MPDU arrived at the MAC. For received frames, only. | ||
170 | * | ||
171 | * IEEE80211_RADIOTAP_CHANNEL 2 x __le16 MHz, bitmap | ||
172 | * | ||
173 | * Tx/Rx frequency in MHz, followed by flags (see below). | ||
174 | * | ||
175 | * IEEE80211_RADIOTAP_FHSS __le16 see below | ||
176 | * | ||
177 | * For frequency-hopping radios, the hop set (first byte) | ||
178 | * and pattern (second byte). | ||
179 | * | ||
180 | * IEEE80211_RADIOTAP_RATE u8 500kb/s | ||
181 | * | ||
182 | * Tx/Rx data rate | ||
183 | * | ||
184 | * IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from | ||
185 | * one milliwatt (dBm) | ||
186 | * | ||
187 | * RF signal power at the antenna, decibel difference from | ||
188 | * one milliwatt. | ||
189 | * | ||
190 | * IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from | ||
191 | * one milliwatt (dBm) | ||
192 | * | ||
193 | * RF noise power at the antenna, decibel difference from one | ||
194 | * milliwatt. | ||
195 | * | ||
196 | * IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB) | ||
197 | * | ||
198 | * RF signal power at the antenna, decibel difference from an | ||
199 | * arbitrary, fixed reference. | ||
200 | * | ||
201 | * IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB) | ||
202 | * | ||
203 | * RF noise power at the antenna, decibel difference from an | ||
204 | * arbitrary, fixed reference point. | ||
205 | * | ||
206 | * IEEE80211_RADIOTAP_LOCK_QUALITY __le16 unitless | ||
207 | * | ||
208 | * Quality of Barker code lock. Unitless. Monotonically | ||
209 | * nondecreasing with "better" lock strength. Called "Signal | ||
210 | * Quality" in datasheets. (Is there a standard way to measure | ||
211 | * this?) | ||
212 | * | ||
213 | * IEEE80211_RADIOTAP_TX_ATTENUATION __le16 unitless | ||
214 | * | ||
215 | * Transmit power expressed as unitless distance from max | ||
216 | * power set at factory calibration. 0 is max power. | ||
217 | * Monotonically nondecreasing with lower power levels. | ||
218 | * | ||
219 | * IEEE80211_RADIOTAP_DB_TX_ATTENUATION __le16 decibels (dB) | ||
220 | * | ||
221 | * Transmit power expressed as decibel distance from max power | ||
222 | * set at factory calibration. 0 is max power. Monotonically | ||
223 | * nondecreasing with lower power levels. | ||
224 | * | ||
225 | * IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from | ||
226 | * one milliwatt (dBm) | ||
227 | * | ||
228 | * Transmit power expressed as dBm (decibels from a 1 milliwatt | ||
229 | * reference). This is the absolute power level measured at | ||
230 | * the antenna port. | ||
231 | * | ||
232 | * IEEE80211_RADIOTAP_FLAGS u8 bitmap | ||
233 | * | ||
234 | * Properties of transmitted and received frames. See flags | ||
235 | * defined below. | ||
236 | * | ||
237 | * IEEE80211_RADIOTAP_ANTENNA u8 antenna index | ||
238 | * | ||
239 | * Unitless indication of the Rx/Tx antenna for this packet. | ||
240 | * The first antenna is antenna 0. | ||
241 | * | ||
242 | * IEEE80211_RADIOTAP_RX_FLAGS __le16 bitmap | ||
243 | * | ||
244 | * Properties of received frames. See flags defined below. | ||
245 | * | ||
246 | * IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap | ||
247 | * | ||
248 | * Properties of transmitted frames. See flags defined below. | ||
249 | * | ||
250 | * IEEE80211_RADIOTAP_RTS_RETRIES u8 data | ||
251 | * | ||
252 | * Number of rts retries a transmitted frame used. | ||
253 | * | ||
254 | * IEEE80211_RADIOTAP_DATA_RETRIES u8 data | ||
255 | * | ||
256 | * Number of unicast retries a transmitted frame used. | ||
257 | * | ||
258 | */ | ||
259 | enum ieee80211_radiotap_type | ||
260 | { | ||
261 | IEEE80211_RADIOTAP_TSFT = 0, | ||
262 | IEEE80211_RADIOTAP_FLAGS = 1, | ||
263 | IEEE80211_RADIOTAP_RATE = 2, | ||
264 | IEEE80211_RADIOTAP_CHANNEL = 3, | ||
265 | IEEE80211_RADIOTAP_FHSS = 4, | ||
266 | IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, | ||
267 | IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, | ||
268 | IEEE80211_RADIOTAP_LOCK_QUALITY = 7, | ||
269 | IEEE80211_RADIOTAP_TX_ATTENUATION = 8, | ||
270 | IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, | ||
271 | IEEE80211_RADIOTAP_DBM_TX_POWER = 10, | ||
272 | IEEE80211_RADIOTAP_ANTENNA = 11, | ||
273 | IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, | ||
274 | IEEE80211_RADIOTAP_DB_ANTNOISE = 13, | ||
275 | IEEE80211_RADIOTAP_RX_FLAGS = 14, | ||
276 | IEEE80211_RADIOTAP_TX_FLAGS = 15, | ||
277 | IEEE80211_RADIOTAP_RTS_RETRIES = 16, | ||
278 | IEEE80211_RADIOTAP_DATA_RETRIES = 17, | ||
279 | IEEE80211_RADIOTAP_EXT = 31 | ||
280 | }; | ||
281 | |||
282 | /* Channel flags. */ | ||
283 | #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ | ||
284 | #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ | ||
285 | #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ | ||
286 | #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ | ||
287 | #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ | ||
288 | #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ | ||
289 | #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ | ||
290 | #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ | ||
291 | |||
292 | /* For IEEE80211_RADIOTAP_FLAGS */ | ||
293 | #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received | ||
294 | * during CFP | ||
295 | */ | ||
296 | #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received | ||
297 | * with short | ||
298 | * preamble | ||
299 | */ | ||
300 | #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received | ||
301 | * with WEP encryption | ||
302 | */ | ||
303 | #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received | ||
304 | * with fragmentation | ||
305 | */ | ||
306 | #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ | ||
307 | #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between | ||
308 | * 802.11 header and payload | ||
309 | * (to 32-bit boundary) | ||
310 | */ | ||
311 | /* For IEEE80211_RADIOTAP_RX_FLAGS */ | ||
312 | #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */ | ||
313 | |||
314 | /* For IEEE80211_RADIOTAP_TX_FLAGS */ | ||
315 | #define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive | ||
316 | * retries */ | ||
317 | #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ | ||
318 | #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ | ||
319 | #define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* frame should not be ACKed */ | ||
320 | #define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 /* sequence number handled | ||
321 | * by userspace */ | ||
322 | |||
323 | /* Ugly macro to convert literal channel numbers into their mhz equivalents | ||
324 | * There are certianly some conditions that will break this (like feeding it '30') | ||
325 | * but they shouldn't arise since nothing talks on channel 30. */ | ||
326 | #define ieee80211chan2mhz(x) \ | ||
327 | (((x) <= 14) ? \ | ||
328 | (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \ | ||
329 | ((x) + 1000) * 5) | ||
330 | |||
331 | |||
332 | |||
333 | /* *INDENT-OFF* */ | ||
334 | #define ___my_swab16(x) \ | ||
335 | ((u_int16_t)( \ | ||
336 | (((u_int16_t)(x) & (u_int16_t)0x00ffU) << 8) | \ | ||
337 | (((u_int16_t)(x) & (u_int16_t)0xff00U) >> 8) )) | ||
338 | |||
339 | #define ___my_swab32(x) \ | ||
340 | ((u_int32_t)( \ | ||
341 | (((u_int32_t)(x) & (u_int32_t)0x000000ffUL) << 24) | \ | ||
342 | (((u_int32_t)(x) & (u_int32_t)0x0000ff00UL) << 8) | \ | ||
343 | (((u_int32_t)(x) & (u_int32_t)0x00ff0000UL) >> 8) | \ | ||
344 | (((u_int32_t)(x) & (u_int32_t)0xff000000UL) >> 24) )) | ||
345 | #define ___my_swab64(x) \ | ||
346 | ((u_int64_t)( \ | ||
347 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000000000ffULL) << 56) | \ | ||
348 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000000000ff00ULL) << 40) | \ | ||
349 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000000000ff0000ULL) << 24) | \ | ||
350 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000ff000000ULL) << 8) | \ | ||
351 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000ff00000000ULL) >> 8) | \ | ||
352 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000ff0000000000ULL) >> 24) | \ | ||
353 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00ff000000000000ULL) >> 40) | \ | ||
354 | (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0xff00000000000000ULL) >> 56) )) | ||
355 | /* *INDENT-ON* */ | ||
356 | /* | ||
357 | * Linux | ||
358 | */ | ||
359 | #if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux__) | ||
360 | #include <endian.h> | ||
361 | #include <unistd.h> | ||
362 | #include <stdint.h> | ||
363 | |||
364 | #ifndef __int8_t_defined | ||
365 | typedef uint64_t u_int64_t; | ||
366 | typedef uint32_t u_int32_t; | ||
367 | typedef uint16_t u_int16_t; | ||
368 | typedef uint8_t u_int8_t; | ||
369 | |||
370 | |||
371 | #endif /* */ | ||
372 | |||
373 | #ifndef htole16 | ||
374 | #if __BYTE_ORDER == __LITTLE_ENDIAN | ||
375 | #define htobe16(x) ___my_swab16 (x) | ||
376 | #define htole16(x) (x) | ||
377 | #define be16toh(x) ___my_swab16 (x) | ||
378 | #define le16toh(x) (x) | ||
379 | |||
380 | #define htobe32(x) ___my_swab32 (x) | ||
381 | #define htole32(x) (x) | ||
382 | #define be32toh(x) ___my_swab32 (x) | ||
383 | #define le32toh(x) (x) | ||
384 | |||
385 | #define htobe64(x) ___my_swab64 (x) | ||
386 | #define htole64(x) (x) | ||
387 | #define be64toh(x) ___my_swab64 (x) | ||
388 | #define le64toh(x) (x) | ||
389 | #else /* */ | ||
390 | #define htobe16(x) (x) | ||
391 | #define htole16(x) ___my_swab16 (x) | ||
392 | #define be16toh(x) (x) | ||
393 | #define le16toh(x) ___my_swab16 (x) | ||
394 | |||
395 | #define htobe32(x) (x) | ||
396 | #define htole32(x) ___my_swab32 (x) | ||
397 | #define be32toh(x) (x) | ||
398 | #define le32toh(x) ___my_swab32 (x) | ||
399 | |||
400 | #define htobe64(x) (x) | ||
401 | #define htole64(x) ___my_swab64 (x) | ||
402 | #define be64toh(x) (x) | ||
403 | #define le64toh(x) ___my_swab64 (x) | ||
404 | #endif /* */ | ||
405 | #endif /* */ | ||
406 | |||
407 | #endif /* */ | ||
408 | /* | ||
409 | * Cygwin | ||
410 | */ | ||
411 | #if defined(__CYGWIN32__) | ||
412 | #include <asm/byteorder.h> | ||
413 | #include <unistd.h> | ||
414 | #define __be64_to_cpu(x) ___my_swab64(x) | ||
415 | #define __be32_to_cpu(x) ___my_swab32(x) | ||
416 | #define __be16_to_cpu(x) ___my_swab16(x) | ||
417 | #define __cpu_to_be64(x) ___my_swab64(x) | ||
418 | #define __cpu_to_be32(x) ___my_swab32(x) | ||
419 | #define __cpu_to_be16(x) ___my_swab16(x) | ||
420 | #define __le64_to_cpu(x) (x) | ||
421 | #define __le32_to_cpu(x) (x) | ||
422 | #define __le16_to_cpu(x) (x) | ||
423 | #define __cpu_to_le64(x) (x) | ||
424 | #define __cpu_to_le32(x) (x) | ||
425 | #define __cpu_to_le16(x) (x) | ||
426 | #define AIRCRACK_NG_BYTE_ORDER_DEFINED | ||
427 | #endif /* */ | ||
428 | /* | ||
429 | * Windows (DDK) | ||
430 | */ | ||
431 | #if defined(__WIN__) | ||
432 | #include <io.h> | ||
433 | #define __be64_to_cpu(x) ___my_swab64(x) | ||
434 | #define __be32_to_cpu(x) ___my_swab32(x) | ||
435 | #define __be16_to_cpu(x) ___my_swab16(x) | ||
436 | #define __cpu_to_be64(x) ___my_swab64(x) | ||
437 | #define __cpu_to_be32(x) ___my_swab32(x) | ||
438 | #define __cpu_to_be16(x) ___my_swab16(x) | ||
439 | #define __le64_to_cpu(x) (x) | ||
440 | #define __le32_to_cpu(x) (x) | ||
441 | #define __le16_to_cpu(x) (x) | ||
442 | #define __cpu_to_le64(x) (x) | ||
443 | #define __cpu_to_le32(x) (x) | ||
444 | #define __cpu_to_le16(x) (x) | ||
445 | #define AIRCRACK_NG_BYTE_ORDER_DEFINED | ||
446 | #endif /* */ | ||
447 | /* | ||
448 | * MAC (Darwin) | ||
449 | */ | ||
450 | #if defined(__APPLE_CC__) | ||
451 | #if defined(__x86_64__) && defined(__APPLE__) | ||
452 | #include <libkern/OSByteOrder.h> | ||
453 | #define __swab64(x) (unsigned long long) OSSwapInt64((uint64_t)x) | ||
454 | #define __swab32(x) (unsigned long) OSSwapInt32((uint32_t)x) | ||
455 | #define __swab16(x) (unsigned short) OSSwapInt16((uint16_t)x) | ||
456 | #define __be64_to_cpu(x) (unsigned long long) OSSwapBigToHostInt64((uint64_t)x) | ||
457 | #define __be32_to_cpu(x) (unsigned long) OSSwapBigToHostInt32((uint32_t)x) | ||
458 | #define __be16_to_cpu(x) (unsigned short) OSSwapBigToHostInt16((uint16_t)x) | ||
459 | #define __le64_to_cpu(x) (unsigned long long) OSSwapLittleToHostInt64((uint64_t)x) | ||
460 | #define __le32_to_cpu(x) (unsigned long) OSSwapLittleToHostInt32((uint32_t)x) | ||
461 | #define __le16_to_cpu(x) (unsigned short) OSSwapLittleToHostInt16((uint16_t)x) | ||
462 | #define __cpu_to_be64(x) (unsigned long long) OSSwapHostToBigInt64((uint64_t)x) | ||
463 | #define __cpu_to_be32(x) (unsigned long) OSSwapHostToBigInt32((uint32_t)x) | ||
464 | #define __cpu_to_be16(x) (unsigned short) OSSwapHostToBigInt16((uint16_t)x) | ||
465 | #define __cpu_to_le64(x) (unsigned long long) OSSwapHostToLittleInt64((uint64_t)x) | ||
466 | #define __cpu_to_le32(x) (unsigned long) OSSwapHostToLittleInt32((uint32_t)x) | ||
467 | #define __cpu_to_le16(x) (unsigned short) OSSwapHostToLittleInt16((uint16_t)x) | ||
468 | #else /* */ | ||
469 | #include <architecture/byte_order.h> | ||
470 | #define __swab64(x) NXSwapLongLong(x) | ||
471 | #define __swab32(x) NXSwapLong(x) | ||
472 | #define __swab16(x) NXSwapShort(x) | ||
473 | #define __be64_to_cpu(x) NXSwapBigLongLongToHost(x) | ||
474 | #define __be32_to_cpu(x) NXSwapBigLongToHost(x) | ||
475 | #define __be16_to_cpu(x) NXSwapBigShortToHost(x) | ||
476 | #define __le64_to_cpu(x) NXSwapLittleLongLongToHost(x) | ||
477 | #define __le32_to_cpu(x) NXSwapLittleLongToHost(x) | ||
478 | #define __le16_to_cpu(x) NXSwapLittleShortToHost(x) | ||
479 | #define __cpu_to_be64(x) NXSwapHostLongLongToBig(x) | ||
480 | #define __cpu_to_be32(x) NXSwapHostLongToBig(x) | ||
481 | #define __cpu_to_be16(x) NXSwapHostShortToBig(x) | ||
482 | #define __cpu_to_le64(x) NXSwapHostLongLongToLittle(x) | ||
483 | #define __cpu_to_le32(x) NXSwapHostLongToLittle(x) | ||
484 | #define __cpu_to_le16(x) NXSwapHostShortToLittle(x) | ||
485 | #endif /* */ | ||
486 | #define __LITTLE_ENDIAN 1234 | ||
487 | #define __BIG_ENDIAN 4321 | ||
488 | #define __PDP_ENDIAN 3412 | ||
489 | #define __BYTE_ORDER __BIG_ENDIAN | ||
490 | #define AIRCRACK_NG_BYTE_ORDER_DEFINED | ||
491 | #endif /* */ | ||
492 | /* | ||
493 | * Solaris | ||
494 | * ------- | ||
495 | */ | ||
496 | #if defined(__sparc__) && defined(__sun__) | ||
497 | #include <sys/byteorder.h> | ||
498 | #include <sys/types.h> | ||
499 | #include <unistd.h> | ||
500 | #define __be64_to_cpu(x) (x) | ||
501 | #define __be32_to_cpu(x) (x) | ||
502 | #define __be16_to_cpu(x) (x) | ||
503 | #define __cpu_to_be64(x) (x) | ||
504 | #define __cpu_to_be32(x) (x) | ||
505 | #define __cpu_to_be16(x) (x) | ||
506 | #define __le64_to_cpu(x) ___my_swab64(x) | ||
507 | #define __le32_to_cpu(x) ___my_swab32(x) | ||
508 | #define __le16_to_cpu(x) ___my_swab16(x) | ||
509 | #define __cpu_to_le64(x) ___my_swab64(x) | ||
510 | #define __cpu_to_le32(x) ___my_swab32(x) | ||
511 | #define __cpu_to_le16(x) ___my_swab16(x) | ||
512 | typedef uint64_t u_int64_t; | ||
513 | typedef uint32_t u_int32_t; | ||
514 | typedef uint16_t u_int16_t; | ||
515 | typedef uint8_t u_int8_t; | ||
516 | |||
517 | |||
518 | #define AIRCRACK_NG_BYTE_ORDER_DEFINED | ||
519 | #endif /* */ | ||
520 | /* | ||
521 | * Custom stuff | ||
522 | */ | ||
523 | #if defined(__MACH__) && !defined(__APPLE_CC__) | ||
524 | #include <libkern/OSByteOrder.h> | ||
525 | #define __cpu_to_be64(x) = OSSwapHostToBigInt64(x) | ||
526 | #define __cpu_to_be32(x) = OSSwapHostToBigInt32(x) | ||
527 | #define AIRCRACK_NG_BYTE_ORDER_DEFINED | ||
528 | #endif /* */ | ||
529 | |||
530 | // FreeBSD | ||
531 | #ifdef __FreeBSD__ | ||
532 | #include <machine/endian.h> | ||
533 | #endif /* */ | ||
534 | // XXX: Is there anything to include on OpenBSD/NetBSD/DragonFlyBSD/...? | ||
535 | |||
536 | // XXX: Mac: Check http://www.opensource.apple.com/source/CF/CF-476.18/CFByteOrder.h | ||
537 | // http://developer.apple.com/DOCUMENTATION/CoreFoundation/Reference/CFByteOrderUtils/Reference/reference.html | ||
538 | // Write to apple to ask what should be used. | ||
539 | #if defined(LITTLE_ENDIAN) | ||
540 | #define AIRCRACK_NG_LITTLE_ENDIAN LITTLE_ENDIAN | ||
541 | #elif defined(__LITTLE_ENDIAN) | ||
542 | #define AIRCRACK_NG_LITTLE_ENDIAN __LITTLE_ENDIAN | ||
543 | #elif defined(_LITTLE_ENDIAN) | ||
544 | #define AIRCRACK_NG_LITTLE_ENDIAN _LITTLE_ENDIAN | ||
545 | #endif /* */ | ||
546 | #if defined(BIG_ENDIAN) | ||
547 | #define AIRCRACK_NG_BIG_ENDIAN BIG_ENDIAN | ||
548 | #elif defined(__BIG_ENDIAN) | ||
549 | #define AIRCRACK_NG_BIG_ENDIAN __BIG_ENDIAN | ||
550 | #elif defined(_BIG_ENDIAN) | ||
551 | #define AIRCRACK_NG_BIG_ENDIAN _BIG_ENDIAN | ||
552 | #endif /* */ | ||
553 | #if !defined(AIRCRACK_NG_LITTLE_ENDIAN) && !defined(AIRCRACK_NG_BIG_ENDIAN) | ||
554 | #error Impossible to determine endianness (Little or Big endian), please contact the author. | ||
555 | #endif /* */ | ||
556 | #if defined(BYTE_ORDER) | ||
557 | #if (BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) | ||
558 | #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN | ||
559 | #elif (BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) | ||
560 | #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN | ||
561 | #endif /* */ | ||
562 | #elif defined(__BYTE_ORDER) | ||
563 | #if (__BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) | ||
564 | #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN | ||
565 | #elif (__BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) | ||
566 | #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN | ||
567 | #endif /* */ | ||
568 | #elif defined(_BYTE_ORDER) | ||
569 | #if (_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) | ||
570 | #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN | ||
571 | #elif (_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) | ||
572 | #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN | ||
573 | #endif /* */ | ||
574 | #endif /* */ | ||
575 | #ifndef AIRCRACK_NG_BYTE_ORDER | ||
576 | #error Impossible to determine endianness (Little or Big endian), please contact the author. | ||
577 | #endif /* */ | ||
578 | #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) | ||
579 | #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED | ||
580 | #define __be64_to_cpu(x) ___my_swab64(x) | ||
581 | #define __be32_to_cpu(x) ___my_swab32(x) | ||
582 | #define __be16_to_cpu(x) ___my_swab16(x) | ||
583 | #define __cpu_to_be64(x) ___my_swab64(x) | ||
584 | #define __cpu_to_be32(x) ___my_swab32(x) | ||
585 | #define __cpu_to_be16(x) ___my_swab16(x) | ||
586 | #define __le64_to_cpu(x) (x) | ||
587 | #define __le32_to_cpu(x) (x) | ||
588 | #define __le16_to_cpu(x) (x) | ||
589 | #define __cpu_to_le64(x) (x) | ||
590 | #define __cpu_to_le32(x) (x) | ||
591 | #define __cpu_to_le16(x) (x) | ||
592 | #endif /* */ | ||
593 | #ifndef htobe16 | ||
594 | #define htobe16 ___my_swab16 | ||
595 | #endif /* */ | ||
596 | #ifndef htobe32 | ||
597 | #define htobe32 ___my_swab32 | ||
598 | #endif /* */ | ||
599 | #ifndef betoh16 | ||
600 | #define betoh16 ___my_swab16 | ||
601 | #endif /* */ | ||
602 | #ifndef betoh32 | ||
603 | #define betoh32 ___my_swab32 | ||
604 | #endif /* */ | ||
605 | #ifndef htole16 | ||
606 | #define htole16(x) (x) | ||
607 | #endif /* */ | ||
608 | #ifndef htole32 | ||
609 | #define htole32(x) (x) | ||
610 | #endif /* */ | ||
611 | #ifndef letoh16 | ||
612 | #define letoh16(x) (x) | ||
613 | #endif /* */ | ||
614 | #ifndef letoh32 | ||
615 | #define letoh32(x) (x) | ||
616 | #endif /* */ | ||
617 | #endif /* */ | ||
618 | #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) | ||
619 | #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED | ||
620 | #define __be64_to_cpu(x) (x) | ||
621 | #define __be32_to_cpu(x) (x) | ||
622 | #define __be16_to_cpu(x) (x) | ||
623 | #define __cpu_to_be64(x) (x) | ||
624 | #define __cpu_to_be32(x) (x) | ||
625 | #define __cpu_to_be16(x) (x) | ||
626 | #define __le64_to_cpu(x) ___my_swab64(x) | ||
627 | #define __le32_to_cpu(x) ___my_swab32(x) | ||
628 | #define __le16_to_cpu(x) ___my_swab16(x) | ||
629 | #define __cpu_to_le64(x) ___my_swab64(x) | ||
630 | #define __cpu_to_le32(x) ___my_swab32(x) | ||
631 | #define __cpu_to_le16(x) ___my_swab16(x) | ||
632 | #endif /* */ | ||
633 | #ifndef htobe16 | ||
634 | #define htobe16(x) (x) | ||
635 | #endif /* */ | ||
636 | #ifndef htobe32 | ||
637 | #define htobe32(x) (x) | ||
638 | #endif /* */ | ||
639 | #ifndef betoh16 | ||
640 | #define betoh16(x) (x) | ||
641 | #endif /* */ | ||
642 | #ifndef betoh32 | ||
643 | #define betoh32(x) (x) | ||
644 | #endif /* */ | ||
645 | #ifndef htole16 | ||
646 | #define htole16 ___my_swab16 | ||
647 | #endif /* */ | ||
648 | #ifndef htole32 | ||
649 | #define htole32 ___my_swab32 | ||
650 | #endif /* */ | ||
651 | #ifndef letoh16 | ||
652 | #define letoh16 ___my_swab16 | ||
653 | #endif /* */ | ||
654 | #ifndef letoh32 | ||
655 | #define letoh32 ___my_swab32 | ||
656 | #endif /* */ | ||
657 | #endif /* */ | ||
658 | // Common defines | ||
659 | #define cpu_to_le64 __cpu_to_le64 | ||
660 | #define le64_to_cpu __le64_to_cpu | ||
661 | #define cpu_to_le32 __cpu_to_le32 | ||
662 | #define le32_to_cpu __le32_to_cpu | ||
663 | #define cpu_to_le16 __cpu_to_le16 | ||
664 | #define le16_to_cpu __le16_to_cpu | ||
665 | #define cpu_to_be64 __cpu_to_be64 | ||
666 | #define be64_to_cpu __be64_to_cpu | ||
667 | #define cpu_to_be32 __cpu_to_be32 | ||
668 | #define be32_to_cpu __be32_to_cpu | ||
669 | #define cpu_to_be16 __cpu_to_be16 | ||
670 | #define be16_to_cpu __be16_to_cpu | ||
671 | #ifndef le16toh | ||
672 | #define le16toh le16_to_cpu | ||
673 | #endif /* */ | ||
674 | #ifndef be16toh | ||
675 | #define be16toh be16_to_cpu | ||
676 | #endif /* */ | ||
677 | #ifndef le32toh | ||
678 | #define le32toh le32_to_cpu | ||
679 | #endif /* */ | ||
680 | #ifndef be32toh | ||
681 | #define be32toh be32_to_cpu | ||
682 | #endif /* */ | ||
683 | |||
684 | #ifndef htons | ||
685 | #define htons be16_to_cpu | ||
686 | #endif /* */ | ||
687 | #ifndef htonl | ||
688 | #define htonl cpu_to_be16 | ||
689 | #endif /* */ | ||
690 | #ifndef ntohs | ||
691 | #define ntohs cpu_to_be16 | ||
692 | #endif /* */ | ||
693 | #ifndef ntohl | ||
694 | #define ntohl cpu_to_be32 | ||
695 | #endif /* */ | ||
696 | |||
697 | |||
58 | 698 | ||
59 | /* | 699 | /* |
60 | //#include <resolv.h> | 700 | * Radiotap header iteration |
61 | #include <string.h> | 701 | * implemented in src/radiotap-parser.c |
62 | #include <utime.h> | 702 | * |
63 | #include <getopt.h> | 703 | * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator |
704 | * struct ieee80211_radiotap_iterator (no need to init the struct beforehand) | ||
705 | * then loop calling __ieee80211_radiotap_iterator_next()... it returns -1 | ||
706 | * if there are no more args in the header, or the next argument type index | ||
707 | * that is present. The iterator's this_arg member points to the start of the | ||
708 | * argument associated with the current argument index that is present, | ||
709 | * which can be found in the iterator's this_arg_index member. This arg | ||
710 | * index corresponds to the IEEE80211_RADIOTAP_... defines. | ||
64 | */ | 711 | */ |
65 | //#include "platform.h" | 712 | /** |
66 | #include "gnunet_constants.h" | 713 | * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args |
67 | #include "gnunet_os_lib.h" | 714 | * @rtheader: pointer to the radiotap header we are walking through |
68 | #include "gnunet_transport_plugin.h" | 715 | * @max_length: length of radiotap header in cpu byte ordering |
69 | #include "transport.h" | 716 | * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg |
70 | #include "gnunet_util_lib.h" | 717 | * @this_arg: pointer to current radiotap arg |
71 | #include "plugin_transport_wlan.h" | 718 | * @arg_index: internal next argument index |
72 | #include "gnunet_common.h" | 719 | * @arg: internal next argument pointer |
73 | #include "gnunet-transport-wlan-helper.h" | 720 | * @next_bitmap: internal pointer to next present u32 |
74 | #include "gnunet_crypto_lib.h" | 721 | * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present |
722 | */ | ||
723 | |||
724 | struct ieee80211_radiotap_iterator | ||
725 | { | ||
726 | struct ieee80211_radiotap_header *rtheader; | ||
727 | int max_length; | ||
728 | int this_arg_index; | ||
729 | u8 *this_arg; | ||
730 | |||
731 | int arg_index; | ||
732 | u8 *arg; | ||
733 | u32 *next_bitmap; | ||
734 | u32 bitmap_shifter; | ||
735 | }; | ||
75 | 736 | ||
76 | #include "wlan/radiotap-parser.h" | 737 | |
77 | /* radiotap-parser defines types like u8 that | 738 | /* |
78 | * ieee80211_radiotap.h needs | 739 | * Radiotap header iteration |
740 | * implemented in src/radiotap-parser.c | ||
79 | * | 741 | * |
80 | * we use our local copy of ieee80211_radiotap.h | 742 | * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator |
743 | * struct ieee80211_radiotap_iterator (no need to init the struct beforehand) | ||
744 | * then loop calling __ieee80211_radiotap_iterator_next()... it returns -1 | ||
745 | * if there are no more args in the header, or the next argument type index | ||
746 | * that is present. The iterator's this_arg member points to the start of the | ||
747 | * argument associated with the current argument index that is present, | ||
748 | * which can be found in the iterator's this_arg_index member. This arg | ||
749 | * index corresponds to the IEEE80211_RADIOTAP_... defines. | ||
750 | */ | ||
751 | |||
752 | |||
753 | int | ||
754 | ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator *iterator, | ||
755 | struct ieee80211_radiotap_header | ||
756 | *radiotap_header, int max_length) | ||
757 | { | ||
758 | if (iterator == NULL) | ||
759 | return (-EINVAL); | ||
760 | |||
761 | if (radiotap_header == NULL) | ||
762 | return (-EINVAL); | ||
763 | /* Linux only supports version 0 radiotap format */ | ||
764 | |||
765 | if (radiotap_header->it_version) | ||
766 | return (-EINVAL); | ||
767 | |||
768 | /* sanity check for allowed length and radiotap length field */ | ||
769 | |||
770 | if (max_length < (le16_to_cpu (radiotap_header->it_len))) | ||
771 | return (-EINVAL); | ||
772 | |||
773 | iterator->rtheader = radiotap_header; | ||
774 | iterator->max_length = le16_to_cpu (radiotap_header->it_len); | ||
775 | iterator->arg_index = 0; | ||
776 | iterator->bitmap_shifter = le32_to_cpu (radiotap_header->it_present); | ||
777 | iterator->arg = | ||
778 | ((u8 *) radiotap_header) + sizeof (struct ieee80211_radiotap_header); | ||
779 | iterator->this_arg = 0; | ||
780 | |||
781 | /* find payload start allowing for extended bitmap(s) */ | ||
782 | |||
783 | if ((iterator->bitmap_shifter & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)) | ||
784 | { | ||
785 | while (le32_to_cpu (*((u32 *) iterator->arg)) & | ||
786 | IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK) | ||
787 | { | ||
788 | iterator->arg += sizeof (u32); | ||
789 | |||
790 | /* | ||
791 | * check for insanity where the present bitmaps | ||
792 | * keep claiming to extend up to or even beyond the | ||
793 | * stated radiotap header length | ||
794 | */ | ||
795 | |||
796 | if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) > | ||
797 | iterator->max_length) | ||
798 | return (-EINVAL); | ||
799 | |||
800 | } | ||
801 | |||
802 | iterator->arg += sizeof (u32); | ||
803 | |||
804 | /* | ||
805 | * no need to check again for blowing past stated radiotap | ||
806 | * header length, becuase ieee80211_radiotap_iterator_next | ||
807 | * checks it before it is dereferenced | ||
808 | */ | ||
809 | |||
810 | } | ||
811 | |||
812 | /* we are all initialized happily */ | ||
813 | |||
814 | return (0); | ||
815 | } | ||
816 | |||
817 | |||
818 | /** | ||
819 | * ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg | ||
820 | * @iterator: radiotap_iterator to move to next arg (if any) | ||
81 | * | 821 | * |
82 | * - since we can't support extensions we don't understand | 822 | * Returns: next present arg index on success or negative if no more or error |
83 | * - since linux does not include it in userspace headers | 823 | * |
824 | * This function returns the next radiotap arg index (IEEE80211_RADIOTAP_...) | ||
825 | * and sets iterator->this_arg to point to the payload for the arg. It takes | ||
826 | * care of alignment handling and extended present fields. interator->this_arg | ||
827 | * can be changed by the caller. The args pointed to are in little-endian | ||
828 | * format. | ||
84 | */ | 829 | */ |
85 | #include "wlan/ieee80211_radiotap.h" | 830 | |
86 | #include "wlan/crctable_osdep.h" | 831 | int |
87 | //#include "wlan/loopback_helper.h" | 832 | ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator *iterator) |
88 | //#include "wlan/ieee80211.h" | 833 | { |
89 | #include "wlan/helper_common.h" | 834 | |
835 | /* | ||
836 | * small length lookup table for all radiotap types we heard of | ||
837 | * starting from b0 in the bitmap, so we can walk the payload | ||
838 | * area of the radiotap header | ||
839 | * | ||
840 | * There is a requirement to pad args, so that args | ||
841 | * of a given length must begin at a boundary of that length | ||
842 | * -- but note that compound args are allowed (eg, 2 x u16 | ||
843 | * for IEEE80211_RADIOTAP_CHANNEL) so total arg length is not | ||
844 | * a reliable indicator of alignment requirement. | ||
845 | * | ||
846 | * upper nybble: content alignment for arg | ||
847 | * lower nybble: content length for arg | ||
848 | */ | ||
849 | |||
850 | static const u8 rt_sizes[] = { | ||
851 | [IEEE80211_RADIOTAP_TSFT] = 0x88, | ||
852 | [IEEE80211_RADIOTAP_FLAGS] = 0x11, | ||
853 | [IEEE80211_RADIOTAP_RATE] = 0x11, | ||
854 | [IEEE80211_RADIOTAP_CHANNEL] = 0x24, | ||
855 | [IEEE80211_RADIOTAP_FHSS] = 0x22, | ||
856 | [IEEE80211_RADIOTAP_DBM_ANTSIGNAL] = 0x11, | ||
857 | [IEEE80211_RADIOTAP_DBM_ANTNOISE] = 0x11, | ||
858 | [IEEE80211_RADIOTAP_LOCK_QUALITY] = 0x22, | ||
859 | [IEEE80211_RADIOTAP_TX_ATTENUATION] = 0x22, | ||
860 | [IEEE80211_RADIOTAP_DB_TX_ATTENUATION] = 0x22, | ||
861 | [IEEE80211_RADIOTAP_DBM_TX_POWER] = 0x11, | ||
862 | [IEEE80211_RADIOTAP_ANTENNA] = 0x11, | ||
863 | [IEEE80211_RADIOTAP_DB_ANTSIGNAL] = 0x11, | ||
864 | [IEEE80211_RADIOTAP_DB_ANTNOISE] = 0x11, | ||
865 | [IEEE80211_RADIOTAP_TX_FLAGS] = 0x22, | ||
866 | [IEEE80211_RADIOTAP_RX_FLAGS] = 0x22, | ||
867 | [IEEE80211_RADIOTAP_RTS_RETRIES] = 0x11, | ||
868 | [IEEE80211_RADIOTAP_DATA_RETRIES] = 0x11 | ||
869 | /* | ||
870 | * add more here as they are defined in | ||
871 | * include/net/ieee80211_radiotap.h | ||
872 | */ | ||
873 | }; | ||
874 | |||
875 | /* | ||
876 | * for every radiotap entry we can at | ||
877 | * least skip (by knowing the length)... | ||
878 | */ | ||
879 | |||
880 | while (iterator->arg_index < (int) sizeof (rt_sizes)) | ||
881 | { | ||
882 | int hit = 0; | ||
883 | |||
884 | if (!(iterator->bitmap_shifter & 1)) | ||
885 | goto next_entry; /* arg not present */ | ||
886 | |||
887 | /* | ||
888 | * arg is present, account for alignment padding | ||
889 | * 8-bit args can be at any alignment | ||
890 | * 16-bit args must start on 16-bit boundary | ||
891 | * 32-bit args must start on 32-bit boundary | ||
892 | * 64-bit args must start on 64-bit boundary | ||
893 | * | ||
894 | * note that total arg size can differ from alignment of | ||
895 | * elements inside arg, so we use upper nybble of length | ||
896 | * table to base alignment on | ||
897 | * | ||
898 | * also note: these alignments are ** relative to the | ||
899 | * start of the radiotap header **. There is no guarantee | ||
900 | * that the radiotap header itself is aligned on any | ||
901 | * kind of boundary. | ||
902 | */ | ||
903 | |||
904 | if ((((void *) iterator->arg) - | ||
905 | ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >> 4) | ||
906 | - 1)) | ||
907 | iterator->arg_index += | ||
908 | (rt_sizes[iterator->arg_index] >> 4) - | ||
909 | ((((void *) iterator->arg) - | ||
910 | ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >> | ||
911 | 4) - 1)); | ||
912 | |||
913 | /* | ||
914 | * this is what we will return to user, but we need to | ||
915 | * move on first so next call has something fresh to test | ||
916 | */ | ||
917 | |||
918 | iterator->this_arg_index = iterator->arg_index; | ||
919 | iterator->this_arg = iterator->arg; | ||
920 | hit = 1; | ||
921 | |||
922 | /* internally move on the size of this arg */ | ||
923 | |||
924 | iterator->arg += rt_sizes[iterator->arg_index] & 0x0f; | ||
925 | |||
926 | /* | ||
927 | * check for insanity where we are given a bitmap that | ||
928 | * claims to have more arg content than the length of the | ||
929 | * radiotap section. We will normally end up equalling this | ||
930 | * max_length on the last arg, never exceeding it. | ||
931 | */ | ||
932 | |||
933 | if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) > | ||
934 | iterator->max_length) | ||
935 | return (-EINVAL); | ||
936 | |||
937 | next_entry: | ||
938 | |||
939 | iterator->arg_index++; | ||
940 | if (((iterator->arg_index & 31) == 0)) | ||
941 | { | ||
942 | /* completed current u32 bitmap */ | ||
943 | if (iterator->bitmap_shifter & 1) | ||
944 | { | ||
945 | /* b31 was set, there is more */ | ||
946 | /* move to next u32 bitmap */ | ||
947 | iterator->bitmap_shifter = le32_to_cpu (*iterator->next_bitmap); | ||
948 | iterator->next_bitmap++; | ||
949 | } | ||
950 | else | ||
951 | { | ||
952 | /* no more bitmaps: end */ | ||
953 | iterator->arg_index = sizeof (rt_sizes); | ||
954 | } | ||
955 | } | ||
956 | else | ||
957 | { /* just try the next bit */ | ||
958 | iterator->bitmap_shifter >>= 1; | ||
959 | } | ||
960 | |||
961 | /* if we found a valid arg earlier, return it now */ | ||
962 | |||
963 | if (hit) | ||
964 | return (iterator->this_arg_index); | ||
965 | |||
966 | } | ||
967 | |||
968 | /* we don't know how to handle any more args, we're done */ | ||
969 | |||
970 | return (-1); | ||
971 | } | ||
972 | |||
973 | |||
974 | const unsigned long int crc_tbl_osdep[256] = { | ||
975 | 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, | ||
976 | 0xE963A535, 0x9E6495A3, | ||
977 | 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, | ||
978 | 0xE7B82D07, 0x90BF1D91, | ||
979 | 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, | ||
980 | 0xF4D4B551, 0x83D385C7, | ||
981 | 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, | ||
982 | 0xFA0F3D63, 0x8D080DF5, | ||
983 | 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, | ||
984 | 0xD20D85FD, 0xA50AB56B, | ||
985 | 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, | ||
986 | 0xDCD60DCF, 0xABD13D59, | ||
987 | 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, | ||
988 | 0xCFBA9599, 0xB8BDA50F, | ||
989 | 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, | ||
990 | 0xC1611DAB, 0xB6662D3D, | ||
991 | 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, | ||
992 | 0x9FBFE4A5, 0xE8B8D433, | ||
993 | 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, | ||
994 | 0x91646C97, 0xE6635C01, | ||
995 | 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, | ||
996 | 0x8208F4C1, 0xF50FC457, | ||
997 | 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, | ||
998 | 0x8CD37CF3, 0xFBD44C65, | ||
999 | 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, | ||
1000 | 0xA4D1C46D, 0xD3D6F4FB, | ||
1001 | 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, | ||
1002 | 0xAA0A4C5F, 0xDD0D7CC9, | ||
1003 | 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, | ||
1004 | 0xB966D409, 0xCE61E49F, | ||
1005 | 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, | ||
1006 | 0xB7BD5C3B, 0xC0BA6CAD, | ||
1007 | 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, | ||
1008 | 0x04DB2615, 0x73DC1683, | ||
1009 | 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, | ||
1010 | 0x0A00AE27, 0x7D079EB1, | ||
1011 | 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, | ||
1012 | 0x196C3671, 0x6E6B06E7, | ||
1013 | 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, | ||
1014 | 0x17B7BE43, 0x60B08ED5, | ||
1015 | 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, | ||
1016 | 0x3FB506DD, 0x48B2364B, | ||
1017 | 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, | ||
1018 | 0x316E8EEF, 0x4669BE79, | ||
1019 | 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, | ||
1020 | 0x220216B9, 0x5505262F, | ||
1021 | 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, | ||
1022 | 0x2CD99E8B, 0x5BDEAE1D, | ||
1023 | 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, | ||
1024 | 0x72076785, 0x05005713, | ||
1025 | 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, | ||
1026 | 0x7CDCEFB7, 0x0BDBDF21, | ||
1027 | 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, | ||
1028 | 0x6FB077E1, 0x18B74777, | ||
1029 | 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, | ||
1030 | 0x616BFFD3, 0x166CCF45, | ||
1031 | 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, | ||
1032 | 0x4969474D, 0x3E6E77DB, | ||
1033 | 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, | ||
1034 | 0x47B2CF7F, 0x30B5FFE9, | ||
1035 | 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, | ||
1036 | 0x54DE5729, 0x23D967BF, | ||
1037 | 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, | ||
1038 | 0x5A05DF1B, 0x2D02EF8D | ||
1039 | }; | ||
1040 | |||
90 | 1041 | ||
91 | #define ARPHRD_IEEE80211 801 | 1042 | #define ARPHRD_IEEE80211 801 |
92 | #define ARPHRD_IEEE80211_PRISM 802 | 1043 | #define ARPHRD_IEEE80211_PRISM 802 |
@@ -99,6 +1050,15 @@ | |||
99 | 1050 | ||
100 | #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ | 1051 | #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ |
101 | 1052 | ||
1053 | #define MAXLINE 4096 | ||
1054 | |||
1055 | struct sendbuf | ||
1056 | { | ||
1057 | unsigned int pos; | ||
1058 | unsigned int size; | ||
1059 | char buf[MAXLINE * 2]; | ||
1060 | }; | ||
1061 | |||
102 | /* | 1062 | /* |
103 | * generic definitions for IEEE 802.11 frames | 1063 | * generic definitions for IEEE 802.11 frames |
104 | */ | 1064 | */ |
@@ -135,7 +1095,8 @@ struct Hardware_Infos | |||
135 | * Name of the interface, not necessarily 0-terminated (!). | 1095 | * Name of the interface, not necessarily 0-terminated (!). |
136 | */ | 1096 | */ |
137 | char iface[IFNAMSIZ]; | 1097 | char iface[IFNAMSIZ]; |
138 | unsigned char pl_mac[MAC_ADDR_SIZE]; | 1098 | |
1099 | struct MacAddress pl_mac; | ||
139 | }; | 1100 | }; |
140 | 1101 | ||
141 | struct RadioTapheader | 1102 | struct RadioTapheader |
@@ -146,6 +1107,32 @@ struct RadioTapheader | |||
146 | u16 txflags; | 1107 | u16 txflags; |
147 | }; | 1108 | }; |
148 | 1109 | ||
1110 | |||
1111 | |||
1112 | |||
1113 | |||
1114 | /** | ||
1115 | * function to create GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL message for plugin | ||
1116 | * @param buffer pointer to buffer for the message | ||
1117 | * @param mac pointer to the mac address | ||
1118 | * @return number of bytes written | ||
1119 | */ | ||
1120 | int | ||
1121 | send_mac_to_plugin (char *buffer, struct MacAddress *mac) | ||
1122 | { | ||
1123 | |||
1124 | struct Wlan_Helper_Control_Message macmsg; | ||
1125 | |||
1126 | memcpy (&macmsg.mac, (char *) mac, sizeof (struct MacAddress)); | ||
1127 | macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message)); | ||
1128 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); | ||
1129 | |||
1130 | memcpy (buffer, &macmsg, sizeof (struct Wlan_Helper_Control_Message)); | ||
1131 | return sizeof (struct Wlan_Helper_Control_Message); | ||
1132 | } | ||
1133 | |||
1134 | |||
1135 | |||
149 | // FIXME: inline? | 1136 | // FIXME: inline? |
150 | int | 1137 | int |
151 | getChannelFromFrequency (int frequency); | 1138 | getChannelFromFrequency (int frequency); |
@@ -508,7 +1495,7 @@ openraw (struct Hardware_Infos *dev) | |||
508 | return 1; | 1495 | return 1; |
509 | } | 1496 | } |
510 | 1497 | ||
511 | memcpy (dev->pl_mac, ifr.ifr_hwaddr.sa_data, MAC_ADDR_SIZE); | 1498 | memcpy (&dev->pl_mac, ifr.ifr_hwaddr.sa_data, MAC_ADDR_SIZE); |
512 | dev->arptype_in = ifr.ifr_hwaddr.sa_family; | 1499 | dev->arptype_in = ifr.ifr_hwaddr.sa_family; |
513 | if ((ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211) && | 1500 | if ((ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211) && |
514 | (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) && | 1501 | (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) && |
@@ -595,7 +1582,7 @@ mac_test (const struct ieee80211_frame *u8aIeeeHeader, | |||
595 | { | 1582 | { |
596 | if (0 != memcmp (u8aIeeeHeader->i_addr3, &mac_bssid, MAC_ADDR_SIZE)) | 1583 | if (0 != memcmp (u8aIeeeHeader->i_addr3, &mac_bssid, MAC_ADDR_SIZE)) |
597 | return 1; | 1584 | return 1; |
598 | if (0 == memcmp (u8aIeeeHeader->i_addr1, dev->pl_mac, MAC_ADDR_SIZE)) | 1585 | if (0 == memcmp (u8aIeeeHeader->i_addr1, &dev->pl_mac, MAC_ADDR_SIZE)) |
599 | return 0; | 1586 | return 0; |
600 | if (0 == memcmp (u8aIeeeHeader->i_addr1, &bc_all_mac, MAC_ADDR_SIZE)) | 1587 | if (0 == memcmp (u8aIeeeHeader->i_addr1, &bc_all_mac, MAC_ADDR_SIZE)) |
601 | return 0; | 1588 | return 0; |
@@ -614,7 +1601,7 @@ mac_set (struct ieee80211_frame *u8aIeeeHeader, | |||
614 | { | 1601 | { |
615 | u8aIeeeHeader->i_fc[0] = 0x08; | 1602 | u8aIeeeHeader->i_fc[0] = 0x08; |
616 | u8aIeeeHeader->i_fc[1] = 0x00; | 1603 | u8aIeeeHeader->i_fc[1] = 0x00; |
617 | memcpy (u8aIeeeHeader->i_addr2, dev->pl_mac, MAC_ADDR_SIZE); | 1604 | memcpy (u8aIeeeHeader->i_addr2, &dev->pl_mac, MAC_ADDR_SIZE); |
618 | memcpy (u8aIeeeHeader->i_addr3, &mac_bssid, MAC_ADDR_SIZE); | 1605 | memcpy (u8aIeeeHeader->i_addr3, &mac_bssid, MAC_ADDR_SIZE); |
619 | 1606 | ||
620 | } | 1607 | } |
@@ -746,7 +1733,7 @@ maketest (unsigned char *buf, struct Hardware_Infos *dev) | |||
746 | if (0 == first) | 1733 | if (0 == first) |
747 | { | 1734 | { |
748 | memcpy (&u8aIeeeHeader, u8aIeeeHeader_def, sizeof (struct ieee80211_frame)); | 1735 | memcpy (&u8aIeeeHeader, u8aIeeeHeader_def, sizeof (struct ieee80211_frame)); |
749 | memcpy (u8aIeeeHeader.i_addr2, dev->pl_mac, MAC_ADDR_SIZE); | 1736 | memcpy (u8aIeeeHeader.i_addr2, &dev->pl_mac, MAC_ADDR_SIZE); |
750 | first = 1; | 1737 | first = 1; |
751 | } | 1738 | } |
752 | 1739 | ||
@@ -807,7 +1794,7 @@ hardwaremode (int argc, char *argv[]) | |||
807 | 1794 | ||
808 | /* send mac to STDOUT first */ | 1795 | /* send mac to STDOUT first */ |
809 | write_std.pos = 0; | 1796 | write_std.pos = 0; |
810 | write_std.size = send_mac_to_plugin ((char *) &write_std.buf, dev.pl_mac); | 1797 | write_std.size = send_mac_to_plugin ((char *) &write_std.buf, &dev.pl_mac); |
811 | stdin_open = 1; | 1798 | stdin_open = 1; |
812 | 1799 | ||
813 | while (1) | 1800 | while (1) |
diff --git a/src/transport/gnunet-transport-wlan-helper.h b/src/transport/gnunet-transport-wlan-helper.h deleted file mode 100644 index 8ebba0ce9..000000000 --- a/src/transport/gnunet-transport-wlan-helper.h +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file transport/gnunet-transport-wlan-helper.h | ||
23 | * @brief common internal definitions for the wlan mediator | ||
24 | * @author David Brodski | ||
25 | */ | ||
26 | |||
27 | #ifndef gnunet_wlan_H | ||
28 | #define gnunet_wlan_H | ||
29 | |||
30 | /* | ||
31 | #include <stdio.h> | ||
32 | #include <stdlib.h> | ||
33 | #include <errno.h> | ||
34 | #include <resolv.h> | ||
35 | #include <string.h> | ||
36 | #include <utime.h> | ||
37 | #include <unistd.h> | ||
38 | #include <getopt.h> | ||
39 | #include <pcap.h>*/ | ||
40 | //#include <endian.h> | ||
41 | |||
42 | /* | ||
43 | typedef unsigned int u32; | ||
44 | typedef unsigned short u16; | ||
45 | typedef unsigned char u8; | ||
46 | typedef u32 __le32; | ||
47 | */ | ||
48 | /* | ||
49 | #if __BYTE_ORDER == __LITTLE_ENDIAN | ||
50 | #define le16_to_cpu(x) (x) | ||
51 | #define le32_to_cpu(x) (x) | ||
52 | #else | ||
53 | #define le16_to_cpu(x) ((((x)&0xff)<<8)|(((x)&0xff00)>>8)) | ||
54 | #define le32_to_cpu(x) \ | ||
55 | ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)&0xff0000)>>8)|(((x)&0xff000000)>>24)) | ||
56 | #endif | ||
57 | */ | ||
58 | #define unlikely(x) (x) | ||
59 | |||
60 | #endif /* gnunet_wlan_H */ | ||
diff --git a/src/transport/wlan/helper_common.c b/src/transport/wlan/helper_common.c deleted file mode 100644 index 8e1c59421..000000000 --- a/src/transport/wlan/helper_common.c +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | /* | ||
2 | * helper_common.c | ||
3 | * | ||
4 | * Created on: 28.03.2011 | ||
5 | * Author: David Brodski | ||
6 | */ | ||
7 | |||
8 | #include <sys/socket.h> | ||
9 | #include <stdint.h> | ||
10 | #include <stdio.h> | ||
11 | #include <stdlib.h> | ||
12 | #include <errno.h> | ||
13 | #include <resolv.h> | ||
14 | #include <string.h> | ||
15 | #include <utime.h> | ||
16 | #include <unistd.h> | ||
17 | #include <getopt.h> | ||
18 | |||
19 | #include "platform.h" | ||
20 | #include "gnunet_constants.h" | ||
21 | #include "gnunet_os_lib.h" | ||
22 | #include "gnunet_transport_plugin.h" | ||
23 | #include "transport.h" | ||
24 | #include "gnunet_util_lib.h" | ||
25 | #include "plugin_transport_wlan.h" | ||
26 | #include "gnunet_common.h" | ||
27 | #include "gnunet_transport_plugin.h" | ||
28 | //#include "gnunet_util_lib.h" | ||
29 | |||
30 | /** | ||
31 | * function to create GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL message for plugin | ||
32 | * @param buffer pointer to buffer for the message | ||
33 | * @param mac pointer to the mac address | ||
34 | * @return number of bytes written | ||
35 | */ | ||
36 | int | ||
37 | send_mac_to_plugin (char *buffer, struct MacAddress *mac) | ||
38 | { | ||
39 | |||
40 | struct Wlan_Helper_Control_Message macmsg; | ||
41 | |||
42 | memcpy (&macmsg.mac, (char *) mac, sizeof (struct MacAddress)); | ||
43 | macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message)); | ||
44 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); | ||
45 | |||
46 | memcpy (buffer, &macmsg, sizeof (struct Wlan_Helper_Control_Message)); | ||
47 | return sizeof (struct Wlan_Helper_Control_Message); | ||
48 | } | ||
diff --git a/src/transport/wlan/helper_common.h b/src/transport/wlan/helper_common.h deleted file mode 100644 index 9d53176c6..000000000 --- a/src/transport/wlan/helper_common.h +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | /* | ||
2 | * helper_common.h | ||
3 | * | ||
4 | * Created on: 28.03.2011 | ||
5 | * Author: david | ||
6 | */ | ||
7 | |||
8 | #ifndef HELPER_COMMON_H_ | ||
9 | #define HELPER_COMMON_H_ | ||
10 | |||
11 | int | ||
12 | send_mac_to_plugin (char *buffer, uint8_t * mac); | ||
13 | |||
14 | |||
15 | #define MAXLINE 4096 | ||
16 | |||
17 | struct sendbuf | ||
18 | { | ||
19 | unsigned int pos; | ||
20 | unsigned int size; | ||
21 | char buf[MAXLINE * 2]; | ||
22 | }; | ||
23 | |||
24 | #endif /* HELPER_COMMON_H_ */ | ||
diff --git a/src/transport/wlan/loopback_helper.h b/src/transport/wlan/loopback_helper.h deleted file mode 100644 index 5da3d834e..000000000 --- a/src/transport/wlan/loopback_helper.h +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | /* | ||
2 | * loopback_helper.h | ||
3 | * | ||
4 | * Created on: 28.03.2011 | ||
5 | * Author: David Brodski | ||
6 | */ | ||
7 | |||
8 | #ifndef LOOPBACK_HELPER_H_ | ||
9 | #define LOOPBACK_HELPER_H_ | ||
10 | |||
11 | //static void sigfunc(int sig); | ||
12 | |||
13 | //static void stdin_send(void *cls, void *client, const struct GNUNET_MessageHeader *hdr); | ||
14 | |||
15 | //static void file_in_send(void *cls, void *client, const struct GNUNET_MessageHeader *hdr); | ||
16 | |||
17 | int | ||
18 | testmode (int argc, char *argv[]); | ||
19 | |||
20 | |||
21 | #define FIFO_FILE1 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_in" | ||
22 | #define FIFO_FILE2 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_out" | ||
23 | |||
24 | extern int closeprog; | ||
25 | |||
26 | #endif /* LOOPBACK_HELPER_H_ */ | ||