1 //------------------------------------------------------------------------------
2 // <copyright file="ieee80211.h" company="Atheros">
3 // Copyright (c) 2004-2010 Atheros Corporation. All rights reserved.
6 // Permission to use, copy, modify, and/or distribute this software for any
7 // purpose with or without fee is hereby granted, provided that the above
8 // copyright notice and this permission notice appear in all copies.
10 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 //------------------------------------------------------------------------------
20 //==============================================================================
21 // Author(s): ="Atheros"
22 //==============================================================================
23 #ifndef _NET80211_IEEE80211_H_
24 #define _NET80211_IEEE80211_H_
26 #include "athstartpack.h"
29 * 802.11 protocol definitions.
31 #define IEEE80211_WEP_KEYLEN 5 /* 40bit */
32 #define IEEE80211_WEP_IVLEN 3 /* 24bit */
33 #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */
34 #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */
35 #define IEEE80211_WEP_NKID 4 /* number of key ids */
38 * 802.11i defines an extended IV for use with non-WEP ciphers.
39 * When the EXTIV bit is set in the key id byte an additional
40 * 4 bytes immediately follow the IV for TKIP. For CCMP the
41 * EXTIV bit is likewise set but the 8 bytes represent the
42 * CCMP header rather than IV+extended-IV.
44 #define IEEE80211_WEP_EXTIV 0x20
45 #define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */
46 #define IEEE80211_WEP_MICLEN 8 /* trailing MIC */
48 #define IEEE80211_CRC_LEN 4
51 #define IEEE80211_WAPI_EXTIVLEN 10 /* extended IV length */
52 #endif /* WAPI ENABLE */
55 #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
56 /* is 802.11 address multicast/broadcast? */
57 #define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01)
58 #define IEEE80211_IS_BROADCAST(_a) (*(_a) == 0xFF)
59 #define WEP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN)
60 #define WEP_TRAILER IEEE80211_WEP_CRCLEN
61 #define CCMP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + \
62 IEEE80211_WEP_EXTIVLEN)
63 #define CCMP_TRAILER IEEE80211_WEP_MICLEN
64 #define TKIP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + \
65 IEEE80211_WEP_EXTIVLEN)
66 #define TKIP_TRAILER IEEE80211_WEP_CRCLEN
67 #define TKIP_MICLEN IEEE80211_WEP_MICLEN
70 #define IEEE80211_ADDR_EQ(addr1, addr2) \
71 (A_MEMCMP(addr1, addr2, IEEE80211_ADDR_LEN) == 0)
73 #define IEEE80211_ADDR_COPY(dst,src) A_MEMCPY(dst,src,IEEE80211_ADDR_LEN)
75 #define IEEE80211_KEYBUF_SIZE 16
76 #define IEEE80211_MICBUF_SIZE (8+8) /* space for both tx and rx */
79 * NB: these values are ordered carefully; there are lots of
80 * of implications in any reordering. In particular beware
81 * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY.
83 #define IEEE80211_CIPHER_WEP 0
84 #define IEEE80211_CIPHER_TKIP 1
85 #define IEEE80211_CIPHER_AES_OCB 2
86 #define IEEE80211_CIPHER_AES_CCM 3
87 #define IEEE80211_CIPHER_CKIP 5
88 #define IEEE80211_CIPHER_CCKM_KRK 6
89 #define IEEE80211_CIPHER_NONE 7 /* pseudo value */
91 #define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+1)
93 #define IEEE80211_IS_VALID_WEP_CIPHER_LEN(len) \
94 (((len) == 5) || ((len) == 13) || ((len) == 16))
99 * generic definitions for IEEE 802.11 frames
101 PREPACK struct ieee80211_frame {
104 u8 i_addr1[IEEE80211_ADDR_LEN];
105 u8 i_addr2[IEEE80211_ADDR_LEN];
106 u8 i_addr3[IEEE80211_ADDR_LEN];
108 /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
112 PREPACK struct ieee80211_qosframe {
115 u8 i_addr1[IEEE80211_ADDR_LEN];
116 u8 i_addr2[IEEE80211_ADDR_LEN];
117 u8 i_addr3[IEEE80211_ADDR_LEN];
122 #define IEEE80211_FC0_VERSION_MASK 0x03
123 #define IEEE80211_FC0_VERSION_SHIFT 0
124 #define IEEE80211_FC0_VERSION_0 0x00
125 #define IEEE80211_FC0_TYPE_MASK 0x0c
126 #define IEEE80211_FC0_TYPE_SHIFT 2
127 #define IEEE80211_FC0_TYPE_MGT 0x00
128 #define IEEE80211_FC0_TYPE_CTL 0x04
129 #define IEEE80211_FC0_TYPE_DATA 0x08
131 #define IEEE80211_FC0_SUBTYPE_MASK 0xf0
132 #define IEEE80211_FC0_SUBTYPE_SHIFT 4
134 #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
135 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
136 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
137 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
138 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
139 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
140 #define IEEE80211_FC0_SUBTYPE_BEACON 0x80
141 #define IEEE80211_FC0_SUBTYPE_ATIM 0x90
142 #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
143 #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
144 #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
146 #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
147 #define IEEE80211_FC0_SUBTYPE_RTS 0xb0
148 #define IEEE80211_FC0_SUBTYPE_CTS 0xc0
149 #define IEEE80211_FC0_SUBTYPE_ACK 0xd0
150 #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
151 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
152 /* for TYPE_DATA (bit combination) */
153 #define IEEE80211_FC0_SUBTYPE_DATA 0x00
154 #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
155 #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
156 #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
157 #define IEEE80211_FC0_SUBTYPE_NODATA 0x40
158 #define IEEE80211_FC0_SUBTYPE_CFACK 0x50
159 #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60
160 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
161 #define IEEE80211_FC0_SUBTYPE_QOS 0x80
162 #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0
164 #define IEEE80211_FC1_DIR_MASK 0x03
165 #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
166 #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
167 #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
168 #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
170 #define IEEE80211_FC1_MORE_FRAG 0x04
171 #define IEEE80211_FC1_RETRY 0x08
172 #define IEEE80211_FC1_PWR_MGT 0x10
173 #define IEEE80211_FC1_MORE_DATA 0x20
174 #define IEEE80211_FC1_WEP 0x40
175 #define IEEE80211_FC1_ORDER 0x80
177 #define IEEE80211_SEQ_FRAG_MASK 0x000f
178 #define IEEE80211_SEQ_FRAG_SHIFT 0
179 #define IEEE80211_SEQ_SEQ_MASK 0xfff0
180 #define IEEE80211_SEQ_SEQ_SHIFT 4
182 #define IEEE80211_NWID_LEN 32
187 #define IEEE80211_RATE_SIZE 8 /* 802.11 standard */
188 #define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */
190 #define WMM_NUM_AC 4 /* 4 AC categories */
192 #define WMM_PARAM_ACI_M 0x60 /* Mask for ACI field */
193 #define WMM_PARAM_ACI_S 5 /* Shift for ACI field */
194 #define WMM_PARAM_ACM_M 0x10 /* Mask for ACM bit */
195 #define WMM_PARAM_ACM_S 4 /* Shift for ACM bit */
196 #define WMM_PARAM_AIFSN_M 0x0f /* Mask for aifsn field */
197 #define WMM_PARAM_LOGCWMIN_M 0x0f /* Mask for CwMin field (in log) */
198 #define WMM_PARAM_LOGCWMAX_M 0xf0 /* Mask for CwMax field (in log) */
199 #define WMM_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */
201 #define WMM_AC_TO_TID(_ac) ( \
202 ((_ac) == WMM_AC_VO) ? 6 : \
203 ((_ac) == WMM_AC_VI) ? 5 : \
204 ((_ac) == WMM_AC_BK) ? 1 : \
207 #define TID_TO_WMM_AC(_tid) ( \
208 ((_tid) < 1) ? WMM_AC_BE : \
209 ((_tid) < 3) ? WMM_AC_BK : \
210 ((_tid) < 6) ? WMM_AC_VI : \
213 * Management information element payloads.
217 IEEE80211_ELEMID_SSID = 0,
218 IEEE80211_ELEMID_RATES = 1,
219 IEEE80211_ELEMID_FHPARMS = 2,
220 IEEE80211_ELEMID_DSPARMS = 3,
221 IEEE80211_ELEMID_CFPARMS = 4,
222 IEEE80211_ELEMID_TIM = 5,
223 IEEE80211_ELEMID_IBSSPARMS = 6,
224 IEEE80211_ELEMID_COUNTRY = 7,
225 IEEE80211_ELEMID_CHALLENGE = 16,
226 /* 17-31 reserved for challenge text extension */
227 IEEE80211_ELEMID_PWRCNSTR = 32,
228 IEEE80211_ELEMID_PWRCAP = 33,
229 IEEE80211_ELEMID_TPCREQ = 34,
230 IEEE80211_ELEMID_TPCREP = 35,
231 IEEE80211_ELEMID_SUPPCHAN = 36,
232 IEEE80211_ELEMID_CHANSWITCH = 37,
233 IEEE80211_ELEMID_MEASREQ = 38,
234 IEEE80211_ELEMID_MEASREP = 39,
235 IEEE80211_ELEMID_QUIET = 40,
236 IEEE80211_ELEMID_IBSSDFS = 41,
237 IEEE80211_ELEMID_ERP = 42,
238 IEEE80211_ELEMID_HTCAP_ANA = 45, /* Address ANA, and non-ANA story, for interop. CL#171733 */
239 IEEE80211_ELEMID_RSN = 48,
240 IEEE80211_ELEMID_XRATES = 50,
241 IEEE80211_ELEMID_HTINFO_ANA = 61,
243 IEEE80211_ELEMID_WAPI = 68,
245 IEEE80211_ELEMID_TPC = 150,
246 IEEE80211_ELEMID_CCKM = 156,
247 IEEE80211_ELEMID_VENDOR = 221, /* vendor private */
250 #define ATH_OUI 0x7f0300 /* Atheros OUI */
251 #define ATH_OUI_TYPE 0x01
252 #define ATH_OUI_SUBTYPE 0x01
253 #define ATH_OUI_VERSION 0x00
255 #define WPA_OUI 0xf25000
256 #define WPA_OUI_TYPE 0x01
257 #define WPA_VERSION 1 /* current supported version */
259 #define WPA_CSE_NULL 0x00
260 #define WPA_CSE_WEP40 0x01
261 #define WPA_CSE_TKIP 0x02
262 #define WPA_CSE_CCMP 0x04
263 #define WPA_CSE_WEP104 0x05
265 #define WPA_ASE_NONE 0x00
266 #define WPA_ASE_8021X_UNSPEC 0x01
267 #define WPA_ASE_8021X_PSK 0x02
269 #define RSN_OUI 0xac0f00
270 #define RSN_VERSION 1 /* current supported version */
272 #define RSN_CSE_NULL 0x00
273 #define RSN_CSE_WEP40 0x01
274 #define RSN_CSE_TKIP 0x02
275 #define RSN_CSE_WRAP 0x03
276 #define RSN_CSE_CCMP 0x04
277 #define RSN_CSE_WEP104 0x05
279 #define RSN_ASE_NONE 0x00
280 #define RSN_ASE_8021X_UNSPEC 0x01
281 #define RSN_ASE_8021X_PSK 0x02
283 #define RSN_CAP_PREAUTH 0x01
285 #define WMM_OUI 0xf25000
286 #define WMM_OUI_TYPE 0x02
287 #define WMM_INFO_OUI_SUBTYPE 0x00
288 #define WMM_PARAM_OUI_SUBTYPE 0x01
289 #define WMM_VERSION 1
291 /* WMM stream classes */
293 #define WMM_AC_BE 0 /* best effort */
294 #define WMM_AC_BK 1 /* background */
295 #define WMM_AC_VI 2 /* video */
296 #define WMM_AC_VO 3 /* voice */
299 #define ACTION_CATEGORY_CODE_TSPEC 17
300 #define ACTION_CODE_TSPEC_ADDTS 0
301 #define ACTION_CODE_TSPEC_ADDTS_RESP 1
302 #define ACTION_CODE_TSPEC_DELTS 2
305 TSPEC_STATUS_CODE_ADMISSION_ACCEPTED = 0,
306 TSPEC_STATUS_CODE_ADDTS_INVALID_PARAMS = 0x1,
307 TSPEC_STATUS_CODE_ADDTS_REQUEST_REFUSED = 0x3,
308 TSPEC_STATUS_CODE_UNSPECIFIED_QOS_RELATED_FAILURE = 0xC8,
309 TSPEC_STATUS_CODE_REQUESTED_REFUSED_POLICY_CONFIGURATION = 0xC9,
310 TSPEC_STATUS_CODE_INSUFFCIENT_BANDWIDTH = 0xCA,
311 TSPEC_STATUS_CODE_INVALID_PARAMS = 0xCB,
312 TSPEC_STATUS_CODE_DELTS_SENT = 0x30,
313 TSPEC_STATUS_CODE_DELTS_RECV = 0x31,
316 #define TSPEC_TSID_MASK 0xF
317 #define TSPEC_TSID_S 1
320 * WMM/802.11e Tspec Element
322 typedef PREPACK struct wmm_tspec_ie_t {
329 A_UINT16 tsInfo_info;
331 A_UINT16 nominalMSDU;
333 A_UINT32 minServiceInt;
334 A_UINT32 maxServiceInt;
335 A_UINT32 inactivityInt;
336 A_UINT32 suspensionInt;
337 A_UINT32 serviceStartTime;
338 A_UINT32 minDataRate;
339 A_UINT32 meanDataRate;
340 A_UINT32 peakDataRate;
341 A_UINT32 maxBurstSize;
346 } POSTPACK WMM_TSPEC_IE;
350 * BEACON management packets
353 * octet beacon interval[2]
354 * octet capability information[2]
355 * information element
358 * octet information[length]
361 #define IEEE80211_BEACON_INTERVAL(beacon) \
362 ((beacon)[8] | ((beacon)[9] << 8))
363 #define IEEE80211_BEACON_CAPABILITY(beacon) \
364 ((beacon)[10] | ((beacon)[11] << 8))
366 #define IEEE80211_CAPINFO_ESS 0x0001
367 #define IEEE80211_CAPINFO_IBSS 0x0002
368 #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004
369 #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008
370 #define IEEE80211_CAPINFO_PRIVACY 0x0010
371 #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020
372 #define IEEE80211_CAPINFO_PBCC 0x0040
373 #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080
374 /* bits 8-9 are reserved */
375 #define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400
376 #define IEEE80211_CAPINFO_APSD 0x0800
377 /* bit 12 is reserved */
378 #define IEEE80211_CAPINFO_DSSSOFDM 0x2000
379 /* bits 14-15 are reserved */
382 * Authentication Modes
385 enum ieee80211_authmode {
386 IEEE80211_AUTH_NONE = 0,
387 IEEE80211_AUTH_OPEN = 1,
388 IEEE80211_AUTH_SHARED = 2,
389 IEEE80211_AUTH_8021X = 3,
390 IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */
391 /* NB: these are used only for ioctls */
392 IEEE80211_AUTH_WPA = 5, /* WPA/RSN w/ 802.1x */
393 IEEE80211_AUTH_WPA_PSK = 6, /* WPA/RSN w/ PSK */
394 IEEE80211_AUTH_WPA_CCKM = 7, /* WPA/RSN IE w/ CCKM */
397 #define IEEE80211_PS_MAX_QUEUE 50 /*Maximum no of buffers that can be queues for PS*/
399 #include "athendpack.h"
401 #endif /* _NET80211_IEEE80211_H_ */