blob: 333d3ae768834c5e6684f63b3f4a34b5c7ba93af [file] [log] [blame]
Jiri Benca9de8ce2007-05-05 11:43:04 -07001/*
2 * IEEE 802.11 defines
3 *
4 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
5 * <jkmaline@cc.hut.fi>
6 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
7 * Copyright (c) 2005, Devicescape Software, Inc.
8 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#ifndef IEEE80211_H
16#define IEEE80211_H
17
18#include <linux/types.h>
Johannes Bergf97df022007-09-18 17:29:20 -040019#include <asm/byteorder.h>
Jiri Benca9de8ce2007-05-05 11:43:04 -070020
21#define FCS_LEN 4
22
23#define IEEE80211_FCTL_VERS 0x0003
24#define IEEE80211_FCTL_FTYPE 0x000c
25#define IEEE80211_FCTL_STYPE 0x00f0
26#define IEEE80211_FCTL_TODS 0x0100
27#define IEEE80211_FCTL_FROMDS 0x0200
28#define IEEE80211_FCTL_MOREFRAGS 0x0400
29#define IEEE80211_FCTL_RETRY 0x0800
30#define IEEE80211_FCTL_PM 0x1000
31#define IEEE80211_FCTL_MOREDATA 0x2000
32#define IEEE80211_FCTL_PROTECTED 0x4000
33#define IEEE80211_FCTL_ORDER 0x8000
34
35#define IEEE80211_SCTL_FRAG 0x000F
36#define IEEE80211_SCTL_SEQ 0xFFF0
37
38#define IEEE80211_FTYPE_MGMT 0x0000
39#define IEEE80211_FTYPE_CTL 0x0004
40#define IEEE80211_FTYPE_DATA 0x0008
41
42/* management */
43#define IEEE80211_STYPE_ASSOC_REQ 0x0000
44#define IEEE80211_STYPE_ASSOC_RESP 0x0010
45#define IEEE80211_STYPE_REASSOC_REQ 0x0020
46#define IEEE80211_STYPE_REASSOC_RESP 0x0030
47#define IEEE80211_STYPE_PROBE_REQ 0x0040
48#define IEEE80211_STYPE_PROBE_RESP 0x0050
49#define IEEE80211_STYPE_BEACON 0x0080
50#define IEEE80211_STYPE_ATIM 0x0090
51#define IEEE80211_STYPE_DISASSOC 0x00A0
52#define IEEE80211_STYPE_AUTH 0x00B0
53#define IEEE80211_STYPE_DEAUTH 0x00C0
54#define IEEE80211_STYPE_ACTION 0x00D0
55
56/* control */
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +020057#define IEEE80211_STYPE_BACK_REQ 0x0080
58#define IEEE80211_STYPE_BACK 0x0090
Jiri Benca9de8ce2007-05-05 11:43:04 -070059#define IEEE80211_STYPE_PSPOLL 0x00A0
60#define IEEE80211_STYPE_RTS 0x00B0
61#define IEEE80211_STYPE_CTS 0x00C0
62#define IEEE80211_STYPE_ACK 0x00D0
63#define IEEE80211_STYPE_CFEND 0x00E0
64#define IEEE80211_STYPE_CFENDACK 0x00F0
65
66/* data */
67#define IEEE80211_STYPE_DATA 0x0000
68#define IEEE80211_STYPE_DATA_CFACK 0x0010
69#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
70#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
71#define IEEE80211_STYPE_NULLFUNC 0x0040
72#define IEEE80211_STYPE_CFACK 0x0050
73#define IEEE80211_STYPE_CFPOLL 0x0060
74#define IEEE80211_STYPE_CFACKPOLL 0x0070
75#define IEEE80211_STYPE_QOS_DATA 0x0080
76#define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
77#define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
78#define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
79#define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
80#define IEEE80211_STYPE_QOS_CFACK 0x00D0
81#define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
82#define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
83
84
85/* miscellaneous IEEE 802.11 constants */
Michael Wuc2378992007-10-30 16:50:05 -040086#define IEEE80211_MAX_FRAG_THRESHOLD 2352
87#define IEEE80211_MAX_RTS_THRESHOLD 2353
Jiri Benca9de8ce2007-05-05 11:43:04 -070088#define IEEE80211_MAX_AID 2007
89#define IEEE80211_MAX_TIM_LEN 251
Jiri Benca9de8ce2007-05-05 11:43:04 -070090/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
91 6.2.1.1.2.
92
Michael Wuc2378992007-10-30 16:50:05 -040093 802.11e clarifies the figure in section 7.1.2. The frame body is
94 up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
95#define IEEE80211_MAX_DATA_LEN 2304
96/* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
97#define IEEE80211_MAX_FRAME_LEN 2352
Jiri Benca9de8ce2007-05-05 11:43:04 -070098
99#define IEEE80211_MAX_SSID_LEN 32
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100100#define IEEE80211_MAX_MESH_ID_LEN 32
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -0700101#define IEEE80211_QOS_CTL_LEN 2
Harvey Harrison238f74a2008-07-02 11:05:34 -0700102#define IEEE80211_QOS_CTL_TID_MASK 0x000F
103#define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
Jiri Benca9de8ce2007-05-05 11:43:04 -0700104
105struct ieee80211_hdr {
106 __le16 frame_control;
107 __le16 duration_id;
108 u8 addr1[6];
109 u8 addr2[6];
110 u8 addr3[6];
111 __le16 seq_ctrl;
112 u8 addr4[6];
113} __attribute__ ((packed));
114
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -0700115/**
116 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
117 * @fc: frame control bytes in little-endian byteorder
118 */
119static inline int ieee80211_has_tods(__le16 fc)
120{
121 return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
122}
123
124/**
125 * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
126 * @fc: frame control bytes in little-endian byteorder
127 */
128static inline int ieee80211_has_fromds(__le16 fc)
129{
130 return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
131}
132
133/**
134 * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
135 * @fc: frame control bytes in little-endian byteorder
136 */
137static inline int ieee80211_has_a4(__le16 fc)
138{
139 __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
140 return (fc & tmp) == tmp;
141}
142
143/**
144 * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
145 * @fc: frame control bytes in little-endian byteorder
146 */
147static inline int ieee80211_has_morefrags(__le16 fc)
148{
149 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
150}
151
152/**
153 * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
154 * @fc: frame control bytes in little-endian byteorder
155 */
156static inline int ieee80211_has_retry(__le16 fc)
157{
158 return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
159}
160
161/**
162 * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
163 * @fc: frame control bytes in little-endian byteorder
164 */
165static inline int ieee80211_has_pm(__le16 fc)
166{
167 return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
168}
169
170/**
171 * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
172 * @fc: frame control bytes in little-endian byteorder
173 */
174static inline int ieee80211_has_moredata(__le16 fc)
175{
176 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
177}
178
179/**
180 * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
181 * @fc: frame control bytes in little-endian byteorder
182 */
183static inline int ieee80211_has_protected(__le16 fc)
184{
185 return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
186}
187
188/**
189 * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
190 * @fc: frame control bytes in little-endian byteorder
191 */
192static inline int ieee80211_has_order(__le16 fc)
193{
194 return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
195}
196
197/**
198 * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
199 * @fc: frame control bytes in little-endian byteorder
200 */
201static inline int ieee80211_is_mgmt(__le16 fc)
202{
203 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
204 cpu_to_le16(IEEE80211_FTYPE_MGMT);
205}
206
207/**
208 * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
209 * @fc: frame control bytes in little-endian byteorder
210 */
211static inline int ieee80211_is_ctl(__le16 fc)
212{
213 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
214 cpu_to_le16(IEEE80211_FTYPE_CTL);
215}
216
217/**
218 * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
219 * @fc: frame control bytes in little-endian byteorder
220 */
221static inline int ieee80211_is_data(__le16 fc)
222{
223 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
224 cpu_to_le16(IEEE80211_FTYPE_DATA);
225}
226
227/**
228 * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
229 * @fc: frame control bytes in little-endian byteorder
230 */
231static inline int ieee80211_is_data_qos(__le16 fc)
232{
233 /*
234 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
235 * to check the one bit
236 */
237 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
238 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
239}
240
241/**
242 * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
243 * @fc: frame control bytes in little-endian byteorder
244 */
245static inline int ieee80211_is_data_present(__le16 fc)
246{
247 /*
248 * mask with 0x40 and test that that bit is clear to only return true
249 * for the data-containing substypes.
250 */
251 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
252 cpu_to_le16(IEEE80211_FTYPE_DATA);
253}
254
255/**
256 * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
257 * @fc: frame control bytes in little-endian byteorder
258 */
259static inline int ieee80211_is_assoc_req(__le16 fc)
260{
261 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
262 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
263}
264
265/**
266 * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
267 * @fc: frame control bytes in little-endian byteorder
268 */
269static inline int ieee80211_is_assoc_resp(__le16 fc)
270{
271 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
272 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
273}
274
275/**
276 * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
277 * @fc: frame control bytes in little-endian byteorder
278 */
279static inline int ieee80211_is_reassoc_req(__le16 fc)
280{
281 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
282 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
283}
284
285/**
286 * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
287 * @fc: frame control bytes in little-endian byteorder
288 */
289static inline int ieee80211_is_reassoc_resp(__le16 fc)
290{
291 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
292 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
293}
294
295/**
296 * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
297 * @fc: frame control bytes in little-endian byteorder
298 */
299static inline int ieee80211_is_probe_req(__le16 fc)
300{
301 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
302 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
303}
304
305/**
306 * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
307 * @fc: frame control bytes in little-endian byteorder
308 */
309static inline int ieee80211_is_probe_resp(__le16 fc)
310{
311 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
312 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
313}
314
315/**
316 * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
317 * @fc: frame control bytes in little-endian byteorder
318 */
319static inline int ieee80211_is_beacon(__le16 fc)
320{
321 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
322 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
323}
324
325/**
326 * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
327 * @fc: frame control bytes in little-endian byteorder
328 */
329static inline int ieee80211_is_atim(__le16 fc)
330{
331 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
332 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
333}
334
335/**
336 * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
337 * @fc: frame control bytes in little-endian byteorder
338 */
339static inline int ieee80211_is_disassoc(__le16 fc)
340{
341 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
342 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
343}
344
345/**
346 * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
347 * @fc: frame control bytes in little-endian byteorder
348 */
349static inline int ieee80211_is_auth(__le16 fc)
350{
351 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
352 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
353}
354
355/**
356 * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
357 * @fc: frame control bytes in little-endian byteorder
358 */
359static inline int ieee80211_is_deauth(__le16 fc)
360{
361 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
362 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
363}
364
365/**
366 * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
367 * @fc: frame control bytes in little-endian byteorder
368 */
369static inline int ieee80211_is_action(__le16 fc)
370{
371 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
372 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
373}
374
375/**
376 * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
377 * @fc: frame control bytes in little-endian byteorder
378 */
379static inline int ieee80211_is_back_req(__le16 fc)
380{
381 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
382 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
383}
384
385/**
386 * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
387 * @fc: frame control bytes in little-endian byteorder
388 */
389static inline int ieee80211_is_back(__le16 fc)
390{
391 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
392 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
393}
394
395/**
396 * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
397 * @fc: frame control bytes in little-endian byteorder
398 */
399static inline int ieee80211_is_pspoll(__le16 fc)
400{
401 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
402 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
403}
404
405/**
406 * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
407 * @fc: frame control bytes in little-endian byteorder
408 */
409static inline int ieee80211_is_rts(__le16 fc)
410{
411 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
412 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
413}
414
415/**
416 * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
417 * @fc: frame control bytes in little-endian byteorder
418 */
419static inline int ieee80211_is_cts(__le16 fc)
420{
421 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
422 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
423}
424
425/**
426 * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
427 * @fc: frame control bytes in little-endian byteorder
428 */
429static inline int ieee80211_is_ack(__le16 fc)
430{
431 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
432 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
433}
434
435/**
436 * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
437 * @fc: frame control bytes in little-endian byteorder
438 */
439static inline int ieee80211_is_cfend(__le16 fc)
440{
441 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
442 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
443}
444
445/**
446 * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
447 * @fc: frame control bytes in little-endian byteorder
448 */
449static inline int ieee80211_is_cfendack(__le16 fc)
450{
451 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
452 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
453}
454
455/**
456 * ieee80211_is_nullfunc - check if FTYPE=IEEE80211_FTYPE_DATA and STYPE=IEEE80211_STYPE_NULLFUNC
457 * @fc: frame control bytes in little-endian byteorder
458 */
459static inline int ieee80211_is_nullfunc(__le16 fc)
460{
461 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
462 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
463}
Jiri Benca9de8ce2007-05-05 11:43:04 -0700464
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100465struct ieee80211s_hdr {
466 u8 flags;
467 u8 ttl;
Luis Carlos Cobo51cedda2008-04-23 12:15:29 -0700468 __le32 seqnum;
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100469 u8 eaddr1[6];
470 u8 eaddr2[6];
471 u8 eaddr3[6];
472} __attribute__ ((packed));
473
Assaf Kraussf2df3852008-06-15 18:23:29 +0300474/**
475 * struct ieee80211_quiet_ie
476 *
477 * This structure refers to "Quiet information element"
478 */
479struct ieee80211_quiet_ie {
480 u8 count;
481 u8 period;
482 __le16 duration;
483 __le16 offset;
484} __attribute__ ((packed));
485
486/**
487 * struct ieee80211_msrment_ie
488 *
489 * This structure refers to "Measurement Request/Report information element"
490 */
491struct ieee80211_msrment_ie {
492 u8 token;
493 u8 mode;
494 u8 type;
495 u8 request[0];
496} __attribute__ ((packed));
497
498/**
499 * struct ieee80211_channel_sw_ie
500 *
501 * This structure refers to "Channel Switch Announcement information element"
502 */
503struct ieee80211_channel_sw_ie {
504 u8 mode;
505 u8 new_ch_num;
506 u8 count;
507} __attribute__ ((packed));
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100508
Emmanuel Grumbach98f7dfd2008-07-18 13:52:59 +0800509/**
510 * struct ieee80211_tim
511 *
512 * This structure refers to "Traffic Indication Map information element"
513 */
514struct ieee80211_tim_ie {
515 u8 dtim_count;
516 u8 dtim_period;
517 u8 bitmap_ctrl;
518 /* variable size: 1 - 251 bytes */
519 u8 virtual_map[0];
520} __attribute__ ((packed));
521
Jiri Benca9de8ce2007-05-05 11:43:04 -0700522struct ieee80211_mgmt {
523 __le16 frame_control;
524 __le16 duration;
525 u8 da[6];
526 u8 sa[6];
527 u8 bssid[6];
528 __le16 seq_ctrl;
529 union {
530 struct {
531 __le16 auth_alg;
532 __le16 auth_transaction;
533 __le16 status_code;
534 /* possibly followed by Challenge text */
535 u8 variable[0];
536 } __attribute__ ((packed)) auth;
537 struct {
538 __le16 reason_code;
539 } __attribute__ ((packed)) deauth;
540 struct {
541 __le16 capab_info;
542 __le16 listen_interval;
543 /* followed by SSID and Supported rates */
544 u8 variable[0];
545 } __attribute__ ((packed)) assoc_req;
546 struct {
547 __le16 capab_info;
548 __le16 status_code;
549 __le16 aid;
550 /* followed by Supported rates */
551 u8 variable[0];
552 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
553 struct {
554 __le16 capab_info;
555 __le16 listen_interval;
556 u8 current_ap[6];
557 /* followed by SSID and Supported rates */
558 u8 variable[0];
559 } __attribute__ ((packed)) reassoc_req;
560 struct {
561 __le16 reason_code;
562 } __attribute__ ((packed)) disassoc;
563 struct {
564 __le64 timestamp;
565 __le16 beacon_int;
566 __le16 capab_info;
567 /* followed by some of SSID, Supported rates,
568 * FH Params, DS Params, CF Params, IBSS Params, TIM */
569 u8 variable[0];
570 } __attribute__ ((packed)) beacon;
571 struct {
572 /* only variable items: SSID, Supported rates */
573 u8 variable[0];
574 } __attribute__ ((packed)) probe_req;
575 struct {
576 __le64 timestamp;
577 __le16 beacon_int;
578 __le16 capab_info;
579 /* followed by some of SSID, Supported rates,
580 * FH Params, DS Params, CF Params, IBSS Params */
581 u8 variable[0];
582 } __attribute__ ((packed)) probe_resp;
583 struct {
584 u8 category;
585 union {
586 struct {
587 u8 action_code;
588 u8 dialog_token;
589 u8 status_code;
590 u8 variable[0];
591 } __attribute__ ((packed)) wme_action;
592 struct{
593 u8 action_code;
594 u8 element_id;
595 u8 length;
Assaf Kraussf2df3852008-06-15 18:23:29 +0300596 struct ieee80211_channel_sw_ie sw_elem;
Jiri Benca9de8ce2007-05-05 11:43:04 -0700597 } __attribute__((packed)) chan_switch;
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200598 struct{
599 u8 action_code;
600 u8 dialog_token;
Assaf Kraussf2df3852008-06-15 18:23:29 +0300601 u8 element_id;
602 u8 length;
603 struct ieee80211_msrment_ie msr_elem;
604 } __attribute__((packed)) measurement;
605 struct{
606 u8 action_code;
607 u8 dialog_token;
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200608 __le16 capab;
609 __le16 timeout;
610 __le16 start_seq_num;
611 } __attribute__((packed)) addba_req;
612 struct{
613 u8 action_code;
614 u8 dialog_token;
615 __le16 status;
616 __le16 capab;
617 __le16 timeout;
618 } __attribute__((packed)) addba_resp;
619 struct{
620 u8 action_code;
621 __le16 params;
622 __le16 reason_code;
623 } __attribute__((packed)) delba;
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100624 struct{
625 u8 action_code;
626 /* capab_info for open and confirm,
627 * reason for close
628 */
629 __le16 aux;
630 /* Followed in plink_confirm by status
631 * code, AID and supported rates,
632 * and directly by supported rates in
633 * plink_open and plink_close
634 */
635 u8 variable[0];
636 } __attribute__((packed)) plink_action;
637 struct{
638 u8 action_code;
639 u8 variable[0];
640 } __attribute__((packed)) mesh_action;
Jiri Benca9de8ce2007-05-05 11:43:04 -0700641 } u;
642 } __attribute__ ((packed)) action;
643 } u;
644} __attribute__ ((packed));
645
646
647/* Control frames */
648struct ieee80211_rts {
649 __le16 frame_control;
650 __le16 duration;
651 u8 ra[6];
652 u8 ta[6];
653} __attribute__ ((packed));
654
655struct ieee80211_cts {
656 __le16 frame_control;
657 __le16 duration;
658 u8 ra[6];
659} __attribute__ ((packed));
660
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200661/**
662 * struct ieee80211_bar - HT Block Ack Request
663 *
664 * This structure refers to "HT BlockAckReq" as
665 * described in 802.11n draft section 7.2.1.7.1
666 */
667struct ieee80211_bar {
668 __le16 frame_control;
669 __le16 duration;
670 __u8 ra[6];
671 __u8 ta[6];
Ron Rindjunskya8b47ea2008-01-21 12:39:11 +0200672 __le16 control;
673 __le16 start_seq_num;
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200674} __attribute__((packed));
675
Ron Rindjunsky429a3802008-07-01 14:16:03 +0300676/* 802.11 BAR control masks */
677#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
678#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
679
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200680/**
681 * struct ieee80211_ht_cap - HT capabilities
682 *
683 * This structure refers to "HT capabilities element" as
684 * described in 802.11n draft section 7.3.2.52
685 */
686struct ieee80211_ht_cap {
687 __le16 cap_info;
688 u8 ampdu_params_info;
689 u8 supp_mcs_set[16];
690 __le16 extended_ht_cap_info;
691 __le32 tx_BF_cap_info;
692 u8 antenna_selection_info;
693} __attribute__ ((packed));
694
695/**
696 * struct ieee80211_ht_cap - HT additional information
697 *
698 * This structure refers to "HT information element" as
699 * described in 802.11n draft section 7.3.2.53
700 */
701struct ieee80211_ht_addt_info {
702 u8 control_chan;
703 u8 ht_param;
704 __le16 operation_mode;
705 __le16 stbc_param;
706 u8 basic_set[16];
707} __attribute__ ((packed));
708
709/* 802.11n HT capabilities masks */
710#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
Tomas Winkler00c5ae22008-09-03 11:26:42 +0800711#define IEEE80211_HT_CAP_SM_PS 0x000C
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200712#define IEEE80211_HT_CAP_GRN_FLD 0x0010
713#define IEEE80211_HT_CAP_SGI_20 0x0020
714#define IEEE80211_HT_CAP_SGI_40 0x0040
715#define IEEE80211_HT_CAP_DELAY_BA 0x0400
716#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
Sujith18d7c652008-08-14 13:27:41 +0530717#define IEEE80211_HT_CAP_DSSSCCK40 0x1000
Ron Rindjunskyedcdf8b2008-05-15 13:53:55 +0800718/* 802.11n HT capability AMPDU settings */
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200719#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
720#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
Ron Rindjunskyedcdf8b2008-05-15 13:53:55 +0800721/* 802.11n HT capability MSC set */
722#define IEEE80211_SUPP_MCS_SET_UEQM 4
723#define IEEE80211_HT_CAP_MAX_STREAMS 4
724#define IEEE80211_SUPP_MCS_SET_LEN 10
725/* maximum streams the spec allows */
726#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01
727#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02
728#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C
729#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200730/* 802.11n HT IE masks */
731#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
Emmanuel Grumbach963f5512008-06-12 09:47:00 +0800732#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00
Emmanuel Grumbach93061022008-05-29 16:35:23 +0800733#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01
734#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200735#define IEEE80211_HT_IE_CHA_WIDTH 0x04
736#define IEEE80211_HT_IE_HT_PROTECTION 0x0003
737#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
738#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
Jiri Benca9de8ce2007-05-05 11:43:04 -0700739
Tomas Winkler00c5ae22008-09-03 11:26:42 +0800740/* Spatial Multiplexing Power Save Modes */
741#define WLAN_HT_CAP_SM_PS_STATIC 0
742#define WLAN_HT_CAP_SM_PS_DYNAMIC 1
743#define WLAN_HT_CAP_SM_PS_INVALID 2
744#define WLAN_HT_CAP_SM_PS_DISABLED 3
Tomas Winklere53cfe02008-01-30 22:05:13 -0800745
Jiri Benca9de8ce2007-05-05 11:43:04 -0700746/* Authentication algorithms */
747#define WLAN_AUTH_OPEN 0
748#define WLAN_AUTH_SHARED_KEY 1
749#define WLAN_AUTH_FAST_BSS_TRANSITION 2
750#define WLAN_AUTH_LEAP 128
751
752#define WLAN_AUTH_CHALLENGE_LEN 128
753
754#define WLAN_CAPABILITY_ESS (1<<0)
755#define WLAN_CAPABILITY_IBSS (1<<1)
756#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
757#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
758#define WLAN_CAPABILITY_PRIVACY (1<<4)
759#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
760#define WLAN_CAPABILITY_PBCC (1<<6)
761#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
Assaf Kraussb6623482008-06-16 16:09:49 +0300762
Jiri Benca9de8ce2007-05-05 11:43:04 -0700763/* 802.11h */
764#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
765#define WLAN_CAPABILITY_QOS (1<<9)
766#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
767#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
Assaf Kraussb6623482008-06-16 16:09:49 +0300768/* measurement */
769#define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
770#define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
771#define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
772
773#define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
774#define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
775#define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
776
Jiri Benca9de8ce2007-05-05 11:43:04 -0700777
Daniel Drake56282212007-07-10 19:32:10 +0200778/* 802.11g ERP information element */
779#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
780#define WLAN_ERP_USE_PROTECTION (1<<1)
781#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
782
783/* WLAN_ERP_BARKER_PREAMBLE values */
784enum {
785 WLAN_ERP_PREAMBLE_SHORT = 0,
786 WLAN_ERP_PREAMBLE_LONG = 1,
787};
788
Jiri Benca9de8ce2007-05-05 11:43:04 -0700789/* Status codes */
790enum ieee80211_statuscode {
791 WLAN_STATUS_SUCCESS = 0,
792 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
793 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
794 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
795 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
796 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
797 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
798 WLAN_STATUS_CHALLENGE_FAIL = 15,
799 WLAN_STATUS_AUTH_TIMEOUT = 16,
800 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
801 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
802 /* 802.11b */
803 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
804 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
805 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
806 /* 802.11h */
807 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
808 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
809 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
810 /* 802.11g */
811 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
812 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
813 /* 802.11i */
814 WLAN_STATUS_INVALID_IE = 40,
815 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
816 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
817 WLAN_STATUS_INVALID_AKMP = 43,
818 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
819 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
820 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200821 /* 802.11e */
822 WLAN_STATUS_UNSPECIFIED_QOS = 32,
823 WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
824 WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
825 WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
826 WLAN_STATUS_REQUEST_DECLINED = 37,
827 WLAN_STATUS_INVALID_QOS_PARAM = 38,
828 WLAN_STATUS_CHANGE_TSPEC = 39,
829 WLAN_STATUS_WAIT_TS_DELAY = 47,
830 WLAN_STATUS_NO_DIRECT_LINK = 48,
831 WLAN_STATUS_STA_NOT_PRESENT = 49,
832 WLAN_STATUS_STA_NOT_QSTA = 50,
Jiri Benca9de8ce2007-05-05 11:43:04 -0700833};
834
835
836/* Reason codes */
837enum ieee80211_reasoncode {
838 WLAN_REASON_UNSPECIFIED = 1,
839 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
840 WLAN_REASON_DEAUTH_LEAVING = 3,
841 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
842 WLAN_REASON_DISASSOC_AP_BUSY = 5,
843 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
844 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
845 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
846 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
847 /* 802.11h */
848 WLAN_REASON_DISASSOC_BAD_POWER = 10,
849 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
850 /* 802.11i */
851 WLAN_REASON_INVALID_IE = 13,
852 WLAN_REASON_MIC_FAILURE = 14,
853 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
854 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
855 WLAN_REASON_IE_DIFFERENT = 17,
856 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
857 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
858 WLAN_REASON_INVALID_AKMP = 20,
859 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
860 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
861 WLAN_REASON_IEEE8021X_FAILED = 23,
862 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200863 /* 802.11e */
864 WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
865 WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
866 WLAN_REASON_DISASSOC_LOW_ACK = 34,
867 WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
868 WLAN_REASON_QSTA_LEAVE_QBSS = 36,
869 WLAN_REASON_QSTA_NOT_USE = 37,
870 WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
871 WLAN_REASON_QSTA_TIMEOUT = 39,
872 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
Jiri Benca9de8ce2007-05-05 11:43:04 -0700873};
874
875
876/* Information Element IDs */
877enum ieee80211_eid {
878 WLAN_EID_SSID = 0,
879 WLAN_EID_SUPP_RATES = 1,
880 WLAN_EID_FH_PARAMS = 2,
881 WLAN_EID_DS_PARAMS = 3,
882 WLAN_EID_CF_PARAMS = 4,
883 WLAN_EID_TIM = 5,
884 WLAN_EID_IBSS_PARAMS = 6,
885 WLAN_EID_CHALLENGE = 16,
886 /* 802.11d */
887 WLAN_EID_COUNTRY = 7,
888 WLAN_EID_HP_PARAMS = 8,
889 WLAN_EID_HP_TABLE = 9,
890 WLAN_EID_REQUEST = 10,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200891 /* 802.11e */
892 WLAN_EID_QBSS_LOAD = 11,
893 WLAN_EID_EDCA_PARAM_SET = 12,
894 WLAN_EID_TSPEC = 13,
895 WLAN_EID_TCLAS = 14,
896 WLAN_EID_SCHEDULE = 15,
897 WLAN_EID_TS_DELAY = 43,
898 WLAN_EID_TCLAS_PROCESSING = 44,
899 WLAN_EID_QOS_CAPA = 46,
Luis Carlos Cobod619ee02008-04-23 12:34:59 -0700900 /* 802.11s
901 *
902 * All mesh EID numbers are pending IEEE 802.11 ANA approval.
903 * The numbers have been incremented from those suggested in
904 * 802.11s/D2.0 so that MESH_CONFIG does not conflict with
905 * EXT_SUPP_RATES.
906 */
907 WLAN_EID_MESH_CONFIG = 51,
908 WLAN_EID_MESH_ID = 52,
909 WLAN_EID_PEER_LINK = 55,
910 WLAN_EID_PREQ = 68,
911 WLAN_EID_PREP = 69,
912 WLAN_EID_PERR = 70,
Jiri Benca9de8ce2007-05-05 11:43:04 -0700913 /* 802.11h */
914 WLAN_EID_PWR_CONSTRAINT = 32,
915 WLAN_EID_PWR_CAPABILITY = 33,
916 WLAN_EID_TPC_REQUEST = 34,
917 WLAN_EID_TPC_REPORT = 35,
918 WLAN_EID_SUPPORTED_CHANNELS = 36,
919 WLAN_EID_CHANNEL_SWITCH = 37,
920 WLAN_EID_MEASURE_REQUEST = 38,
921 WLAN_EID_MEASURE_REPORT = 39,
922 WLAN_EID_QUIET = 40,
923 WLAN_EID_IBSS_DFS = 41,
924 /* 802.11g */
925 WLAN_EID_ERP_INFO = 42,
926 WLAN_EID_EXT_SUPP_RATES = 50,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200927 /* 802.11n */
928 WLAN_EID_HT_CAPABILITY = 45,
929 WLAN_EID_HT_EXTRA_INFO = 61,
Jiri Benca9de8ce2007-05-05 11:43:04 -0700930 /* 802.11i */
931 WLAN_EID_RSN = 48,
932 WLAN_EID_WPA = 221,
933 WLAN_EID_GENERIC = 221,
934 WLAN_EID_VENDOR_SPECIFIC = 221,
935 WLAN_EID_QOS_PARAMETER = 222
936};
937
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200938/* Action category code */
939enum ieee80211_category {
940 WLAN_CATEGORY_SPECTRUM_MGMT = 0,
941 WLAN_CATEGORY_QOS = 1,
942 WLAN_CATEGORY_DLS = 2,
943 WLAN_CATEGORY_BACK = 3,
944 WLAN_CATEGORY_WMM = 17,
945};
946
Assaf Kraussf2df3852008-06-15 18:23:29 +0300947/* SPECTRUM_MGMT action code */
948enum ieee80211_spectrum_mgmt_actioncode {
949 WLAN_ACTION_SPCT_MSR_REQ = 0,
950 WLAN_ACTION_SPCT_MSR_RPRT = 1,
951 WLAN_ACTION_SPCT_TPC_REQ = 2,
952 WLAN_ACTION_SPCT_TPC_RPRT = 3,
953 WLAN_ACTION_SPCT_CHL_SWITCH = 4,
954};
955
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200956/* BACK action code */
957enum ieee80211_back_actioncode {
958 WLAN_ACTION_ADDBA_REQ = 0,
959 WLAN_ACTION_ADDBA_RESP = 1,
960 WLAN_ACTION_DELBA = 2,
961};
962
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200963/* BACK (block-ack) parties */
964enum ieee80211_back_parties {
965 WLAN_BACK_RECIPIENT = 0,
966 WLAN_BACK_INITIATOR = 1,
967 WLAN_BACK_TIMER = 2,
968};
969
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200970/* A-MSDU 802.11n */
971#define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
972
Jiri Benca9de8ce2007-05-05 11:43:04 -0700973/* cipher suite selectors */
974#define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
975#define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
976#define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
977/* reserved: 0x000FAC03 */
978#define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
979#define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
980
981#define WLAN_MAX_KEY_LEN 32
982
Johannes Bergf97df022007-09-18 17:29:20 -0400983/**
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -0700984 * ieee80211_get_qos_ctl - get pointer to qos control bytes
985 * @hdr: the frame
986 *
987 * The qos ctrl bytes come after the frame_control, duration, seq_num
988 * and 3 or 4 addresses of length ETH_ALEN.
989 * 3 addr: 2 + 2 + 2 + 3*6 = 24
990 * 4 addr: 2 + 2 + 2 + 4*6 = 30
991 */
992static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
993{
994 if (ieee80211_has_a4(hdr->frame_control))
995 return (u8 *)hdr + 30;
996 else
997 return (u8 *)hdr + 24;
998}
999
1000/**
Johannes Bergf97df022007-09-18 17:29:20 -04001001 * ieee80211_get_SA - get pointer to SA
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001002 * @hdr: the frame
Johannes Bergf97df022007-09-18 17:29:20 -04001003 *
1004 * Given an 802.11 frame, this function returns the offset
1005 * to the source address (SA). It does not verify that the
1006 * header is long enough to contain the address, and the
1007 * header must be long enough to contain the frame control
1008 * field.
Johannes Bergf97df022007-09-18 17:29:20 -04001009 */
1010static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
1011{
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001012 if (ieee80211_has_a4(hdr->frame_control))
Harvey Harrison5a433b32008-04-21 10:41:10 -07001013 return hdr->addr4;
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001014 if (ieee80211_has_fromds(hdr->frame_control))
1015 return hdr->addr3;
1016 return hdr->addr2;
Johannes Bergf97df022007-09-18 17:29:20 -04001017}
1018
1019/**
1020 * ieee80211_get_DA - get pointer to DA
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001021 * @hdr: the frame
Johannes Bergf97df022007-09-18 17:29:20 -04001022 *
1023 * Given an 802.11 frame, this function returns the offset
1024 * to the destination address (DA). It does not verify that
1025 * the header is long enough to contain the address, and the
1026 * header must be long enough to contain the frame control
1027 * field.
Johannes Bergf97df022007-09-18 17:29:20 -04001028 */
1029static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1030{
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001031 if (ieee80211_has_tods(hdr->frame_control))
Johannes Bergf97df022007-09-18 17:29:20 -04001032 return hdr->addr3;
Harvey Harrison5a433b32008-04-21 10:41:10 -07001033 else
1034 return hdr->addr1;
Johannes Bergf97df022007-09-18 17:29:20 -04001035}
1036
Jiri Benca9de8ce2007-05-05 11:43:04 -07001037#endif /* IEEE80211_H */