xref: /netbsd-src/sys/net80211/ieee80211.h (revision 1c9b56c830954ccf3b57004ac65562e3d6afacf6)
1 /*	$NetBSD: ieee80211.h,v 1.11 2004/12/27 05:36:08 mycroft Exp $	*/
2 /*-
3  * Copyright (c) 2001 Atsushi Onoe
4  * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission.
17  *
18  * Alternatively, this software may be distributed under the terms of the
19  * GNU General Public License ("GPL") version 2 as published by the Free
20  * Software Foundation.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.5 2004/04/05 17:47:40 sam Exp $
34  */
35 #ifndef _NET80211_IEEE80211_H_
36 #define _NET80211_IEEE80211_H_
37 
38 /*
39  * 802.11 protocol definitions.
40  */
41 
42 #define	IEEE80211_ADDR_LEN	6		/* size of 802.11 address */
43 /* is 802.11 address multicast/broadcast? */
44 #define	IEEE80211_IS_MULTICAST(_a)	(*(_a) & 0x01)
45 
46 /* IEEE 802.11 PLCP header */
47 struct ieee80211_plcp_hdr {
48 	u_int16_t	i_sfd;
49 	u_int8_t	i_signal;
50 	u_int8_t	i_service;
51 	u_int16_t	i_length;
52 	u_int16_t	i_crc;
53 } __attribute__((__packed__));
54 
55 #define IEEE80211_PLCP_SFD      0xF3A0
56 
57 /*
58  * generic definitions for IEEE 802.11 frames
59  */
60 struct ieee80211_frame {
61 	u_int8_t	i_fc[2];
62 	u_int8_t	i_dur[2];
63 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
64 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
65 	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
66 	u_int8_t	i_seq[2];
67 	/* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
68 	/* see below */
69 } __attribute__((__packed__));
70 
71 struct ieee80211_qosframe {
72 	u_int8_t	i_fc[2];
73 	u_int8_t	i_dur[2];
74 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
75 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
76 	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
77 	u_int8_t	i_seq[2];
78 	u_int8_t	i_qos[2];
79 	/* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
80 	/* see below */
81 } __attribute__((__packed__));
82 
83 struct ieee80211_qoscntl {
84 	u_int8_t	i_qos[2];
85 };
86 
87 struct ieee80211_frame_addr4 {
88 	u_int8_t	i_fc[2];
89 	u_int8_t	i_dur[2];
90 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
91 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
92 	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
93 	u_int8_t	i_seq[2];
94 	u_int8_t	i_addr4[IEEE80211_ADDR_LEN];
95 } __attribute__((__packed__));
96 
97 
98 struct ieee80211_qosframe_addr4 {
99 	u_int8_t	i_fc[2];
100 	u_int8_t	i_dur[2];
101 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
102 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
103 	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
104 	u_int8_t	i_seq[2];
105 	u_int8_t	i_addr4[IEEE80211_ADDR_LEN];
106 	u_int8_t	i_qos[2];
107 } __attribute__((__packed__));
108 
109 #define	IEEE80211_FC0_VERSION_MASK		0x03
110 #define	IEEE80211_FC0_VERSION_SHIFT		0
111 #define	IEEE80211_FC0_VERSION_0			0x00
112 #define	IEEE80211_FC0_TYPE_MASK			0x0c
113 #define	IEEE80211_FC0_TYPE_SHIFT		2
114 #define	IEEE80211_FC0_TYPE_MGT			0x00
115 #define	IEEE80211_FC0_TYPE_CTL			0x04
116 #define	IEEE80211_FC0_TYPE_DATA			0x08
117 
118 #define	IEEE80211_FC0_SUBTYPE_MASK		0xf0
119 #define	IEEE80211_FC0_SUBTYPE_SHIFT		4
120 /* for TYPE_MGT */
121 #define	IEEE80211_FC0_SUBTYPE_ASSOC_REQ		0x00
122 #define	IEEE80211_FC0_SUBTYPE_ASSOC_RESP	0x10
123 #define	IEEE80211_FC0_SUBTYPE_REASSOC_REQ	0x20
124 #define	IEEE80211_FC0_SUBTYPE_REASSOC_RESP	0x30
125 #define	IEEE80211_FC0_SUBTYPE_PROBE_REQ		0x40
126 #define	IEEE80211_FC0_SUBTYPE_PROBE_RESP	0x50
127 #define	IEEE80211_FC0_SUBTYPE_BEACON		0x80
128 #define	IEEE80211_FC0_SUBTYPE_ATIM		0x90
129 #define	IEEE80211_FC0_SUBTYPE_DISASSOC		0xa0
130 #define	IEEE80211_FC0_SUBTYPE_AUTH		0xb0
131 #define	IEEE80211_FC0_SUBTYPE_DEAUTH		0xc0
132 /* for TYPE_CTL */
133 #define	IEEE80211_FC0_SUBTYPE_PS_POLL		0xa0
134 #define	IEEE80211_FC0_SUBTYPE_RTS		0xb0
135 #define	IEEE80211_FC0_SUBTYPE_CTS		0xc0
136 #define	IEEE80211_FC0_SUBTYPE_ACK		0xd0
137 #define	IEEE80211_FC0_SUBTYPE_CF_END		0xe0
138 #define	IEEE80211_FC0_SUBTYPE_CF_END_ACK	0xf0
139 /* for TYPE_DATA (bit combination) */
140 #define	IEEE80211_FC0_SUBTYPE_DATA		0x00
141 #define	IEEE80211_FC0_SUBTYPE_CF_ACK		0x10
142 #define	IEEE80211_FC0_SUBTYPE_CF_POLL		0x20
143 #define	IEEE80211_FC0_SUBTYPE_CF_ACPL		0x30
144 #define	IEEE80211_FC0_SUBTYPE_NODATA		0x40
145 #define	IEEE80211_FC0_SUBTYPE_CFACK		0x50
146 #define	IEEE80211_FC0_SUBTYPE_CFPOLL		0x60
147 #define	IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK	0x70
148 #define	IEEE80211_FC0_SUBTYPE_QOS		0x80
149 
150 #define	IEEE80211_FC1_DIR_MASK			0x03
151 #define	IEEE80211_FC1_DIR_NODS			0x00	/* STA->STA */
152 #define	IEEE80211_FC1_DIR_TODS			0x01	/* STA->AP  */
153 #define	IEEE80211_FC1_DIR_FROMDS		0x02	/* AP ->STA */
154 #define	IEEE80211_FC1_DIR_DSTODS		0x03	/* AP ->AP  */
155 
156 #define	IEEE80211_FC1_MORE_FRAG			0x04
157 #define	IEEE80211_FC1_RETRY			0x08
158 #define	IEEE80211_FC1_PWR_MGT			0x10
159 #define	IEEE80211_FC1_MORE_DATA			0x20
160 #define	IEEE80211_FC1_WEP			0x40
161 #define	IEEE80211_FC1_ORDER			0x80
162 
163 #define	IEEE80211_SEQ_FRAG_MASK			0x000f
164 #define	IEEE80211_SEQ_FRAG_SHIFT		0
165 #define	IEEE80211_SEQ_SEQ_MASK			0xfff0
166 #define	IEEE80211_SEQ_SEQ_SHIFT			4
167 
168 #define	IEEE80211_NWID_LEN			32
169 
170 #define	IEEE80211_QOS_TXOP			0x00ff
171 /* bit 8 is reserved */
172 #define	IEEE80211_QOS_ACKPOLICY			0x0600
173 #define	IEEE80211_QOS_ESOP			0x0800
174 #define	IEEE80211_QOS_TID			0xf000
175 
176 /*
177  * WME/802.11e information element.
178  */
179 struct ieee80211_ie_wme {
180 	u_int8_t	wme_id;		/* IEEE80211_ELEMID_VENDOR */
181 	u_int8_t	wme_len;	/* length in bytes */
182 	u_int8_t	wme_oui[3];	/* 0x00, 0x50, 0xf2 */
183 	u_int8_t	wme_type;	/* OUI type */
184 	u_int8_t	wme_subtype;	/* OUI subtype */
185 	u_int8_t	wme_version;	/* spec revision */
186 	u_int8_t	wme_info;	/* AC info */
187 } __attribute__((__packed__));
188 
189 /*
190  * WME/802.11e Tspec Element
191  */
192 struct ieee80211_wme_tspec {
193 	u_int8_t	ts_id;
194 	u_int8_t	ts_len;
195 	u_int8_t	ts_oui[3];
196 	u_int8_t	ts_oui_type;
197 	u_int8_t	ts_oui_subtype;
198 	u_int8_t	ts_version;
199 	u_int8_t	ts_tsinfo[3];
200 	u_int8_t	ts_nom_msdu[2];
201 	u_int8_t	ts_max_msdu[2];
202 	u_int8_t	ts_min_svc[4];
203 	u_int8_t	ts_max_svc[4];
204 	u_int8_t	ts_inactv_intv[4];
205 	u_int8_t	ts_susp_intv[4];
206 	u_int8_t	ts_start_svc[4];
207 	u_int8_t	ts_min_rate[4];
208 	u_int8_t	ts_mean_rate[4];
209 	u_int8_t	ts_max_burst[4];
210 	u_int8_t	ts_min_phy[4];
211 	u_int8_t	ts_peak_rate[4];
212 	u_int8_t	ts_delay[4];
213 	u_int8_t	ts_surplus[2];
214 	u_int8_t	ts_medium_time[2];
215 } __attribute__((__packed__));
216 
217 /*
218  * Management Notification Frame
219  */
220 struct ieee80211_mnf {
221 	u_int8_t	mnf_category;
222 	u_int8_t	mnf_action;
223 	u_int8_t	mnf_dialog;
224 	u_int8_t	mnf_status;
225 } __attribute__((__packed__));
226 #define	MNF_SETUP_REQ	0
227 #define	MNF_SETUP_RESP	1
228 #define	MNF_TEARDOWN	2
229 
230 /*
231  * Control frames.
232  */
233 struct ieee80211_frame_min {
234 	u_int8_t	i_fc[2];
235 	u_int8_t	i_dur[2];
236 	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
237 	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
238 	/* FCS */
239 } __attribute__((__packed__));
240 
241 struct ieee80211_frame_rts {
242 	u_int8_t	i_fc[2];
243 	u_int8_t	i_dur[2];
244 	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
245 	u_int8_t	i_ta[IEEE80211_ADDR_LEN];
246 	/* FCS */
247 } __attribute__((__packed__));
248 
249 struct ieee80211_frame_cts {
250 	u_int8_t	i_fc[2];
251 	u_int8_t	i_dur[2];
252 	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
253 	/* FCS */
254 } __attribute__((__packed__));
255 
256 struct ieee80211_frame_ack {
257 	u_int8_t	i_fc[2];
258 	u_int8_t	i_dur[2];
259 	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
260 	/* FCS */
261 } __attribute__((__packed__));
262 
263 struct ieee80211_frame_pspoll {
264 	u_int8_t	i_fc[2];
265 	u_int8_t	i_aid[2];
266 	u_int8_t	i_bssid[IEEE80211_ADDR_LEN];
267 	u_int8_t	i_ta[IEEE80211_ADDR_LEN];
268 	/* FCS */
269 } __attribute__((__packed__));
270 
271 struct ieee80211_frame_cfend {		/* NB: also CF-End+CF-Ack */
272 	u_int8_t	i_fc[2];
273 	u_int8_t	i_dur[2];	/* should be zero */
274 	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
275 	u_int8_t	i_bssid[IEEE80211_ADDR_LEN];
276 	/* FCS */
277 } __attribute__((__packed__));
278 
279 /*
280  * BEACON management packets
281  *
282  *	octet timestamp[8]
283  *	octet beacon interval[2]
284  *	octet capability information[2]
285  *	information element
286  *		octet elemid
287  *		octet length
288  *		octet information[length]
289  */
290 
291 typedef u_int8_t *ieee80211_mgt_beacon_t;
292 
293 #define	IEEE80211_BEACON_INTERVAL(beacon) \
294 	((beacon)[8] | ((beacon)[9] << 8))
295 #define	IEEE80211_BEACON_CAPABILITY(beacon) \
296 	((beacon)[10] | ((beacon)[11] << 8))
297 
298 #define	IEEE80211_CAPINFO_ESS			0x0001
299 #define	IEEE80211_CAPINFO_IBSS			0x0002
300 #define	IEEE80211_CAPINFO_CF_POLLABLE		0x0004
301 #define	IEEE80211_CAPINFO_CF_POLLREQ		0x0008
302 #define	IEEE80211_CAPINFO_PRIVACY		0x0010
303 #define	IEEE80211_CAPINFO_SHORT_PREAMBLE	0x0020
304 #define	IEEE80211_CAPINFO_PBCC			0x0040
305 #define	IEEE80211_CAPINFO_CHNL_AGILITY		0x0080
306 /* bits 8-9 are reserved */
307 #define	IEEE80211_CAPINFO_SHORT_SLOTTIME	0x0400
308 #define	IEEE80211_CAPINFO_RSN			0x0800
309 /* bit 12 is reserved */
310 #define	IEEE80211_CAPINFO_DSSSOFDM		0x2000
311 /* bits 14-15 are reserved */
312 
313 /*
314  * 802.11i/WPA information element (maximally sized).
315  */
316 struct ieee80211_ie_wpa {
317 	u_int8_t	wpa_id;		/* IEEE80211_ELEMID_VENDOR */
318 	u_int8_t	wpa_len;	/* length in bytes */
319 	u_int8_t	wpa_oui[3];	/* 0x00, 0x50, 0xf2 */
320 	u_int8_t	wpa_type;	/* OUI type */
321 	u_int16_t	wpa_version;	/* spec revision */
322 	u_int32_t	wpa_mcipher[1];	/* multicast/group key cipher */
323 	u_int16_t	wpa_uciphercnt;	/* # pairwise key ciphers */
324 	u_int32_t	wpa_uciphers[8];/* ciphers */
325 	u_int16_t	wpa_authselcnt;	/* authentication selector cnt*/
326 	u_int32_t	wpa_authsels[8];/* selectors */
327 	u_int16_t	wpa_caps;	/* 802.11i capabilities */
328 	u_int16_t	wpa_pmkidcnt;	/* 802.11i pmkid count */
329 	u_int16_t	wpa_pmkids[8];	/* 802.11i pmkids */
330 } __attribute__((__packed__));
331 
332 /*
333  * Management information element payloads
334  */
335 union ieee80211_information {
336 	char	ssid[IEEE80211_NWID_LEN+1];
337 	struct rates {
338 		u_int8_t	*p;
339 	} rates;
340 	struct fh {
341 		u_int16_t	dwell;
342 		u_int8_t	set;
343 		u_int8_t	pattern;
344 		u_int8_t	index;
345 	} fh;
346 	struct ds {
347 		u_int8_t	channel;
348 	} ds;
349 	struct cf {
350 		u_int8_t	count;
351 		u_int8_t	period;
352 		u_int8_t	maxdur[2];
353 		u_int8_t	dur[2];
354 	} cf;
355 	struct tim {
356 		u_int8_t	count;
357 		u_int8_t	period;
358 		u_int8_t	bitctl;
359 		/* u_int8_t	pvt[251]; The driver needs to use this. */
360 	} tim;
361 	struct ibss {
362 		u_int16_t	atim;
363 	} ibss;
364 	struct challenge {
365 		u_int8_t	*p;
366 		u_int8_t	len;
367 	} challenge;
368 	struct erp {
369 		u_int8_t	flags;
370 	} erp;
371 	struct country {
372 		u_int8_t	cc[3];		/* ISO CC+(I)ndoor/(O)utdoor */
373 		struct {
374 			u_int8_t schan;		/* starting channel */
375 			u_int8_t nchan;		/* number channels */
376 			u_int8_t maxtxpwr;
377 		} band[4];			/* up to 4 sub bands */
378 	} country;
379 	struct ath {
380 		u_int8_t	flags;
381 	} ath;
382 };
383 
384 enum {
385 	IEEE80211_ELEMID_SSID		= 0,
386 	IEEE80211_ELEMID_RATES		= 1,
387 	IEEE80211_ELEMID_FHPARMS	= 2,
388 	IEEE80211_ELEMID_DSPARMS	= 3,
389 	IEEE80211_ELEMID_CFPARMS	= 4,
390 	IEEE80211_ELEMID_TIM		= 5,
391 	IEEE80211_ELEMID_IBSSPARMS	= 6,
392 	IEEE80211_ELEMID_COUNTRY	= 7,
393 	IEEE80211_ELEMID_CHALLENGE	= 16,
394 	/* 17-31 reserved for challenge text extension */
395 	IEEE80211_ELEMID_ERP		= 42,
396 	IEEE80211_ELEMID_RSN		= 48,
397 	IEEE80211_ELEMID_XRATES		= 50,
398 	IEEE80211_ELEMID_TPC		= 150,
399 	IEEE80211_ELEMID_CCKM		= 156,
400 	IEEE80211_ELEMID_VENDOR		= 221,	/* vendor private */
401 };
402 
403 #define IEEE80211_CHALLENGE_LEN		128
404 
405 #define	IEEE80211_RATE_BASIC		0x80
406 #define	IEEE80211_RATE_VAL		0x7f
407 
408 /* EPR information element flags */
409 #define	IEEE80211_ERP_NON_ERP_PRESENT	0x01
410 #define	IEEE80211_ERP_USE_PROTECTION	0x02
411 #define	IEEE80211_ERP_LONG_PREAMBLE	0x04
412 
413 /* Atheros private advanced capabilities info */
414 #define	ATHEROS_CAP_TURBO_PRIME		0x01
415 #define	ATHEROS_CAP_COMPRESSION		0x02
416 #define	ATHEROS_CAP_FAST_FRAME		0x04
417 /* bits 3-6 reserved */
418 #define	ATHEROS_CAP_BOOST		0x80
419 
420 #define	ATH_OUI			0x7f0300		/* Atheros OUI */
421 #define	ATH_OUI_TYPE		0x01
422 #define	ATH_OUI_VERSION		0x01
423 
424 #define	WPA_OUI			0xf25000
425 #define	WPA_OUI_TYPE		0x01
426 #define	WPA_VERSION		1		/* current supported version */
427 
428 #define	WPA_CSE_NULL		0x00
429 #define	WPA_CSE_WEP40		0x01
430 #define	WPA_CSE_TKIP		0x02
431 #define	WPA_CSE_CCMP		0x04
432 #define	WPA_CSE_WEP104		0x05
433 
434 #define	WPA_ASE_NONE		0x00
435 #define	WPA_ASE_8021X_UNSPEC	0x01
436 #define	WPA_ASE_8021X_PSK	0x02
437 
438 #define	RSN_OUI			0xac0f00
439 #define	RSN_VERSION		1		/* current supported version */
440 
441 #define	RSN_CSE_NULL		0x00
442 #define	RSN_CSE_WEP40		0x01
443 #define	RSN_CSE_TKIP		0x02
444 #define	RSN_CSE_WRAP		0x03
445 #define	RSN_CSE_CCMP		0x04
446 #define	RSN_CSE_WEP104		0x05
447 
448 #define	RSN_ASE_NONE		0x00
449 #define	RSN_ASE_8021X_UNSPEC	0x01
450 #define	RSN_ASE_8021X_PSK	0x02
451 
452 #define	WME_OUI			0xf25000
453 #define	WME_OUI_TYPE		0x02
454 #define	WME_VERSION		1
455 
456 /* WME stream classes */
457 #define	WME_AC_BE	0		/* best effort */
458 #define	WME_AC_BK	1		/* background */
459 #define	WME_AC_VI	2		/* video */
460 #define	WME_AC_VO	3		/* voice */
461 
462 /*
463  * AUTH management packets
464  *
465  *	octet algo[2]
466  *	octet seq[2]
467  *	octet status[2]
468  *	octet chal.id
469  *	octet chal.length
470  *	octet chal.text[253]
471  */
472 
473 typedef u_int8_t *ieee80211_mgt_auth_t;
474 
475 #define	IEEE80211_AUTH_ALGORITHM(auth) \
476 	((auth)[0] | ((auth)[1] << 8))
477 #define	IEEE80211_AUTH_TRANSACTION(auth) \
478 	((auth)[2] | ((auth)[3] << 8))
479 #define	IEEE80211_AUTH_STATUS(auth) \
480 	((auth)[4] | ((auth)[5] << 8))
481 
482 #define	IEEE80211_AUTH_ALG_OPEN		0x0000
483 #define	IEEE80211_AUTH_ALG_SHARED	0x0001
484 #define	IEEE80211_AUTH_ALG_LEAP		0x0080
485 
486 enum {
487 	IEEE80211_AUTH_OPEN_REQUEST		= 1,
488 	IEEE80211_AUTH_OPEN_RESPONSE		= 2,
489 };
490 
491 enum {
492 	IEEE80211_AUTH_SHARED_REQUEST		= 1,
493 	IEEE80211_AUTH_SHARED_CHALLENGE		= 2,
494 	IEEE80211_AUTH_SHARED_RESPONSE		= 3,
495 	IEEE80211_AUTH_SHARED_PASS		= 4,
496 };
497 
498 /*
499  * Reason codes
500  *
501  * Unlisted codes are reserved
502  */
503 
504 enum {
505 	IEEE80211_REASON_UNSPECIFIED		= 1,
506 	IEEE80211_REASON_AUTH_EXPIRE		= 2,
507 	IEEE80211_REASON_AUTH_LEAVE		= 3,
508 	IEEE80211_REASON_ASSOC_EXPIRE		= 4,
509 	IEEE80211_REASON_ASSOC_TOOMANY		= 5,
510 	IEEE80211_REASON_NOT_AUTHED		= 6,
511 	IEEE80211_REASON_NOT_ASSOCED		= 7,
512 	IEEE80211_REASON_ASSOC_LEAVE		= 8,
513 	IEEE80211_REASON_ASSOC_NOT_AUTHED	= 9,
514 
515 	IEEE80211_REASON_RSN_REQUIRED		= 11,
516 	IEEE80211_REASON_RSN_INCONSISTENT	= 12,
517 	IEEE80211_REASON_IE_INVALID		= 13,
518 	IEEE80211_REASON_MIC_FAILURE		= 14,
519 
520 	IEEE80211_STATUS_SUCCESS		= 0,
521 	IEEE80211_STATUS_UNSPECIFIED		= 1,
522 	IEEE80211_STATUS_CAPINFO		= 10,
523 	IEEE80211_STATUS_NOT_ASSOCED		= 11,
524 	IEEE80211_STATUS_OTHER			= 12,
525 	IEEE80211_STATUS_ALG			= 13,
526 	IEEE80211_STATUS_SEQUENCE		= 14,
527 	IEEE80211_STATUS_CHALLENGE		= 15,
528 	IEEE80211_STATUS_TIMEOUT		= 16,
529 	IEEE80211_STATUS_TOOMANY		= 17,
530 	IEEE80211_STATUS_BASIC_RATE		= 18,
531 	IEEE80211_STATUS_SP_REQUIRED		= 19,
532 	IEEE80211_STATUS_PBCC_REQUIRED		= 20,
533 	IEEE80211_STATUS_CA_REQUIRED		= 21,
534 	IEEE80211_STATUS_TOO_MANY_STATIONS	= 22,
535 	IEEE80211_STATUS_RATES			= 23,
536 	IEEE80211_STATUS_SHORTSLOT_REQUIRED	= 25,
537 	IEEE80211_STATUS_DSSSOFDM_REQUIRED	= 26,
538 };
539 
540 #define	IEEE80211_WEP_KEYLEN		5	/* 40bit */
541 #define	IEEE80211_WEP_NKID		4	/* number of key ids */
542 
543 /* WEP header constants */
544 #define	IEEE80211_WEP_IVLEN		3	/* 24bit */
545 #define	IEEE80211_WEP_KIDLEN		1	/* 1 octet */
546 #define	IEEE80211_WEP_CRCLEN		4	/* CRC-32 */
547 #define	IEEE80211_WEP_TOTLEN		(IEEE80211_WEP_IVLEN + \
548 					 IEEE80211_WEP_KIDLEN + \
549 					 IEEE80211_WEP_CRCLEN)
550 /*
551  * 802.11i defines an extended IV for use with non-WEP ciphers.
552  * When the EXTIV bit is set in the key id byte an additional
553  * 4 bytes immediately follow the IV for TKIP.  For CCMP the
554  * EXTIV bit is likewise set but the 8 bytes represent the
555  * CCMP header rather than IV+extended-IV.
556  */
557 #define	IEEE80211_WEP_EXTIV		0x20
558 #define	IEEE80211_WEP_EXTIVLEN		4	/* extended IV length */
559 #define	IEEE80211_WEP_MICLEN		8	/* trailing MIC */
560 
561 #define	IEEE80211_CRC_LEN		4
562 
563 /*
564  * Maximum acceptable MTU is:
565  *	IEEE80211_MAX_LEN - WEP overhead - CRC -
566  *		QoS overhead - RSN/WPA overhead
567  * Min is arbitrarily chosen > IEEE80211_MIN_LEN.  The default
568  * mtu is Ethernet-compatible; it's set by ether_ifattach.
569  */
570 #define	IEEE80211_MTU_MAX		2290
571 #define	IEEE80211_MTU_MIN		32
572 
573 #define	IEEE80211_MAX_LEN		(2300 + IEEE80211_CRC_LEN + \
574     (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
575 #define	IEEE80211_ACK_LEN \
576 	(sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
577 #define	IEEE80211_MIN_LEN \
578 	(sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
579 
580 /*
581  * The 802.11 spec says at most 2007 stations may be
582  * associated at once.  For most AP's this is way more
583  * than is feasible so we use a default of 128.  This
584  * number may be overridden by the driver and/or by
585  * user configuration.
586  */
587 #define	IEEE80211_AID_MAX		2007
588 #define	IEEE80211_AID_DEF		128
589 
590 #define	IEEE80211_AID(b)	((b) &~ 0xc000)
591 #define	IEEE80211_AID_SET(b, w) \
592 	((w)[IEEE80211_AID(b) / 32] |= (1 << (IEEE80211_AID(b) % 32)))
593 #define	IEEE80211_AID_CLR(b, w) \
594 	((w)[IEEE80211_AID(b) / 32] &= ~(1 << (IEEE80211_AID(b) % 32)))
595 #define	IEEE80211_AID_ISSET(b, w) \
596 	((w)[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32)))
597 
598 /*
599  * RTS frame length parameters.  The default is specified in
600  * the 802.11 spec.  The max may be wrong for jumbo frames.
601  */
602 #define	IEEE80211_RTS_DEFAULT		512
603 #define	IEEE80211_RTS_MIN		1
604 #define	IEEE80211_RTS_MAX		IEEE80211_MAX_LEN
605 
606 /*
607  * 802.11 frame duration definitions.
608  */
609 
610 struct ieee80211_duration {
611 	uint16_t	d_rts_dur;
612 	uint16_t	d_data_dur;
613 	uint16_t	d_plcp_len;
614 	uint8_t		d_residue;	/* unused octets in time slot */
615 };
616 
617 /* One Time Unit (TU) is 1Kus = 1024 microseconds. */
618 #define IEEE80211_DUR_TU		1024
619 
620 /* IEEE 802.11b durations for DSSS PHY in microseconds */
621 #define IEEE80211_DUR_DS_LONG_PREAMBLE	144
622 #define IEEE80211_DUR_DS_SHORT_PREAMBLE	72
623 
624 #define IEEE80211_DUR_DS_SLOW_PLCPHDR	48
625 #define IEEE80211_DUR_DS_FAST_PLCPHDR	24
626 #define IEEE80211_DUR_DS_SLOW_ACK	112
627 #define IEEE80211_DUR_DS_FAST_ACK	56
628 #define IEEE80211_DUR_DS_SLOW_CTS	112
629 #define IEEE80211_DUR_DS_FAST_CTS	56
630 
631 #define IEEE80211_DUR_DS_SLOT		20
632 #define IEEE80211_DUR_DS_SIFS		10
633 #define IEEE80211_DUR_DS_PIFS	(IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT)
634 #define IEEE80211_DUR_DS_DIFS	(IEEE80211_DUR_DS_SIFS + \
635 				 2 * IEEE80211_DUR_DS_SLOT)
636 #define IEEE80211_DUR_DS_EIFS	(IEEE80211_DUR_DS_SIFS + \
637 				 IEEE80211_DUR_DS_SLOW_ACK + \
638 				 IEEE80211_DUR_DS_LONG_PREAMBLE + \
639 				 IEEE80211_DUR_DS_SLOW_PLCPHDR + \
640 				 IEEE80211_DUR_DIFS)
641 
642 enum {
643 	IEEE80211_AUTH_NONE	= 0,
644 	IEEE80211_AUTH_OPEN	= 1,		/* open */
645 	IEEE80211_AUTH_SHARED	= 2,		/* shared-key */
646 	IEEE80211_AUTH_8021X	= 3,		/* 802.1x */
647 	IEEE80211_AUTH_AUTO	= 4,		/* auto-select/accept */
648 	/* NB: these are used only for ioctls */
649 	IEEE80211_AUTH_WPA	= 5,		/* WPA w/ 802.1x */
650 	IEEE80211_AUTH_WPA_PSK	= 6,		/* WPA w/ preshared key */
651 	IEEE80211_AUTH_WPA2	= 7,		/* WPA2 w/ 802.1x */
652 	IEEE80211_AUTH_WPA2_PSK	= 8,		/* WPA2 w/ preshared key */
653 };
654 
655 #endif /* _NET80211_IEEE80211_H_ */
656