2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * Alternatively, this software may be distributed under the terms of the
18 * GNU General Public License ("GPL") version 2 as published by the Free
19 * Software Foundation.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.5 2004/04/05 17:47:40 sam Exp $
33 * $DragonFly: src/sys/netproto/802_11/ieee80211.h,v 1.1 2004/07/26 16:30:17 joerg Exp $
36 #ifndef _NETPROTO_802_11_IEEE80211_H_
37 #define _NETPROTO_802_11_IEEE80211_H_
40 * 802.11 protocol definitions.
43 #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
44 /* is 802.11 address multicast/broadcast? */
45 #define IEEE80211_IS_MULTICAST(a) ETHER_IS_MULTICAST(a)
47 /* IEEE 802.11 PLCP header */
48 struct ieee80211_plcp_hdr {
54 } __attribute__((__packed__));
56 #define IEEE80211_PLCP_SFD 0xF3A0
57 #define IEEE80211_PLCP_SERVICE 0x00
60 * generic definitions for IEEE 802.11 frames
62 struct ieee80211_frame {
65 uint8_t i_addr1[IEEE80211_ADDR_LEN];
66 uint8_t i_addr2[IEEE80211_ADDR_LEN];
67 uint8_t i_addr3[IEEE80211_ADDR_LEN];
69 /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
71 } __attribute__((__packed__));
73 struct ieee80211_qosframe {
76 uint8_t i_addr1[IEEE80211_ADDR_LEN];
77 uint8_t i_addr2[IEEE80211_ADDR_LEN];
78 uint8_t i_addr3[IEEE80211_ADDR_LEN];
81 /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
83 } __attribute__((__packed__));
85 struct ieee80211_qoscntl {
89 struct ieee80211_frame_addr4 {
92 uint8_t i_addr1[IEEE80211_ADDR_LEN];
93 uint8_t i_addr2[IEEE80211_ADDR_LEN];
94 uint8_t i_addr3[IEEE80211_ADDR_LEN];
96 uint8_t i_addr4[IEEE80211_ADDR_LEN];
97 } __attribute__((__packed__));
100 struct ieee80211_qosframe_addr4 {
103 uint8_t i_addr1[IEEE80211_ADDR_LEN];
104 uint8_t i_addr2[IEEE80211_ADDR_LEN];
105 uint8_t i_addr3[IEEE80211_ADDR_LEN];
107 uint8_t i_addr4[IEEE80211_ADDR_LEN];
109 } __attribute__((__packed__));
112 * Management Notification Frame
114 struct ieee80211_mnf {
115 uint8_t mnf_category;
119 } __attribute__((__packed__));
120 #define MNF_SETUP_REQ 0
121 #define MNF_SETUP_RESP 1
122 #define MNF_TEARDOWN 2
125 * WME/802.11e Tspec Element
127 struct ieee80211_wme_tspec {
132 uint8_t ts_oui_subtype;
134 uint8_t ts_tsinfo[3];
135 uint8_t ts_nom_msdu[2];
136 uint8_t ts_max_msdu[2];
137 uint8_t ts_min_svc[4];
138 uint8_t ts_max_svc[4];
139 uint8_t ts_inactv_intv[4];
140 uint8_t ts_susp_intv[4];
141 uint8_t ts_start_svc[4];
142 uint8_t ts_min_rate[4];
143 uint8_t ts_mean_rate[4];
144 uint8_t ts_max_burst[4];
145 uint8_t ts_min_phy[4];
146 uint8_t ts_peak_rate[4];
148 uint8_t ts_surplus[2];
149 uint8_t ts_medium_time[2];
150 } __attribute__((__packed__));
152 #define IEEE80211_FC0_VERSION_MASK 0x03
153 #define IEEE80211_FC0_VERSION_SHIFT 0
154 #define IEEE80211_FC0_VERSION_0 0x00
155 #define IEEE80211_FC0_TYPE_MASK 0x0c
156 #define IEEE80211_FC0_TYPE_SHIFT 2
157 #define IEEE80211_FC0_TYPE_MGT 0x00
158 #define IEEE80211_FC0_TYPE_CTL 0x04
159 #define IEEE80211_FC0_TYPE_DATA 0x08
161 #define IEEE80211_FC0_SUBTYPE_MASK 0xf0
162 #define IEEE80211_FC0_SUBTYPE_SHIFT 4
164 #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
165 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
166 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
167 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
168 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
169 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
170 #define IEEE80211_FC0_SUBTYPE_BEACON 0x80
171 #define IEEE80211_FC0_SUBTYPE_ATIM 0x90
172 #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
173 #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
174 #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
176 #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
177 #define IEEE80211_FC0_SUBTYPE_RTS 0xb0
178 #define IEEE80211_FC0_SUBTYPE_CTS 0xc0
179 #define IEEE80211_FC0_SUBTYPE_ACK 0xd0
180 #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
181 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
182 /* for TYPE_DATA (bit combination) */
183 #define IEEE80211_FC0_SUBTYPE_DATA 0x00
184 #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
185 #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
186 #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
187 #define IEEE80211_FC0_SUBTYPE_NODATA 0x40
188 #define IEEE80211_FC0_SUBTYPE_CFACK 0x50
189 #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60
190 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
191 #define IEEE80211_FC0_SUBTYPE_QOS 0x80
193 #define IEEE80211_FC1_DIR_MASK 0x03
194 #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
195 #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
196 #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
197 #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
199 #define IEEE80211_FC1_MORE_FRAG 0x04
200 #define IEEE80211_FC1_RETRY 0x08
201 #define IEEE80211_FC1_PWR_MGT 0x10
202 #define IEEE80211_FC1_MORE_DATA 0x20
203 #define IEEE80211_FC1_WEP 0x40
204 #define IEEE80211_FC1_ORDER 0x80
206 #define IEEE80211_SEQ_FRAG_MASK 0x000f
207 #define IEEE80211_SEQ_FRAG_SHIFT 0
208 #define IEEE80211_SEQ_SEQ_MASK 0xfff0
209 #define IEEE80211_SEQ_SEQ_SHIFT 4
211 #define IEEE80211_NWID_LEN 32
213 #define IEEE80211_QOS_TXOP 0x00ff
214 /* bit 8 is reserved */
215 #define IEEE80211_QOS_ACKPOLICY 0x0600
216 #define IEEE80211_QOS_ESOP 0x0800
217 #define IEEE80211_QOS_TID 0xf000
222 struct ieee80211_frame_min {
225 uint8_t i_addr1[IEEE80211_ADDR_LEN];
226 uint8_t i_addr2[IEEE80211_ADDR_LEN];
228 } __attribute__((__packed__));
230 struct ieee80211_frame_rts {
233 uint8_t i_ra[IEEE80211_ADDR_LEN];
234 uint8_t i_ta[IEEE80211_ADDR_LEN];
236 } __attribute__((__packed__));
238 struct ieee80211_frame_cts {
241 uint8_t i_ra[IEEE80211_ADDR_LEN];
243 } __attribute__((__packed__));
245 struct ieee80211_frame_ack {
248 uint8_t i_ra[IEEE80211_ADDR_LEN];
250 } __attribute__((__packed__));
252 struct ieee80211_frame_pspoll {
255 uint8_t i_bssid[IEEE80211_ADDR_LEN];
256 uint8_t i_ta[IEEE80211_ADDR_LEN];
258 } __attribute__((__packed__));
260 struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */
262 uint8_t i_dur[2]; /* should be zero */
263 uint8_t i_ra[IEEE80211_ADDR_LEN];
264 uint8_t i_bssid[IEEE80211_ADDR_LEN];
266 } __attribute__((__packed__));
269 * BEACON management packets
272 * octet beacon interval[2]
273 * octet capability information[2]
274 * information element
277 * octet information[length]
280 typedef uint8_t *ieee80211_mgt_beacon_t;
282 #define IEEE80211_BEACON_INTERVAL(beacon) \
283 ((beacon)[8] | ((beacon)[9] << 8))
284 #define IEEE80211_BEACON_CAPABILITY(beacon) \
285 ((beacon)[10] | ((beacon)[11] << 8))
287 #define IEEE80211_CAPINFO_ESS 0x0001
288 #define IEEE80211_CAPINFO_IBSS 0x0002
289 #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004
290 #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008
291 #define IEEE80211_CAPINFO_PRIVACY 0x0010
292 #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020
293 #define IEEE80211_CAPINFO_PBCC 0x0040
294 #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080
295 /* bits 8-9 are reserved */
296 #define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400
297 #define IEEE80211_CAPINFO_RSN 0x0800
298 /* bit 12 is reserved */
299 #define IEEE80211_CAPINFO_DSSSOFDM 0x2000
300 /* bits 14-15 are reserved */
303 * 802.11i/WPA information element (maximally sized).
305 struct ieee80211_ie_wpa {
306 uint8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */
307 uint8_t wpa_type; /* OUI type */
308 uint16_t wpa_version; /* spec revision */
309 uint32_t wpa_mcipher[1]; /* multicast/group key cipher */
310 uint16_t wpa_uciphercnt; /* # pairwise key ciphers */
311 uint32_t wpa_uciphers[8];/* ciphers */
312 uint16_t wpa_authselcnt; /* authentication selector cnt*/
313 uint32_t wpa_authsels[8];/* selectors */
314 } __attribute__((__packed__));
317 * Management information elements
319 struct ieee80211_information {
320 char ssid[IEEE80211_NWID_LEN+1];
343 /* uint8_t pvt[251]; The driver needs to use this. */
356 uint8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */
358 uint8_t schan; /* starting channel */
359 uint8_t nchan; /* number channels */
361 } band[4]; /* up to 4 sub bands */
366 struct ieee80211_ie_wpa wpa;
370 IEEE80211_ELEMID_SSID = 0,
371 IEEE80211_ELEMID_RATES = 1,
372 IEEE80211_ELEMID_FHPARMS = 2,
373 IEEE80211_ELEMID_DSPARMS = 3,
374 IEEE80211_ELEMID_CFPARMS = 4,
375 IEEE80211_ELEMID_TIM = 5,
376 IEEE80211_ELEMID_IBSSPARMS = 6,
377 IEEE80211_ELEMID_COUNTRY = 7,
378 IEEE80211_ELEMID_CHALLENGE = 16,
379 /* 17-31 reserved for challenge text extension */
380 IEEE80211_ELEMID_ERP = 42,
381 IEEE80211_ELEMID_XRATES = 50,
382 IEEE80211_ELEMID_TPC = 150,
383 IEEE80211_ELEMID_CCKM = 156,
384 IEEE80211_ELEMID_VENDOR = 221, /* vendor private */
387 #define IEEE80211_CHALLENGE_LEN 128
389 #define IEEE80211_RATE_BASIC 0x80
390 #define IEEE80211_RATE_VAL 0x7f
392 /* EPR information element flags */
393 #define IEEE80211_ERP_NON_ERP_PRESENT 0x01
394 #define IEEE80211_ERP_USE_PROTECTION 0x02
395 #define IEEE80211_ERP_BARKER_MODE 0x04
397 /* Atheros private advanced capabilities info */
398 #define ATHEROS_CAP_TURBO_PRIME 0x01
399 #define ATHEROS_CAP_COMPRESSION 0x02
400 #define ATHEROS_CAP_FAST_FRAME 0x04
401 /* bits 3-6 reserved */
402 #define ATHEROS_CAP_BOOST 0x80
404 #define ATH_OUI 0x7f0300 /* Atheros OUI */
405 #define ATH_OUI_TYPE 0x01
406 #define ATH_OUI_VERSION 0x01
408 #define WPA_OUI 0xf25000
409 #define WPA_OUI_TYPE 0x01
410 #define WPA_OUI_VERSION 1 /* current supported version */
412 #define WPA_CSE_NULL 0x00
413 #define WPA_CSE_WEP40 0x01
414 #define WPA_CSE_TKIP 0x02
415 #define WPA_CSE_WRAP 0x03 /* WPA2/802.11i */
416 #define WPA_CSE_CCMP 0x04
417 #define WPA_CSE_WEP104 0x05
419 #define WPA_ASE_NONE 0x00
420 #define WPA_ASE_8021X_UNSPEC 0x01
421 #define WPA_ASE_8021X_PSK 0x02
424 * AUTH management packets
431 * octet chal.text[253]
434 typedef uint8_t *ieee80211_mgt_auth_t;
436 #define IEEE80211_AUTH_ALGORITHM(auth) \
437 ((auth)[0] | ((auth)[1] << 8))
438 #define IEEE80211_AUTH_TRANSACTION(auth) \
439 ((auth)[2] | ((auth)[3] << 8))
440 #define IEEE80211_AUTH_STATUS(auth) \
441 ((auth)[4] | ((auth)[5] << 8))
443 #define IEEE80211_AUTH_ALG_OPEN 0x0000
444 #define IEEE80211_AUTH_ALG_SHARED 0x0001
445 #define IEEE80211_AUTH_ALG_LEAP 0x0080
448 IEEE80211_AUTH_OPEN_REQUEST = 1,
449 IEEE80211_AUTH_OPEN_RESPONSE = 2,
453 IEEE80211_AUTH_SHARED_REQUEST = 1,
454 IEEE80211_AUTH_SHARED_CHALLENGE = 2,
455 IEEE80211_AUTH_SHARED_RESPONSE = 3,
456 IEEE80211_AUTH_SHARED_PASS = 4,
462 * Unlisted codes are reserved
466 IEEE80211_REASON_UNSPECIFIED = 1,
467 IEEE80211_REASON_AUTH_EXPIRE = 2,
468 IEEE80211_REASON_AUTH_LEAVE = 3,
469 IEEE80211_REASON_ASSOC_EXPIRE = 4,
470 IEEE80211_REASON_ASSOC_TOOMANY = 5,
471 IEEE80211_REASON_NOT_AUTHED = 6,
472 IEEE80211_REASON_NOT_ASSOCED = 7,
473 IEEE80211_REASON_ASSOC_LEAVE = 8,
474 IEEE80211_REASON_ASSOC_NOT_AUTHED = 9,
476 IEEE80211_REASON_RSN_REQUIRED = 11,
477 IEEE80211_REASON_RSN_INCONSISTENT = 12,
478 IEEE80211_REASON_IE_INVALID = 13,
479 IEEE80211_REASON_MIC_FAILURE = 14,
481 IEEE80211_STATUS_SUCCESS = 0,
482 IEEE80211_STATUS_UNSPECIFIED = 1,
483 IEEE80211_STATUS_CAPINFO = 10,
484 IEEE80211_STATUS_NOT_ASSOCED = 11,
485 IEEE80211_STATUS_OTHER = 12,
486 IEEE80211_STATUS_ALG = 13,
487 IEEE80211_STATUS_SEQUENCE = 14,
488 IEEE80211_STATUS_CHALLENGE = 15,
489 IEEE80211_STATUS_TIMEOUT = 16,
490 IEEE80211_STATUS_TOOMANY = 17,
491 IEEE80211_STATUS_BASIC_RATE = 18,
492 IEEE80211_STATUS_SP_REQUIRED = 19,
493 IEEE80211_STATUS_PBCC_REQUIRED = 20,
494 IEEE80211_STATUS_CA_REQUIRED = 21,
495 IEEE80211_STATUS_TOO_MANY_STATIONS = 22,
496 IEEE80211_STATUS_RATES = 23,
497 IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25,
498 IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26,
501 #define IEEE80211_WEP_KEYLEN 5 /* 40bit */
502 #define IEEE80211_WEP_IVLEN 3 /* 24bit */
503 #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */
504 #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */
505 #define IEEE80211_WEP_NKID 4 /* number of key ids */
507 #define IEEE80211_CRC_LEN 4
510 * Maximum acceptable MTU is:
511 * IEEE80211_MAX_LEN - WEP overhead - CRC -
512 * QoS overhead - RSN/WPA overhead
513 * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default
514 * mtu is Ethernet-compatible; it's set by ether_ifattach.
516 #define IEEE80211_MTU_MAX 2290
517 #define IEEE80211_MTU_MIN 32
519 #define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \
520 (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
521 #define IEEE80211_MIN_LEN \
522 (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
525 * RTS frame length parameters. The default is specified in
526 * the 802.11 spec. The max may be wrong for jumbo frames.
528 #define IEEE80211_RTS_DEFAULT 512
529 #define IEEE80211_RTS_MIN 1
530 #define IEEE80211_RTS_MAX IEEE80211_MAX_LEN
533 IEEE80211_AUTH_NONE = 0,
534 IEEE80211_AUTH_OPEN = 1,
535 IEEE80211_AUTH_SHARED = 2,
538 #endif /* _NETPROTO_802_11_IEEE80211_H_ */