mac80211: remove unused type argument
[deliverable/linux.git] / include / linux / ieee80211.h
CommitLineData
a9de8ce0
JB
1/*
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
9387b7ca
JL
15#ifndef LINUX_IEEE80211_H
16#define LINUX_IEEE80211_H
a9de8ce0
JB
17
18#include <linux/types.h>
f97df02e 19#include <asm/byteorder.h>
a9de8ce0 20
3f46b29c
JB
21/*
22 * DS bit usage
23 *
24 * TA = transmitter address
25 * RA = receiver address
26 * DA = destination address
27 * SA = source address
28 *
29 * ToDS FromDS A1(RA) A2(TA) A3 A4 Use
30 * -----------------------------------------------------------------
31 * 0 0 DA SA BSSID - IBSS/DLS
32 * 0 1 DA BSSID SA - AP -> STA
33 * 1 0 BSSID SA DA - AP <- STA
34 * 1 1 RA TA DA SA unspecified (WDS)
35 */
36
a9de8ce0
JB
37#define FCS_LEN 4
38
39#define IEEE80211_FCTL_VERS 0x0003
40#define IEEE80211_FCTL_FTYPE 0x000c
41#define IEEE80211_FCTL_STYPE 0x00f0
42#define IEEE80211_FCTL_TODS 0x0100
43#define IEEE80211_FCTL_FROMDS 0x0200
44#define IEEE80211_FCTL_MOREFRAGS 0x0400
45#define IEEE80211_FCTL_RETRY 0x0800
46#define IEEE80211_FCTL_PM 0x1000
47#define IEEE80211_FCTL_MOREDATA 0x2000
48#define IEEE80211_FCTL_PROTECTED 0x4000
49#define IEEE80211_FCTL_ORDER 0x8000
50
51#define IEEE80211_SCTL_FRAG 0x000F
52#define IEEE80211_SCTL_SEQ 0xFFF0
53
54#define IEEE80211_FTYPE_MGMT 0x0000
55#define IEEE80211_FTYPE_CTL 0x0004
56#define IEEE80211_FTYPE_DATA 0x0008
57
58/* management */
59#define IEEE80211_STYPE_ASSOC_REQ 0x0000
60#define IEEE80211_STYPE_ASSOC_RESP 0x0010
61#define IEEE80211_STYPE_REASSOC_REQ 0x0020
62#define IEEE80211_STYPE_REASSOC_RESP 0x0030
63#define IEEE80211_STYPE_PROBE_REQ 0x0040
64#define IEEE80211_STYPE_PROBE_RESP 0x0050
65#define IEEE80211_STYPE_BEACON 0x0080
66#define IEEE80211_STYPE_ATIM 0x0090
67#define IEEE80211_STYPE_DISASSOC 0x00A0
68#define IEEE80211_STYPE_AUTH 0x00B0
69#define IEEE80211_STYPE_DEAUTH 0x00C0
70#define IEEE80211_STYPE_ACTION 0x00D0
71
72/* control */
6b4e3241
RR
73#define IEEE80211_STYPE_BACK_REQ 0x0080
74#define IEEE80211_STYPE_BACK 0x0090
a9de8ce0
JB
75#define IEEE80211_STYPE_PSPOLL 0x00A0
76#define IEEE80211_STYPE_RTS 0x00B0
77#define IEEE80211_STYPE_CTS 0x00C0
78#define IEEE80211_STYPE_ACK 0x00D0
79#define IEEE80211_STYPE_CFEND 0x00E0
80#define IEEE80211_STYPE_CFENDACK 0x00F0
81
82/* data */
83#define IEEE80211_STYPE_DATA 0x0000
84#define IEEE80211_STYPE_DATA_CFACK 0x0010
85#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
86#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
87#define IEEE80211_STYPE_NULLFUNC 0x0040
88#define IEEE80211_STYPE_CFACK 0x0050
89#define IEEE80211_STYPE_CFPOLL 0x0060
90#define IEEE80211_STYPE_CFACKPOLL 0x0070
91#define IEEE80211_STYPE_QOS_DATA 0x0080
92#define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
93#define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
94#define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
95#define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
96#define IEEE80211_STYPE_QOS_CFACK 0x00D0
97#define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
98#define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
99
100
101/* miscellaneous IEEE 802.11 constants */
c237899d
MW
102#define IEEE80211_MAX_FRAG_THRESHOLD 2352
103#define IEEE80211_MAX_RTS_THRESHOLD 2353
a9de8ce0
JB
104#define IEEE80211_MAX_AID 2007
105#define IEEE80211_MAX_TIM_LEN 251
a9de8ce0
JB
106/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
107 6.2.1.1.2.
108
c237899d
MW
109 802.11e clarifies the figure in section 7.1.2. The frame body is
110 up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
111#define IEEE80211_MAX_DATA_LEN 2304
112/* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
113#define IEEE80211_MAX_FRAME_LEN 2352
a9de8ce0
JB
114
115#define IEEE80211_MAX_SSID_LEN 32
1239cd58 116
37c57989 117#define IEEE80211_MAX_MESH_ID_LEN 32
1239cd58 118
fd7c8a40 119#define IEEE80211_QOS_CTL_LEN 2
238f74a2
HH
120#define IEEE80211_QOS_CTL_TID_MASK 0x000F
121#define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
a9de8ce0
JB
122
123struct ieee80211_hdr {
124 __le16 frame_control;
125 __le16 duration_id;
126 u8 addr1[6];
127 u8 addr2[6];
128 u8 addr3[6];
129 __le16 seq_ctrl;
130 u8 addr4[6];
131} __attribute__ ((packed));
132
7044cc56
KV
133struct ieee80211_hdr_3addr {
134 __le16 frame_control;
135 __le16 duration_id;
136 u8 addr1[6];
137 u8 addr2[6];
138 u8 addr3[6];
139 __le16 seq_ctrl;
140} __attribute__ ((packed));
141
fd7c8a40
HH
142/**
143 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
144 * @fc: frame control bytes in little-endian byteorder
145 */
146static inline int ieee80211_has_tods(__le16 fc)
147{
148 return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
149}
150
151/**
152 * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
153 * @fc: frame control bytes in little-endian byteorder
154 */
155static inline int ieee80211_has_fromds(__le16 fc)
156{
157 return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
158}
159
160/**
161 * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
162 * @fc: frame control bytes in little-endian byteorder
163 */
164static inline int ieee80211_has_a4(__le16 fc)
165{
166 __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
167 return (fc & tmp) == tmp;
168}
169
170/**
171 * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
172 * @fc: frame control bytes in little-endian byteorder
173 */
174static inline int ieee80211_has_morefrags(__le16 fc)
175{
176 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
177}
178
179/**
180 * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
181 * @fc: frame control bytes in little-endian byteorder
182 */
183static inline int ieee80211_has_retry(__le16 fc)
184{
185 return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
186}
187
188/**
189 * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
190 * @fc: frame control bytes in little-endian byteorder
191 */
192static inline int ieee80211_has_pm(__le16 fc)
193{
194 return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
195}
196
197/**
198 * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
199 * @fc: frame control bytes in little-endian byteorder
200 */
201static inline int ieee80211_has_moredata(__le16 fc)
202{
203 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
204}
205
206/**
207 * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
208 * @fc: frame control bytes in little-endian byteorder
209 */
210static inline int ieee80211_has_protected(__le16 fc)
211{
212 return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
213}
214
215/**
216 * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
217 * @fc: frame control bytes in little-endian byteorder
218 */
219static inline int ieee80211_has_order(__le16 fc)
220{
221 return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
222}
223
224/**
225 * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
226 * @fc: frame control bytes in little-endian byteorder
227 */
228static inline int ieee80211_is_mgmt(__le16 fc)
229{
230 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
231 cpu_to_le16(IEEE80211_FTYPE_MGMT);
232}
233
234/**
235 * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
236 * @fc: frame control bytes in little-endian byteorder
237 */
238static inline int ieee80211_is_ctl(__le16 fc)
239{
240 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
241 cpu_to_le16(IEEE80211_FTYPE_CTL);
242}
243
244/**
245 * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
246 * @fc: frame control bytes in little-endian byteorder
247 */
248static inline int ieee80211_is_data(__le16 fc)
249{
250 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
251 cpu_to_le16(IEEE80211_FTYPE_DATA);
252}
253
254/**
255 * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
256 * @fc: frame control bytes in little-endian byteorder
257 */
258static inline int ieee80211_is_data_qos(__le16 fc)
259{
260 /*
261 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
262 * to check the one bit
263 */
264 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
265 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
266}
267
268/**
269 * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
270 * @fc: frame control bytes in little-endian byteorder
271 */
272static inline int ieee80211_is_data_present(__le16 fc)
273{
274 /*
275 * mask with 0x40 and test that that bit is clear to only return true
276 * for the data-containing substypes.
277 */
278 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
279 cpu_to_le16(IEEE80211_FTYPE_DATA);
280}
281
282/**
283 * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
284 * @fc: frame control bytes in little-endian byteorder
285 */
286static inline int ieee80211_is_assoc_req(__le16 fc)
287{
288 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
289 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
290}
291
292/**
293 * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
294 * @fc: frame control bytes in little-endian byteorder
295 */
296static inline int ieee80211_is_assoc_resp(__le16 fc)
297{
298 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
299 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
300}
301
302/**
303 * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
304 * @fc: frame control bytes in little-endian byteorder
305 */
306static inline int ieee80211_is_reassoc_req(__le16 fc)
307{
308 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
309 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
310}
311
312/**
313 * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
314 * @fc: frame control bytes in little-endian byteorder
315 */
316static inline int ieee80211_is_reassoc_resp(__le16 fc)
317{
318 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
319 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
320}
321
322/**
323 * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
324 * @fc: frame control bytes in little-endian byteorder
325 */
326static inline int ieee80211_is_probe_req(__le16 fc)
327{
328 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
329 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
330}
331
332/**
333 * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
334 * @fc: frame control bytes in little-endian byteorder
335 */
336static inline int ieee80211_is_probe_resp(__le16 fc)
337{
338 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
339 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
340}
341
342/**
343 * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
344 * @fc: frame control bytes in little-endian byteorder
345 */
346static inline int ieee80211_is_beacon(__le16 fc)
347{
348 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
349 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
350}
351
352/**
353 * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
354 * @fc: frame control bytes in little-endian byteorder
355 */
356static inline int ieee80211_is_atim(__le16 fc)
357{
358 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
359 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
360}
361
362/**
363 * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
364 * @fc: frame control bytes in little-endian byteorder
365 */
366static inline int ieee80211_is_disassoc(__le16 fc)
367{
368 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
369 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
370}
371
372/**
373 * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
374 * @fc: frame control bytes in little-endian byteorder
375 */
376static inline int ieee80211_is_auth(__le16 fc)
377{
378 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
379 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
380}
381
382/**
383 * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
384 * @fc: frame control bytes in little-endian byteorder
385 */
386static inline int ieee80211_is_deauth(__le16 fc)
387{
388 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
389 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
390}
391
392/**
393 * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
394 * @fc: frame control bytes in little-endian byteorder
395 */
396static inline int ieee80211_is_action(__le16 fc)
397{
398 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
399 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
400}
401
402/**
403 * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
404 * @fc: frame control bytes in little-endian byteorder
405 */
406static inline int ieee80211_is_back_req(__le16 fc)
407{
408 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
409 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
410}
411
412/**
413 * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
414 * @fc: frame control bytes in little-endian byteorder
415 */
416static inline int ieee80211_is_back(__le16 fc)
417{
418 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
419 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
420}
421
422/**
423 * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
424 * @fc: frame control bytes in little-endian byteorder
425 */
426static inline int ieee80211_is_pspoll(__le16 fc)
427{
428 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
429 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
430}
431
432/**
433 * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
434 * @fc: frame control bytes in little-endian byteorder
435 */
436static inline int ieee80211_is_rts(__le16 fc)
437{
438 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
439 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
440}
441
442/**
443 * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
444 * @fc: frame control bytes in little-endian byteorder
445 */
446static inline int ieee80211_is_cts(__le16 fc)
447{
448 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
449 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
450}
451
452/**
453 * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
454 * @fc: frame control bytes in little-endian byteorder
455 */
456static inline int ieee80211_is_ack(__le16 fc)
457{
458 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
459 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
460}
461
462/**
463 * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
464 * @fc: frame control bytes in little-endian byteorder
465 */
466static inline int ieee80211_is_cfend(__le16 fc)
467{
468 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
469 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
470}
471
472/**
473 * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
474 * @fc: frame control bytes in little-endian byteorder
475 */
476static inline int ieee80211_is_cfendack(__le16 fc)
477{
478 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
479 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
480}
481
482/**
22403def 483 * ieee80211_is_nullfunc - check if frame is a regular (non-QoS) nullfunc frame
fd7c8a40
HH
484 * @fc: frame control bytes in little-endian byteorder
485 */
486static inline int ieee80211_is_nullfunc(__le16 fc)
487{
488 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
489 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
490}
a9de8ce0 491
22403def
JB
492/**
493 * ieee80211_is_qos_nullfunc - check if frame is a QoS nullfunc frame
494 * @fc: frame control bytes in little-endian byteorder
495 */
496static inline int ieee80211_is_qos_nullfunc(__le16 fc)
497{
498 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
499 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC);
500}
501
37c57989
LCC
502struct ieee80211s_hdr {
503 u8 flags;
504 u8 ttl;
51ceddad 505 __le32 seqnum;
37c57989
LCC
506 u8 eaddr1[6];
507 u8 eaddr2[6];
508 u8 eaddr3[6];
509} __attribute__ ((packed));
510
79617dee
Y
511/* Mesh flags */
512#define MESH_FLAGS_AE_A4 0x1
513#define MESH_FLAGS_AE_A5_A6 0x2
e31a16d6 514#define MESH_FLAGS_AE 0x3
79617dee
Y
515#define MESH_FLAGS_PS_DEEP 0x4
516
f2df3859
AK
517/**
518 * struct ieee80211_quiet_ie
519 *
520 * This structure refers to "Quiet information element"
521 */
522struct ieee80211_quiet_ie {
523 u8 count;
524 u8 period;
525 __le16 duration;
526 __le16 offset;
527} __attribute__ ((packed));
528
529/**
530 * struct ieee80211_msrment_ie
531 *
532 * This structure refers to "Measurement Request/Report information element"
533 */
534struct ieee80211_msrment_ie {
535 u8 token;
536 u8 mode;
537 u8 type;
538 u8 request[0];
539} __attribute__ ((packed));
540
541/**
542 * struct ieee80211_channel_sw_ie
543 *
544 * This structure refers to "Channel Switch Announcement information element"
545 */
546struct ieee80211_channel_sw_ie {
547 u8 mode;
548 u8 new_ch_num;
549 u8 count;
550} __attribute__ ((packed));
37c57989 551
98f7dfd8
EG
552/**
553 * struct ieee80211_tim
554 *
555 * This structure refers to "Traffic Indication Map information element"
556 */
557struct ieee80211_tim_ie {
558 u8 dtim_count;
559 u8 dtim_period;
560 u8 bitmap_ctrl;
561 /* variable size: 1 - 251 bytes */
e7ec86f5 562 u8 virtual_map[1];
98f7dfd8
EG
563} __attribute__ ((packed));
564
136cfa28
RP
565/**
566 * struct ieee80211_meshconf_ie
567 *
568 * This structure refers to "Mesh Configuration information element"
569 */
570struct ieee80211_meshconf_ie {
571 u8 meshconf_psel;
572 u8 meshconf_pmetric;
573 u8 meshconf_congest;
574 u8 meshconf_synch;
575 u8 meshconf_auth;
576 u8 meshconf_form;
577 u8 meshconf_cap;
578} __attribute__ ((packed));
579
90a5e169
RP
580/**
581 * struct ieee80211_rann_ie
582 *
583 * This structure refers to "Root Announcement information element"
584 */
585struct ieee80211_rann_ie {
586 u8 rann_flags;
587 u8 rann_hopcount;
588 u8 rann_ttl;
589 u8 rann_addr[6];
590 u32 rann_seq;
591 u32 rann_metric;
592} __attribute__ ((packed));
593
9dfd6ba3 594#define WLAN_SA_QUERY_TR_ID_LEN 2
fea14732 595
a9de8ce0
JB
596struct ieee80211_mgmt {
597 __le16 frame_control;
598 __le16 duration;
599 u8 da[6];
600 u8 sa[6];
601 u8 bssid[6];
602 __le16 seq_ctrl;
603 union {
604 struct {
605 __le16 auth_alg;
606 __le16 auth_transaction;
607 __le16 status_code;
608 /* possibly followed by Challenge text */
609 u8 variable[0];
610 } __attribute__ ((packed)) auth;
611 struct {
612 __le16 reason_code;
613 } __attribute__ ((packed)) deauth;
614 struct {
615 __le16 capab_info;
616 __le16 listen_interval;
617 /* followed by SSID and Supported rates */
618 u8 variable[0];
619 } __attribute__ ((packed)) assoc_req;
620 struct {
621 __le16 capab_info;
622 __le16 status_code;
623 __le16 aid;
624 /* followed by Supported rates */
625 u8 variable[0];
626 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
627 struct {
628 __le16 capab_info;
629 __le16 listen_interval;
630 u8 current_ap[6];
631 /* followed by SSID and Supported rates */
632 u8 variable[0];
633 } __attribute__ ((packed)) reassoc_req;
634 struct {
635 __le16 reason_code;
636 } __attribute__ ((packed)) disassoc;
637 struct {
638 __le64 timestamp;
639 __le16 beacon_int;
640 __le16 capab_info;
641 /* followed by some of SSID, Supported rates,
642 * FH Params, DS Params, CF Params, IBSS Params, TIM */
643 u8 variable[0];
644 } __attribute__ ((packed)) beacon;
645 struct {
646 /* only variable items: SSID, Supported rates */
647 u8 variable[0];
648 } __attribute__ ((packed)) probe_req;
649 struct {
650 __le64 timestamp;
651 __le16 beacon_int;
652 __le16 capab_info;
653 /* followed by some of SSID, Supported rates,
654 * FH Params, DS Params, CF Params, IBSS Params */
655 u8 variable[0];
656 } __attribute__ ((packed)) probe_resp;
657 struct {
658 u8 category;
659 union {
660 struct {
661 u8 action_code;
662 u8 dialog_token;
663 u8 status_code;
664 u8 variable[0];
665 } __attribute__ ((packed)) wme_action;
666 struct{
667 u8 action_code;
668 u8 element_id;
669 u8 length;
f2df3859 670 struct ieee80211_channel_sw_ie sw_elem;
a9de8ce0 671 } __attribute__((packed)) chan_switch;
f2df3859
AK
672 struct{
673 u8 action_code;
674 u8 dialog_token;
675 u8 element_id;
676 u8 length;
677 struct ieee80211_msrment_ie msr_elem;
678 } __attribute__((packed)) measurement;
6b4e3241
RR
679 struct{
680 u8 action_code;
681 u8 dialog_token;
682 __le16 capab;
683 __le16 timeout;
684 __le16 start_seq_num;
685 } __attribute__((packed)) addba_req;
686 struct{
687 u8 action_code;
688 u8 dialog_token;
689 __le16 status;
690 __le16 capab;
691 __le16 timeout;
692 } __attribute__((packed)) addba_resp;
693 struct{
694 u8 action_code;
695 __le16 params;
696 __le16 reason_code;
697 } __attribute__((packed)) delba;
37c57989
LCC
698 struct{
699 u8 action_code;
700 /* capab_info for open and confirm,
701 * reason for close
702 */
703 __le16 aux;
704 /* Followed in plink_confirm by status
705 * code, AID and supported rates,
706 * and directly by supported rates in
707 * plink_open and plink_close
708 */
709 u8 variable[0];
710 } __attribute__((packed)) plink_action;
711 struct{
712 u8 action_code;
713 u8 variable[0];
714 } __attribute__((packed)) mesh_action;
fea14732
JM
715 struct {
716 u8 action;
717 u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
718 } __attribute__ ((packed)) sa_query;
0f78231b
JB
719 struct {
720 u8 action;
721 u8 smps_control;
722 } __attribute__ ((packed)) ht_smps;
a9de8ce0
JB
723 } u;
724 } __attribute__ ((packed)) action;
725 } u;
726} __attribute__ ((packed));
727
44d414db
JB
728/* mgmt header + 1 byte category code */
729#define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
730
a9de8ce0 731
765cb46a
JM
732/* Management MIC information element (IEEE 802.11w) */
733struct ieee80211_mmie {
734 u8 element_id;
735 u8 length;
736 __le16 key_id;
737 u8 sequence_number[6];
738 u8 mic[8];
739} __attribute__ ((packed));
740
a9de8ce0
JB
741/* Control frames */
742struct ieee80211_rts {
743 __le16 frame_control;
744 __le16 duration;
745 u8 ra[6];
746 u8 ta[6];
747} __attribute__ ((packed));
748
749struct ieee80211_cts {
750 __le16 frame_control;
751 __le16 duration;
752 u8 ra[6];
753} __attribute__ ((packed));
754
fc6971d4
JM
755struct ieee80211_pspoll {
756 __le16 frame_control;
757 __le16 aid;
758 u8 bssid[6];
759 u8 ta[6];
760} __attribute__ ((packed));
761
6b4e3241
RR
762/**
763 * struct ieee80211_bar - HT Block Ack Request
764 *
765 * This structure refers to "HT BlockAckReq" as
766 * described in 802.11n draft section 7.2.1.7.1
767 */
768struct ieee80211_bar {
769 __le16 frame_control;
770 __le16 duration;
771 __u8 ra[6];
772 __u8 ta[6];
a8b47ea3
RR
773 __le16 control;
774 __le16 start_seq_num;
6b4e3241
RR
775} __attribute__((packed));
776
429a3805
RR
777/* 802.11 BAR control masks */
778#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
779#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
780
d9fe60de
JB
781
782#define IEEE80211_HT_MCS_MASK_LEN 10
783
784/**
785 * struct ieee80211_mcs_info - MCS information
786 * @rx_mask: RX mask
9da3e068
LR
787 * @rx_highest: highest supported RX rate. If set represents
788 * the highest supported RX data rate in units of 1 Mbps.
789 * If this field is 0 this value should not be used to
790 * consider the highest RX data rate supported.
d9fe60de
JB
791 * @tx_params: TX parameters
792 */
793struct ieee80211_mcs_info {
794 u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN];
795 __le16 rx_highest;
796 u8 tx_params;
797 u8 reserved[3];
798} __attribute__((packed));
799
800/* 802.11n HT capability MSC set */
801#define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3ff
802#define IEEE80211_HT_MCS_TX_DEFINED 0x01
803#define IEEE80211_HT_MCS_TX_RX_DIFF 0x02
804/* value 0 == 1 stream etc */
805#define IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK 0x0C
806#define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2
807#define IEEE80211_HT_MCS_TX_MAX_STREAMS 4
808#define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10
809
810/*
811 * 802.11n D5.0 20.3.5 / 20.6 says:
812 * - indices 0 to 7 and 32 are single spatial stream
813 * - 8 to 31 are multiple spatial streams using equal modulation
814 * [8..15 for two streams, 16..23 for three and 24..31 for four]
815 * - remainder are multiple spatial streams using unequal modulation
816 */
817#define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START 33
818#define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE \
819 (IEEE80211_HT_MCS_UNEQUAL_MODULATION_START / 8)
820
6b4e3241
RR
821/**
822 * struct ieee80211_ht_cap - HT capabilities
823 *
d9fe60de
JB
824 * This structure is the "HT capabilities element" as
825 * described in 802.11n D5.0 7.3.2.57
6b4e3241
RR
826 */
827struct ieee80211_ht_cap {
828 __le16 cap_info;
829 u8 ampdu_params_info;
d9fe60de
JB
830
831 /* 16 bytes MCS information */
832 struct ieee80211_mcs_info mcs;
833
6b4e3241
RR
834 __le16 extended_ht_cap_info;
835 __le32 tx_BF_cap_info;
836 u8 antenna_selection_info;
837} __attribute__ ((packed));
838
d9fe60de
JB
839/* 802.11n HT capabilities masks (for cap_info) */
840#define IEEE80211_HT_CAP_LDPC_CODING 0x0001
841#define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002
842#define IEEE80211_HT_CAP_SM_PS 0x000C
0f78231b 843#define IEEE80211_HT_CAP_SM_PS_SHIFT 2
d9fe60de
JB
844#define IEEE80211_HT_CAP_GRN_FLD 0x0010
845#define IEEE80211_HT_CAP_SGI_20 0x0020
846#define IEEE80211_HT_CAP_SGI_40 0x0040
847#define IEEE80211_HT_CAP_TX_STBC 0x0080
848#define IEEE80211_HT_CAP_RX_STBC 0x0300
849#define IEEE80211_HT_CAP_DELAY_BA 0x0400
850#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
851#define IEEE80211_HT_CAP_DSSSCCK40 0x1000
9a418af5 852#define IEEE80211_HT_CAP_RESERVED 0x2000
d9fe60de
JB
853#define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
854#define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
855
856/* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
857#define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03
858#define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C
0f78231b 859#define IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT 2
d9fe60de 860
d1eba248
S
861/*
862 * Maximum length of AMPDU that the STA can receive.
863 * Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
864 */
865enum ieee80211_max_ampdu_length_exp {
866 IEEE80211_HT_MAX_AMPDU_8K = 0,
867 IEEE80211_HT_MAX_AMPDU_16K = 1,
868 IEEE80211_HT_MAX_AMPDU_32K = 2,
869 IEEE80211_HT_MAX_AMPDU_64K = 3
870};
871
872#define IEEE80211_HT_MAX_AMPDU_FACTOR 13
873
874/* Minimum MPDU start spacing */
875enum ieee80211_min_mpdu_spacing {
876 IEEE80211_HT_MPDU_DENSITY_NONE = 0, /* No restriction */
877 IEEE80211_HT_MPDU_DENSITY_0_25 = 1, /* 1/4 usec */
878 IEEE80211_HT_MPDU_DENSITY_0_5 = 2, /* 1/2 usec */
879 IEEE80211_HT_MPDU_DENSITY_1 = 3, /* 1 usec */
880 IEEE80211_HT_MPDU_DENSITY_2 = 4, /* 2 usec */
881 IEEE80211_HT_MPDU_DENSITY_4 = 5, /* 4 usec */
882 IEEE80211_HT_MPDU_DENSITY_8 = 6, /* 8 usec */
883 IEEE80211_HT_MPDU_DENSITY_16 = 7 /* 16 usec */
884};
885
6b4e3241 886/**
d9fe60de 887 * struct ieee80211_ht_info - HT information
6b4e3241 888 *
d9fe60de
JB
889 * This structure is the "HT information element" as
890 * described in 802.11n D5.0 7.3.2.58
6b4e3241 891 */
d9fe60de 892struct ieee80211_ht_info {
6b4e3241
RR
893 u8 control_chan;
894 u8 ht_param;
895 __le16 operation_mode;
896 __le16 stbc_param;
897 u8 basic_set[16];
898} __attribute__ ((packed));
899
d9fe60de
JB
900/* for ht_param */
901#define IEEE80211_HT_PARAM_CHA_SEC_OFFSET 0x03
902#define IEEE80211_HT_PARAM_CHA_SEC_NONE 0x00
903#define IEEE80211_HT_PARAM_CHA_SEC_ABOVE 0x01
904#define IEEE80211_HT_PARAM_CHA_SEC_BELOW 0x03
905#define IEEE80211_HT_PARAM_CHAN_WIDTH_ANY 0x04
906#define IEEE80211_HT_PARAM_RIFS_MODE 0x08
907#define IEEE80211_HT_PARAM_SPSMP_SUPPORT 0x10
908#define IEEE80211_HT_PARAM_SERV_INTERVAL_GRAN 0xE0
909
910/* for operation_mode */
911#define IEEE80211_HT_OP_MODE_PROTECTION 0x0003
912#define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0
913#define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 1
914#define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 2
915#define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 3
916#define IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT 0x0004
917#define IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT 0x0010
918
919/* for stbc_param */
920#define IEEE80211_HT_STBC_PARAM_DUAL_BEACON 0x0040
921#define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080
922#define IEEE80211_HT_STBC_PARAM_STBC_BEACON 0x0100
923#define IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT 0x0200
924#define IEEE80211_HT_STBC_PARAM_PCO_ACTIVE 0x0400
925#define IEEE80211_HT_STBC_PARAM_PCO_PHASE 0x0800
926
a9de8ce0 927
44d414db
JB
928/* block-ack parameters */
929#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
930#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
931#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
932#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
933#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
934
935/*
936 * A-PMDU buffer sizes
937 * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
938 */
939#define IEEE80211_MIN_AMPDU_BUF 0x8
940#define IEEE80211_MAX_AMPDU_BUF 0x40
941
942
0f78231b 943/* Spatial Multiplexing Power Save Modes (for capability) */
00c5ae2f
TW
944#define WLAN_HT_CAP_SM_PS_STATIC 0
945#define WLAN_HT_CAP_SM_PS_DYNAMIC 1
946#define WLAN_HT_CAP_SM_PS_INVALID 2
947#define WLAN_HT_CAP_SM_PS_DISABLED 3
e53cfe0e 948
0f78231b
JB
949/* for SM power control field lower two bits */
950#define WLAN_HT_SMPS_CONTROL_DISABLED 0
951#define WLAN_HT_SMPS_CONTROL_STATIC 1
952#define WLAN_HT_SMPS_CONTROL_DYNAMIC 3
953
a9de8ce0
JB
954/* Authentication algorithms */
955#define WLAN_AUTH_OPEN 0
956#define WLAN_AUTH_SHARED_KEY 1
636a5d36 957#define WLAN_AUTH_FT 2
bb608e9d 958#define WLAN_AUTH_LEAP 128
a9de8ce0
JB
959
960#define WLAN_AUTH_CHALLENGE_LEN 128
961
962#define WLAN_CAPABILITY_ESS (1<<0)
963#define WLAN_CAPABILITY_IBSS (1<<1)
964#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
965#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
966#define WLAN_CAPABILITY_PRIVACY (1<<4)
967#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
968#define WLAN_CAPABILITY_PBCC (1<<6)
969#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
b6623486 970
a9de8ce0
JB
971/* 802.11h */
972#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
973#define WLAN_CAPABILITY_QOS (1<<9)
974#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
975#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
b6623486
AK
976/* measurement */
977#define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
978#define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
979#define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
980
981#define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
982#define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
983#define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
984
a9de8ce0 985
5628221c
DD
986/* 802.11g ERP information element */
987#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
988#define WLAN_ERP_USE_PROTECTION (1<<1)
989#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
990
991/* WLAN_ERP_BARKER_PREAMBLE values */
992enum {
993 WLAN_ERP_PREAMBLE_SHORT = 0,
994 WLAN_ERP_PREAMBLE_LONG = 1,
995};
996
a9de8ce0
JB
997/* Status codes */
998enum ieee80211_statuscode {
999 WLAN_STATUS_SUCCESS = 0,
1000 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
1001 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
1002 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
1003 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
1004 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
1005 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
1006 WLAN_STATUS_CHALLENGE_FAIL = 15,
1007 WLAN_STATUS_AUTH_TIMEOUT = 16,
1008 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
1009 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
1010 /* 802.11b */
1011 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
1012 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
1013 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
1014 /* 802.11h */
1015 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
1016 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
1017 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
1018 /* 802.11g */
1019 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
1020 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
63a5ab82
JM
1021 /* 802.11w */
1022 WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY = 30,
1023 WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31,
a9de8ce0
JB
1024 /* 802.11i */
1025 WLAN_STATUS_INVALID_IE = 40,
1026 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
1027 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
1028 WLAN_STATUS_INVALID_AKMP = 43,
1029 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
1030 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
1031 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
6b4e3241
RR
1032 /* 802.11e */
1033 WLAN_STATUS_UNSPECIFIED_QOS = 32,
1034 WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
1035 WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
1036 WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
1037 WLAN_STATUS_REQUEST_DECLINED = 37,
1038 WLAN_STATUS_INVALID_QOS_PARAM = 38,
1039 WLAN_STATUS_CHANGE_TSPEC = 39,
1040 WLAN_STATUS_WAIT_TS_DELAY = 47,
1041 WLAN_STATUS_NO_DIRECT_LINK = 48,
1042 WLAN_STATUS_STA_NOT_PRESENT = 49,
1043 WLAN_STATUS_STA_NOT_QSTA = 50,
a9de8ce0
JB
1044};
1045
1046
1047/* Reason codes */
1048enum ieee80211_reasoncode {
1049 WLAN_REASON_UNSPECIFIED = 1,
1050 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
1051 WLAN_REASON_DEAUTH_LEAVING = 3,
1052 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
1053 WLAN_REASON_DISASSOC_AP_BUSY = 5,
1054 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
1055 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
1056 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
1057 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
1058 /* 802.11h */
1059 WLAN_REASON_DISASSOC_BAD_POWER = 10,
1060 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
1061 /* 802.11i */
1062 WLAN_REASON_INVALID_IE = 13,
1063 WLAN_REASON_MIC_FAILURE = 14,
1064 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
1065 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
1066 WLAN_REASON_IE_DIFFERENT = 17,
1067 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
1068 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
1069 WLAN_REASON_INVALID_AKMP = 20,
1070 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
1071 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
1072 WLAN_REASON_IEEE8021X_FAILED = 23,
1073 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
6b4e3241
RR
1074 /* 802.11e */
1075 WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
1076 WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
1077 WLAN_REASON_DISASSOC_LOW_ACK = 34,
1078 WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
1079 WLAN_REASON_QSTA_LEAVE_QBSS = 36,
1080 WLAN_REASON_QSTA_NOT_USE = 37,
1081 WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
1082 WLAN_REASON_QSTA_TIMEOUT = 39,
1083 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
a9de8ce0
JB
1084};
1085
1086
1087/* Information Element IDs */
1088enum ieee80211_eid {
1089 WLAN_EID_SSID = 0,
1090 WLAN_EID_SUPP_RATES = 1,
1091 WLAN_EID_FH_PARAMS = 2,
1092 WLAN_EID_DS_PARAMS = 3,
1093 WLAN_EID_CF_PARAMS = 4,
1094 WLAN_EID_TIM = 5,
1095 WLAN_EID_IBSS_PARAMS = 6,
1096 WLAN_EID_CHALLENGE = 16,
8e664fb3 1097
a9de8ce0
JB
1098 WLAN_EID_COUNTRY = 7,
1099 WLAN_EID_HP_PARAMS = 8,
1100 WLAN_EID_HP_TABLE = 9,
1101 WLAN_EID_REQUEST = 10,
8e664fb3 1102
6b4e3241
RR
1103 WLAN_EID_QBSS_LOAD = 11,
1104 WLAN_EID_EDCA_PARAM_SET = 12,
1105 WLAN_EID_TSPEC = 13,
1106 WLAN_EID_TCLAS = 14,
1107 WLAN_EID_SCHEDULE = 15,
1108 WLAN_EID_TS_DELAY = 43,
1109 WLAN_EID_TCLAS_PROCESSING = 44,
1110 WLAN_EID_QOS_CAPA = 46,
d619ee08
LCC
1111 /* 802.11s
1112 *
1113 * All mesh EID numbers are pending IEEE 802.11 ANA approval.
1114 * The numbers have been incremented from those suggested in
1115 * 802.11s/D2.0 so that MESH_CONFIG does not conflict with
1116 * EXT_SUPP_RATES.
1117 */
1118 WLAN_EID_MESH_CONFIG = 51,
1119 WLAN_EID_MESH_ID = 52,
1120 WLAN_EID_PEER_LINK = 55,
1121 WLAN_EID_PREQ = 68,
1122 WLAN_EID_PREP = 69,
1123 WLAN_EID_PERR = 70,
90a5e169 1124 WLAN_EID_RANN = 49, /* compatible with FreeBSD */
8e664fb3 1125
a9de8ce0
JB
1126 WLAN_EID_PWR_CONSTRAINT = 32,
1127 WLAN_EID_PWR_CAPABILITY = 33,
1128 WLAN_EID_TPC_REQUEST = 34,
1129 WLAN_EID_TPC_REPORT = 35,
1130 WLAN_EID_SUPPORTED_CHANNELS = 36,
1131 WLAN_EID_CHANNEL_SWITCH = 37,
1132 WLAN_EID_MEASURE_REQUEST = 38,
1133 WLAN_EID_MEASURE_REPORT = 39,
1134 WLAN_EID_QUIET = 40,
1135 WLAN_EID_IBSS_DFS = 41,
8e664fb3 1136
a9de8ce0
JB
1137 WLAN_EID_ERP_INFO = 42,
1138 WLAN_EID_EXT_SUPP_RATES = 50,
8e664fb3 1139
6b4e3241 1140 WLAN_EID_HT_CAPABILITY = 45,
d9fe60de 1141 WLAN_EID_HT_INFORMATION = 61,
8e664fb3 1142
a9de8ce0 1143 WLAN_EID_RSN = 48,
8e664fb3 1144 WLAN_EID_MMIE = 76,
a9de8ce0
JB
1145 WLAN_EID_WPA = 221,
1146 WLAN_EID_GENERIC = 221,
1147 WLAN_EID_VENDOR_SPECIFIC = 221,
8e664fb3
JB
1148 WLAN_EID_QOS_PARAMETER = 222,
1149
1150 WLAN_EID_AP_CHAN_REPORT = 51,
1151 WLAN_EID_NEIGHBOR_REPORT = 52,
1152 WLAN_EID_RCPI = 53,
1153 WLAN_EID_BSS_AVG_ACCESS_DELAY = 63,
1154 WLAN_EID_ANTENNA_INFO = 64,
1155 WLAN_EID_RSNI = 65,
1156 WLAN_EID_MEASUREMENT_PILOT_TX_INFO = 66,
1157 WLAN_EID_BSS_AVAILABLE_CAPACITY = 67,
1158 WLAN_EID_BSS_AC_ACCESS_DELAY = 68,
1159 WLAN_EID_RRM_ENABLED_CAPABILITIES = 70,
1160 WLAN_EID_MULTIPLE_BSSID = 71,
1161
1162 WLAN_EID_MOBILITY_DOMAIN = 54,
1163 WLAN_EID_FAST_BSS_TRANSITION = 55,
1164 WLAN_EID_TIMEOUT_INTERVAL = 56,
1165 WLAN_EID_RIC_DATA = 57,
1166 WLAN_EID_RIC_DESCRIPTOR = 75,
1167
1168 WLAN_EID_DSE_REGISTERED_LOCATION = 58,
1169 WLAN_EID_SUPPORTED_REGULATORY_CLASSES = 59,
1170 WLAN_EID_EXT_CHANSWITCH_ANN = 60,
a9de8ce0
JB
1171};
1172
6b4e3241
RR
1173/* Action category code */
1174enum ieee80211_category {
1175 WLAN_CATEGORY_SPECTRUM_MGMT = 0,
1176 WLAN_CATEGORY_QOS = 1,
1177 WLAN_CATEGORY_DLS = 2,
1178 WLAN_CATEGORY_BACK = 3,
fb733336 1179 WLAN_CATEGORY_PUBLIC = 4,
528769cf 1180 WLAN_CATEGORY_HT = 7,
fea14732 1181 WLAN_CATEGORY_SA_QUERY = 8,
528769cf 1182 WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9,
6b4e3241 1183 WLAN_CATEGORY_WMM = 17,
528769cf
JM
1184 WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126,
1185 WLAN_CATEGORY_VENDOR_SPECIFIC = 127,
6b4e3241
RR
1186};
1187
f2df3859
AK
1188/* SPECTRUM_MGMT action code */
1189enum ieee80211_spectrum_mgmt_actioncode {
1190 WLAN_ACTION_SPCT_MSR_REQ = 0,
1191 WLAN_ACTION_SPCT_MSR_RPRT = 1,
1192 WLAN_ACTION_SPCT_TPC_REQ = 2,
1193 WLAN_ACTION_SPCT_TPC_RPRT = 3,
1194 WLAN_ACTION_SPCT_CHL_SWITCH = 4,
1195};
1196
0f78231b
JB
1197/* HT action codes */
1198enum ieee80211_ht_actioncode {
1199 WLAN_HT_ACTION_NOTIFY_CHANWIDTH = 0,
1200 WLAN_HT_ACTION_SMPS = 1,
1201 WLAN_HT_ACTION_PSMP = 2,
1202 WLAN_HT_ACTION_PCO_PHASE = 3,
1203 WLAN_HT_ACTION_CSI = 4,
1204 WLAN_HT_ACTION_NONCOMPRESSED_BF = 5,
1205 WLAN_HT_ACTION_COMPRESSED_BF = 6,
1206 WLAN_HT_ACTION_ASEL_IDX_FEEDBACK = 7,
1207};
1208
e31a16d6
ZY
1209/* Security key length */
1210enum ieee80211_key_len {
1211 WLAN_KEY_LEN_WEP40 = 5,
1212 WLAN_KEY_LEN_WEP104 = 13,
1213 WLAN_KEY_LEN_CCMP = 16,
1214 WLAN_KEY_LEN_TKIP = 32,
8fc0fee0 1215 WLAN_KEY_LEN_AES_CMAC = 16,
e31a16d6
ZY
1216};
1217
3f2355cb
LR
1218/*
1219 * IEEE 802.11-2007 7.3.2.9 Country information element
1220 *
1221 * Minimum length is 8 octets, ie len must be evenly
1222 * divisible by 2
1223 */
1224
1225/* Although the spec says 8 I'm seeing 6 in practice */
1226#define IEEE80211_COUNTRY_IE_MIN_LEN 6
1227
1228/*
1229 * For regulatory extension stuff see IEEE 802.11-2007
1230 * Annex I (page 1141) and Annex J (page 1147). Also
1231 * review 7.3.2.9.
1232 *
1233 * When dot11RegulatoryClassesRequired is true and the
1234 * first_channel/reg_extension_id is >= 201 then the IE
1235 * compromises of the 'ext' struct represented below:
1236 *
1237 * - Regulatory extension ID - when generating IE this just needs
1238 * to be monotonically increasing for each triplet passed in
1239 * the IE
1240 * - Regulatory class - index into set of rules
1241 * - Coverage class - index into air propagation time (Table 7-27),
1242 * in microseconds, you can compute the air propagation time from
1243 * the index by multiplying by 3, so index 10 yields a propagation
1244 * of 10 us. Valid values are 0-31, values 32-255 are not defined
1245 * yet. A value of 0 inicates air propagation of <= 1 us.
1246 *
1247 * See also Table I.2 for Emission limit sets and table
1248 * I.3 for Behavior limit sets. Table J.1 indicates how to map
1249 * a reg_class to an emission limit set and behavior limit set.
1250 */
1251#define IEEE80211_COUNTRY_EXTENSION_ID 201
1252
1253/*
1254 * Channels numbers in the IE must be monotonically increasing
1255 * if dot11RegulatoryClassesRequired is not true.
1256 *
1257 * If dot11RegulatoryClassesRequired is true consecutive
1258 * subband triplets following a regulatory triplet shall
1259 * have monotonically increasing first_channel number fields.
1260 *
1261 * Channel numbers shall not overlap.
1262 *
1263 * Note that max_power is signed.
1264 */
1265struct ieee80211_country_ie_triplet {
1266 union {
1267 struct {
1268 u8 first_channel;
1269 u8 num_channels;
1270 s8 max_power;
1271 } __attribute__ ((packed)) chans;
1272 struct {
1273 u8 reg_extension_id;
1274 u8 reg_class;
1275 u8 coverage_class;
1276 } __attribute__ ((packed)) ext;
1277 };
1278} __attribute__ ((packed));
1279
f797eb7e
JM
1280enum ieee80211_timeout_interval_type {
1281 WLAN_TIMEOUT_REASSOC_DEADLINE = 1 /* 802.11r */,
1282 WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */,
1283 WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
1284};
1285
6b4e3241
RR
1286/* BACK action code */
1287enum ieee80211_back_actioncode {
1288 WLAN_ACTION_ADDBA_REQ = 0,
1289 WLAN_ACTION_ADDBA_RESP = 1,
1290 WLAN_ACTION_DELBA = 2,
1291};
1292
07db2183
RR
1293/* BACK (block-ack) parties */
1294enum ieee80211_back_parties {
1295 WLAN_BACK_RECIPIENT = 0,
1296 WLAN_BACK_INITIATOR = 1,
1297 WLAN_BACK_TIMER = 2,
1298};
1299
fea14732
JM
1300/* SA Query action */
1301enum ieee80211_sa_query_action {
1302 WLAN_ACTION_SA_QUERY_REQUEST = 0,
1303 WLAN_ACTION_SA_QUERY_RESPONSE = 1,
1304};
1305
1306
6b4e3241
RR
1307/* A-MSDU 802.11n */
1308#define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
1309
a9de8ce0
JB
1310/* cipher suite selectors */
1311#define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
1312#define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
1313#define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
1314/* reserved: 0x000FAC03 */
1315#define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
1316#define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
3cfcf6ac 1317#define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06
a9de8ce0 1318
6a669e65
JB
1319/* AKM suite selectors */
1320#define WLAN_AKM_SUITE_8021X 0x000FAC01
1321#define WLAN_AKM_SUITE_PSK 0x000FAC02
1322
a9de8ce0
JB
1323#define WLAN_MAX_KEY_LEN 32
1324
67fbb16b
SO
1325#define WLAN_PMKID_LEN 16
1326
fd7c8a40
HH
1327/**
1328 * ieee80211_get_qos_ctl - get pointer to qos control bytes
1329 * @hdr: the frame
1330 *
1331 * The qos ctrl bytes come after the frame_control, duration, seq_num
1332 * and 3 or 4 addresses of length ETH_ALEN.
1333 * 3 addr: 2 + 2 + 2 + 3*6 = 24
1334 * 4 addr: 2 + 2 + 2 + 4*6 = 30
1335 */
1336static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
1337{
1338 if (ieee80211_has_a4(hdr->frame_control))
1339 return (u8 *)hdr + 30;
1340 else
1341 return (u8 *)hdr + 24;
1342}
1343
f97df02e
JB
1344/**
1345 * ieee80211_get_SA - get pointer to SA
fd7c8a40 1346 * @hdr: the frame
f97df02e
JB
1347 *
1348 * Given an 802.11 frame, this function returns the offset
1349 * to the source address (SA). It does not verify that the
1350 * header is long enough to contain the address, and the
1351 * header must be long enough to contain the frame control
1352 * field.
f97df02e
JB
1353 */
1354static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
1355{
fd7c8a40 1356 if (ieee80211_has_a4(hdr->frame_control))
5a433b3a 1357 return hdr->addr4;
fd7c8a40
HH
1358 if (ieee80211_has_fromds(hdr->frame_control))
1359 return hdr->addr3;
1360 return hdr->addr2;
f97df02e
JB
1361}
1362
1363/**
1364 * ieee80211_get_DA - get pointer to DA
fd7c8a40 1365 * @hdr: the frame
f97df02e
JB
1366 *
1367 * Given an 802.11 frame, this function returns the offset
1368 * to the destination address (DA). It does not verify that
1369 * the header is long enough to contain the address, and the
1370 * header must be long enough to contain the frame control
1371 * field.
f97df02e
JB
1372 */
1373static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1374{
fd7c8a40 1375 if (ieee80211_has_tods(hdr->frame_control))
f97df02e 1376 return hdr->addr3;
5a433b3a
HH
1377 else
1378 return hdr->addr1;
f97df02e
JB
1379}
1380
fb733336
JM
1381/**
1382 * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
1383 * @hdr: the frame (buffer must include at least the first octet of payload)
1384 */
1385static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
1386{
1387 if (ieee80211_is_disassoc(hdr->frame_control) ||
1388 ieee80211_is_deauth(hdr->frame_control))
1389 return true;
1390
1391 if (ieee80211_is_action(hdr->frame_control)) {
1392 u8 *category;
1393
1394 /*
1395 * Action frames, excluding Public Action frames, are Robust
1396 * Management Frames. However, if we are looking at a Protected
1397 * frame, skip the check since the data may be encrypted and
1398 * the frame has already been found to be a Robust Management
1399 * Frame (by the other end).
1400 */
1401 if (ieee80211_has_protected(hdr->frame_control))
1402 return true;
1403 category = ((u8 *) hdr) + 24;
528769cf
JM
1404 return *category != WLAN_CATEGORY_PUBLIC &&
1405 *category != WLAN_CATEGORY_HT &&
1406 *category != WLAN_CATEGORY_VENDOR_SPECIFIC;
fb733336
JM
1407 }
1408
1409 return false;
1410}
1411
9ee677c2
DK
1412/**
1413 * ieee80211_fhss_chan_to_freq - get channel frequency
1414 * @channel: the FHSS channel
1415 *
1416 * Convert IEEE802.11 FHSS channel to frequency (MHz)
1417 * Ref IEEE 802.11-2007 section 14.6
1418 */
1419static inline int ieee80211_fhss_chan_to_freq(int channel)
1420{
1421 if ((channel > 1) && (channel < 96))
1422 return channel + 2400;
1423 else
1424 return -1;
1425}
1426
1427/**
1428 * ieee80211_freq_to_fhss_chan - get channel
1429 * @freq: the channels frequency
1430 *
1431 * Convert frequency (MHz) to IEEE802.11 FHSS channel
1432 * Ref IEEE 802.11-2007 section 14.6
1433 */
1434static inline int ieee80211_freq_to_fhss_chan(int freq)
1435{
1436 if ((freq > 2401) && (freq < 2496))
1437 return freq - 2400;
1438 else
1439 return -1;
1440}
1441
1442/**
1443 * ieee80211_dsss_chan_to_freq - get channel center frequency
1444 * @channel: the DSSS channel
1445 *
1446 * Convert IEEE802.11 DSSS channel to the center frequency (MHz).
1447 * Ref IEEE 802.11-2007 section 15.6
1448 */
1449static inline int ieee80211_dsss_chan_to_freq(int channel)
1450{
1451 if ((channel > 0) && (channel < 14))
1452 return 2407 + (channel * 5);
1453 else if (channel == 14)
1454 return 2484;
1455 else
1456 return -1;
1457}
1458
1459/**
1460 * ieee80211_freq_to_dsss_chan - get channel
1461 * @freq: the frequency
1462 *
1463 * Convert frequency (MHz) to IEEE802.11 DSSS channel
1464 * Ref IEEE 802.11-2007 section 15.6
1465 *
1466 * This routine selects the channel with the closest center frequency.
1467 */
1468static inline int ieee80211_freq_to_dsss_chan(int freq)
1469{
1470 if ((freq >= 2410) && (freq < 2475))
1471 return (freq - 2405) / 5;
1472 else if ((freq >= 2482) && (freq < 2487))
1473 return 14;
1474 else
1475 return -1;
1476}
1477
1478/* Convert IEEE802.11 HR DSSS channel to frequency (MHz) and back
1479 * Ref IEEE 802.11-2007 section 18.4.6.2
1480 *
1481 * The channels and frequencies are the same as those defined for DSSS
1482 */
1483#define ieee80211_hr_chan_to_freq(chan) ieee80211_dsss_chan_to_freq(chan)
1484#define ieee80211_freq_to_hr_chan(freq) ieee80211_freq_to_dsss_chan(freq)
1485
1486/* Convert IEEE802.11 ERP channel to frequency (MHz) and back
1487 * Ref IEEE 802.11-2007 section 19.4.2
1488 */
1489#define ieee80211_erp_chan_to_freq(chan) ieee80211_hr_chan_to_freq(chan)
1490#define ieee80211_freq_to_erp_chan(freq) ieee80211_freq_to_hr_chan(freq)
1491
1492/**
1493 * ieee80211_ofdm_chan_to_freq - get channel center frequency
1494 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
1495 * @channel: the OFDM channel
1496 *
1497 * Convert IEEE802.11 OFDM channel to center frequency (MHz)
1498 * Ref IEEE 802.11-2007 section 17.3.8.3.2
1499 */
1500static inline int ieee80211_ofdm_chan_to_freq(int s_freq, int channel)
1501{
1502 if ((channel > 0) && (channel <= 200) &&
1503 (s_freq >= 4000))
1504 return s_freq + (channel * 5);
1505 else
1506 return -1;
1507}
1508
1509/**
1510 * ieee80211_freq_to_ofdm_channel - get channel
1511 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
1512 * @freq: the frequency
1513 *
1514 * Convert frequency (MHz) to IEEE802.11 OFDM channel
1515 * Ref IEEE 802.11-2007 section 17.3.8.3.2
1516 *
1517 * This routine selects the channel with the closest center frequency.
1518 */
1519static inline int ieee80211_freq_to_ofdm_chan(int s_freq, int freq)
1520{
1521 if ((freq > (s_freq + 2)) && (freq <= (s_freq + 1202)) &&
1522 (s_freq >= 4000))
1523 return (freq + 2 - s_freq) / 5;
1524 else
1525 return -1;
1526}
1527
10f644a4
JB
1528/**
1529 * ieee80211_tu_to_usec - convert time units (TU) to microseconds
1530 * @tu: the TUs
1531 */
1532static inline unsigned long ieee80211_tu_to_usec(unsigned long tu)
1533{
1534 return 1024 * tu;
1535}
1536
e7ec86f5
JB
1537/**
1538 * ieee80211_check_tim - check if AID bit is set in TIM
1539 * @tim: the TIM IE
1540 * @tim_len: length of the TIM IE
1541 * @aid: the AID to look for
1542 */
1543static inline bool ieee80211_check_tim(struct ieee80211_tim_ie *tim,
1544 u8 tim_len, u16 aid)
1545{
1546 u8 mask;
1547 u8 index, indexn1, indexn2;
1548
1549 if (unlikely(!tim || tim_len < sizeof(*tim)))
1550 return false;
1551
1552 aid &= 0x3fff;
1553 index = aid / 8;
1554 mask = 1 << (aid & 7);
1555
1556 indexn1 = tim->bitmap_ctrl & 0xfe;
1557 indexn2 = tim_len + indexn1 - 4;
1558
1559 if (index < indexn1 || index > indexn2)
1560 return false;
1561
1562 index -= indexn1;
1563
1564 return !!(tim->virtual_map[index] & mask);
1565}
1566
9387b7ca 1567#endif /* LINUX_IEEE80211_H */
This page took 0.758952 seconds and 5 git commands to generate.