blob: b1bb817d1427875a4ddc2923084fb9dfebc65b57 [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
John W. Linville9387b7c2008-09-30 20:59:05 -040015#ifndef LINUX_IEEE80211_H
16#define LINUX_IEEE80211_H
Jiri Benca9de8ce2007-05-05 11:43:04 -070017
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
Johannes Berg1239cd52008-10-28 11:12:57 +0100100
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100101#define IEEE80211_MAX_MESH_ID_LEN 32
Johannes Berg1239cd52008-10-28 11:12:57 +0100102#define IEEE80211_MESH_CONFIG_LEN 19
103
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -0700104#define IEEE80211_QOS_CTL_LEN 2
Harvey Harrison238f74a2008-07-02 11:05:34 -0700105#define IEEE80211_QOS_CTL_TID_MASK 0x000F
106#define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
Jiri Benca9de8ce2007-05-05 11:43:04 -0700107
108struct ieee80211_hdr {
109 __le16 frame_control;
110 __le16 duration_id;
111 u8 addr1[6];
112 u8 addr2[6];
113 u8 addr3[6];
114 __le16 seq_ctrl;
115 u8 addr4[6];
116} __attribute__ ((packed));
117
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -0700118/**
119 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
120 * @fc: frame control bytes in little-endian byteorder
121 */
122static inline int ieee80211_has_tods(__le16 fc)
123{
124 return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
125}
126
127/**
128 * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
129 * @fc: frame control bytes in little-endian byteorder
130 */
131static inline int ieee80211_has_fromds(__le16 fc)
132{
133 return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
134}
135
136/**
137 * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
138 * @fc: frame control bytes in little-endian byteorder
139 */
140static inline int ieee80211_has_a4(__le16 fc)
141{
142 __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
143 return (fc & tmp) == tmp;
144}
145
146/**
147 * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
148 * @fc: frame control bytes in little-endian byteorder
149 */
150static inline int ieee80211_has_morefrags(__le16 fc)
151{
152 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
153}
154
155/**
156 * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
157 * @fc: frame control bytes in little-endian byteorder
158 */
159static inline int ieee80211_has_retry(__le16 fc)
160{
161 return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
162}
163
164/**
165 * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
166 * @fc: frame control bytes in little-endian byteorder
167 */
168static inline int ieee80211_has_pm(__le16 fc)
169{
170 return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
171}
172
173/**
174 * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
175 * @fc: frame control bytes in little-endian byteorder
176 */
177static inline int ieee80211_has_moredata(__le16 fc)
178{
179 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
180}
181
182/**
183 * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
184 * @fc: frame control bytes in little-endian byteorder
185 */
186static inline int ieee80211_has_protected(__le16 fc)
187{
188 return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
189}
190
191/**
192 * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
193 * @fc: frame control bytes in little-endian byteorder
194 */
195static inline int ieee80211_has_order(__le16 fc)
196{
197 return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
198}
199
200/**
201 * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
202 * @fc: frame control bytes in little-endian byteorder
203 */
204static inline int ieee80211_is_mgmt(__le16 fc)
205{
206 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
207 cpu_to_le16(IEEE80211_FTYPE_MGMT);
208}
209
210/**
211 * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
212 * @fc: frame control bytes in little-endian byteorder
213 */
214static inline int ieee80211_is_ctl(__le16 fc)
215{
216 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
217 cpu_to_le16(IEEE80211_FTYPE_CTL);
218}
219
220/**
221 * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
222 * @fc: frame control bytes in little-endian byteorder
223 */
224static inline int ieee80211_is_data(__le16 fc)
225{
226 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
227 cpu_to_le16(IEEE80211_FTYPE_DATA);
228}
229
230/**
231 * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
232 * @fc: frame control bytes in little-endian byteorder
233 */
234static inline int ieee80211_is_data_qos(__le16 fc)
235{
236 /*
237 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
238 * to check the one bit
239 */
240 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
241 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
242}
243
244/**
245 * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
246 * @fc: frame control bytes in little-endian byteorder
247 */
248static inline int ieee80211_is_data_present(__le16 fc)
249{
250 /*
251 * mask with 0x40 and test that that bit is clear to only return true
252 * for the data-containing substypes.
253 */
254 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
255 cpu_to_le16(IEEE80211_FTYPE_DATA);
256}
257
258/**
259 * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
260 * @fc: frame control bytes in little-endian byteorder
261 */
262static inline int ieee80211_is_assoc_req(__le16 fc)
263{
264 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
265 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
266}
267
268/**
269 * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
270 * @fc: frame control bytes in little-endian byteorder
271 */
272static inline int ieee80211_is_assoc_resp(__le16 fc)
273{
274 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
275 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
276}
277
278/**
279 * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
280 * @fc: frame control bytes in little-endian byteorder
281 */
282static inline int ieee80211_is_reassoc_req(__le16 fc)
283{
284 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
285 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
286}
287
288/**
289 * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
290 * @fc: frame control bytes in little-endian byteorder
291 */
292static inline int ieee80211_is_reassoc_resp(__le16 fc)
293{
294 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
295 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
296}
297
298/**
299 * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
300 * @fc: frame control bytes in little-endian byteorder
301 */
302static inline int ieee80211_is_probe_req(__le16 fc)
303{
304 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
305 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
306}
307
308/**
309 * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
310 * @fc: frame control bytes in little-endian byteorder
311 */
312static inline int ieee80211_is_probe_resp(__le16 fc)
313{
314 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
315 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
316}
317
318/**
319 * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
320 * @fc: frame control bytes in little-endian byteorder
321 */
322static inline int ieee80211_is_beacon(__le16 fc)
323{
324 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
325 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
326}
327
328/**
329 * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
330 * @fc: frame control bytes in little-endian byteorder
331 */
332static inline int ieee80211_is_atim(__le16 fc)
333{
334 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
335 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
336}
337
338/**
339 * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
340 * @fc: frame control bytes in little-endian byteorder
341 */
342static inline int ieee80211_is_disassoc(__le16 fc)
343{
344 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
345 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
346}
347
348/**
349 * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
350 * @fc: frame control bytes in little-endian byteorder
351 */
352static inline int ieee80211_is_auth(__le16 fc)
353{
354 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
355 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
356}
357
358/**
359 * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
360 * @fc: frame control bytes in little-endian byteorder
361 */
362static inline int ieee80211_is_deauth(__le16 fc)
363{
364 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
365 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
366}
367
368/**
369 * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
370 * @fc: frame control bytes in little-endian byteorder
371 */
372static inline int ieee80211_is_action(__le16 fc)
373{
374 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
375 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
376}
377
378/**
379 * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
380 * @fc: frame control bytes in little-endian byteorder
381 */
382static inline int ieee80211_is_back_req(__le16 fc)
383{
384 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
385 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
386}
387
388/**
389 * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
390 * @fc: frame control bytes in little-endian byteorder
391 */
392static inline int ieee80211_is_back(__le16 fc)
393{
394 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
395 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
396}
397
398/**
399 * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
400 * @fc: frame control bytes in little-endian byteorder
401 */
402static inline int ieee80211_is_pspoll(__le16 fc)
403{
404 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
405 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
406}
407
408/**
409 * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
410 * @fc: frame control bytes in little-endian byteorder
411 */
412static inline int ieee80211_is_rts(__le16 fc)
413{
414 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
415 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
416}
417
418/**
419 * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
420 * @fc: frame control bytes in little-endian byteorder
421 */
422static inline int ieee80211_is_cts(__le16 fc)
423{
424 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
425 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
426}
427
428/**
429 * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
430 * @fc: frame control bytes in little-endian byteorder
431 */
432static inline int ieee80211_is_ack(__le16 fc)
433{
434 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
435 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
436}
437
438/**
439 * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
440 * @fc: frame control bytes in little-endian byteorder
441 */
442static inline int ieee80211_is_cfend(__le16 fc)
443{
444 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
445 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
446}
447
448/**
449 * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
450 * @fc: frame control bytes in little-endian byteorder
451 */
452static inline int ieee80211_is_cfendack(__le16 fc)
453{
454 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
455 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
456}
457
458/**
459 * ieee80211_is_nullfunc - check if FTYPE=IEEE80211_FTYPE_DATA and STYPE=IEEE80211_STYPE_NULLFUNC
460 * @fc: frame control bytes in little-endian byteorder
461 */
462static inline int ieee80211_is_nullfunc(__le16 fc)
463{
464 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
465 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
466}
Jiri Benca9de8ce2007-05-05 11:43:04 -0700467
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100468struct ieee80211s_hdr {
469 u8 flags;
470 u8 ttl;
Luis Carlos Cobo51cedda2008-04-23 12:15:29 -0700471 __le32 seqnum;
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100472 u8 eaddr1[6];
473 u8 eaddr2[6];
474 u8 eaddr3[6];
475} __attribute__ ((packed));
476
YanBo79617de2008-09-22 13:30:32 +0800477/* Mesh flags */
478#define MESH_FLAGS_AE_A4 0x1
479#define MESH_FLAGS_AE_A5_A6 0x2
480#define MESH_FLAGS_PS_DEEP 0x4
481
Assaf Kraussf2df3852008-06-15 18:23:29 +0300482/**
483 * struct ieee80211_quiet_ie
484 *
485 * This structure refers to "Quiet information element"
486 */
487struct ieee80211_quiet_ie {
488 u8 count;
489 u8 period;
490 __le16 duration;
491 __le16 offset;
492} __attribute__ ((packed));
493
494/**
495 * struct ieee80211_msrment_ie
496 *
497 * This structure refers to "Measurement Request/Report information element"
498 */
499struct ieee80211_msrment_ie {
500 u8 token;
501 u8 mode;
502 u8 type;
503 u8 request[0];
504} __attribute__ ((packed));
505
506/**
507 * struct ieee80211_channel_sw_ie
508 *
509 * This structure refers to "Channel Switch Announcement information element"
510 */
511struct ieee80211_channel_sw_ie {
512 u8 mode;
513 u8 new_ch_num;
514 u8 count;
515} __attribute__ ((packed));
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100516
Emmanuel Grumbach98f7dfd2008-07-18 13:52:59 +0800517/**
518 * struct ieee80211_tim
519 *
520 * This structure refers to "Traffic Indication Map information element"
521 */
522struct ieee80211_tim_ie {
523 u8 dtim_count;
524 u8 dtim_period;
525 u8 bitmap_ctrl;
526 /* variable size: 1 - 251 bytes */
527 u8 virtual_map[0];
528} __attribute__ ((packed));
529
Jouni Malinenfea14732009-01-08 13:32:06 +0200530#define WLAN_SA_QUERY_TR_ID_LEN 16
531
Jiri Benca9de8ce2007-05-05 11:43:04 -0700532struct ieee80211_mgmt {
533 __le16 frame_control;
534 __le16 duration;
535 u8 da[6];
536 u8 sa[6];
537 u8 bssid[6];
538 __le16 seq_ctrl;
539 union {
540 struct {
541 __le16 auth_alg;
542 __le16 auth_transaction;
543 __le16 status_code;
544 /* possibly followed by Challenge text */
545 u8 variable[0];
546 } __attribute__ ((packed)) auth;
547 struct {
548 __le16 reason_code;
549 } __attribute__ ((packed)) deauth;
550 struct {
551 __le16 capab_info;
552 __le16 listen_interval;
553 /* followed by SSID and Supported rates */
554 u8 variable[0];
555 } __attribute__ ((packed)) assoc_req;
556 struct {
557 __le16 capab_info;
558 __le16 status_code;
559 __le16 aid;
560 /* followed by Supported rates */
561 u8 variable[0];
562 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
563 struct {
564 __le16 capab_info;
565 __le16 listen_interval;
566 u8 current_ap[6];
567 /* followed by SSID and Supported rates */
568 u8 variable[0];
569 } __attribute__ ((packed)) reassoc_req;
570 struct {
571 __le16 reason_code;
572 } __attribute__ ((packed)) disassoc;
573 struct {
574 __le64 timestamp;
575 __le16 beacon_int;
576 __le16 capab_info;
577 /* followed by some of SSID, Supported rates,
578 * FH Params, DS Params, CF Params, IBSS Params, TIM */
579 u8 variable[0];
580 } __attribute__ ((packed)) beacon;
581 struct {
582 /* only variable items: SSID, Supported rates */
583 u8 variable[0];
584 } __attribute__ ((packed)) probe_req;
585 struct {
586 __le64 timestamp;
587 __le16 beacon_int;
588 __le16 capab_info;
589 /* followed by some of SSID, Supported rates,
590 * FH Params, DS Params, CF Params, IBSS Params */
591 u8 variable[0];
592 } __attribute__ ((packed)) probe_resp;
593 struct {
594 u8 category;
595 union {
596 struct {
597 u8 action_code;
598 u8 dialog_token;
599 u8 status_code;
600 u8 variable[0];
601 } __attribute__ ((packed)) wme_action;
602 struct{
603 u8 action_code;
604 u8 element_id;
605 u8 length;
Assaf Kraussf2df3852008-06-15 18:23:29 +0300606 struct ieee80211_channel_sw_ie sw_elem;
Jiri Benca9de8ce2007-05-05 11:43:04 -0700607 } __attribute__((packed)) chan_switch;
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200608 struct{
609 u8 action_code;
610 u8 dialog_token;
Assaf Kraussf2df3852008-06-15 18:23:29 +0300611 u8 element_id;
612 u8 length;
613 struct ieee80211_msrment_ie msr_elem;
614 } __attribute__((packed)) measurement;
615 struct{
616 u8 action_code;
617 u8 dialog_token;
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200618 __le16 capab;
619 __le16 timeout;
620 __le16 start_seq_num;
621 } __attribute__((packed)) addba_req;
622 struct{
623 u8 action_code;
624 u8 dialog_token;
625 __le16 status;
626 __le16 capab;
627 __le16 timeout;
628 } __attribute__((packed)) addba_resp;
629 struct{
630 u8 action_code;
631 __le16 params;
632 __le16 reason_code;
633 } __attribute__((packed)) delba;
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100634 struct{
635 u8 action_code;
636 /* capab_info for open and confirm,
637 * reason for close
638 */
639 __le16 aux;
640 /* Followed in plink_confirm by status
641 * code, AID and supported rates,
642 * and directly by supported rates in
643 * plink_open and plink_close
644 */
645 u8 variable[0];
646 } __attribute__((packed)) plink_action;
647 struct{
648 u8 action_code;
649 u8 variable[0];
650 } __attribute__((packed)) mesh_action;
Jouni Malinenfea14732009-01-08 13:32:06 +0200651 struct {
652 u8 action;
653 u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
654 } __attribute__ ((packed)) sa_query;
Jiri Benca9de8ce2007-05-05 11:43:04 -0700655 } u;
656 } __attribute__ ((packed)) action;
657 } u;
658} __attribute__ ((packed));
659
Johannes Berg44d414d2008-09-08 17:44:28 +0200660/* mgmt header + 1 byte category code */
661#define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
662
Jiri Benca9de8ce2007-05-05 11:43:04 -0700663
Jouni Malinen765cb462009-01-08 13:32:01 +0200664/* Management MIC information element (IEEE 802.11w) */
665struct ieee80211_mmie {
666 u8 element_id;
667 u8 length;
668 __le16 key_id;
669 u8 sequence_number[6];
670 u8 mic[8];
671} __attribute__ ((packed));
672
Jiri Benca9de8ce2007-05-05 11:43:04 -0700673/* Control frames */
674struct ieee80211_rts {
675 __le16 frame_control;
676 __le16 duration;
677 u8 ra[6];
678 u8 ta[6];
679} __attribute__ ((packed));
680
681struct ieee80211_cts {
682 __le16 frame_control;
683 __le16 duration;
684 u8 ra[6];
685} __attribute__ ((packed));
686
Jouni Malinenfc6971d2008-10-30 19:59:05 +0200687struct ieee80211_pspoll {
688 __le16 frame_control;
689 __le16 aid;
690 u8 bssid[6];
691 u8 ta[6];
692} __attribute__ ((packed));
693
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200694/**
695 * struct ieee80211_bar - HT Block Ack Request
696 *
697 * This structure refers to "HT BlockAckReq" as
698 * described in 802.11n draft section 7.2.1.7.1
699 */
700struct ieee80211_bar {
701 __le16 frame_control;
702 __le16 duration;
703 __u8 ra[6];
704 __u8 ta[6];
Ron Rindjunskya8b47ea2008-01-21 12:39:11 +0200705 __le16 control;
706 __le16 start_seq_num;
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200707} __attribute__((packed));
708
Ron Rindjunsky429a3802008-07-01 14:16:03 +0300709/* 802.11 BAR control masks */
710#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
711#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
712
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200713
714#define IEEE80211_HT_MCS_MASK_LEN 10
715
716/**
717 * struct ieee80211_mcs_info - MCS information
718 * @rx_mask: RX mask
719 * @rx_highest: highest supported RX rate
720 * @tx_params: TX parameters
721 */
722struct ieee80211_mcs_info {
723 u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN];
724 __le16 rx_highest;
725 u8 tx_params;
726 u8 reserved[3];
727} __attribute__((packed));
728
729/* 802.11n HT capability MSC set */
730#define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3ff
731#define IEEE80211_HT_MCS_TX_DEFINED 0x01
732#define IEEE80211_HT_MCS_TX_RX_DIFF 0x02
733/* value 0 == 1 stream etc */
734#define IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK 0x0C
735#define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2
736#define IEEE80211_HT_MCS_TX_MAX_STREAMS 4
737#define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10
738
739/*
740 * 802.11n D5.0 20.3.5 / 20.6 says:
741 * - indices 0 to 7 and 32 are single spatial stream
742 * - 8 to 31 are multiple spatial streams using equal modulation
743 * [8..15 for two streams, 16..23 for three and 24..31 for four]
744 * - remainder are multiple spatial streams using unequal modulation
745 */
746#define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START 33
747#define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE \
748 (IEEE80211_HT_MCS_UNEQUAL_MODULATION_START / 8)
749
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200750/**
751 * struct ieee80211_ht_cap - HT capabilities
752 *
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200753 * This structure is the "HT capabilities element" as
754 * described in 802.11n D5.0 7.3.2.57
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200755 */
756struct ieee80211_ht_cap {
757 __le16 cap_info;
758 u8 ampdu_params_info;
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200759
760 /* 16 bytes MCS information */
761 struct ieee80211_mcs_info mcs;
762
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200763 __le16 extended_ht_cap_info;
764 __le32 tx_BF_cap_info;
765 u8 antenna_selection_info;
766} __attribute__ ((packed));
767
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200768/* 802.11n HT capabilities masks (for cap_info) */
769#define IEEE80211_HT_CAP_LDPC_CODING 0x0001
770#define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002
771#define IEEE80211_HT_CAP_SM_PS 0x000C
772#define IEEE80211_HT_CAP_GRN_FLD 0x0010
773#define IEEE80211_HT_CAP_SGI_20 0x0020
774#define IEEE80211_HT_CAP_SGI_40 0x0040
775#define IEEE80211_HT_CAP_TX_STBC 0x0080
776#define IEEE80211_HT_CAP_RX_STBC 0x0300
777#define IEEE80211_HT_CAP_DELAY_BA 0x0400
778#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
779#define IEEE80211_HT_CAP_DSSSCCK40 0x1000
780#define IEEE80211_HT_CAP_PSMP_SUPPORT 0x2000
781#define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
782#define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
783
784/* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
785#define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03
786#define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C
787
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200788/**
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200789 * struct ieee80211_ht_info - HT information
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200790 *
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200791 * This structure is the "HT information element" as
792 * described in 802.11n D5.0 7.3.2.58
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200793 */
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200794struct ieee80211_ht_info {
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200795 u8 control_chan;
796 u8 ht_param;
797 __le16 operation_mode;
798 __le16 stbc_param;
799 u8 basic_set[16];
800} __attribute__ ((packed));
801
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200802/* for ht_param */
803#define IEEE80211_HT_PARAM_CHA_SEC_OFFSET 0x03
804#define IEEE80211_HT_PARAM_CHA_SEC_NONE 0x00
805#define IEEE80211_HT_PARAM_CHA_SEC_ABOVE 0x01
806#define IEEE80211_HT_PARAM_CHA_SEC_BELOW 0x03
807#define IEEE80211_HT_PARAM_CHAN_WIDTH_ANY 0x04
808#define IEEE80211_HT_PARAM_RIFS_MODE 0x08
809#define IEEE80211_HT_PARAM_SPSMP_SUPPORT 0x10
810#define IEEE80211_HT_PARAM_SERV_INTERVAL_GRAN 0xE0
811
812/* for operation_mode */
813#define IEEE80211_HT_OP_MODE_PROTECTION 0x0003
814#define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0
815#define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 1
816#define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 2
817#define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 3
818#define IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT 0x0004
819#define IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT 0x0010
820
821/* for stbc_param */
822#define IEEE80211_HT_STBC_PARAM_DUAL_BEACON 0x0040
823#define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080
824#define IEEE80211_HT_STBC_PARAM_STBC_BEACON 0x0100
825#define IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT 0x0200
826#define IEEE80211_HT_STBC_PARAM_PCO_ACTIVE 0x0400
827#define IEEE80211_HT_STBC_PARAM_PCO_PHASE 0x0800
828
Jiri Benca9de8ce2007-05-05 11:43:04 -0700829
Johannes Berg44d414d2008-09-08 17:44:28 +0200830/* block-ack parameters */
831#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
832#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
833#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
834#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
835#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
836
837/*
838 * A-PMDU buffer sizes
839 * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
840 */
841#define IEEE80211_MIN_AMPDU_BUF 0x8
842#define IEEE80211_MAX_AMPDU_BUF 0x40
843
844
Tomas Winkler00c5ae22008-09-03 11:26:42 +0800845/* Spatial Multiplexing Power Save Modes */
846#define WLAN_HT_CAP_SM_PS_STATIC 0
847#define WLAN_HT_CAP_SM_PS_DYNAMIC 1
848#define WLAN_HT_CAP_SM_PS_INVALID 2
849#define WLAN_HT_CAP_SM_PS_DISABLED 3
Tomas Winklere53cfe02008-01-30 22:05:13 -0800850
Jiri Benca9de8ce2007-05-05 11:43:04 -0700851/* Authentication algorithms */
852#define WLAN_AUTH_OPEN 0
853#define WLAN_AUTH_SHARED_KEY 1
Senthil Balasubramanianbb608e92008-12-04 20:38:13 +0530854#define WLAN_AUTH_LEAP 128
Jiri Benca9de8ce2007-05-05 11:43:04 -0700855
856#define WLAN_AUTH_CHALLENGE_LEN 128
857
858#define WLAN_CAPABILITY_ESS (1<<0)
859#define WLAN_CAPABILITY_IBSS (1<<1)
860#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
861#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
862#define WLAN_CAPABILITY_PRIVACY (1<<4)
863#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
864#define WLAN_CAPABILITY_PBCC (1<<6)
865#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
Assaf Kraussb6623482008-06-16 16:09:49 +0300866
Jiri Benca9de8ce2007-05-05 11:43:04 -0700867/* 802.11h */
868#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
869#define WLAN_CAPABILITY_QOS (1<<9)
870#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
871#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
Assaf Kraussb6623482008-06-16 16:09:49 +0300872/* measurement */
873#define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
874#define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
875#define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
876
877#define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
878#define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
879#define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
880
Jiri Benca9de8ce2007-05-05 11:43:04 -0700881
Daniel Drake56282212007-07-10 19:32:10 +0200882/* 802.11g ERP information element */
883#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
884#define WLAN_ERP_USE_PROTECTION (1<<1)
885#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
886
887/* WLAN_ERP_BARKER_PREAMBLE values */
888enum {
889 WLAN_ERP_PREAMBLE_SHORT = 0,
890 WLAN_ERP_PREAMBLE_LONG = 1,
891};
892
Jiri Benca9de8ce2007-05-05 11:43:04 -0700893/* Status codes */
894enum ieee80211_statuscode {
895 WLAN_STATUS_SUCCESS = 0,
896 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
897 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
898 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
899 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
900 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
901 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
902 WLAN_STATUS_CHALLENGE_FAIL = 15,
903 WLAN_STATUS_AUTH_TIMEOUT = 16,
904 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
905 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
906 /* 802.11b */
907 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
908 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
909 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
910 /* 802.11h */
911 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
912 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
913 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
914 /* 802.11g */
915 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
916 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
Jouni Malinen63a5ab82009-01-08 13:32:09 +0200917 /* 802.11w */
918 WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30,
919 WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31,
Jiri Benca9de8ce2007-05-05 11:43:04 -0700920 /* 802.11i */
921 WLAN_STATUS_INVALID_IE = 40,
922 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
923 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
924 WLAN_STATUS_INVALID_AKMP = 43,
925 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
926 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
927 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200928 /* 802.11e */
929 WLAN_STATUS_UNSPECIFIED_QOS = 32,
930 WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
931 WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
932 WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
933 WLAN_STATUS_REQUEST_DECLINED = 37,
934 WLAN_STATUS_INVALID_QOS_PARAM = 38,
935 WLAN_STATUS_CHANGE_TSPEC = 39,
936 WLAN_STATUS_WAIT_TS_DELAY = 47,
937 WLAN_STATUS_NO_DIRECT_LINK = 48,
938 WLAN_STATUS_STA_NOT_PRESENT = 49,
939 WLAN_STATUS_STA_NOT_QSTA = 50,
Jiri Benca9de8ce2007-05-05 11:43:04 -0700940};
941
942
943/* Reason codes */
944enum ieee80211_reasoncode {
945 WLAN_REASON_UNSPECIFIED = 1,
946 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
947 WLAN_REASON_DEAUTH_LEAVING = 3,
948 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
949 WLAN_REASON_DISASSOC_AP_BUSY = 5,
950 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
951 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
952 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
953 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
954 /* 802.11h */
955 WLAN_REASON_DISASSOC_BAD_POWER = 10,
956 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
957 /* 802.11i */
958 WLAN_REASON_INVALID_IE = 13,
959 WLAN_REASON_MIC_FAILURE = 14,
960 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
961 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
962 WLAN_REASON_IE_DIFFERENT = 17,
963 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
964 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
965 WLAN_REASON_INVALID_AKMP = 20,
966 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
967 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
968 WLAN_REASON_IEEE8021X_FAILED = 23,
969 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200970 /* 802.11e */
971 WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
972 WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
973 WLAN_REASON_DISASSOC_LOW_ACK = 34,
974 WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
975 WLAN_REASON_QSTA_LEAVE_QBSS = 36,
976 WLAN_REASON_QSTA_NOT_USE = 37,
977 WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
978 WLAN_REASON_QSTA_TIMEOUT = 39,
979 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
Jiri Benca9de8ce2007-05-05 11:43:04 -0700980};
981
982
983/* Information Element IDs */
984enum ieee80211_eid {
985 WLAN_EID_SSID = 0,
986 WLAN_EID_SUPP_RATES = 1,
987 WLAN_EID_FH_PARAMS = 2,
988 WLAN_EID_DS_PARAMS = 3,
989 WLAN_EID_CF_PARAMS = 4,
990 WLAN_EID_TIM = 5,
991 WLAN_EID_IBSS_PARAMS = 6,
992 WLAN_EID_CHALLENGE = 16,
993 /* 802.11d */
994 WLAN_EID_COUNTRY = 7,
995 WLAN_EID_HP_PARAMS = 8,
996 WLAN_EID_HP_TABLE = 9,
997 WLAN_EID_REQUEST = 10,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200998 /* 802.11e */
999 WLAN_EID_QBSS_LOAD = 11,
1000 WLAN_EID_EDCA_PARAM_SET = 12,
1001 WLAN_EID_TSPEC = 13,
1002 WLAN_EID_TCLAS = 14,
1003 WLAN_EID_SCHEDULE = 15,
1004 WLAN_EID_TS_DELAY = 43,
1005 WLAN_EID_TCLAS_PROCESSING = 44,
1006 WLAN_EID_QOS_CAPA = 46,
Luis Carlos Cobod619ee02008-04-23 12:34:59 -07001007 /* 802.11s
1008 *
1009 * All mesh EID numbers are pending IEEE 802.11 ANA approval.
1010 * The numbers have been incremented from those suggested in
1011 * 802.11s/D2.0 so that MESH_CONFIG does not conflict with
1012 * EXT_SUPP_RATES.
1013 */
1014 WLAN_EID_MESH_CONFIG = 51,
1015 WLAN_EID_MESH_ID = 52,
1016 WLAN_EID_PEER_LINK = 55,
1017 WLAN_EID_PREQ = 68,
1018 WLAN_EID_PREP = 69,
1019 WLAN_EID_PERR = 70,
Jiri Benca9de8ce2007-05-05 11:43:04 -07001020 /* 802.11h */
1021 WLAN_EID_PWR_CONSTRAINT = 32,
1022 WLAN_EID_PWR_CAPABILITY = 33,
1023 WLAN_EID_TPC_REQUEST = 34,
1024 WLAN_EID_TPC_REPORT = 35,
1025 WLAN_EID_SUPPORTED_CHANNELS = 36,
1026 WLAN_EID_CHANNEL_SWITCH = 37,
1027 WLAN_EID_MEASURE_REQUEST = 38,
1028 WLAN_EID_MEASURE_REPORT = 39,
1029 WLAN_EID_QUIET = 40,
1030 WLAN_EID_IBSS_DFS = 41,
1031 /* 802.11g */
1032 WLAN_EID_ERP_INFO = 42,
1033 WLAN_EID_EXT_SUPP_RATES = 50,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +02001034 /* 802.11n */
1035 WLAN_EID_HT_CAPABILITY = 45,
Johannes Bergd9fe60d2008-10-09 12:13:49 +02001036 WLAN_EID_HT_INFORMATION = 61,
Jiri Benca9de8ce2007-05-05 11:43:04 -07001037 /* 802.11i */
1038 WLAN_EID_RSN = 48,
Jouni Malinenf797eb72009-01-19 18:48:46 +02001039 WLAN_EID_TIMEOUT_INTERVAL = 56,
Jouni Malinen765cb462009-01-08 13:32:01 +02001040 WLAN_EID_MMIE = 76 /* 802.11w */,
Jiri Benca9de8ce2007-05-05 11:43:04 -07001041 WLAN_EID_WPA = 221,
1042 WLAN_EID_GENERIC = 221,
1043 WLAN_EID_VENDOR_SPECIFIC = 221,
1044 WLAN_EID_QOS_PARAMETER = 222
1045};
1046
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +02001047/* Action category code */
1048enum ieee80211_category {
1049 WLAN_CATEGORY_SPECTRUM_MGMT = 0,
1050 WLAN_CATEGORY_QOS = 1,
1051 WLAN_CATEGORY_DLS = 2,
1052 WLAN_CATEGORY_BACK = 3,
Jouni Malinenfb733332009-01-08 13:32:00 +02001053 WLAN_CATEGORY_PUBLIC = 4,
Jouni Malinenfea14732009-01-08 13:32:06 +02001054 WLAN_CATEGORY_SA_QUERY = 8,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +02001055 WLAN_CATEGORY_WMM = 17,
1056};
1057
Assaf Kraussf2df3852008-06-15 18:23:29 +03001058/* SPECTRUM_MGMT action code */
1059enum ieee80211_spectrum_mgmt_actioncode {
1060 WLAN_ACTION_SPCT_MSR_REQ = 0,
1061 WLAN_ACTION_SPCT_MSR_RPRT = 1,
1062 WLAN_ACTION_SPCT_TPC_REQ = 2,
1063 WLAN_ACTION_SPCT_TPC_RPRT = 3,
1064 WLAN_ACTION_SPCT_CHL_SWITCH = 4,
1065};
1066
Luis R. Rodriguez3f2355c2008-11-12 14:22:02 -08001067/*
1068 * IEEE 802.11-2007 7.3.2.9 Country information element
1069 *
1070 * Minimum length is 8 octets, ie len must be evenly
1071 * divisible by 2
1072 */
1073
1074/* Although the spec says 8 I'm seeing 6 in practice */
1075#define IEEE80211_COUNTRY_IE_MIN_LEN 6
1076
1077/*
1078 * For regulatory extension stuff see IEEE 802.11-2007
1079 * Annex I (page 1141) and Annex J (page 1147). Also
1080 * review 7.3.2.9.
1081 *
1082 * When dot11RegulatoryClassesRequired is true and the
1083 * first_channel/reg_extension_id is >= 201 then the IE
1084 * compromises of the 'ext' struct represented below:
1085 *
1086 * - Regulatory extension ID - when generating IE this just needs
1087 * to be monotonically increasing for each triplet passed in
1088 * the IE
1089 * - Regulatory class - index into set of rules
1090 * - Coverage class - index into air propagation time (Table 7-27),
1091 * in microseconds, you can compute the air propagation time from
1092 * the index by multiplying by 3, so index 10 yields a propagation
1093 * of 10 us. Valid values are 0-31, values 32-255 are not defined
1094 * yet. A value of 0 inicates air propagation of <= 1 us.
1095 *
1096 * See also Table I.2 for Emission limit sets and table
1097 * I.3 for Behavior limit sets. Table J.1 indicates how to map
1098 * a reg_class to an emission limit set and behavior limit set.
1099 */
1100#define IEEE80211_COUNTRY_EXTENSION_ID 201
1101
1102/*
1103 * Channels numbers in the IE must be monotonically increasing
1104 * if dot11RegulatoryClassesRequired is not true.
1105 *
1106 * If dot11RegulatoryClassesRequired is true consecutive
1107 * subband triplets following a regulatory triplet shall
1108 * have monotonically increasing first_channel number fields.
1109 *
1110 * Channel numbers shall not overlap.
1111 *
1112 * Note that max_power is signed.
1113 */
1114struct ieee80211_country_ie_triplet {
1115 union {
1116 struct {
1117 u8 first_channel;
1118 u8 num_channels;
1119 s8 max_power;
1120 } __attribute__ ((packed)) chans;
1121 struct {
1122 u8 reg_extension_id;
1123 u8 reg_class;
1124 u8 coverage_class;
1125 } __attribute__ ((packed)) ext;
1126 };
1127} __attribute__ ((packed));
1128
Jouni Malinenf797eb72009-01-19 18:48:46 +02001129enum ieee80211_timeout_interval_type {
1130 WLAN_TIMEOUT_REASSOC_DEADLINE = 1 /* 802.11r */,
1131 WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */,
1132 WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
1133};
1134
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +02001135/* BACK action code */
1136enum ieee80211_back_actioncode {
1137 WLAN_ACTION_ADDBA_REQ = 0,
1138 WLAN_ACTION_ADDBA_RESP = 1,
1139 WLAN_ACTION_DELBA = 2,
1140};
1141
Ron Rindjunsky07db2182007-12-25 17:00:33 +02001142/* BACK (block-ack) parties */
1143enum ieee80211_back_parties {
1144 WLAN_BACK_RECIPIENT = 0,
1145 WLAN_BACK_INITIATOR = 1,
1146 WLAN_BACK_TIMER = 2,
1147};
1148
Jouni Malinenfea14732009-01-08 13:32:06 +02001149/* SA Query action */
1150enum ieee80211_sa_query_action {
1151 WLAN_ACTION_SA_QUERY_REQUEST = 0,
1152 WLAN_ACTION_SA_QUERY_RESPONSE = 1,
1153};
1154
1155
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +02001156/* A-MSDU 802.11n */
1157#define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
1158
Jiri Benca9de8ce2007-05-05 11:43:04 -07001159/* cipher suite selectors */
1160#define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
1161#define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
1162#define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
1163/* reserved: 0x000FAC03 */
1164#define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
1165#define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
Jouni Malinen3cfcf6a2009-01-08 13:32:02 +02001166#define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06
Jiri Benca9de8ce2007-05-05 11:43:04 -07001167
1168#define WLAN_MAX_KEY_LEN 32
1169
Johannes Bergf97df022007-09-18 17:29:20 -04001170/**
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001171 * ieee80211_get_qos_ctl - get pointer to qos control bytes
1172 * @hdr: the frame
1173 *
1174 * The qos ctrl bytes come after the frame_control, duration, seq_num
1175 * and 3 or 4 addresses of length ETH_ALEN.
1176 * 3 addr: 2 + 2 + 2 + 3*6 = 24
1177 * 4 addr: 2 + 2 + 2 + 4*6 = 30
1178 */
1179static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
1180{
1181 if (ieee80211_has_a4(hdr->frame_control))
1182 return (u8 *)hdr + 30;
1183 else
1184 return (u8 *)hdr + 24;
1185}
1186
1187/**
Johannes Bergf97df022007-09-18 17:29:20 -04001188 * ieee80211_get_SA - get pointer to SA
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001189 * @hdr: the frame
Johannes Bergf97df022007-09-18 17:29:20 -04001190 *
1191 * Given an 802.11 frame, this function returns the offset
1192 * to the source address (SA). It does not verify that the
1193 * header is long enough to contain the address, and the
1194 * header must be long enough to contain the frame control
1195 * field.
Johannes Bergf97df022007-09-18 17:29:20 -04001196 */
1197static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
1198{
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001199 if (ieee80211_has_a4(hdr->frame_control))
Harvey Harrison5a433b32008-04-21 10:41:10 -07001200 return hdr->addr4;
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001201 if (ieee80211_has_fromds(hdr->frame_control))
1202 return hdr->addr3;
1203 return hdr->addr2;
Johannes Bergf97df022007-09-18 17:29:20 -04001204}
1205
1206/**
1207 * ieee80211_get_DA - get pointer to DA
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001208 * @hdr: the frame
Johannes Bergf97df022007-09-18 17:29:20 -04001209 *
1210 * Given an 802.11 frame, this function returns the offset
1211 * to the destination address (DA). It does not verify that
1212 * the header is long enough to contain the address, and the
1213 * header must be long enough to contain the frame control
1214 * field.
Johannes Bergf97df022007-09-18 17:29:20 -04001215 */
1216static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1217{
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001218 if (ieee80211_has_tods(hdr->frame_control))
Johannes Bergf97df022007-09-18 17:29:20 -04001219 return hdr->addr3;
Harvey Harrison5a433b32008-04-21 10:41:10 -07001220 else
1221 return hdr->addr1;
Johannes Bergf97df022007-09-18 17:29:20 -04001222}
1223
David Kilroy9ee677c2008-12-23 14:03:38 +00001224/**
Jouni Malinenfb733332009-01-08 13:32:00 +02001225 * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
1226 * @hdr: the frame (buffer must include at least the first octet of payload)
1227 */
1228static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
1229{
1230 if (ieee80211_is_disassoc(hdr->frame_control) ||
1231 ieee80211_is_deauth(hdr->frame_control))
1232 return true;
1233
1234 if (ieee80211_is_action(hdr->frame_control)) {
1235 u8 *category;
1236
1237 /*
1238 * Action frames, excluding Public Action frames, are Robust
1239 * Management Frames. However, if we are looking at a Protected
1240 * frame, skip the check since the data may be encrypted and
1241 * the frame has already been found to be a Robust Management
1242 * Frame (by the other end).
1243 */
1244 if (ieee80211_has_protected(hdr->frame_control))
1245 return true;
1246 category = ((u8 *) hdr) + 24;
1247 return *category != WLAN_CATEGORY_PUBLIC;
1248 }
1249
1250 return false;
1251}
1252
1253/**
David Kilroy9ee677c2008-12-23 14:03:38 +00001254 * ieee80211_fhss_chan_to_freq - get channel frequency
1255 * @channel: the FHSS channel
1256 *
1257 * Convert IEEE802.11 FHSS channel to frequency (MHz)
1258 * Ref IEEE 802.11-2007 section 14.6
1259 */
1260static inline int ieee80211_fhss_chan_to_freq(int channel)
1261{
1262 if ((channel > 1) && (channel < 96))
1263 return channel + 2400;
1264 else
1265 return -1;
1266}
1267
1268/**
1269 * ieee80211_freq_to_fhss_chan - get channel
1270 * @freq: the channels frequency
1271 *
1272 * Convert frequency (MHz) to IEEE802.11 FHSS channel
1273 * Ref IEEE 802.11-2007 section 14.6
1274 */
1275static inline int ieee80211_freq_to_fhss_chan(int freq)
1276{
1277 if ((freq > 2401) && (freq < 2496))
1278 return freq - 2400;
1279 else
1280 return -1;
1281}
1282
1283/**
1284 * ieee80211_dsss_chan_to_freq - get channel center frequency
1285 * @channel: the DSSS channel
1286 *
1287 * Convert IEEE802.11 DSSS channel to the center frequency (MHz).
1288 * Ref IEEE 802.11-2007 section 15.6
1289 */
1290static inline int ieee80211_dsss_chan_to_freq(int channel)
1291{
1292 if ((channel > 0) && (channel < 14))
1293 return 2407 + (channel * 5);
1294 else if (channel == 14)
1295 return 2484;
1296 else
1297 return -1;
1298}
1299
1300/**
1301 * ieee80211_freq_to_dsss_chan - get channel
1302 * @freq: the frequency
1303 *
1304 * Convert frequency (MHz) to IEEE802.11 DSSS channel
1305 * Ref IEEE 802.11-2007 section 15.6
1306 *
1307 * This routine selects the channel with the closest center frequency.
1308 */
1309static inline int ieee80211_freq_to_dsss_chan(int freq)
1310{
1311 if ((freq >= 2410) && (freq < 2475))
1312 return (freq - 2405) / 5;
1313 else if ((freq >= 2482) && (freq < 2487))
1314 return 14;
1315 else
1316 return -1;
1317}
1318
1319/* Convert IEEE802.11 HR DSSS channel to frequency (MHz) and back
1320 * Ref IEEE 802.11-2007 section 18.4.6.2
1321 *
1322 * The channels and frequencies are the same as those defined for DSSS
1323 */
1324#define ieee80211_hr_chan_to_freq(chan) ieee80211_dsss_chan_to_freq(chan)
1325#define ieee80211_freq_to_hr_chan(freq) ieee80211_freq_to_dsss_chan(freq)
1326
1327/* Convert IEEE802.11 ERP channel to frequency (MHz) and back
1328 * Ref IEEE 802.11-2007 section 19.4.2
1329 */
1330#define ieee80211_erp_chan_to_freq(chan) ieee80211_hr_chan_to_freq(chan)
1331#define ieee80211_freq_to_erp_chan(freq) ieee80211_freq_to_hr_chan(freq)
1332
1333/**
1334 * ieee80211_ofdm_chan_to_freq - get channel center frequency
1335 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
1336 * @channel: the OFDM channel
1337 *
1338 * Convert IEEE802.11 OFDM channel to center frequency (MHz)
1339 * Ref IEEE 802.11-2007 section 17.3.8.3.2
1340 */
1341static inline int ieee80211_ofdm_chan_to_freq(int s_freq, int channel)
1342{
1343 if ((channel > 0) && (channel <= 200) &&
1344 (s_freq >= 4000))
1345 return s_freq + (channel * 5);
1346 else
1347 return -1;
1348}
1349
1350/**
1351 * ieee80211_freq_to_ofdm_channel - get channel
1352 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
1353 * @freq: the frequency
1354 *
1355 * Convert frequency (MHz) to IEEE802.11 OFDM channel
1356 * Ref IEEE 802.11-2007 section 17.3.8.3.2
1357 *
1358 * This routine selects the channel with the closest center frequency.
1359 */
1360static inline int ieee80211_freq_to_ofdm_chan(int s_freq, int freq)
1361{
1362 if ((freq > (s_freq + 2)) && (freq <= (s_freq + 1202)) &&
1363 (s_freq >= 4000))
1364 return (freq + 2 - s_freq) / 5;
1365 else
1366 return -1;
1367}
1368
John W. Linville9387b7c2008-09-30 20:59:05 -04001369#endif /* LINUX_IEEE80211_H */