Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ieee80211.h
Go to the documentation of this file.
1 /*
2  * IEEE 802.11 defines
3  *
4  * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
6  * Copyright (c) 2002-2003, Jouni Malinen <[email protected]>
7  * Copyright (c) 2005, Devicescape Software, Inc.
8  * Copyright (c) 2006, Michael Wu <[email protected]>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14 
15 #ifndef LINUX_IEEE80211_H
16 #define LINUX_IEEE80211_H
17 
18 #include <linux/types.h>
19 #include <asm/byteorder.h>
20 
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 
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 #define IEEE80211_FCTL_CTL_EXT 0x0f00
51 
52 #define IEEE80211_SCTL_FRAG 0x000F
53 #define IEEE80211_SCTL_SEQ 0xFFF0
54 
55 #define IEEE80211_FTYPE_MGMT 0x0000
56 #define IEEE80211_FTYPE_CTL 0x0004
57 #define IEEE80211_FTYPE_DATA 0x0008
58 #define IEEE80211_FTYPE_EXT 0x000c
59 
60 /* management */
61 #define IEEE80211_STYPE_ASSOC_REQ 0x0000
62 #define IEEE80211_STYPE_ASSOC_RESP 0x0010
63 #define IEEE80211_STYPE_REASSOC_REQ 0x0020
64 #define IEEE80211_STYPE_REASSOC_RESP 0x0030
65 #define IEEE80211_STYPE_PROBE_REQ 0x0040
66 #define IEEE80211_STYPE_PROBE_RESP 0x0050
67 #define IEEE80211_STYPE_BEACON 0x0080
68 #define IEEE80211_STYPE_ATIM 0x0090
69 #define IEEE80211_STYPE_DISASSOC 0x00A0
70 #define IEEE80211_STYPE_AUTH 0x00B0
71 #define IEEE80211_STYPE_DEAUTH 0x00C0
72 #define IEEE80211_STYPE_ACTION 0x00D0
73 
74 /* control */
75 #define IEEE80211_STYPE_CTL_EXT 0x0060
76 #define IEEE80211_STYPE_BACK_REQ 0x0080
77 #define IEEE80211_STYPE_BACK 0x0090
78 #define IEEE80211_STYPE_PSPOLL 0x00A0
79 #define IEEE80211_STYPE_RTS 0x00B0
80 #define IEEE80211_STYPE_CTS 0x00C0
81 #define IEEE80211_STYPE_ACK 0x00D0
82 #define IEEE80211_STYPE_CFEND 0x00E0
83 #define IEEE80211_STYPE_CFENDACK 0x00F0
84 
85 /* data */
86 #define IEEE80211_STYPE_DATA 0x0000
87 #define IEEE80211_STYPE_DATA_CFACK 0x0010
88 #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
89 #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
90 #define IEEE80211_STYPE_NULLFUNC 0x0040
91 #define IEEE80211_STYPE_CFACK 0x0050
92 #define IEEE80211_STYPE_CFPOLL 0x0060
93 #define IEEE80211_STYPE_CFACKPOLL 0x0070
94 #define IEEE80211_STYPE_QOS_DATA 0x0080
95 #define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
96 #define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
97 #define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
98 #define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
99 #define IEEE80211_STYPE_QOS_CFACK 0x00D0
100 #define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
101 #define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
102 
103 /* extension, added by 802.11ad */
104 #define IEEE80211_STYPE_DMG_BEACON 0x0000
105 
106 /* control extension - for IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTL_EXT */
107 #define IEEE80211_CTL_EXT_POLL 0x2000
108 #define IEEE80211_CTL_EXT_SPR 0x3000
109 #define IEEE80211_CTL_EXT_GRANT 0x4000
110 #define IEEE80211_CTL_EXT_DMG_CTS 0x5000
111 #define IEEE80211_CTL_EXT_DMG_DTS 0x6000
112 #define IEEE80211_CTL_EXT_SSW 0x8000
113 #define IEEE80211_CTL_EXT_SSW_FBACK 0x9000
114 #define IEEE80211_CTL_EXT_SSW_ACK 0xa000
115 
116 /* miscellaneous IEEE 802.11 constants */
117 #define IEEE80211_MAX_FRAG_THRESHOLD 2352
118 #define IEEE80211_MAX_RTS_THRESHOLD 2353
119 #define IEEE80211_MAX_AID 2007
120 #define IEEE80211_MAX_TIM_LEN 251
121 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
122  6.2.1.1.2.
123 
124  802.11e clarifies the figure in section 7.1.2. The frame body is
125  up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
126 #define IEEE80211_MAX_DATA_LEN 2304
127 /* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
128 #define IEEE80211_MAX_FRAME_LEN 2352
129 
130 #define IEEE80211_MAX_SSID_LEN 32
131 
132 #define IEEE80211_MAX_MESH_ID_LEN 32
133 
134 #define IEEE80211_QOS_CTL_LEN 2
135 /* 1d tag mask */
136 #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
137 /* TID mask */
138 #define IEEE80211_QOS_CTL_TID_MASK 0x000f
139 /* EOSP */
140 #define IEEE80211_QOS_CTL_EOSP 0x0010
141 /* ACK policy */
142 #define IEEE80211_QOS_CTL_ACK_POLICY_NORMAL 0x0000
143 #define IEEE80211_QOS_CTL_ACK_POLICY_NOACK 0x0020
144 #define IEEE80211_QOS_CTL_ACK_POLICY_NO_EXPL 0x0040
145 #define IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK 0x0060
146 #define IEEE80211_QOS_CTL_ACK_POLICY_MASK 0x0060
147 /* A-MSDU 802.11n */
148 #define IEEE80211_QOS_CTL_A_MSDU_PRESENT 0x0080
149 /* Mesh Control 802.11s */
150 #define IEEE80211_QOS_CTL_MESH_CONTROL_PRESENT 0x0100
151 
152 /* U-APSD queue for WMM IEs sent by AP */
153 #define IEEE80211_WMM_IE_AP_QOSINFO_UAPSD (1<<7)
154 #define IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK 0x0f
155 
156 /* U-APSD queues for WMM IEs sent by STA */
157 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VO (1<<0)
158 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_VI (1<<1)
159 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BK (1<<2)
160 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_BE (1<<3)
161 #define IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK 0x0f
162 
163 /* U-APSD max SP length for WMM IEs sent by STA */
164 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL 0x00
165 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_2 0x01
166 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_4 0x02
167 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_6 0x03
168 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK 0x03
169 #define IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT 5
170 
171 #define IEEE80211_HT_CTL_LEN 4
172 
173 struct ieee80211_hdr {
176  u8 addr1[6];
177  u8 addr2[6];
178  u8 addr3[6];
180  u8 addr4[6];
181 } __attribute__ ((packed));
186  u8 addr1[6];
187  u8 addr2[6];
188  u8 addr3[6];
190 } __attribute__ ((packed));
191 
195  u8 addr1[6];
196  u8 addr2[6];
197  u8 addr3[6];
200 } __attribute__ ((packed));
201 
206 static inline int ieee80211_has_tods(__le16 fc)
207 {
208  return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
209 }
210 
215 static inline int ieee80211_has_fromds(__le16 fc)
216 {
217  return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
218 }
219 
224 static inline int ieee80211_has_a4(__le16 fc)
225 {
227  return (fc & tmp) == tmp;
228 }
229 
234 static inline int ieee80211_has_morefrags(__le16 fc)
235 {
236  return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
237 }
238 
243 static inline int ieee80211_has_retry(__le16 fc)
244 {
245  return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
246 }
247 
252 static inline int ieee80211_has_pm(__le16 fc)
253 {
254  return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
255 }
256 
261 static inline int ieee80211_has_moredata(__le16 fc)
262 {
263  return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
264 }
265 
270 static inline int ieee80211_has_protected(__le16 fc)
271 {
272  return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
273 }
274 
279 static inline int ieee80211_has_order(__le16 fc)
280 {
281  return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
282 }
283 
288 static inline int ieee80211_is_mgmt(__le16 fc)
289 {
290  return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
292 }
293 
298 static inline int ieee80211_is_ctl(__le16 fc)
299 {
300  return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
302 }
303 
308 static inline int ieee80211_is_data(__le16 fc)
309 {
310  return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
312 }
313 
318 static inline int ieee80211_is_data_qos(__le16 fc)
319 {
320  /*
321  * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
322  * to check the one bit
323  */
326 }
327 
332 static inline int ieee80211_is_data_present(__le16 fc)
333 {
334  /*
335  * mask with 0x40 and test that that bit is clear to only return true
336  * for the data-containing substypes.
337  */
338  return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
340 }
341 
346 static inline int ieee80211_is_assoc_req(__le16 fc)
347 {
350 }
351 
356 static inline int ieee80211_is_assoc_resp(__le16 fc)
357 {
360 }
361 
366 static inline int ieee80211_is_reassoc_req(__le16 fc)
367 {
370 }
371 
376 static inline int ieee80211_is_reassoc_resp(__le16 fc)
377 {
380 }
381 
386 static inline int ieee80211_is_probe_req(__le16 fc)
387 {
390 }
391 
396 static inline int ieee80211_is_probe_resp(__le16 fc)
397 {
400 }
401 
406 static inline int ieee80211_is_beacon(__le16 fc)
407 {
410 }
411 
416 static inline int ieee80211_is_atim(__le16 fc)
417 {
420 }
421 
426 static inline int ieee80211_is_disassoc(__le16 fc)
427 {
430 }
431 
436 static inline int ieee80211_is_auth(__le16 fc)
437 {
440 }
441 
446 static inline int ieee80211_is_deauth(__le16 fc)
447 {
450 }
451 
456 static inline int ieee80211_is_action(__le16 fc)
457 {
460 }
461 
466 static inline int ieee80211_is_back_req(__le16 fc)
467 {
470 }
471 
476 static inline int ieee80211_is_back(__le16 fc)
477 {
480 }
481 
486 static inline int ieee80211_is_pspoll(__le16 fc)
487 {
490 }
491 
496 static inline int ieee80211_is_rts(__le16 fc)
497 {
500 }
501 
506 static inline int ieee80211_is_cts(__le16 fc)
507 {
510 }
511 
516 static inline int ieee80211_is_ack(__le16 fc)
517 {
520 }
521 
526 static inline int ieee80211_is_cfend(__le16 fc)
527 {
530 }
531 
536 static inline int ieee80211_is_cfendack(__le16 fc)
537 {
540 }
541 
546 static inline int ieee80211_is_nullfunc(__le16 fc)
547 {
550 }
551 
556 static inline int ieee80211_is_qos_nullfunc(__le16 fc)
557 {
560 }
561 
566 static inline int ieee80211_is_first_frag(__le16 seq_ctrl)
567 {
568  return (seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0;
569 }
570 
575  u8 eaddr1[6];
576  u8 eaddr2[6];
577 } __attribute__ ((packed));
579 /* Mesh flags */
580 #define MESH_FLAGS_AE_A4 0x1
581 #define MESH_FLAGS_AE_A5_A6 0x2
582 #define MESH_FLAGS_AE 0x3
583 #define MESH_FLAGS_PS_DEEP 0x4
584 
592 };
593 
603 };
604 
615 } __attribute__ ((packed));
627 } __attribute__ ((packed));
638 } __attribute__ ((packed));
639 
649  /* variable size: 1 - 251 bytes */
651 } __attribute__ ((packed));
666 } __attribute__ ((packed));
681 } __attribute__ ((packed));
685 };
687 #define WLAN_SA_QUERY_TR_ID_LEN 2
692  u8 da[6];
693  u8 sa[6];
694  u8 bssid[6];
696  union {
697  struct {
701  /* possibly followed by Challenge text */
703  } __attribute__ ((packed)) auth;
706  } __attribute__ ((packed)) deauth;
710  /* followed by SSID and Supported rates */
711  u8 variable[0];
712  } __attribute__ ((packed)) assoc_req;
717  /* followed by Supported rates */
718  u8 variable[0];
719  } __attribute__ ((packed)) assoc_resp, reassoc_resp;
720  struct {
724  /* followed by SSID and Supported rates */
725  u8 variable[0];
726  } __attribute__ ((packed)) reassoc_req;
727  struct {
729  } __attribute__ ((packed)) disassoc;
730  struct {
734  /* followed by some of SSID, Supported rates,
735  * FH Params, DS Params, CF Params, IBSS Params, TIM */
736  u8 variable[0];
737  } __attribute__ ((packed)) beacon;
739  /* only variable items: SSID, Supported rates */
740  u8 variable[0];
741  } __attribute__ ((packed)) probe_req;
742  struct {
746  /* followed by some of SSID, Supported rates,
747  * FH Params, DS Params, CF Params, IBSS Params */
748  u8 variable[0];
749  } __attribute__ ((packed)) probe_resp;
750  struct {
752  union {
753  struct {
757  u8 variable[0];
758  } __attribute__ ((packed)) wme_action;
764  } __attribute__((packed)) chan_switch;
765  struct{
769  u8 length;
771  } __attribute__((packed)) measurement;
772  struct{
773  u8 action_code;
778  } __attribute__((packed)) addba_req;
779  struct{
780  u8 action_code;
784  __le16 timeout;
785  } __attribute__((packed)) addba_resp;
786  struct{
787  u8 action_code;
790  } __attribute__((packed)) delba;
791  struct {
793  u8 variable[0];
794  } __attribute__((packed)) self_prot;
795  struct{
796  u8 action_code;
797  u8 variable[0];
798  } __attribute__((packed)) mesh_action;
799  struct {
802  } __attribute__ ((packed)) sa_query;
806  } __attribute__ ((packed)) ht_smps;
807  struct {
811  u8 variable[0];
813  } u;
814  } __attribute__ ((packed)) action;
815  } u;
816 } __attribute__ ((packed));
817 
818 /* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */
819 #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
821 /* mgmt header + 1 byte category code */
822 #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
823 
824 
825 /* Management MIC information element (IEEE 802.11w) */
831  u8 mic[8];
832 } __attribute__ ((packed));
833 
837  u8 oui[3];
839 } __packed;
840 
841 /* Control frames */
845  u8 ra[6];
846  u8 ta[6];
847 } __attribute__ ((packed));
848 
852  u8 ra[6];
853 } __attribute__ ((packed));
854 
858  u8 bssid[6];
859  u8 ta[6];
860 } __attribute__ ((packed));
861 
862 /* TDLS */
863 
864 /* Link-id information element */
866  u8 ie_type; /* Link Identifier IE */
868  u8 bssid[6];
869  u8 init_sta[6];
870  u8 resp_sta[6];
871 } __packed;
872 
874  u8 da[6];
875  u8 sa[6];
880  union {
881  struct {
885  } __packed setup_req;
886  struct {
890  u8 variable[0];
891  } __packed setup_resp;
892  struct {
895  u8 variable[0];
896  } __packed setup_cfm;
897  struct {
899  u8 variable[0];
900  } __packed teardown;
901  struct {
903  u8 variable[0];
904  } __packed discover_req;
905  } u;
906 } __packed;
907 
914 struct ieee80211_bar {
917  __u8 ra[6];
918  __u8 ta[6];
921 } __attribute__((packed));
922 
923 /* 802.11 BAR control masks */
924 #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
925 #define IEEE80211_BAR_CTRL_MULTI_TID 0x0002
926 #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
927 #define IEEE80211_BAR_CTRL_TID_INFO_MASK 0xf000
928 #define IEEE80211_BAR_CTRL_TID_INFO_SHIFT 12
929 
930 #define IEEE80211_HT_MCS_MASK_LEN 10
931 
946 } __attribute__((packed));
948 /* 802.11n HT capability MSC set */
949 #define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3ff
950 #define IEEE80211_HT_MCS_TX_DEFINED 0x01
951 #define IEEE80211_HT_MCS_TX_RX_DIFF 0x02
952 /* value 0 == 1 stream etc */
953 #define IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK 0x0C
954 #define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2
955 #define IEEE80211_HT_MCS_TX_MAX_STREAMS 4
956 #define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10
957 
958 /*
959  * 802.11n D5.0 20.3.5 / 20.6 says:
960  * - indices 0 to 7 and 32 are single spatial stream
961  * - 8 to 31 are multiple spatial streams using equal modulation
962  * [8..15 for two streams, 16..23 for three and 24..31 for four]
963  * - remainder are multiple spatial streams using unequal modulation
964  */
965 #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START 33
966 #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE \
967  (IEEE80211_HT_MCS_UNEQUAL_MODULATION_START / 8)
968 
975 struct ieee80211_ht_cap {
978 
979  /* 16 bytes MCS information */
981 
985 } __attribute__ ((packed));
987 /* 802.11n HT capabilities masks (for cap_info) */
988 #define IEEE80211_HT_CAP_LDPC_CODING 0x0001
989 #define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002
990 #define IEEE80211_HT_CAP_SM_PS 0x000C
991 #define IEEE80211_HT_CAP_SM_PS_SHIFT 2
992 #define IEEE80211_HT_CAP_GRN_FLD 0x0010
993 #define IEEE80211_HT_CAP_SGI_20 0x0020
994 #define IEEE80211_HT_CAP_SGI_40 0x0040
995 #define IEEE80211_HT_CAP_TX_STBC 0x0080
996 #define IEEE80211_HT_CAP_RX_STBC 0x0300
997 #define IEEE80211_HT_CAP_RX_STBC_SHIFT 8
998 #define IEEE80211_HT_CAP_DELAY_BA 0x0400
999 #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
1000 #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
1001 #define IEEE80211_HT_CAP_RESERVED 0x2000
1002 #define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
1003 #define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
1004 
1005 /* 802.11n HT extended capabilities masks (for extended_ht_cap_info) */
1006 #define IEEE80211_HT_EXT_CAP_PCO 0x0001
1007 #define IEEE80211_HT_EXT_CAP_PCO_TIME 0x0006
1008 #define IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT 1
1009 #define IEEE80211_HT_EXT_CAP_MCS_FB 0x0300
1010 #define IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT 8
1011 #define IEEE80211_HT_EXT_CAP_HTC_SUP 0x0400
1012 #define IEEE80211_HT_EXT_CAP_RD_RESPONDER 0x0800
1013 
1014 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
1015 #define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03
1016 #define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C
1017 #define IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT 2
1018 
1019 /*
1020  * Maximum length of AMPDU that the STA can receive.
1021  * Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
1022  */
1028 };
1029 
1030 #define IEEE80211_HT_MAX_AMPDU_FACTOR 13
1031 
1032 /* Minimum MPDU start spacing */
1034  IEEE80211_HT_MPDU_DENSITY_NONE = 0, /* No restriction */
1036  IEEE80211_HT_MPDU_DENSITY_0_5 = 2, /* 1/2 usec */
1042 };
1043 
1056 } __attribute__ ((packed));
1058 /* for ht_param */
1059 #define IEEE80211_HT_PARAM_CHA_SEC_OFFSET 0x03
1060 #define IEEE80211_HT_PARAM_CHA_SEC_NONE 0x00
1061 #define IEEE80211_HT_PARAM_CHA_SEC_ABOVE 0x01
1062 #define IEEE80211_HT_PARAM_CHA_SEC_BELOW 0x03
1063 #define IEEE80211_HT_PARAM_CHAN_WIDTH_ANY 0x04
1064 #define IEEE80211_HT_PARAM_RIFS_MODE 0x08
1065 
1066 /* for operation_mode */
1067 #define IEEE80211_HT_OP_MODE_PROTECTION 0x0003
1068 #define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0
1069 #define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 1
1070 #define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 2
1071 #define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 3
1072 #define IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT 0x0004
1073 #define IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT 0x0010
1074 
1075 /* for stbc_param */
1076 #define IEEE80211_HT_STBC_PARAM_DUAL_BEACON 0x0040
1077 #define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080
1078 #define IEEE80211_HT_STBC_PARAM_STBC_BEACON 0x0100
1079 #define IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT 0x0200
1080 #define IEEE80211_HT_STBC_PARAM_PCO_ACTIVE 0x0400
1081 #define IEEE80211_HT_STBC_PARAM_PCO_PHASE 0x0800
1082 
1083 
1084 /* block-ack parameters */
1085 #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
1086 #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
1087 #define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0
1088 #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
1089 #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
1090 
1091 /*
1092  * A-PMDU buffer sizes
1093  * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
1094  */
1095 #define IEEE80211_MIN_AMPDU_BUF 0x8
1096 #define IEEE80211_MAX_AMPDU_BUF 0x40
1097 
1098 
1099 /* Spatial Multiplexing Power Save Modes (for capability) */
1100 #define WLAN_HT_CAP_SM_PS_STATIC 0
1101 #define WLAN_HT_CAP_SM_PS_DYNAMIC 1
1102 #define WLAN_HT_CAP_SM_PS_INVALID 2
1103 #define WLAN_HT_CAP_SM_PS_DISABLED 3
1104 
1105 /* for SM power control field lower two bits */
1106 #define WLAN_HT_SMPS_CONTROL_DISABLED 0
1107 #define WLAN_HT_SMPS_CONTROL_STATIC 1
1108 #define WLAN_HT_SMPS_CONTROL_DYNAMIC 3
1109 
1110 #define VHT_MCS_SUPPORTED_SET_SIZE 8
1111 
1114  u8 vht_supported_mcs_set[VHT_MCS_SUPPORTED_SET_SIZE];
1115 } __packed;
1116 
1122 } __packed;
1123 
1142 } __packed;
1143 
1144 #define IEEE80211_VHT_MCS_ZERO_TO_SEVEN_SUPPORT 0
1145 #define IEEE80211_VHT_MCS_ZERO_TO_EIGHT_SUPPORT 1
1146 #define IEEE80211_VHT_MCS_ZERO_TO_NINE_SUPPORT 2
1147 #define IEEE80211_VHT_MCS_NOT_SUPPORTED 3
1148 
1149 /* 802.11ac VHT Capabilities */
1150 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000
1151 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001
1152 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 0x00000002
1153 #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ 0x00000004
1154 #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ 0x00000008
1155 #define IEEE80211_VHT_CAP_RXLDPC 0x00000010
1156 #define IEEE80211_VHT_CAP_SHORT_GI_80 0x00000020
1157 #define IEEE80211_VHT_CAP_SHORT_GI_160 0x00000040
1158 #define IEEE80211_VHT_CAP_TXSTBC 0x00000080
1159 #define IEEE80211_VHT_CAP_RXSTBC_1 0x00000100
1160 #define IEEE80211_VHT_CAP_RXSTBC_2 0x00000200
1161 #define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300
1162 #define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400
1163 #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
1164 #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
1165 #define IEEE80211_VHT_CAP_BEAMFORMER_ANTENNAS_MAX 0x00006000
1166 #define IEEE80211_VHT_CAP_SOUNDING_DIMENTION_MAX 0x00030000
1167 #define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000
1168 #define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000
1169 #define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000
1170 #define IEEE80211_VHT_CAP_HTC_VHT 0x00400000
1171 #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT 0x00800000
1172 #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB 0x08000000
1173 #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB 0x0c000000
1174 #define IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN 0x10000000
1175 #define IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN 0x20000000
1176 
1177 /* Authentication algorithms */
1178 #define WLAN_AUTH_OPEN 0
1179 #define WLAN_AUTH_SHARED_KEY 1
1180 #define WLAN_AUTH_FT 2
1181 #define WLAN_AUTH_SAE 3
1182 #define WLAN_AUTH_LEAP 128
1183 
1184 #define WLAN_AUTH_CHALLENGE_LEN 128
1185 
1186 #define WLAN_CAPABILITY_ESS (1<<0)
1187 #define WLAN_CAPABILITY_IBSS (1<<1)
1188 
1189 /*
1190  * A mesh STA sets the ESS and IBSS capability bits to zero.
1191  * however, this holds true for p2p probe responses (in the p2p_find
1192  * phase) as well.
1193  */
1194 #define WLAN_CAPABILITY_IS_STA_BSS(cap) \
1195  (!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)))
1196 
1197 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
1198 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
1199 #define WLAN_CAPABILITY_PRIVACY (1<<4)
1200 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
1201 #define WLAN_CAPABILITY_PBCC (1<<6)
1202 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
1203 
1204 /* 802.11h */
1205 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
1206 #define WLAN_CAPABILITY_QOS (1<<9)
1207 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
1208 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
1209 
1210 /* DMG (60gHz) 802.11ad */
1211 /* type - bits 0..1 */
1212 #define WLAN_CAPABILITY_DMG_TYPE_IBSS (1<<0) /* Tx by: STA */
1213 #define WLAN_CAPABILITY_DMG_TYPE_PBSS (2<<0) /* Tx by: PCP */
1214 #define WLAN_CAPABILITY_DMG_TYPE_AP (3<<0) /* Tx by: AP */
1215 
1216 #define WLAN_CAPABILITY_DMG_CBAP_ONLY (1<<2)
1217 #define WLAN_CAPABILITY_DMG_CBAP_SOURCE (1<<3)
1218 #define WLAN_CAPABILITY_DMG_PRIVACY (1<<4)
1219 #define WLAN_CAPABILITY_DMG_ECPAC (1<<5)
1220 
1221 #define WLAN_CAPABILITY_DMG_SPECTRUM_MGMT (1<<8)
1222 #define WLAN_CAPABILITY_DMG_RADIO_MEASURE (1<<12)
1223 
1224 /* measurement */
1225 #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
1226 #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
1227 #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
1228 
1229 #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
1230 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
1231 #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
1232 
1233 /* 802.11g ERP information element */
1234 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
1235 #define WLAN_ERP_USE_PROTECTION (1<<1)
1236 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
1237 
1238 /* WLAN_ERP_BARKER_PREAMBLE values */
1239 enum {
1242 };
1243 
1244 /* Band ID, 802.11ad #8.4.1.45 */
1245 enum {
1246  IEEE80211_BANDID_TV_WS = 0, /* TV white spaces */
1247  IEEE80211_BANDID_SUB1 = 1, /* Sub-1 GHz (excluding TV white spaces) */
1248  IEEE80211_BANDID_2G = 2, /* 2.4 GHz */
1249  IEEE80211_BANDID_3G = 3, /* 3.6 GHz */
1250  IEEE80211_BANDID_5G = 4, /* 4.9 and 5 GHz */
1251  IEEE80211_BANDID_60G = 5, /* 60 GHz */
1252 };
1253 
1254 /* Status codes */
1267  /* 802.11b */
1271  /* 802.11h */
1275  /* 802.11g */
1278  /* 802.11w */
1281  /* 802.11i */
1289  /* 802.11e */
1301  /* 802.11s */
1305  /* 802.11ad */
1316 };
1317 
1318 
1319 /* Reason codes */
1330  /* 802.11h */
1333  /* 802.11i */
1346  /* 802.11e */
1356  /* 802.11s */
1372 };
1373 
1374 
1375 /* Information Element IDs */
1385 
1390 
1399  /* 802.11z */
1401  /* 802.11s */
1423 
1434 
1437 
1440 
1447 
1462 
1468 
1472 
1475 
1476  /* 802.11ad */
1509 };
1510 
1511 /* Action category code */
1531 };
1532 
1533 /* SPECTRUM_MGMT action code */
1540 };
1541 
1542 /* HT action codes */
1552 };
1553 
1554 /* Self Protected Action codes */
1562 };
1563 
1564 /* Mesh action codes */
1577 };
1578 
1579 /* Security key length */
1586 };
1587 
1588 /* Public action codes */
1591 };
1592 
1593 /* TDLS action codes */
1606 };
1607 
1608 /*
1609  * TDLS capabililites to be enabled in the 5th byte of the
1610  * @WLAN_EID_EXT_CAPABILITY information element
1611  */
1612 #define WLAN_EXT_CAPA5_TDLS_ENABLED BIT(5)
1613 #define WLAN_EXT_CAPA5_TDLS_PROHIBITED BIT(6)
1614 
1615 /* TDLS specific payload type in the LLC/SNAP header */
1616 #define WLAN_TDLS_SNAP_RFTYPE 0x2
1617 
1625 enum {
1628 };
1629 
1637 enum {
1640 };
1641 
1649 enum {
1652 };
1653 
1675 };
1676 
1677 /*
1678  * IEEE 802.11-2007 7.3.2.9 Country information element
1679  *
1680  * Minimum length is 8 octets, ie len must be evenly
1681  * divisible by 2
1682  */
1683 
1684 /* Although the spec says 8 I'm seeing 6 in practice */
1685 #define IEEE80211_COUNTRY_IE_MIN_LEN 6
1686 
1687 /* The Country String field of the element shall be 3 octets in length */
1688 #define IEEE80211_COUNTRY_STRING_LEN 3
1689 
1690 /*
1691  * For regulatory extension stuff see IEEE 802.11-2007
1692  * Annex I (page 1141) and Annex J (page 1147). Also
1693  * review 7.3.2.9.
1694  *
1695  * When dot11RegulatoryClassesRequired is true and the
1696  * first_channel/reg_extension_id is >= 201 then the IE
1697  * compromises of the 'ext' struct represented below:
1698  *
1699  * - Regulatory extension ID - when generating IE this just needs
1700  * to be monotonically increasing for each triplet passed in
1701  * the IE
1702  * - Regulatory class - index into set of rules
1703  * - Coverage class - index into air propagation time (Table 7-27),
1704  * in microseconds, you can compute the air propagation time from
1705  * the index by multiplying by 3, so index 10 yields a propagation
1706  * of 10 us. Valid values are 0-31, values 32-255 are not defined
1707  * yet. A value of 0 inicates air propagation of <= 1 us.
1708  *
1709  * See also Table I.2 for Emission limit sets and table
1710  * I.3 for Behavior limit sets. Table J.1 indicates how to map
1711  * a reg_class to an emission limit set and behavior limit set.
1712  */
1713 #define IEEE80211_COUNTRY_EXTENSION_ID 201
1714 
1715 /*
1716  * Channels numbers in the IE must be monotonically increasing
1717  * if dot11RegulatoryClassesRequired is not true.
1718  *
1719  * If dot11RegulatoryClassesRequired is true consecutive
1720  * subband triplets following a regulatory triplet shall
1721  * have monotonically increasing first_channel number fields.
1722  *
1723  * Channel numbers shall not overlap.
1724  *
1725  * Note that max_power is signed.
1726  */
1728  union {
1729  struct {
1733  } __attribute__ ((packed)) chans;
1738  } __attribute__ ((packed)) ext;
1739  };
1740 } __attribute__ ((packed));
1744  WLAN_TIMEOUT_KEY_LIFETIME = 2 /* 802.11r */,
1745  WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
1746 };
1747 
1748 /* BACK action code */
1753 };
1754 
1755 /* BACK (block-ack) parties */
1759 };
1760 
1761 /* SA Query action */
1765 };
1766 
1767 
1768 /* cipher suite selectors */
1769 #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
1770 #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
1771 #define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
1772 /* reserved: 0x000FAC03 */
1773 #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
1774 #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
1775 #define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06
1776 #define WLAN_CIPHER_SUITE_GCMP 0x000FAC08
1777 
1778 #define WLAN_CIPHER_SUITE_SMS4 0x00147201
1779 
1780 /* AKM suite selectors */
1781 #define WLAN_AKM_SUITE_8021X 0x000FAC01
1782 #define WLAN_AKM_SUITE_PSK 0x000FAC02
1783 #define WLAN_AKM_SUITE_SAE 0x000FAC08
1784 #define WLAN_AKM_SUITE_FT_OVER_SAE 0x000FAC09
1785 
1786 #define WLAN_MAX_KEY_LEN 32
1787 
1788 #define WLAN_PMKID_LEN 16
1789 
1790 #define WLAN_OUI_WFA 0x506f9a
1791 #define WLAN_OUI_TYPE_WFA_P2P 9
1792 #define WLAN_OUI_MICROSOFT 0x0050f2
1793 #define WLAN_OUI_TYPE_MICROSOFT_WPA 1
1794 #define WLAN_OUI_TYPE_MICROSOFT_WMM 2
1795 #define WLAN_OUI_TYPE_MICROSOFT_WPS 4
1796 
1797 /*
1798  * WMM/802.11e Tspec Element
1799  */
1800 #define IEEE80211_WMM_IE_TSPEC_TID_MASK 0x0F
1801 #define IEEE80211_WMM_IE_TSPEC_TID_SHIFT 1
1802 
1806 };
1807 
1811  u8 oui[3];
1832 } __packed;
1833 
1843 static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
1844 {
1845  if (ieee80211_has_a4(hdr->frame_control))
1846  return (u8 *)hdr + 30;
1847  else
1848  return (u8 *)hdr + 24;
1849 }
1850 
1861 static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
1862 {
1863  if (ieee80211_has_a4(hdr->frame_control))
1864  return hdr->addr4;
1865  if (ieee80211_has_fromds(hdr->frame_control))
1866  return hdr->addr3;
1867  return hdr->addr2;
1868 }
1869 
1880 static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1881 {
1882  if (ieee80211_has_tods(hdr->frame_control))
1883  return hdr->addr3;
1884  else
1885  return hdr->addr1;
1886 }
1887 
1892 static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
1893 {
1894  if (ieee80211_is_disassoc(hdr->frame_control) ||
1895  ieee80211_is_deauth(hdr->frame_control))
1896  return true;
1897 
1898  if (ieee80211_is_action(hdr->frame_control)) {
1899  u8 *category;
1900 
1901  /*
1902  * Action frames, excluding Public Action frames, are Robust
1903  * Management Frames. However, if we are looking at a Protected
1904  * frame, skip the check since the data may be encrypted and
1905  * the frame has already been found to be a Robust Management
1906  * Frame (by the other end).
1907  */
1908  if (ieee80211_has_protected(hdr->frame_control))
1909  return true;
1910  category = ((u8 *) hdr) + 24;
1911  return *category != WLAN_CATEGORY_PUBLIC &&
1912  *category != WLAN_CATEGORY_HT &&
1913  *category != WLAN_CATEGORY_SELF_PROTECTED &&
1914  *category != WLAN_CATEGORY_VENDOR_SPECIFIC;
1915  }
1916 
1917  return false;
1918 }
1919 
1925 static inline bool ieee80211_is_public_action(struct ieee80211_hdr *hdr,
1926  size_t len)
1927 {
1928  struct ieee80211_mgmt *mgmt = (void *)hdr;
1929 
1930  if (len < IEEE80211_MIN_ACTION_SIZE)
1931  return false;
1932  if (!ieee80211_is_action(hdr->frame_control))
1933  return false;
1934  return mgmt->u.action.category == WLAN_CATEGORY_PUBLIC;
1935 }
1936 
1944 static inline int ieee80211_dsss_chan_to_freq(int channel)
1945 {
1946  if ((channel > 0) && (channel < 14))
1947  return 2407 + (channel * 5);
1948  else if (channel == 14)
1949  return 2484;
1950  else
1951  return -1;
1952 }
1953 
1963 static inline int ieee80211_freq_to_dsss_chan(int freq)
1964 {
1965  if ((freq >= 2410) && (freq < 2475))
1966  return (freq - 2405) / 5;
1967  else if ((freq >= 2482) && (freq < 2487))
1968  return 14;
1969  else
1970  return -1;
1971 }
1972 
1977 static inline unsigned long ieee80211_tu_to_usec(unsigned long tu)
1978 {
1979  return 1024 * tu;
1980 }
1981 
1988 static inline bool ieee80211_check_tim(struct ieee80211_tim_ie *tim,
1989  u8 tim_len, u16 aid)
1990 {
1991  u8 mask;
1992  u8 index, indexn1, indexn2;
1993 
1994  if (unlikely(!tim || tim_len < sizeof(*tim)))
1995  return false;
1996 
1997  aid &= 0x3fff;
1998  index = aid / 8;
1999  mask = 1 << (aid & 7);
2000 
2001  indexn1 = tim->bitmap_ctrl & 0xfe;
2002  indexn2 = tim_len + indexn1 - 4;
2003 
2004  if (index < indexn1 || index > indexn2)
2005  return false;
2006 
2007  index -= indexn1;
2008 
2009  return !!(tim->virtual_map[index] & mask);
2010 }
2011 
2012 #endif /* LINUX_IEEE80211_H */