ieee80211.h revision 139530
1/*	$NetBSD: ieee80211.h,v 1.4 2003/10/15 11:43:51 dyoung Exp $	*/
2/*-
3 * Copyright (c) 2001 Atsushi Onoe
4 * Copyright (c) 2002-2005 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: head/sys/net80211/ieee80211.h 139530 2004-12-31 22:42:38Z sam $
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 */
47struct 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} __packed;
54
55#define IEEE80211_PLCP_SFD      0xF3A0
56#define IEEE80211_PLCP_SERVICE  0x00
57
58/*
59 * generic definitions for IEEE 802.11 frames
60 */
61struct ieee80211_frame {
62	u_int8_t	i_fc[2];
63	u_int8_t	i_dur[2];
64	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
65	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
66	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
67	u_int8_t	i_seq[2];
68	/* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
69	/* see below */
70} __packed;
71
72struct ieee80211_qosframe {
73	u_int8_t	i_fc[2];
74	u_int8_t	i_dur[2];
75	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
76	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
77	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
78	u_int8_t	i_seq[2];
79	u_int8_t	i_qos[2];
80	/* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
81	/* see below */
82} __packed;
83
84struct ieee80211_qoscntl {
85	u_int8_t	i_qos[2];
86};
87
88struct ieee80211_frame_addr4 {
89	u_int8_t	i_fc[2];
90	u_int8_t	i_dur[2];
91	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
92	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
93	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
94	u_int8_t	i_seq[2];
95	u_int8_t	i_addr4[IEEE80211_ADDR_LEN];
96} __packed;
97
98
99struct ieee80211_qosframe_addr4 {
100	u_int8_t	i_fc[2];
101	u_int8_t	i_dur[2];
102	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
103	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
104	u_int8_t	i_addr3[IEEE80211_ADDR_LEN];
105	u_int8_t	i_seq[2];
106	u_int8_t	i_addr4[IEEE80211_ADDR_LEN];
107	u_int8_t	i_qos[2];
108} __packed;
109
110#define	IEEE80211_FC0_VERSION_MASK		0x03
111#define	IEEE80211_FC0_VERSION_SHIFT		0
112#define	IEEE80211_FC0_VERSION_0			0x00
113#define	IEEE80211_FC0_TYPE_MASK			0x0c
114#define	IEEE80211_FC0_TYPE_SHIFT		2
115#define	IEEE80211_FC0_TYPE_MGT			0x00
116#define	IEEE80211_FC0_TYPE_CTL			0x04
117#define	IEEE80211_FC0_TYPE_DATA			0x08
118
119#define	IEEE80211_FC0_SUBTYPE_MASK		0xf0
120#define	IEEE80211_FC0_SUBTYPE_SHIFT		4
121/* for TYPE_MGT */
122#define	IEEE80211_FC0_SUBTYPE_ASSOC_REQ		0x00
123#define	IEEE80211_FC0_SUBTYPE_ASSOC_RESP	0x10
124#define	IEEE80211_FC0_SUBTYPE_REASSOC_REQ	0x20
125#define	IEEE80211_FC0_SUBTYPE_REASSOC_RESP	0x30
126#define	IEEE80211_FC0_SUBTYPE_PROBE_REQ		0x40
127#define	IEEE80211_FC0_SUBTYPE_PROBE_RESP	0x50
128#define	IEEE80211_FC0_SUBTYPE_BEACON		0x80
129#define	IEEE80211_FC0_SUBTYPE_ATIM		0x90
130#define	IEEE80211_FC0_SUBTYPE_DISASSOC		0xa0
131#define	IEEE80211_FC0_SUBTYPE_AUTH		0xb0
132#define	IEEE80211_FC0_SUBTYPE_DEAUTH		0xc0
133/* for TYPE_CTL */
134#define	IEEE80211_FC0_SUBTYPE_PS_POLL		0xa0
135#define	IEEE80211_FC0_SUBTYPE_RTS		0xb0
136#define	IEEE80211_FC0_SUBTYPE_CTS		0xc0
137#define	IEEE80211_FC0_SUBTYPE_ACK		0xd0
138#define	IEEE80211_FC0_SUBTYPE_CF_END		0xe0
139#define	IEEE80211_FC0_SUBTYPE_CF_END_ACK	0xf0
140/* for TYPE_DATA (bit combination) */
141#define	IEEE80211_FC0_SUBTYPE_DATA		0x00
142#define	IEEE80211_FC0_SUBTYPE_CF_ACK		0x10
143#define	IEEE80211_FC0_SUBTYPE_CF_POLL		0x20
144#define	IEEE80211_FC0_SUBTYPE_CF_ACPL		0x30
145#define	IEEE80211_FC0_SUBTYPE_NODATA		0x40
146#define	IEEE80211_FC0_SUBTYPE_CFACK		0x50
147#define	IEEE80211_FC0_SUBTYPE_CFPOLL		0x60
148#define	IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK	0x70
149#define	IEEE80211_FC0_SUBTYPE_QOS		0x80
150#define	IEEE80211_FC0_SUBTYPE_QOS_NULL		0xc0
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_WEP			0x40
163#define	IEEE80211_FC1_ORDER			0x80
164
165#define	IEEE80211_SEQ_FRAG_MASK			0x000f
166#define	IEEE80211_SEQ_FRAG_SHIFT		0
167#define	IEEE80211_SEQ_SEQ_MASK			0xfff0
168#define	IEEE80211_SEQ_SEQ_SHIFT			4
169
170#define	IEEE80211_NWID_LEN			32
171
172#define	IEEE80211_QOS_TXOP			0x00ff
173/* bit 8 is reserved */
174#define	IEEE80211_QOS_ACKPOLICY			0x60
175#define	IEEE80211_QOS_ACKPOLICY_S		5
176#define	IEEE80211_QOS_ESOP			0x10
177#define	IEEE80211_QOS_ESOP_S			4
178#define	IEEE80211_QOS_TID			0x0f
179
180/* does frame have QoS sequence control data */
181#define	IEEE80211_QOS_HAS_SEQ(wh) \
182	(((wh)->i_fc[0] & \
183	  (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \
184	  (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
185
186/*
187 * WME/802.11e information element.
188 */
189struct ieee80211_wme_info {
190	u_int8_t	wme_id;		/* IEEE80211_ELEMID_VENDOR */
191	u_int8_t	wme_len;	/* length in bytes */
192	u_int8_t	wme_oui[3];	/* 0x00, 0x50, 0xf2 */
193	u_int8_t	wme_type;	/* OUI type */
194	u_int8_t	wme_subtype;	/* OUI subtype */
195	u_int8_t	wme_version;	/* spec revision */
196	u_int8_t	wme_info;	/* QoS info */
197} __packed;
198
199/*
200 * WME/802.11e Tspec Element
201 */
202struct ieee80211_wme_tspec {
203	u_int8_t	ts_id;
204	u_int8_t	ts_len;
205	u_int8_t	ts_oui[3];
206	u_int8_t	ts_oui_type;
207	u_int8_t	ts_oui_subtype;
208	u_int8_t	ts_version;
209	u_int8_t	ts_tsinfo[3];
210	u_int8_t	ts_nom_msdu[2];
211	u_int8_t	ts_max_msdu[2];
212	u_int8_t	ts_min_svc[4];
213	u_int8_t	ts_max_svc[4];
214	u_int8_t	ts_inactv_intv[4];
215	u_int8_t	ts_susp_intv[4];
216	u_int8_t	ts_start_svc[4];
217	u_int8_t	ts_min_rate[4];
218	u_int8_t	ts_mean_rate[4];
219	u_int8_t	ts_max_burst[4];
220	u_int8_t	ts_min_phy[4];
221	u_int8_t	ts_peak_rate[4];
222	u_int8_t	ts_delay[4];
223	u_int8_t	ts_surplus[2];
224	u_int8_t	ts_medium_time[2];
225} __packed;
226
227/*
228 * WME AC parameter field
229 */
230struct ieee80211_wme_acparams {
231	u_int8_t	acp_aci_aifsn;
232	u_int8_t	acp_logcwminmax;
233	u_int16_t	acp_txop;
234} __packed;
235
236#define WME_NUM_AC		4	/* 4 AC categories */
237
238#define WME_PARAM_ACI		0x60	/* Mask for ACI field */
239#define WME_PARAM_ACI_S		5	/* Shift for ACI field */
240#define WME_PARAM_ACM		0x10	/* Mask for ACM bit */
241#define WME_PARAM_ACM_S		4	/* Shift for ACM bit */
242#define WME_PARAM_AIFSN		0x0f	/* Mask for aifsn field */
243#define WME_PARAM_AIFSN_S	0	/* Shift for aifsn field */
244#define WME_PARAM_LOGCWMIN	0x0f	/* Mask for CwMin field (in log) */
245#define WME_PARAM_LOGCWMIN_S	0	/* Shift for CwMin field */
246#define WME_PARAM_LOGCWMAX	0xf0	/* Mask for CwMax field (in log) */
247#define WME_PARAM_LOGCWMAX_S	4	/* Shift for CwMax field */
248
249#define WME_AC_TO_TID(_ac) (       \
250	((_ac) == WME_AC_VO) ? 6 : \
251	((_ac) == WME_AC_VI) ? 5 : \
252	((_ac) == WME_AC_BK) ? 1 : \
253	0)
254
255#define TID_TO_WME_AC(_tid) (      \
256	((_tid) < 1) ? WME_AC_BE : \
257	((_tid) < 3) ? WME_AC_BK : \
258	((_tid) < 6) ? WME_AC_VI : \
259	WME_AC_VO)
260
261/*
262 * WME Parameter Element
263 */
264struct ieee80211_wme_param {
265	u_int8_t	param_id;
266	u_int8_t	param_len;
267	u_int8_t	param_oui[3];
268	u_int8_t	param_oui_type;
269	u_int8_t	param_oui_sybtype;
270	u_int8_t	param_version;
271	u_int8_t	param_qosInfo;
272#define	WME_QOSINFO_COUNT	0x0f	/* Mask for param count field */
273	u_int8_t	param_reserved;
274	struct ieee80211_wme_acparams	params_acParams[WME_NUM_AC];
275} __packed;
276
277/*
278 * Management Notification Frame
279 */
280struct ieee80211_mnf {
281	u_int8_t	mnf_category;
282	u_int8_t	mnf_action;
283	u_int8_t	mnf_dialog;
284	u_int8_t	mnf_status;
285} __packed;
286#define	MNF_SETUP_REQ	0
287#define	MNF_SETUP_RESP	1
288#define	MNF_TEARDOWN	2
289
290/*
291 * Control frames.
292 */
293struct ieee80211_frame_min {
294	u_int8_t	i_fc[2];
295	u_int8_t	i_dur[2];
296	u_int8_t	i_addr1[IEEE80211_ADDR_LEN];
297	u_int8_t	i_addr2[IEEE80211_ADDR_LEN];
298	/* FCS */
299} __packed;
300
301struct ieee80211_frame_rts {
302	u_int8_t	i_fc[2];
303	u_int8_t	i_dur[2];
304	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
305	u_int8_t	i_ta[IEEE80211_ADDR_LEN];
306	/* FCS */
307} __packed;
308
309struct ieee80211_frame_cts {
310	u_int8_t	i_fc[2];
311	u_int8_t	i_dur[2];
312	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
313	/* FCS */
314} __packed;
315
316struct ieee80211_frame_ack {
317	u_int8_t	i_fc[2];
318	u_int8_t	i_dur[2];
319	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
320	/* FCS */
321} __packed;
322
323struct ieee80211_frame_pspoll {
324	u_int8_t	i_fc[2];
325	u_int8_t	i_aid[2];
326	u_int8_t	i_bssid[IEEE80211_ADDR_LEN];
327	u_int8_t	i_ta[IEEE80211_ADDR_LEN];
328	/* FCS */
329} __packed;
330
331struct ieee80211_frame_cfend {		/* NB: also CF-End+CF-Ack */
332	u_int8_t	i_fc[2];
333	u_int8_t	i_dur[2];	/* should be zero */
334	u_int8_t	i_ra[IEEE80211_ADDR_LEN];
335	u_int8_t	i_bssid[IEEE80211_ADDR_LEN];
336	/* FCS */
337} __packed;
338
339/*
340 * BEACON management packets
341 *
342 *	octet timestamp[8]
343 *	octet beacon interval[2]
344 *	octet capability information[2]
345 *	information element
346 *		octet elemid
347 *		octet length
348 *		octet information[length]
349 */
350
351typedef u_int8_t *ieee80211_mgt_beacon_t;
352
353#define	IEEE80211_BEACON_INTERVAL(beacon) \
354	((beacon)[8] | ((beacon)[9] << 8))
355#define	IEEE80211_BEACON_CAPABILITY(beacon) \
356	((beacon)[10] | ((beacon)[11] << 8))
357
358#define	IEEE80211_CAPINFO_ESS			0x0001
359#define	IEEE80211_CAPINFO_IBSS			0x0002
360#define	IEEE80211_CAPINFO_CF_POLLABLE		0x0004
361#define	IEEE80211_CAPINFO_CF_POLLREQ		0x0008
362#define	IEEE80211_CAPINFO_PRIVACY		0x0010
363#define	IEEE80211_CAPINFO_SHORT_PREAMBLE	0x0020
364#define	IEEE80211_CAPINFO_PBCC			0x0040
365#define	IEEE80211_CAPINFO_CHNL_AGILITY		0x0080
366/* bits 8-9 are reserved */
367#define	IEEE80211_CAPINFO_SHORT_SLOTTIME	0x0400
368#define	IEEE80211_CAPINFO_RSN			0x0800
369/* bit 12 is reserved */
370#define	IEEE80211_CAPINFO_DSSSOFDM		0x2000
371/* bits 14-15 are reserved */
372
373/*
374 * 802.11i/WPA information element (maximally sized).
375 */
376struct ieee80211_ie_wpa {
377	u_int8_t	wpa_id;		/* IEEE80211_ELEMID_VENDOR */
378	u_int8_t	wpa_len;	/* length in bytes */
379	u_int8_t	wpa_oui[3];	/* 0x00, 0x50, 0xf2 */
380	u_int8_t	wpa_type;	/* OUI type */
381	u_int16_t	wpa_version;	/* spec revision */
382	u_int32_t	wpa_mcipher[1];	/* multicast/group key cipher */
383	u_int16_t	wpa_uciphercnt;	/* # pairwise key ciphers */
384	u_int32_t	wpa_uciphers[8];/* ciphers */
385	u_int16_t	wpa_authselcnt;	/* authentication selector cnt*/
386	u_int32_t	wpa_authsels[8];/* selectors */
387	u_int16_t	wpa_caps;	/* 802.11i capabilities */
388	u_int16_t	wpa_pmkidcnt;	/* 802.11i pmkid count */
389	u_int16_t	wpa_pmkids[8];	/* 802.11i pmkids */
390} __packed;
391
392/*
393 * Management information element payloads.
394 */
395
396enum {
397	IEEE80211_ELEMID_SSID		= 0,
398	IEEE80211_ELEMID_RATES		= 1,
399	IEEE80211_ELEMID_FHPARMS	= 2,
400	IEEE80211_ELEMID_DSPARMS	= 3,
401	IEEE80211_ELEMID_CFPARMS	= 4,
402	IEEE80211_ELEMID_TIM		= 5,
403	IEEE80211_ELEMID_IBSSPARMS	= 6,
404	IEEE80211_ELEMID_COUNTRY	= 7,
405	IEEE80211_ELEMID_CHALLENGE	= 16,
406	/* 17-31 reserved for challenge text extension */
407	IEEE80211_ELEMID_ERP		= 42,
408	IEEE80211_ELEMID_RSN		= 48,
409	IEEE80211_ELEMID_XRATES		= 50,
410	IEEE80211_ELEMID_TPC		= 150,
411	IEEE80211_ELEMID_CCKM		= 156,
412	IEEE80211_ELEMID_VENDOR		= 221,	/* vendor private */
413};
414
415struct ieee80211_tim_ie {
416	u_int8_t	tim_ie;			/* IEEE80211_ELEMID_TIM */
417	u_int8_t	tim_len;
418	u_int8_t	tim_count;		/* DTIM count */
419	u_int8_t	tim_period;		/* DTIM period */
420	u_int8_t	tim_bitctl;		/* bitmap control */
421	u_int8_t	tim_bitmap[1];		/* variable-length bitmap */
422} __packed;
423
424struct ieee80211_country_ie {
425	u_int8_t	ie;			/* IEEE80211_ELEMID_COUNTRY */
426	u_int8_t	len;
427	u_int8_t	cc[3];			/* ISO CC+(I)ndoor/(O)utdoor */
428	struct {
429		u_int8_t schan;			/* starting channel */
430		u_int8_t nchan;			/* number channels */
431		u_int8_t maxtxpwr;		/* tx power cap */
432	} band[4] __packed;			/* up to 4 sub bands */
433} __packed;
434
435#define IEEE80211_CHALLENGE_LEN		128
436
437#define	IEEE80211_RATE_BASIC		0x80
438#define	IEEE80211_RATE_VAL		0x7f
439
440/* EPR information element flags */
441#define	IEEE80211_ERP_NON_ERP_PRESENT	0x01
442#define	IEEE80211_ERP_USE_PROTECTION	0x02
443#define	IEEE80211_ERP_LONG_PREAMBLE	0x04
444
445/* Atheros private advanced capabilities info */
446#define	ATHEROS_CAP_TURBO_PRIME		0x01
447#define	ATHEROS_CAP_COMPRESSION		0x02
448#define	ATHEROS_CAP_FAST_FRAME		0x04
449/* bits 3-6 reserved */
450#define	ATHEROS_CAP_BOOST		0x80
451
452#define	ATH_OUI			0x7f0300		/* Atheros OUI */
453#define	ATH_OUI_TYPE		0x01
454#define	ATH_OUI_VERSION		0x01
455
456#define	WPA_OUI			0xf25000
457#define	WPA_OUI_TYPE		0x01
458#define	WPA_VERSION		1		/* current supported version */
459
460#define	WPA_CSE_NULL		0x00
461#define	WPA_CSE_WEP40		0x01
462#define	WPA_CSE_TKIP		0x02
463#define	WPA_CSE_CCMP		0x04
464#define	WPA_CSE_WEP104		0x05
465
466#define	WPA_ASE_NONE		0x00
467#define	WPA_ASE_8021X_UNSPEC	0x01
468#define	WPA_ASE_8021X_PSK	0x02
469
470#define	RSN_OUI			0xac0f00
471#define	RSN_VERSION		1		/* current supported version */
472
473#define	RSN_CSE_NULL		0x00
474#define	RSN_CSE_WEP40		0x01
475#define	RSN_CSE_TKIP		0x02
476#define	RSN_CSE_WRAP		0x03
477#define	RSN_CSE_CCMP		0x04
478#define	RSN_CSE_WEP104		0x05
479
480#define	RSN_ASE_NONE		0x00
481#define	RSN_ASE_8021X_UNSPEC	0x01
482#define	RSN_ASE_8021X_PSK	0x02
483
484#define	RSN_CAP_PREAUTH		0x01
485
486#define	WME_OUI			0xf25000
487#define	WME_OUI_TYPE		0x02
488#define	WME_INFO_OUI_SUBTYPE	0x00
489#define	WME_PARAM_OUI_SUBTYPE	0x01
490#define	WME_VERSION		1
491
492/* WME stream classes */
493#define	WME_AC_BE	0		/* best effort */
494#define	WME_AC_BK	1		/* background */
495#define	WME_AC_VI	2		/* video */
496#define	WME_AC_VO	3		/* voice */
497
498/*
499 * AUTH management packets
500 *
501 *	octet algo[2]
502 *	octet seq[2]
503 *	octet status[2]
504 *	octet chal.id
505 *	octet chal.length
506 *	octet chal.text[253]
507 */
508
509typedef u_int8_t *ieee80211_mgt_auth_t;
510
511#define	IEEE80211_AUTH_ALGORITHM(auth) \
512	((auth)[0] | ((auth)[1] << 8))
513#define	IEEE80211_AUTH_TRANSACTION(auth) \
514	((auth)[2] | ((auth)[3] << 8))
515#define	IEEE80211_AUTH_STATUS(auth) \
516	((auth)[4] | ((auth)[5] << 8))
517
518#define	IEEE80211_AUTH_ALG_OPEN		0x0000
519#define	IEEE80211_AUTH_ALG_SHARED	0x0001
520#define	IEEE80211_AUTH_ALG_LEAP		0x0080
521
522enum {
523	IEEE80211_AUTH_OPEN_REQUEST		= 1,
524	IEEE80211_AUTH_OPEN_RESPONSE		= 2,
525};
526
527enum {
528	IEEE80211_AUTH_SHARED_REQUEST		= 1,
529	IEEE80211_AUTH_SHARED_CHALLENGE		= 2,
530	IEEE80211_AUTH_SHARED_RESPONSE		= 3,
531	IEEE80211_AUTH_SHARED_PASS		= 4,
532};
533
534/*
535 * Reason codes
536 *
537 * Unlisted codes are reserved
538 */
539
540enum {
541	IEEE80211_REASON_UNSPECIFIED		= 1,
542	IEEE80211_REASON_AUTH_EXPIRE		= 2,
543	IEEE80211_REASON_AUTH_LEAVE		= 3,
544	IEEE80211_REASON_ASSOC_EXPIRE		= 4,
545	IEEE80211_REASON_ASSOC_TOOMANY		= 5,
546	IEEE80211_REASON_NOT_AUTHED		= 6,
547	IEEE80211_REASON_NOT_ASSOCED		= 7,
548	IEEE80211_REASON_ASSOC_LEAVE		= 8,
549	IEEE80211_REASON_ASSOC_NOT_AUTHED	= 9,
550
551	IEEE80211_REASON_RSN_REQUIRED		= 11,
552	IEEE80211_REASON_RSN_INCONSISTENT	= 12,
553	IEEE80211_REASON_IE_INVALID		= 13,
554	IEEE80211_REASON_MIC_FAILURE		= 14,
555
556	IEEE80211_STATUS_SUCCESS		= 0,
557	IEEE80211_STATUS_UNSPECIFIED		= 1,
558	IEEE80211_STATUS_CAPINFO		= 10,
559	IEEE80211_STATUS_NOT_ASSOCED		= 11,
560	IEEE80211_STATUS_OTHER			= 12,
561	IEEE80211_STATUS_ALG			= 13,
562	IEEE80211_STATUS_SEQUENCE		= 14,
563	IEEE80211_STATUS_CHALLENGE		= 15,
564	IEEE80211_STATUS_TIMEOUT		= 16,
565	IEEE80211_STATUS_TOOMANY		= 17,
566	IEEE80211_STATUS_BASIC_RATE		= 18,
567	IEEE80211_STATUS_SP_REQUIRED		= 19,
568	IEEE80211_STATUS_PBCC_REQUIRED		= 20,
569	IEEE80211_STATUS_CA_REQUIRED		= 21,
570	IEEE80211_STATUS_TOO_MANY_STATIONS	= 22,
571	IEEE80211_STATUS_RATES			= 23,
572	IEEE80211_STATUS_SHORTSLOT_REQUIRED	= 25,
573	IEEE80211_STATUS_DSSSOFDM_REQUIRED	= 26,
574};
575
576#define	IEEE80211_WEP_KEYLEN		5	/* 40bit */
577#define	IEEE80211_WEP_IVLEN		3	/* 24bit */
578#define	IEEE80211_WEP_KIDLEN		1	/* 1 octet */
579#define	IEEE80211_WEP_CRCLEN		4	/* CRC-32 */
580#define	IEEE80211_WEP_NKID		4	/* number of key ids */
581
582/*
583 * 802.11i defines an extended IV for use with non-WEP ciphers.
584 * When the EXTIV bit is set in the key id byte an additional
585 * 4 bytes immediately follow the IV for TKIP.  For CCMP the
586 * EXTIV bit is likewise set but the 8 bytes represent the
587 * CCMP header rather than IV+extended-IV.
588 */
589#define	IEEE80211_WEP_EXTIV		0x20
590#define	IEEE80211_WEP_EXTIVLEN		4	/* extended IV length */
591#define	IEEE80211_WEP_MICLEN		8	/* trailing MIC */
592
593#define	IEEE80211_CRC_LEN		4
594
595/*
596 * Maximum acceptable MTU is:
597 *	IEEE80211_MAX_LEN - WEP overhead - CRC -
598 *		QoS overhead - RSN/WPA overhead
599 * Min is arbitrarily chosen > IEEE80211_MIN_LEN.  The default
600 * mtu is Ethernet-compatible; it's set by ether_ifattach.
601 */
602#define	IEEE80211_MTU_MAX		2290
603#define	IEEE80211_MTU_MIN		32
604
605#define	IEEE80211_MAX_LEN		(2300 + IEEE80211_CRC_LEN + \
606    (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
607#define	IEEE80211_ACK_LEN \
608	(sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
609#define	IEEE80211_MIN_LEN \
610	(sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
611
612/*
613 * The 802.11 spec says at most 2007 stations may be
614 * associated at once.  For most AP's this is way more
615 * than is feasible so we use a default of 128.  This
616 * number may be overridden by the driver and/or by
617 * user configuration.
618 */
619#define	IEEE80211_AID_MAX		2007
620#define	IEEE80211_AID_DEF		128
621
622#define	IEEE80211_AID(b)	((b) &~ 0xc000)
623#define	IEEE80211_AID_SET(b, w) \
624	((w)[IEEE80211_AID(b) / 32] |= (1 << (IEEE80211_AID(b) % 32)))
625#define	IEEE80211_AID_CLR(b, w) \
626	((w)[IEEE80211_AID(b) / 32] &= ~(1 << (IEEE80211_AID(b) % 32)))
627#define	IEEE80211_AID_ISSET(b, w) \
628	((w)[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32)))
629
630/*
631 * RTS frame length parameters.  The default is specified in
632 * the 802.11 spec.  The max may be wrong for jumbo frames.
633 */
634#define	IEEE80211_RTS_DEFAULT		512
635#define	IEEE80211_RTS_MIN		1
636#define	IEEE80211_RTS_MAX		IEEE80211_MAX_LEN
637
638#endif /* _NET80211_IEEE80211_H_ */
639