1*01bc90aaSmlelstv /* $NetBSD: ieee80211.h,v 1.28 2016/09/16 09:25:30 mlelstv Exp $ */
240e261aaSdyoung /*-
340e261aaSdyoung * Copyright (c) 2001 Atsushi Onoe
490634029Sdyoung * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
540e261aaSdyoung * All rights reserved.
640e261aaSdyoung *
740e261aaSdyoung * Redistribution and use in source and binary forms, with or without
840e261aaSdyoung * modification, are permitted provided that the following conditions
940e261aaSdyoung * are met:
1040e261aaSdyoung * 1. Redistributions of source code must retain the above copyright
1140e261aaSdyoung * notice, this list of conditions and the following disclaimer.
1240e261aaSdyoung * 2. Redistributions in binary form must reproduce the above copyright
1340e261aaSdyoung * notice, this list of conditions and the following disclaimer in the
1440e261aaSdyoung * documentation and/or other materials provided with the distribution.
1540e261aaSdyoung * 3. The name of the author may not be used to endorse or promote products
1640e261aaSdyoung * derived from this software without specific prior written permission.
1740e261aaSdyoung *
1840e261aaSdyoung * Alternatively, this software may be distributed under the terms of the
1940e261aaSdyoung * GNU General Public License ("GPL") version 2 as published by the Free
2040e261aaSdyoung * Software Foundation.
2140e261aaSdyoung *
2240e261aaSdyoung * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2340e261aaSdyoung * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2440e261aaSdyoung * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2540e261aaSdyoung * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2640e261aaSdyoung * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2740e261aaSdyoung * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2840e261aaSdyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2940e261aaSdyoung * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3040e261aaSdyoung * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3140e261aaSdyoung * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3240e261aaSdyoung *
3387515e34Sskrll * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.10 2005/07/22 16:55:27 sam Exp $
3440e261aaSdyoung */
3540e261aaSdyoung #ifndef _NET80211_IEEE80211_H_
3640e261aaSdyoung #define _NET80211_IEEE80211_H_
3740e261aaSdyoung
3840e261aaSdyoung /*
3940e261aaSdyoung * 802.11 protocol definitions.
4040e261aaSdyoung */
4140e261aaSdyoung
4240e261aaSdyoung #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
4340e261aaSdyoung /* is 802.11 address multicast/broadcast? */
4440e261aaSdyoung #define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01)
4540e261aaSdyoung
4640e261aaSdyoung /* IEEE 802.11 PLCP header */
4740e261aaSdyoung struct ieee80211_plcp_hdr {
4840e261aaSdyoung u_int16_t i_sfd;
4940e261aaSdyoung u_int8_t i_signal;
5040e261aaSdyoung u_int8_t i_service;
5140e261aaSdyoung u_int16_t i_length;
5240e261aaSdyoung u_int16_t i_crc;
5390634029Sdyoung } __packed;
5440e261aaSdyoung
558a3890c6Sdyoung #define IEEE80211_PLCP_SFD 0xF3A0
5690634029Sdyoung #define IEEE80211_PLCP_SERVICE 0x00
578a3890c6Sdyoung
5840e261aaSdyoung /*
5940e261aaSdyoung * generic definitions for IEEE 802.11 frames
6040e261aaSdyoung */
6140e261aaSdyoung struct ieee80211_frame {
6240e261aaSdyoung u_int8_t i_fc[2];
6340e261aaSdyoung u_int8_t i_dur[2];
6440e261aaSdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN];
6540e261aaSdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN];
6640e261aaSdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN];
6740e261aaSdyoung u_int8_t i_seq[2];
6840e261aaSdyoung /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
6940e261aaSdyoung /* see below */
7090634029Sdyoung } __packed;
7140e261aaSdyoung
72bf300177Sdyoung struct ieee80211_qosframe {
73bf300177Sdyoung u_int8_t i_fc[2];
74bf300177Sdyoung u_int8_t i_dur[2];
75bf300177Sdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN];
76bf300177Sdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN];
77bf300177Sdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN];
78bf300177Sdyoung u_int8_t i_seq[2];
79bf300177Sdyoung u_int8_t i_qos[2];
80bf300177Sdyoung /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
81bf300177Sdyoung /* see below */
8290634029Sdyoung } __packed;
83bf300177Sdyoung
845777d86dSchristos struct ieee80211_htframe { /* 11n */
855777d86dSchristos u_int8_t i_fc[2];
865777d86dSchristos u_int8_t i_dur[2];
875777d86dSchristos u_int8_t i_addr1[IEEE80211_ADDR_LEN];
885777d86dSchristos u_int8_t i_addr2[IEEE80211_ADDR_LEN];
895777d86dSchristos u_int8_t i_addr3[IEEE80211_ADDR_LEN];
905777d86dSchristos u_int8_t i_seq[2];
915777d86dSchristos u_int8_t i_qos[2];
925777d86dSchristos u_int8_t i_ht[4];
935777d86dSchristos } __packed;
945777d86dSchristos
95bf300177Sdyoung struct ieee80211_qoscntl {
96bf300177Sdyoung u_int8_t i_qos[2];
97bf300177Sdyoung };
98bf300177Sdyoung
9940e261aaSdyoung struct ieee80211_frame_addr4 {
10040e261aaSdyoung u_int8_t i_fc[2];
10140e261aaSdyoung u_int8_t i_dur[2];
10240e261aaSdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN];
10340e261aaSdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN];
10440e261aaSdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN];
10540e261aaSdyoung u_int8_t i_seq[2];
10640e261aaSdyoung u_int8_t i_addr4[IEEE80211_ADDR_LEN];
10790634029Sdyoung } __packed;
10840e261aaSdyoung
109bf300177Sdyoung
110bf300177Sdyoung struct ieee80211_qosframe_addr4 {
111bf300177Sdyoung u_int8_t i_fc[2];
112bf300177Sdyoung u_int8_t i_dur[2];
113bf300177Sdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN];
114bf300177Sdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN];
115bf300177Sdyoung u_int8_t i_addr3[IEEE80211_ADDR_LEN];
116bf300177Sdyoung u_int8_t i_seq[2];
117bf300177Sdyoung u_int8_t i_addr4[IEEE80211_ADDR_LEN];
118bf300177Sdyoung u_int8_t i_qos[2];
11990634029Sdyoung } __packed;
120bf300177Sdyoung
12140e261aaSdyoung #define IEEE80211_FC0_VERSION_MASK 0x03
12240e261aaSdyoung #define IEEE80211_FC0_VERSION_SHIFT 0
12340e261aaSdyoung #define IEEE80211_FC0_VERSION_0 0x00
12440e261aaSdyoung #define IEEE80211_FC0_TYPE_MASK 0x0c
12540e261aaSdyoung #define IEEE80211_FC0_TYPE_SHIFT 2
12640e261aaSdyoung #define IEEE80211_FC0_TYPE_MGT 0x00
12740e261aaSdyoung #define IEEE80211_FC0_TYPE_CTL 0x04
12840e261aaSdyoung #define IEEE80211_FC0_TYPE_DATA 0x08
12940e261aaSdyoung
13040e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_MASK 0xf0
13140e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_SHIFT 4
13240e261aaSdyoung /* for TYPE_MGT */
13340e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
13440e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
13540e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
13640e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
13740e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
13840e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
13940e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_BEACON 0x80
14040e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ATIM 0x90
14140e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
14240e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
14340e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
14440e261aaSdyoung /* for TYPE_CTL */
14540e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
14640e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_RTS 0xb0
14740e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CTS 0xc0
14840e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_ACK 0xd0
14940e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
15040e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
15140e261aaSdyoung /* for TYPE_DATA (bit combination) */
15240e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_DATA 0x00
15340e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
15440e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
15540e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
15640e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_NODATA 0x40
15740e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CFACK 0x50
15840e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60
15940e261aaSdyoung #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
160bf300177Sdyoung #define IEEE80211_FC0_SUBTYPE_QOS 0x80
16190634029Sdyoung #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0
16240e261aaSdyoung
1632bc1a71dSchristos /*
1642bc1a71dSchristos * DS bit usage
1652bc1a71dSchristos *
1662bc1a71dSchristos * TA = transmitter address
1672bc1a71dSchristos * RA = receiver address
1682bc1a71dSchristos * DA = destination address
1692bc1a71dSchristos * SA = source address
1702bc1a71dSchristos *
1712bc1a71dSchristos * ToDS FromDS A1(RA) A2(TA) A3 A4 Use
1722bc1a71dSchristos * -----------------------------------------------------------------
1732bc1a71dSchristos * 0 0 DA SA BSSID - IBSS/DLS
1742bc1a71dSchristos * 0 1 DA BSSID SA - AP -> STA
1752bc1a71dSchristos * 1 0 BSSID SA DA - AP <- STA
1762bc1a71dSchristos * 1 1 RA TA DA SA unspecified (WDS)
1772bc1a71dSchristos */
17840e261aaSdyoung #define IEEE80211_FC1_DIR_MASK 0x03
17940e261aaSdyoung #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
18040e261aaSdyoung #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
18140e261aaSdyoung #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
18240e261aaSdyoung #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
18340e261aaSdyoung
184*01bc90aaSmlelstv #define IEEE80211_IS_DSTODS(wh) \
185*01bc90aaSmlelstv (((wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS)
186*01bc90aaSmlelstv
18740e261aaSdyoung #define IEEE80211_FC1_MORE_FRAG 0x04
18840e261aaSdyoung #define IEEE80211_FC1_RETRY 0x08
18940e261aaSdyoung #define IEEE80211_FC1_PWR_MGT 0x10
19040e261aaSdyoung #define IEEE80211_FC1_MORE_DATA 0x20
19192607a7bSchristos #define IEEE80211_FC1_PROTECTED 0x40
19292607a7bSchristos #define IEEE80211_FC1_WEP 0x40 /* pre-RSNA compat */
19340e261aaSdyoung #define IEEE80211_FC1_ORDER 0x80
19440e261aaSdyoung
19540e261aaSdyoung #define IEEE80211_SEQ_FRAG_MASK 0x000f
19640e261aaSdyoung #define IEEE80211_SEQ_FRAG_SHIFT 0
19740e261aaSdyoung #define IEEE80211_SEQ_SEQ_MASK 0xfff0
19840e261aaSdyoung #define IEEE80211_SEQ_SEQ_SHIFT 4
19940e261aaSdyoung
20040e261aaSdyoung #define IEEE80211_NWID_LEN 32
20140e261aaSdyoung
202c8c3c949Schristos /*
203c8c3c949Schristos * QoS Control field (see 7.1.3.5).
204c8c3c949Schristos */
205bf300177Sdyoung /* bit 8 is reserved */
206c8c3c949Schristos #define IEEE80211_QOS_TXOP 0xff00
207c8c3c949Schristos #define IEEE80211_QOS_AMSDU 0x0080 /* 11n */
208c8c3c949Schristos #define IEEE80211_QOS_ACKPOLICY_NORMAL 0x0000
209c8c3c949Schristos #define IEEE80211_QOS_ACKPOLICY_NOACK 0x0020
210c8c3c949Schristos #define IEEE80211_QOS_ACKPOLICY_NOEXPLACK 0x0040
211c8c3c949Schristos #define IEEE80211_QOS_ACKPOLICY 0x0060
21290634029Sdyoung #define IEEE80211_QOS_ACKPOLICY_S 5
213c8c3c949Schristos #define IEEE80211_QOS_ACKPOLICY_MASK 0x0060
214c8c3c949Schristos #define IEEE80211_QOS_ACKPOLICY_BA 0x0060
215c8c3c949Schristos #define IEEE80211_QOS_ESOP 0x0010
21690634029Sdyoung #define IEEE80211_QOS_ESOP_S 4
217c8c3c949Schristos #define IEEE80211_QOS_TID 0x000f
21890634029Sdyoung
219*01bc90aaSmlelstv /* does frame have QoS sequence control data */
220*01bc90aaSmlelstv #define IEEE80211_QOS_HAS_SEQ(wh) \
221*01bc90aaSmlelstv (((wh)->i_fc[0] & \
222*01bc90aaSmlelstv (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \
223*01bc90aaSmlelstv (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
224*01bc90aaSmlelstv
22540e261aaSdyoung /*
226de64f03aSmycroft * WME/802.11e information element.
227de64f03aSmycroft */
22890634029Sdyoung struct ieee80211_wme_info {
229de64f03aSmycroft u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */
230de64f03aSmycroft u_int8_t wme_len; /* length in bytes */
231de64f03aSmycroft u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */
232de64f03aSmycroft u_int8_t wme_type; /* OUI type */
233de64f03aSmycroft u_int8_t wme_subtype; /* OUI subtype */
234de64f03aSmycroft u_int8_t wme_version; /* spec revision */
23590634029Sdyoung u_int8_t wme_info; /* QoS info */
23690634029Sdyoung } __packed;
237de64f03aSmycroft
238de64f03aSmycroft /*
239de64f03aSmycroft * WME/802.11e Tspec Element
240de64f03aSmycroft */
241de64f03aSmycroft struct ieee80211_wme_tspec {
242de64f03aSmycroft u_int8_t ts_id;
243de64f03aSmycroft u_int8_t ts_len;
244de64f03aSmycroft u_int8_t ts_oui[3];
245de64f03aSmycroft u_int8_t ts_oui_type;
246de64f03aSmycroft u_int8_t ts_oui_subtype;
247de64f03aSmycroft u_int8_t ts_version;
248de64f03aSmycroft u_int8_t ts_tsinfo[3];
249de64f03aSmycroft u_int8_t ts_nom_msdu[2];
250de64f03aSmycroft u_int8_t ts_max_msdu[2];
251de64f03aSmycroft u_int8_t ts_min_svc[4];
252de64f03aSmycroft u_int8_t ts_max_svc[4];
253de64f03aSmycroft u_int8_t ts_inactv_intv[4];
254de64f03aSmycroft u_int8_t ts_susp_intv[4];
255de64f03aSmycroft u_int8_t ts_start_svc[4];
256de64f03aSmycroft u_int8_t ts_min_rate[4];
257de64f03aSmycroft u_int8_t ts_mean_rate[4];
258de64f03aSmycroft u_int8_t ts_max_burst[4];
259de64f03aSmycroft u_int8_t ts_min_phy[4];
260de64f03aSmycroft u_int8_t ts_peak_rate[4];
261de64f03aSmycroft u_int8_t ts_delay[4];
262de64f03aSmycroft u_int8_t ts_surplus[2];
263de64f03aSmycroft u_int8_t ts_medium_time[2];
26490634029Sdyoung } __packed;
26590634029Sdyoung
26690634029Sdyoung /*
26790634029Sdyoung * WME AC parameter field
26890634029Sdyoung */
26990634029Sdyoung struct ieee80211_wme_acparams {
27090634029Sdyoung u_int8_t acp_aci_aifsn;
27190634029Sdyoung u_int8_t acp_logcwminmax;
27290634029Sdyoung u_int16_t acp_txop;
27390634029Sdyoung } __packed;
27490634029Sdyoung
275f6af2e00Schristos /* WME stream classes */
276f6af2e00Schristos enum ieee80211_wme_ac {
277f6af2e00Schristos WME_AC_BE = 0, /* best effort */
278f6af2e00Schristos WME_AC_BK = 1, /* background */
279f6af2e00Schristos WME_AC_VI = 2, /* video */
280f6af2e00Schristos WME_AC_VO = 3, /* voice */
281f6af2e00Schristos };
28290634029Sdyoung #define WME_NUM_AC 4 /* 4 AC categories */
28390634029Sdyoung
28490634029Sdyoung #define WME_PARAM_ACI 0x60 /* Mask for ACI field */
28590634029Sdyoung #define WME_PARAM_ACI_S 5 /* Shift for ACI field */
28690634029Sdyoung #define WME_PARAM_ACM 0x10 /* Mask for ACM bit */
28790634029Sdyoung #define WME_PARAM_ACM_S 4 /* Shift for ACM bit */
28890634029Sdyoung #define WME_PARAM_AIFSN 0x0f /* Mask for aifsn field */
28990634029Sdyoung #define WME_PARAM_AIFSN_S 0 /* Shift for aifsn field */
29090634029Sdyoung #define WME_PARAM_LOGCWMIN 0x0f /* Mask for CwMin field (in log) */
29190634029Sdyoung #define WME_PARAM_LOGCWMIN_S 0 /* Shift for CwMin field */
29290634029Sdyoung #define WME_PARAM_LOGCWMAX 0xf0 /* Mask for CwMax field (in log) */
29390634029Sdyoung #define WME_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */
29490634029Sdyoung
29590634029Sdyoung #define WME_AC_TO_TID(_ac) ( \
29690634029Sdyoung ((_ac) == WME_AC_VO) ? 6 : \
29790634029Sdyoung ((_ac) == WME_AC_VI) ? 5 : \
29890634029Sdyoung ((_ac) == WME_AC_BK) ? 1 : \
29990634029Sdyoung 0)
30090634029Sdyoung
30190634029Sdyoung #define TID_TO_WME_AC(_tid) ( \
30290634029Sdyoung ((_tid) < 1) ? WME_AC_BE : \
30390634029Sdyoung ((_tid) < 3) ? WME_AC_BK : \
30490634029Sdyoung ((_tid) < 6) ? WME_AC_VI : \
30590634029Sdyoung WME_AC_VO)
30690634029Sdyoung
30790634029Sdyoung /*
30890634029Sdyoung * WME Parameter Element
30990634029Sdyoung */
31090634029Sdyoung struct ieee80211_wme_param {
31190634029Sdyoung u_int8_t param_id;
31290634029Sdyoung u_int8_t param_len;
31390634029Sdyoung u_int8_t param_oui[3];
31490634029Sdyoung u_int8_t param_oui_type;
31590634029Sdyoung u_int8_t param_oui_sybtype;
31690634029Sdyoung u_int8_t param_version;
31790634029Sdyoung u_int8_t param_qosInfo;
31890634029Sdyoung #define WME_QOSINFO_COUNT 0x0f /* Mask for param count field */
31990634029Sdyoung u_int8_t param_reserved;
32090634029Sdyoung struct ieee80211_wme_acparams params_acParams[WME_NUM_AC];
32190634029Sdyoung } __packed;
322de64f03aSmycroft
323de64f03aSmycroft /*
324de64f03aSmycroft * Management Notification Frame
325de64f03aSmycroft */
326de64f03aSmycroft struct ieee80211_mnf {
327de64f03aSmycroft u_int8_t mnf_category;
328de64f03aSmycroft u_int8_t mnf_action;
329de64f03aSmycroft u_int8_t mnf_dialog;
330de64f03aSmycroft u_int8_t mnf_status;
33190634029Sdyoung } __packed;
332de64f03aSmycroft #define MNF_SETUP_REQ 0
333de64f03aSmycroft #define MNF_SETUP_RESP 1
334de64f03aSmycroft #define MNF_TEARDOWN 2
335de64f03aSmycroft
336de64f03aSmycroft /*
3379280f4b4Sdyoung * Control frames.
3389280f4b4Sdyoung */
3399280f4b4Sdyoung struct ieee80211_frame_min {
3409280f4b4Sdyoung u_int8_t i_fc[2];
3419280f4b4Sdyoung u_int8_t i_dur[2];
3429280f4b4Sdyoung u_int8_t i_addr1[IEEE80211_ADDR_LEN];
3439280f4b4Sdyoung u_int8_t i_addr2[IEEE80211_ADDR_LEN];
3449280f4b4Sdyoung /* FCS */
34590634029Sdyoung } __packed;
3469280f4b4Sdyoung
3479280f4b4Sdyoung struct ieee80211_frame_rts {
3489280f4b4Sdyoung u_int8_t i_fc[2];
3499280f4b4Sdyoung u_int8_t i_dur[2];
3509280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN];
3519280f4b4Sdyoung u_int8_t i_ta[IEEE80211_ADDR_LEN];
3529280f4b4Sdyoung /* FCS */
35390634029Sdyoung } __packed;
3549280f4b4Sdyoung
3559280f4b4Sdyoung struct ieee80211_frame_cts {
3569280f4b4Sdyoung u_int8_t i_fc[2];
3579280f4b4Sdyoung u_int8_t i_dur[2];
3589280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN];
3599280f4b4Sdyoung /* FCS */
36090634029Sdyoung } __packed;
3619280f4b4Sdyoung
3629280f4b4Sdyoung struct ieee80211_frame_ack {
3639280f4b4Sdyoung u_int8_t i_fc[2];
3649280f4b4Sdyoung u_int8_t i_dur[2];
3659280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN];
3669280f4b4Sdyoung /* FCS */
36790634029Sdyoung } __packed;
3689280f4b4Sdyoung
3699280f4b4Sdyoung struct ieee80211_frame_pspoll {
3709280f4b4Sdyoung u_int8_t i_fc[2];
3719280f4b4Sdyoung u_int8_t i_aid[2];
3729280f4b4Sdyoung u_int8_t i_bssid[IEEE80211_ADDR_LEN];
3739280f4b4Sdyoung u_int8_t i_ta[IEEE80211_ADDR_LEN];
3749280f4b4Sdyoung /* FCS */
37590634029Sdyoung } __packed;
3769280f4b4Sdyoung
3779280f4b4Sdyoung struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */
3789280f4b4Sdyoung u_int8_t i_fc[2];
3799280f4b4Sdyoung u_int8_t i_dur[2]; /* should be zero */
3809280f4b4Sdyoung u_int8_t i_ra[IEEE80211_ADDR_LEN];
3819280f4b4Sdyoung u_int8_t i_bssid[IEEE80211_ADDR_LEN];
3829280f4b4Sdyoung /* FCS */
38390634029Sdyoung } __packed;
3849280f4b4Sdyoung
3852bc1a71dSchristos static __inline int
ieee80211_has_seq(const struct ieee80211_frame * wh)3862bc1a71dSchristos ieee80211_has_seq(const struct ieee80211_frame *wh)
3872bc1a71dSchristos {
3882bc1a71dSchristos return (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
3892bc1a71dSchristos IEEE80211_FC0_TYPE_CTL;
3902bc1a71dSchristos }
3912bc1a71dSchristos
3922bc1a71dSchristos static __inline int
ieee80211_has_addr4(const struct ieee80211_frame * wh)3932bc1a71dSchristos ieee80211_has_addr4(const struct ieee80211_frame *wh)
3942bc1a71dSchristos {
3952bc1a71dSchristos return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) ==
3962bc1a71dSchristos IEEE80211_FC1_DIR_DSTODS;
3972bc1a71dSchristos }
3982bc1a71dSchristos
3992bc1a71dSchristos static __inline int
ieee80211_has_qos(const struct ieee80211_frame * wh)4002bc1a71dSchristos ieee80211_has_qos(const struct ieee80211_frame *wh)
4012bc1a71dSchristos {
4022bc1a71dSchristos return (wh->i_fc[0] &
4032bc1a71dSchristos (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) ==
4042bc1a71dSchristos (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS);
4052bc1a71dSchristos }
4062bc1a71dSchristos
4072bc1a71dSchristos static __inline int
ieee80211_has_htc(const struct ieee80211_frame * wh)4082bc1a71dSchristos ieee80211_has_htc(const struct ieee80211_frame *wh)
4092bc1a71dSchristos {
4102bc1a71dSchristos return (wh->i_fc[1] & IEEE80211_FC1_ORDER) &&
4112bc1a71dSchristos (ieee80211_has_qos(wh) ||
4122bc1a71dSchristos (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
4132bc1a71dSchristos IEEE80211_FC0_TYPE_MGT);
4142bc1a71dSchristos }
4152bc1a71dSchristos
4162bc1a71dSchristos static __inline u_int16_t
ieee80211_get_qos(const struct ieee80211_frame * wh)4172bc1a71dSchristos ieee80211_get_qos(const struct ieee80211_frame *wh)
4182bc1a71dSchristos {
4192bc1a71dSchristos const u_int8_t *frm;
4202bc1a71dSchristos
4212bc1a71dSchristos if (ieee80211_has_addr4(wh))
4222bc1a71dSchristos frm = ((const struct ieee80211_qosframe_addr4 *)wh)->i_qos;
4232bc1a71dSchristos else
4242bc1a71dSchristos frm = ((const struct ieee80211_qosframe *)wh)->i_qos;
4252bc1a71dSchristos
4262bc1a71dSchristos return le16toh(*(const u_int16_t *)frm);
4272bc1a71dSchristos }
4282bc1a71dSchristos
4299280f4b4Sdyoung /*
43040e261aaSdyoung * BEACON management packets
43140e261aaSdyoung *
43240e261aaSdyoung * octet timestamp[8]
43340e261aaSdyoung * octet beacon interval[2]
43440e261aaSdyoung * octet capability information[2]
43540e261aaSdyoung * information element
43640e261aaSdyoung * octet elemid
43740e261aaSdyoung * octet length
43840e261aaSdyoung * octet information[length]
43940e261aaSdyoung */
44040e261aaSdyoung
441de64f03aSmycroft typedef u_int8_t *ieee80211_mgt_beacon_t;
44240e261aaSdyoung
44340e261aaSdyoung #define IEEE80211_BEACON_INTERVAL(beacon) \
44440e261aaSdyoung ((beacon)[8] | ((beacon)[9] << 8))
44540e261aaSdyoung #define IEEE80211_BEACON_CAPABILITY(beacon) \
44640e261aaSdyoung ((beacon)[10] | ((beacon)[11] << 8))
44740e261aaSdyoung
44840e261aaSdyoung #define IEEE80211_CAPINFO_ESS 0x0001
44940e261aaSdyoung #define IEEE80211_CAPINFO_IBSS 0x0002
45040e261aaSdyoung #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004
45140e261aaSdyoung #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008
45240e261aaSdyoung #define IEEE80211_CAPINFO_PRIVACY 0x0010
45340e261aaSdyoung #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020
45440e261aaSdyoung #define IEEE80211_CAPINFO_PBCC 0x0040
45540e261aaSdyoung #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080
45640e261aaSdyoung /* bits 8-9 are reserved */
45740e261aaSdyoung #define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400
458bf300177Sdyoung #define IEEE80211_CAPINFO_RSN 0x0800
459bf300177Sdyoung /* bit 12 is reserved */
46040e261aaSdyoung #define IEEE80211_CAPINFO_DSSSOFDM 0x2000
46140e261aaSdyoung /* bits 14-15 are reserved */
46240e261aaSdyoung
46340e261aaSdyoung /*
464bf300177Sdyoung * 802.11i/WPA information element (maximally sized).
465bf300177Sdyoung */
466bf300177Sdyoung struct ieee80211_ie_wpa {
467de64f03aSmycroft u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */
468de64f03aSmycroft u_int8_t wpa_len; /* length in bytes */
469bf300177Sdyoung u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */
470bf300177Sdyoung u_int8_t wpa_type; /* OUI type */
471bf300177Sdyoung u_int16_t wpa_version; /* spec revision */
472bf300177Sdyoung u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */
473bf300177Sdyoung u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */
474bf300177Sdyoung u_int32_t wpa_uciphers[8];/* ciphers */
475bf300177Sdyoung u_int16_t wpa_authselcnt; /* authentication selector cnt*/
476bf300177Sdyoung u_int32_t wpa_authsels[8];/* selectors */
477de64f03aSmycroft u_int16_t wpa_caps; /* 802.11i capabilities */
478de64f03aSmycroft u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */
479de64f03aSmycroft u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */
48090634029Sdyoung } __packed;
481bf300177Sdyoung
482bf300177Sdyoung /*
48390634029Sdyoung * Management information element payloads.
48440e261aaSdyoung */
48540e261aaSdyoung
48640e261aaSdyoung enum {
48740e261aaSdyoung IEEE80211_ELEMID_SSID = 0,
48840e261aaSdyoung IEEE80211_ELEMID_RATES = 1,
48940e261aaSdyoung IEEE80211_ELEMID_FHPARMS = 2,
49040e261aaSdyoung IEEE80211_ELEMID_DSPARMS = 3,
49140e261aaSdyoung IEEE80211_ELEMID_CFPARMS = 4,
49240e261aaSdyoung IEEE80211_ELEMID_TIM = 5,
49340e261aaSdyoung IEEE80211_ELEMID_IBSSPARMS = 6,
49440e261aaSdyoung IEEE80211_ELEMID_COUNTRY = 7,
49592607a7bSchristos IEEE80211_ELEMID_EDCAPARMS = 12,
49640e261aaSdyoung IEEE80211_ELEMID_CHALLENGE = 16,
497bf300177Sdyoung /* 17-31 reserved for challenge text extension */
4989fe6472fSdegroote IEEE80211_ELEMID_PWRCNSTR = 32,
4999fe6472fSdegroote IEEE80211_ELEMID_PWRCAP = 33,
5009fe6472fSdegroote IEEE80211_ELEMID_TPCREQ = 34,
5019fe6472fSdegroote IEEE80211_ELEMID_TPCREP = 35,
5029fe6472fSdegroote IEEE80211_ELEMID_SUPPCHAN = 36,
5039fe6472fSdegroote IEEE80211_ELEMID_CHANSWITCHANN = 37,
5049fe6472fSdegroote IEEE80211_ELEMID_MEASREQ = 38,
5059fe6472fSdegroote IEEE80211_ELEMID_MEASREP = 39,
5069fe6472fSdegroote IEEE80211_ELEMID_QUIET = 40,
5079fe6472fSdegroote IEEE80211_ELEMID_IBSSDFS = 41,
50840e261aaSdyoung IEEE80211_ELEMID_ERP = 42,
50992607a7bSchristos IEEE80211_ELEMID_HTCAP = 45, /* 11n */
51092607a7bSchristos IEEE80211_ELEMID_QOS_CAP = 46,
511de64f03aSmycroft IEEE80211_ELEMID_RSN = 48,
51240e261aaSdyoung IEEE80211_ELEMID_XRATES = 50,
51392607a7bSchristos IEEE80211_ELEMID_TIE = 56, /* 11r */
51492607a7bSchristos IEEE80211_ELEMID_HTINFO = 61, /* 11n */
51592607a7bSchristos IEEE80211_ELEMID_MMIE = 76, /* 11w */
516bf300177Sdyoung IEEE80211_ELEMID_TPC = 150,
517bf300177Sdyoung IEEE80211_ELEMID_CCKM = 156,
518eda454c1Schristos IEEE80211_ELEMID_VENDOR = 221 /* vendor private */
51940e261aaSdyoung };
52040e261aaSdyoung
52190634029Sdyoung struct ieee80211_tim_ie {
52290634029Sdyoung u_int8_t tim_ie; /* IEEE80211_ELEMID_TIM */
52390634029Sdyoung u_int8_t tim_len;
52490634029Sdyoung u_int8_t tim_count; /* DTIM count */
52590634029Sdyoung u_int8_t tim_period; /* DTIM period */
52690634029Sdyoung u_int8_t tim_bitctl; /* bitmap control */
52790634029Sdyoung u_int8_t tim_bitmap[1]; /* variable-length bitmap */
52890634029Sdyoung } __packed;
52990634029Sdyoung
5300ea2ddfdSdyoung struct ieee80211_band {
5310ea2ddfdSdyoung u_int8_t schan; /* starting channel */
5320ea2ddfdSdyoung u_int8_t nchan; /* number channels */
5330ea2ddfdSdyoung u_int8_t maxtxpwr; /* tx power cap */
5340ea2ddfdSdyoung } __packed;
5350ea2ddfdSdyoung
53690634029Sdyoung struct ieee80211_country_ie {
53790634029Sdyoung u_int8_t ie; /* IEEE80211_ELEMID_COUNTRY */
53890634029Sdyoung u_int8_t len;
53990634029Sdyoung u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */
5400ea2ddfdSdyoung struct ieee80211_band band[4]; /* up to 4 sub bands */
54190634029Sdyoung } __packed;
54290634029Sdyoung
543db0e43b2Sdyoung #define IEEE80211_CHALLENGE_LEN 128
544db0e43b2Sdyoung
54540e261aaSdyoung #define IEEE80211_RATE_BASIC 0x80
54640e261aaSdyoung #define IEEE80211_RATE_VAL 0x7f
54740e261aaSdyoung
54840e261aaSdyoung /* EPR information element flags */
54940e261aaSdyoung #define IEEE80211_ERP_NON_ERP_PRESENT 0x01
55040e261aaSdyoung #define IEEE80211_ERP_USE_PROTECTION 0x02
551de64f03aSmycroft #define IEEE80211_ERP_LONG_PREAMBLE 0x04
55240e261aaSdyoung
553bf300177Sdyoung /* Atheros private advanced capabilities info */
554bf300177Sdyoung #define ATHEROS_CAP_TURBO_PRIME 0x01
555bf300177Sdyoung #define ATHEROS_CAP_COMPRESSION 0x02
556bf300177Sdyoung #define ATHEROS_CAP_FAST_FRAME 0x04
557bf300177Sdyoung /* bits 3-6 reserved */
558bf300177Sdyoung #define ATHEROS_CAP_BOOST 0x80
559bf300177Sdyoung
560bf300177Sdyoung #define ATH_OUI 0x7f0300 /* Atheros OUI */
561bf300177Sdyoung #define ATH_OUI_TYPE 0x01
562bf300177Sdyoung #define ATH_OUI_VERSION 0x01
563bf300177Sdyoung
564bf300177Sdyoung #define WPA_OUI 0xf25000
565bf300177Sdyoung #define WPA_OUI_TYPE 0x01
566de64f03aSmycroft #define WPA_VERSION 1 /* current supported version */
567bf300177Sdyoung
568bf300177Sdyoung #define WPA_CSE_NULL 0x00
569bf300177Sdyoung #define WPA_CSE_WEP40 0x01
570bf300177Sdyoung #define WPA_CSE_TKIP 0x02
571bf300177Sdyoung #define WPA_CSE_CCMP 0x04
572bf300177Sdyoung #define WPA_CSE_WEP104 0x05
573bf300177Sdyoung
574bf300177Sdyoung #define WPA_ASE_NONE 0x00
575bf300177Sdyoung #define WPA_ASE_8021X_UNSPEC 0x01
576bf300177Sdyoung #define WPA_ASE_8021X_PSK 0x02
577bf300177Sdyoung
578de64f03aSmycroft #define RSN_OUI 0xac0f00
579de64f03aSmycroft #define RSN_VERSION 1 /* current supported version */
580de64f03aSmycroft
581de64f03aSmycroft #define RSN_CSE_NULL 0x00
582de64f03aSmycroft #define RSN_CSE_WEP40 0x01
583de64f03aSmycroft #define RSN_CSE_TKIP 0x02
584de64f03aSmycroft #define RSN_CSE_WRAP 0x03
585de64f03aSmycroft #define RSN_CSE_CCMP 0x04
586de64f03aSmycroft #define RSN_CSE_WEP104 0x05
587de64f03aSmycroft
588de64f03aSmycroft #define RSN_ASE_NONE 0x00
589de64f03aSmycroft #define RSN_ASE_8021X_UNSPEC 0x01
590de64f03aSmycroft #define RSN_ASE_8021X_PSK 0x02
591de64f03aSmycroft
59290634029Sdyoung #define RSN_CAP_PREAUTH 0x01
59390634029Sdyoung
594de64f03aSmycroft #define WME_OUI 0xf25000
595de64f03aSmycroft #define WME_OUI_TYPE 0x02
59690634029Sdyoung #define WME_INFO_OUI_SUBTYPE 0x00
59790634029Sdyoung #define WME_PARAM_OUI_SUBTYPE 0x01
598de64f03aSmycroft #define WME_VERSION 1
599de64f03aSmycroft
60040e261aaSdyoung /*
60140e261aaSdyoung * AUTH management packets
60240e261aaSdyoung *
60340e261aaSdyoung * octet algo[2]
60440e261aaSdyoung * octet seq[2]
60540e261aaSdyoung * octet status[2]
60640e261aaSdyoung * octet chal.id
60740e261aaSdyoung * octet chal.length
60840e261aaSdyoung * octet chal.text[253]
60940e261aaSdyoung */
61040e261aaSdyoung
61140e261aaSdyoung typedef u_int8_t *ieee80211_mgt_auth_t;
61240e261aaSdyoung
61340e261aaSdyoung #define IEEE80211_AUTH_ALGORITHM(auth) \
61440e261aaSdyoung ((auth)[0] | ((auth)[1] << 8))
61540e261aaSdyoung #define IEEE80211_AUTH_TRANSACTION(auth) \
61640e261aaSdyoung ((auth)[2] | ((auth)[3] << 8))
61740e261aaSdyoung #define IEEE80211_AUTH_STATUS(auth) \
61840e261aaSdyoung ((auth)[4] | ((auth)[5] << 8))
61940e261aaSdyoung
62040e261aaSdyoung #define IEEE80211_AUTH_ALG_OPEN 0x0000
62140e261aaSdyoung #define IEEE80211_AUTH_ALG_SHARED 0x0001
622bf300177Sdyoung #define IEEE80211_AUTH_ALG_LEAP 0x0080
62340e261aaSdyoung
62440e261aaSdyoung enum {
62540e261aaSdyoung IEEE80211_AUTH_OPEN_REQUEST = 1,
626eda454c1Schristos IEEE80211_AUTH_OPEN_RESPONSE = 2
62740e261aaSdyoung };
62840e261aaSdyoung
62940e261aaSdyoung enum {
63040e261aaSdyoung IEEE80211_AUTH_SHARED_REQUEST = 1,
63140e261aaSdyoung IEEE80211_AUTH_SHARED_CHALLENGE = 2,
63240e261aaSdyoung IEEE80211_AUTH_SHARED_RESPONSE = 3,
633eda454c1Schristos IEEE80211_AUTH_SHARED_PASS = 4
63440e261aaSdyoung };
63540e261aaSdyoung
63640e261aaSdyoung /*
63740e261aaSdyoung * Reason codes
63840e261aaSdyoung *
63940e261aaSdyoung * Unlisted codes are reserved
64040e261aaSdyoung */
64140e261aaSdyoung
64240e261aaSdyoung enum {
64340e261aaSdyoung IEEE80211_REASON_UNSPECIFIED = 1,
64440e261aaSdyoung IEEE80211_REASON_AUTH_EXPIRE = 2,
64540e261aaSdyoung IEEE80211_REASON_AUTH_LEAVE = 3,
64640e261aaSdyoung IEEE80211_REASON_ASSOC_EXPIRE = 4,
64740e261aaSdyoung IEEE80211_REASON_ASSOC_TOOMANY = 5,
64840e261aaSdyoung IEEE80211_REASON_NOT_AUTHED = 6,
64940e261aaSdyoung IEEE80211_REASON_NOT_ASSOCED = 7,
65040e261aaSdyoung IEEE80211_REASON_ASSOC_LEAVE = 8,
65140e261aaSdyoung IEEE80211_REASON_ASSOC_NOT_AUTHED = 9,
65240e261aaSdyoung
653bf300177Sdyoung IEEE80211_REASON_RSN_REQUIRED = 11,
654bf300177Sdyoung IEEE80211_REASON_RSN_INCONSISTENT = 12,
655bf300177Sdyoung IEEE80211_REASON_IE_INVALID = 13,
656bf300177Sdyoung IEEE80211_REASON_MIC_FAILURE = 14,
657bf300177Sdyoung
65840e261aaSdyoung IEEE80211_STATUS_SUCCESS = 0,
65940e261aaSdyoung IEEE80211_STATUS_UNSPECIFIED = 1,
66040e261aaSdyoung IEEE80211_STATUS_CAPINFO = 10,
66140e261aaSdyoung IEEE80211_STATUS_NOT_ASSOCED = 11,
66240e261aaSdyoung IEEE80211_STATUS_OTHER = 12,
66340e261aaSdyoung IEEE80211_STATUS_ALG = 13,
66440e261aaSdyoung IEEE80211_STATUS_SEQUENCE = 14,
66540e261aaSdyoung IEEE80211_STATUS_CHALLENGE = 15,
66640e261aaSdyoung IEEE80211_STATUS_TIMEOUT = 16,
66740e261aaSdyoung IEEE80211_STATUS_TOOMANY = 17,
66840e261aaSdyoung IEEE80211_STATUS_BASIC_RATE = 18,
66940e261aaSdyoung IEEE80211_STATUS_SP_REQUIRED = 19,
67040e261aaSdyoung IEEE80211_STATUS_PBCC_REQUIRED = 20,
67140e261aaSdyoung IEEE80211_STATUS_CA_REQUIRED = 21,
67240e261aaSdyoung IEEE80211_STATUS_TOO_MANY_STATIONS = 22,
67340e261aaSdyoung IEEE80211_STATUS_RATES = 23,
67440e261aaSdyoung IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25,
675eda454c1Schristos IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26
67640e261aaSdyoung };
67740e261aaSdyoung
67840e261aaSdyoung #define IEEE80211_WEP_KEYLEN 5 /* 40bit */
67940e261aaSdyoung #define IEEE80211_WEP_IVLEN 3 /* 24bit */
68040e261aaSdyoung #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */
68140e261aaSdyoung #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */
68281eefc6fSdyoung #define IEEE80211_WEP_TOTLEN (IEEE80211_WEP_IVLEN + \
68381eefc6fSdyoung IEEE80211_WEP_KIDLEN + \
68481eefc6fSdyoung IEEE80211_WEP_CRCLEN)
68590634029Sdyoung #define IEEE80211_WEP_NKID 4 /* number of key ids */
68690634029Sdyoung
687de64f03aSmycroft /*
688de64f03aSmycroft * 802.11i defines an extended IV for use with non-WEP ciphers.
689de64f03aSmycroft * When the EXTIV bit is set in the key id byte an additional
690de64f03aSmycroft * 4 bytes immediately follow the IV for TKIP. For CCMP the
691de64f03aSmycroft * EXTIV bit is likewise set but the 8 bytes represent the
692de64f03aSmycroft * CCMP header rather than IV+extended-IV.
693de64f03aSmycroft */
694de64f03aSmycroft #define IEEE80211_WEP_EXTIV 0x20
695de64f03aSmycroft #define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */
696de64f03aSmycroft #define IEEE80211_WEP_MICLEN 8 /* trailing MIC */
697de64f03aSmycroft
69840e261aaSdyoung #define IEEE80211_CRC_LEN 4
69940e261aaSdyoung
700bf300177Sdyoung /*
701bf300177Sdyoung * Maximum acceptable MTU is:
702bf300177Sdyoung * IEEE80211_MAX_LEN - WEP overhead - CRC -
703bf300177Sdyoung * QoS overhead - RSN/WPA overhead
704bf300177Sdyoung * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default
705bf300177Sdyoung * mtu is Ethernet-compatible; it's set by ether_ifattach.
706bf300177Sdyoung */
707bf300177Sdyoung #define IEEE80211_MTU_MAX 2290
708bf300177Sdyoung #define IEEE80211_MTU_MIN 32
709bf300177Sdyoung
71040e261aaSdyoung #define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \
71140e261aaSdyoung (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
712de64f03aSmycroft #define IEEE80211_ACK_LEN \
713de64f03aSmycroft (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
7149280f4b4Sdyoung #define IEEE80211_MIN_LEN \
7159280f4b4Sdyoung (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
71640e261aaSdyoung
717de64f03aSmycroft /*
718de64f03aSmycroft * The 802.11 spec says at most 2007 stations may be
719de64f03aSmycroft * associated at once. For most AP's this is way more
720de64f03aSmycroft * than is feasible so we use a default of 128. This
721de64f03aSmycroft * number may be overridden by the driver and/or by
722de64f03aSmycroft * user configuration.
723de64f03aSmycroft */
724de64f03aSmycroft #define IEEE80211_AID_MAX 2007
725de64f03aSmycroft #define IEEE80211_AID_DEF 128
7268a3890c6Sdyoung
727de64f03aSmycroft #define IEEE80211_AID(b) ((b) &~ 0xc000)
7288a3890c6Sdyoung
72940e261aaSdyoung /*
73040e261aaSdyoung * RTS frame length parameters. The default is specified in
73187515e34Sskrll * the 802.11 spec as 512; we treat it as implementation-dependent
73287515e34Sskrll * so it's defined in ieee80211_var.h. The max may be wrong
73387515e34Sskrll * for jumbo frames.
73440e261aaSdyoung */
73540e261aaSdyoung #define IEEE80211_RTS_MIN 1
73687515e34Sskrll #define IEEE80211_RTS_MAX 2346
73787515e34Sskrll
73887515e34Sskrll /*
73987515e34Sskrll * TX fragmentation parameters. As above for RTS, we treat
74087515e34Sskrll * default as implementation-dependent so define it elsewhere.
74187515e34Sskrll */
74287515e34Sskrll #define IEEE80211_FRAG_MIN 256
74387515e34Sskrll #define IEEE80211_FRAG_MAX 2346
74440e261aaSdyoung
74581eefc6fSdyoung /*
74681eefc6fSdyoung * 802.11 frame duration definitions.
74781eefc6fSdyoung */
74881eefc6fSdyoung
74981eefc6fSdyoung struct ieee80211_duration {
75081eefc6fSdyoung uint16_t d_rts_dur;
75181eefc6fSdyoung uint16_t d_data_dur;
75281eefc6fSdyoung uint16_t d_plcp_len;
75306e4fe7fSmycroft uint8_t d_residue; /* unused octets in time slot */
75481eefc6fSdyoung };
75581eefc6fSdyoung
75681eefc6fSdyoung /* One Time Unit (TU) is 1Kus = 1024 microseconds. */
75781eefc6fSdyoung #define IEEE80211_DUR_TU 1024
75881eefc6fSdyoung
75981eefc6fSdyoung /* IEEE 802.11b durations for DSSS PHY in microseconds */
76081eefc6fSdyoung #define IEEE80211_DUR_DS_LONG_PREAMBLE 144
76181eefc6fSdyoung #define IEEE80211_DUR_DS_SHORT_PREAMBLE 72
7621989546aSmycroft
76381eefc6fSdyoung #define IEEE80211_DUR_DS_SLOW_PLCPHDR 48
7641989546aSmycroft #define IEEE80211_DUR_DS_FAST_PLCPHDR 24
76581eefc6fSdyoung #define IEEE80211_DUR_DS_SLOW_ACK 112
76681eefc6fSdyoung #define IEEE80211_DUR_DS_FAST_ACK 56
76781eefc6fSdyoung #define IEEE80211_DUR_DS_SLOW_CTS 112
76881eefc6fSdyoung #define IEEE80211_DUR_DS_FAST_CTS 56
7691989546aSmycroft
77081eefc6fSdyoung #define IEEE80211_DUR_DS_SLOT 20
77181eefc6fSdyoung #define IEEE80211_DUR_DS_SIFS 10
77281eefc6fSdyoung #define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT)
77381eefc6fSdyoung #define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \
77481eefc6fSdyoung 2 * IEEE80211_DUR_DS_SLOT)
77581eefc6fSdyoung #define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \
77681eefc6fSdyoung IEEE80211_DUR_DS_SLOW_ACK + \
77781eefc6fSdyoung IEEE80211_DUR_DS_LONG_PREAMBLE + \
77881eefc6fSdyoung IEEE80211_DUR_DS_SLOW_PLCPHDR + \
7790703ab0fSdyoung IEEE80211_DUR_DS_DIFS)
78081eefc6fSdyoung
78140e261aaSdyoung
782976bf6cfSelad #endif /* !_NET80211_IEEE80211_H_ */
783