aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-25 09:19:41 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-25 09:19:41 +0000
commit87cbb6dba24959428c7a71e1aa125f80584e0249 (patch)
tree51eae9fdeef925c99dae2cdb9ad691b0edf3693b /src/transport
parentbd4822b448a18c28b07754efff1d962630a0da31 (diff)
downloadgnunet-87cbb6dba24959428c7a71e1aa125f80584e0249.tar.gz
gnunet-87cbb6dba24959428c7a71e1aa125f80584e0249.zip
removing no longer needed wlan directory
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/wlan/byteorder.h387
-rw-r--r--src/transport/wlan/crctable_osdep.h71
-rw-r--r--src/transport/wlan/ieee80211.h689
-rw-r--r--src/transport/wlan/ieee80211_radiotap.h262
-rw-r--r--src/transport/wlan/radiotap-parser.c260
-rw-r--r--src/transport/wlan/radiotap-parser.h79
6 files changed, 0 insertions, 1748 deletions
diff --git a/src/transport/wlan/byteorder.h b/src/transport/wlan/byteorder.h
deleted file mode 100644
index 1a13470e9..000000000
--- a/src/transport/wlan/byteorder.h
+++ /dev/null
@@ -1,387 +0,0 @@
1/*
2 * Compatibility header
3 *
4 * Copyright (C) 2009 Thomas d'Otreppe
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef _AIRCRACK_NG_BYTEORDER_H_
22#define _AIRCRACK_NG_BYTEORDER_H_
23
24 /* *INDENT-OFF* */
25#define ___my_swab16(x) \
26((u_int16_t)( \
27 (((u_int16_t)(x) & (u_int16_t)0x00ffU) << 8) | \
28 (((u_int16_t)(x) & (u_int16_t)0xff00U) >> 8) ))
29
30#define ___my_swab32(x) \
31((u_int32_t)( \
32 (((u_int32_t)(x) & (u_int32_t)0x000000ffUL) << 24) | \
33 (((u_int32_t)(x) & (u_int32_t)0x0000ff00UL) << 8) | \
34 (((u_int32_t)(x) & (u_int32_t)0x00ff0000UL) >> 8) | \
35 (((u_int32_t)(x) & (u_int32_t)0xff000000UL) >> 24) ))
36#define ___my_swab64(x) \
37((u_int64_t)( \
38 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000000000ffULL) << 56) | \
39 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000000000ff00ULL) << 40) | \
40 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000000000ff0000ULL) << 24) | \
41 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000ff000000ULL) << 8) | \
42 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000ff00000000ULL) >> 8) | \
43 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000ff0000000000ULL) >> 24) | \
44 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00ff000000000000ULL) >> 40) | \
45 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0xff00000000000000ULL) >> 56) ))
46 /* *INDENT-ON* */
47 /*
48 * Linux
49 */
50#if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux__)
51#include <endian.h>
52#include <unistd.h>
53#include <stdint.h>
54
55#ifndef __int8_t_defined
56typedef uint64_t u_int64_t;
57typedef uint32_t u_int32_t;
58typedef uint16_t u_int16_t;
59typedef uint8_t u_int8_t;
60
61
62#endif /* */
63
64#ifndef htole16
65#if __BYTE_ORDER == __LITTLE_ENDIAN
66#define htobe16(x) ___my_swab16 (x)
67#define htole16(x) (x)
68#define be16toh(x) ___my_swab16 (x)
69#define le16toh(x) (x)
70
71#define htobe32(x) ___my_swab32 (x)
72#define htole32(x) (x)
73#define be32toh(x) ___my_swab32 (x)
74#define le32toh(x) (x)
75
76#define htobe64(x) ___my_swab64 (x)
77#define htole64(x) (x)
78#define be64toh(x) ___my_swab64 (x)
79#define le64toh(x) (x)
80#else /* */
81#define htobe16(x) (x)
82#define htole16(x) ___my_swab16 (x)
83#define be16toh(x) (x)
84#define le16toh(x) ___my_swab16 (x)
85
86#define htobe32(x) (x)
87#define htole32(x) ___my_swab32 (x)
88#define be32toh(x) (x)
89#define le32toh(x) ___my_swab32 (x)
90
91#define htobe64(x) (x)
92#define htole64(x) ___my_swab64 (x)
93#define be64toh(x) (x)
94#define le64toh(x) ___my_swab64 (x)
95#endif /* */
96#endif /* */
97
98#endif /* */
99 /*
100 * Cygwin
101 */
102#if defined(__CYGWIN32__)
103#include <asm/byteorder.h>
104#include <unistd.h>
105#define __be64_to_cpu(x) ___my_swab64(x)
106#define __be32_to_cpu(x) ___my_swab32(x)
107#define __be16_to_cpu(x) ___my_swab16(x)
108#define __cpu_to_be64(x) ___my_swab64(x)
109#define __cpu_to_be32(x) ___my_swab32(x)
110#define __cpu_to_be16(x) ___my_swab16(x)
111#define __le64_to_cpu(x) (x)
112#define __le32_to_cpu(x) (x)
113#define __le16_to_cpu(x) (x)
114#define __cpu_to_le64(x) (x)
115#define __cpu_to_le32(x) (x)
116#define __cpu_to_le16(x) (x)
117#define AIRCRACK_NG_BYTE_ORDER_DEFINED
118#endif /* */
119 /*
120 * Windows (DDK)
121 */
122#if defined(__WIN__)
123#include <io.h>
124#define __be64_to_cpu(x) ___my_swab64(x)
125#define __be32_to_cpu(x) ___my_swab32(x)
126#define __be16_to_cpu(x) ___my_swab16(x)
127#define __cpu_to_be64(x) ___my_swab64(x)
128#define __cpu_to_be32(x) ___my_swab32(x)
129#define __cpu_to_be16(x) ___my_swab16(x)
130#define __le64_to_cpu(x) (x)
131#define __le32_to_cpu(x) (x)
132#define __le16_to_cpu(x) (x)
133#define __cpu_to_le64(x) (x)
134#define __cpu_to_le32(x) (x)
135#define __cpu_to_le16(x) (x)
136#define AIRCRACK_NG_BYTE_ORDER_DEFINED
137#endif /* */
138 /*
139 * MAC (Darwin)
140 */
141#if defined(__APPLE_CC__)
142#if defined(__x86_64__) && defined(__APPLE__)
143#include <libkern/OSByteOrder.h>
144#define __swab64(x) (unsigned long long) OSSwapInt64((uint64_t)x)
145#define __swab32(x) (unsigned long) OSSwapInt32((uint32_t)x)
146#define __swab16(x) (unsigned short) OSSwapInt16((uint16_t)x)
147#define __be64_to_cpu(x) (unsigned long long) OSSwapBigToHostInt64((uint64_t)x)
148#define __be32_to_cpu(x) (unsigned long) OSSwapBigToHostInt32((uint32_t)x)
149#define __be16_to_cpu(x) (unsigned short) OSSwapBigToHostInt16((uint16_t)x)
150#define __le64_to_cpu(x) (unsigned long long) OSSwapLittleToHostInt64((uint64_t)x)
151#define __le32_to_cpu(x) (unsigned long) OSSwapLittleToHostInt32((uint32_t)x)
152#define __le16_to_cpu(x) (unsigned short) OSSwapLittleToHostInt16((uint16_t)x)
153#define __cpu_to_be64(x) (unsigned long long) OSSwapHostToBigInt64((uint64_t)x)
154#define __cpu_to_be32(x) (unsigned long) OSSwapHostToBigInt32((uint32_t)x)
155#define __cpu_to_be16(x) (unsigned short) OSSwapHostToBigInt16((uint16_t)x)
156#define __cpu_to_le64(x) (unsigned long long) OSSwapHostToLittleInt64((uint64_t)x)
157#define __cpu_to_le32(x) (unsigned long) OSSwapHostToLittleInt32((uint32_t)x)
158#define __cpu_to_le16(x) (unsigned short) OSSwapHostToLittleInt16((uint16_t)x)
159#else /* */
160#include <architecture/byte_order.h>
161#define __swab64(x) NXSwapLongLong(x)
162#define __swab32(x) NXSwapLong(x)
163#define __swab16(x) NXSwapShort(x)
164#define __be64_to_cpu(x) NXSwapBigLongLongToHost(x)
165#define __be32_to_cpu(x) NXSwapBigLongToHost(x)
166#define __be16_to_cpu(x) NXSwapBigShortToHost(x)
167#define __le64_to_cpu(x) NXSwapLittleLongLongToHost(x)
168#define __le32_to_cpu(x) NXSwapLittleLongToHost(x)
169#define __le16_to_cpu(x) NXSwapLittleShortToHost(x)
170#define __cpu_to_be64(x) NXSwapHostLongLongToBig(x)
171#define __cpu_to_be32(x) NXSwapHostLongToBig(x)
172#define __cpu_to_be16(x) NXSwapHostShortToBig(x)
173#define __cpu_to_le64(x) NXSwapHostLongLongToLittle(x)
174#define __cpu_to_le32(x) NXSwapHostLongToLittle(x)
175#define __cpu_to_le16(x) NXSwapHostShortToLittle(x)
176#endif /* */
177#define __LITTLE_ENDIAN 1234
178#define __BIG_ENDIAN 4321
179#define __PDP_ENDIAN 3412
180#define __BYTE_ORDER __BIG_ENDIAN
181#define AIRCRACK_NG_BYTE_ORDER_DEFINED
182#endif /* */
183 /*
184 * Solaris
185 * -------
186 */
187#if defined(__sparc__) && defined(__sun__)
188#include <sys/byteorder.h>
189#include <sys/types.h>
190#include <unistd.h>
191#define __be64_to_cpu(x) (x)
192#define __be32_to_cpu(x) (x)
193#define __be16_to_cpu(x) (x)
194#define __cpu_to_be64(x) (x)
195#define __cpu_to_be32(x) (x)
196#define __cpu_to_be16(x) (x)
197#define __le64_to_cpu(x) ___my_swab64(x)
198#define __le32_to_cpu(x) ___my_swab32(x)
199#define __le16_to_cpu(x) ___my_swab16(x)
200#define __cpu_to_le64(x) ___my_swab64(x)
201#define __cpu_to_le32(x) ___my_swab32(x)
202#define __cpu_to_le16(x) ___my_swab16(x)
203typedef uint64_t u_int64_t;
204typedef uint32_t u_int32_t;
205typedef uint16_t u_int16_t;
206typedef uint8_t u_int8_t;
207
208
209#define AIRCRACK_NG_BYTE_ORDER_DEFINED
210#endif /* */
211 /*
212 * Custom stuff
213 */
214#if defined(__MACH__) && !defined(__APPLE_CC__)
215#include <libkern/OSByteOrder.h>
216#define __cpu_to_be64(x) = OSSwapHostToBigInt64(x)
217#define __cpu_to_be32(x) = OSSwapHostToBigInt32(x)
218#define AIRCRACK_NG_BYTE_ORDER_DEFINED
219#endif /* */
220
221 // FreeBSD
222#ifdef __FreeBSD__
223#include <machine/endian.h>
224#endif /* */
225 // XXX: Is there anything to include on OpenBSD/NetBSD/DragonFlyBSD/...?
226
227 // XXX: Mac: Check http://www.opensource.apple.com/source/CF/CF-476.18/CFByteOrder.h
228 // http://developer.apple.com/DOCUMENTATION/CoreFoundation/Reference/CFByteOrderUtils/Reference/reference.html
229 // Write to apple to ask what should be used.
230#if defined(LITTLE_ENDIAN)
231#define AIRCRACK_NG_LITTLE_ENDIAN LITTLE_ENDIAN
232#elif defined(__LITTLE_ENDIAN)
233#define AIRCRACK_NG_LITTLE_ENDIAN __LITTLE_ENDIAN
234#elif defined(_LITTLE_ENDIAN)
235#define AIRCRACK_NG_LITTLE_ENDIAN _LITTLE_ENDIAN
236#endif /* */
237#if defined(BIG_ENDIAN)
238#define AIRCRACK_NG_BIG_ENDIAN BIG_ENDIAN
239#elif defined(__BIG_ENDIAN)
240#define AIRCRACK_NG_BIG_ENDIAN __BIG_ENDIAN
241#elif defined(_BIG_ENDIAN)
242#define AIRCRACK_NG_BIG_ENDIAN _BIG_ENDIAN
243#endif /* */
244#if !defined(AIRCRACK_NG_LITTLE_ENDIAN) && !defined(AIRCRACK_NG_BIG_ENDIAN)
245#error Impossible to determine endianness (Little or Big endian), please contact the author.
246#endif /* */
247#if defined(BYTE_ORDER)
248#if (BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
249#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN
250#elif (BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
251#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN
252#endif /* */
253#elif defined(__BYTE_ORDER)
254#if (__BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
255#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN
256#elif (__BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
257#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN
258#endif /* */
259#elif defined(_BYTE_ORDER)
260#if (_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
261#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN
262#elif (_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
263#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN
264#endif /* */
265#endif /* */
266#ifndef AIRCRACK_NG_BYTE_ORDER
267#error Impossible to determine endianness (Little or Big endian), please contact the author.
268#endif /* */
269#if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
270#ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED
271#define __be64_to_cpu(x) ___my_swab64(x)
272#define __be32_to_cpu(x) ___my_swab32(x)
273#define __be16_to_cpu(x) ___my_swab16(x)
274#define __cpu_to_be64(x) ___my_swab64(x)
275#define __cpu_to_be32(x) ___my_swab32(x)
276#define __cpu_to_be16(x) ___my_swab16(x)
277#define __le64_to_cpu(x) (x)
278#define __le32_to_cpu(x) (x)
279#define __le16_to_cpu(x) (x)
280#define __cpu_to_le64(x) (x)
281#define __cpu_to_le32(x) (x)
282#define __cpu_to_le16(x) (x)
283#endif /* */
284#ifndef htobe16
285#define htobe16 ___my_swab16
286#endif /* */
287#ifndef htobe32
288#define htobe32 ___my_swab32
289#endif /* */
290#ifndef betoh16
291#define betoh16 ___my_swab16
292#endif /* */
293#ifndef betoh32
294#define betoh32 ___my_swab32
295#endif /* */
296#ifndef htole16
297#define htole16(x) (x)
298#endif /* */
299#ifndef htole32
300#define htole32(x) (x)
301#endif /* */
302#ifndef letoh16
303#define letoh16(x) (x)
304#endif /* */
305#ifndef letoh32
306#define letoh32(x) (x)
307#endif /* */
308#endif /* */
309#if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
310#ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED
311#define __be64_to_cpu(x) (x)
312#define __be32_to_cpu(x) (x)
313#define __be16_to_cpu(x) (x)
314#define __cpu_to_be64(x) (x)
315#define __cpu_to_be32(x) (x)
316#define __cpu_to_be16(x) (x)
317#define __le64_to_cpu(x) ___my_swab64(x)
318#define __le32_to_cpu(x) ___my_swab32(x)
319#define __le16_to_cpu(x) ___my_swab16(x)
320#define __cpu_to_le64(x) ___my_swab64(x)
321#define __cpu_to_le32(x) ___my_swab32(x)
322#define __cpu_to_le16(x) ___my_swab16(x)
323#endif /* */
324#ifndef htobe16
325#define htobe16(x) (x)
326#endif /* */
327#ifndef htobe32
328#define htobe32(x) (x)
329#endif /* */
330#ifndef betoh16
331#define betoh16(x) (x)
332#endif /* */
333#ifndef betoh32
334#define betoh32(x) (x)
335#endif /* */
336#ifndef htole16
337#define htole16 ___my_swab16
338#endif /* */
339#ifndef htole32
340#define htole32 ___my_swab32
341#endif /* */
342#ifndef letoh16
343#define letoh16 ___my_swab16
344#endif /* */
345#ifndef letoh32
346#define letoh32 ___my_swab32
347#endif /* */
348#endif /* */
349 // Common defines
350#define cpu_to_le64 __cpu_to_le64
351#define le64_to_cpu __le64_to_cpu
352#define cpu_to_le32 __cpu_to_le32
353#define le32_to_cpu __le32_to_cpu
354#define cpu_to_le16 __cpu_to_le16
355#define le16_to_cpu __le16_to_cpu
356#define cpu_to_be64 __cpu_to_be64
357#define be64_to_cpu __be64_to_cpu
358#define cpu_to_be32 __cpu_to_be32
359#define be32_to_cpu __be32_to_cpu
360#define cpu_to_be16 __cpu_to_be16
361#define be16_to_cpu __be16_to_cpu
362#ifndef le16toh
363#define le16toh le16_to_cpu
364#endif /* */
365#ifndef be16toh
366#define be16toh be16_to_cpu
367#endif /* */
368#ifndef le32toh
369#define le32toh le32_to_cpu
370#endif /* */
371#ifndef be32toh
372#define be32toh be32_to_cpu
373#endif /* */
374
375#ifndef htons
376#define htons be16_to_cpu
377#endif /* */
378#ifndef htonl
379#define htonl cpu_to_be16
380#endif /* */
381#ifndef ntohs
382#define ntohs cpu_to_be16
383#endif /* */
384#ifndef ntohl
385#define ntohl cpu_to_be32
386#endif /* */
387#endif /* */
diff --git a/src/transport/wlan/crctable_osdep.h b/src/transport/wlan/crctable_osdep.h
deleted file mode 100644
index 04c769f2a..000000000
--- a/src/transport/wlan/crctable_osdep.h
+++ /dev/null
@@ -1,71 +0,0 @@
1#ifndef _CRCTABLE_OSDEP_H
2#define _CRCTABLE_OSDEP_H
3
4const unsigned long int crc_tbl_osdep[256] = {
5 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
6 0xE963A535, 0x9E6495A3,
7 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD,
8 0xE7B82D07, 0x90BF1D91,
9 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB,
10 0xF4D4B551, 0x83D385C7,
11 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9,
12 0xFA0F3D63, 0x8D080DF5,
13 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447,
14 0xD20D85FD, 0xA50AB56B,
15 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75,
16 0xDCD60DCF, 0xABD13D59,
17 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423,
18 0xCFBA9599, 0xB8BDA50F,
19 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11,
20 0xC1611DAB, 0xB6662D3D,
21 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F,
22 0x9FBFE4A5, 0xE8B8D433,
23 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D,
24 0x91646C97, 0xE6635C01,
25 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B,
26 0x8208F4C1, 0xF50FC457,
27 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49,
28 0x8CD37CF3, 0xFBD44C65,
29 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7,
30 0xA4D1C46D, 0xD3D6F4FB,
31 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5,
32 0xAA0A4C5F, 0xDD0D7CC9,
33 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3,
34 0xB966D409, 0xCE61E49F,
35 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
36 0xB7BD5C3B, 0xC0BA6CAD,
37 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF,
38 0x04DB2615, 0x73DC1683,
39 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D,
40 0x0A00AE27, 0x7D079EB1,
41 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
42 0x196C3671, 0x6E6B06E7,
43 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9,
44 0x17B7BE43, 0x60B08ED5,
45 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767,
46 0x3FB506DD, 0x48B2364B,
47 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55,
48 0x316E8EEF, 0x4669BE79,
49 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703,
50 0x220216B9, 0x5505262F,
51 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31,
52 0x2CD99E8B, 0x5BDEAE1D,
53 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F,
54 0x72076785, 0x05005713,
55 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D,
56 0x7CDCEFB7, 0x0BDBDF21,
57 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B,
58 0x6FB077E1, 0x18B74777,
59 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69,
60 0x616BFFD3, 0x166CCF45,
61 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7,
62 0x4969474D, 0x3E6E77DB,
63 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5,
64 0x47B2CF7F, 0x30B5FFE9,
65 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
66 0x54DE5729, 0x23D967BF,
67 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1,
68 0x5A05DF1B, 0x2D02EF8D
69};
70
71#endif /* crctable_osdep.h */
diff --git a/src/transport/wlan/ieee80211.h b/src/transport/wlan/ieee80211.h
deleted file mode 100644
index fd297f4a4..000000000
--- a/src/transport/wlan/ieee80211.h
+++ /dev/null
@@ -1,689 +0,0 @@
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * Alternatively, this software may be distributed under the terms of the
18 * GNU General Public License ("GPL") version 2 as published by the Free
19 * Software Foundation.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.12 2006/12/01 18:40:51 imp Exp $
33 */
34#ifndef _NET80211_IEEE80211_H_
35#define _NET80211_IEEE80211_H_
36
37/*
38 * 802.11 protocol definitions.
39 */
40
41#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
42/* is 802.11 address multicast/broadcast? */
43#define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01)
44
45/* IEEE 802.11 PLCP header */
46struct ieee80211_plcp_hdr
47{
48 u_int16_t i_sfd;
49 u_int8_t i_signal;
50 u_int8_t i_service;
51 u_int16_t i_length;
52 u_int16_t i_crc;
53} GNUNET_PACKED;
54
55#define IEEE80211_PLCP_SFD 0xF3A0
56#define IEEE80211_PLCP_SERVICE 0x00
57
58/*
59 * generic definitions for IEEE 802.11 frames
60 */
61struct ieee80211_frame
62{
63 u_int8_t i_fc[2];
64 u_int8_t i_dur[2];
65 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
66 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
67 u_int8_t i_addr3[IEEE80211_ADDR_LEN];
68 u_int8_t i_seq[2];
69 /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
70 /* see below */
71} GNUNET_PACKED;
72
73struct ieee80211_qosframe
74{
75 u_int8_t i_fc[2];
76 u_int8_t i_dur[2];
77 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
78 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
79 u_int8_t i_addr3[IEEE80211_ADDR_LEN];
80 u_int8_t i_seq[2];
81 u_int8_t i_qos[2];
82 /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
83 /* see below */
84} GNUNET_PACKED;
85
86struct ieee80211_qoscntl
87{
88 u_int8_t i_qos[2];
89};
90
91struct ieee80211_frame_addr4
92{
93 u_int8_t i_fc[2];
94 u_int8_t i_dur[2];
95 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
96 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
97 u_int8_t i_addr3[IEEE80211_ADDR_LEN];
98 u_int8_t i_seq[2];
99 u_int8_t i_addr4[IEEE80211_ADDR_LEN];
100} GNUNET_PACKED;
101
102
103struct ieee80211_qosframe_addr4
104{
105 u_int8_t i_fc[2];
106 u_int8_t i_dur[2];
107 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
108 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
109 u_int8_t i_addr3[IEEE80211_ADDR_LEN];
110 u_int8_t i_seq[2];
111 u_int8_t i_addr4[IEEE80211_ADDR_LEN];
112 u_int8_t i_qos[2];
113} GNUNET_PACKED;
114
115#define IEEE80211_FC0_VERSION_MASK 0x03
116#define IEEE80211_FC0_VERSION_SHIFT 0
117#define IEEE80211_FC0_VERSION_0 0x00
118#define IEEE80211_FC0_TYPE_MASK 0x0c
119#define IEEE80211_FC0_TYPE_SHIFT 2
120#define IEEE80211_FC0_TYPE_MGT 0x00
121#define IEEE80211_FC0_TYPE_CTL 0x04
122#define IEEE80211_FC0_TYPE_DATA 0x08
123
124#define IEEE80211_FC0_SUBTYPE_MASK 0xf0
125#define IEEE80211_FC0_SUBTYPE_SHIFT 4
126/* for TYPE_MGT */
127#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
128#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
129#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
130#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
131#define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
132#define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
133#define IEEE80211_FC0_SUBTYPE_BEACON 0x80
134#define IEEE80211_FC0_SUBTYPE_ATIM 0x90
135#define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
136#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
137#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
138/* for TYPE_CTL */
139#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
140#define IEEE80211_FC0_SUBTYPE_RTS 0xb0
141#define IEEE80211_FC0_SUBTYPE_CTS 0xc0
142#define IEEE80211_FC0_SUBTYPE_ACK 0xd0
143#define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
144#define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
145/* for TYPE_DATA (bit combination) */
146#define IEEE80211_FC0_SUBTYPE_DATA 0x00
147#define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
148#define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
149#define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
150#define IEEE80211_FC0_SUBTYPE_NODATA 0x40
151#define IEEE80211_FC0_SUBTYPE_CFACK 0x50
152#define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60
153#define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
154#define IEEE80211_FC0_SUBTYPE_QOS 0x80
155#define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0
156
157#define IEEE80211_FC1_DIR_MASK 0x03
158#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
159#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
160#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
161#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
162
163#define IEEE80211_FC1_MORE_FRAG 0x04
164#define IEEE80211_FC1_RETRY 0x08
165#define IEEE80211_FC1_PWR_MGT 0x10
166#define IEEE80211_FC1_MORE_DATA 0x20
167#define IEEE80211_FC1_WEP 0x40
168#define IEEE80211_FC1_ORDER 0x80
169
170#define IEEE80211_SEQ_FRAG_MASK 0x000f
171#define IEEE80211_SEQ_FRAG_SHIFT 0
172#define IEEE80211_SEQ_SEQ_MASK 0xfff0
173#define IEEE80211_SEQ_SEQ_SHIFT 4
174
175#define IEEE80211_NWID_LEN 32
176
177#define IEEE80211_QOS_TXOP 0x00ff
178/* bit 8 is reserved */
179#define IEEE80211_QOS_ACKPOLICY 0x60
180#define IEEE80211_QOS_ACKPOLICY_S 5
181#define IEEE80211_QOS_ESOP 0x10
182#define IEEE80211_QOS_ESOP_S 4
183#define IEEE80211_QOS_TID 0x0f
184
185/* does frame have QoS sequence control data */
186#define IEEE80211_QOS_HAS_SEQ(wh) \
187 (((wh)->i_fc[0] & \
188 (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \
189 (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
190
191/*
192 * WME/802.11e information element.
193 */
194struct ieee80211_wme_info
195{
196 u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */
197 u_int8_t wme_len; /* length in bytes */
198 u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */
199 u_int8_t wme_type; /* OUI type */
200 u_int8_t wme_subtype; /* OUI subtype */
201 u_int8_t wme_version; /* spec revision */
202 u_int8_t wme_info; /* QoS info */
203} GNUNET_PACKED;
204
205/*
206 * WME/802.11e Tspec Element
207 */
208struct ieee80211_wme_tspec
209{
210 u_int8_t ts_id;
211 u_int8_t ts_len;
212 u_int8_t ts_oui[3];
213 u_int8_t ts_oui_type;
214 u_int8_t ts_oui_subtype;
215 u_int8_t ts_version;
216 u_int8_t ts_tsinfo[3];
217 u_int8_t ts_nom_msdu[2];
218 u_int8_t ts_max_msdu[2];
219 u_int8_t ts_min_svc[4];
220 u_int8_t ts_max_svc[4];
221 u_int8_t ts_inactv_intv[4];
222 u_int8_t ts_susp_intv[4];
223 u_int8_t ts_start_svc[4];
224 u_int8_t ts_min_rate[4];
225 u_int8_t ts_mean_rate[4];
226 u_int8_t ts_max_burst[4];
227 u_int8_t ts_min_phy[4];
228 u_int8_t ts_peak_rate[4];
229 u_int8_t ts_delay[4];
230 u_int8_t ts_surplus[2];
231 u_int8_t ts_medium_time[2];
232} GNUNET_PACKED;
233
234/*
235 * WME AC parameter field
236 */
237struct ieee80211_wme_acparams
238{
239 u_int8_t acp_aci_aifsn;
240 u_int8_t acp_logcwminmax;
241 u_int16_t acp_txop;
242} GNUNET_PACKED;
243
244#define WME_NUM_AC 4 /* 4 AC categories */
245
246#define WME_PARAM_ACI 0x60 /* Mask for ACI field */
247#define WME_PARAM_ACI_S 5 /* Shift for ACI field */
248#define WME_PARAM_ACM 0x10 /* Mask for ACM bit */
249#define WME_PARAM_ACM_S 4 /* Shift for ACM bit */
250#define WME_PARAM_AIFSN 0x0f /* Mask for aifsn field */
251#define WME_PARAM_AIFSN_S 0 /* Shift for aifsn field */
252#define WME_PARAM_LOGCWMIN 0x0f /* Mask for CwMin field (in log) */
253#define WME_PARAM_LOGCWMIN_S 0 /* Shift for CwMin field */
254#define WME_PARAM_LOGCWMAX 0xf0 /* Mask for CwMax field (in log) */
255#define WME_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */
256
257#define WME_AC_TO_TID(_ac) ( \
258 ((_ac) == WME_AC_VO) ? 6 : \
259 ((_ac) == WME_AC_VI) ? 5 : \
260 ((_ac) == WME_AC_BK) ? 1 : \
261 0)
262
263#define TID_TO_WME_AC(_tid) ( \
264 ((_tid) < 1) ? WME_AC_BE : \
265 ((_tid) < 3) ? WME_AC_BK : \
266 ((_tid) < 6) ? WME_AC_VI : \
267 WME_AC_VO)
268
269/*
270 * WME Parameter Element
271 */
272struct ieee80211_wme_param
273{
274 u_int8_t param_id;
275 u_int8_t param_len;
276 u_int8_t param_oui[3];
277 u_int8_t param_oui_type;
278 u_int8_t param_oui_sybtype;
279 u_int8_t param_version;
280 u_int8_t param_qosInfo;
281#define WME_QOSINFO_COUNT 0x0f /* Mask for param count field */
282 u_int8_t param_reserved;
283 struct ieee80211_wme_acparams params_acParams[WME_NUM_AC];
284} GNUNET_PACKED;
285
286/*
287 * Management Notification Frame
288 */
289struct ieee80211_mnf
290{
291 u_int8_t mnf_category;
292 u_int8_t mnf_action;
293 u_int8_t mnf_dialog;
294 u_int8_t mnf_status;
295} GNUNET_PACKED;
296
297#define MNF_SETUP_REQ 0
298#define MNF_SETUP_RESP 1
299#define MNF_TEARDOWN 2
300
301/*
302 * Control frames.
303 */
304struct ieee80211_frame_min
305{
306 u_int8_t i_fc[2];
307 u_int8_t i_dur[2];
308 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
309 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
310 /* FCS */
311} GNUNET_PACKED;
312
313struct ieee80211_frame_rts
314{
315 u_int8_t i_fc[2];
316 u_int8_t i_dur[2];
317 u_int8_t i_ra[IEEE80211_ADDR_LEN];
318 u_int8_t i_ta[IEEE80211_ADDR_LEN];
319 /* FCS */
320} GNUNET_PACKED;
321
322struct ieee80211_frame_cts
323{
324 u_int8_t i_fc[2];
325 u_int8_t i_dur[2];
326 u_int8_t i_ra[IEEE80211_ADDR_LEN];
327 /* FCS */
328} GNUNET_PACKED;
329
330struct ieee80211_frame_ack
331{
332 u_int8_t i_fc[2];
333 u_int8_t i_dur[2];
334 u_int8_t i_ra[IEEE80211_ADDR_LEN];
335 /* FCS */
336} GNUNET_PACKED;
337
338struct ieee80211_frame_pspoll
339{
340 u_int8_t i_fc[2];
341 u_int8_t i_aid[2];
342 u_int8_t i_bssid[IEEE80211_ADDR_LEN];
343 u_int8_t i_ta[IEEE80211_ADDR_LEN];
344 /* FCS */
345} GNUNET_PACKED;
346
347struct ieee80211_frame_cfend
348{ /* NB: also CF-End+CF-Ack */
349 u_int8_t i_fc[2];
350 u_int8_t i_dur[2]; /* should be zero */
351 u_int8_t i_ra[IEEE80211_ADDR_LEN];
352 u_int8_t i_bssid[IEEE80211_ADDR_LEN];
353 /* FCS */
354} GNUNET_PACKED;
355
356/*
357 * BEACON management packets
358 *
359 * octet timestamp[8]
360 * octet beacon interval[2]
361 * octet capability information[2]
362 * information element
363 * octet elemid
364 * octet length
365 * octet information[length]
366 */
367
368typedef u_int8_t *ieee80211_mgt_beacon_t;
369
370#define IEEE80211_BEACON_INTERVAL(beacon) \
371 ((beacon)[8] | ((beacon)[9] << 8))
372#define IEEE80211_BEACON_CAPABILITY(beacon) \
373 ((beacon)[10] | ((beacon)[11] << 8))
374
375#define IEEE80211_CAPINFO_ESS 0x0001
376#define IEEE80211_CAPINFO_IBSS 0x0002
377#define IEEE80211_CAPINFO_CF_POLLABLE 0x0004
378#define IEEE80211_CAPINFO_CF_POLLREQ 0x0008
379#define IEEE80211_CAPINFO_PRIVACY 0x0010
380#define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020
381#define IEEE80211_CAPINFO_PBCC 0x0040
382#define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080
383/* bits 8-9 are reserved */
384#define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400
385#define IEEE80211_CAPINFO_RSN 0x0800
386/* bit 12 is reserved */
387#define IEEE80211_CAPINFO_DSSSOFDM 0x2000
388/* bits 14-15 are reserved */
389
390/*
391 * 802.11i/WPA information element (maximally sized).
392 */
393struct ieee80211_ie_wpa
394{
395 u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */
396 u_int8_t wpa_len; /* length in bytes */
397 u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */
398 u_int8_t wpa_type; /* OUI type */
399 u_int16_t wpa_version; /* spec revision */
400 u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */
401 u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */
402 u_int32_t wpa_uciphers[8]; /* ciphers */
403 u_int16_t wpa_authselcnt; /* authentication selector cnt */
404 u_int32_t wpa_authsels[8]; /* selectors */
405 u_int16_t wpa_caps; /* 802.11i capabilities */
406 u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */
407 u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */
408} GNUNET_PACKED;
409
410/*
411 * Management information element payloads.
412 */
413
414enum
415{
416 IEEE80211_ELEMID_SSID = 0,
417 IEEE80211_ELEMID_RATES = 1,
418 IEEE80211_ELEMID_FHPARMS = 2,
419 IEEE80211_ELEMID_DSPARMS = 3,
420 IEEE80211_ELEMID_CFPARMS = 4,
421 IEEE80211_ELEMID_TIM = 5,
422 IEEE80211_ELEMID_IBSSPARMS = 6,
423 IEEE80211_ELEMID_COUNTRY = 7,
424 IEEE80211_ELEMID_CHALLENGE = 16,
425 /* 17-31 reserved for challenge text extension */
426 IEEE80211_ELEMID_ERP = 42,
427 IEEE80211_ELEMID_RSN = 48,
428 IEEE80211_ELEMID_XRATES = 50,
429 IEEE80211_ELEMID_TPC = 150,
430 IEEE80211_ELEMID_CCKM = 156,
431 IEEE80211_ELEMID_VENDOR = 221, /* vendor private */
432};
433
434struct ieee80211_tim_ie
435{
436 u_int8_t tim_ie; /* IEEE80211_ELEMID_TIM */
437 u_int8_t tim_len;
438 u_int8_t tim_count; /* DTIM count */
439 u_int8_t tim_period; /* DTIM period */
440 u_int8_t tim_bitctl; /* bitmap control */
441 u_int8_t tim_bitmap[1]; /* variable-length bitmap */
442} GNUNET_PACKED;
443
444struct ieee80211_country_ie
445{
446 u_int8_t ie; /* IEEE80211_ELEMID_COUNTRY */
447 u_int8_t len;
448 u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */
449 struct
450 {
451 u_int8_t schan; /* starting channel */
452 u_int8_t nchan; /* number channels */
453 u_int8_t maxtxpwr; /* tx power cap */
454 } GNUNET_PACKED band[4]; /* up to 4 sub bands */
455} GNUNET_PACKED;
456
457#define IEEE80211_CHALLENGE_LEN 128
458
459#define IEEE80211_RATE_BASIC 0x80
460#define IEEE80211_RATE_VAL 0x7f
461
462/* EPR information element flags */
463#define IEEE80211_ERP_NON_ERP_PRESENT 0x01
464#define IEEE80211_ERP_USE_PROTECTION 0x02
465#define IEEE80211_ERP_LONG_PREAMBLE 0x04
466
467/* Atheros private advanced capabilities info */
468#define ATHEROS_CAP_TURBO_PRIME 0x01
469#define ATHEROS_CAP_COMPRESSION 0x02
470#define ATHEROS_CAP_FAST_FRAME 0x04
471/* bits 3-6 reserved */
472#define ATHEROS_CAP_BOOST 0x80
473
474#define ATH_OUI 0x7f0300 /* Atheros OUI */
475#define ATH_OUI_TYPE 0x01
476#define ATH_OUI_VERSION 0x01
477
478#define WPA_OUI 0xf25000
479#define WPA_OUI_TYPE 0x01
480#define WPA_VERSION 1 /* current supported version */
481
482#define WPA_CSE_NULL 0x00
483#define WPA_CSE_WEP40 0x01
484#define WPA_CSE_TKIP 0x02
485#define WPA_CSE_CCMP 0x04
486#define WPA_CSE_WEP104 0x05
487
488#define WPA_ASE_NONE 0x00
489#define WPA_ASE_8021X_UNSPEC 0x01
490#define WPA_ASE_8021X_PSK 0x02
491
492#define RSN_OUI 0xac0f00
493#define RSN_VERSION 1 /* current supported version */
494
495#define RSN_CSE_NULL 0x00
496#define RSN_CSE_WEP40 0x01
497#define RSN_CSE_TKIP 0x02
498#define RSN_CSE_WRAP 0x03
499#define RSN_CSE_CCMP 0x04
500#define RSN_CSE_WEP104 0x05
501
502#define RSN_ASE_NONE 0x00
503#define RSN_ASE_8021X_UNSPEC 0x01
504#define RSN_ASE_8021X_PSK 0x02
505
506#define RSN_CAP_PREAUTH 0x01
507
508#define WME_OUI 0xf25000
509#define WME_OUI_TYPE 0x02
510#define WME_INFO_OUI_SUBTYPE 0x00
511#define WME_PARAM_OUI_SUBTYPE 0x01
512#define WME_VERSION 1
513
514/* WME stream classes */
515#define WME_AC_BE 0 /* best effort */
516#define WME_AC_BK 1 /* background */
517#define WME_AC_VI 2 /* video */
518#define WME_AC_VO 3 /* voice */
519
520/*
521 * AUTH management packets
522 *
523 * octet algo[2]
524 * octet seq[2]
525 * octet status[2]
526 * octet chal.id
527 * octet chal.length
528 * octet chal.text[253]
529 */
530
531typedef u_int8_t *ieee80211_mgt_auth_t;
532
533#define IEEE80211_AUTH_ALGORITHM(auth) \
534 ((auth)[0] | ((auth)[1] << 8))
535#define IEEE80211_AUTH_TRANSACTION(auth) \
536 ((auth)[2] | ((auth)[3] << 8))
537#define IEEE80211_AUTH_STATUS(auth) \
538 ((auth)[4] | ((auth)[5] << 8))
539
540#define IEEE80211_AUTH_ALG_OPEN 0x0000
541#define IEEE80211_AUTH_ALG_SHARED 0x0001
542#define IEEE80211_AUTH_ALG_LEAP 0x0080
543
544enum
545{
546 IEEE80211_AUTH_OPEN_REQUEST = 1,
547 IEEE80211_AUTH_OPEN_RESPONSE = 2,
548};
549
550enum
551{
552 IEEE80211_AUTH_SHARED_REQUEST = 1,
553 IEEE80211_AUTH_SHARED_CHALLENGE = 2,
554 IEEE80211_AUTH_SHARED_RESPONSE = 3,
555 IEEE80211_AUTH_SHARED_PASS = 4,
556};
557
558/*
559 * Reason codes
560 *
561 * Unlisted codes are reserved
562 */
563
564enum
565{
566 IEEE80211_REASON_UNSPECIFIED = 1,
567 IEEE80211_REASON_AUTH_EXPIRE = 2,
568 IEEE80211_REASON_AUTH_LEAVE = 3,
569 IEEE80211_REASON_ASSOC_EXPIRE = 4,
570 IEEE80211_REASON_ASSOC_TOOMANY = 5,
571 IEEE80211_REASON_NOT_AUTHED = 6,
572 IEEE80211_REASON_NOT_ASSOCED = 7,
573 IEEE80211_REASON_ASSOC_LEAVE = 8,
574 IEEE80211_REASON_ASSOC_NOT_AUTHED = 9,
575
576 IEEE80211_REASON_RSN_REQUIRED = 11,
577 IEEE80211_REASON_RSN_INCONSISTENT = 12,
578 IEEE80211_REASON_IE_INVALID = 13,
579 IEEE80211_REASON_MIC_FAILURE = 14,
580
581 IEEE80211_STATUS_SUCCESS = 0,
582 IEEE80211_STATUS_UNSPECIFIED = 1,
583 IEEE80211_STATUS_CAPINFO = 10,
584 IEEE80211_STATUS_NOT_ASSOCED = 11,
585 IEEE80211_STATUS_OTHER = 12,
586 IEEE80211_STATUS_ALG = 13,
587 IEEE80211_STATUS_SEQUENCE = 14,
588 IEEE80211_STATUS_CHALLENGE = 15,
589 IEEE80211_STATUS_TIMEOUT = 16,
590 IEEE80211_STATUS_TOOMANY = 17,
591 IEEE80211_STATUS_BASIC_RATE = 18,
592 IEEE80211_STATUS_SP_REQUIRED = 19,
593 IEEE80211_STATUS_PBCC_REQUIRED = 20,
594 IEEE80211_STATUS_CA_REQUIRED = 21,
595 IEEE80211_STATUS_TOO_MANY_STATIONS = 22,
596 IEEE80211_STATUS_RATES = 23,
597 IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25,
598 IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26,
599};
600
601#define IEEE80211_WEP_KEYLEN 5 /* 40bit */
602#define IEEE80211_WEP_IVLEN 3 /* 24bit */
603#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */
604#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */
605#define IEEE80211_WEP_NKID 4 /* number of key ids */
606
607/*
608 * 802.11i defines an extended IV for use with non-WEP ciphers.
609 * When the EXTIV bit is set in the key id byte an additional
610 * 4 bytes immediately follow the IV for TKIP. For CCMP the
611 * EXTIV bit is likewise set but the 8 bytes represent the
612 * CCMP header rather than IV+extended-IV.
613 */
614#define IEEE80211_WEP_EXTIV 0x20
615#define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */
616#define IEEE80211_WEP_MICLEN 8 /* trailing MIC */
617
618#define IEEE80211_CRC_LEN 4
619
620/*
621 * Maximum acceptable MTU is:
622 * IEEE80211_MAX_LEN - WEP overhead - CRC -
623 * QoS overhead - RSN/WPA overhead
624 * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default
625 * mtu is Ethernet-compatible; it's set by ether_ifattach.
626 */
627#define IEEE80211_MTU_MAX 2290
628#define IEEE80211_MTU_MIN 32
629
630#define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \
631 (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
632#define IEEE80211_ACK_LEN \
633 (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
634#define IEEE80211_MIN_LEN \
635 (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
636
637/*
638 * The 802.11 spec says at most 2007 stations may be
639 * associated at once. For most AP's this is way more
640 * than is feasible so we use a default of 128. This
641 * number may be overridden by the driver and/or by
642 * user configuration.
643 */
644#define IEEE80211_AID_MAX 2007
645#define IEEE80211_AID_DEF 128
646
647#define IEEE80211_AID(b) ((b) &~ 0xc000)
648
649/*
650 * RTS frame length parameters. The default is specified in
651 * the 802.11 spec as 512; we treat it as implementation-dependent
652 * so it's defined in ieee80211_var.h. The max may be wrong
653 * for jumbo frames.
654 */
655#define IEEE80211_RTS_MIN 1
656#define IEEE80211_RTS_MAX 2346
657
658/*
659 * TX fragmentation parameters. As above for RTS, we treat
660 * default as implementation-dependent so define it elsewhere.
661 */
662#define IEEE80211_FRAG_MIN 256
663#define IEEE80211_FRAG_MAX 2346
664
665/*
666 * Beacon interval (TU's). Min+max come from WiFi requirements.
667 * As above, we treat default as implementation-dependent so
668 * define it elsewhere.
669 */
670#define IEEE80211_BINTVAL_MAX 1000 /* max beacon interval (TU's) */
671#define IEEE80211_BINTVAL_MIN 25 /* min beacon interval (TU's) */
672
673/*
674 * DTIM period (beacons). Min+max are not really defined
675 * by the protocol but we want them publicly visible so
676 * define them here.
677 */
678#define IEEE80211_DTIM_MAX 15 /* max DTIM period */
679#define IEEE80211_DTIM_MIN 1 /* min DTIM period */
680
681/*
682 * Beacon miss threshold (beacons). As for DTIM, we define
683 * them here to be publicly visible. Note the max may be
684 * clamped depending on device capabilities.
685 */
686#define IEEE80211_HWBMISS_MIN 1
687#define IEEE80211_HWBMISS_MAX 255
688
689#endif /* _NET80211_IEEE80211_H_ */
diff --git a/src/transport/wlan/ieee80211_radiotap.h b/src/transport/wlan/ieee80211_radiotap.h
deleted file mode 100644
index f3afbecce..000000000
--- a/src/transport/wlan/ieee80211_radiotap.h
+++ /dev/null
@@ -1,262 +0,0 @@
1/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
2/* $NetBSD: ieee80211_radiotap.h,v 1.11 2005/06/22 06:16:02 dyoung Exp $ */
3
4/*-
5 * Copyright (c) 2003, 2004 David Young. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of David Young may not be used to endorse or promote
16 * products derived from this software without specific prior
17 * written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
23 * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
25 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30 * OF SUCH DAMAGE.
31 */
32
33/*
34 * Modifications to fit into the linux IEEE 802.11 stack,
35 * Mike Kershaw (dragorn@kismetwireless.net)
36 */
37
38#ifndef IEEE80211RADIOTAP_H
39#define IEEE80211RADIOTAP_H
40
41/* Radiotap header version (from official NetBSD feed) */
42#define IEEE80211RADIOTAP_VERSION "1.5"
43/* Base version of the radiotap packet header data */
44#define PKTHDR_RADIOTAP_VERSION 0
45
46/* A generic radio capture format is desirable. There is one for
47 * Linux, but it is neither rigidly defined (there were not even
48 * units given for some fields) nor easily extensible.
49 *
50 * I suggest the following extensible radio capture format. It is
51 * based on a bitmap indicating which fields are present.
52 *
53 * I am trying to describe precisely what the application programmer
54 * should expect in the following, and for that reason I tell the
55 * units and origin of each measurement (where it applies), or else I
56 * use sufficiently weaselly language ("is a monotonically nondecreasing
57 * function of...") that I cannot set false expectations for lawyerly
58 * readers.
59 */
60
61/* XXX tcpdump/libpcap do not tolerate variable-length headers,
62 * yet, so we pad every radiotap header to 64 bytes. Ugh.
63 */
64#define IEEE80211_RADIOTAP_HDRLEN 64
65
66/* The radio capture header precedes the 802.11 header.
67 * All data in the header is little endian on all platforms.
68 */
69struct ieee80211_radiotap_header
70{
71 u8 it_version; /* Version 0. Only increases
72 * for drastic changes,
73 * introduction of compatible
74 * new fields does not count.
75 */
76 u8 it_pad;
77 u16 it_len; /* length of the whole
78 * header in bytes, including
79 * it_version, it_pad,
80 * it_len, and data fields.
81 */
82 u32 it_present; /* A bitmap telling which
83 * fields are present. Set bit 31
84 * (0x80000000) to extend the
85 * bitmap by another 32 bits.
86 * Additional extensions are made
87 * by setting bit 31.
88 */
89};
90
91#define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK 0x80000000
92
93/* Name Data type Units
94 * ---- --------- -----
95 *
96 * IEEE80211_RADIOTAP_TSFT __le64 microseconds
97 *
98 * Value in microseconds of the MAC's 64-bit 802.11 Time
99 * Synchronization Function timer when the first bit of the
100 * MPDU arrived at the MAC. For received frames, only.
101 *
102 * IEEE80211_RADIOTAP_CHANNEL 2 x __le16 MHz, bitmap
103 *
104 * Tx/Rx frequency in MHz, followed by flags (see below).
105 *
106 * IEEE80211_RADIOTAP_FHSS __le16 see below
107 *
108 * For frequency-hopping radios, the hop set (first byte)
109 * and pattern (second byte).
110 *
111 * IEEE80211_RADIOTAP_RATE u8 500kb/s
112 *
113 * Tx/Rx data rate
114 *
115 * IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from
116 * one milliwatt (dBm)
117 *
118 * RF signal power at the antenna, decibel difference from
119 * one milliwatt.
120 *
121 * IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from
122 * one milliwatt (dBm)
123 *
124 * RF noise power at the antenna, decibel difference from one
125 * milliwatt.
126 *
127 * IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB)
128 *
129 * RF signal power at the antenna, decibel difference from an
130 * arbitrary, fixed reference.
131 *
132 * IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB)
133 *
134 * RF noise power at the antenna, decibel difference from an
135 * arbitrary, fixed reference point.
136 *
137 * IEEE80211_RADIOTAP_LOCK_QUALITY __le16 unitless
138 *
139 * Quality of Barker code lock. Unitless. Monotonically
140 * nondecreasing with "better" lock strength. Called "Signal
141 * Quality" in datasheets. (Is there a standard way to measure
142 * this?)
143 *
144 * IEEE80211_RADIOTAP_TX_ATTENUATION __le16 unitless
145 *
146 * Transmit power expressed as unitless distance from max
147 * power set at factory calibration. 0 is max power.
148 * Monotonically nondecreasing with lower power levels.
149 *
150 * IEEE80211_RADIOTAP_DB_TX_ATTENUATION __le16 decibels (dB)
151 *
152 * Transmit power expressed as decibel distance from max power
153 * set at factory calibration. 0 is max power. Monotonically
154 * nondecreasing with lower power levels.
155 *
156 * IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from
157 * one milliwatt (dBm)
158 *
159 * Transmit power expressed as dBm (decibels from a 1 milliwatt
160 * reference). This is the absolute power level measured at
161 * the antenna port.
162 *
163 * IEEE80211_RADIOTAP_FLAGS u8 bitmap
164 *
165 * Properties of transmitted and received frames. See flags
166 * defined below.
167 *
168 * IEEE80211_RADIOTAP_ANTENNA u8 antenna index
169 *
170 * Unitless indication of the Rx/Tx antenna for this packet.
171 * The first antenna is antenna 0.
172 *
173 * IEEE80211_RADIOTAP_RX_FLAGS __le16 bitmap
174 *
175 * Properties of received frames. See flags defined below.
176 *
177 * IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap
178 *
179 * Properties of transmitted frames. See flags defined below.
180 *
181 * IEEE80211_RADIOTAP_RTS_RETRIES u8 data
182 *
183 * Number of rts retries a transmitted frame used.
184 *
185 * IEEE80211_RADIOTAP_DATA_RETRIES u8 data
186 *
187 * Number of unicast retries a transmitted frame used.
188 *
189 */
190enum ieee80211_radiotap_type
191{
192 IEEE80211_RADIOTAP_TSFT = 0,
193 IEEE80211_RADIOTAP_FLAGS = 1,
194 IEEE80211_RADIOTAP_RATE = 2,
195 IEEE80211_RADIOTAP_CHANNEL = 3,
196 IEEE80211_RADIOTAP_FHSS = 4,
197 IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
198 IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
199 IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
200 IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
201 IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
202 IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
203 IEEE80211_RADIOTAP_ANTENNA = 11,
204 IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
205 IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
206 IEEE80211_RADIOTAP_RX_FLAGS = 14,
207 IEEE80211_RADIOTAP_TX_FLAGS = 15,
208 IEEE80211_RADIOTAP_RTS_RETRIES = 16,
209 IEEE80211_RADIOTAP_DATA_RETRIES = 17,
210 IEEE80211_RADIOTAP_EXT = 31
211};
212
213/* Channel flags. */
214#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
215#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
216#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
217#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
218#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
219#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
220#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
221#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
222
223/* For IEEE80211_RADIOTAP_FLAGS */
224#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
225 * during CFP
226 */
227#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
228 * with short
229 * preamble
230 */
231#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
232 * with WEP encryption
233 */
234#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
235 * with fragmentation
236 */
237#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
238#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
239 * 802.11 header and payload
240 * (to 32-bit boundary)
241 */
242/* For IEEE80211_RADIOTAP_RX_FLAGS */
243#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
244
245/* For IEEE80211_RADIOTAP_TX_FLAGS */
246#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive
247 * retries */
248#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */
249#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
250#define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* frame should not be ACKed */
251#define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 /* sequence number handled
252 * by userspace */
253
254/* Ugly macro to convert literal channel numbers into their mhz equivalents
255 * There are certianly some conditions that will break this (like feeding it '30')
256 * but they shouldn't arise since nothing talks on channel 30. */
257#define ieee80211chan2mhz(x) \
258 (((x) <= 14) ? \
259 (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \
260 ((x) + 1000) * 5)
261
262#endif /* IEEE80211_RADIOTAP_H */
diff --git a/src/transport/wlan/radiotap-parser.c b/src/transport/wlan/radiotap-parser.c
deleted file mode 100644
index 9cc992728..000000000
--- a/src/transport/wlan/radiotap-parser.c
+++ /dev/null
@@ -1,260 +0,0 @@
1 /*
2 * Copyright (c) 2007, 2008, Andy Green <andy@warmcat.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#include <sys/types.h>
20#include <stdio.h>
21#include <errno.h>
22
23#include "radiotap-parser.h"
24
25
26/*
27 * Radiotap header iteration
28 * implemented in src/radiotap-parser.c
29 *
30 * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator
31 * struct ieee80211_radiotap_iterator (no need to init the struct beforehand)
32 * then loop calling __ieee80211_radiotap_iterator_next()... it returns -1
33 * if there are no more args in the header, or the next argument type index
34 * that is present. The iterator's this_arg member points to the start of the
35 * argument associated with the current argument index that is present,
36 * which can be found in the iterator's this_arg_index member. This arg
37 * index corresponds to the IEEE80211_RADIOTAP_... defines.
38 */
39
40
41int
42ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator *iterator,
43 struct ieee80211_radiotap_header
44 *radiotap_header, int max_length)
45{
46 if (iterator == NULL)
47 return (-EINVAL);
48
49 if (radiotap_header == NULL)
50 return (-EINVAL);
51 /* Linux only supports version 0 radiotap format */
52
53 if (radiotap_header->it_version)
54 return (-EINVAL);
55
56 /* sanity check for allowed length and radiotap length field */
57
58 if (max_length < (le16_to_cpu (radiotap_header->it_len)))
59 return (-EINVAL);
60
61 iterator->rtheader = radiotap_header;
62 iterator->max_length = le16_to_cpu (radiotap_header->it_len);
63 iterator->arg_index = 0;
64 iterator->bitmap_shifter = le32_to_cpu (radiotap_header->it_present);
65 iterator->arg =
66 ((u8 *) radiotap_header) + sizeof (struct ieee80211_radiotap_header);
67 iterator->this_arg = 0;
68
69 /* find payload start allowing for extended bitmap(s) */
70
71 if (unlikely
72 (iterator->bitmap_shifter & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK))
73 {
74 while (le32_to_cpu (*((u32 *) iterator->arg)) &
75 IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)
76 {
77 iterator->arg += sizeof (u32);
78
79 /*
80 * check for insanity where the present bitmaps
81 * keep claiming to extend up to or even beyond the
82 * stated radiotap header length
83 */
84
85 if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) >
86 iterator->max_length)
87 return (-EINVAL);
88
89 }
90
91 iterator->arg += sizeof (u32);
92
93 /*
94 * no need to check again for blowing past stated radiotap
95 * header length, becuase ieee80211_radiotap_iterator_next
96 * checks it before it is dereferenced
97 */
98
99 }
100
101 /* we are all initialized happily */
102
103 return (0);
104}
105
106
107/**
108 * ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg
109 * @iterator: radiotap_iterator to move to next arg (if any)
110 *
111 * Returns: next present arg index on success or negative if no more or error
112 *
113 * This function returns the next radiotap arg index (IEEE80211_RADIOTAP_...)
114 * and sets iterator->this_arg to point to the payload for the arg. It takes
115 * care of alignment handling and extended present fields. interator->this_arg
116 * can be changed by the caller. The args pointed to are in little-endian
117 * format.
118 */
119
120int
121ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator *iterator)
122{
123
124 /*
125 * small length lookup table for all radiotap types we heard of
126 * starting from b0 in the bitmap, so we can walk the payload
127 * area of the radiotap header
128 *
129 * There is a requirement to pad args, so that args
130 * of a given length must begin at a boundary of that length
131 * -- but note that compound args are allowed (eg, 2 x u16
132 * for IEEE80211_RADIOTAP_CHANNEL) so total arg length is not
133 * a reliable indicator of alignment requirement.
134 *
135 * upper nybble: content alignment for arg
136 * lower nybble: content length for arg
137 */
138
139 static const u8 rt_sizes[] = {
140 [IEEE80211_RADIOTAP_TSFT] = 0x88,
141 [IEEE80211_RADIOTAP_FLAGS] = 0x11,
142 [IEEE80211_RADIOTAP_RATE] = 0x11,
143 [IEEE80211_RADIOTAP_CHANNEL] = 0x24,
144 [IEEE80211_RADIOTAP_FHSS] = 0x22,
145 [IEEE80211_RADIOTAP_DBM_ANTSIGNAL] = 0x11,
146 [IEEE80211_RADIOTAP_DBM_ANTNOISE] = 0x11,
147 [IEEE80211_RADIOTAP_LOCK_QUALITY] = 0x22,
148 [IEEE80211_RADIOTAP_TX_ATTENUATION] = 0x22,
149 [IEEE80211_RADIOTAP_DB_TX_ATTENUATION] = 0x22,
150 [IEEE80211_RADIOTAP_DBM_TX_POWER] = 0x11,
151 [IEEE80211_RADIOTAP_ANTENNA] = 0x11,
152 [IEEE80211_RADIOTAP_DB_ANTSIGNAL] = 0x11,
153 [IEEE80211_RADIOTAP_DB_ANTNOISE] = 0x11,
154 [IEEE80211_RADIOTAP_TX_FLAGS] = 0x22,
155 [IEEE80211_RADIOTAP_RX_FLAGS] = 0x22,
156 [IEEE80211_RADIOTAP_RTS_RETRIES] = 0x11,
157 [IEEE80211_RADIOTAP_DATA_RETRIES] = 0x11
158 /*
159 * add more here as they are defined in
160 * include/net/ieee80211_radiotap.h
161 */
162 };
163
164 /*
165 * for every radiotap entry we can at
166 * least skip (by knowing the length)...
167 */
168
169 while (iterator->arg_index < (int) sizeof (rt_sizes))
170 {
171 int hit = 0;
172
173 if (!(iterator->bitmap_shifter & 1))
174 goto next_entry; /* arg not present */
175
176 /*
177 * arg is present, account for alignment padding
178 * 8-bit args can be at any alignment
179 * 16-bit args must start on 16-bit boundary
180 * 32-bit args must start on 32-bit boundary
181 * 64-bit args must start on 64-bit boundary
182 *
183 * note that total arg size can differ from alignment of
184 * elements inside arg, so we use upper nybble of length
185 * table to base alignment on
186 *
187 * also note: these alignments are ** relative to the
188 * start of the radiotap header **. There is no guarantee
189 * that the radiotap header itself is aligned on any
190 * kind of boundary.
191 */
192
193 if ((((void *) iterator->arg) -
194 ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >> 4)
195 - 1))
196 iterator->arg_index +=
197 (rt_sizes[iterator->arg_index] >> 4) -
198 ((((void *) iterator->arg) -
199 ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >>
200 4) - 1));
201
202 /*
203 * this is what we will return to user, but we need to
204 * move on first so next call has something fresh to test
205 */
206
207 iterator->this_arg_index = iterator->arg_index;
208 iterator->this_arg = iterator->arg;
209 hit = 1;
210
211 /* internally move on the size of this arg */
212
213 iterator->arg += rt_sizes[iterator->arg_index] & 0x0f;
214
215 /*
216 * check for insanity where we are given a bitmap that
217 * claims to have more arg content than the length of the
218 * radiotap section. We will normally end up equalling this
219 * max_length on the last arg, never exceeding it.
220 */
221
222 if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) >
223 iterator->max_length)
224 return (-EINVAL);
225
226next_entry:
227
228 iterator->arg_index++;
229 if (unlikely ((iterator->arg_index & 31) == 0))
230 {
231 /* completed current u32 bitmap */
232 if (iterator->bitmap_shifter & 1)
233 {
234 /* b31 was set, there is more */
235 /* move to next u32 bitmap */
236 iterator->bitmap_shifter = le32_to_cpu (*iterator->next_bitmap);
237 iterator->next_bitmap++;
238 }
239 else
240 {
241 /* no more bitmaps: end */
242 iterator->arg_index = sizeof (rt_sizes);
243 }
244 }
245 else
246 { /* just try the next bit */
247 iterator->bitmap_shifter >>= 1;
248 }
249
250 /* if we found a valid arg earlier, return it now */
251
252 if (hit)
253 return (iterator->this_arg_index);
254
255 }
256
257 /* we don't know how to handle any more args, we're done */
258
259 return (-1);
260}
diff --git a/src/transport/wlan/radiotap-parser.h b/src/transport/wlan/radiotap-parser.h
deleted file mode 100644
index 6c88175ec..000000000
--- a/src/transport/wlan/radiotap-parser.h
+++ /dev/null
@@ -1,79 +0,0 @@
1/*
2 * Copyright (c) 2007, 2008, Andy Green <andy@warmcat.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18
19#define __user
20#include "byteorder.h"
21#include <stdint.h>
22
23typedef uint64_t u64;
24typedef uint32_t u32;
25typedef uint16_t u16;
26typedef uint8_t u8;
27
28#ifndef unlikely
29#define unlikely(x) (x)
30#endif
31
32#include "ieee80211_radiotap.h"
33
34
35/*
36 * Radiotap header iteration
37 * implemented in src/radiotap-parser.c
38 *
39 * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator
40 * struct ieee80211_radiotap_iterator (no need to init the struct beforehand)
41 * then loop calling __ieee80211_radiotap_iterator_next()... it returns -1
42 * if there are no more args in the header, or the next argument type index
43 * that is present. The iterator's this_arg member points to the start of the
44 * argument associated with the current argument index that is present,
45 * which can be found in the iterator's this_arg_index member. This arg
46 * index corresponds to the IEEE80211_RADIOTAP_... defines.
47 */
48/**
49 * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
50 * @rtheader: pointer to the radiotap header we are walking through
51 * @max_length: length of radiotap header in cpu byte ordering
52 * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg
53 * @this_arg: pointer to current radiotap arg
54 * @arg_index: internal next argument index
55 * @arg: internal next argument pointer
56 * @next_bitmap: internal pointer to next present u32
57 * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
58 */
59
60struct ieee80211_radiotap_iterator
61{
62 struct ieee80211_radiotap_header *rtheader;
63 int max_length;
64 int this_arg_index;
65 u8 *this_arg;
66
67 int arg_index;
68 u8 *arg;
69 u32 *next_bitmap;
70 u32 bitmap_shifter;
71};
72
73int
74ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator *iterator,
75 struct ieee80211_radiotap_header
76 *radiotap_header, int max_length);
77
78int
79ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator *iterator);