4 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
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>
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.
18 #include <linux/types.h>
19 #include <asm/byteorder.h>
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
35 #define IEEE80211_SCTL_FRAG 0x000F
36 #define IEEE80211_SCTL_SEQ 0xFFF0
38 #define IEEE80211_FTYPE_MGMT 0x0000
39 #define IEEE80211_FTYPE_CTL 0x0004
40 #define IEEE80211_FTYPE_DATA 0x0008
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
57 #define IEEE80211_STYPE_BACK_REQ 0x0080
58 #define IEEE80211_STYPE_BACK 0x0090
59 #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
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
85 /* miscellaneous IEEE 802.11 constants */
86 #define IEEE80211_MAX_FRAG_THRESHOLD 2352
87 #define IEEE80211_MAX_RTS_THRESHOLD 2353
88 #define IEEE80211_MAX_AID 2007
89 #define IEEE80211_MAX_TIM_LEN 251
90 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
93 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
99 #define IEEE80211_MAX_SSID_LEN 32
100 #define IEEE80211_MAX_MESH_ID_LEN 32
101 #define IEEE80211_QOS_CTL_LEN 2
103 struct ieee80211_hdr {
104 __le16 frame_control;
111 } __attribute__ ((packed));
114 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
115 * @fc: frame control bytes in little-endian byteorder
117 static inline int ieee80211_has_tods(__le16 fc)
119 return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
123 * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
124 * @fc: frame control bytes in little-endian byteorder
126 static inline int ieee80211_has_fromds(__le16 fc)
128 return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
132 * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
133 * @fc: frame control bytes in little-endian byteorder
135 static inline int ieee80211_has_a4(__le16 fc)
137 __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
138 return (fc & tmp) == tmp;
142 * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
143 * @fc: frame control bytes in little-endian byteorder
145 static inline int ieee80211_has_morefrags(__le16 fc)
147 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
151 * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
152 * @fc: frame control bytes in little-endian byteorder
154 static inline int ieee80211_has_retry(__le16 fc)
156 return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
160 * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
161 * @fc: frame control bytes in little-endian byteorder
163 static inline int ieee80211_has_pm(__le16 fc)
165 return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
169 * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
170 * @fc: frame control bytes in little-endian byteorder
172 static inline int ieee80211_has_moredata(__le16 fc)
174 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
178 * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
179 * @fc: frame control bytes in little-endian byteorder
181 static inline int ieee80211_has_protected(__le16 fc)
183 return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
187 * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
188 * @fc: frame control bytes in little-endian byteorder
190 static inline int ieee80211_has_order(__le16 fc)
192 return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
196 * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
197 * @fc: frame control bytes in little-endian byteorder
199 static inline int ieee80211_is_mgmt(__le16 fc)
201 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
202 cpu_to_le16(IEEE80211_FTYPE_MGMT);
206 * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
207 * @fc: frame control bytes in little-endian byteorder
209 static inline int ieee80211_is_ctl(__le16 fc)
211 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
212 cpu_to_le16(IEEE80211_FTYPE_CTL);
216 * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
217 * @fc: frame control bytes in little-endian byteorder
219 static inline int ieee80211_is_data(__le16 fc)
221 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
222 cpu_to_le16(IEEE80211_FTYPE_DATA);
226 * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
227 * @fc: frame control bytes in little-endian byteorder
229 static inline int ieee80211_is_data_qos(__le16 fc)
232 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
233 * to check the one bit
235 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
236 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
240 * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
241 * @fc: frame control bytes in little-endian byteorder
243 static inline int ieee80211_is_data_present(__le16 fc)
246 * mask with 0x40 and test that that bit is clear to only return true
247 * for the data-containing substypes.
249 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
250 cpu_to_le16(IEEE80211_FTYPE_DATA);
254 * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
255 * @fc: frame control bytes in little-endian byteorder
257 static inline int ieee80211_is_assoc_req(__le16 fc)
259 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
260 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
264 * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
265 * @fc: frame control bytes in little-endian byteorder
267 static inline int ieee80211_is_assoc_resp(__le16 fc)
269 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
270 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
274 * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
275 * @fc: frame control bytes in little-endian byteorder
277 static inline int ieee80211_is_reassoc_req(__le16 fc)
279 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
280 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
284 * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
285 * @fc: frame control bytes in little-endian byteorder
287 static inline int ieee80211_is_reassoc_resp(__le16 fc)
289 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
290 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
294 * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
295 * @fc: frame control bytes in little-endian byteorder
297 static inline int ieee80211_is_probe_req(__le16 fc)
299 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
300 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
304 * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
305 * @fc: frame control bytes in little-endian byteorder
307 static inline int ieee80211_is_probe_resp(__le16 fc)
309 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
310 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
314 * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
315 * @fc: frame control bytes in little-endian byteorder
317 static inline int ieee80211_is_beacon(__le16 fc)
319 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
320 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
324 * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
325 * @fc: frame control bytes in little-endian byteorder
327 static inline int ieee80211_is_atim(__le16 fc)
329 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
330 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
334 * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
335 * @fc: frame control bytes in little-endian byteorder
337 static inline int ieee80211_is_disassoc(__le16 fc)
339 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
340 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
344 * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
345 * @fc: frame control bytes in little-endian byteorder
347 static inline int ieee80211_is_auth(__le16 fc)
349 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
350 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
354 * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
355 * @fc: frame control bytes in little-endian byteorder
357 static inline int ieee80211_is_deauth(__le16 fc)
359 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
360 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
364 * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
365 * @fc: frame control bytes in little-endian byteorder
367 static inline int ieee80211_is_action(__le16 fc)
369 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
370 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
374 * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
375 * @fc: frame control bytes in little-endian byteorder
377 static inline int ieee80211_is_back_req(__le16 fc)
379 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
380 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
384 * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
385 * @fc: frame control bytes in little-endian byteorder
387 static inline int ieee80211_is_back(__le16 fc)
389 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
390 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
394 * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
395 * @fc: frame control bytes in little-endian byteorder
397 static inline int ieee80211_is_pspoll(__le16 fc)
399 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
400 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
404 * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
405 * @fc: frame control bytes in little-endian byteorder
407 static inline int ieee80211_is_rts(__le16 fc)
409 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
410 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
414 * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
415 * @fc: frame control bytes in little-endian byteorder
417 static inline int ieee80211_is_cts(__le16 fc)
419 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
420 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
424 * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
425 * @fc: frame control bytes in little-endian byteorder
427 static inline int ieee80211_is_ack(__le16 fc)
429 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
430 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
434 * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
435 * @fc: frame control bytes in little-endian byteorder
437 static inline int ieee80211_is_cfend(__le16 fc)
439 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
440 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
444 * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
445 * @fc: frame control bytes in little-endian byteorder
447 static inline int ieee80211_is_cfendack(__le16 fc)
449 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
450 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
454 * ieee80211_is_nullfunc - check if FTYPE=IEEE80211_FTYPE_DATA and STYPE=IEEE80211_STYPE_NULLFUNC
455 * @fc: frame control bytes in little-endian byteorder
457 static inline int ieee80211_is_nullfunc(__le16 fc)
459 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
460 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
463 struct ieee80211s_hdr {
470 } __attribute__ ((packed));
473 * struct ieee80211_quiet_ie
475 * This structure refers to "Quiet information element"
477 struct ieee80211_quiet_ie {
482 } __attribute__ ((packed));
485 * struct ieee80211_msrment_ie
487 * This structure refers to "Measurement Request/Report information element"
489 struct ieee80211_msrment_ie {
494 } __attribute__ ((packed));
497 * struct ieee80211_channel_sw_ie
499 * This structure refers to "Channel Switch Announcement information element"
501 struct ieee80211_channel_sw_ie {
505 } __attribute__ ((packed));
507 struct ieee80211_mgmt {
508 __le16 frame_control;
517 __le16 auth_transaction;
519 /* possibly followed by Challenge text */
521 } __attribute__ ((packed)) auth;
524 } __attribute__ ((packed)) deauth;
527 __le16 listen_interval;
528 /* followed by SSID and Supported rates */
530 } __attribute__ ((packed)) assoc_req;
535 /* followed by Supported rates */
537 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
540 __le16 listen_interval;
542 /* followed by SSID and Supported rates */
544 } __attribute__ ((packed)) reassoc_req;
547 } __attribute__ ((packed)) disassoc;
552 /* followed by some of SSID, Supported rates,
553 * FH Params, DS Params, CF Params, IBSS Params, TIM */
555 } __attribute__ ((packed)) beacon;
557 /* only variable items: SSID, Supported rates */
559 } __attribute__ ((packed)) probe_req;
564 /* followed by some of SSID, Supported rates,
565 * FH Params, DS Params, CF Params, IBSS Params */
567 } __attribute__ ((packed)) probe_resp;
576 } __attribute__ ((packed)) wme_action;
581 struct ieee80211_channel_sw_ie sw_elem;
582 } __attribute__((packed)) chan_switch;
588 struct ieee80211_msrment_ie msr_elem;
589 } __attribute__((packed)) measurement;
595 __le16 start_seq_num;
596 } __attribute__((packed)) addba_req;
603 } __attribute__((packed)) addba_resp;
608 } __attribute__((packed)) delba;
611 /* capab_info for open and confirm,
615 /* Followed in plink_confirm by status
616 * code, AID and supported rates,
617 * and directly by supported rates in
618 * plink_open and plink_close
621 } __attribute__((packed)) plink_action;
625 } __attribute__((packed)) mesh_action;
627 } __attribute__ ((packed)) action;
629 } __attribute__ ((packed));
633 struct ieee80211_rts {
634 __le16 frame_control;
638 } __attribute__ ((packed));
640 struct ieee80211_cts {
641 __le16 frame_control;
644 } __attribute__ ((packed));
647 * struct ieee80211_bar - HT Block Ack Request
649 * This structure refers to "HT BlockAckReq" as
650 * described in 802.11n draft section 7.2.1.7.1
652 struct ieee80211_bar {
653 __le16 frame_control;
658 __le16 start_seq_num;
659 } __attribute__((packed));
662 * struct ieee80211_ht_cap - HT capabilities
664 * This structure refers to "HT capabilities element" as
665 * described in 802.11n draft section 7.3.2.52
667 struct ieee80211_ht_cap {
669 u8 ampdu_params_info;
671 __le16 extended_ht_cap_info;
672 __le32 tx_BF_cap_info;
673 u8 antenna_selection_info;
674 } __attribute__ ((packed));
677 * struct ieee80211_ht_cap - HT additional information
679 * This structure refers to "HT information element" as
680 * described in 802.11n draft section 7.3.2.53
682 struct ieee80211_ht_addt_info {
685 __le16 operation_mode;
688 } __attribute__ ((packed));
690 /* 802.11n HT capabilities masks */
691 #define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
692 #define IEEE80211_HT_CAP_MIMO_PS 0x000C
693 #define IEEE80211_HT_CAP_GRN_FLD 0x0010
694 #define IEEE80211_HT_CAP_SGI_20 0x0020
695 #define IEEE80211_HT_CAP_SGI_40 0x0040
696 #define IEEE80211_HT_CAP_DELAY_BA 0x0400
697 #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
698 /* 802.11n HT capability AMPDU settings */
699 #define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
700 #define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
701 /* 802.11n HT capability MSC set */
702 #define IEEE80211_SUPP_MCS_SET_UEQM 4
703 #define IEEE80211_HT_CAP_MAX_STREAMS 4
704 #define IEEE80211_SUPP_MCS_SET_LEN 10
705 /* maximum streams the spec allows */
706 #define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01
707 #define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02
708 #define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C
709 #define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10
710 /* 802.11n HT IE masks */
711 #define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
712 #define IEEE80211_HT_IE_CHA_SEC_NONE 0x00
713 #define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01
714 #define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03
715 #define IEEE80211_HT_IE_CHA_WIDTH 0x04
716 #define IEEE80211_HT_IE_HT_PROTECTION 0x0003
717 #define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
718 #define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
720 /* MIMO Power Save Modes */
721 #define WLAN_HT_CAP_MIMO_PS_STATIC 0
722 #define WLAN_HT_CAP_MIMO_PS_DYNAMIC 1
723 #define WLAN_HT_CAP_MIMO_PS_INVALID 2
724 #define WLAN_HT_CAP_MIMO_PS_DISABLED 3
726 /* Authentication algorithms */
727 #define WLAN_AUTH_OPEN 0
728 #define WLAN_AUTH_SHARED_KEY 1
729 #define WLAN_AUTH_FAST_BSS_TRANSITION 2
730 #define WLAN_AUTH_LEAP 128
732 #define WLAN_AUTH_CHALLENGE_LEN 128
734 #define WLAN_CAPABILITY_ESS (1<<0)
735 #define WLAN_CAPABILITY_IBSS (1<<1)
736 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
737 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
738 #define WLAN_CAPABILITY_PRIVACY (1<<4)
739 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
740 #define WLAN_CAPABILITY_PBCC (1<<6)
741 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
744 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
745 #define WLAN_CAPABILITY_QOS (1<<9)
746 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
747 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
749 #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
750 #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
751 #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
753 #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
754 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
755 #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
758 /* 802.11g ERP information element */
759 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
760 #define WLAN_ERP_USE_PROTECTION (1<<1)
761 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
763 /* WLAN_ERP_BARKER_PREAMBLE values */
765 WLAN_ERP_PREAMBLE_SHORT = 0,
766 WLAN_ERP_PREAMBLE_LONG = 1,
770 enum ieee80211_statuscode {
771 WLAN_STATUS_SUCCESS = 0,
772 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
773 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
774 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
775 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
776 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
777 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
778 WLAN_STATUS_CHALLENGE_FAIL = 15,
779 WLAN_STATUS_AUTH_TIMEOUT = 16,
780 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
781 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
783 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
784 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
785 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
787 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
788 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
789 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
791 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
792 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
794 WLAN_STATUS_INVALID_IE = 40,
795 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
796 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
797 WLAN_STATUS_INVALID_AKMP = 43,
798 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
799 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
800 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
802 WLAN_STATUS_UNSPECIFIED_QOS = 32,
803 WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
804 WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
805 WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
806 WLAN_STATUS_REQUEST_DECLINED = 37,
807 WLAN_STATUS_INVALID_QOS_PARAM = 38,
808 WLAN_STATUS_CHANGE_TSPEC = 39,
809 WLAN_STATUS_WAIT_TS_DELAY = 47,
810 WLAN_STATUS_NO_DIRECT_LINK = 48,
811 WLAN_STATUS_STA_NOT_PRESENT = 49,
812 WLAN_STATUS_STA_NOT_QSTA = 50,
817 enum ieee80211_reasoncode {
818 WLAN_REASON_UNSPECIFIED = 1,
819 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
820 WLAN_REASON_DEAUTH_LEAVING = 3,
821 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
822 WLAN_REASON_DISASSOC_AP_BUSY = 5,
823 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
824 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
825 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
826 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
828 WLAN_REASON_DISASSOC_BAD_POWER = 10,
829 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
831 WLAN_REASON_INVALID_IE = 13,
832 WLAN_REASON_MIC_FAILURE = 14,
833 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
834 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
835 WLAN_REASON_IE_DIFFERENT = 17,
836 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
837 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
838 WLAN_REASON_INVALID_AKMP = 20,
839 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
840 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
841 WLAN_REASON_IEEE8021X_FAILED = 23,
842 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
844 WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
845 WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
846 WLAN_REASON_DISASSOC_LOW_ACK = 34,
847 WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
848 WLAN_REASON_QSTA_LEAVE_QBSS = 36,
849 WLAN_REASON_QSTA_NOT_USE = 37,
850 WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
851 WLAN_REASON_QSTA_TIMEOUT = 39,
852 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
856 /* Information Element IDs */
859 WLAN_EID_SUPP_RATES = 1,
860 WLAN_EID_FH_PARAMS = 2,
861 WLAN_EID_DS_PARAMS = 3,
862 WLAN_EID_CF_PARAMS = 4,
864 WLAN_EID_IBSS_PARAMS = 6,
865 WLAN_EID_CHALLENGE = 16,
867 WLAN_EID_COUNTRY = 7,
868 WLAN_EID_HP_PARAMS = 8,
869 WLAN_EID_HP_TABLE = 9,
870 WLAN_EID_REQUEST = 10,
872 WLAN_EID_QBSS_LOAD = 11,
873 WLAN_EID_EDCA_PARAM_SET = 12,
876 WLAN_EID_SCHEDULE = 15,
877 WLAN_EID_TS_DELAY = 43,
878 WLAN_EID_TCLAS_PROCESSING = 44,
879 WLAN_EID_QOS_CAPA = 46,
882 * All mesh EID numbers are pending IEEE 802.11 ANA approval.
883 * The numbers have been incremented from those suggested in
884 * 802.11s/D2.0 so that MESH_CONFIG does not conflict with
887 WLAN_EID_MESH_CONFIG = 51,
888 WLAN_EID_MESH_ID = 52,
889 WLAN_EID_PEER_LINK = 55,
894 WLAN_EID_PWR_CONSTRAINT = 32,
895 WLAN_EID_PWR_CAPABILITY = 33,
896 WLAN_EID_TPC_REQUEST = 34,
897 WLAN_EID_TPC_REPORT = 35,
898 WLAN_EID_SUPPORTED_CHANNELS = 36,
899 WLAN_EID_CHANNEL_SWITCH = 37,
900 WLAN_EID_MEASURE_REQUEST = 38,
901 WLAN_EID_MEASURE_REPORT = 39,
903 WLAN_EID_IBSS_DFS = 41,
905 WLAN_EID_ERP_INFO = 42,
906 WLAN_EID_EXT_SUPP_RATES = 50,
908 WLAN_EID_HT_CAPABILITY = 45,
909 WLAN_EID_HT_EXTRA_INFO = 61,
913 WLAN_EID_GENERIC = 221,
914 WLAN_EID_VENDOR_SPECIFIC = 221,
915 WLAN_EID_QOS_PARAMETER = 222
918 /* Action category code */
919 enum ieee80211_category {
920 WLAN_CATEGORY_SPECTRUM_MGMT = 0,
921 WLAN_CATEGORY_QOS = 1,
922 WLAN_CATEGORY_DLS = 2,
923 WLAN_CATEGORY_BACK = 3,
924 WLAN_CATEGORY_WMM = 17,
927 /* SPECTRUM_MGMT action code */
928 enum ieee80211_spectrum_mgmt_actioncode {
929 WLAN_ACTION_SPCT_MSR_REQ = 0,
930 WLAN_ACTION_SPCT_MSR_RPRT = 1,
931 WLAN_ACTION_SPCT_TPC_REQ = 2,
932 WLAN_ACTION_SPCT_TPC_RPRT = 3,
933 WLAN_ACTION_SPCT_CHL_SWITCH = 4,
936 /* BACK action code */
937 enum ieee80211_back_actioncode {
938 WLAN_ACTION_ADDBA_REQ = 0,
939 WLAN_ACTION_ADDBA_RESP = 1,
940 WLAN_ACTION_DELBA = 2,
943 /* BACK (block-ack) parties */
944 enum ieee80211_back_parties {
945 WLAN_BACK_RECIPIENT = 0,
946 WLAN_BACK_INITIATOR = 1,
951 #define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
953 /* cipher suite selectors */
954 #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
955 #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
956 #define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
957 /* reserved: 0x000FAC03 */
958 #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
959 #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
961 #define WLAN_MAX_KEY_LEN 32
964 * ieee80211_get_qos_ctl - get pointer to qos control bytes
967 * The qos ctrl bytes come after the frame_control, duration, seq_num
968 * and 3 or 4 addresses of length ETH_ALEN.
969 * 3 addr: 2 + 2 + 2 + 3*6 = 24
970 * 4 addr: 2 + 2 + 2 + 4*6 = 30
972 static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
974 if (ieee80211_has_a4(hdr->frame_control))
975 return (u8 *)hdr + 30;
977 return (u8 *)hdr + 24;
981 * ieee80211_get_SA - get pointer to SA
984 * Given an 802.11 frame, this function returns the offset
985 * to the source address (SA). It does not verify that the
986 * header is long enough to contain the address, and the
987 * header must be long enough to contain the frame control
990 static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
992 if (ieee80211_has_a4(hdr->frame_control))
994 if (ieee80211_has_fromds(hdr->frame_control))
1000 * ieee80211_get_DA - get pointer to DA
1003 * Given an 802.11 frame, this function returns the offset
1004 * to the destination address (DA). It does not verify that
1005 * the header is long enough to contain the address, and the
1006 * header must be long enough to contain the frame control
1009 static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1011 if (ieee80211_has_tods(hdr->frame_control))
1017 #endif /* IEEE80211_H */