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_
27 * 802.11 protocol definitions.
29 #define IEEE80211_WEP_KEYLEN 5 /* 40bit */
30 #define IEEE80211_WEP_IVLEN 3 /* 24bit */
31 #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */
32 #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */
33 #define IEEE80211_WEP_NKID 4 /* number of key ids */
36 * 802.11i defines an extended IV for use with non-WEP ciphers.
37 * When the EXTIV bit is set in the key id byte an additional
38 * 4 bytes immediately follow the IV for TKIP. For CCMP the
39 * EXTIV bit is likewise set but the 8 bytes represent the
40 * CCMP header rather than IV+extended-IV.
42 #define IEEE80211_WEP_EXTIV 0x20
43 #define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */
44 #define IEEE80211_WEP_MICLEN 8 /* trailing MIC */
46 #define IEEE80211_CRC_LEN 4
49 #define IEEE80211_WAPI_EXTIVLEN 10 /* extended IV length */
50 #endif /* WAPI ENABLE */
53 #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
54 /* is 802.11 address multicast/broadcast? */
55 #define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01)
56 #define IEEE80211_IS_BROADCAST(_a) (*(_a) == 0xFF)
57 #define WEP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN)
58 #define WEP_TRAILER IEEE80211_WEP_CRCLEN
59 #define CCMP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + \
60 IEEE80211_WEP_EXTIVLEN)
61 #define CCMP_TRAILER IEEE80211_WEP_MICLEN
62 #define TKIP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + \
63 IEEE80211_WEP_EXTIVLEN)
64 #define TKIP_TRAILER IEEE80211_WEP_CRCLEN
65 #define TKIP_MICLEN IEEE80211_WEP_MICLEN
68 #define IEEE80211_ADDR_EQ(addr1, addr2) \
69 (memcmp(addr1, addr2, IEEE80211_ADDR_LEN) == 0)
71 #define IEEE80211_ADDR_COPY(dst,src) memcpy(dst,src,IEEE80211_ADDR_LEN)
73 #define IEEE80211_KEYBUF_SIZE 16
74 #define IEEE80211_MICBUF_SIZE (8+8) /* space for both tx and rx */
77 * NB: these values are ordered carefully; there are lots of
78 * of implications in any reordering. In particular beware
79 * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY.
81 #define IEEE80211_CIPHER_WEP 0
82 #define IEEE80211_CIPHER_TKIP 1
83 #define IEEE80211_CIPHER_AES_OCB 2
84 #define IEEE80211_CIPHER_AES_CCM 3
85 #define IEEE80211_CIPHER_CKIP 5
86 #define IEEE80211_CIPHER_CCKM_KRK 6
87 #define IEEE80211_CIPHER_NONE 7 /* pseudo value */
89 #define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+1)
91 #define IEEE80211_IS_VALID_WEP_CIPHER_LEN(len) \
92 (((len) == 5) || ((len) == 13) || ((len) == 16))
97 * generic definitions for IEEE 802.11 frames
99 PREPACK struct ieee80211_frame {
102 u8 i_addr1[IEEE80211_ADDR_LEN];
103 u8 i_addr2[IEEE80211_ADDR_LEN];
104 u8 i_addr3[IEEE80211_ADDR_LEN];
106 /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
110 PREPACK struct ieee80211_qosframe {
113 u8 i_addr1[IEEE80211_ADDR_LEN];
114 u8 i_addr2[IEEE80211_ADDR_LEN];
115 u8 i_addr3[IEEE80211_ADDR_LEN];
120 #define IEEE80211_FC0_VERSION_MASK 0x03
121 #define IEEE80211_FC0_VERSION_SHIFT 0
122 #define IEEE80211_FC0_VERSION_0 0x00
123 #define IEEE80211_FC0_TYPE_MASK 0x0c
124 #define IEEE80211_FC0_TYPE_SHIFT 2
125 #define IEEE80211_FC0_TYPE_MGT 0x00
126 #define IEEE80211_FC0_TYPE_CTL 0x04
127 #define IEEE80211_FC0_TYPE_DATA 0x08
129 #define IEEE80211_FC0_SUBTYPE_MASK 0xf0
130 #define IEEE80211_FC0_SUBTYPE_SHIFT 4
132 #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
133 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
134 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
135 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
136 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
137 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
138 #define IEEE80211_FC0_SUBTYPE_BEACON 0x80
139 #define IEEE80211_FC0_SUBTYPE_ATIM 0x90
140 #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
141 #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
142 #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
144 #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
145 #define IEEE80211_FC0_SUBTYPE_RTS 0xb0
146 #define IEEE80211_FC0_SUBTYPE_CTS 0xc0
147 #define IEEE80211_FC0_SUBTYPE_ACK 0xd0
148 #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
149 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
150 /* for TYPE_DATA (bit combination) */
151 #define IEEE80211_FC0_SUBTYPE_DATA 0x00
152 #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
153 #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
154 #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
155 #define IEEE80211_FC0_SUBTYPE_NODATA 0x40
156 #define IEEE80211_FC0_SUBTYPE_CFACK 0x50
157 #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60
158 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
159 #define IEEE80211_FC0_SUBTYPE_QOS 0x80
160 #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0
162 #define IEEE80211_FC1_DIR_MASK 0x03
163 #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
164 #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
165 #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
166 #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
168 #define IEEE80211_FC1_MORE_FRAG 0x04
169 #define IEEE80211_FC1_RETRY 0x08
170 #define IEEE80211_FC1_PWR_MGT 0x10
171 #define IEEE80211_FC1_MORE_DATA 0x20
172 #define IEEE80211_FC1_WEP 0x40
173 #define IEEE80211_FC1_ORDER 0x80
175 #define IEEE80211_SEQ_FRAG_MASK 0x000f
176 #define IEEE80211_SEQ_FRAG_SHIFT 0
177 #define IEEE80211_SEQ_SEQ_MASK 0xfff0
178 #define IEEE80211_SEQ_SEQ_SHIFT 4
180 #define IEEE80211_NWID_LEN 32
185 #define IEEE80211_RATE_SIZE 8 /* 802.11 standard */
186 #define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */
188 #define WMM_NUM_AC 4 /* 4 AC categories */
190 #define WMM_PARAM_ACI_M 0x60 /* Mask for ACI field */
191 #define WMM_PARAM_ACI_S 5 /* Shift for ACI field */
192 #define WMM_PARAM_ACM_M 0x10 /* Mask for ACM bit */
193 #define WMM_PARAM_ACM_S 4 /* Shift for ACM bit */
194 #define WMM_PARAM_AIFSN_M 0x0f /* Mask for aifsn field */
195 #define WMM_PARAM_LOGCWMIN_M 0x0f /* Mask for CwMin field (in log) */
196 #define WMM_PARAM_LOGCWMAX_M 0xf0 /* Mask for CwMax field (in log) */
197 #define WMM_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */
199 #define WMM_AC_TO_TID(_ac) ( \
200 ((_ac) == WMM_AC_VO) ? 6 : \
201 ((_ac) == WMM_AC_VI) ? 5 : \
202 ((_ac) == WMM_AC_BK) ? 1 : \
205 #define TID_TO_WMM_AC(_tid) ( \
206 ((_tid) < 1) ? WMM_AC_BE : \
207 ((_tid) < 3) ? WMM_AC_BK : \
208 ((_tid) < 6) ? WMM_AC_VI : \
211 * Management information element payloads.
215 IEEE80211_ELEMID_SSID = 0,
216 IEEE80211_ELEMID_RATES = 1,
217 IEEE80211_ELEMID_FHPARMS = 2,
218 IEEE80211_ELEMID_DSPARMS = 3,
219 IEEE80211_ELEMID_CFPARMS = 4,
220 IEEE80211_ELEMID_TIM = 5,
221 IEEE80211_ELEMID_IBSSPARMS = 6,
222 IEEE80211_ELEMID_COUNTRY = 7,
223 IEEE80211_ELEMID_CHALLENGE = 16,
224 /* 17-31 reserved for challenge text extension */
225 IEEE80211_ELEMID_PWRCNSTR = 32,
226 IEEE80211_ELEMID_PWRCAP = 33,
227 IEEE80211_ELEMID_TPCREQ = 34,
228 IEEE80211_ELEMID_TPCREP = 35,
229 IEEE80211_ELEMID_SUPPCHAN = 36,
230 IEEE80211_ELEMID_CHANSWITCH = 37,
231 IEEE80211_ELEMID_MEASREQ = 38,
232 IEEE80211_ELEMID_MEASREP = 39,
233 IEEE80211_ELEMID_QUIET = 40,
234 IEEE80211_ELEMID_IBSSDFS = 41,
235 IEEE80211_ELEMID_ERP = 42,
236 IEEE80211_ELEMID_HTCAP_ANA = 45, /* Address ANA, and non-ANA story, for interop. CL#171733 */
237 IEEE80211_ELEMID_RSN = 48,
238 IEEE80211_ELEMID_XRATES = 50,
239 IEEE80211_ELEMID_HTINFO_ANA = 61,
241 IEEE80211_ELEMID_WAPI = 68,
243 IEEE80211_ELEMID_TPC = 150,
244 IEEE80211_ELEMID_CCKM = 156,
245 IEEE80211_ELEMID_VENDOR = 221, /* vendor private */
248 #define ATH_OUI 0x7f0300 /* Atheros OUI */
249 #define ATH_OUI_TYPE 0x01
250 #define ATH_OUI_SUBTYPE 0x01
251 #define ATH_OUI_VERSION 0x00
253 #define WPA_OUI 0xf25000
254 #define WPA_OUI_TYPE 0x01
255 #define WPA_VERSION 1 /* current supported version */
257 #define WPA_CSE_NULL 0x00
258 #define WPA_CSE_WEP40 0x01
259 #define WPA_CSE_TKIP 0x02
260 #define WPA_CSE_CCMP 0x04
261 #define WPA_CSE_WEP104 0x05
263 #define WPA_ASE_NONE 0x00
264 #define WPA_ASE_8021X_UNSPEC 0x01
265 #define WPA_ASE_8021X_PSK 0x02
267 #define RSN_OUI 0xac0f00
268 #define RSN_VERSION 1 /* current supported version */
270 #define RSN_CSE_NULL 0x00
271 #define RSN_CSE_WEP40 0x01
272 #define RSN_CSE_TKIP 0x02
273 #define RSN_CSE_WRAP 0x03
274 #define RSN_CSE_CCMP 0x04
275 #define RSN_CSE_WEP104 0x05
277 #define RSN_ASE_NONE 0x00
278 #define RSN_ASE_8021X_UNSPEC 0x01
279 #define RSN_ASE_8021X_PSK 0x02
281 #define RSN_CAP_PREAUTH 0x01
283 #define WMM_OUI 0xf25000
284 #define WMM_OUI_TYPE 0x02
285 #define WMM_INFO_OUI_SUBTYPE 0x00
286 #define WMM_PARAM_OUI_SUBTYPE 0x01
287 #define WMM_VERSION 1
289 /* WMM stream classes */
291 #define WMM_AC_BE 0 /* best effort */
292 #define WMM_AC_BK 1 /* background */
293 #define WMM_AC_VI 2 /* video */
294 #define WMM_AC_VO 3 /* voice */
297 #define ACTION_CATEGORY_CODE_TSPEC 17
298 #define ACTION_CODE_TSPEC_ADDTS 0
299 #define ACTION_CODE_TSPEC_ADDTS_RESP 1
300 #define ACTION_CODE_TSPEC_DELTS 2
303 TSPEC_STATUS_CODE_ADMISSION_ACCEPTED = 0,
304 TSPEC_STATUS_CODE_ADDTS_INVALID_PARAMS = 0x1,
305 TSPEC_STATUS_CODE_ADDTS_REQUEST_REFUSED = 0x3,
306 TSPEC_STATUS_CODE_UNSPECIFIED_QOS_RELATED_FAILURE = 0xC8,
307 TSPEC_STATUS_CODE_REQUESTED_REFUSED_POLICY_CONFIGURATION = 0xC9,
308 TSPEC_STATUS_CODE_INSUFFCIENT_BANDWIDTH = 0xCA,
309 TSPEC_STATUS_CODE_INVALID_PARAMS = 0xCB,
310 TSPEC_STATUS_CODE_DELTS_SENT = 0x30,
311 TSPEC_STATUS_CODE_DELTS_RECV = 0x31,
314 #define TSPEC_TSID_MASK 0xF
315 #define TSPEC_TSID_S 1
318 * WMM/802.11e Tspec Element
320 typedef PREPACK struct wmm_tspec_ie_t {
335 u32 serviceStartTime;
344 } POSTPACK WMM_TSPEC_IE;
348 * BEACON management packets
351 * octet beacon interval[2]
352 * octet capability information[2]
353 * information element
356 * octet information[length]
359 #define IEEE80211_BEACON_INTERVAL(beacon) \
360 ((beacon)[8] | ((beacon)[9] << 8))
361 #define IEEE80211_BEACON_CAPABILITY(beacon) \
362 ((beacon)[10] | ((beacon)[11] << 8))
364 #define IEEE80211_CAPINFO_ESS 0x0001
365 #define IEEE80211_CAPINFO_IBSS 0x0002
366 #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004
367 #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008
368 #define IEEE80211_CAPINFO_PRIVACY 0x0010
369 #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020
370 #define IEEE80211_CAPINFO_PBCC 0x0040
371 #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080
372 /* bits 8-9 are reserved */
373 #define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400
374 #define IEEE80211_CAPINFO_APSD 0x0800
375 /* bit 12 is reserved */
376 #define IEEE80211_CAPINFO_DSSSOFDM 0x2000
377 /* bits 14-15 are reserved */
380 * Authentication Modes
383 enum ieee80211_authmode {
384 IEEE80211_AUTH_NONE = 0,
385 IEEE80211_AUTH_OPEN = 1,
386 IEEE80211_AUTH_SHARED = 2,
387 IEEE80211_AUTH_8021X = 3,
388 IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */
389 /* NB: these are used only for ioctls */
390 IEEE80211_AUTH_WPA = 5, /* WPA/RSN w/ 802.1x */
391 IEEE80211_AUTH_WPA_PSK = 6, /* WPA/RSN w/ PSK */
392 IEEE80211_AUTH_WPA_CCKM = 7, /* WPA/RSN IE w/ CCKM */
395 #define IEEE80211_PS_MAX_QUEUE 50 /*Maximum no of buffers that can be queues for PS*/
397 #endif /* _NET80211_IEEE80211_H_ */