ieee80211.h revision 1.9 1 /* $NetBSD: ieee80211.h,v 1.9 2004/12/23 05:25:41 dyoung Exp $ */
2 /*-
3 * Copyright (c) 2001 Atsushi Onoe
4 * Copyright (c) 2002-2004 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 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * Alternatively, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") version 2 as published by the Free
20 * Software Foundation.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.5 2004/04/05 17:47:40 sam Exp $
34 */
35 #ifndef _NET80211_IEEE80211_H_
36 #define _NET80211_IEEE80211_H_
37
38 /*
39 * 802.11 protocol definitions.
40 */
41
42 #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
43 /* is 802.11 address multicast/broadcast? */
44 #define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01)
45
46 /* IEEE 802.11 PLCP header */
47 struct ieee80211_plcp_hdr {
48 u_int16_t i_sfd;
49 u_int8_t i_signal;
50 u_int8_t i_service;
51 u_int16_t i_length;
52 u_int16_t i_crc;
53 } __attribute__((__packed__));
54
55 #define IEEE80211_PLCP_SFD 0xF3A0
56 #define IEEE80211_PLCP_SERVICE 0x00
57 #define IEEE80211_PLCP_SERVICE_PBCC 0x08 /* PBCC encoded */
58 #define IEEE80211_PLCP_SERVICE_LENEXT 0x80 /* length extension bit */
59
60 /*
61 * generic definitions for IEEE 802.11 frames
62 */
63 struct ieee80211_frame {
64 u_int8_t i_fc[2];
65 u_int8_t i_dur[2];
66 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
67 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
68 u_int8_t i_addr3[IEEE80211_ADDR_LEN];
69 u_int8_t i_seq[2];
70 /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
71 /* see below */
72 } __attribute__((__packed__));
73
74 struct ieee80211_qosframe {
75 u_int8_t i_fc[2];
76 u_int8_t i_dur[2];
77 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
78 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
79 u_int8_t i_addr3[IEEE80211_ADDR_LEN];
80 u_int8_t i_seq[2];
81 u_int8_t i_qos[2];
82 /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
83 /* see below */
84 } __attribute__((__packed__));
85
86 struct ieee80211_qoscntl {
87 u_int8_t i_qos[2];
88 };
89
90 struct ieee80211_frame_addr4 {
91 u_int8_t i_fc[2];
92 u_int8_t i_dur[2];
93 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
94 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
95 u_int8_t i_addr3[IEEE80211_ADDR_LEN];
96 u_int8_t i_seq[2];
97 u_int8_t i_addr4[IEEE80211_ADDR_LEN];
98 } __attribute__((__packed__));
99
100
101 struct ieee80211_qosframe_addr4 {
102 u_int8_t i_fc[2];
103 u_int8_t i_dur[2];
104 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
105 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
106 u_int8_t i_addr3[IEEE80211_ADDR_LEN];
107 u_int8_t i_seq[2];
108 u_int8_t i_addr4[IEEE80211_ADDR_LEN];
109 u_int8_t i_qos[2];
110 } __attribute__((__packed__));
111
112 #define IEEE80211_FC0_VERSION_MASK 0x03
113 #define IEEE80211_FC0_VERSION_SHIFT 0
114 #define IEEE80211_FC0_VERSION_0 0x00
115 #define IEEE80211_FC0_TYPE_MASK 0x0c
116 #define IEEE80211_FC0_TYPE_SHIFT 2
117 #define IEEE80211_FC0_TYPE_MGT 0x00
118 #define IEEE80211_FC0_TYPE_CTL 0x04
119 #define IEEE80211_FC0_TYPE_DATA 0x08
120
121 #define IEEE80211_FC0_SUBTYPE_MASK 0xf0
122 #define IEEE80211_FC0_SUBTYPE_SHIFT 4
123 /* for TYPE_MGT */
124 #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
125 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
126 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
127 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
128 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
129 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
130 #define IEEE80211_FC0_SUBTYPE_BEACON 0x80
131 #define IEEE80211_FC0_SUBTYPE_ATIM 0x90
132 #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
133 #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
134 #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
135 /* for TYPE_CTL */
136 #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
137 #define IEEE80211_FC0_SUBTYPE_RTS 0xb0
138 #define IEEE80211_FC0_SUBTYPE_CTS 0xc0
139 #define IEEE80211_FC0_SUBTYPE_ACK 0xd0
140 #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
141 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
142 /* for TYPE_DATA (bit combination) */
143 #define IEEE80211_FC0_SUBTYPE_DATA 0x00
144 #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
145 #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
146 #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
147 #define IEEE80211_FC0_SUBTYPE_NODATA 0x40
148 #define IEEE80211_FC0_SUBTYPE_CFACK 0x50
149 #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60
150 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
151 #define IEEE80211_FC0_SUBTYPE_QOS 0x80
152
153 #define IEEE80211_FC1_DIR_MASK 0x03
154 #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
155 #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
156 #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
157 #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
158
159 #define IEEE80211_FC1_MORE_FRAG 0x04
160 #define IEEE80211_FC1_RETRY 0x08
161 #define IEEE80211_FC1_PWR_MGT 0x10
162 #define IEEE80211_FC1_MORE_DATA 0x20
163 #define IEEE80211_FC1_WEP 0x40
164 #define IEEE80211_FC1_ORDER 0x80
165
166 #define IEEE80211_SEQ_FRAG_MASK 0x000f
167 #define IEEE80211_SEQ_FRAG_SHIFT 0
168 #define IEEE80211_SEQ_SEQ_MASK 0xfff0
169 #define IEEE80211_SEQ_SEQ_SHIFT 4
170
171 #define IEEE80211_NWID_LEN 32
172
173 #define IEEE80211_QOS_TXOP 0x00ff
174 /* bit 8 is reserved */
175 #define IEEE80211_QOS_ACKPOLICY 0x0600
176 #define IEEE80211_QOS_ESOP 0x0800
177 #define IEEE80211_QOS_TID 0xf000
178
179 /*
180 * WME/802.11e information element.
181 */
182 struct ieee80211_ie_wme {
183 u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */
184 u_int8_t wme_len; /* length in bytes */
185 u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */
186 u_int8_t wme_type; /* OUI type */
187 u_int8_t wme_subtype; /* OUI subtype */
188 u_int8_t wme_version; /* spec revision */
189 u_int8_t wme_info; /* AC info */
190 } __attribute__((__packed__));
191
192 /*
193 * WME/802.11e Tspec Element
194 */
195 struct ieee80211_wme_tspec {
196 u_int8_t ts_id;
197 u_int8_t ts_len;
198 u_int8_t ts_oui[3];
199 u_int8_t ts_oui_type;
200 u_int8_t ts_oui_subtype;
201 u_int8_t ts_version;
202 u_int8_t ts_tsinfo[3];
203 u_int8_t ts_nom_msdu[2];
204 u_int8_t ts_max_msdu[2];
205 u_int8_t ts_min_svc[4];
206 u_int8_t ts_max_svc[4];
207 u_int8_t ts_inactv_intv[4];
208 u_int8_t ts_susp_intv[4];
209 u_int8_t ts_start_svc[4];
210 u_int8_t ts_min_rate[4];
211 u_int8_t ts_mean_rate[4];
212 u_int8_t ts_max_burst[4];
213 u_int8_t ts_min_phy[4];
214 u_int8_t ts_peak_rate[4];
215 u_int8_t ts_delay[4];
216 u_int8_t ts_surplus[2];
217 u_int8_t ts_medium_time[2];
218 } __attribute__((__packed__));
219
220 /*
221 * Management Notification Frame
222 */
223 struct ieee80211_mnf {
224 u_int8_t mnf_category;
225 u_int8_t mnf_action;
226 u_int8_t mnf_dialog;
227 u_int8_t mnf_status;
228 } __attribute__((__packed__));
229 #define MNF_SETUP_REQ 0
230 #define MNF_SETUP_RESP 1
231 #define MNF_TEARDOWN 2
232
233 /*
234 * Control frames.
235 */
236 struct ieee80211_frame_min {
237 u_int8_t i_fc[2];
238 u_int8_t i_dur[2];
239 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
240 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
241 /* FCS */
242 } __attribute__((__packed__));
243
244 struct ieee80211_frame_rts {
245 u_int8_t i_fc[2];
246 u_int8_t i_dur[2];
247 u_int8_t i_ra[IEEE80211_ADDR_LEN];
248 u_int8_t i_ta[IEEE80211_ADDR_LEN];
249 /* FCS */
250 } __attribute__((__packed__));
251
252 struct ieee80211_frame_cts {
253 u_int8_t i_fc[2];
254 u_int8_t i_dur[2];
255 u_int8_t i_ra[IEEE80211_ADDR_LEN];
256 /* FCS */
257 } __attribute__((__packed__));
258
259 struct ieee80211_frame_ack {
260 u_int8_t i_fc[2];
261 u_int8_t i_dur[2];
262 u_int8_t i_ra[IEEE80211_ADDR_LEN];
263 /* FCS */
264 } __attribute__((__packed__));
265
266 struct ieee80211_frame_pspoll {
267 u_int8_t i_fc[2];
268 u_int8_t i_aid[2];
269 u_int8_t i_bssid[IEEE80211_ADDR_LEN];
270 u_int8_t i_ta[IEEE80211_ADDR_LEN];
271 /* FCS */
272 } __attribute__((__packed__));
273
274 struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */
275 u_int8_t i_fc[2];
276 u_int8_t i_dur[2]; /* should be zero */
277 u_int8_t i_ra[IEEE80211_ADDR_LEN];
278 u_int8_t i_bssid[IEEE80211_ADDR_LEN];
279 /* FCS */
280 } __attribute__((__packed__));
281
282 /*
283 * BEACON management packets
284 *
285 * octet timestamp[8]
286 * octet beacon interval[2]
287 * octet capability information[2]
288 * information element
289 * octet elemid
290 * octet length
291 * octet information[length]
292 */
293
294 typedef u_int8_t *ieee80211_mgt_beacon_t;
295
296 #define IEEE80211_BEACON_INTERVAL(beacon) \
297 ((beacon)[8] | ((beacon)[9] << 8))
298 #define IEEE80211_BEACON_CAPABILITY(beacon) \
299 ((beacon)[10] | ((beacon)[11] << 8))
300
301 #define IEEE80211_CAPINFO_ESS 0x0001
302 #define IEEE80211_CAPINFO_IBSS 0x0002
303 #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004
304 #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008
305 #define IEEE80211_CAPINFO_PRIVACY 0x0010
306 #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020
307 #define IEEE80211_CAPINFO_PBCC 0x0040
308 #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080
309 /* bits 8-9 are reserved */
310 #define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400
311 #define IEEE80211_CAPINFO_RSN 0x0800
312 /* bit 12 is reserved */
313 #define IEEE80211_CAPINFO_DSSSOFDM 0x2000
314 /* bits 14-15 are reserved */
315
316 /*
317 * 802.11i/WPA information element (maximally sized).
318 */
319 struct ieee80211_ie_wpa {
320 u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */
321 u_int8_t wpa_len; /* length in bytes */
322 u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */
323 u_int8_t wpa_type; /* OUI type */
324 u_int16_t wpa_version; /* spec revision */
325 u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */
326 u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */
327 u_int32_t wpa_uciphers[8];/* ciphers */
328 u_int16_t wpa_authselcnt; /* authentication selector cnt*/
329 u_int32_t wpa_authsels[8];/* selectors */
330 u_int16_t wpa_caps; /* 802.11i capabilities */
331 u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */
332 u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */
333 } __attribute__((__packed__));
334
335 /*
336 * Management information element payloads
337 */
338 union ieee80211_information {
339 char ssid[IEEE80211_NWID_LEN+1];
340 struct rates {
341 u_int8_t *p;
342 } rates;
343 struct fh {
344 u_int16_t dwell;
345 u_int8_t set;
346 u_int8_t pattern;
347 u_int8_t index;
348 } fh;
349 struct ds {
350 u_int8_t channel;
351 } ds;
352 struct cf {
353 u_int8_t count;
354 u_int8_t period;
355 u_int8_t maxdur[2];
356 u_int8_t dur[2];
357 } cf;
358 struct tim {
359 u_int8_t count;
360 u_int8_t period;
361 u_int8_t bitctl;
362 /* u_int8_t pvt[251]; The driver needs to use this. */
363 } tim;
364 struct ibss {
365 u_int16_t atim;
366 } ibss;
367 struct challenge {
368 u_int8_t *p;
369 u_int8_t len;
370 } challenge;
371 struct erp {
372 u_int8_t flags;
373 } erp;
374 struct country {
375 u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */
376 struct {
377 u_int8_t schan; /* starting channel */
378 u_int8_t nchan; /* number channels */
379 u_int8_t maxtxpwr;
380 } band[4]; /* up to 4 sub bands */
381 } country;
382 struct ath {
383 u_int8_t flags;
384 } ath;
385 };
386
387 enum {
388 IEEE80211_ELEMID_SSID = 0,
389 IEEE80211_ELEMID_RATES = 1,
390 IEEE80211_ELEMID_FHPARMS = 2,
391 IEEE80211_ELEMID_DSPARMS = 3,
392 IEEE80211_ELEMID_CFPARMS = 4,
393 IEEE80211_ELEMID_TIM = 5,
394 IEEE80211_ELEMID_IBSSPARMS = 6,
395 IEEE80211_ELEMID_COUNTRY = 7,
396 IEEE80211_ELEMID_CHALLENGE = 16,
397 /* 17-31 reserved for challenge text extension */
398 IEEE80211_ELEMID_ERP = 42,
399 IEEE80211_ELEMID_RSN = 48,
400 IEEE80211_ELEMID_XRATES = 50,
401 IEEE80211_ELEMID_TPC = 150,
402 IEEE80211_ELEMID_CCKM = 156,
403 IEEE80211_ELEMID_VENDOR = 221, /* vendor private */
404 };
405
406 #define IEEE80211_CHALLENGE_LEN 128
407
408 #define IEEE80211_RATE_BASIC 0x80
409 #define IEEE80211_RATE_VAL 0x7f
410
411 /* EPR information element flags */
412 #define IEEE80211_ERP_NON_ERP_PRESENT 0x01
413 #define IEEE80211_ERP_USE_PROTECTION 0x02
414 #define IEEE80211_ERP_LONG_PREAMBLE 0x04
415
416 /* Atheros private advanced capabilities info */
417 #define ATHEROS_CAP_TURBO_PRIME 0x01
418 #define ATHEROS_CAP_COMPRESSION 0x02
419 #define ATHEROS_CAP_FAST_FRAME 0x04
420 /* bits 3-6 reserved */
421 #define ATHEROS_CAP_BOOST 0x80
422
423 #define ATH_OUI 0x7f0300 /* Atheros OUI */
424 #define ATH_OUI_TYPE 0x01
425 #define ATH_OUI_VERSION 0x01
426
427 #define WPA_OUI 0xf25000
428 #define WPA_OUI_TYPE 0x01
429 #define WPA_VERSION 1 /* current supported version */
430
431 #define WPA_CSE_NULL 0x00
432 #define WPA_CSE_WEP40 0x01
433 #define WPA_CSE_TKIP 0x02
434 #define WPA_CSE_CCMP 0x04
435 #define WPA_CSE_WEP104 0x05
436
437 #define WPA_ASE_NONE 0x00
438 #define WPA_ASE_8021X_UNSPEC 0x01
439 #define WPA_ASE_8021X_PSK 0x02
440
441 #define RSN_OUI 0xac0f00
442 #define RSN_VERSION 1 /* current supported version */
443
444 #define RSN_CSE_NULL 0x00
445 #define RSN_CSE_WEP40 0x01
446 #define RSN_CSE_TKIP 0x02
447 #define RSN_CSE_WRAP 0x03
448 #define RSN_CSE_CCMP 0x04
449 #define RSN_CSE_WEP104 0x05
450
451 #define RSN_ASE_NONE 0x00
452 #define RSN_ASE_8021X_UNSPEC 0x01
453 #define RSN_ASE_8021X_PSK 0x02
454
455 #define WME_OUI 0xf25000
456 #define WME_OUI_TYPE 0x02
457 #define WME_VERSION 1
458
459 /* WME stream classes */
460 #define WME_AC_BE 0 /* best effort */
461 #define WME_AC_BK 1 /* background */
462 #define WME_AC_VI 2 /* video */
463 #define WME_AC_VO 3 /* voice */
464
465 /*
466 * AUTH management packets
467 *
468 * octet algo[2]
469 * octet seq[2]
470 * octet status[2]
471 * octet chal.id
472 * octet chal.length
473 * octet chal.text[253]
474 */
475
476 typedef u_int8_t *ieee80211_mgt_auth_t;
477
478 #define IEEE80211_AUTH_ALGORITHM(auth) \
479 ((auth)[0] | ((auth)[1] << 8))
480 #define IEEE80211_AUTH_TRANSACTION(auth) \
481 ((auth)[2] | ((auth)[3] << 8))
482 #define IEEE80211_AUTH_STATUS(auth) \
483 ((auth)[4] | ((auth)[5] << 8))
484
485 #define IEEE80211_AUTH_ALG_OPEN 0x0000
486 #define IEEE80211_AUTH_ALG_SHARED 0x0001
487 #define IEEE80211_AUTH_ALG_LEAP 0x0080
488
489 enum {
490 IEEE80211_AUTH_OPEN_REQUEST = 1,
491 IEEE80211_AUTH_OPEN_RESPONSE = 2,
492 };
493
494 enum {
495 IEEE80211_AUTH_SHARED_REQUEST = 1,
496 IEEE80211_AUTH_SHARED_CHALLENGE = 2,
497 IEEE80211_AUTH_SHARED_RESPONSE = 3,
498 IEEE80211_AUTH_SHARED_PASS = 4,
499 };
500
501 /*
502 * Reason codes
503 *
504 * Unlisted codes are reserved
505 */
506
507 enum {
508 IEEE80211_REASON_UNSPECIFIED = 1,
509 IEEE80211_REASON_AUTH_EXPIRE = 2,
510 IEEE80211_REASON_AUTH_LEAVE = 3,
511 IEEE80211_REASON_ASSOC_EXPIRE = 4,
512 IEEE80211_REASON_ASSOC_TOOMANY = 5,
513 IEEE80211_REASON_NOT_AUTHED = 6,
514 IEEE80211_REASON_NOT_ASSOCED = 7,
515 IEEE80211_REASON_ASSOC_LEAVE = 8,
516 IEEE80211_REASON_ASSOC_NOT_AUTHED = 9,
517
518 IEEE80211_REASON_RSN_REQUIRED = 11,
519 IEEE80211_REASON_RSN_INCONSISTENT = 12,
520 IEEE80211_REASON_IE_INVALID = 13,
521 IEEE80211_REASON_MIC_FAILURE = 14,
522
523 IEEE80211_STATUS_SUCCESS = 0,
524 IEEE80211_STATUS_UNSPECIFIED = 1,
525 IEEE80211_STATUS_CAPINFO = 10,
526 IEEE80211_STATUS_NOT_ASSOCED = 11,
527 IEEE80211_STATUS_OTHER = 12,
528 IEEE80211_STATUS_ALG = 13,
529 IEEE80211_STATUS_SEQUENCE = 14,
530 IEEE80211_STATUS_CHALLENGE = 15,
531 IEEE80211_STATUS_TIMEOUT = 16,
532 IEEE80211_STATUS_TOOMANY = 17,
533 IEEE80211_STATUS_BASIC_RATE = 18,
534 IEEE80211_STATUS_SP_REQUIRED = 19,
535 IEEE80211_STATUS_PBCC_REQUIRED = 20,
536 IEEE80211_STATUS_CA_REQUIRED = 21,
537 IEEE80211_STATUS_TOO_MANY_STATIONS = 22,
538 IEEE80211_STATUS_RATES = 23,
539 IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25,
540 IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26,
541 };
542
543 #define IEEE80211_WEP_KEYLEN 5 /* 40bit */
544 #define IEEE80211_WEP_NKID 4 /* number of key ids */
545
546 /* WEP header constants */
547 #define IEEE80211_WEP_IVLEN 3 /* 24bit */
548 #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */
549 #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */
550 #define IEEE80211_WEP_TOTLEN (IEEE80211_WEP_IVLEN + \
551 IEEE80211_WEP_KIDLEN + \
552 IEEE80211_WEP_CRCLEN)
553 /*
554 * 802.11i defines an extended IV for use with non-WEP ciphers.
555 * When the EXTIV bit is set in the key id byte an additional
556 * 4 bytes immediately follow the IV for TKIP. For CCMP the
557 * EXTIV bit is likewise set but the 8 bytes represent the
558 * CCMP header rather than IV+extended-IV.
559 */
560 #define IEEE80211_WEP_EXTIV 0x20
561 #define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */
562 #define IEEE80211_WEP_MICLEN 8 /* trailing MIC */
563
564 #define IEEE80211_CRC_LEN 4
565
566 /*
567 * Maximum acceptable MTU is:
568 * IEEE80211_MAX_LEN - WEP overhead - CRC -
569 * QoS overhead - RSN/WPA overhead
570 * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default
571 * mtu is Ethernet-compatible; it's set by ether_ifattach.
572 */
573 #define IEEE80211_MTU_MAX 2290
574 #define IEEE80211_MTU_MIN 32
575
576 #define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \
577 (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
578 #define IEEE80211_ACK_LEN \
579 (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
580 #define IEEE80211_MIN_LEN \
581 (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
582
583 /*
584 * The 802.11 spec says at most 2007 stations may be
585 * associated at once. For most AP's this is way more
586 * than is feasible so we use a default of 128. This
587 * number may be overridden by the driver and/or by
588 * user configuration.
589 */
590 #define IEEE80211_AID_MAX 2007
591 #define IEEE80211_AID_DEF 128
592
593 #define IEEE80211_AID(b) ((b) &~ 0xc000)
594 #define IEEE80211_AID_SET(b, w) \
595 ((w)[IEEE80211_AID(b) / 32] |= (1 << (IEEE80211_AID(b) % 32)))
596 #define IEEE80211_AID_CLR(b, w) \
597 ((w)[IEEE80211_AID(b) / 32] &= ~(1 << (IEEE80211_AID(b) % 32)))
598 #define IEEE80211_AID_ISSET(b, w) \
599 ((w)[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32)))
600
601 /*
602 * RTS frame length parameters. The default is specified in
603 * the 802.11 spec. The max may be wrong for jumbo frames.
604 */
605 #define IEEE80211_RTS_DEFAULT 512
606 #define IEEE80211_RTS_MIN 1
607 #define IEEE80211_RTS_MAX IEEE80211_MAX_LEN
608
609 /*
610 * 802.11 frame duration definitions.
611 */
612
613 struct ieee80211_duration {
614 uint16_t d_rts_dur;
615 uint16_t d_data_dur;
616 uint16_t d_plcp_len;
617 uint8_t d_plcp_svc;
618 };
619
620 /* One Time Unit (TU) is 1Kus = 1024 microseconds. */
621 #define IEEE80211_DUR_TU 1024
622
623 /* IEEE 802.11b durations for DSSS PHY in microseconds */
624 #define IEEE80211_DUR_DS_LONG_PREAMBLE 144
625 #define IEEE80211_DUR_DS_SHORT_PREAMBLE 72
626 #define IEEE80211_DUR_DS_PREAMBLE_DIFFERENCE \
627 (IEEE80211_DUR_DS_LONG_PREAMBLE - IEEE80211_DUR_DS_SHORT_PREAMBLE)
628 #define IEEE80211_DUR_DS_FAST_PLCPHDR 24
629 #define IEEE80211_DUR_DS_SLOW_PLCPHDR 48
630 #define IEEE80211_DUR_DS_PLCPHDR_DIFFERENCE \
631 (IEEE80211_DUR_DS_SLOW_PLCPHDR - IEEE80211_DUR_DS_FAST_PLCPHDR)
632 #define IEEE80211_DUR_DS_SLOW_ACK 112
633 #define IEEE80211_DUR_DS_FAST_ACK 56
634 #define IEEE80211_DUR_DS_SLOW_CTS 112
635 #define IEEE80211_DUR_DS_FAST_CTS 56
636 #define IEEE80211_DUR_DS_SLOT 20
637 #define IEEE80211_DUR_DS_SIFS 10
638 #define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT)
639 #define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \
640 2 * IEEE80211_DUR_DS_SLOT)
641 #define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \
642 IEEE80211_DUR_DS_SLOW_ACK + \
643 IEEE80211_DUR_DS_LONG_PREAMBLE + \
644 IEEE80211_DUR_DS_SLOW_PLCPHDR + \
645 IEEE80211_DUR_DIFS)
646
647 enum {
648 IEEE80211_AUTH_NONE = 0,
649 IEEE80211_AUTH_OPEN = 1, /* open */
650 IEEE80211_AUTH_SHARED = 2, /* shared-key */
651 IEEE80211_AUTH_8021X = 3, /* 802.1x */
652 IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */
653 /* NB: these are used only for ioctls */
654 IEEE80211_AUTH_WPA = 5, /* WPA w/ 802.1x */
655 IEEE80211_AUTH_WPA_PSK = 6, /* WPA w/ preshared key */
656 IEEE80211_AUTH_WPA2 = 7, /* WPA2 w/ 802.1x */
657 IEEE80211_AUTH_WPA2_PSK = 8, /* WPA2 w/ preshared key */
658 };
659
660 #endif /* _NET80211_IEEE80211_H_ */
661