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
102 #define IEEE80211_QOS_CTL_TID_MASK 0x000F
103 #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
105 struct ieee80211_hdr {
106 __le16 frame_control;
113 } __attribute__ ((packed));
116 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
117 * @fc: frame control bytes in little-endian byteorder
119 static inline int ieee80211_has_tods(__le16 fc)
121 return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
125 * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
126 * @fc: frame control bytes in little-endian byteorder
128 static inline int ieee80211_has_fromds(__le16 fc)
130 return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
134 * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
135 * @fc: frame control bytes in little-endian byteorder
137 static inline int ieee80211_has_a4(__le16 fc)
139 __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
140 return (fc & tmp) == tmp;
144 * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
145 * @fc: frame control bytes in little-endian byteorder
147 static inline int ieee80211_has_morefrags(__le16 fc)
149 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
153 * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
154 * @fc: frame control bytes in little-endian byteorder
156 static inline int ieee80211_has_retry(__le16 fc)
158 return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
162 * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
163 * @fc: frame control bytes in little-endian byteorder
165 static inline int ieee80211_has_pm(__le16 fc)
167 return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
171 * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
172 * @fc: frame control bytes in little-endian byteorder
174 static inline int ieee80211_has_moredata(__le16 fc)
176 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
180 * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
181 * @fc: frame control bytes in little-endian byteorder
183 static inline int ieee80211_has_protected(__le16 fc)
185 return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
189 * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
190 * @fc: frame control bytes in little-endian byteorder
192 static inline int ieee80211_has_order(__le16 fc)
194 return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
198 * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
199 * @fc: frame control bytes in little-endian byteorder
201 static inline int ieee80211_is_mgmt(__le16 fc)
203 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
204 cpu_to_le16(IEEE80211_FTYPE_MGMT);
208 * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
209 * @fc: frame control bytes in little-endian byteorder
211 static inline int ieee80211_is_ctl(__le16 fc)
213 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
214 cpu_to_le16(IEEE80211_FTYPE_CTL);
218 * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
219 * @fc: frame control bytes in little-endian byteorder
221 static inline int ieee80211_is_data(__le16 fc)
223 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
224 cpu_to_le16(IEEE80211_FTYPE_DATA);
228 * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
229 * @fc: frame control bytes in little-endian byteorder
231 static inline int ieee80211_is_data_qos(__le16 fc)
234 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
235 * to check the one bit
237 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
238 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
242 * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
243 * @fc: frame control bytes in little-endian byteorder
245 static inline int ieee80211_is_data_present(__le16 fc)
248 * mask with 0x40 and test that that bit is clear to only return true
249 * for the data-containing substypes.
251 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
252 cpu_to_le16(IEEE80211_FTYPE_DATA);
256 * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
257 * @fc: frame control bytes in little-endian byteorder
259 static inline int ieee80211_is_assoc_req(__le16 fc)
261 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
262 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
266 * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
267 * @fc: frame control bytes in little-endian byteorder
269 static inline int ieee80211_is_assoc_resp(__le16 fc)
271 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
272 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
276 * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
277 * @fc: frame control bytes in little-endian byteorder
279 static inline int ieee80211_is_reassoc_req(__le16 fc)
281 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
282 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
286 * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
287 * @fc: frame control bytes in little-endian byteorder
289 static inline int ieee80211_is_reassoc_resp(__le16 fc)
291 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
292 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
296 * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
297 * @fc: frame control bytes in little-endian byteorder
299 static inline int ieee80211_is_probe_req(__le16 fc)
301 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
302 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
306 * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
307 * @fc: frame control bytes in little-endian byteorder
309 static inline int ieee80211_is_probe_resp(__le16 fc)
311 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
312 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
316 * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
317 * @fc: frame control bytes in little-endian byteorder
319 static inline int ieee80211_is_beacon(__le16 fc)
321 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
322 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
326 * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
327 * @fc: frame control bytes in little-endian byteorder
329 static inline int ieee80211_is_atim(__le16 fc)
331 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
332 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
336 * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
337 * @fc: frame control bytes in little-endian byteorder
339 static inline int ieee80211_is_disassoc(__le16 fc)
341 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
342 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
346 * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
347 * @fc: frame control bytes in little-endian byteorder
349 static inline int ieee80211_is_auth(__le16 fc)
351 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
352 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
356 * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
357 * @fc: frame control bytes in little-endian byteorder
359 static inline int ieee80211_is_deauth(__le16 fc)
361 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
362 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
366 * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
367 * @fc: frame control bytes in little-endian byteorder
369 static inline int ieee80211_is_action(__le16 fc)
371 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
372 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
376 * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
377 * @fc: frame control bytes in little-endian byteorder
379 static inline int ieee80211_is_back_req(__le16 fc)
381 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
382 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
386 * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
387 * @fc: frame control bytes in little-endian byteorder
389 static inline int ieee80211_is_back(__le16 fc)
391 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
392 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
396 * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
397 * @fc: frame control bytes in little-endian byteorder
399 static inline int ieee80211_is_pspoll(__le16 fc)
401 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
402 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
406 * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
407 * @fc: frame control bytes in little-endian byteorder
409 static inline int ieee80211_is_rts(__le16 fc)
411 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
412 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
416 * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
417 * @fc: frame control bytes in little-endian byteorder
419 static inline int ieee80211_is_cts(__le16 fc)
421 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
422 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
426 * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
427 * @fc: frame control bytes in little-endian byteorder
429 static inline int ieee80211_is_ack(__le16 fc)
431 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
432 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
436 * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
437 * @fc: frame control bytes in little-endian byteorder
439 static inline int ieee80211_is_cfend(__le16 fc)
441 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
442 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
446 * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
447 * @fc: frame control bytes in little-endian byteorder
449 static inline int ieee80211_is_cfendack(__le16 fc)
451 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
452 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
456 * ieee80211_is_nullfunc - check if FTYPE=IEEE80211_FTYPE_DATA and STYPE=IEEE80211_STYPE_NULLFUNC
457 * @fc: frame control bytes in little-endian byteorder
459 static inline int ieee80211_is_nullfunc(__le16 fc)
461 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
462 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
465 struct ieee80211s_hdr {
472 } __attribute__ ((packed));
475 * struct ieee80211_quiet_ie
477 * This structure refers to "Quiet information element"
479 struct ieee80211_quiet_ie {
484 } __attribute__ ((packed));
487 * struct ieee80211_msrment_ie
489 * This structure refers to "Measurement Request/Report information element"
491 struct ieee80211_msrment_ie {
496 } __attribute__ ((packed));
499 * struct ieee80211_channel_sw_ie
501 * This structure refers to "Channel Switch Announcement information element"
503 struct ieee80211_channel_sw_ie {
507 } __attribute__ ((packed));
509 struct ieee80211_mgmt {
510 __le16 frame_control;
519 __le16 auth_transaction;
521 /* possibly followed by Challenge text */
523 } __attribute__ ((packed)) auth;
526 } __attribute__ ((packed)) deauth;
529 __le16 listen_interval;
530 /* followed by SSID and Supported rates */
532 } __attribute__ ((packed)) assoc_req;
537 /* followed by Supported rates */
539 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
542 __le16 listen_interval;
544 /* followed by SSID and Supported rates */
546 } __attribute__ ((packed)) reassoc_req;
549 } __attribute__ ((packed)) disassoc;
554 /* followed by some of SSID, Supported rates,
555 * FH Params, DS Params, CF Params, IBSS Params, TIM */
557 } __attribute__ ((packed)) beacon;
559 /* only variable items: SSID, Supported rates */
561 } __attribute__ ((packed)) probe_req;
566 /* followed by some of SSID, Supported rates,
567 * FH Params, DS Params, CF Params, IBSS Params */
569 } __attribute__ ((packed)) probe_resp;
578 } __attribute__ ((packed)) wme_action;
583 struct ieee80211_channel_sw_ie sw_elem;
584 } __attribute__((packed)) chan_switch;
590 struct ieee80211_msrment_ie msr_elem;
591 } __attribute__((packed)) measurement;
597 __le16 start_seq_num;
598 } __attribute__((packed)) addba_req;
605 } __attribute__((packed)) addba_resp;
610 } __attribute__((packed)) delba;
613 /* capab_info for open and confirm,
617 /* Followed in plink_confirm by status
618 * code, AID and supported rates,
619 * and directly by supported rates in
620 * plink_open and plink_close
623 } __attribute__((packed)) plink_action;
627 } __attribute__((packed)) mesh_action;
629 } __attribute__ ((packed)) action;
631 } __attribute__ ((packed));
635 struct ieee80211_rts {
636 __le16 frame_control;
640 } __attribute__ ((packed));
642 struct ieee80211_cts {
643 __le16 frame_control;
646 } __attribute__ ((packed));
649 * struct ieee80211_bar - HT Block Ack Request
651 * This structure refers to "HT BlockAckReq" as
652 * described in 802.11n draft section 7.2.1.7.1
654 struct ieee80211_bar {
655 __le16 frame_control;
660 __le16 start_seq_num;
661 } __attribute__((packed));
663 /* 802.11 BAR control masks */
664 #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
665 #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
668 * struct ieee80211_ht_cap - HT capabilities
670 * This structure refers to "HT capabilities element" as
671 * described in 802.11n draft section 7.3.2.52
673 struct ieee80211_ht_cap {
675 u8 ampdu_params_info;
677 __le16 extended_ht_cap_info;
678 __le32 tx_BF_cap_info;
679 u8 antenna_selection_info;
680 } __attribute__ ((packed));
683 * struct ieee80211_ht_cap - HT additional information
685 * This structure refers to "HT information element" as
686 * described in 802.11n draft section 7.3.2.53
688 struct ieee80211_ht_addt_info {
691 __le16 operation_mode;
694 } __attribute__ ((packed));
696 /* 802.11n HT capabilities masks */
697 #define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
698 #define IEEE80211_HT_CAP_MIMO_PS 0x000C
699 #define IEEE80211_HT_CAP_GRN_FLD 0x0010
700 #define IEEE80211_HT_CAP_SGI_20 0x0020
701 #define IEEE80211_HT_CAP_SGI_40 0x0040
702 #define IEEE80211_HT_CAP_DELAY_BA 0x0400
703 #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
704 /* 802.11n HT capability AMPDU settings */
705 #define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
706 #define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
707 /* 802.11n HT capability MSC set */
708 #define IEEE80211_SUPP_MCS_SET_UEQM 4
709 #define IEEE80211_HT_CAP_MAX_STREAMS 4
710 #define IEEE80211_SUPP_MCS_SET_LEN 10
711 /* maximum streams the spec allows */
712 #define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01
713 #define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02
714 #define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C
715 #define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10
716 /* 802.11n HT IE masks */
717 #define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
718 #define IEEE80211_HT_IE_CHA_SEC_NONE 0x00
719 #define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01
720 #define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03
721 #define IEEE80211_HT_IE_CHA_WIDTH 0x04
722 #define IEEE80211_HT_IE_HT_PROTECTION 0x0003
723 #define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
724 #define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
726 /* MIMO Power Save Modes */
727 #define WLAN_HT_CAP_MIMO_PS_STATIC 0
728 #define WLAN_HT_CAP_MIMO_PS_DYNAMIC 1
729 #define WLAN_HT_CAP_MIMO_PS_INVALID 2
730 #define WLAN_HT_CAP_MIMO_PS_DISABLED 3
732 /* Authentication algorithms */
733 #define WLAN_AUTH_OPEN 0
734 #define WLAN_AUTH_SHARED_KEY 1
735 #define WLAN_AUTH_FAST_BSS_TRANSITION 2
736 #define WLAN_AUTH_LEAP 128
738 #define WLAN_AUTH_CHALLENGE_LEN 128
740 #define WLAN_CAPABILITY_ESS (1<<0)
741 #define WLAN_CAPABILITY_IBSS (1<<1)
742 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
743 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
744 #define WLAN_CAPABILITY_PRIVACY (1<<4)
745 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
746 #define WLAN_CAPABILITY_PBCC (1<<6)
747 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
750 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
751 #define WLAN_CAPABILITY_QOS (1<<9)
752 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
753 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
755 #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
756 #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
757 #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
759 #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
760 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
761 #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
764 /* 802.11g ERP information element */
765 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
766 #define WLAN_ERP_USE_PROTECTION (1<<1)
767 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
769 /* WLAN_ERP_BARKER_PREAMBLE values */
771 WLAN_ERP_PREAMBLE_SHORT = 0,
772 WLAN_ERP_PREAMBLE_LONG = 1,
776 enum ieee80211_statuscode {
777 WLAN_STATUS_SUCCESS = 0,
778 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
779 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
780 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
781 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
782 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
783 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
784 WLAN_STATUS_CHALLENGE_FAIL = 15,
785 WLAN_STATUS_AUTH_TIMEOUT = 16,
786 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
787 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
789 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
790 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
791 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
793 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
794 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
795 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
797 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
798 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
800 WLAN_STATUS_INVALID_IE = 40,
801 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
802 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
803 WLAN_STATUS_INVALID_AKMP = 43,
804 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
805 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
806 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
808 WLAN_STATUS_UNSPECIFIED_QOS = 32,
809 WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
810 WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
811 WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
812 WLAN_STATUS_REQUEST_DECLINED = 37,
813 WLAN_STATUS_INVALID_QOS_PARAM = 38,
814 WLAN_STATUS_CHANGE_TSPEC = 39,
815 WLAN_STATUS_WAIT_TS_DELAY = 47,
816 WLAN_STATUS_NO_DIRECT_LINK = 48,
817 WLAN_STATUS_STA_NOT_PRESENT = 49,
818 WLAN_STATUS_STA_NOT_QSTA = 50,
823 enum ieee80211_reasoncode {
824 WLAN_REASON_UNSPECIFIED = 1,
825 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
826 WLAN_REASON_DEAUTH_LEAVING = 3,
827 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
828 WLAN_REASON_DISASSOC_AP_BUSY = 5,
829 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
830 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
831 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
832 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
834 WLAN_REASON_DISASSOC_BAD_POWER = 10,
835 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
837 WLAN_REASON_INVALID_IE = 13,
838 WLAN_REASON_MIC_FAILURE = 14,
839 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
840 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
841 WLAN_REASON_IE_DIFFERENT = 17,
842 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
843 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
844 WLAN_REASON_INVALID_AKMP = 20,
845 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
846 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
847 WLAN_REASON_IEEE8021X_FAILED = 23,
848 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
850 WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
851 WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
852 WLAN_REASON_DISASSOC_LOW_ACK = 34,
853 WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
854 WLAN_REASON_QSTA_LEAVE_QBSS = 36,
855 WLAN_REASON_QSTA_NOT_USE = 37,
856 WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
857 WLAN_REASON_QSTA_TIMEOUT = 39,
858 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
862 /* Information Element IDs */
865 WLAN_EID_SUPP_RATES = 1,
866 WLAN_EID_FH_PARAMS = 2,
867 WLAN_EID_DS_PARAMS = 3,
868 WLAN_EID_CF_PARAMS = 4,
870 WLAN_EID_IBSS_PARAMS = 6,
871 WLAN_EID_CHALLENGE = 16,
873 WLAN_EID_COUNTRY = 7,
874 WLAN_EID_HP_PARAMS = 8,
875 WLAN_EID_HP_TABLE = 9,
876 WLAN_EID_REQUEST = 10,
878 WLAN_EID_QBSS_LOAD = 11,
879 WLAN_EID_EDCA_PARAM_SET = 12,
882 WLAN_EID_SCHEDULE = 15,
883 WLAN_EID_TS_DELAY = 43,
884 WLAN_EID_TCLAS_PROCESSING = 44,
885 WLAN_EID_QOS_CAPA = 46,
888 * All mesh EID numbers are pending IEEE 802.11 ANA approval.
889 * The numbers have been incremented from those suggested in
890 * 802.11s/D2.0 so that MESH_CONFIG does not conflict with
893 WLAN_EID_MESH_CONFIG = 51,
894 WLAN_EID_MESH_ID = 52,
895 WLAN_EID_PEER_LINK = 55,
900 WLAN_EID_PWR_CONSTRAINT = 32,
901 WLAN_EID_PWR_CAPABILITY = 33,
902 WLAN_EID_TPC_REQUEST = 34,
903 WLAN_EID_TPC_REPORT = 35,
904 WLAN_EID_SUPPORTED_CHANNELS = 36,
905 WLAN_EID_CHANNEL_SWITCH = 37,
906 WLAN_EID_MEASURE_REQUEST = 38,
907 WLAN_EID_MEASURE_REPORT = 39,
909 WLAN_EID_IBSS_DFS = 41,
911 WLAN_EID_ERP_INFO = 42,
912 WLAN_EID_EXT_SUPP_RATES = 50,
914 WLAN_EID_HT_CAPABILITY = 45,
915 WLAN_EID_HT_EXTRA_INFO = 61,
919 WLAN_EID_GENERIC = 221,
920 WLAN_EID_VENDOR_SPECIFIC = 221,
921 WLAN_EID_QOS_PARAMETER = 222
924 /* Action category code */
925 enum ieee80211_category {
926 WLAN_CATEGORY_SPECTRUM_MGMT = 0,
927 WLAN_CATEGORY_QOS = 1,
928 WLAN_CATEGORY_DLS = 2,
929 WLAN_CATEGORY_BACK = 3,
930 WLAN_CATEGORY_WMM = 17,
933 /* SPECTRUM_MGMT action code */
934 enum ieee80211_spectrum_mgmt_actioncode {
935 WLAN_ACTION_SPCT_MSR_REQ = 0,
936 WLAN_ACTION_SPCT_MSR_RPRT = 1,
937 WLAN_ACTION_SPCT_TPC_REQ = 2,
938 WLAN_ACTION_SPCT_TPC_RPRT = 3,
939 WLAN_ACTION_SPCT_CHL_SWITCH = 4,
942 /* BACK action code */
943 enum ieee80211_back_actioncode {
944 WLAN_ACTION_ADDBA_REQ = 0,
945 WLAN_ACTION_ADDBA_RESP = 1,
946 WLAN_ACTION_DELBA = 2,
949 /* BACK (block-ack) parties */
950 enum ieee80211_back_parties {
951 WLAN_BACK_RECIPIENT = 0,
952 WLAN_BACK_INITIATOR = 1,
957 #define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
959 /* cipher suite selectors */
960 #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
961 #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
962 #define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
963 /* reserved: 0x000FAC03 */
964 #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
965 #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
967 #define WLAN_MAX_KEY_LEN 32
970 * ieee80211_get_qos_ctl - get pointer to qos control bytes
973 * The qos ctrl bytes come after the frame_control, duration, seq_num
974 * and 3 or 4 addresses of length ETH_ALEN.
975 * 3 addr: 2 + 2 + 2 + 3*6 = 24
976 * 4 addr: 2 + 2 + 2 + 4*6 = 30
978 static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
980 if (ieee80211_has_a4(hdr->frame_control))
981 return (u8 *)hdr + 30;
983 return (u8 *)hdr + 24;
987 * ieee80211_get_SA - get pointer to SA
990 * Given an 802.11 frame, this function returns the offset
991 * to the source address (SA). It does not verify that the
992 * header is long enough to contain the address, and the
993 * header must be long enough to contain the frame control
996 static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
998 if (ieee80211_has_a4(hdr->frame_control))
1000 if (ieee80211_has_fromds(hdr->frame_control))
1006 * ieee80211_get_DA - get pointer to DA
1009 * Given an 802.11 frame, this function returns the offset
1010 * to the destination address (DA). It does not verify that
1011 * the header is long enough to contain the address, and the
1012 * header must be long enough to contain the frame control
1015 static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1017 if (ieee80211_has_tods(hdr->frame_control))
1023 #endif /* IEEE80211_H */