xref: /openbsd-src/sys/net80211/ieee80211.h (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /*	$OpenBSD: ieee80211.h,v 1.58 2016/05/12 18:18:48 dcoppa Exp $	*/
2 /*	$NetBSD: ieee80211.h,v 1.6 2004/04/30 23:51:53 dyoung Exp $	*/
3 
4 /*-
5  * Copyright (c) 2001 Atsushi Onoe
6  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 #ifndef _NET80211_IEEE80211_H_
30 #define _NET80211_IEEE80211_H_
31 
32 /*
33  * 802.11 protocol definitions.
34  */
35 
36 #define IEEE80211_ADDR_LEN	6	/* size of 802.11 address */
37 /* is 802.11 address multicast/broadcast? */
38 #define IEEE80211_IS_MULTICAST(_a)	(*(_a) & 0x01)
39 
40 /*
41  * Generic definitions for IEEE 802.11 frames.
42  */
43 struct ieee80211_frame {
44 	u_int8_t	i_fc[2];
45 	u_int8_t	i_dur[2];
46 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
47 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
48 	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
49 	u_int8_t	i_seq[2];
50 } __packed;
51 
52 struct ieee80211_qosframe {
53 	u_int8_t	i_fc[2];
54 	u_int8_t	i_dur[2];
55 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
56 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
57 	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
58 	u_int8_t	i_seq[2];
59 	u_int8_t	i_qos[2];
60 } __packed;
61 
62 struct ieee80211_htframe {		/* 11n */
63 	u_int8_t	i_fc[2];
64 	u_int8_t	i_dur[2];
65 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
66 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
67 	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
68 	u_int8_t	i_seq[2];
69 	u_int8_t	i_qos[2];
70 	u_int8_t	i_ht[4];
71 } __packed;
72 
73 struct ieee80211_frame_addr4 {
74 	u_int8_t	i_fc[2];
75 	u_int8_t	i_dur[2];
76 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
77 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
78 	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
79 	u_int8_t	i_seq[2];
80 	u_int8_t	i_addr4[IEEE80211_ADDR_LEN];
81 } __packed;
82 
83 struct ieee80211_qosframe_addr4 {
84 	u_int8_t	i_fc[2];
85 	u_int8_t	i_dur[2];
86 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
87 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
88 	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
89 	u_int8_t	i_seq[2];
90 	u_int8_t	i_addr4[IEEE80211_ADDR_LEN];
91 	u_int8_t	i_qos[2];
92 } __packed;
93 
94 struct ieee80211_htframe_addr4 {	/* 11n */
95 	u_int8_t	i_fc[2];
96 	u_int8_t	i_dur[2];
97 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
98 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
99 	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
100 	u_int8_t	i_seq[2];
101 	u_int8_t	i_addr4[IEEE80211_ADDR_LEN];
102 	u_int8_t	i_qos[2];
103 	u_int8_t	i_ht[4];
104 } __packed;
105 
106 #define	IEEE80211_FC0_VERSION_MASK		0x03
107 #define	IEEE80211_FC0_VERSION_SHIFT		0
108 #define	IEEE80211_FC0_VERSION_0			0x00
109 #define	IEEE80211_FC0_TYPE_MASK			0x0c
110 #define	IEEE80211_FC0_TYPE_SHIFT		2
111 #define	IEEE80211_FC0_TYPE_MGT			0x00
112 #define	IEEE80211_FC0_TYPE_CTL			0x04
113 #define	IEEE80211_FC0_TYPE_DATA			0x08
114 
115 #define	IEEE80211_FC0_SUBTYPE_MASK		0xf0
116 #define	IEEE80211_FC0_SUBTYPE_SHIFT		4
117 /* for TYPE_MGT */
118 #define	IEEE80211_FC0_SUBTYPE_ASSOC_REQ		0x00
119 #define	IEEE80211_FC0_SUBTYPE_ASSOC_RESP	0x10
120 #define	IEEE80211_FC0_SUBTYPE_REASSOC_REQ	0x20
121 #define	IEEE80211_FC0_SUBTYPE_REASSOC_RESP	0x30
122 #define	IEEE80211_FC0_SUBTYPE_PROBE_REQ		0x40
123 #define	IEEE80211_FC0_SUBTYPE_PROBE_RESP	0x50
124 #define	IEEE80211_FC0_SUBTYPE_BEACON		0x80
125 #define	IEEE80211_FC0_SUBTYPE_ATIM		0x90
126 #define	IEEE80211_FC0_SUBTYPE_DISASSOC		0xa0
127 #define	IEEE80211_FC0_SUBTYPE_AUTH		0xb0
128 #define	IEEE80211_FC0_SUBTYPE_DEAUTH		0xc0
129 #define IEEE80211_FC0_SUBTYPE_ACTION		0xd0
130 #define IEEE80211_FC0_SUBTYPE_ACTION_NOACK	0xe0	/* 11n */
131 /* for TYPE_CTL */
132 #define IEEE80211_FC0_SUBTYPE_WRAPPER		0x70	/* 11n */
133 #define IEEE80211_FC0_SUBTYPE_BAR		0x80
134 #define IEEE80211_FC0_SUBTYPE_BA		0x90
135 #define	IEEE80211_FC0_SUBTYPE_PS_POLL		0xa0
136 #define	IEEE80211_FC0_SUBTYPE_RTS		0xb0
137 #define	IEEE80211_FC0_SUBTYPE_CTS		0xc0
138 #define	IEEE80211_FC0_SUBTYPE_ACK		0xd0
139 #define	IEEE80211_FC0_SUBTYPE_CF_END		0xe0
140 #define	IEEE80211_FC0_SUBTYPE_CF_END_ACK	0xf0
141 /* for TYPE_DATA (bit combination) */
142 #define	IEEE80211_FC0_SUBTYPE_DATA		0x00
143 #define	IEEE80211_FC0_SUBTYPE_CF_ACK		0x10
144 #define	IEEE80211_FC0_SUBTYPE_CF_POLL		0x20
145 #define	IEEE80211_FC0_SUBTYPE_CF_ACPL		0x30
146 #define	IEEE80211_FC0_SUBTYPE_NODATA		0x40
147 #define	IEEE80211_FC0_SUBTYPE_CFACK		0x50
148 #define	IEEE80211_FC0_SUBTYPE_CFPOLL		0x60
149 #define	IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK	0x70
150 #define	IEEE80211_FC0_SUBTYPE_QOS		0x80
151 
152 #define	IEEE80211_FC1_DIR_MASK			0x03
153 #define	IEEE80211_FC1_DIR_NODS			0x00	/* STA->STA */
154 #define	IEEE80211_FC1_DIR_TODS			0x01	/* STA->AP  */
155 #define	IEEE80211_FC1_DIR_FROMDS		0x02	/* AP ->STA */
156 #define	IEEE80211_FC1_DIR_DSTODS		0x03	/* AP ->AP  */
157 
158 #define	IEEE80211_FC1_MORE_FRAG			0x04
159 #define	IEEE80211_FC1_RETRY			0x08
160 #define	IEEE80211_FC1_PWR_MGT			0x10
161 #define	IEEE80211_FC1_MORE_DATA			0x20
162 #define	IEEE80211_FC1_PROTECTED			0x40
163 #define	IEEE80211_FC1_WEP			0x40	/* pre-RSNA compat */
164 #define	IEEE80211_FC1_ORDER			0x80
165 #define IEEE80211_FC1_BITS					\
166 	"\20\03MORE_FRAG\04RETRY\05PWR_MGT\06MORE_DATA"		\
167 	"\07PROTECTED\08ORDER"
168 
169 /*
170  * Sequence Control field (see 802.11-2012 8.2.4.4).
171  */
172 #define	IEEE80211_SEQ_FRAG_MASK			0x000f
173 #define	IEEE80211_SEQ_FRAG_SHIFT		0
174 #define	IEEE80211_SEQ_SEQ_MASK			0xfff0
175 #define	IEEE80211_SEQ_SEQ_SHIFT			4
176 
177 #define	IEEE80211_NWID_LEN			32
178 #define IEEE80211_MMIE_LEN			18	/* 11w */
179 
180 /*
181  * QoS Control field (see 802.11-2012 8.2.4.5).
182  */
183 #define IEEE80211_QOS_TXOP			0xff00
184 #define IEEE80211_QOS_AMSDU			0x0080	/* 11n */
185 #define IEEE80211_QOS_ACK_POLICY_NORMAL		0x0000
186 #define IEEE80211_QOS_ACK_POLICY_NOACK		0x0020
187 #define IEEE80211_QOS_ACK_POLICY_NOEXPLACK	0x0040
188 #define IEEE80211_QOS_ACK_POLICY_BA		0x0060
189 #define IEEE80211_QOS_ACK_POLICY_MASK		0x0060
190 #define IEEE80211_QOS_ACK_POLICY_SHIFT		5
191 #define IEEE80211_QOS_EOSP			0x0010
192 #define IEEE80211_QOS_TID			0x000f
193 
194 /*
195  * Control frames.
196  */
197 struct ieee80211_frame_min {
198 	u_int8_t	i_fc[2];
199 	u_int8_t	i_dur[2];
200 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
201 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
202 	/* FCS */
203 } __packed;
204 
205 struct ieee80211_frame_rts {
206 	u_int8_t	i_fc[2];
207 	u_int8_t	i_dur[2];
208 	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
209 	u_int8_t	i_ta[IEEE80211_ADDR_LEN];
210 	/* FCS */
211 } __packed;
212 
213 struct ieee80211_frame_cts {
214 	u_int8_t	i_fc[2];
215 	u_int8_t	i_dur[2];
216 	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
217 	/* FCS */
218 } __packed;
219 
220 struct ieee80211_frame_ack {
221 	u_int8_t	i_fc[2];
222 	u_int8_t	i_dur[2];
223 	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
224 	/* FCS */
225 } __packed;
226 
227 struct ieee80211_frame_pspoll {
228 	u_int8_t	i_fc[2];
229 	u_int8_t	i_aid[2];
230 	u_int8_t	i_bssid[IEEE80211_ADDR_LEN];
231 	u_int8_t	i_ta[IEEE80211_ADDR_LEN];
232 	/* FCS */
233 } __packed;
234 
235 struct ieee80211_frame_cfend {		/* NB: also CF-End+CF-Ack */
236 	u_int8_t	i_fc[2];
237 	u_int8_t	i_dur[2];	/* should be zero */
238 	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
239 	u_int8_t	i_bssid[IEEE80211_ADDR_LEN];
240 	/* FCS */
241 } __packed;
242 
243 #ifdef _KERNEL
244 static __inline int
245 ieee80211_has_seq(const struct ieee80211_frame *wh)
246 {
247 	return (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
248 	    IEEE80211_FC0_TYPE_CTL;
249 }
250 
251 static __inline int
252 ieee80211_has_addr4(const struct ieee80211_frame *wh)
253 {
254 	return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) ==
255 	    IEEE80211_FC1_DIR_DSTODS;
256 }
257 
258 static __inline int
259 ieee80211_has_qos(const struct ieee80211_frame *wh)
260 {
261 	return (wh->i_fc[0] &
262 	    (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) ==
263 	    (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS);
264 }
265 
266 static __inline int
267 ieee80211_has_htc(const struct ieee80211_frame *wh)
268 {
269 	return (wh->i_fc[1] & IEEE80211_FC1_ORDER) &&
270 	    (ieee80211_has_qos(wh) ||
271 	     (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
272 	     IEEE80211_FC0_TYPE_MGT);
273 }
274 
275 static __inline u_int16_t
276 ieee80211_get_qos(const struct ieee80211_frame *wh)
277 {
278 	const u_int8_t *frm;
279 
280 	if (ieee80211_has_addr4(wh))
281 		frm = ((const struct ieee80211_qosframe_addr4 *)wh)->i_qos;
282 	else
283 		frm = ((const struct ieee80211_qosframe *)wh)->i_qos;
284 
285 	return letoh16(*(const u_int16_t *)frm);
286 }
287 #endif	/* _KERNEL */
288 
289 /*
290  * Capability Information field (see 802.11-2012 8.4.1.4).
291  */
292 #define	IEEE80211_CAPINFO_ESS			0x0001
293 #define	IEEE80211_CAPINFO_IBSS			0x0002
294 #define	IEEE80211_CAPINFO_CF_POLLABLE		0x0004
295 #define	IEEE80211_CAPINFO_CF_POLLREQ		0x0008
296 #define	IEEE80211_CAPINFO_PRIVACY		0x0010
297 #define	IEEE80211_CAPINFO_SHORT_PREAMBLE	0x0020
298 #define	IEEE80211_CAPINFO_PBCC			0x0040
299 #define	IEEE80211_CAPINFO_CHNL_AGILITY		0x0080
300 #define IEEE80211_CAPINFO_SPECTRUM_MGMT		0x0100
301 #define IEEE80211_CAPINFO_QOS			0x0200
302 #define	IEEE80211_CAPINFO_SHORT_SLOTTIME	0x0400
303 #define	IEEE80211_CAPINFO_APSD			0x0800
304 #define	IEEE80211_CAPINFO_RADIO_MEASUREMENT	0x1000
305 #define	IEEE80211_CAPINFO_DSSSOFDM		0x2000
306 #define IEEE80211_CAPINFO_DELAYED_B_ACK		0x4000
307 #define IEEE80211_CAPINFO_IMMEDIATE_B_ACK	0x8000
308 #define IEEE80211_CAPINFO_BITS					\
309 	"\10\01ESS\02IBSS\03CF_POLLABLE\04CF_POLLREQ"		\
310 	"\05PRIVACY\06SHORT_PREAMBLE\07PBCC\10CHNL_AGILITY"	\
311 	"\11SPECTRUM_MGMT\12QOS\13SHORT_SLOTTIME\14APSD"	\
312 	"\15RADIO_MEASUREMENT\16DSSSOFDM\17DELAYED_B_ACK\20IMMEDIATE_B_ACK"
313 
314 /*
315  * Information element IDs (see 802.11-2012 Table 8.4.2).
316  */
317 enum {
318 	IEEE80211_ELEMID_SSID			= 0,
319 	IEEE80211_ELEMID_RATES			= 1,
320 	IEEE80211_ELEMID_FHPARMS		= 2,
321 	IEEE80211_ELEMID_DSPARMS		= 3,
322 	IEEE80211_ELEMID_CFPARMS		= 4,
323 	IEEE80211_ELEMID_TIM			= 5,
324 	IEEE80211_ELEMID_IBSSPARMS		= 6,
325 	IEEE80211_ELEMID_COUNTRY		= 7,
326 	IEEE80211_ELEMID_HOPPING_PARMS		= 8,
327 	IEEE80211_ELEMID_HOPPING_PATTERN	= 9,
328 	IEEE80211_ELEMID_REQUEST		= 10,
329 	IEEE80211_ELEMID_QBSS_LOAD		= 11,
330 	IEEE80211_ELEMID_EDCAPARMS		= 12,
331 	IEEE80211_ELEMID_TSPEC			= 13,
332 	IEEE80211_ELEMID_TCLASS			= 14,
333 	IEEE80211_ELEMID_SCHEDULE		= 15,
334 	IEEE80211_ELEMID_CHALLENGE		= 16,
335 	/* 17-31 reserved for challenge text extension */
336 	IEEE80211_ELEMID_POWER_CONSTRAINT	= 32,
337 	IEEE80211_ELEMID_POWER_CAP		= 33,
338 	IEEE80211_ELEMID_TPC_REQUEST		= 34,
339 	IEEE80211_ELEMID_TPC_REPORT		= 35,
340 	IEEE80211_ELEMID_SUPP_CHNLS		= 35,
341 	IEEE80211_ELEMID_CSA			= 37,	/* 11h */
342 	IEEE80211_ELEMID_MEASUREMENT_REQUEST	= 38,	/* DFS */
343 	IEEE80211_ELEMID_MEASUREMENT_REPORT	= 39,	/* DFS */
344 	IEEE80211_ELEMID_QUIET			= 40,
345 	IEEE80211_ELEMID_IBSS_DFS		= 41,
346 	IEEE80211_ELEMID_ERP			= 42,
347 	IEEE80211_ELEMID_TS_DELAY		= 43,
348 	IEEE80211_ELEMID_TCLAS			= 44,
349 	IEEE80211_ELEMID_HTCAPS			= 45,	/* 11n */
350 	IEEE80211_ELEMID_QOS_CAP		= 46,
351 	/* 47 reserved */
352 	IEEE80211_ELEMID_RSN			= 48,
353 	/* 49 reserved */
354 	IEEE80211_ELEMID_XRATES			= 50,
355 	IEEE80211_ELEMID_AP_CHNL_REPORT		= 51,
356 	IEEE80211_ELEMID_NBR_REPORT		= 52,
357 	IEEE80211_ELEMID_RCPI			= 53,
358 	IEEE80211_ELEMID_MDE			= 54,
359 	IEEE80211_ELEMID_FTE			= 55,
360 	IEEE80211_ELEMID_TIE			= 56,	/* 11r */
361 	IEEE80211_ELEMID_RDE			= 57,
362 	IEEE80211_ELEMID_DSE			= 58,
363 	IEEE80211_ELEMID_SUPP_OPCLASS		= 59,
364 	IEEE80211_ELEMID_XCSA			= 60,
365 	IEEE80211_ELEMID_HTOP			= 61,	/* 11n */
366 	IEEE80211_ELEMID_SECONDARY_CHANL_OFFSET	= 62,	/* 11n */
367 	IEEE80211_ELEMID_AVG_ACCESS_DELAY	= 63,
368 	IEEE80211_ELEMID_ANTENNA		= 64,
369 	IEEE80211_ELEMID_RSNI			= 65,
370 	IEEE80211_ELEMID_MEASUREMENT_PILOT_TX	= 66,
371 	IEEE80211_ELEMID_AVAIL_CAPACITY		= 67,
372 	IEEE80211_ELEMID_AC_ACCESS_DELAY	= 68,
373 	IEEE80211_ELEMID_TIME_ADVERT		= 69,
374 	IEEE80211_ELEMID_RM			= 70,
375 	IEEE80211_ELEMID_MULTI_BSSID		= 71,
376 	IEEE80211_ELEMID_20_40_CBW_COEX		= 72,	/* 11n */
377 	IEEE80211_ELEMID_20_40_CBW_INTOLERANT	= 73,	/* 11n */
378 	IEEE80211_ELEMID_SCAN_PARAM_OVERLAP	= 74,
379 	IEEE80211_ELEMID_RIC			= 75,
380 	IEEE80211_ELEMID_MMIE			= 76,	/* 11w */
381 	IEEE80211_ELEMID_EVENT_REQUEST		= 78,
382 	IEEE80211_ELEMID_EVENT_REPORT		= 79,
383 	IEEE80211_ELEMID_DIAG_REQUEST		= 80,
384 	IEEE80211_ELEMID_DIAG_REPORT		= 81,
385 	IEEE80211_ELEMID_LOCATION_PARMS		= 82,
386 	IEEE80211_ELEMID_NONTX_BSSID		= 83,
387 	IEEE80211_ELEMID_SSID_LIST		= 84,
388 	IEEE80211_ELEMID_MULTI_BSSID_IDX	= 85,
389 	IEEE80211_ELEMID_FMS_DESC		= 86,
390 	IEEE80211_ELEMID_FMS_REQUEST		= 87,
391 	IEEE80211_ELEMID_FMS_RESPONSE		= 88,
392 	IEEE80211_ELEMID_QOS_TRAFFIC_CAP	= 89,
393 	IEEE80211_ELEMID_MAX_IDLE_PERIOD	= 90,
394 	IEEE80211_ELEMID_TFS_REQUEST		= 91,
395 	IEEE80211_ELEMID_TFS_RESPONSE		= 92,
396 	IEEE80211_ELEMID_WNM_SLEEP		= 93,
397 	IEEE80211_ELEMID_TIM_BCAST_REQUEST	= 94,
398 	IEEE80211_ELEMID_TIM_BCAST_RESPONSE	= 95,
399 	IEEE80211_ELEMID_INTERFERENCE_REPORT	= 96,
400 	IEEE80211_ELEMID_CHNL_USAGE		= 97,
401 	IEEE80211_ELEMID_TIME_ZONE		= 98,
402 	IEEE80211_ELEMID_DMS_REQUEST		= 99,
403 	IEEE80211_ELEMID_DMS_RESPONSE		= 100,
404 	IEEE80211_ELEMID_LINK_ID		= 101,
405 	IEEE80211_ELEMID_WAKE_SCHED		= 102,
406 	/* 103 undefined */
407 	IEEE80211_ELEMID_CHNL_SWITCH_TIMING	= 104,
408 	IEEE80211_ELEMID_PTI_CTRL		= 105,
409 	IEEE80211_ELEMID_TPU_BUF_STATUS		= 106,
410 	IEEE80211_ELEMID_INTERWORKING		= 107,
411 	IEEE80211_ELEMID_ADVERT_PROTOCOL	= 108,
412 	IEEE80211_ELEMID_EXPEDITED_BW_REQUEST	= 109,
413 	IEEE80211_ELEMID_QOS_MAP_SET		= 110,
414 	IEEE80211_ELEMID_ROAMING_CONSORTIUM	= 111,
415 	IEEE80211_ELEMID_EMERGENCY_ALERT_ID	= 112,
416 	IEEE80211_ELEMID_MESHCONF		= 113,
417 	IEEE80211_ELEMID_MESHID			= 114,
418 	IEEE80211_ELEMID_MESHLINK		= 115,
419 	IEEE80211_ELEMID_MESHCNGST		= 116,
420 	IEEE80211_ELEMID_MESHPEER		= 117,
421 	IEEE80211_ELEMID_MESHCSA		= 118,
422 	IEEE80211_ELEMID_MESHAWAKEW		= 119,
423 	IEEE80211_ELEMID_MESHBEACONT		= 120,
424 	IEEE80211_ELEMID_MCCAOP_SETUP_REQUEST	= 121,
425 	IEEE80211_ELEMID_MCCAOP_SETUP_REPLY	= 122,
426 	IEEE80211_ELEMID_MCCAOP_ADVERT		= 123,
427 	IEEE80211_ELEMID_MCCAOP_TEARDOWN	= 124,
428 	IEEE80211_ELEMID_MESHGANN		= 125,
429 	IEEE80211_ELEMID_MESHRANN		= 126,
430 	IEEE80211_ELEMID_XCAPS			= 127,
431 	/* 128-129 reserved */
432 	IEEE80211_ELEMID_MESHPREQ		= 130,
433 	IEEE80211_ELEMID_MESHPREP		= 131,
434 	IEEE80211_ELEMID_MESHPERR		= 132,
435 	/* 133-136 reserved */
436 	IEEE80211_ELEMID_MESHPXU		= 137,
437 	IEEE80211_ELEMID_MESHPXUC		= 138,
438 	IEEE80211_ELEMID_AUTH_MESH_PEERING_XCHG	= 139,
439 	IEEE80211_ELEMID_MIC			= 140,
440 	IEEE80211_ELEMID_DEST_URI		= 141,
441 	IEEE80211_ELEMID_U_APSD_COEX		= 142,
442 	/* 143-174 reserved */
443 	IEEE80211_ELEMID_MCCAOP_ADVERT_OVIEW	= 174,
444 	/* 175-220 reserved */
445 	IEEE80211_ELEMID_VENDOR			= 221	/* vendor private */
446 	/* 222-255 reserved */
447 };
448 
449 /*
450  * Action field category values (see 802.11-2012 8.4.1.11 Table 8-38).
451  */
452 enum {
453 	IEEE80211_CATEG_SPECTRUM		= 0,
454 	IEEE80211_CATEG_QOS			= 1,
455 	IEEE80211_CATEG_DLS			= 2,
456 	IEEE80211_CATEG_BA			= 3,
457 	IEEE80211_CATEG_PUB			= 4,
458 	IEEE80211_CATEG_RADIO_MSRMNT		= 5,
459 	IEEE80211_CATEG_FAST_BSS_TRANS		= 6,
460 	IEEE80211_CATEG_HT			= 7,	/* 11n */
461 	IEEE80211_CATEG_SA_QUERY		= 8,	/* 11w */
462 	IEEE80211_CATEG_PROT_DUAL_PUBLIC_ACTION	= 9,
463 	IEEE80211_CATEG_WNM			= 10,
464 	IEEE80211_CATEG_UNPROT_WNM		= 11,
465 	IEEE80211_CATEG_TDLS			= 12,
466 	IEEE80211_CATEG_MESH			= 13,
467 	IEEE80211_CATEG_MULTIHOP		= 14,
468 	IEEE80211_CATEG_SELF_PROT		= 15,
469 	/* 16-125 reserved */
470 	IEEE80211_CATEG_PROT_VENDOR		= 126,
471 	IEEE80211_CATEG_VENDOR			= 127
472 	/* 128-255 error */
473 };
474 
475 /*
476  * Block Ack Action field values (see 802.11-2012 8.5.5 Table 8-202).
477  */
478 #define IEEE80211_ACTION_ADDBA_REQ	0
479 #define IEEE80211_ACTION_ADDBA_RESP	1
480 #define IEEE80211_ACTION_DELBA		2
481 /* 3-255 reserved */
482 
483 /*
484  * SA Query Action field values (see 802.11-2012 8.5.10 Table 8-227).
485  */
486 #define IEEE80211_ACTION_SA_QUERY_REQ	0
487 #define IEEE80211_ACTION_SA_QUERY_RESP	1
488 
489 /*
490  * HT Action field values (see 802.11-2012 8.5.12 Table 8-229).
491  */
492 #define IEEE80211_ACTION_NOTIFYCW		0
493 #define IEEE80211_ACTION_SM_PWRSAVE		1
494 #define IEEE80211_ACTION_PSMP			2
495 #define IEEE80211_ACTION_SET_PCO_PHASE		3
496 #define IEEE80211_ACTION_CSI			4
497 #define IEEE80211_ACTION_NONCOMPRESSED_BF	5
498 #define IEEE80211_ACTION_COMPRESSED_BF		6
499 #define IEEE80211_ACTION_ASEL_IDX_FEEDBACK	7
500 /* 8-255 reserved */
501 
502 #define	IEEE80211_RATE_BASIC			0x80
503 #define	IEEE80211_RATE_VAL			0x7f
504 #define	IEEE80211_RATE_SIZE			8	/* 802.11 standard */
505 #define	IEEE80211_RATE_MAXSIZE			15	/* max rates we'll handle */
506 
507 #define	IEEE80211_HT_NUM_MCS			77
508 
509 /*
510  * BlockAck/BlockAckReq Control field (see 802.11-2012 8.3.1.9 Figure 8-25).
511  */
512 #define IEEE80211_BA_ACK_POLICY		0x0001
513 #define IEEE80211_BA_MULTI_TID		0x0002
514 #define IEEE80211_BA_COMPRESSED		0x0004
515 #define IEEE80211_BA_TID_INFO_MASK	0xf000
516 #define IEEE80211_BA_TID_INFO_SHIFT	12
517 
518 /*
519  * ADDBA Parameter Set field (see 802.11-2012 8.4.1.14 Figure 8-48).
520  */
521 #define IEEE80211_ADDBA_AMSDU		0x0001 /* A-MSDU in A-MPDU supported */
522 #define IEEE80211_ADDBA_BA_POLICY	0x0002 /* 1=immediate BA 0=delayed BA */
523 #define IEEE80211_ADDBA_TID_MASK	0x003c
524 #define IEEE80211_ADDBA_TID_SHIFT	2
525 #define IEEE80211_ADDBA_BUFSZ_MASK	0xffc0
526 #define IEEE80211_ADDBA_BUFSZ_SHIFT	6
527 
528 /*
529  * DELBA Parameter Set field (see 802.11-2012 8.4.1.16 Figure 8-50).
530  */
531 #define IEEE80211_DELBA_INITIATOR	0x0800
532 #define IEEE80211_DELBA_TID_INFO_MASK	0xf000
533 #define IEEE80211_DELBA_TID_INFO_SHIFT	12
534 
535 /*
536  * ERP information element parameters (see 802.11-2012 8.4.2.14 Figure 8-95).
537  */
538 #define	IEEE80211_ERP_NON_ERP_PRESENT		0x01
539 #define	IEEE80211_ERP_USE_PROTECTION		0x02
540 #define	IEEE80211_ERP_BARKER_MODE		0x04
541 
542 /*
543  * RSN capabilities (see 802.11-2012 8.4.2.27.4).
544  */
545 #define IEEE80211_RSNCAP_PREAUTH		0x0001
546 #define IEEE80211_RSNCAP_NOPAIRWISE		0x0002
547 #define IEEE80211_RSNCAP_PTKSA_RCNT_MASK	0x000c
548 #define IEEE80211_RSNCAP_PTKSA_RCNT_SHIFT	2
549 #define IEEE80211_RSNCAP_GTKSA_RCNT_MASK	0x0030
550 #define IEEE80211_RSNCAP_GTKSA_RCNT_SHIFT	4
551 #define IEEE80211_RSNCAP_RCNT1			0
552 #define IEEE80211_RSNCAP_RCNT2			1
553 #define IEEE80211_RSNCAP_RCNT4			2
554 #define IEEE80211_RSNCAP_RCNT16			3
555 #define IEEE80211_RSNCAP_MFPR			0x0040	/* 11w */
556 #define IEEE80211_RSNCAP_MFPC			0x0080	/* 11w */
557 #define IEEE80211_RSNCAP_PEERKEYENA		0x0200
558 #define IEEE80211_RSNCAP_SPPAMSDUC		0x0400	/* 11n */
559 #define IEEE80211_RSNCAP_SPPAMSDUR		0x0800	/* 11n */
560 #define IEEE80211_RSNCAP_PBAC			0x1000	/* 11n */
561 #define IEEE80211_RSNCAP_EXTENDED_KEYID		0x2000
562 
563 /*
564  * HT Capabilities Info (see 802.11-2012 8.4.2.58.2).
565  */
566 #define IEEE80211_HTCAP_LDPC		0x00000001
567 #define IEEE80211_HTCAP_CBW20_40	0x00000002
568 #define IEEE80211_HTCAP_SMPS_MASK	0x0000000c
569 #define IEEE80211_HTCAP_SMPS_SHIFT	2
570 #define IEEE80211_HTCAP_SMPS_STA	0
571 #define IEEE80211_HTCAP_SMPS_DYN	1
572 #define IEEE80211_HTCAP_SMPS_DIS	3
573 #define IEEE80211_HTCAP_GF		0x00000010
574 #define IEEE80211_HTCAP_SGI20		0x00000020
575 #define IEEE80211_HTCAP_SGI40		0x00000040
576 #define IEEE80211_HTCAP_TXSTBC		0x00000080
577 #define IEEE80211_HTCAP_RXSTBC_MASK	0x00000300
578 #define IEEE80211_HTCAP_RXSTBC_SHIFT	8
579 #define IEEE80211_HTCAP_DELAYEDBA	0x00000400
580 #define IEEE80211_HTCAP_AMSDU7935	0x00000800
581 #define IEEE80211_HTCAP_DSSSCCK40	0x00001000
582 #define IEEE80211_HTCAP_PSMP		0x00002000
583 #define IEEE80211_HTCAP_40INTOLERANT	0x00004000
584 #define IEEE80211_HTCAP_LSIGTXOPPROT	0x00008000
585 
586 /*
587  * HT A-MPDU parameters (see 802.11-2012 8.4.2.58.3).
588  */
589 #define IEEE80211_AMPDU_PARAM_LE	0x03
590 #define IEEE80211_AMPDU_PARAM_SS	0x1c
591 #define IEEE80211_AMPDU_PARAM_SS_NONE	(0 << 2)
592 #define IEEE80211_AMPDU_PARAM_SS_0_25	(1 << 2)
593 #define IEEE80211_AMPDU_PARAM_SS_0_5	(2 << 2)
594 #define IEEE80211_AMPDU_PARAM_SS_1	(3 << 2)
595 #define IEEE80211_AMPDU_PARAM_SS_2	(4 << 2)
596 #define IEEE80211_AMPDU_PARAM_SS_4	(5 << 2)
597 #define IEEE80211_AMPDU_PARAM_SS_8	(6 << 2)
598 #define IEEE80211_AMPDU_PARAM_SS_16	(7 << 2)
599 /* bits 5-7 reserved */
600 
601 /*
602  * HT Supported MCS Set (see 802.11-2012 8.4.2.58.4).
603  * This field is 16 bytes in size. Bitmasks given below
604  * operate on 8 or 16 bit integer subsets of this field
605  * for use with ieee80211com and ieee80211_node.
606  */
607 /* Bits 0-76: Supported Rx MCS bitmask */
608 /* Bits 77-79: Reserved */
609 /* Bits 80-89: Highest Rx rate in units of 1MB/s */
610 #define IEEE80211_MCS_RX_RATE_HIGH	0x03ff
611 /* Bits 90-95: Reserved */
612 /* Bits 96-100: Tx MCS set */
613 #define IEEE80211_TX_MCS_SET_DEFINED		0x01
614 #define IEEE80211_TX_RX_MCS_NOT_EQUAL		0x02
615 #define IEEE80211_TX_SPATIAL_STREAMS		0x18
616 #define IEEE80211_TX_UNEQUAL_MODULATION		0x20
617 /* Bits 101-127: Reserved */
618 
619 /*
620  * HT Extended Capabilities (see 802.11-2012 8.4.2.58.5).
621  */
622 #define IEEE80211_HTXCAP_PCO		0x0001
623 #define IEEE80211_HTXCAP_PCOTT_MASK	0x0006
624 #define IEEE80211_HTXCAP_PCOTT_SHIFT	1
625 #define IEEE80211_HTXCAP_PCOTT_400	1
626 #define IEEE80211_HTXCAP_PCOTT_1500	2
627 #define IEEE80211_HTXCAP_PCOTT_5000	3
628 /* Bits 3-7 are reserved. */
629 #define IEEE80211_HTXCAP_MFB_MASK	0x0300
630 #define IEEE80211_HTXCAP_MFB_SHIFT	8
631 #define IEEE80211_HTXCAP_MFB_NONE	0
632 #define IEEE80211_HTXCAP_MFB_UNSOL	2
633 #define IEEE80211_HTXCAP_MFB_BOTH	3
634 #define IEEE80211_HTXCAP_HTC		0x0400
635 #define IEEE80211_HTXCAP_RDRESP		0x0800
636 /* Bits 12-15 are reserved. */
637 
638 /*
639  * Transmit Beamforming (TxBF) Capabilities (see 802.11-2012 8.4.2.58.6).
640  */
641 #define IEEE80211_TXBFCAP_IMPLICIT_RX			0x00000001
642 #define IEEE80211_TXBFCAP_RSSC				0x00000002
643 #define IEEE80211_TXBFCAP_TSSC				0x00000004
644 #define IEEE80211_TXBFCAP_RNDP				0x00000008
645 #define IEEE80211_TXBFCAP_TNDP				0x00000010
646 #define IEEE80211_TXBFCAP_IMPLICIT_TX			0x00000020
647 #define IEEE80211_TXBFCAP_CALIB_MASK			0x000000c0
648 #define IEEE80211_TXBFCAP_CALIB_SHIFT			6
649 #define IEEE80211_TXBFCAP_TX_CSI			0x00000100
650 #define IEEE80211_TXBFCAP_EXPLICIT_NSC			0x00000200
651 #define IEEE80211_TXBFCAP_EXPLICIT_CSC			0x00000400
652 #define IEEE80211_TXBFCAP_CSI_FB_DELAYED		0x00000800
653 #define IEEE80211_TXBFCAP_CSI_FB_IMMEDIATE		0x00001000
654 #define IEEE80211_TXBFCAP_EXPLICIT_NB_FB_DELAYED	0x00002000
655 #define IEEE80211_TXBFCAP_EXPLICIT_NB_FB_IMMEDIATE	0x00004000
656 #define IEEE80211_TXBFCAP_EXPLICIT_CB_FB_DELAYED	0x00008000
657 #define IEEE80211_TXBFCAP_EXPLICIT_CB_FB_IMMEDIATE	0x00010000
658 #define IEEE80211_TXBFCAP_MINIMAL_GROUPING_1_2		0x00020000
659 #define IEEE80211_TXBFCAP_MINIMAL_GROUPING_1_4		0x00040000
660 #define IEEE80211_TXBFCAP_CSI_NUM_ANT_MASK		0x00180000
661 #define IEEE80211_TXBFCAP_CSI_NUM_ANT_SHIFT		19
662 #define IEEE80211_TXBFCAP_NS_NUM_ANT_MASK		0x00600000
663 #define IEEE80211_TXBFCAP_NS_NUM_ANT_SHIFT		21
664 #define IEEE80211_TXBFCAP_CS_NUM_ANT_MASK		0x01800000
665 #define IEEE80211_TXBFCAP_CS_NUM_ANT_SHIFT		23
666 #define IEEE80211_TXBFCAP_CSI_NUM_ROWS_MASK		0x06000000
667 #define IEEE80211_TXBFCAP_CSI_NUM_ROWS_SHIFT		25
668 #define IEEE80211_TXBFCAP_CHANL_ESTIMATE_MASK		0x18000000
669 #define IEEE80211_TXBFCAP_CHANL_ESTIMATE_SHIFT		27
670 
671 /*
672  * Antenna Selection (ASEL) Capability (see 802.11-2012 8.4.2.58.7).
673  */
674 #define IEEE80211_ASELCAP_ASEL		0x01
675 #define IEEE80211_ASELCAP_CSIFB_TX	0x02
676 #define IEEE80211_ASELCAP_ANT_IDX_FB_TX	0x04
677 #define IEEE80211_ASELCAP_CSIFB		0x08
678 #define IEEE80211_ASELCAP_ANT_IDX_FB	0x10
679 #define IEEE80211_ASELCAP_ASEL_RX	0x20
680 #define IEEE80211_ASELCAP_TX_SOUND_PPDU	0x20
681 /* Bit 7 is reserved. */
682 
683 /*
684  * HT Operation element (see 802.11-2012 8.4.2.59).
685  */
686 /* Byte 0 contains primary channel number. */
687 /* Byte 1. */
688 #define IEEE80211_HTOP0_SCO_MASK	0x03
689 #define IEEE80211_HTOP0_SCO_SHIFT	0
690 #define IEEE80211_HTOP0_SCO_SCN		0
691 #define IEEE80211_HTOP0_SCO_SCA		1
692 #define IEEE80211_HTOP0_SCO_SCB		3
693 #define IEEE80211_HTOP0_CHW		0x04
694 #define IEEE80211_HTOP0_RIFS		0x08
695 /* bits 4-7 reserved */
696 /* Bytes 2-3. */
697 #define IEEE80211_HTOP1_PROT_MASK	0x0003
698 #define IEEE80211_HTOP1_PROT_SHIFT	0
699 #define IEEE80211_HTOP1_NONGF_STA	0x0004
700 /* Bit 3 is reserved. */
701 #define IEEE80211_HTOP1_OBSS_NONHT_STA	0x0010
702 /* Bits 5-15 are reserved. */
703 /* Bytes 4-5. */
704 /* Bits 0-5 are reserved. */
705 #define IEEE80211_HTOP2_DUALBEACON	0x0040
706 #define IEEE80211_HTOP2_DUALCTSPROT	0x0080
707 #define IEEE80211_HTOP2_STBCBEACON	0x0100
708 #define IEEE80211_HTOP2_LSIGTXOP	0x0200
709 #define IEEE80211_HTOP2_PCOACTIVE	0x0400
710 #define IEEE80211_HTOP2_PCOPHASE40	0x0800
711 /* Bits 12-15 are reserved. */
712 
713 /*
714  * EDCA Access Categories.
715  */
716 enum ieee80211_edca_ac {
717 	EDCA_AC_BK  = 1,	/* Background */
718 	EDCA_AC_BE  = 0,	/* Best Effort */
719 	EDCA_AC_VI  = 2,	/* Video */
720 	EDCA_AC_VO  = 3		/* Voice */
721 };
722 #define EDCA_NUM_AC	4
723 
724 /* number of TID values (traffic identifier) */
725 #define IEEE80211_NUM_TID	16
726 
727 /* Atheros private advanced capabilities info */
728 #define	ATHEROS_CAP_TURBO_PRIME			0x01
729 #define	ATHEROS_CAP_COMPRESSION			0x02
730 #define	ATHEROS_CAP_FAST_FRAME			0x04
731 /* bits 3-6 reserved */
732 #define	ATHEROS_CAP_BOOST			0x80
733 
734 /*-
735  * Organizationally Unique Identifiers.
736  * See http://standards.ieee.org/regauth/oui/oui.txt for a list.
737  */
738 #define ATHEROS_OUI	((const u_int8_t[]){ 0x00, 0x03, 0x7f })
739 #define BROADCOM_OUI	((const u_int8_t[]){ 0x00, 0x90, 0x4c })
740 #define IEEE80211_OUI	((const u_int8_t[]){ 0x00, 0x0f, 0xac })
741 #define MICROSOFT_OUI	((const u_int8_t[]){ 0x00, 0x50, 0xf2 })
742 
743 #define	IEEE80211_AUTH_ALGORITHM(auth) \
744 	((auth)[0] | ((auth)[1] << 8))
745 #define	IEEE80211_AUTH_TRANSACTION(auth) \
746 	((auth)[2] | ((auth)[3] << 8))
747 #define	IEEE80211_AUTH_STATUS(auth) \
748 	((auth)[4] | ((auth)[5] << 8))
749 
750 /*
751  * Authentication Algorithm Number field (see 7.3.1.1).
752  */
753 #define IEEE80211_AUTH_ALG_OPEN			0x0000
754 #define IEEE80211_AUTH_ALG_SHARED		0x0001
755 #define IEEE80211_AUTH_ALG_LEAP			0x0080
756 
757 /*
758  * Authentication Transaction Sequence Number field (see 7.3.1.2).
759  */
760 enum {
761 	IEEE80211_AUTH_OPEN_REQUEST		= 1,
762 	IEEE80211_AUTH_OPEN_RESPONSE		= 2
763 };
764 enum {
765 	IEEE80211_AUTH_SHARED_REQUEST		= 1,
766 	IEEE80211_AUTH_SHARED_CHALLENGE		= 2,
767 	IEEE80211_AUTH_SHARED_RESPONSE		= 3,
768 	IEEE80211_AUTH_SHARED_PASS		= 4
769 };
770 
771 /*
772  * Reason codes (see Table 22).
773  */
774 enum {
775 	IEEE80211_REASON_UNSPECIFIED		= 1,
776 	IEEE80211_REASON_AUTH_EXPIRE		= 2,
777 	IEEE80211_REASON_AUTH_LEAVE		= 3,
778 	IEEE80211_REASON_ASSOC_EXPIRE		= 4,
779 	IEEE80211_REASON_ASSOC_TOOMANY		= 5,
780 	IEEE80211_REASON_NOT_AUTHED		= 6,
781 	IEEE80211_REASON_NOT_ASSOCED		= 7,
782 	IEEE80211_REASON_ASSOC_LEAVE		= 8,
783 	IEEE80211_REASON_ASSOC_NOT_AUTHED	= 9,
784 
785 	/* XXX the following two reason codes are not correct */
786 	IEEE80211_REASON_RSN_REQUIRED		= 11,
787 	IEEE80211_REASON_RSN_INCONSISTENT	= 12,
788 
789 	IEEE80211_REASON_IE_INVALID		= 13,
790 	IEEE80211_REASON_MIC_FAILURE		= 14,
791 	IEEE80211_REASON_4WAY_TIMEOUT		= 15,
792 	IEEE80211_REASON_GROUP_TIMEOUT		= 16,
793 	IEEE80211_REASON_RSN_DIFFERENT_IE	= 17,
794 	IEEE80211_REASON_BAD_GROUP_CIPHER	= 18,
795 	IEEE80211_REASON_BAD_PAIRWISE_CIPHER	= 19,
796 	IEEE80211_REASON_BAD_AKMP		= 20,
797 	IEEE80211_REASON_RSN_IE_VER_UNSUP	= 21,
798 	IEEE80211_REASON_RSN_IE_BAD_CAP		= 22,
799 
800 	IEEE80211_REASON_CIPHER_REJ_POLICY	= 24,
801 
802 	IEEE80211_REASON_SETUP_REQUIRED		= 38,
803 	IEEE80211_REASON_TIMEOUT		= 39
804 };
805 
806 /*
807  * Status codes (see Table 23).
808  */
809 enum {
810 	IEEE80211_STATUS_SUCCESS		= 0,
811 	IEEE80211_STATUS_UNSPECIFIED		= 1,
812 	IEEE80211_STATUS_CAPINFO		= 10,
813 	IEEE80211_STATUS_NOT_ASSOCED		= 11,
814 	IEEE80211_STATUS_OTHER			= 12,
815 	IEEE80211_STATUS_ALG			= 13,
816 	IEEE80211_STATUS_SEQUENCE		= 14,
817 	IEEE80211_STATUS_CHALLENGE		= 15,
818 	IEEE80211_STATUS_TIMEOUT		= 16,
819 	IEEE80211_STATUS_TOOMANY		= 17,
820 	IEEE80211_STATUS_BASIC_RATE		= 18,
821 	IEEE80211_STATUS_SP_REQUIRED		= 19,
822 	IEEE80211_STATUS_PBCC_REQUIRED		= 20,
823 	IEEE80211_STATUS_CA_REQUIRED		= 21,
824 	IEEE80211_STATUS_TOO_MANY_STATIONS	= 22,
825 	IEEE80211_STATUS_RATES			= 23,
826 	IEEE80211_STATUS_SHORTSLOT_REQUIRED	= 25,
827 	IEEE80211_STATUS_DSSSOFDM_REQUIRED	= 26,
828 
829 	IEEE80211_STATUS_TRY_AGAIN_LATER	= 30,
830 	IEEE80211_STATUS_MFP_POLICY		= 31,
831 
832 	IEEE80211_STATUS_REFUSED		= 37,
833 	IEEE80211_STATUS_INVALID_PARAM		= 38,
834 
835 	IEEE80211_STATUS_IE_INVALID		= 40,
836 	IEEE80211_STATUS_BAD_GROUP_CIPHER	= 41,
837 	IEEE80211_STATUS_BAD_PAIRWISE_CIPHER	= 42,
838 	IEEE80211_STATUS_BAD_AKMP		= 43,
839 	IEEE80211_STATUS_RSN_IE_VER_UNSUP	= 44,
840 
841 	IEEE80211_STATUS_CIPHER_REJ_POLICY	= 46
842 };
843 
844 #define	IEEE80211_WEP_KEYLEN			5	/* 40bit */
845 #define	IEEE80211_WEP_NKID			4	/* number of key ids */
846 #define IEEE80211_CHALLENGE_LEN			128
847 
848 /* WEP header constants */
849 #define	IEEE80211_WEP_IVLEN			3	/* 24bit */
850 #define	IEEE80211_WEP_KIDLEN			1	/* 1 octet */
851 #define	IEEE80211_WEP_CRCLEN			4	/* CRC-32 */
852 #define	IEEE80211_CRC_LEN			4
853 #define	IEEE80211_WEP_TOTLEN		(IEEE80211_WEP_IVLEN + \
854 					 IEEE80211_WEP_KIDLEN + \
855 					 IEEE80211_WEP_CRCLEN)
856 
857 /*
858  * 802.11i defines an extended IV for use with non-WEP ciphers.
859  * When the EXTIV bit is set in the key id byte an additional
860  * 4 bytes immediately follow the IV for TKIP.  For CCMP the
861  * EXTIV bit is likewise set but the 8 bytes represent the
862  * CCMP header rather than IV+extended-IV.
863  */
864 #define	IEEE80211_WEP_EXTIV		0x20
865 #define	IEEE80211_WEP_EXTIVLEN		4	/* extended IV length */
866 #define	IEEE80211_WEP_MICLEN		8	/* trailing MIC */
867 
868 /*
869  * Maximum acceptable MTU is:
870  *	IEEE80211_MAX_LEN - WEP overhead - CRC -
871  *		QoS overhead - RSN/WPA overhead
872  * Min is arbitrarily chosen > IEEE80211_MIN_LEN.  The default
873  * mtu is Ethernet-compatible; it's set by ether_ifattach.
874  */
875 #define	IEEE80211_MTU_MAX			2290
876 #define	IEEE80211_MTU_MIN			32
877 
878 #define	IEEE80211_MAX_LEN			(2300 + IEEE80211_CRC_LEN + \
879     (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
880 #define	IEEE80211_ACK_LEN \
881 	(sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
882 #define	IEEE80211_MIN_LEN \
883 	(sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
884 
885 /*
886  * The 802.11 spec says at most 2007 stations may be
887  * associated at once.  For most AP's this is way more
888  * than is feasible so we use a default of 1800. This
889  * number may be overridden by the driver and/or by
890  * user configuration.
891  */
892 #define	IEEE80211_AID_MAX	2007
893 #define	IEEE80211_AID_DEF	1800
894 #define IEEE80211_AID(b)	((b) &~ 0xc000)
895 
896 /*
897  * RTS frame length parameters.  The default is specified in
898  * the 802.11 spec.  The max may be wrong for jumbo frames.
899  */
900 #define	IEEE80211_RTS_DEFAULT			512
901 #define	IEEE80211_RTS_MIN			1
902 #define	IEEE80211_RTS_MAX			IEEE80211_MAX_LEN
903 
904 #define IEEE80211_PLCP_SERVICE		0x00
905 #define IEEE80211_PLCP_SERVICE_PBCC	0x08	/* PBCC encoded */
906 #define IEEE80211_PLCP_SERVICE_LENEXT	0x80	/* length extension bit */
907 
908 /* One Time Unit (TU) is 1Kus = 1024 microseconds. */
909 #define IEEE80211_DUR_TU		1024
910 
911 /* IEEE 802.11b durations for DSSS PHY in microseconds */
912 #define IEEE80211_DUR_DS_LONG_PREAMBLE	144
913 #define IEEE80211_DUR_DS_SHORT_PREAMBLE	72
914 #define	IEEE80211_DUR_DS_PREAMBLE_DIFFERENCE	\
915     (IEEE80211_DUR_DS_LONG_PREAMBLE - IEEE80211_DUR_DS_SHORT_PREAMBLE)
916 #define IEEE80211_DUR_DS_FAST_PLCPHDR	24
917 #define IEEE80211_DUR_DS_SLOW_PLCPHDR	48
918 #define	IEEE80211_DUR_DS_PLCPHDR_DIFFERENCE	\
919     (IEEE80211_DUR_DS_SLOW_PLCPHDR - IEEE80211_DUR_DS_FAST_PLCPHDR)
920 #define IEEE80211_DUR_DS_SLOW_ACK	112
921 #define IEEE80211_DUR_DS_FAST_ACK	56
922 #define IEEE80211_DUR_DS_SLOW_CTS	112
923 #define IEEE80211_DUR_DS_FAST_CTS	56
924 #define IEEE80211_DUR_DS_SLOT		20
925 #define IEEE80211_DUR_DS_SIFS		10
926 #define IEEE80211_DUR_DS_PIFS	(IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT)
927 #define IEEE80211_DUR_DS_DIFS	(IEEE80211_DUR_DS_SIFS + \
928 				 2 * IEEE80211_DUR_DS_SLOT)
929 #define IEEE80211_DUR_DS_EIFS	(IEEE80211_DUR_DS_SIFS + \
930 				 IEEE80211_DUR_DS_SLOW_ACK + \
931 				 IEEE80211_DUR_DS_LONG_PREAMBLE + \
932 				 IEEE80211_DUR_DS_SLOW_PLCPHDR + \
933 				 IEEE80211_DUR_DIFS)
934 
935 /*
936  * The RSNA key descriptor used by IEEE 802.11 does not use the IEEE 802.1X
937  * key descriptor.  Instead, it uses the key descriptor described in 8.5.2.
938  */
939 #define EAPOL_KEY_NONCE_LEN	32
940 #define EAPOL_KEY_IV_LEN	16
941 #define EAPOL_KEY_MIC_LEN	16
942 
943 struct ieee80211_eapol_key {
944 	u_int8_t	version;
945 #define EAPOL_VERSION	1
946 
947 	u_int8_t	type;
948 /* IEEE Std 802.1X-2004, 7.5.4 (only type EAPOL-Key is used here) */
949 #define EAP_PACKET	0
950 #define EAPOL_START	1
951 #define EAPOL_LOGOFF	2
952 #define EAPOL_KEY	3
953 #define EAPOL_ASF_ALERT	4
954 
955 	u_int8_t	len[2];
956 	u_int8_t	desc;
957 /* IEEE Std 802.1X-2004, 7.6.1 */
958 #define EAPOL_KEY_DESC_RC4		  1	/* deprecated */
959 #define EAPOL_KEY_DESC_IEEE80211	  2
960 #define EAPOL_KEY_DESC_WPA		254	/* non-standard WPA */
961 
962 	u_int8_t	info[2];
963 #define EAPOL_KEY_VERSION_MASK	0x7
964 #define EAPOL_KEY_DESC_V1	1
965 #define EAPOL_KEY_DESC_V2	2
966 #define EAPOL_KEY_DESC_V3	3		/* 11r */
967 #define EAPOL_KEY_PAIRWISE	(1 <<  3)
968 #define EAPOL_KEY_INSTALL	(1 <<  6)	/* I */
969 #define EAPOL_KEY_KEYACK	(1 <<  7)	/* A */
970 #define EAPOL_KEY_KEYMIC	(1 <<  8)	/* M */
971 #define EAPOL_KEY_SECURE	(1 <<  9)	/* S */
972 #define EAPOL_KEY_ERROR		(1 << 10)
973 #define EAPOL_KEY_REQUEST	(1 << 11)
974 #define EAPOL_KEY_ENCRYPTED	(1 << 12)
975 #define EAPOL_KEY_SMK		(1 << 13)
976 /* WPA compatibility */
977 #define EAPOL_KEY_WPA_KID_MASK	0x3
978 #define EAPOL_KEY_WPA_KID_SHIFT	4
979 #define EAPOL_KEY_WPA_TX	EAPOL_KEY_INSTALL
980 
981 	u_int8_t	keylen[2];
982 	u_int8_t	replaycnt[8];
983 	u_int8_t	nonce[EAPOL_KEY_NONCE_LEN];
984 	u_int8_t	iv[EAPOL_KEY_IV_LEN];
985 	u_int8_t	rsc[8];
986 	u_int8_t	reserved[8];
987 	u_int8_t	mic[EAPOL_KEY_MIC_LEN];
988 	u_int8_t	paylen[2];
989 } __packed;
990 
991 /* Pairwise Transient Key (see 8.5.1.2) */
992 struct ieee80211_ptk {
993 	u_int8_t	kck[16];	/* Key Confirmation Key */
994 	u_int8_t	kek[16];	/* Key Encryption Key */
995 	u_int8_t	tk[32];		/* Temporal Key */
996 } __packed;
997 
998 #define IEEE80211_PMKID_LEN	16
999 #define IEEE80211_SMKID_LEN	16
1000 
1001 /*
1002  * Key Data Encapsulation (see Table 62).
1003  */
1004 enum {
1005 	IEEE80211_KDE_GTK	= 1,
1006 	IEEE80211_KDE_MACADDR	= 3,
1007 	IEEE80211_KDE_PMKID	= 4,
1008 	IEEE80211_KDE_SMK	= 5,
1009 	IEEE80211_KDE_NONCE	= 6,
1010 	IEEE80211_KDE_LIFETIME	= 7,
1011 	IEEE80211_KDE_ERROR	= 8,
1012 	IEEE80211_KDE_IGTK	= 9	/* 11w */
1013 };
1014 
1015 /*
1016  * HT protection modes (see 802.11-2012 8.4.2.59)
1017  */
1018 enum ieee80211_htprot {
1019 	IEEE80211_HTPROT_NONE = 0,	/* only 20/40MHz HT STAs exist */
1020 	IEEE80211_HTPROT_NONMEMBER,	/* non-HT STA overlaps our channel */
1021 	IEEE80211_HTPROT_20MHZ,		/* 20MHz HT STA on a 40MHz channel */
1022 	IEEE80211_HTPROT_NONHT_MIXED	/* non-HT STA associated to our BSS */
1023 };
1024 
1025 #endif /* _NET80211_IEEE80211_H_ */
1026