ieee80211.h revision 193840
1116742Ssam/*-
2116904Ssam * Copyright (c) 2001 Atsushi Onoe
3186904Ssam * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
4116742Ssam * All rights reserved.
5116742Ssam *
6116742Ssam * Redistribution and use in source and binary forms, with or without
7116742Ssam * modification, are permitted provided that the following conditions
8116742Ssam * are met:
9116742Ssam * 1. Redistributions of source code must retain the above copyright
10116742Ssam *    notice, this list of conditions and the following disclaimer.
11116742Ssam * 2. Redistributions in binary form must reproduce the above copyright
12116742Ssam *    notice, this list of conditions and the following disclaimer in the
13116742Ssam *    documentation and/or other materials provided with the distribution.
14116742Ssam *
15116904Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16116904Ssam * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17116904Ssam * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18116904Ssam * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19116904Ssam * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20116904Ssam * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21116904Ssam * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22116904Ssam * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23116904Ssam * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24116904Ssam * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25116904Ssam *
26116742Ssam * $FreeBSD: head/sys/net80211/ieee80211.h 193840 2009-06-09 16:32:07Z sam $
27116742Ssam */
28116742Ssam#ifndef _NET80211_IEEE80211_H_
29116742Ssam#define _NET80211_IEEE80211_H_
30116742Ssam
31116742Ssam/*
32116742Ssam * 802.11 protocol definitions.
33116742Ssam */
34116742Ssam
35116742Ssam#define	IEEE80211_ADDR_LEN	6		/* size of 802.11 address */
36116742Ssam/* is 802.11 address multicast/broadcast? */
37116742Ssam#define	IEEE80211_IS_MULTICAST(_a)	(*(_a) & 0x01)
38116742Ssam
39191756Ssamtypedef uint16_t ieee80211_seq;
40191756Ssam
41116742Ssam/* IEEE 802.11 PLCP header */
42116742Ssamstruct ieee80211_plcp_hdr {
43170530Ssam	uint16_t	i_sfd;
44170530Ssam	uint8_t		i_signal;
45170530Ssam	uint8_t		i_service;
46170530Ssam	uint16_t	i_length;
47170530Ssam	uint16_t	i_crc;
48138568Ssam} __packed;
49116742Ssam
50127903Ssam#define IEEE80211_PLCP_SFD      0xF3A0
51127903Ssam#define IEEE80211_PLCP_SERVICE  0x00
52178952Ssam#define IEEE80211_PLCP_SERVICE_LOCKED	0x04
53178952Ssam#define IEEE80211_PLCL_SERVICE_PBCC	0x08
54178952Ssam#define IEEE80211_PLCP_SERVICE_LENEXT5	0x20
55178952Ssam#define IEEE80211_PLCP_SERVICE_LENEXT6	0x40
56178952Ssam#define IEEE80211_PLCP_SERVICE_LENEXT7	0x80
57127903Ssam
58116742Ssam/*
59116742Ssam * generic definitions for IEEE 802.11 frames
60116742Ssam */
61116742Ssamstruct ieee80211_frame {
62170530Ssam	uint8_t		i_fc[2];
63170530Ssam	uint8_t		i_dur[2];
64170530Ssam	uint8_t		i_addr1[IEEE80211_ADDR_LEN];
65170530Ssam	uint8_t		i_addr2[IEEE80211_ADDR_LEN];
66170530Ssam	uint8_t		i_addr3[IEEE80211_ADDR_LEN];
67170530Ssam	uint8_t		i_seq[2];
68116742Ssam	/* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
69116742Ssam	/* see below */
70138568Ssam} __packed;
71116742Ssam
72127903Ssamstruct ieee80211_qosframe {
73170530Ssam	uint8_t		i_fc[2];
74170530Ssam	uint8_t		i_dur[2];
75170530Ssam	uint8_t		i_addr1[IEEE80211_ADDR_LEN];
76170530Ssam	uint8_t		i_addr2[IEEE80211_ADDR_LEN];
77170530Ssam	uint8_t		i_addr3[IEEE80211_ADDR_LEN];
78170530Ssam	uint8_t		i_seq[2];
79170530Ssam	uint8_t		i_qos[2];
80127903Ssam	/* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
81127903Ssam	/* see below */
82138568Ssam} __packed;
83127903Ssam
84127903Ssamstruct ieee80211_qoscntl {
85170530Ssam	uint8_t		i_qos[2];
86127903Ssam};
87127903Ssam
88116742Ssamstruct ieee80211_frame_addr4 {
89170530Ssam	uint8_t		i_fc[2];
90170530Ssam	uint8_t		i_dur[2];
91170530Ssam	uint8_t		i_addr1[IEEE80211_ADDR_LEN];
92170530Ssam	uint8_t		i_addr2[IEEE80211_ADDR_LEN];
93170530Ssam	uint8_t		i_addr3[IEEE80211_ADDR_LEN];
94170530Ssam	uint8_t		i_seq[2];
95170530Ssam	uint8_t		i_addr4[IEEE80211_ADDR_LEN];
96138568Ssam} __packed;
97116742Ssam
98127903Ssam
99127903Ssamstruct ieee80211_qosframe_addr4 {
100170530Ssam	uint8_t		i_fc[2];
101170530Ssam	uint8_t		i_dur[2];
102170530Ssam	uint8_t		i_addr1[IEEE80211_ADDR_LEN];
103170530Ssam	uint8_t		i_addr2[IEEE80211_ADDR_LEN];
104170530Ssam	uint8_t		i_addr3[IEEE80211_ADDR_LEN];
105170530Ssam	uint8_t		i_seq[2];
106170530Ssam	uint8_t		i_addr4[IEEE80211_ADDR_LEN];
107170530Ssam	uint8_t		i_qos[2];
108138568Ssam} __packed;
109127903Ssam
110116742Ssam#define	IEEE80211_FC0_VERSION_MASK		0x03
111116742Ssam#define	IEEE80211_FC0_VERSION_SHIFT		0
112116742Ssam#define	IEEE80211_FC0_VERSION_0			0x00
113116742Ssam#define	IEEE80211_FC0_TYPE_MASK			0x0c
114116742Ssam#define	IEEE80211_FC0_TYPE_SHIFT		2
115116742Ssam#define	IEEE80211_FC0_TYPE_MGT			0x00
116116742Ssam#define	IEEE80211_FC0_TYPE_CTL			0x04
117116742Ssam#define	IEEE80211_FC0_TYPE_DATA			0x08
118116742Ssam
119116742Ssam#define	IEEE80211_FC0_SUBTYPE_MASK		0xf0
120116742Ssam#define	IEEE80211_FC0_SUBTYPE_SHIFT		4
121116742Ssam/* for TYPE_MGT */
122116742Ssam#define	IEEE80211_FC0_SUBTYPE_ASSOC_REQ		0x00
123116742Ssam#define	IEEE80211_FC0_SUBTYPE_ASSOC_RESP	0x10
124116742Ssam#define	IEEE80211_FC0_SUBTYPE_REASSOC_REQ	0x20
125116742Ssam#define	IEEE80211_FC0_SUBTYPE_REASSOC_RESP	0x30
126116742Ssam#define	IEEE80211_FC0_SUBTYPE_PROBE_REQ		0x40
127116742Ssam#define	IEEE80211_FC0_SUBTYPE_PROBE_RESP	0x50
128116742Ssam#define	IEEE80211_FC0_SUBTYPE_BEACON		0x80
129116742Ssam#define	IEEE80211_FC0_SUBTYPE_ATIM		0x90
130116742Ssam#define	IEEE80211_FC0_SUBTYPE_DISASSOC		0xa0
131116742Ssam#define	IEEE80211_FC0_SUBTYPE_AUTH		0xb0
132116742Ssam#define	IEEE80211_FC0_SUBTYPE_DEAUTH		0xc0
133170530Ssam#define	IEEE80211_FC0_SUBTYPE_ACTION		0xd0
134116742Ssam/* for TYPE_CTL */
135170530Ssam#define	IEEE80211_FC0_SUBTYPE_BAR		0x80
136192328Ssam#define	IEEE80211_FC0_SUBTYPE_BA		0x90
137116742Ssam#define	IEEE80211_FC0_SUBTYPE_PS_POLL		0xa0
138116742Ssam#define	IEEE80211_FC0_SUBTYPE_RTS		0xb0
139116742Ssam#define	IEEE80211_FC0_SUBTYPE_CTS		0xc0
140116742Ssam#define	IEEE80211_FC0_SUBTYPE_ACK		0xd0
141116742Ssam#define	IEEE80211_FC0_SUBTYPE_CF_END		0xe0
142116742Ssam#define	IEEE80211_FC0_SUBTYPE_CF_END_ACK	0xf0
143116742Ssam/* for TYPE_DATA (bit combination) */
144116742Ssam#define	IEEE80211_FC0_SUBTYPE_DATA		0x00
145116742Ssam#define	IEEE80211_FC0_SUBTYPE_CF_ACK		0x10
146116742Ssam#define	IEEE80211_FC0_SUBTYPE_CF_POLL		0x20
147116742Ssam#define	IEEE80211_FC0_SUBTYPE_CF_ACPL		0x30
148116742Ssam#define	IEEE80211_FC0_SUBTYPE_NODATA		0x40
149116742Ssam#define	IEEE80211_FC0_SUBTYPE_CFACK		0x50
150116742Ssam#define	IEEE80211_FC0_SUBTYPE_CFPOLL		0x60
151116742Ssam#define	IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK	0x70
152127903Ssam#define	IEEE80211_FC0_SUBTYPE_QOS		0x80
153138568Ssam#define	IEEE80211_FC0_SUBTYPE_QOS_NULL		0xc0
154116742Ssam
155116742Ssam#define	IEEE80211_FC1_DIR_MASK			0x03
156116742Ssam#define	IEEE80211_FC1_DIR_NODS			0x00	/* STA->STA */
157116742Ssam#define	IEEE80211_FC1_DIR_TODS			0x01	/* STA->AP  */
158116742Ssam#define	IEEE80211_FC1_DIR_FROMDS		0x02	/* AP ->STA */
159116742Ssam#define	IEEE80211_FC1_DIR_DSTODS		0x03	/* AP ->AP  */
160116742Ssam
161193840Ssam#define	IEEE80211_IS_DSTODS(wh) \
162193840Ssam	(((wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS)
163193840Ssam
164116742Ssam#define	IEEE80211_FC1_MORE_FRAG			0x04
165116742Ssam#define	IEEE80211_FC1_RETRY			0x08
166116742Ssam#define	IEEE80211_FC1_PWR_MGT			0x10
167116742Ssam#define	IEEE80211_FC1_MORE_DATA			0x20
168116742Ssam#define	IEEE80211_FC1_WEP			0x40
169116742Ssam#define	IEEE80211_FC1_ORDER			0x80
170116742Ssam
171116742Ssam#define	IEEE80211_SEQ_FRAG_MASK			0x000f
172116742Ssam#define	IEEE80211_SEQ_FRAG_SHIFT		0
173116742Ssam#define	IEEE80211_SEQ_SEQ_MASK			0xfff0
174116742Ssam#define	IEEE80211_SEQ_SEQ_SHIFT			4
175170530Ssam#define	IEEE80211_SEQ_RANGE			4096
176116742Ssam
177170530Ssam#define	IEEE80211_SEQ_ADD(seq, incr) \
178170530Ssam	(((seq) + (incr)) & (IEEE80211_SEQ_RANGE-1))
179170530Ssam#define	IEEE80211_SEQ_INC(seq)	IEEE80211_SEQ_ADD(seq,1)
180170530Ssam#define	IEEE80211_SEQ_SUB(a, b) \
181170530Ssam	(((a) + IEEE80211_SEQ_RANGE - (b)) & (IEEE80211_SEQ_RANGE-1))
182170530Ssam
183173273Ssam#define	IEEE80211_SEQ_BA_RANGE			2048	/* 2^11 */
184173273Ssam#define	IEEE80211_SEQ_BA_BEFORE(a, b) \
185173273Ssam	(IEEE80211_SEQ_SUB(b, a+1) < IEEE80211_SEQ_BA_RANGE-1)
186173273Ssam
187116742Ssam#define	IEEE80211_NWID_LEN			32
188116742Ssam
189127903Ssam#define	IEEE80211_QOS_TXOP			0x00ff
190127903Ssam/* bit 8 is reserved */
191170530Ssam#define	IEEE80211_QOS_AMSDU			0x80
192170530Ssam#define	IEEE80211_QOS_AMSDU_S			7
193138568Ssam#define	IEEE80211_QOS_ACKPOLICY			0x60
194138568Ssam#define	IEEE80211_QOS_ACKPOLICY_S		5
195170530Ssam#define	IEEE80211_QOS_ACKPOLICY_NOACK		0x20	/* No ACK required */
196170530Ssam#define	IEEE80211_QOS_ACKPOLICY_BA		0x60	/* Block ACK */
197183243Ssam#define	IEEE80211_QOS_EOSP			0x10	/* EndOfService Period*/
198183243Ssam#define	IEEE80211_QOS_EOSP_S			4
199138568Ssam#define	IEEE80211_QOS_TID			0x0f
200127903Ssam
201138568Ssam/* does frame have QoS sequence control data */
202138568Ssam#define	IEEE80211_QOS_HAS_SEQ(wh) \
203138568Ssam	(((wh)->i_fc[0] & \
204138568Ssam	  (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \
205138568Ssam	  (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
206138568Ssam
207116742Ssam/*
208138568Ssam * WME/802.11e information element.
209138568Ssam */
210138568Ssamstruct ieee80211_wme_info {
211170530Ssam	uint8_t		wme_id;		/* IEEE80211_ELEMID_VENDOR */
212170530Ssam	uint8_t		wme_len;	/* length in bytes */
213170530Ssam	uint8_t		wme_oui[3];	/* 0x00, 0x50, 0xf2 */
214170530Ssam	uint8_t		wme_type;	/* OUI type */
215170530Ssam	uint8_t		wme_subtype;	/* OUI subtype */
216170530Ssam	uint8_t		wme_version;	/* spec revision */
217170530Ssam	uint8_t		wme_info;	/* QoS info */
218138568Ssam} __packed;
219138568Ssam
220138568Ssam/*
221138568Ssam * WME/802.11e Tspec Element
222138568Ssam */
223138568Ssamstruct ieee80211_wme_tspec {
224170530Ssam	uint8_t		ts_id;
225170530Ssam	uint8_t		ts_len;
226170530Ssam	uint8_t		ts_oui[3];
227170530Ssam	uint8_t		ts_oui_type;
228170530Ssam	uint8_t		ts_oui_subtype;
229170530Ssam	uint8_t		ts_version;
230170530Ssam	uint8_t		ts_tsinfo[3];
231170530Ssam	uint8_t		ts_nom_msdu[2];
232170530Ssam	uint8_t		ts_max_msdu[2];
233170530Ssam	uint8_t		ts_min_svc[4];
234170530Ssam	uint8_t		ts_max_svc[4];
235170530Ssam	uint8_t		ts_inactv_intv[4];
236170530Ssam	uint8_t		ts_susp_intv[4];
237170530Ssam	uint8_t		ts_start_svc[4];
238170530Ssam	uint8_t		ts_min_rate[4];
239170530Ssam	uint8_t		ts_mean_rate[4];
240170530Ssam	uint8_t		ts_max_burst[4];
241170530Ssam	uint8_t		ts_min_phy[4];
242170530Ssam	uint8_t		ts_peak_rate[4];
243170530Ssam	uint8_t		ts_delay[4];
244170530Ssam	uint8_t		ts_surplus[2];
245170530Ssam	uint8_t		ts_medium_time[2];
246138568Ssam} __packed;
247138568Ssam
248138568Ssam/*
249138568Ssam * WME AC parameter field
250138568Ssam */
251138568Ssamstruct ieee80211_wme_acparams {
252170530Ssam	uint8_t		acp_aci_aifsn;
253170530Ssam	uint8_t		acp_logcwminmax;
254170530Ssam	uint16_t	acp_txop;
255138568Ssam} __packed;
256138568Ssam
257138568Ssam#define WME_NUM_AC		4	/* 4 AC categories */
258170530Ssam#define	WME_NUM_TID		16	/* 16 tids */
259138568Ssam
260138568Ssam#define WME_PARAM_ACI		0x60	/* Mask for ACI field */
261138568Ssam#define WME_PARAM_ACI_S		5	/* Shift for ACI field */
262138568Ssam#define WME_PARAM_ACM		0x10	/* Mask for ACM bit */
263138568Ssam#define WME_PARAM_ACM_S		4	/* Shift for ACM bit */
264138568Ssam#define WME_PARAM_AIFSN		0x0f	/* Mask for aifsn field */
265138568Ssam#define WME_PARAM_AIFSN_S	0	/* Shift for aifsn field */
266138568Ssam#define WME_PARAM_LOGCWMIN	0x0f	/* Mask for CwMin field (in log) */
267138568Ssam#define WME_PARAM_LOGCWMIN_S	0	/* Shift for CwMin field */
268138568Ssam#define WME_PARAM_LOGCWMAX	0xf0	/* Mask for CwMax field (in log) */
269138568Ssam#define WME_PARAM_LOGCWMAX_S	4	/* Shift for CwMax field */
270138568Ssam
271138568Ssam#define WME_AC_TO_TID(_ac) (       \
272138568Ssam	((_ac) == WME_AC_VO) ? 6 : \
273138568Ssam	((_ac) == WME_AC_VI) ? 5 : \
274138568Ssam	((_ac) == WME_AC_BK) ? 1 : \
275138568Ssam	0)
276138568Ssam
277138568Ssam#define TID_TO_WME_AC(_tid) (      \
278173863Ssam	((_tid) == 0 || (_tid) == 3) ? WME_AC_BE : \
279138568Ssam	((_tid) < 3) ? WME_AC_BK : \
280138568Ssam	((_tid) < 6) ? WME_AC_VI : \
281138568Ssam	WME_AC_VO)
282138568Ssam
283138568Ssam/*
284138568Ssam * WME Parameter Element
285138568Ssam */
286138568Ssamstruct ieee80211_wme_param {
287170530Ssam	uint8_t		param_id;
288170530Ssam	uint8_t		param_len;
289170530Ssam	uint8_t		param_oui[3];
290170530Ssam	uint8_t		param_oui_type;
291172055Ssam	uint8_t		param_oui_subtype;
292170530Ssam	uint8_t		param_version;
293170530Ssam	uint8_t		param_qosInfo;
294138568Ssam#define	WME_QOSINFO_COUNT	0x0f	/* Mask for param count field */
295170530Ssam	uint8_t		param_reserved;
296138568Ssam	struct ieee80211_wme_acparams	params_acParams[WME_NUM_AC];
297138568Ssam} __packed;
298138568Ssam
299138568Ssam/*
300138568Ssam * Management Notification Frame
301138568Ssam */
302138568Ssamstruct ieee80211_mnf {
303170530Ssam	uint8_t		mnf_category;
304170530Ssam	uint8_t		mnf_action;
305170530Ssam	uint8_t		mnf_dialog;
306170530Ssam	uint8_t		mnf_status;
307138568Ssam} __packed;
308138568Ssam#define	MNF_SETUP_REQ	0
309138568Ssam#define	MNF_SETUP_RESP	1
310138568Ssam#define	MNF_TEARDOWN	2
311138568Ssam
312170530Ssam/*
313170530Ssam * 802.11n Management Action Frames
314170530Ssam */
315170530Ssam/* generic frame format */
316170530Ssamstruct ieee80211_action {
317170530Ssam	uint8_t		ia_category;
318170530Ssam	uint8_t		ia_action;
319170530Ssam} __packed;
320170530Ssam
321193542Ssam#define	IEEE80211_ACTION_CAT_SM		0	/* Spectrum Management */
322193542Ssam#define	IEEE80211_ACTION_CAT_QOS	1	/* QoS */
323193542Ssam#define	IEEE80211_ACTION_CAT_DLS	2	/* DLS */
324170530Ssam#define	IEEE80211_ACTION_CAT_BA		3	/* BA */
325172055Ssam#define	IEEE80211_ACTION_CAT_HT		7	/* HT */
326193542Ssam#define	IEEE80211_ACTION_CAT_VENDOR	127	/* Vendor Specific */
327170530Ssam
328170530Ssam#define	IEEE80211_ACTION_HT_TXCHWIDTH	0	/* recommended xmit chan width*/
329170530Ssam#define	IEEE80211_ACTION_HT_MIMOPWRSAVE	1	/* MIMO power save */
330170530Ssam
331170530Ssam/* HT - recommended transmission channel width */
332170530Ssamstruct ieee80211_action_ht_txchwidth {
333170530Ssam	struct ieee80211_action	at_header;
334170530Ssam	uint8_t		at_chwidth;
335170530Ssam} __packed;
336170530Ssam
337170530Ssam#define	IEEE80211_A_HT_TXCHWIDTH_20	0
338170530Ssam#define	IEEE80211_A_HT_TXCHWIDTH_2040	1
339170530Ssam
340172055Ssam/* HT - MIMO Power Save (NB: D2.04) */
341170530Ssamstruct ieee80211_action_ht_mimopowersave {
342170530Ssam	struct ieee80211_action am_header;
343173618Ssam	uint8_t		am_control;
344170530Ssam} __packed;
345170530Ssam
346173618Ssam#define	IEEE80211_A_HT_MIMOPWRSAVE_ENA		0x01	/* PS enabled */
347173618Ssam#define	IEEE80211_A_HT_MIMOPWRSAVE_MODE		0x02
348173618Ssam#define	IEEE80211_A_HT_MIMOPWRSAVE_MODE_S	1
349173618Ssam#define	IEEE80211_A_HT_MIMOPWRSAVE_DYNAMIC	0x02	/* Dynamic Mode */
350173618Ssam#define	IEEE80211_A_HT_MIMOPWRSAVE_STATIC	0x00	/* no SM packets */
351173618Ssam/* bits 2-7 reserved */
352173618Ssam
353170530Ssam/* Block Ack actions */
354170530Ssam#define IEEE80211_ACTION_BA_ADDBA_REQUEST       0   /* ADDBA request */
355170530Ssam#define IEEE80211_ACTION_BA_ADDBA_RESPONSE      1   /* ADDBA response */
356170530Ssam#define IEEE80211_ACTION_BA_DELBA	        2   /* DELBA */
357170530Ssam
358170530Ssam/* Block Ack Parameter Set */
359170530Ssam#define	IEEE80211_BAPS_BUFSIZ	0xffc0		/* buffer size */
360170530Ssam#define	IEEE80211_BAPS_BUFSIZ_S	6
361170530Ssam#define	IEEE80211_BAPS_TID	0x003c		/* TID */
362170530Ssam#define	IEEE80211_BAPS_TID_S	2
363170530Ssam#define	IEEE80211_BAPS_POLICY	0x0002		/* block ack policy */
364170530Ssam#define	IEEE80211_BAPS_POLICY_S	1
365170530Ssam
366170530Ssam#define	IEEE80211_BAPS_POLICY_DELAYED	(0<<IEEE80211_BAPS_POLICY_S)
367170530Ssam#define	IEEE80211_BAPS_POLICY_IMMEDIATE	(1<<IEEE80211_BAPS_POLICY_S)
368170530Ssam
369170530Ssam/* Block Ack Sequence Control */
370170530Ssam#define	IEEE80211_BASEQ_START	0xfff0		/* starting seqnum */
371170530Ssam#define	IEEE80211_BASEQ_START_S	4
372170530Ssam#define	IEEE80211_BASEQ_FRAG	0x000f		/* fragment number */
373170530Ssam#define	IEEE80211_BASEQ_FRAG_S	0
374170530Ssam
375170530Ssam/* Delayed Block Ack Parameter Set */
376170530Ssam#define	IEEE80211_DELBAPS_TID	0xf000		/* TID */
377170530Ssam#define	IEEE80211_DELBAPS_TID_S	12
378170530Ssam#define	IEEE80211_DELBAPS_INIT	0x0800		/* initiator */
379170530Ssam#define	IEEE80211_DELBAPS_INIT_S 11
380170530Ssam
381170530Ssam/* BA - ADDBA request */
382170530Ssamstruct ieee80211_action_ba_addbarequest {
383170530Ssam	struct ieee80211_action rq_header;
384170530Ssam	uint8_t		rq_dialogtoken;
385170530Ssam	uint16_t	rq_baparamset;
386170530Ssam	uint16_t	rq_batimeout;		/* in TUs */
387170530Ssam	uint16_t	rq_baseqctl;
388170530Ssam} __packed;
389170530Ssam
390170530Ssam/* BA - ADDBA response */
391170530Ssamstruct ieee80211_action_ba_addbaresponse {
392170530Ssam	struct ieee80211_action rs_header;
393170530Ssam	uint8_t		rs_dialogtoken;
394170530Ssam	uint16_t	rs_statuscode;
395170530Ssam	uint16_t	rs_baparamset;
396170530Ssam	uint16_t	rs_batimeout;		/* in TUs */
397170530Ssam} __packed;
398170530Ssam
399170530Ssam/* BA - DELBA */
400170530Ssamstruct ieee80211_action_ba_delba {
401170530Ssam	struct ieee80211_action dl_header;
402170530Ssam	uint16_t	dl_baparamset;
403170530Ssam	uint16_t	dl_reasoncode;
404170530Ssam} __packed;
405170530Ssam
406170530Ssam/* BAR Control */
407170530Ssam#define	IEEE80211_BAR_TID	0xf000		/* TID */
408170530Ssam#define	IEEE80211_BAR_TID_S	12
409182820Ssam#define	IEEE80211_BAR_COMP	0x0004		/* Compressed Bitmap */
410182820Ssam#define	IEEE80211_BAR_MTID	0x0002		/* Multi-TID */
411182820Ssam#define	IEEE80211_BAR_NOACK	0x0001		/* No-Ack policy */
412170530Ssam
413182820Ssam/* BAR Starting Sequence Control */
414182820Ssam#define	IEEE80211_BAR_SEQ_START	0xfff0		/* starting seqnum */
415182820Ssam#define	IEEE80211_BAR_SEQ_START_S	4
416182820Ssam
417170530Ssamstruct ieee80211_ba_request {
418170530Ssam	uint16_t	rq_barctl;
419170530Ssam	uint16_t	rq_barseqctl;
420170530Ssam} __packed;
421170530Ssam
422138568Ssam/*
423120098Ssam * Control frames.
424120098Ssam */
425120098Ssamstruct ieee80211_frame_min {
426170530Ssam	uint8_t		i_fc[2];
427170530Ssam	uint8_t		i_dur[2];
428170530Ssam	uint8_t		i_addr1[IEEE80211_ADDR_LEN];
429170530Ssam	uint8_t		i_addr2[IEEE80211_ADDR_LEN];
430120098Ssam	/* FCS */
431138568Ssam} __packed;
432120098Ssam
433120098Ssamstruct ieee80211_frame_rts {
434170530Ssam	uint8_t		i_fc[2];
435170530Ssam	uint8_t		i_dur[2];
436170530Ssam	uint8_t		i_ra[IEEE80211_ADDR_LEN];
437170530Ssam	uint8_t		i_ta[IEEE80211_ADDR_LEN];
438120098Ssam	/* FCS */
439138568Ssam} __packed;
440120098Ssam
441120098Ssamstruct ieee80211_frame_cts {
442170530Ssam	uint8_t		i_fc[2];
443170530Ssam	uint8_t		i_dur[2];
444170530Ssam	uint8_t		i_ra[IEEE80211_ADDR_LEN];
445120098Ssam	/* FCS */
446138568Ssam} __packed;
447120098Ssam
448120098Ssamstruct ieee80211_frame_ack {
449170530Ssam	uint8_t		i_fc[2];
450170530Ssam	uint8_t		i_dur[2];
451170530Ssam	uint8_t		i_ra[IEEE80211_ADDR_LEN];
452120098Ssam	/* FCS */
453138568Ssam} __packed;
454120098Ssam
455120098Ssamstruct ieee80211_frame_pspoll {
456170530Ssam	uint8_t		i_fc[2];
457170530Ssam	uint8_t		i_aid[2];
458170530Ssam	uint8_t		i_bssid[IEEE80211_ADDR_LEN];
459170530Ssam	uint8_t		i_ta[IEEE80211_ADDR_LEN];
460120098Ssam	/* FCS */
461138568Ssam} __packed;
462120098Ssam
463120098Ssamstruct ieee80211_frame_cfend {		/* NB: also CF-End+CF-Ack */
464170530Ssam	uint8_t		i_fc[2];
465170530Ssam	uint8_t		i_dur[2];	/* should be zero */
466170530Ssam	uint8_t		i_ra[IEEE80211_ADDR_LEN];
467170530Ssam	uint8_t		i_bssid[IEEE80211_ADDR_LEN];
468120098Ssam	/* FCS */
469138568Ssam} __packed;
470120098Ssam
471170530Ssamstruct ieee80211_frame_bar {
472170530Ssam	uint8_t		i_fc[2];
473170530Ssam	uint8_t		i_dur[2];
474170530Ssam	uint8_t		i_ra[IEEE80211_ADDR_LEN];
475170530Ssam	uint8_t		i_ta[IEEE80211_ADDR_LEN];
476170530Ssam	uint16_t	i_ctl;
477170530Ssam	uint16_t	i_seq;
478170530Ssam	/* FCS */
479170530Ssam} __packed;
480170530Ssam
481120098Ssam/*
482116742Ssam * BEACON management packets
483116742Ssam *
484116742Ssam *	octet timestamp[8]
485116742Ssam *	octet beacon interval[2]
486116742Ssam *	octet capability information[2]
487116742Ssam *	information element
488116742Ssam *		octet elemid
489116742Ssam *		octet length
490116742Ssam *		octet information[length]
491116742Ssam */
492116742Ssam
493116742Ssam#define	IEEE80211_BEACON_INTERVAL(beacon) \
494116742Ssam	((beacon)[8] | ((beacon)[9] << 8))
495116742Ssam#define	IEEE80211_BEACON_CAPABILITY(beacon) \
496116742Ssam	((beacon)[10] | ((beacon)[11] << 8))
497116742Ssam
498116742Ssam#define	IEEE80211_CAPINFO_ESS			0x0001
499116742Ssam#define	IEEE80211_CAPINFO_IBSS			0x0002
500116742Ssam#define	IEEE80211_CAPINFO_CF_POLLABLE		0x0004
501116742Ssam#define	IEEE80211_CAPINFO_CF_POLLREQ		0x0008
502116742Ssam#define	IEEE80211_CAPINFO_PRIVACY		0x0010
503116742Ssam#define	IEEE80211_CAPINFO_SHORT_PREAMBLE	0x0020
504116742Ssam#define	IEEE80211_CAPINFO_PBCC			0x0040
505116742Ssam#define	IEEE80211_CAPINFO_CHNL_AGILITY		0x0080
506172055Ssam#define	IEEE80211_CAPINFO_SPECTRUM_MGMT		0x0100
507172055Ssam/* bit 9 is reserved */
508116742Ssam#define	IEEE80211_CAPINFO_SHORT_SLOTTIME	0x0400
509127903Ssam#define	IEEE80211_CAPINFO_RSN			0x0800
510127903Ssam/* bit 12 is reserved */
511116742Ssam#define	IEEE80211_CAPINFO_DSSSOFDM		0x2000
512116742Ssam/* bits 14-15 are reserved */
513116742Ssam
514187797Ssam#define	IEEE80211_CAPINFO_BITS \
515187797Ssam	"\20\1ESS\2IBSS\3CF_POLLABLE\4CF_POLLREQ\5PRIVACY\6SHORT_PREAMBLE" \
516187797Ssam	"\7PBCC\10CHNL_AGILITY\11SPECTRUM_MGMT\13SHORT_SLOTTIME\14RSN" \
517187797Ssam	"\16DSSOFDM"
518187797Ssam
519116742Ssam/*
520127903Ssam * 802.11i/WPA information element (maximally sized).
521127903Ssam */
522127903Ssamstruct ieee80211_ie_wpa {
523170530Ssam	uint8_t		wpa_id;		/* IEEE80211_ELEMID_VENDOR */
524170530Ssam	uint8_t		wpa_len;	/* length in bytes */
525170530Ssam	uint8_t		wpa_oui[3];	/* 0x00, 0x50, 0xf2 */
526170530Ssam	uint8_t		wpa_type;	/* OUI type */
527170530Ssam	uint16_t	wpa_version;	/* spec revision */
528170530Ssam	uint32_t	wpa_mcipher[1];	/* multicast/group key cipher */
529170530Ssam	uint16_t	wpa_uciphercnt;	/* # pairwise key ciphers */
530170530Ssam	uint32_t	wpa_uciphers[8];/* ciphers */
531170530Ssam	uint16_t	wpa_authselcnt;	/* authentication selector cnt*/
532170530Ssam	uint32_t	wpa_authsels[8];/* selectors */
533170530Ssam	uint16_t	wpa_caps;	/* 802.11i capabilities */
534170530Ssam	uint16_t	wpa_pmkidcnt;	/* 802.11i pmkid count */
535170530Ssam	uint16_t	wpa_pmkids[8];	/* 802.11i pmkids */
536138568Ssam} __packed;
537127903Ssam
538127903Ssam/*
539170530Ssam * 802.11n HT Capability IE
540170530Ssam * NB: these reflect D1.10
541170530Ssam */
542170530Ssamstruct ieee80211_ie_htcap {
543170530Ssam	uint8_t		hc_id;			/* element ID */
544170530Ssam	uint8_t		hc_len;			/* length in bytes */
545170530Ssam	uint16_t	hc_cap;			/* HT caps (see below) */
546170530Ssam	uint8_t		hc_param;		/* HT params (see below) */
547170530Ssam	uint8_t 	hc_mcsset[16]; 		/* supported MCS set */
548170530Ssam	uint16_t	hc_extcap;		/* extended HT capabilities */
549170530Ssam	uint32_t	hc_txbf;		/* txbf capabilities */
550170530Ssam	uint8_t		hc_antenna;		/* antenna capabilities */
551170530Ssam} __packed;
552170530Ssam
553170530Ssam/* HT capability flags (ht_cap) */
554170530Ssam#define	IEEE80211_HTCAP_LDPC		0x0001	/* LDPC supported */
555170530Ssam#define	IEEE80211_HTCAP_CHWIDTH40	0x0002	/* 20/40 supported */
556170530Ssam#define	IEEE80211_HTCAP_SMPS		0x000c	/* SM Power Save mode */
557183243Ssam#define	IEEE80211_HTCAP_SMPS_OFF	0x000c	/* disabled */
558170530Ssam#define	IEEE80211_HTCAP_SMPS_DYNAMIC	0x0004	/* send RTS first */
559170530Ssam/* NB: SMPS value 2 is reserved */
560183243Ssam#define	IEEE80211_HTCAP_SMPS_ENA	0x0000	/* enabled (static mode) */
561170530Ssam#define	IEEE80211_HTCAP_GREENFIELD	0x0010	/* Greenfield supported */
562170530Ssam#define	IEEE80211_HTCAP_SHORTGI20	0x0020	/* Short GI in 20MHz */
563170530Ssam#define	IEEE80211_HTCAP_SHORTGI40	0x0040	/* Short GI in 40MHz */
564170530Ssam#define	IEEE80211_HTCAP_TXSTBC		0x0080	/* STBC tx ok */
565170530Ssam#define	IEEE80211_HTCAP_RXSTBC		0x0300  /* STBC rx support */
566170530Ssam#define	IEEE80211_HTCAP_RXSTBC_S	8
567170530Ssam#define	IEEE80211_HTCAP_RXSTBC_1STREAM	0x0100  /* 1 spatial stream */
568170530Ssam#define	IEEE80211_HTCAP_RXSTBC_2STREAM	0x0200  /* 1-2 spatial streams*/
569170530Ssam#define	IEEE80211_HTCAP_RXSTBC_3STREAM	0x0300  /* 1-3 spatial streams*/
570170530Ssam#define	IEEE80211_HTCAP_DELBA		0x0400	/* HT DELBA supported */
571170530Ssam#define	IEEE80211_HTCAP_MAXAMSDU	0x0800	/* max A-MSDU length */
572170530Ssam#define	IEEE80211_HTCAP_MAXAMSDU_7935	0x0800	/* 7935 octets */
573170530Ssam#define	IEEE80211_HTCAP_MAXAMSDU_3839	0x0000	/* 3839 octets */
574170530Ssam#define	IEEE80211_HTCAP_DSSSCCK40	0x1000  /* DSSS/CCK in 40MHz */
575170530Ssam#define	IEEE80211_HTCAP_PSMP		0x2000  /* PSMP supported */
576170530Ssam#define	IEEE80211_HTCAP_40INTOLERANT	0x4000  /* 40MHz intolerant */
577170530Ssam#define	IEEE80211_HTCAP_LSIGTXOPPROT	0x8000  /* L-SIG TXOP prot */
578170530Ssam
579187797Ssam#define	IEEE80211_HTCAP_BITS \
580187797Ssam	"\20\1LDPC\2CHWIDTH40\5GREENFIELD\6SHORTGI20\7SHORTGI40\10TXSTBC" \
581187797Ssam	"\13DELBA\14AMSDU(7935)\15DSSSCCK40\16PSMP\1740INTOLERANT" \
582187797Ssam	"\20LSIGTXOPPROT"
583187797Ssam
584170530Ssam/* HT parameters (hc_param) */
585170530Ssam#define	IEEE80211_HTCAP_MAXRXAMPDU	0x03	/* max rx A-MPDU factor */
586170530Ssam#define	IEEE80211_HTCAP_MAXRXAMPDU_S	0
587173273Ssam#define	IEEE80211_HTCAP_MAXRXAMPDU_8K	0
588173273Ssam#define	IEEE80211_HTCAP_MAXRXAMPDU_16K	1
589173273Ssam#define	IEEE80211_HTCAP_MAXRXAMPDU_32K	2
590173273Ssam#define	IEEE80211_HTCAP_MAXRXAMPDU_64K	3
591170530Ssam#define	IEEE80211_HTCAP_MPDUDENSITY	0x1c	/* min MPDU start spacing */
592170530Ssam#define	IEEE80211_HTCAP_MPDUDENSITY_S	2
593173273Ssam#define	IEEE80211_HTCAP_MPDUDENSITY_NA	0	/* no time restriction */
594173273Ssam#define	IEEE80211_HTCAP_MPDUDENSITY_025	1	/* 1/4 us */
595173273Ssam#define	IEEE80211_HTCAP_MPDUDENSITY_05	2	/* 1/2 us */
596173273Ssam#define	IEEE80211_HTCAP_MPDUDENSITY_1	3	/* 1 us */
597173273Ssam#define	IEEE80211_HTCAP_MPDUDENSITY_2	4	/* 2 us */
598173273Ssam#define	IEEE80211_HTCAP_MPDUDENSITY_4	5	/* 4 us */
599173273Ssam#define	IEEE80211_HTCAP_MPDUDENSITY_8	6	/* 8 us */
600173273Ssam#define	IEEE80211_HTCAP_MPDUDENSITY_16	7	/* 16 us */
601170530Ssam
602170530Ssam/* HT extended capabilities (hc_extcap) */
603170530Ssam#define	IEEE80211_HTCAP_PCO		0x0001	/* PCO capable */
604170530Ssam#define	IEEE80211_HTCAP_PCOTRANS	0x0006	/* PCO transition time */
605170530Ssam#define	IEEE80211_HTCAP_PCOTRANS_S	1
606170530Ssam#define	IEEE80211_HTCAP_PCOTRANS_04	0x0002	/* 400 us */
607170530Ssam#define	IEEE80211_HTCAP_PCOTRANS_15	0x0004	/* 1.5 ms */
608170530Ssam#define	IEEE80211_HTCAP_PCOTRANS_5	0x0006	/* 5 ms */
609170530Ssam/* bits 3-7 reserved */
610170530Ssam#define	IEEE80211_HTCAP_MCSFBACK	0x0300	/* MCS feedback */
611170530Ssam#define	IEEE80211_HTCAP_MCSFBACK_S	8
612170530Ssam#define	IEEE80211_HTCAP_MCSFBACK_NONE	0x0000	/* nothing provided */
613170530Ssam#define	IEEE80211_HTCAP_MCSFBACK_UNSOL	0x0200	/* unsolicited feedback */
614170530Ssam#define	IEEE80211_HTCAP_MCSFBACK_MRQ	0x0300	/* " "+respond to MRQ */
615170530Ssam#define	IEEE80211_HTCAP_HTC		0x0400	/* +HTC support */
616170530Ssam#define	IEEE80211_HTCAP_RDR		0x0800	/* reverse direction responder*/
617170530Ssam/* bits 12-15 reserved */
618170530Ssam
619170530Ssam/*
620170530Ssam * 802.11n HT Information IE
621170530Ssam */
622170530Ssamstruct ieee80211_ie_htinfo {
623170530Ssam	uint8_t		hi_id;			/* element ID */
624170530Ssam	uint8_t		hi_len;			/* length in bytes */
625170530Ssam	uint8_t		hi_ctrlchannel;		/* primary channel */
626170530Ssam	uint8_t		hi_byte1;		/* ht ie byte 1 */
627172055Ssam	uint8_t		hi_byte2;		/* ht ie byte 2 */
628172055Ssam	uint8_t		hi_byte3;		/* ht ie byte 3 */
629170530Ssam	uint16_t	hi_byte45;		/* ht ie bytes 4+5 */
630172055Ssam	uint8_t 	hi_basicmcsset[16]; 	/* basic MCS set */
631170530Ssam} __packed;
632170530Ssam
633170530Ssam/* byte1 */
634170530Ssam#define	IEEE80211_HTINFO_2NDCHAN	0x03	/* secondary/ext chan offset */
635170530Ssam#define	IEEE80211_HTINFO_2NDCHAN_S	0
636170530Ssam#define	IEEE80211_HTINFO_2NDCHAN_NONE	0x00	/* no secondary/ext channel */
637170530Ssam#define	IEEE80211_HTINFO_2NDCHAN_ABOVE	0x01	/* above private channel */
638170530Ssam/* NB: 2 is reserved */
639170530Ssam#define	IEEE80211_HTINFO_2NDCHAN_BELOW	0x03	/* below primary channel */
640170530Ssam#define	IEEE80211_HTINFO_TXWIDTH	0x04	/* tx channel width */
641170530Ssam#define	IEEE80211_HTINFO_TXWIDTH_20	0x00	/* 20MHz width */
642170530Ssam#define	IEEE80211_HTINFO_TXWIDTH_2040	0x04	/* any supported width */
643170530Ssam#define	IEEE80211_HTINFO_RIFSMODE	0x08	/* Reduced IFS (RIFS) use */
644170530Ssam#define	IEEE80211_HTINFO_RIFSMODE_PROH	0x00	/* RIFS use prohibited */
645170530Ssam#define	IEEE80211_HTINFO_RIFSMODE_PERM	0x08	/* RIFS use permitted */
646170530Ssam#define	IEEE80211_HTINFO_PMSPONLY	0x10	/* PSMP required to associate */
647170530Ssam#define	IEEE80211_HTINFO_SIGRAN		0xe0	/* shortest Service Interval */
648170530Ssam#define	IEEE80211_HTINFO_SIGRAN_S	5
649170530Ssam#define	IEEE80211_HTINFO_SIGRAN_5	0x00	/* 5 ms */
650170530Ssam/* XXX add rest */
651170530Ssam
652170530Ssam/* bytes 2+3 */
653170530Ssam#define	IEEE80211_HTINFO_OPMODE		0x03	/* operating mode */
654170530Ssam#define	IEEE80211_HTINFO_OPMODE_S	0
655170530Ssam#define	IEEE80211_HTINFO_OPMODE_PURE	0x00	/* no protection */
656172055Ssam#define	IEEE80211_HTINFO_OPMODE_PROTOPT	0x01	/* protection optional */
657172055Ssam#define	IEEE80211_HTINFO_OPMODE_HT20PR	0x02	/* protection for HT20 sta's */
658172055Ssam#define	IEEE80211_HTINFO_OPMODE_MIXED	0x03	/* protection for legacy sta's*/
659170530Ssam#define	IEEE80211_HTINFO_NONGF_PRESENT	0x04	/* non-GF sta's present */
660170530Ssam#define	IEEE80211_HTINFO_TXBL		0x08	/* transmit burst limit */
661170530Ssam#define	IEEE80211_HTINFO_NONHT_PRESENT	0x10	/* non-HT sta's present */
662170530Ssam/* bits 5-15 reserved */
663170530Ssam
664170530Ssam/* bytes 4+5 */
665170530Ssam#define	IEEE80211_HTINFO_2NDARYBEACON	0x01
666170530Ssam#define	IEEE80211_HTINFO_LSIGTXOPPROT	0x02
667170530Ssam#define	IEEE80211_HTINFO_PCO_ACTIVE	0x04
668170530Ssam#define	IEEE80211_HTINFO_40MHZPHASE	0x08
669170530Ssam
670170530Ssam/* byte5 */
671170530Ssam#define	IEEE80211_HTINFO_BASIC_STBCMCS	0x7f
672170530Ssam#define	IEEE80211_HTINFO_BASIC_STBCMCS_S 0
673170530Ssam#define	IEEE80211_HTINFO_DUALPROTECTED	0x80
674170530Ssam
675170530Ssam/*
676138568Ssam * Management information element payloads.
677116742Ssam */
678116742Ssam
679116742Ssamenum {
680138568Ssam	IEEE80211_ELEMID_SSID		= 0,
681138568Ssam	IEEE80211_ELEMID_RATES		= 1,
682138568Ssam	IEEE80211_ELEMID_FHPARMS	= 2,
683138568Ssam	IEEE80211_ELEMID_DSPARMS	= 3,
684138568Ssam	IEEE80211_ELEMID_CFPARMS	= 4,
685138568Ssam	IEEE80211_ELEMID_TIM		= 5,
686138568Ssam	IEEE80211_ELEMID_IBSSPARMS	= 6,
687138568Ssam	IEEE80211_ELEMID_COUNTRY	= 7,
688138568Ssam	IEEE80211_ELEMID_CHALLENGE	= 16,
689127903Ssam	/* 17-31 reserved for challenge text extension */
690170530Ssam	IEEE80211_ELEMID_PWRCNSTR	= 32,
691170530Ssam	IEEE80211_ELEMID_PWRCAP		= 33,
692170530Ssam	IEEE80211_ELEMID_TPCREQ		= 34,
693170530Ssam	IEEE80211_ELEMID_TPCREP		= 35,
694170530Ssam	IEEE80211_ELEMID_SUPPCHAN	= 36,
695193439Ssam	IEEE80211_ELEMID_CSA		= 37,
696170530Ssam	IEEE80211_ELEMID_MEASREQ	= 38,
697170530Ssam	IEEE80211_ELEMID_MEASREP	= 39,
698170530Ssam	IEEE80211_ELEMID_QUIET		= 40,
699170530Ssam	IEEE80211_ELEMID_IBSSDFS	= 41,
700138568Ssam	IEEE80211_ELEMID_ERP		= 42,
701170530Ssam	IEEE80211_ELEMID_HTCAP		= 45,
702138568Ssam	IEEE80211_ELEMID_RSN		= 48,
703138568Ssam	IEEE80211_ELEMID_XRATES		= 50,
704170530Ssam	IEEE80211_ELEMID_HTINFO		= 61,
705138568Ssam	IEEE80211_ELEMID_TPC		= 150,
706138568Ssam	IEEE80211_ELEMID_CCKM		= 156,
707138568Ssam	IEEE80211_ELEMID_VENDOR		= 221,	/* vendor private */
708116742Ssam};
709116742Ssam
710138568Ssamstruct ieee80211_tim_ie {
711170530Ssam	uint8_t		tim_ie;			/* IEEE80211_ELEMID_TIM */
712170530Ssam	uint8_t		tim_len;
713170530Ssam	uint8_t		tim_count;		/* DTIM count */
714170530Ssam	uint8_t		tim_period;		/* DTIM period */
715170530Ssam	uint8_t		tim_bitctl;		/* bitmap control */
716170530Ssam	uint8_t		tim_bitmap[1];		/* variable-length bitmap */
717138568Ssam} __packed;
718127903Ssam
719138568Ssamstruct ieee80211_country_ie {
720170530Ssam	uint8_t		ie;			/* IEEE80211_ELEMID_COUNTRY */
721170530Ssam	uint8_t		len;
722170530Ssam	uint8_t		cc[3];			/* ISO CC+(I)ndoor/(O)utdoor */
723138568Ssam	struct {
724170530Ssam		uint8_t schan;			/* starting channel */
725170530Ssam		uint8_t nchan;			/* number channels */
726170530Ssam		uint8_t maxtxpwr;		/* tx power cap */
727178354Ssam	} __packed band[1];			/* sub bands (NB: var size) */
728138568Ssam} __packed;
729116742Ssam
730178354Ssam#define	IEEE80211_COUNTRY_MAX_BANDS	84	/* max possible bands */
731178354Ssam#define	IEEE80211_COUNTRY_MAX_SIZE \
732178354Ssam	(sizeof(struct ieee80211_country_ie) + 3*(IEEE80211_COUNTRY_MAX_BANDS-1))
733178354Ssam
734170530Ssam/*
735172055Ssam * 802.11h Channel Switch Announcement (CSA).
736172055Ssam */
737172055Ssamstruct ieee80211_csa_ie {
738172055Ssam	uint8_t		csa_ie;		/* IEEE80211_ELEMID_CHANSWITCHANN */
739172055Ssam	uint8_t		csa_len;
740172055Ssam	uint8_t		csa_mode;		/* Channel Switch Mode */
741172055Ssam	uint8_t		csa_newchan;		/* New Channel Number */
742172055Ssam	uint8_t		csa_count;		/* Channel Switch Count */
743172055Ssam} __packed;
744172055Ssam
745193439Ssam/*
746193439Ssam * Note the min acceptable CSA count is used to guard against
747193439Ssam * malicious CSA injection in station mode.  Defining this value
748193439Ssam * as other than 0 violates the 11h spec.
749193439Ssam */
750193439Ssam#define	IEEE80211_CSA_COUNT_MIN	2
751193439Ssam#define	IEEE80211_CSA_COUNT_MAX	255
752193439Ssam
753172055Ssam/* rate set entries are in .5 Mb/s units, and potentially marked as basic */
754138568Ssam#define	IEEE80211_RATE_BASIC		0x80
755138568Ssam#define	IEEE80211_RATE_VAL		0x7f
756138568Ssam
757116742Ssam/* EPR information element flags */
758138568Ssam#define	IEEE80211_ERP_NON_ERP_PRESENT	0x01
759138568Ssam#define	IEEE80211_ERP_USE_PROTECTION	0x02
760138568Ssam#define	IEEE80211_ERP_LONG_PREAMBLE	0x04
761116742Ssam
762187797Ssam#define	IEEE80211_ERP_BITS \
763187797Ssam	"\20\1NON_ERP_PRESENT\2USE_PROTECTION\3LONG_PREAMBLE"
764187797Ssam
765170530Ssam#define	ATH_OUI			0x7f0300	/* Atheros OUI */
766190455Ssam#define	ATH_OUI_TYPE		0x01		/* Atheros protocol ie */
767127903Ssam
768190455Ssam/* NB: Atheros allocated the OUI for this purpose ~2005 but beware ... */
769190455Ssam#define	TDMA_OUI		ATH_OUI
770190455Ssam#define	TDMA_OUI_TYPE		0x02		/* TDMA protocol ie */
771190455Ssam
772170530Ssam#define	BCM_OUI			0x4c9000	/* Broadcom OUI */
773170530Ssam#define	BCM_OUI_HTCAP		51		/* pre-draft HTCAP ie */
774170530Ssam#define	BCM_OUI_HTINFO		52		/* pre-draft HTINFO ie */
775170530Ssam
776127903Ssam#define	WPA_OUI			0xf25000
777127903Ssam#define	WPA_OUI_TYPE		0x01
778138568Ssam#define	WPA_VERSION		1		/* current supported version */
779127903Ssam
780127903Ssam#define	WPA_CSE_NULL		0x00
781127903Ssam#define	WPA_CSE_WEP40		0x01
782127903Ssam#define	WPA_CSE_TKIP		0x02
783127903Ssam#define	WPA_CSE_CCMP		0x04
784127903Ssam#define	WPA_CSE_WEP104		0x05
785127903Ssam
786127903Ssam#define	WPA_ASE_NONE		0x00
787127903Ssam#define	WPA_ASE_8021X_UNSPEC	0x01
788127903Ssam#define	WPA_ASE_8021X_PSK	0x02
789127903Ssam
790181347Ssam#define	WPS_OUI_TYPE		0x04
791181347Ssam
792138568Ssam#define	RSN_OUI			0xac0f00
793138568Ssam#define	RSN_VERSION		1		/* current supported version */
794138568Ssam
795138568Ssam#define	RSN_CSE_NULL		0x00
796138568Ssam#define	RSN_CSE_WEP40		0x01
797138568Ssam#define	RSN_CSE_TKIP		0x02
798138568Ssam#define	RSN_CSE_WRAP		0x03
799138568Ssam#define	RSN_CSE_CCMP		0x04
800138568Ssam#define	RSN_CSE_WEP104		0x05
801138568Ssam
802138568Ssam#define	RSN_ASE_NONE		0x00
803138568Ssam#define	RSN_ASE_8021X_UNSPEC	0x01
804138568Ssam#define	RSN_ASE_8021X_PSK	0x02
805138568Ssam
806138568Ssam#define	RSN_CAP_PREAUTH		0x01
807138568Ssam
808138568Ssam#define	WME_OUI			0xf25000
809138568Ssam#define	WME_OUI_TYPE		0x02
810138568Ssam#define	WME_INFO_OUI_SUBTYPE	0x00
811138568Ssam#define	WME_PARAM_OUI_SUBTYPE	0x01
812138568Ssam#define	WME_VERSION		1
813138568Ssam
814138568Ssam/* WME stream classes */
815138568Ssam#define	WME_AC_BE	0		/* best effort */
816138568Ssam#define	WME_AC_BK	1		/* background */
817138568Ssam#define	WME_AC_VI	2		/* video */
818138568Ssam#define	WME_AC_VO	3		/* voice */
819138568Ssam
820116742Ssam/*
821116742Ssam * AUTH management packets
822116742Ssam *
823116742Ssam *	octet algo[2]
824116742Ssam *	octet seq[2]
825116742Ssam *	octet status[2]
826116742Ssam *	octet chal.id
827116742Ssam *	octet chal.length
828172055Ssam *	octet chal.text[253]		NB: 1-253 bytes
829116742Ssam */
830116742Ssam
831172055Ssam/* challenge length for shared key auth */
832172055Ssam#define IEEE80211_CHALLENGE_LEN		128
833116742Ssam
834138568Ssam#define	IEEE80211_AUTH_ALG_OPEN		0x0000
835138568Ssam#define	IEEE80211_AUTH_ALG_SHARED	0x0001
836138568Ssam#define	IEEE80211_AUTH_ALG_LEAP		0x0080
837116742Ssam
838116742Ssamenum {
839116742Ssam	IEEE80211_AUTH_OPEN_REQUEST		= 1,
840116742Ssam	IEEE80211_AUTH_OPEN_RESPONSE		= 2,
841116742Ssam};
842116742Ssam
843116742Ssamenum {
844116742Ssam	IEEE80211_AUTH_SHARED_REQUEST		= 1,
845116742Ssam	IEEE80211_AUTH_SHARED_CHALLENGE		= 2,
846116742Ssam	IEEE80211_AUTH_SHARED_RESPONSE		= 3,
847116742Ssam	IEEE80211_AUTH_SHARED_PASS		= 4,
848116742Ssam};
849116742Ssam
850116742Ssam/*
851172055Ssam * Reason and status codes.
852116742Ssam *
853172055Ssam * Reason codes are used in management frames to indicate why an
854172055Ssam * action took place (e.g. on disassociation).  Status codes are
855172055Ssam * used in management frames to indicate the result of an operation.
856172055Ssam *
857116742Ssam * Unlisted codes are reserved
858116742Ssam */
859116742Ssam
860116742Ssamenum {
861116742Ssam	IEEE80211_REASON_UNSPECIFIED		= 1,
862116742Ssam	IEEE80211_REASON_AUTH_EXPIRE		= 2,
863116742Ssam	IEEE80211_REASON_AUTH_LEAVE		= 3,
864116742Ssam	IEEE80211_REASON_ASSOC_EXPIRE		= 4,
865116742Ssam	IEEE80211_REASON_ASSOC_TOOMANY		= 5,
866116742Ssam	IEEE80211_REASON_NOT_AUTHED		= 6,
867116742Ssam	IEEE80211_REASON_NOT_ASSOCED		= 7,
868116742Ssam	IEEE80211_REASON_ASSOC_LEAVE		= 8,
869116742Ssam	IEEE80211_REASON_ASSOC_NOT_AUTHED	= 9,
870172055Ssam	IEEE80211_REASON_DISASSOC_PWRCAP_BAD	= 10,	/* 11h */
871172055Ssam	IEEE80211_REASON_DISASSOC_SUPCHAN_BAD	= 11,	/* 11h */
872172055Ssam	IEEE80211_REASON_IE_INVALID		= 13,	/* 11i */
873172055Ssam	IEEE80211_REASON_MIC_FAILURE		= 14,	/* 11i */
874172055Ssam	IEEE80211_REASON_4WAY_HANDSHAKE_TIMEOUT	= 15,	/* 11i */
875172055Ssam	IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,	/* 11i */
876172055Ssam	IEEE80211_REASON_IE_IN_4WAY_DIFFERS	= 17,	/* 11i */
877172055Ssam	IEEE80211_REASON_GROUP_CIPHER_INVALID	= 18,	/* 11i */
878172055Ssam	IEEE80211_REASON_PAIRWISE_CIPHER_INVALID= 19,	/* 11i */
879172055Ssam	IEEE80211_REASON_AKMP_INVALID		= 20,	/* 11i */
880172055Ssam	IEEE80211_REASON_UNSUPP_RSN_IE_VERSION	= 21,	/* 11i */
881172055Ssam	IEEE80211_REASON_INVALID_RSN_IE_CAP	= 22,	/* 11i */
882172055Ssam	IEEE80211_REASON_802_1X_AUTH_FAILED	= 23,	/* 11i */
883172055Ssam	IEEE80211_REASON_CIPHER_SUITE_REJECTED	= 24,	/* 11i */
884182820Ssam	IEEE80211_REASON_UNSPECIFIED_QOS	= 32,	/* 11e */
885182820Ssam	IEEE80211_REASON_INSUFFICIENT_BW	= 33,	/* 11e */
886182820Ssam	IEEE80211_REASON_TOOMANY_FRAMES		= 34,	/* 11e */
887182820Ssam	IEEE80211_REASON_OUTSIDE_TXOP		= 35,	/* 11e */
888182820Ssam	IEEE80211_REASON_LEAVING_QBSS		= 36,	/* 11e */
889182820Ssam	IEEE80211_REASON_BAD_MECHANISM		= 37,	/* 11e */
890182820Ssam	IEEE80211_REASON_SETUP_NEEDED		= 38,	/* 11e */
891182820Ssam	IEEE80211_REASON_TIMEOUT		= 39,	/* 11e */
892116742Ssam
893116742Ssam	IEEE80211_STATUS_SUCCESS		= 0,
894116742Ssam	IEEE80211_STATUS_UNSPECIFIED		= 1,
895116742Ssam	IEEE80211_STATUS_CAPINFO		= 10,
896116742Ssam	IEEE80211_STATUS_NOT_ASSOCED		= 11,
897116742Ssam	IEEE80211_STATUS_OTHER			= 12,
898116742Ssam	IEEE80211_STATUS_ALG			= 13,
899116742Ssam	IEEE80211_STATUS_SEQUENCE		= 14,
900116742Ssam	IEEE80211_STATUS_CHALLENGE		= 15,
901116742Ssam	IEEE80211_STATUS_TIMEOUT		= 16,
902116742Ssam	IEEE80211_STATUS_TOOMANY		= 17,
903116742Ssam	IEEE80211_STATUS_BASIC_RATE		= 18,
904172055Ssam	IEEE80211_STATUS_SP_REQUIRED		= 19,	/* 11b */
905172055Ssam	IEEE80211_STATUS_PBCC_REQUIRED		= 20,	/* 11b */
906172055Ssam	IEEE80211_STATUS_CA_REQUIRED		= 21,	/* 11b */
907172055Ssam	IEEE80211_STATUS_SPECMGMT_REQUIRED	= 22,	/* 11h */
908172055Ssam	IEEE80211_STATUS_PWRCAP_REQUIRED	= 23,	/* 11h */
909172055Ssam	IEEE80211_STATUS_SUPCHAN_REQUIRED	= 24,	/* 11h */
910172055Ssam	IEEE80211_STATUS_SHORTSLOT_REQUIRED	= 25,	/* 11g */
911172055Ssam	IEEE80211_STATUS_DSSSOFDM_REQUIRED	= 26,	/* 11g */
912193542Ssam	IEEE80211_STATUS_MISSING_HT_CAPS	= 27,	/* 11n D3.0 */
913172055Ssam	IEEE80211_STATUS_INVALID_IE		= 40,	/* 11i */
914172055Ssam	IEEE80211_STATUS_GROUP_CIPHER_INVALID	= 41,	/* 11i */
915172055Ssam	IEEE80211_STATUS_PAIRWISE_CIPHER_INVALID = 42,	/* 11i */
916172055Ssam	IEEE80211_STATUS_AKMP_INVALID		= 43,	/* 11i */
917172055Ssam	IEEE80211_STATUS_UNSUPP_RSN_IE_VERSION	= 44,	/* 11i */
918172055Ssam	IEEE80211_STATUS_INVALID_RSN_IE_CAP	= 45,	/* 11i */
919172055Ssam	IEEE80211_STATUS_CIPHER_SUITE_REJECTED	= 46,	/* 11i */
920116742Ssam};
921116742Ssam
922138568Ssam#define	IEEE80211_WEP_KEYLEN		5	/* 40bit */
923138568Ssam#define	IEEE80211_WEP_IVLEN		3	/* 24bit */
924138568Ssam#define	IEEE80211_WEP_KIDLEN		1	/* 1 octet */
925138568Ssam#define	IEEE80211_WEP_CRCLEN		4	/* CRC-32 */
926178354Ssam#define	IEEE80211_WEP_TOTLEN		(IEEE80211_WEP_IVLEN + \
927178354Ssam					 IEEE80211_WEP_KIDLEN + \
928178354Ssam					 IEEE80211_WEP_CRCLEN)
929138568Ssam#define	IEEE80211_WEP_NKID		4	/* number of key ids */
930116742Ssam
931138568Ssam/*
932138568Ssam * 802.11i defines an extended IV for use with non-WEP ciphers.
933138568Ssam * When the EXTIV bit is set in the key id byte an additional
934138568Ssam * 4 bytes immediately follow the IV for TKIP.  For CCMP the
935138568Ssam * EXTIV bit is likewise set but the 8 bytes represent the
936138568Ssam * CCMP header rather than IV+extended-IV.
937138568Ssam */
938138568Ssam#define	IEEE80211_WEP_EXTIV		0x20
939138568Ssam#define	IEEE80211_WEP_EXTIVLEN		4	/* extended IV length */
940138568Ssam#define	IEEE80211_WEP_MICLEN		8	/* trailing MIC */
941116742Ssam
942138568Ssam#define	IEEE80211_CRC_LEN		4
943138568Ssam
944124457Ssam/*
945124457Ssam * Maximum acceptable MTU is:
946124457Ssam *	IEEE80211_MAX_LEN - WEP overhead - CRC -
947124457Ssam *		QoS overhead - RSN/WPA overhead
948124457Ssam * Min is arbitrarily chosen > IEEE80211_MIN_LEN.  The default
949124457Ssam * mtu is Ethernet-compatible; it's set by ether_ifattach.
950124457Ssam */
951138568Ssam#define	IEEE80211_MTU_MAX		2290
952138568Ssam#define	IEEE80211_MTU_MIN		32
953124457Ssam
954138568Ssam#define	IEEE80211_MAX_LEN		(2300 + IEEE80211_CRC_LEN + \
955116742Ssam    (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
956138568Ssam#define	IEEE80211_ACK_LEN \
957138568Ssam	(sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
958120098Ssam#define	IEEE80211_MIN_LEN \
959120098Ssam	(sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
960116742Ssam
961138568Ssam/*
962138568Ssam * The 802.11 spec says at most 2007 stations may be
963138568Ssam * associated at once.  For most AP's this is way more
964178354Ssam * than is feasible so we use a default of IEEE80211_AID_DEF.
965178354Ssam * This number may be overridden by the driver and/or by
966178354Ssam * user configuration but may not be less than IEEE80211_AID_MIN
967178354Ssam * (see _ieee80211.h for implementation-specific settings).
968138568Ssam */
969138568Ssam#define	IEEE80211_AID_MAX		2007
970138568Ssam
971138568Ssam#define	IEEE80211_AID(b)	((b) &~ 0xc000)
972138568Ssam
973116742Ssam/*
974116742Ssam * RTS frame length parameters.  The default is specified in
975148291Ssam * the 802.11 spec as 512; we treat it as implementation-dependent
976148291Ssam * so it's defined in ieee80211_var.h.  The max may be wrong
977148291Ssam * for jumbo frames.
978116742Ssam */
979138568Ssam#define	IEEE80211_RTS_MIN		1
980148291Ssam#define	IEEE80211_RTS_MAX		2346
981116742Ssam
982148291Ssam/*
983148291Ssam * TX fragmentation parameters.  As above for RTS, we treat
984148291Ssam * default as implementation-dependent so define it elsewhere.
985148291Ssam */
986148291Ssam#define	IEEE80211_FRAG_MIN		256
987148291Ssam#define	IEEE80211_FRAG_MAX		2346
988148291Ssam
989160685Ssam/*
990160685Ssam * Beacon interval (TU's).  Min+max come from WiFi requirements.
991160685Ssam * As above, we treat default as implementation-dependent so
992160685Ssam * define it elsewhere.
993160685Ssam */
994160685Ssam#define	IEEE80211_BINTVAL_MAX	1000	/* max beacon interval (TU's) */
995160685Ssam#define	IEEE80211_BINTVAL_MIN	25	/* min beacon interval (TU's) */
996160685Ssam
997160685Ssam/*
998160685Ssam * DTIM period (beacons).  Min+max are not really defined
999160685Ssam * by the protocol but we want them publicly visible so
1000160685Ssam * define them here.
1001160685Ssam */
1002160685Ssam#define	IEEE80211_DTIM_MAX	15	/* max DTIM period */
1003160685Ssam#define	IEEE80211_DTIM_MIN	1	/* min DTIM period */
1004160685Ssam
1005160685Ssam/*
1006160685Ssam * Beacon miss threshold (beacons).  As for DTIM, we define
1007160685Ssam * them here to be publicly visible.  Note the max may be
1008160685Ssam * clamped depending on device capabilities.
1009160685Ssam */
1010160685Ssam#define	IEEE80211_HWBMISS_MIN 	1
1011160685Ssam#define	IEEE80211_HWBMISS_MAX 	255
1012160685Ssam
1013170530Ssam/*
1014170530Ssam * 802.11 frame duration definitions.
1015170530Ssam */
1016170530Ssam
1017170530Ssamstruct ieee80211_duration {
1018170530Ssam	uint16_t	d_rts_dur;
1019170530Ssam	uint16_t	d_data_dur;
1020170530Ssam	uint16_t	d_plcp_len;
1021170530Ssam	uint8_t		d_residue;	/* unused octets in time slot */
1022170530Ssam};
1023170530Ssam
1024170530Ssam/* One Time Unit (TU) is 1Kus = 1024 microseconds. */
1025170530Ssam#define IEEE80211_DUR_TU		1024
1026170530Ssam
1027170530Ssam/* IEEE 802.11b durations for DSSS PHY in microseconds */
1028170530Ssam#define IEEE80211_DUR_DS_LONG_PREAMBLE	144
1029170530Ssam#define IEEE80211_DUR_DS_SHORT_PREAMBLE	72
1030170530Ssam
1031170530Ssam#define IEEE80211_DUR_DS_SLOW_PLCPHDR	48
1032170530Ssam#define IEEE80211_DUR_DS_FAST_PLCPHDR	24
1033170530Ssam#define IEEE80211_DUR_DS_SLOW_ACK	112
1034170530Ssam#define IEEE80211_DUR_DS_FAST_ACK	56
1035170530Ssam#define IEEE80211_DUR_DS_SLOW_CTS	112
1036170530Ssam#define IEEE80211_DUR_DS_FAST_CTS	56
1037170530Ssam
1038170530Ssam#define IEEE80211_DUR_DS_SLOT		20
1039170530Ssam#define IEEE80211_DUR_DS_SIFS		10
1040170530Ssam#define IEEE80211_DUR_DS_PIFS	(IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT)
1041170530Ssam#define IEEE80211_DUR_DS_DIFS	(IEEE80211_DUR_DS_SIFS + \
1042170530Ssam				 2 * IEEE80211_DUR_DS_SLOT)
1043170530Ssam#define IEEE80211_DUR_DS_EIFS	(IEEE80211_DUR_DS_SIFS + \
1044170530Ssam				 IEEE80211_DUR_DS_SLOW_ACK + \
1045170530Ssam				 IEEE80211_DUR_DS_LONG_PREAMBLE + \
1046170530Ssam				 IEEE80211_DUR_DS_SLOW_PLCPHDR + \
1047170530Ssam				 IEEE80211_DUR_DIFS)
1048170530Ssam
1049116742Ssam#endif /* _NET80211_IEEE80211_H_ */
1050