Home | History | Annotate | Line # | Download | only in net80211
ieee80211.h revision 1.18.4.1
      1 /*	$NetBSD: ieee80211.h,v 1.18.4.1 2008/02/22 16:50:25 skrll Exp $	*/
      2 /*-
      3  * Copyright (c) 2001 Atsushi Onoe
      4  * Copyright (c) 2002-2007 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  *
     16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26  *
     27  * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.18 2007/11/23 06:12:46 sam Exp $
     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 /* IEEE 802.11 PLCP header */
     41 struct ieee80211_plcp_hdr {
     42 	uint16_t	i_sfd;
     43 	uint8_t		i_signal;
     44 	uint8_t		i_service;
     45 	uint16_t	i_length;
     46 	uint16_t	i_crc;
     47 } __packed;
     48 
     49 #define IEEE80211_PLCP_SFD      0xF3A0
     50 #define IEEE80211_PLCP_SERVICE  0x00
     51 
     52 /*
     53  * generic definitions for IEEE 802.11 frames
     54  */
     55 struct ieee80211_frame {
     56 	uint8_t		i_fc[2];
     57 	uint8_t		i_dur[2];
     58 	uint8_t		i_addr1[IEEE80211_ADDR_LEN];
     59 	uint8_t		i_addr2[IEEE80211_ADDR_LEN];
     60 	uint8_t		i_addr3[IEEE80211_ADDR_LEN];
     61 	uint8_t		i_seq[2];
     62 	/* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
     63 	/* see below */
     64 } __packed;
     65 
     66 struct ieee80211_qosframe {
     67 	uint8_t		i_fc[2];
     68 	uint8_t		i_dur[2];
     69 	uint8_t		i_addr1[IEEE80211_ADDR_LEN];
     70 	uint8_t		i_addr2[IEEE80211_ADDR_LEN];
     71 	uint8_t		i_addr3[IEEE80211_ADDR_LEN];
     72 	uint8_t		i_seq[2];
     73 	uint8_t		i_qos[2];
     74 	/* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
     75 	/* see below */
     76 } __packed;
     77 
     78 struct ieee80211_qoscntl {
     79 	uint8_t		i_qos[2];
     80 };
     81 
     82 struct ieee80211_frame_addr4 {
     83 	uint8_t		i_fc[2];
     84 	uint8_t		i_dur[2];
     85 	uint8_t		i_addr1[IEEE80211_ADDR_LEN];
     86 	uint8_t		i_addr2[IEEE80211_ADDR_LEN];
     87 	uint8_t		i_addr3[IEEE80211_ADDR_LEN];
     88 	uint8_t		i_seq[2];
     89 	uint8_t		i_addr4[IEEE80211_ADDR_LEN];
     90 } __packed;
     91 
     92 
     93 struct ieee80211_qosframe_addr4 {
     94 	uint8_t		i_fc[2];
     95 	uint8_t		i_dur[2];
     96 	uint8_t		i_addr1[IEEE80211_ADDR_LEN];
     97 	uint8_t		i_addr2[IEEE80211_ADDR_LEN];
     98 	uint8_t		i_addr3[IEEE80211_ADDR_LEN];
     99 	uint8_t		i_seq[2];
    100 	uint8_t		i_addr4[IEEE80211_ADDR_LEN];
    101 	uint8_t		i_qos[2];
    102 } __packed;
    103 
    104 #define	IEEE80211_FC0_VERSION_MASK		0x03
    105 #define	IEEE80211_FC0_VERSION_SHIFT		0
    106 #define	IEEE80211_FC0_VERSION_0			0x00
    107 #define	IEEE80211_FC0_TYPE_MASK			0x0c
    108 #define	IEEE80211_FC0_TYPE_SHIFT		2
    109 #define	IEEE80211_FC0_TYPE_MGT			0x00
    110 #define	IEEE80211_FC0_TYPE_CTL			0x04
    111 #define	IEEE80211_FC0_TYPE_DATA			0x08
    112 
    113 #define	IEEE80211_FC0_SUBTYPE_MASK		0xf0
    114 #define	IEEE80211_FC0_SUBTYPE_SHIFT		4
    115 /* for TYPE_MGT */
    116 #define	IEEE80211_FC0_SUBTYPE_ASSOC_REQ		0x00
    117 #define	IEEE80211_FC0_SUBTYPE_ASSOC_RESP	0x10
    118 #define	IEEE80211_FC0_SUBTYPE_REASSOC_REQ	0x20
    119 #define	IEEE80211_FC0_SUBTYPE_REASSOC_RESP	0x30
    120 #define	IEEE80211_FC0_SUBTYPE_PROBE_REQ		0x40
    121 #define	IEEE80211_FC0_SUBTYPE_PROBE_RESP	0x50
    122 #define	IEEE80211_FC0_SUBTYPE_BEACON		0x80
    123 #define	IEEE80211_FC0_SUBTYPE_ATIM		0x90
    124 #define	IEEE80211_FC0_SUBTYPE_DISASSOC		0xa0
    125 #define	IEEE80211_FC0_SUBTYPE_AUTH		0xb0
    126 #define	IEEE80211_FC0_SUBTYPE_DEAUTH		0xc0
    127 #define	IEEE80211_FC0_SUBTYPE_ACTION		0xd0
    128 /* for TYPE_CTL */
    129 #define	IEEE80211_FC0_SUBTYPE_BAR		0x80
    130 #define	IEEE80211_FC0_SUBTYPE_PS_POLL		0xa0
    131 #define	IEEE80211_FC0_SUBTYPE_RTS		0xb0
    132 #define	IEEE80211_FC0_SUBTYPE_CTS		0xc0
    133 #define	IEEE80211_FC0_SUBTYPE_ACK		0xd0
    134 #define	IEEE80211_FC0_SUBTYPE_CF_END		0xe0
    135 #define	IEEE80211_FC0_SUBTYPE_CF_END_ACK	0xf0
    136 /* for TYPE_DATA (bit combination) */
    137 #define	IEEE80211_FC0_SUBTYPE_DATA		0x00
    138 #define	IEEE80211_FC0_SUBTYPE_CF_ACK		0x10
    139 #define	IEEE80211_FC0_SUBTYPE_CF_POLL		0x20
    140 #define	IEEE80211_FC0_SUBTYPE_CF_ACPL		0x30
    141 #define	IEEE80211_FC0_SUBTYPE_NODATA		0x40
    142 #define	IEEE80211_FC0_SUBTYPE_CFACK		0x50
    143 #define	IEEE80211_FC0_SUBTYPE_CFPOLL		0x60
    144 #define	IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK	0x70
    145 #define	IEEE80211_FC0_SUBTYPE_QOS		0x80
    146 #define	IEEE80211_FC0_SUBTYPE_QOS_NULL		0xc0
    147 
    148 #define	IEEE80211_FC1_DIR_MASK			0x03
    149 #define	IEEE80211_FC1_DIR_NODS			0x00	/* STA->STA */
    150 #define	IEEE80211_FC1_DIR_TODS			0x01	/* STA->AP  */
    151 #define	IEEE80211_FC1_DIR_FROMDS		0x02	/* AP ->STA */
    152 #define	IEEE80211_FC1_DIR_DSTODS		0x03	/* AP ->AP  */
    153 
    154 #define	IEEE80211_FC1_MORE_FRAG			0x04
    155 #define	IEEE80211_FC1_RETRY			0x08
    156 #define	IEEE80211_FC1_PWR_MGT			0x10
    157 #define	IEEE80211_FC1_MORE_DATA			0x20
    158 #define	IEEE80211_FC1_WEP			0x40
    159 #define	IEEE80211_FC1_ORDER			0x80
    160 
    161 #define	IEEE80211_SEQ_FRAG_MASK			0x000f
    162 #define	IEEE80211_SEQ_FRAG_SHIFT		0
    163 #define	IEEE80211_SEQ_SEQ_MASK			0xfff0
    164 #define	IEEE80211_SEQ_SEQ_SHIFT			4
    165 #define	IEEE80211_SEQ_RANGE			4096
    166 
    167 #define	IEEE80211_SEQ_ADD(seq, incr) \
    168 	(((seq) + (incr)) & (IEEE80211_SEQ_RANGE-1))
    169 #define	IEEE80211_SEQ_INC(seq)	IEEE80211_SEQ_ADD(seq,1)
    170 #define	IEEE80211_SEQ_SUB(a, b) \
    171 	(((a) + IEEE80211_SEQ_RANGE - (b)) & (IEEE80211_SEQ_RANGE-1))
    172 
    173 #define	IEEE80211_SEQ_BA_RANGE			2048	/* 2^11 */
    174 #define	IEEE80211_SEQ_BA_BEFORE(a, b) \
    175 	(IEEE80211_SEQ_SUB(b, a+1) < IEEE80211_SEQ_BA_RANGE-1)
    176 
    177 #define	IEEE80211_NWID_LEN			32
    178 
    179 #define	IEEE80211_QOS_TXOP			0x00ff
    180 /* bit 8 is reserved */
    181 #define	IEEE80211_QOS_AMSDU			0x80
    182 #define	IEEE80211_QOS_AMSDU_S			7
    183 #define	IEEE80211_QOS_ACKPOLICY			0x60
    184 #define	IEEE80211_QOS_ACKPOLICY_S		5
    185 #define	IEEE80211_QOS_ACKPOLICY_NOACK		0x20	/* No ACK required */
    186 #define	IEEE80211_QOS_ACKPOLICY_BA		0x60	/* Block ACK */
    187 #define	IEEE80211_QOS_ESOP			0x10
    188 #define	IEEE80211_QOS_ESOP_S			4
    189 #define	IEEE80211_QOS_TID			0x0f
    190 
    191 /* does frame have QoS sequence control data */
    192 #define	IEEE80211_QOS_HAS_SEQ(wh) \
    193 	(((wh)->i_fc[0] & \
    194 	  (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \
    195 	  (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
    196 
    197 /*
    198  * WME/802.11e information element.
    199  */
    200 struct ieee80211_wme_info {
    201 	uint8_t		wme_id;		/* IEEE80211_ELEMID_VENDOR */
    202 	uint8_t		wme_len;	/* length in bytes */
    203 	uint8_t		wme_oui[3];	/* 0x00, 0x50, 0xf2 */
    204 	uint8_t		wme_type;	/* OUI type */
    205 	uint8_t		wme_subtype;	/* OUI subtype */
    206 	uint8_t		wme_version;	/* spec revision */
    207 	uint8_t		wme_info;	/* QoS info */
    208 } __packed;
    209 
    210 /*
    211  * WME/802.11e Tspec Element
    212  */
    213 struct ieee80211_wme_tspec {
    214 	uint8_t		ts_id;
    215 	uint8_t		ts_len;
    216 	uint8_t		ts_oui[3];
    217 	uint8_t		ts_oui_type;
    218 	uint8_t		ts_oui_subtype;
    219 	uint8_t		ts_version;
    220 	uint8_t		ts_tsinfo[3];
    221 	uint8_t		ts_nom_msdu[2];
    222 	uint8_t		ts_max_msdu[2];
    223 	uint8_t		ts_min_svc[4];
    224 	uint8_t		ts_max_svc[4];
    225 	uint8_t		ts_inactv_intv[4];
    226 	uint8_t		ts_susp_intv[4];
    227 	uint8_t		ts_start_svc[4];
    228 	uint8_t		ts_min_rate[4];
    229 	uint8_t		ts_mean_rate[4];
    230 	uint8_t		ts_max_burst[4];
    231 	uint8_t		ts_min_phy[4];
    232 	uint8_t		ts_peak_rate[4];
    233 	uint8_t		ts_delay[4];
    234 	uint8_t		ts_surplus[2];
    235 	uint8_t		ts_medium_time[2];
    236 } __packed;
    237 
    238 /*
    239  * WME AC parameter field
    240  */
    241 struct ieee80211_wme_acparams {
    242 	uint8_t		acp_aci_aifsn;
    243 	uint8_t		acp_logcwminmax;
    244 	uint16_t	acp_txop;
    245 } __packed;
    246 
    247 #define WME_NUM_AC		4	/* 4 AC categories */
    248 #define	WME_NUM_TID		16	/* 16 tids */
    249 
    250 #define WME_PARAM_ACI		0x60	/* Mask for ACI field */
    251 #define WME_PARAM_ACI_S		5	/* Shift for ACI field */
    252 #define WME_PARAM_ACM		0x10	/* Mask for ACM bit */
    253 #define WME_PARAM_ACM_S		4	/* Shift for ACM bit */
    254 #define WME_PARAM_AIFSN		0x0f	/* Mask for aifsn field */
    255 #define WME_PARAM_AIFSN_S	0	/* Shift for aifsn field */
    256 #define WME_PARAM_LOGCWMIN	0x0f	/* Mask for CwMin field (in log) */
    257 #define WME_PARAM_LOGCWMIN_S	0	/* Shift for CwMin field */
    258 #define WME_PARAM_LOGCWMAX	0xf0	/* Mask for CwMax field (in log) */
    259 #define WME_PARAM_LOGCWMAX_S	4	/* Shift for CwMax field */
    260 
    261 #define WME_AC_TO_TID(_ac) (       \
    262 	((_ac) == WME_AC_VO) ? 6 : \
    263 	((_ac) == WME_AC_VI) ? 5 : \
    264 	((_ac) == WME_AC_BK) ? 1 : \
    265 	0)
    266 
    267 #define TID_TO_WME_AC(_tid) (      \
    268 	((_tid) == 0 || (_tid) == 3) ? WME_AC_BE : \
    269 	((_tid) < 3) ? WME_AC_BK : \
    270 	((_tid) < 6) ? WME_AC_VI : \
    271 	WME_AC_VO)
    272 
    273 /*
    274  * WME Parameter Element
    275  */
    276 struct ieee80211_wme_param {
    277 	uint8_t		param_id;
    278 	uint8_t		param_len;
    279 	uint8_t		param_oui[3];
    280 	uint8_t		param_oui_type;
    281 	uint8_t		param_oui_subtype;
    282 	uint8_t		param_version;
    283 	uint8_t		param_qosInfo;
    284 #define	WME_QOSINFO_COUNT	0x0f	/* Mask for param count field */
    285 	uint8_t		param_reserved;
    286 	struct ieee80211_wme_acparams	params_acParams[WME_NUM_AC];
    287 } __packed;
    288 
    289 /*
    290  * Management Notification Frame
    291  */
    292 struct ieee80211_mnf {
    293 	uint8_t		mnf_category;
    294 	uint8_t		mnf_action;
    295 	uint8_t		mnf_dialog;
    296 	uint8_t		mnf_status;
    297 } __packed;
    298 #define	MNF_SETUP_REQ	0
    299 #define	MNF_SETUP_RESP	1
    300 #define	MNF_TEARDOWN	2
    301 
    302 /*
    303  * 802.11n Management Action Frames
    304  */
    305 /* generic frame format */
    306 struct ieee80211_action {
    307 	uint8_t		ia_category;
    308 	uint8_t		ia_action;
    309 } __packed;
    310 
    311 #define	IEEE80211_ACTION_CAT_QOS	0	/* QoS */
    312 #define	IEEE80211_ACTION_CAT_BA		3	/* BA */
    313 #define	IEEE80211_ACTION_CAT_HT		7	/* HT */
    314 
    315 #define	IEEE80211_ACTION_HT_TXCHWIDTH	0	/* recommended xmit chan width*/
    316 #define	IEEE80211_ACTION_HT_MIMOPWRSAVE	1	/* MIMO power save */
    317 
    318 /* HT - recommended transmission channel width */
    319 struct ieee80211_action_ht_txchwidth {
    320 	struct ieee80211_action	at_header;
    321 	uint8_t		at_chwidth;
    322 } __packed;
    323 
    324 #define	IEEE80211_A_HT_TXCHWIDTH_20	0
    325 #define	IEEE80211_A_HT_TXCHWIDTH_2040	1
    326 
    327 /* HT - MIMO Power Save (NB: D2.04) */
    328 struct ieee80211_action_ht_mimopowersave {
    329 	struct ieee80211_action am_header;
    330 	uint8_t		am_control;
    331 } __packed;
    332 
    333 #define	IEEE80211_A_HT_MIMOPWRSAVE_ENA		0x01	/* PS enabled */
    334 #define	IEEE80211_A_HT_MIMOPWRSAVE_MODE		0x02
    335 #define	IEEE80211_A_HT_MIMOPWRSAVE_MODE_S	1
    336 #define	IEEE80211_A_HT_MIMOPWRSAVE_DYNAMIC	0x02	/* Dynamic Mode */
    337 #define	IEEE80211_A_HT_MIMOPWRSAVE_STATIC	0x00	/* no SM packets */
    338 /* bits 2-7 reserved */
    339 
    340 /* Block Ack actions */
    341 #define IEEE80211_ACTION_BA_ADDBA_REQUEST       0   /* ADDBA request */
    342 #define IEEE80211_ACTION_BA_ADDBA_RESPONSE      1   /* ADDBA response */
    343 #define IEEE80211_ACTION_BA_DELBA	        2   /* DELBA */
    344 
    345 /* Block Ack Parameter Set */
    346 #define	IEEE80211_BAPS_BUFSIZ	0xffc0		/* buffer size */
    347 #define	IEEE80211_BAPS_BUFSIZ_S	6
    348 #define	IEEE80211_BAPS_TID	0x003c		/* TID */
    349 #define	IEEE80211_BAPS_TID_S	2
    350 #define	IEEE80211_BAPS_POLICY	0x0002		/* block ack policy */
    351 #define	IEEE80211_BAPS_POLICY_S	1
    352 
    353 #define	IEEE80211_BAPS_POLICY_DELAYED	(0<<IEEE80211_BAPS_POLICY_S)
    354 #define	IEEE80211_BAPS_POLICY_IMMEDIATE	(1<<IEEE80211_BAPS_POLICY_S)
    355 
    356 /* Block Ack Sequence Control */
    357 #define	IEEE80211_BASEQ_START	0xfff0		/* starting seqnum */
    358 #define	IEEE80211_BASEQ_START_S	4
    359 #define	IEEE80211_BASEQ_FRAG	0x000f		/* fragment number */
    360 #define	IEEE80211_BASEQ_FRAG_S	0
    361 
    362 /* Delayed Block Ack Parameter Set */
    363 #define	IEEE80211_DELBAPS_TID	0xf000		/* TID */
    364 #define	IEEE80211_DELBAPS_TID_S	12
    365 #define	IEEE80211_DELBAPS_INIT	0x0800		/* initiator */
    366 #define	IEEE80211_DELBAPS_INIT_S 11
    367 
    368 /* BA - ADDBA request */
    369 struct ieee80211_action_ba_addbarequest {
    370 	struct ieee80211_action rq_header;
    371 	uint8_t		rq_dialogtoken;
    372 	uint16_t	rq_baparamset;
    373 	uint16_t	rq_batimeout;		/* in TUs */
    374 	uint16_t	rq_baseqctl;
    375 } __packed;
    376 
    377 /* BA - ADDBA response */
    378 struct ieee80211_action_ba_addbaresponse {
    379 	struct ieee80211_action rs_header;
    380 	uint8_t		rs_dialogtoken;
    381 	uint16_t	rs_statuscode;
    382 	uint16_t	rs_baparamset;
    383 	uint16_t	rs_batimeout;		/* in TUs */
    384 } __packed;
    385 
    386 /* BA - DELBA */
    387 struct ieee80211_action_ba_delba {
    388 	struct ieee80211_action dl_header;
    389 	uint16_t	dl_baparamset;
    390 	uint16_t	dl_reasoncode;
    391 } __packed;
    392 
    393 /* BAR Control */
    394 #define	IEEE80211_BAR_TID	0xf000		/* TID */
    395 #define	IEEE80211_BAR_TID_S	12
    396 #define	IEEE80211_BAR_COMP	0x0004		/* compressed */
    397 #define	IEEE80211_BAR_MTID	0x0002
    398 #define	IEEE80211_BAR_NOACK	0x0001		/* no-ack policy */
    399 
    400 struct ieee80211_ba_request {
    401 	uint16_t	rq_barctl;
    402 	uint16_t	rq_barseqctl;
    403 } __packed;
    404 
    405 /*
    406  * Control frames.
    407  */
    408 struct ieee80211_frame_min {
    409 	uint8_t		i_fc[2];
    410 	uint8_t		i_dur[2];
    411 	uint8_t		i_addr1[IEEE80211_ADDR_LEN];
    412 	uint8_t		i_addr2[IEEE80211_ADDR_LEN];
    413 	/* FCS */
    414 } __packed;
    415 
    416 struct ieee80211_frame_rts {
    417 	uint8_t		i_fc[2];
    418 	uint8_t		i_dur[2];
    419 	uint8_t		i_ra[IEEE80211_ADDR_LEN];
    420 	uint8_t		i_ta[IEEE80211_ADDR_LEN];
    421 	/* FCS */
    422 } __packed;
    423 
    424 struct ieee80211_frame_cts {
    425 	uint8_t		i_fc[2];
    426 	uint8_t		i_dur[2];
    427 	uint8_t		i_ra[IEEE80211_ADDR_LEN];
    428 	/* FCS */
    429 } __packed;
    430 
    431 struct ieee80211_frame_ack {
    432 	uint8_t		i_fc[2];
    433 	uint8_t		i_dur[2];
    434 	uint8_t		i_ra[IEEE80211_ADDR_LEN];
    435 	/* FCS */
    436 } __packed;
    437 
    438 struct ieee80211_frame_pspoll {
    439 	uint8_t		i_fc[2];
    440 	uint8_t		i_aid[2];
    441 	uint8_t		i_bssid[IEEE80211_ADDR_LEN];
    442 	uint8_t		i_ta[IEEE80211_ADDR_LEN];
    443 	/* FCS */
    444 } __packed;
    445 
    446 struct ieee80211_frame_cfend {		/* NB: also CF-End+CF-Ack */
    447 	uint8_t		i_fc[2];
    448 	uint8_t		i_dur[2];	/* should be zero */
    449 	uint8_t		i_ra[IEEE80211_ADDR_LEN];
    450 	uint8_t		i_bssid[IEEE80211_ADDR_LEN];
    451 	/* FCS */
    452 } __packed;
    453 
    454 struct ieee80211_frame_bar {
    455 	uint8_t		i_fc[2];
    456 	uint8_t		i_dur[2];
    457 	uint8_t		i_ra[IEEE80211_ADDR_LEN];
    458 	uint8_t		i_ta[IEEE80211_ADDR_LEN];
    459 	uint16_t	i_ctl;
    460 	uint16_t	i_seq;
    461 	/* FCS */
    462 } __packed;
    463 
    464 /*
    465  * BEACON management packets
    466  *
    467  *	octet timestamp[8]
    468  *	octet beacon interval[2]
    469  *	octet capability information[2]
    470  *	information element
    471  *		octet elemid
    472  *		octet length
    473  *		octet information[length]
    474  */
    475 
    476 #define	IEEE80211_BEACON_INTERVAL(beacon) \
    477 	((beacon)[8] | ((beacon)[9] << 8))
    478 #define	IEEE80211_BEACON_CAPABILITY(beacon) \
    479 	((beacon)[10] | ((beacon)[11] << 8))
    480 
    481 #define	IEEE80211_CAPINFO_ESS			0x0001
    482 #define	IEEE80211_CAPINFO_IBSS			0x0002
    483 #define	IEEE80211_CAPINFO_CF_POLLABLE		0x0004
    484 #define	IEEE80211_CAPINFO_CF_POLLREQ		0x0008
    485 #define	IEEE80211_CAPINFO_PRIVACY		0x0010
    486 #define	IEEE80211_CAPINFO_SHORT_PREAMBLE	0x0020
    487 #define	IEEE80211_CAPINFO_PBCC			0x0040
    488 #define	IEEE80211_CAPINFO_CHNL_AGILITY		0x0080
    489 #define	IEEE80211_CAPINFO_SPECTRUM_MGMT		0x0100
    490 /* bit 9 is reserved */
    491 #define	IEEE80211_CAPINFO_SHORT_SLOTTIME	0x0400
    492 #define	IEEE80211_CAPINFO_RSN			0x0800
    493 /* bit 12 is reserved */
    494 #define	IEEE80211_CAPINFO_DSSSOFDM		0x2000
    495 /* bits 14-15 are reserved */
    496 
    497 /*
    498  * 802.11i/WPA information element (maximally sized).
    499  */
    500 struct ieee80211_ie_wpa {
    501 	uint8_t		wpa_id;		/* IEEE80211_ELEMID_VENDOR */
    502 	uint8_t		wpa_len;	/* length in bytes */
    503 	uint8_t		wpa_oui[3];	/* 0x00, 0x50, 0xf2 */
    504 	uint8_t		wpa_type;	/* OUI type */
    505 	uint16_t	wpa_version;	/* spec revision */
    506 	uint32_t	wpa_mcipher[1];	/* multicast/group key cipher */
    507 	uint16_t	wpa_uciphercnt;	/* # pairwise key ciphers */
    508 	uint32_t	wpa_uciphers[8];/* ciphers */
    509 	uint16_t	wpa_authselcnt;	/* authentication selector cnt*/
    510 	uint32_t	wpa_authsels[8];/* selectors */
    511 	uint16_t	wpa_caps;	/* 802.11i capabilities */
    512 	uint16_t	wpa_pmkidcnt;	/* 802.11i pmkid count */
    513 	uint16_t	wpa_pmkids[8];	/* 802.11i pmkids */
    514 } __packed;
    515 
    516 /*
    517  * 802.11n HT Capability IE
    518  * NB: these reflect D1.10
    519  */
    520 struct ieee80211_ie_htcap {
    521 	uint8_t		hc_id;			/* element ID */
    522 	uint8_t		hc_len;			/* length in bytes */
    523 	uint16_t	hc_cap;			/* HT caps (see below) */
    524 	uint8_t		hc_param;		/* HT params (see below) */
    525 	uint8_t 	hc_mcsset[16]; 		/* supported MCS set */
    526 	uint16_t	hc_extcap;		/* extended HT capabilities */
    527 	uint32_t	hc_txbf;		/* txbf capabilities */
    528 	uint8_t		hc_antenna;		/* antenna capabilities */
    529 } __packed;
    530 
    531 /* HT capability flags (ht_cap) */
    532 #define	IEEE80211_HTCAP_LDPC		0x0001	/* LDPC supported */
    533 #define	IEEE80211_HTCAP_CHWIDTH40	0x0002	/* 20/40 supported */
    534 #define	IEEE80211_HTCAP_SMPS		0x000c	/* SM Power Save mode */
    535 #define	IEEE80211_HTCAP_SMPS_OFF	0x0000	/* none (static mode) */
    536 #define	IEEE80211_HTCAP_SMPS_DYNAMIC	0x0004	/* send RTS first */
    537 /* NB: SMPS value 2 is reserved */
    538 #define	IEEE80211_HTCAP_SMPS_ENA	0x000c	/* enabled */
    539 #define	IEEE80211_HTCAP_GREENFIELD	0x0010	/* Greenfield supported */
    540 #define	IEEE80211_HTCAP_SHORTGI20	0x0020	/* Short GI in 20MHz */
    541 #define	IEEE80211_HTCAP_SHORTGI40	0x0040	/* Short GI in 40MHz */
    542 #define	IEEE80211_HTCAP_TXSTBC		0x0080	/* STBC tx ok */
    543 #define	IEEE80211_HTCAP_RXSTBC		0x0300  /* STBC rx support */
    544 #define	IEEE80211_HTCAP_RXSTBC_S	8
    545 #define	IEEE80211_HTCAP_RXSTBC_1STREAM	0x0100  /* 1 spatial stream */
    546 #define	IEEE80211_HTCAP_RXSTBC_2STREAM	0x0200  /* 1-2 spatial streams*/
    547 #define	IEEE80211_HTCAP_RXSTBC_3STREAM	0x0300  /* 1-3 spatial streams*/
    548 #define	IEEE80211_HTCAP_DELBA		0x0400	/* HT DELBA supported */
    549 #define	IEEE80211_HTCAP_MAXAMSDU	0x0800	/* max A-MSDU length */
    550 #define	IEEE80211_HTCAP_MAXAMSDU_7935	0x0800	/* 7935 octets */
    551 #define	IEEE80211_HTCAP_MAXAMSDU_3839	0x0000	/* 3839 octets */
    552 #define	IEEE80211_HTCAP_DSSSCCK40	0x1000  /* DSSS/CCK in 40MHz */
    553 #define	IEEE80211_HTCAP_PSMP		0x2000  /* PSMP supported */
    554 #define	IEEE80211_HTCAP_40INTOLERANT	0x4000  /* 40MHz intolerant */
    555 #define	IEEE80211_HTCAP_LSIGTXOPPROT	0x8000  /* L-SIG TXOP prot */
    556 
    557 /* HT parameters (hc_param) */
    558 #define	IEEE80211_HTCAP_MAXRXAMPDU	0x03	/* max rx A-MPDU factor */
    559 #define	IEEE80211_HTCAP_MAXRXAMPDU_S	0
    560 #define	IEEE80211_HTCAP_MAXRXAMPDU_8K	0
    561 #define	IEEE80211_HTCAP_MAXRXAMPDU_16K	1
    562 #define	IEEE80211_HTCAP_MAXRXAMPDU_32K	2
    563 #define	IEEE80211_HTCAP_MAXRXAMPDU_64K	3
    564 #define	IEEE80211_HTCAP_MPDUDENSITY	0x1c	/* min MPDU start spacing */
    565 #define	IEEE80211_HTCAP_MPDUDENSITY_S	2
    566 #define	IEEE80211_HTCAP_MPDUDENSITY_NA	0	/* no time restriction */
    567 #define	IEEE80211_HTCAP_MPDUDENSITY_025	1	/* 1/4 us */
    568 #define	IEEE80211_HTCAP_MPDUDENSITY_05	2	/* 1/2 us */
    569 #define	IEEE80211_HTCAP_MPDUDENSITY_1	3	/* 1 us */
    570 #define	IEEE80211_HTCAP_MPDUDENSITY_2	4	/* 2 us */
    571 #define	IEEE80211_HTCAP_MPDUDENSITY_4	5	/* 4 us */
    572 #define	IEEE80211_HTCAP_MPDUDENSITY_8	6	/* 8 us */
    573 #define	IEEE80211_HTCAP_MPDUDENSITY_16	7	/* 16 us */
    574 
    575 /* HT extended capabilities (hc_extcap) */
    576 #define	IEEE80211_HTCAP_PCO		0x0001	/* PCO capable */
    577 #define	IEEE80211_HTCAP_PCOTRANS	0x0006	/* PCO transition time */
    578 #define	IEEE80211_HTCAP_PCOTRANS_S	1
    579 #define	IEEE80211_HTCAP_PCOTRANS_04	0x0002	/* 400 us */
    580 #define	IEEE80211_HTCAP_PCOTRANS_15	0x0004	/* 1.5 ms */
    581 #define	IEEE80211_HTCAP_PCOTRANS_5	0x0006	/* 5 ms */
    582 /* bits 3-7 reserved */
    583 #define	IEEE80211_HTCAP_MCSFBACK	0x0300	/* MCS feedback */
    584 #define	IEEE80211_HTCAP_MCSFBACK_S	8
    585 #define	IEEE80211_HTCAP_MCSFBACK_NONE	0x0000	/* nothing provided */
    586 #define	IEEE80211_HTCAP_MCSFBACK_UNSOL	0x0200	/* unsolicited feedback */
    587 #define	IEEE80211_HTCAP_MCSFBACK_MRQ	0x0300	/* " "+respond to MRQ */
    588 #define	IEEE80211_HTCAP_HTC		0x0400	/* +HTC support */
    589 #define	IEEE80211_HTCAP_RDR		0x0800	/* reverse direction responder*/
    590 /* bits 12-15 reserved */
    591 
    592 /*
    593  * 802.11n HT Information IE
    594  */
    595 struct ieee80211_ie_htinfo {
    596 	uint8_t		hi_id;			/* element ID */
    597 	uint8_t		hi_len;			/* length in bytes */
    598 	uint8_t		hi_ctrlchannel;		/* primary channel */
    599 	uint8_t		hi_byte1;		/* ht ie byte 1 */
    600 	uint8_t		hi_byte2;		/* ht ie byte 2 */
    601 	uint8_t		hi_byte3;		/* ht ie byte 3 */
    602 	uint16_t	hi_byte45;		/* ht ie bytes 4+5 */
    603 	uint8_t 	hi_basicmcsset[16]; 	/* basic MCS set */
    604 } __packed;
    605 
    606 /* byte1 */
    607 #define	IEEE80211_HTINFO_2NDCHAN	0x03	/* secondary/ext chan offset */
    608 #define	IEEE80211_HTINFO_2NDCHAN_S	0
    609 #define	IEEE80211_HTINFO_2NDCHAN_NONE	0x00	/* no secondary/ext channel */
    610 #define	IEEE80211_HTINFO_2NDCHAN_ABOVE	0x01	/* above private channel */
    611 /* NB: 2 is reserved */
    612 #define	IEEE80211_HTINFO_2NDCHAN_BELOW	0x03	/* below primary channel */
    613 #define	IEEE80211_HTINFO_TXWIDTH	0x04	/* tx channel width */
    614 #define	IEEE80211_HTINFO_TXWIDTH_20	0x00	/* 20MHz width */
    615 #define	IEEE80211_HTINFO_TXWIDTH_2040	0x04	/* any supported width */
    616 #define	IEEE80211_HTINFO_RIFSMODE	0x08	/* Reduced IFS (RIFS) use */
    617 #define	IEEE80211_HTINFO_RIFSMODE_PROH	0x00	/* RIFS use prohibited */
    618 #define	IEEE80211_HTINFO_RIFSMODE_PERM	0x08	/* RIFS use permitted */
    619 #define	IEEE80211_HTINFO_PMSPONLY	0x10	/* PSMP required to associate */
    620 #define	IEEE80211_HTINFO_SIGRAN		0xe0	/* shortest Service Interval */
    621 #define	IEEE80211_HTINFO_SIGRAN_S	5
    622 #define	IEEE80211_HTINFO_SIGRAN_5	0x00	/* 5 ms */
    623 /* XXX add rest */
    624 
    625 /* bytes 2+3 */
    626 #define	IEEE80211_HTINFO_OPMODE		0x03	/* operating mode */
    627 #define	IEEE80211_HTINFO_OPMODE_S	0
    628 #define	IEEE80211_HTINFO_OPMODE_PURE	0x00	/* no protection */
    629 #define	IEEE80211_HTINFO_OPMODE_PROTOPT	0x01	/* protection optional */
    630 #define	IEEE80211_HTINFO_OPMODE_HT20PR	0x02	/* protection for HT20 sta's */
    631 #define	IEEE80211_HTINFO_OPMODE_MIXED	0x03	/* protection for legacy sta's*/
    632 #define	IEEE80211_HTINFO_NONGF_PRESENT	0x04	/* non-GF sta's present */
    633 #define	IEEE80211_HTINFO_TXBL		0x08	/* transmit burst limit */
    634 #define	IEEE80211_HTINFO_NONHT_PRESENT	0x10	/* non-HT sta's present */
    635 /* bits 5-15 reserved */
    636 
    637 /* bytes 4+5 */
    638 #define	IEEE80211_HTINFO_2NDARYBEACON	0x01
    639 #define	IEEE80211_HTINFO_LSIGTXOPPROT	0x02
    640 #define	IEEE80211_HTINFO_PCO_ACTIVE	0x04
    641 #define	IEEE80211_HTINFO_40MHZPHASE	0x08
    642 
    643 /* byte5 */
    644 #define	IEEE80211_HTINFO_BASIC_STBCMCS	0x7f
    645 #define	IEEE80211_HTINFO_BASIC_STBCMCS_S 0
    646 #define	IEEE80211_HTINFO_DUALPROTECTED	0x80
    647 
    648 /*
    649  * Management information element payloads.
    650  */
    651 
    652 enum {
    653 	IEEE80211_ELEMID_SSID		= 0,
    654 	IEEE80211_ELEMID_RATES		= 1,
    655 	IEEE80211_ELEMID_FHPARMS	= 2,
    656 	IEEE80211_ELEMID_DSPARMS	= 3,
    657 	IEEE80211_ELEMID_CFPARMS	= 4,
    658 	IEEE80211_ELEMID_TIM		= 5,
    659 	IEEE80211_ELEMID_IBSSPARMS	= 6,
    660 	IEEE80211_ELEMID_COUNTRY	= 7,
    661 	IEEE80211_ELEMID_CHALLENGE	= 16,
    662 	/* 17-31 reserved for challenge text extension */
    663 	IEEE80211_ELEMID_PWRCNSTR	= 32,
    664 	IEEE80211_ELEMID_PWRCAP		= 33,
    665 	IEEE80211_ELEMID_TPCREQ		= 34,
    666 	IEEE80211_ELEMID_TPCREP		= 35,
    667 	IEEE80211_ELEMID_SUPPCHAN	= 36,
    668 	IEEE80211_ELEMID_CHANSWITCHANN	= 37,
    669 	IEEE80211_ELEMID_MEASREQ	= 38,
    670 	IEEE80211_ELEMID_MEASREP	= 39,
    671 	IEEE80211_ELEMID_QUIET		= 40,
    672 	IEEE80211_ELEMID_IBSSDFS	= 41,
    673 	IEEE80211_ELEMID_ERP		= 42,
    674 	IEEE80211_ELEMID_HTCAP		= 45,
    675 	IEEE80211_ELEMID_RSN		= 48,
    676 	IEEE80211_ELEMID_XRATES		= 50,
    677 	IEEE80211_ELEMID_HTINFO		= 61,
    678 	IEEE80211_ELEMID_TPC		= 150,
    679 	IEEE80211_ELEMID_CCKM		= 156,
    680 	IEEE80211_ELEMID_VENDOR		= 221,	/* vendor private */
    681 };
    682 
    683 struct ieee80211_tim_ie {
    684 	uint8_t		tim_ie;			/* IEEE80211_ELEMID_TIM */
    685 	uint8_t		tim_len;
    686 	uint8_t		tim_count;		/* DTIM count */
    687 	uint8_t		tim_period;		/* DTIM period */
    688 	uint8_t		tim_bitctl;		/* bitmap control */
    689 	uint8_t		tim_bitmap[1];		/* variable-length bitmap */
    690 } __packed;
    691 
    692 struct ieee80211_country_ie {
    693 	uint8_t		ie;			/* IEEE80211_ELEMID_COUNTRY */
    694 	uint8_t		len;
    695 	uint8_t		cc[3];			/* ISO CC+(I)ndoor/(O)utdoor */
    696 	struct {
    697 		uint8_t schan;			/* starting channel */
    698 		uint8_t nchan;			/* number channels */
    699 		uint8_t maxtxpwr;		/* tx power cap */
    700 	} __packed band[10];			/* sub bands */
    701 } __packed;
    702 
    703 /*
    704  * 802.11h Channel Switch Announcement (CSA).
    705  */
    706 struct ieee80211_csa_ie {
    707 	uint8_t		csa_ie;		/* IEEE80211_ELEMID_CHANSWITCHANN */
    708 	uint8_t		csa_len;
    709 	uint8_t		csa_mode;		/* Channel Switch Mode */
    710 	uint8_t		csa_newchan;		/* New Channel Number */
    711 	uint8_t		csa_count;		/* Channel Switch Count */
    712 } __packed;
    713 
    714 /*
    715  * Atheros advanced capability information element.
    716  */
    717 struct ieee80211_ath_ie {
    718 	uint8_t		ath_id;			/* IEEE80211_ELEMID_VENDOR */
    719 	uint8_t		ath_len;		/* length in bytes */
    720 	uint8_t		ath_oui[3];		/* 0x00, 0x03, 0x7f */
    721 	uint8_t		ath_oui_type;		/* OUI type */
    722 	uint8_t		ath_oui_subtype;	/* OUI subtype */
    723 	uint8_t		ath_version;		/* spec revision */
    724 	uint8_t		ath_capability;		/* capability info */
    725 #define	ATHEROS_CAP_TURBO_PRIME		0x01	/* dynamic turbo--aka Turbo' */
    726 #define	ATHEROS_CAP_COMPRESSION		0x02	/* data compression */
    727 #define	ATHEROS_CAP_FAST_FRAME		0x04	/* fast (jumbo) frames */
    728 #define	ATHEROS_CAP_XR			0x08	/* Xtended Range support */
    729 #define	ATHEROS_CAP_AR			0x10	/* Advanded Radar support */
    730 #define	ATHEROS_CAP_BURST		0x20	/* Bursting - not negotiated */
    731 #define	ATHEROS_CAP_WME			0x40	/* CWMin tuning */
    732 #define	ATHEROS_CAP_BOOST		0x80	/* use turbo/!turbo mode */
    733 	uint8_t		ath_defkeyix[2];
    734 } __packed;
    735 
    736 /* rate set entries are in .5 Mb/s units, and potentially marked as basic */
    737 #define	IEEE80211_RATE_BASIC		0x80
    738 #define	IEEE80211_RATE_VAL		0x7f
    739 
    740 /* EPR information element flags */
    741 #define	IEEE80211_ERP_NON_ERP_PRESENT	0x01
    742 #define	IEEE80211_ERP_USE_PROTECTION	0x02
    743 #define	IEEE80211_ERP_LONG_PREAMBLE	0x04
    744 
    745 #define	ATH_OUI			0x7f0300	/* Atheros OUI */
    746 #define	ATH_OUI_TYPE		0x01
    747 #define	ATH_OUI_SUBTYPE		0x01
    748 #define	ATH_OUI_VERSION		0x00
    749 
    750 #define	BCM_OUI			0x4c9000	/* Broadcom OUI */
    751 #define	BCM_OUI_HTCAP		51		/* pre-draft HTCAP ie */
    752 #define	BCM_OUI_HTINFO		52		/* pre-draft HTINFO ie */
    753 
    754 #define	WPA_OUI			0xf25000
    755 #define	WPA_OUI_TYPE		0x01
    756 #define	WPA_VERSION		1		/* current supported version */
    757 
    758 #define	WPA_CSE_NULL		0x00
    759 #define	WPA_CSE_WEP40		0x01
    760 #define	WPA_CSE_TKIP		0x02
    761 #define	WPA_CSE_CCMP		0x04
    762 #define	WPA_CSE_WEP104		0x05
    763 
    764 #define	WPA_ASE_NONE		0x00
    765 #define	WPA_ASE_8021X_UNSPEC	0x01
    766 #define	WPA_ASE_8021X_PSK	0x02
    767 
    768 #define	RSN_OUI			0xac0f00
    769 #define	RSN_VERSION		1		/* current supported version */
    770 
    771 #define	RSN_CSE_NULL		0x00
    772 #define	RSN_CSE_WEP40		0x01
    773 #define	RSN_CSE_TKIP		0x02
    774 #define	RSN_CSE_WRAP		0x03
    775 #define	RSN_CSE_CCMP		0x04
    776 #define	RSN_CSE_WEP104		0x05
    777 
    778 #define	RSN_ASE_NONE		0x00
    779 #define	RSN_ASE_8021X_UNSPEC	0x01
    780 #define	RSN_ASE_8021X_PSK	0x02
    781 
    782 #define	RSN_CAP_PREAUTH		0x01
    783 
    784 #define	WME_OUI			0xf25000
    785 #define	WME_OUI_TYPE		0x02
    786 #define	WME_INFO_OUI_SUBTYPE	0x00
    787 #define	WME_PARAM_OUI_SUBTYPE	0x01
    788 #define	WME_VERSION		1
    789 
    790 /* WME stream classes */
    791 #define	WME_AC_BE	0		/* best effort */
    792 #define	WME_AC_BK	1		/* background */
    793 #define	WME_AC_VI	2		/* video */
    794 #define	WME_AC_VO	3		/* voice */
    795 
    796 /*
    797  * AUTH management packets
    798  *
    799  *	octet algo[2]
    800  *	octet seq[2]
    801  *	octet status[2]
    802  *	octet chal.id
    803  *	octet chal.length
    804  *	octet chal.text[253]		NB: 1-253 bytes
    805  */
    806 
    807 /* challenge length for shared key auth */
    808 #define IEEE80211_CHALLENGE_LEN		128
    809 
    810 #define	IEEE80211_AUTH_ALG_OPEN		0x0000
    811 #define	IEEE80211_AUTH_ALG_SHARED	0x0001
    812 #define	IEEE80211_AUTH_ALG_LEAP		0x0080
    813 
    814 enum {
    815 	IEEE80211_AUTH_OPEN_REQUEST		= 1,
    816 	IEEE80211_AUTH_OPEN_RESPONSE		= 2,
    817 };
    818 
    819 enum {
    820 	IEEE80211_AUTH_SHARED_REQUEST		= 1,
    821 	IEEE80211_AUTH_SHARED_CHALLENGE		= 2,
    822 	IEEE80211_AUTH_SHARED_RESPONSE		= 3,
    823 	IEEE80211_AUTH_SHARED_PASS		= 4,
    824 };
    825 
    826 /*
    827  * Reason and status codes.
    828  *
    829  * Reason codes are used in management frames to indicate why an
    830  * action took place (e.g. on disassociation).  Status codes are
    831  * used in management frames to indicate the result of an operation.
    832  *
    833  * Unlisted codes are reserved
    834  */
    835 
    836 enum {
    837 	IEEE80211_REASON_UNSPECIFIED		= 1,
    838 	IEEE80211_REASON_AUTH_EXPIRE		= 2,
    839 	IEEE80211_REASON_AUTH_LEAVE		= 3,
    840 	IEEE80211_REASON_ASSOC_EXPIRE		= 4,
    841 	IEEE80211_REASON_ASSOC_TOOMANY		= 5,
    842 	IEEE80211_REASON_NOT_AUTHED		= 6,
    843 	IEEE80211_REASON_NOT_ASSOCED		= 7,
    844 	IEEE80211_REASON_ASSOC_LEAVE		= 8,
    845 	IEEE80211_REASON_ASSOC_NOT_AUTHED	= 9,
    846 	IEEE80211_REASON_DISASSOC_PWRCAP_BAD	= 10,	/* 11h */
    847 	IEEE80211_REASON_DISASSOC_SUPCHAN_BAD	= 11,	/* 11h */
    848 	IEEE80211_REASON_IE_INVALID		= 13,	/* 11i */
    849 	IEEE80211_REASON_MIC_FAILURE		= 14,	/* 11i */
    850 	IEEE80211_REASON_4WAY_HANDSHAKE_TIMEOUT	= 15,	/* 11i */
    851 	IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,	/* 11i */
    852 	IEEE80211_REASON_IE_IN_4WAY_DIFFERS	= 17,	/* 11i */
    853 	IEEE80211_REASON_GROUP_CIPHER_INVALID	= 18,	/* 11i */
    854 	IEEE80211_REASON_PAIRWISE_CIPHER_INVALID= 19,	/* 11i */
    855 	IEEE80211_REASON_AKMP_INVALID		= 20,	/* 11i */
    856 	IEEE80211_REASON_UNSUPP_RSN_IE_VERSION	= 21,	/* 11i */
    857 	IEEE80211_REASON_INVALID_RSN_IE_CAP	= 22,	/* 11i */
    858 	IEEE80211_REASON_802_1X_AUTH_FAILED	= 23,	/* 11i */
    859 	IEEE80211_REASON_CIPHER_SUITE_REJECTED	= 24,	/* 11i */
    860 
    861 	IEEE80211_STATUS_SUCCESS		= 0,
    862 	IEEE80211_STATUS_UNSPECIFIED		= 1,
    863 	IEEE80211_STATUS_CAPINFO		= 10,
    864 	IEEE80211_STATUS_NOT_ASSOCED		= 11,
    865 	IEEE80211_STATUS_OTHER			= 12,
    866 	IEEE80211_STATUS_ALG			= 13,
    867 	IEEE80211_STATUS_SEQUENCE		= 14,
    868 	IEEE80211_STATUS_CHALLENGE		= 15,
    869 	IEEE80211_STATUS_TIMEOUT		= 16,
    870 	IEEE80211_STATUS_TOOMANY		= 17,
    871 	IEEE80211_STATUS_BASIC_RATE		= 18,
    872 	IEEE80211_STATUS_SP_REQUIRED		= 19,	/* 11b */
    873 	IEEE80211_STATUS_PBCC_REQUIRED		= 20,	/* 11b */
    874 	IEEE80211_STATUS_CA_REQUIRED		= 21,	/* 11b */
    875 	IEEE80211_STATUS_SPECMGMT_REQUIRED	= 22,	/* 11h */
    876 	IEEE80211_STATUS_PWRCAP_REQUIRED	= 23,	/* 11h */
    877 	IEEE80211_STATUS_SUPCHAN_REQUIRED	= 24,	/* 11h */
    878 	IEEE80211_STATUS_SHORTSLOT_REQUIRED	= 25,	/* 11g */
    879 	IEEE80211_STATUS_DSSSOFDM_REQUIRED	= 26,	/* 11g */
    880 	IEEE80211_STATUS_INVALID_IE		= 40,	/* 11i */
    881 	IEEE80211_STATUS_GROUP_CIPHER_INVALID	= 41,	/* 11i */
    882 	IEEE80211_STATUS_PAIRWISE_CIPHER_INVALID = 42,	/* 11i */
    883 	IEEE80211_STATUS_AKMP_INVALID		= 43,	/* 11i */
    884 	IEEE80211_STATUS_UNSUPP_RSN_IE_VERSION	= 44,	/* 11i */
    885 	IEEE80211_STATUS_INVALID_RSN_IE_CAP	= 45,	/* 11i */
    886 	IEEE80211_STATUS_CIPHER_SUITE_REJECTED	= 46,	/* 11i */
    887 };
    888 
    889 #define	IEEE80211_WEP_KEYLEN		5	/* 40bit */
    890 #define	IEEE80211_WEP_IVLEN		3	/* 24bit */
    891 #define	IEEE80211_WEP_KIDLEN		1	/* 1 octet */
    892 #define	IEEE80211_WEP_CRCLEN		4	/* CRC-32 */
    893 #define	IEEE80211_WEP_TOTLEN		(IEEE80211_WEP_IVLEN + \
    894 					 IEEE80211_WEP_KIDLEN + \
    895 					 IEEE80211_WEP_CRCLEN)
    896 #define	IEEE80211_WEP_NKID		4	/* number of key ids */
    897 
    898 /*
    899  * 802.11i defines an extended IV for use with non-WEP ciphers.
    900  * When the EXTIV bit is set in the key id byte an additional
    901  * 4 bytes immediately follow the IV for TKIP.  For CCMP the
    902  * EXTIV bit is likewise set but the 8 bytes represent the
    903  * CCMP header rather than IV+extended-IV.
    904  */
    905 #define	IEEE80211_WEP_EXTIV		0x20
    906 #define	IEEE80211_WEP_EXTIVLEN		4	/* extended IV length */
    907 #define	IEEE80211_WEP_MICLEN		8	/* trailing MIC */
    908 
    909 #define	IEEE80211_CRC_LEN		4
    910 
    911 /*
    912  * Maximum acceptable MTU is:
    913  *	IEEE80211_MAX_LEN - WEP overhead - CRC -
    914  *		QoS overhead - RSN/WPA overhead
    915  * Min is arbitrarily chosen > IEEE80211_MIN_LEN.  The default
    916  * mtu is Ethernet-compatible; it's set by ether_ifattach.
    917  */
    918 #define	IEEE80211_MTU_MAX		2290
    919 #define	IEEE80211_MTU_MIN		32
    920 
    921 #define	IEEE80211_MAX_LEN		(2300 + IEEE80211_CRC_LEN + \
    922     (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
    923 #define	IEEE80211_ACK_LEN \
    924 	(sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
    925 #define	IEEE80211_MIN_LEN \
    926 	(sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
    927 
    928 /*
    929  * The 802.11 spec says at most 2007 stations may be
    930  * associated at once.  For most AP's this is way more
    931  * than is feasible so we use a default of 128.  This
    932  * number may be overridden by the driver and/or by
    933  * user configuration.
    934  */
    935 #define	IEEE80211_AID_MAX		2007
    936 #define	IEEE80211_AID_DEF		128
    937 
    938 #define	IEEE80211_AID(b)	((b) &~ 0xc000)
    939 
    940 /*
    941  * RTS frame length parameters.  The default is specified in
    942  * the 802.11 spec as 512; we treat it as implementation-dependent
    943  * so it's defined in ieee80211_var.h.  The max may be wrong
    944  * for jumbo frames.
    945  */
    946 #define	IEEE80211_RTS_MIN		1
    947 #define	IEEE80211_RTS_MAX		2346
    948 
    949 /*
    950  * TX fragmentation parameters.  As above for RTS, we treat
    951  * default as implementation-dependent so define it elsewhere.
    952  */
    953 #define	IEEE80211_FRAG_MIN		256
    954 #define	IEEE80211_FRAG_MAX		2346
    955 
    956 /*
    957  * Beacon interval (TU's).  Min+max come from WiFi requirements.
    958  * As above, we treat default as implementation-dependent so
    959  * define it elsewhere.
    960  */
    961 #define	IEEE80211_BINTVAL_MAX	1000	/* max beacon interval (TU's) */
    962 #define	IEEE80211_BINTVAL_MIN	25	/* min beacon interval (TU's) */
    963 
    964 /*
    965  * DTIM period (beacons).  Min+max are not really defined
    966  * by the protocol but we want them publicly visible so
    967  * define them here.
    968  */
    969 #define	IEEE80211_DTIM_MAX	15	/* max DTIM period */
    970 #define	IEEE80211_DTIM_MIN	1	/* min DTIM period */
    971 
    972 /*
    973  * Beacon miss threshold (beacons).  As for DTIM, we define
    974  * them here to be publicly visible.  Note the max may be
    975  * clamped depending on device capabilities.
    976  */
    977 #define	IEEE80211_HWBMISS_MIN 	1
    978 #define	IEEE80211_HWBMISS_MAX 	255
    979 
    980 /*
    981  * 802.11 frame duration definitions.
    982  */
    983 
    984 struct ieee80211_duration {
    985 	uint16_t	d_rts_dur;
    986 	uint16_t	d_data_dur;
    987 	uint16_t	d_plcp_len;
    988 	uint8_t		d_residue;	/* unused octets in time slot */
    989 };
    990 
    991 /* One Time Unit (TU) is 1Kus = 1024 microseconds. */
    992 #define IEEE80211_DUR_TU		1024
    993 
    994 /* IEEE 802.11b durations for DSSS PHY in microseconds */
    995 #define IEEE80211_DUR_DS_LONG_PREAMBLE	144
    996 #define IEEE80211_DUR_DS_SHORT_PREAMBLE	72
    997 
    998 #define IEEE80211_DUR_DS_SLOW_PLCPHDR	48
    999 #define IEEE80211_DUR_DS_FAST_PLCPHDR	24
   1000 #define IEEE80211_DUR_DS_SLOW_ACK	112
   1001 #define IEEE80211_DUR_DS_FAST_ACK	56
   1002 #define IEEE80211_DUR_DS_SLOW_CTS	112
   1003 #define IEEE80211_DUR_DS_FAST_CTS	56
   1004 
   1005 #define IEEE80211_DUR_DS_SLOT		20
   1006 #define IEEE80211_DUR_DS_SIFS		10
   1007 #define IEEE80211_DUR_DS_PIFS	(IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT)
   1008 #define IEEE80211_DUR_DS_DIFS	(IEEE80211_DUR_DS_SIFS + \
   1009 				 2 * IEEE80211_DUR_DS_SLOT)
   1010 #define IEEE80211_DUR_DS_EIFS	(IEEE80211_DUR_DS_SIFS + \
   1011 				 IEEE80211_DUR_DS_SLOW_ACK + \
   1012 				 IEEE80211_DUR_DS_LONG_PREAMBLE + \
   1013 				 IEEE80211_DUR_DS_SLOW_PLCPHDR + \
   1014 				 IEEE80211_DUR_DIFS)
   1015 
   1016 /*
   1017  * Atheros fast-frame encapsulation format.
   1018  * FF max payload:
   1019  * 802.2 + FFHDR + HPAD + 802.3 + 802.2 + 1500 + SPAD + 802.3 + 802.2 + 1500:
   1020  *   8   +   4   +  4   +   14  +   8   + 1500 +  6   +   14  +   8   + 1500
   1021  * = 3066
   1022  */
   1023 /* fast frame header is 32-bits */
   1024 #define	ATH_FF_PROTO	0x0000003f	/* protocol */
   1025 #define	ATH_FF_PROTO_S	0
   1026 #define	ATH_FF_FTYPE	0x000000c0	/* frame type */
   1027 #define	ATH_FF_FTYPE_S	6
   1028 #define	ATH_FF_HLEN32	0x00000300	/* optional hdr length */
   1029 #define	ATH_FF_HLEN32_S	8
   1030 #define	ATH_FF_SEQNUM	0x001ffc00	/* sequence number */
   1031 #define	ATH_FF_SEQNUM_S	10
   1032 #define	ATH_FF_OFFSET	0xffe00000	/* offset to 2nd payload */
   1033 #define	ATH_FF_OFFSET_S	21
   1034 
   1035 #define	ATH_FF_MAX_HDR_PAD	4
   1036 #define	ATH_FF_MAX_SEP_PAD	6
   1037 #define	ATH_FF_MAX_HDR		30
   1038 
   1039 #define	ATH_FF_PROTO_L2TUNNEL	0	/* L2 tunnel protocol */
   1040 #define	ATH_FF_ETH_TYPE		0x88bd	/* Ether type for encapsulated frames */
   1041 #define	ATH_FF_SNAP_ORGCODE_0	0x00
   1042 #define	ATH_FF_SNAP_ORGCODE_1	0x03
   1043 #define	ATH_FF_SNAP_ORGCODE_2	0x7f
   1044 
   1045 #endif /* !_NET80211_IEEE80211_H_ */
   1046