ieee80211.h revision 1.47
1/* $OpenBSD: ieee80211.h,v 1.47 2008/09/27 15:00:08 damien Exp $ */ 2/* $NetBSD: ieee80211.h,v 1.6 2004/04/30 23:51:53 dyoung Exp $ */ 3 4/*- 5 * Copyright (c) 2001 Atsushi Onoe 6 * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29#ifndef _NET80211_IEEE80211_H_ 30#define _NET80211_IEEE80211_H_ 31 32/* 33 * 802.11 protocol definitions. 34 */ 35 36#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ 37/* is 802.11 address multicast/broadcast? */ 38#define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01) 39 40/* 41 * Generic definitions for IEEE 802.11 frames. 42 */ 43struct ieee80211_frame { 44 u_int8_t i_fc[2]; 45 u_int8_t i_dur[2]; 46 u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 47 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 48 u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 49 u_int8_t i_seq[2]; 50} __packed; 51 52struct ieee80211_qosframe { 53 u_int8_t i_fc[2]; 54 u_int8_t i_dur[2]; 55 u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 56 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 57 u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 58 u_int8_t i_seq[2]; 59 u_int8_t i_qos[2]; 60} __packed; 61 62struct ieee80211_htframe { /* 11n */ 63 u_int8_t i_fc[2]; 64 u_int8_t i_dur[2]; 65 u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 66 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 67 u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 68 u_int8_t i_seq[2]; 69 u_int8_t i_qos[2]; 70 u_int8_t i_ht[4]; 71} __packed; 72 73struct ieee80211_frame_addr4 { 74 u_int8_t i_fc[2]; 75 u_int8_t i_dur[2]; 76 u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 77 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 78 u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 79 u_int8_t i_seq[2]; 80 u_int8_t i_addr4[IEEE80211_ADDR_LEN]; 81} __packed; 82 83struct ieee80211_qosframe_addr4 { 84 u_int8_t i_fc[2]; 85 u_int8_t i_dur[2]; 86 u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 87 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 88 u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 89 u_int8_t i_seq[2]; 90 u_int8_t i_addr4[IEEE80211_ADDR_LEN]; 91 u_int8_t i_qos[2]; 92} __packed; 93 94struct ieee80211_htframe_addr4 { /* 11n */ 95 u_int8_t i_fc[2]; 96 u_int8_t i_dur[2]; 97 u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 98 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 99 u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 100 u_int8_t i_seq[2]; 101 u_int8_t i_addr4[IEEE80211_ADDR_LEN]; 102 u_int8_t i_qos[2]; 103 u_int8_t i_ht[4]; 104} __packed; 105 106#define IEEE80211_FC0_VERSION_MASK 0x03 107#define IEEE80211_FC0_VERSION_SHIFT 0 108#define IEEE80211_FC0_VERSION_0 0x00 109#define IEEE80211_FC0_TYPE_MASK 0x0c 110#define IEEE80211_FC0_TYPE_SHIFT 2 111#define IEEE80211_FC0_TYPE_MGT 0x00 112#define IEEE80211_FC0_TYPE_CTL 0x04 113#define IEEE80211_FC0_TYPE_DATA 0x08 114 115#define IEEE80211_FC0_SUBTYPE_MASK 0xf0 116#define IEEE80211_FC0_SUBTYPE_SHIFT 4 117/* for TYPE_MGT */ 118#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 119#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 120#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 121#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 122#define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 123#define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 124#define IEEE80211_FC0_SUBTYPE_BEACON 0x80 125#define IEEE80211_FC0_SUBTYPE_ATIM 0x90 126#define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 127#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 128#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 129#define IEEE80211_FC0_SUBTYPE_ACTION 0xd0 130#define IEEE80211_FC0_SUBTYPE_ACTION_NOACK 0xe0 /* 11n */ 131/* for TYPE_CTL */ 132#define IEEE80211_FC0_SUBTYPE_WRAPPER 0x70 /* 11n */ 133#define IEEE80211_FC0_SUBTYPE_BAR 0x80 134#define IEEE80211_FC0_SUBTYPE_BA 0x90 135#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 136#define IEEE80211_FC0_SUBTYPE_RTS 0xb0 137#define IEEE80211_FC0_SUBTYPE_CTS 0xc0 138#define IEEE80211_FC0_SUBTYPE_ACK 0xd0 139#define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 140#define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 141/* for TYPE_DATA (bit combination) */ 142#define IEEE80211_FC0_SUBTYPE_DATA 0x00 143#define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 144#define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 145#define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 146#define IEEE80211_FC0_SUBTYPE_NODATA 0x40 147#define IEEE80211_FC0_SUBTYPE_CFACK 0x50 148#define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 149#define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 150#define IEEE80211_FC0_SUBTYPE_QOS 0x80 151 152#define IEEE80211_FC1_DIR_MASK 0x03 153#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ 154#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ 155#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ 156#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ 157 158#define IEEE80211_FC1_MORE_FRAG 0x04 159#define IEEE80211_FC1_RETRY 0x08 160#define IEEE80211_FC1_PWR_MGT 0x10 161#define IEEE80211_FC1_MORE_DATA 0x20 162#define IEEE80211_FC1_PROTECTED 0x40 163#define IEEE80211_FC1_WEP 0x40 /* pre-RSNA compat */ 164#define IEEE80211_FC1_ORDER 0x80 165 166/* 167 * Sequence Control field (see 7.1.3.4). 168 */ 169#define IEEE80211_SEQ_FRAG_MASK 0x000f 170#define IEEE80211_SEQ_FRAG_SHIFT 0 171#define IEEE80211_SEQ_SEQ_MASK 0xfff0 172#define IEEE80211_SEQ_SEQ_SHIFT 4 173 174#define IEEE80211_NWID_LEN 32 175#define IEEE80211_MMIE_LEN 18 /* 11w */ 176 177/* 178 * QoS Control field (see 7.1.3.5). 179 */ 180#define IEEE80211_QOS_TXOP 0xff00 181#define IEEE80211_QOS_AMSDU 0x0080 /* 11n */ 182#define IEEE80211_QOS_ACK_POLICY_NORMAL 0 183#define IEEE80211_QOS_ACK_POLICY_NOACK 1 184#define IEEE80211_QOS_ACK_POLICY_NOEXPLACK 2 185#define IEEE80211_QOS_ACK_POLICY_BA 3 186#define IEEE80211_QOS_ACK_POLICY_MASK 0x0060 187#define IEEE80211_QOS_ACK_POLICY_SHIFT 5 188#define IEEE80211_QOS_EOSP 0x0010 189#define IEEE80211_QOS_TID 0x000f 190 191/* 192 * Control frames. 193 */ 194struct ieee80211_frame_min { 195 u_int8_t i_fc[2]; 196 u_int8_t i_dur[2]; 197 u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 198 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 199 /* FCS */ 200} __packed; 201 202struct ieee80211_frame_rts { 203 u_int8_t i_fc[2]; 204 u_int8_t i_dur[2]; 205 u_int8_t i_ra[IEEE80211_ADDR_LEN]; 206 u_int8_t i_ta[IEEE80211_ADDR_LEN]; 207 /* FCS */ 208} __packed; 209 210struct ieee80211_frame_cts { 211 u_int8_t i_fc[2]; 212 u_int8_t i_dur[2]; 213 u_int8_t i_ra[IEEE80211_ADDR_LEN]; 214 /* FCS */ 215} __packed; 216 217struct ieee80211_frame_ack { 218 u_int8_t i_fc[2]; 219 u_int8_t i_dur[2]; 220 u_int8_t i_ra[IEEE80211_ADDR_LEN]; 221 /* FCS */ 222} __packed; 223 224struct ieee80211_frame_pspoll { 225 u_int8_t i_fc[2]; 226 u_int8_t i_aid[2]; 227 u_int8_t i_bssid[IEEE80211_ADDR_LEN]; 228 u_int8_t i_ta[IEEE80211_ADDR_LEN]; 229 /* FCS */ 230} __packed; 231 232struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */ 233 u_int8_t i_fc[2]; 234 u_int8_t i_dur[2]; /* should be zero */ 235 u_int8_t i_ra[IEEE80211_ADDR_LEN]; 236 u_int8_t i_bssid[IEEE80211_ADDR_LEN]; 237 /* FCS */ 238} __packed; 239 240#ifdef _KERNEL 241static __inline int 242ieee80211_has_seq(const struct ieee80211_frame *wh) 243{ 244 return (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) != 245 IEEE80211_FC0_TYPE_CTL; 246} 247 248static __inline int 249ieee80211_has_addr4(const struct ieee80211_frame *wh) 250{ 251 return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == 252 IEEE80211_FC1_DIR_DSTODS; 253} 254 255static __inline int 256ieee80211_has_qos(const struct ieee80211_frame *wh) 257{ 258 return (wh->i_fc[0] & 259 (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == 260 (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS); 261} 262 263static __inline int 264ieee80211_has_htc(const struct ieee80211_frame *wh) 265{ 266 return (wh->i_fc[1] & IEEE80211_FC1_ORDER) && 267 (ieee80211_has_qos(wh) || 268 (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == 269 IEEE80211_FC0_TYPE_MGT); 270} 271 272static __inline u_int16_t 273ieee80211_get_qos(const struct ieee80211_frame *wh) 274{ 275 const u_int8_t *frm; 276 277 if (ieee80211_has_addr4(wh)) 278 frm = ((const struct ieee80211_qosframe_addr4 *)wh)->i_qos; 279 else 280 frm = ((const struct ieee80211_qosframe *)wh)->i_qos; 281 282 return letoh16(*(const u_int16_t *)frm); 283} 284#endif /* _KERNEL */ 285 286/* 287 * Capability Information field (see 7.3.1.4). 288 */ 289#define IEEE80211_CAPINFO_ESS 0x0001 290#define IEEE80211_CAPINFO_IBSS 0x0002 291#define IEEE80211_CAPINFO_CF_POLLABLE 0x0004 292#define IEEE80211_CAPINFO_CF_POLLREQ 0x0008 293#define IEEE80211_CAPINFO_PRIVACY 0x0010 294#define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020 295#define IEEE80211_CAPINFO_PBCC 0x0040 296#define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080 297#define IEEE80211_CAPINFO_SPECTRUM_MGMT 0x0100 298#define IEEE80211_CAPINFO_QOS 0x0200 299#define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400 300#define IEEE80211_CAPINFO_APSD 0x0800 301/* bit 12 is reserved */ 302#define IEEE80211_CAPINFO_DSSSOFDM 0x2000 303#define IEEE80211_CAPINFO_DELAYED_B_ACK 0x4000 304#define IEEE80211_CAPINFO_IMMEDIATE_B_ACK 0x8000 305#define IEEE80211_CAPINFO_BITS \ 306 "\10\01ESS\02IBSS\03CF_POLLABLE\04CF_POLLREQ" \ 307 "\05PRIVACY\06SHORT_PREAMBLE\07PBCC\10CHNL_AGILITY" \ 308 "\11SPECTRUM_MGMT\12QOS\13SHORT_SLOTTIME\14APSD" \ 309 "\16DSSSOFDM\17DELAYED_B_ACK\20IMMEDIATE_B_ACK" 310 311/* 312 * Information elements (see Table 7-26). 313 */ 314enum { 315 IEEE80211_ELEMID_SSID = 0, 316 IEEE80211_ELEMID_RATES = 1, 317 IEEE80211_ELEMID_FHPARMS = 2, 318 IEEE80211_ELEMID_DSPARMS = 3, 319 IEEE80211_ELEMID_CFPARMS = 4, 320 IEEE80211_ELEMID_TIM = 5, 321 IEEE80211_ELEMID_IBSSPARMS = 6, 322 IEEE80211_ELEMID_COUNTRY = 7, 323 IEEE80211_ELEMID_QBSS_LOAD = 11, 324 IEEE80211_ELEMID_EDCAPARMS = 12, 325 IEEE80211_ELEMID_CHALLENGE = 16, 326 /* 17-31 reserved for challenge text extension */ 327 IEEE80211_ELEMID_ERP = 42, 328 IEEE80211_ELEMID_QOS_CAP = 46, 329 IEEE80211_ELEMID_RSN = 48, 330 IEEE80211_ELEMID_XRATES = 50, 331 IEEE80211_ELEMID_MMIE = 76, /* 11w */ 332 IEEE80211_ELEMID_ASSOC_CBT = 77, /* 11w */ 333 IEEE80211_ELEMID_TPC = 150, 334 IEEE80211_ELEMID_CCKM = 156, 335 IEEE80211_ELEMID_VENDOR = 221 /* vendor private */ 336}; 337 338/* 339 * Action field category values (see Table 7-24). 340 */ 341enum { 342 IEEE80211_CATEG_SPECTRUM = 0, 343 IEEE80211_CATEG_QOS = 1, 344 IEEE80211_CATEG_DLS = 2, 345 IEEE80211_CATEG_BA = 3, 346 IEEE80211_CATEG_HT = 7, /* 11n */ 347 IEEE80211_CATEG_SALT = 8 /* 11w */ 348}; 349 350/* 351 * Block Ack Action field values (see Table 7-54). 352 */ 353#define IEEE80211_ACTION_ADDBA_REQ 0 354#define IEEE80211_ACTION_ADDBA_RESP 1 355#define IEEE80211_ACTION_DELBA 2 356 357/* 358 * SALT Action field values (see Table 7.57l). 359 */ 360#define IEEE80211_ACTION_SALT_REQ 0 361#define IEEE80211_ACTION_SALT_RESP 1 362 363/* 364 * HT Action field values (see Table 7-57m). 365 */ 366#define IEEE80211_ACTION_NOTIFYCW 0 367 368#define IEEE80211_RATE_BASIC 0x80 369#define IEEE80211_RATE_VAL 0x7f 370#define IEEE80211_RATE_SIZE 8 /* 802.11 standard */ 371#define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */ 372 373/* 374 * ERP information element (see 7.3.2.13). 375 */ 376#define IEEE80211_ERP_NON_ERP_PRESENT 0x01 377#define IEEE80211_ERP_USE_PROTECTION 0x02 378#define IEEE80211_ERP_BARKER_MODE 0x04 379 380/* 381 * RSN capabilities (see 7.3.2.25.3). 382 */ 383#define IEEE80211_RSNCAP_PREAUTH 0x0001 384#define IEEE80211_RSNCAP_NOPAIRWISE 0x0002 385#define IEEE80211_RSNCAP_PTKSA_RCNT_MASK 0x000c 386#define IEEE80211_RSNCAP_PTKSA_RCNT_SHIFT 2 387#define IEEE80211_RSNCAP_GTKSA_RCNT_MASK 0x0030 388#define IEEE80211_RSNCAP_GTKSA_RCNT_SHIFT 4 389#define IEEE80211_RSNCAP_RCNT1 0 390#define IEEE80211_RSNCAP_RCNT2 1 391#define IEEE80211_RSNCAP_RCNT4 2 392#define IEEE80211_RSNCAP_RCNT16 3 393#define IEEE80211_RSNCAP_MFPR 0x0040 /* 11w */ 394#define IEEE80211_RSNCAP_MFPC 0x0080 /* 11w */ 395#define IEEE80211_RSNCAP_PEERKEYENA 0x0200 396#define IEEE80211_RSNCAP_SPPAMSDUC 0x0400 /* 11n */ 397#define IEEE80211_RSNCAP_SPPAMSDUR 0x0800 /* 11n */ 398 399/* 400 * EDCA Access Categories. 401 */ 402enum ieee80211_edca_ac { 403 EDCA_AC_BK = 1, /* Background */ 404 EDCA_AC_BE = 0, /* Best Effort */ 405 EDCA_AC_VI = 2, /* Video */ 406 EDCA_AC_VO = 3 /* Voice */ 407}; 408#define EDCA_NUM_AC 4 409 410/* number of TID values (traffic identifier) */ 411#define IEEE80211_NUM_TID 16 412 413/* Atheros private advanced capabilities info */ 414#define ATHEROS_CAP_TURBO_PRIME 0x01 415#define ATHEROS_CAP_COMPRESSION 0x02 416#define ATHEROS_CAP_FAST_FRAME 0x04 417/* bits 3-6 reserved */ 418#define ATHEROS_CAP_BOOST 0x80 419 420/*- 421 * Organizationally Unique Identifiers. 422 * See http://standards.ieee.org/regauth/oui/oui.txt for a list. 423 */ 424#define ATHEROS_OUI ((const u_int8_t[]){ 0x00, 0x03, 0x7f }) 425#define BROADCOM_OUI ((const u_int8_t[]){ 0x00, 0x90, 0x4c }) 426#define IEEE80211_OUI ((const u_int8_t[]){ 0x00, 0x0f, 0xac }) 427#define MICROSOFT_OUI ((const u_int8_t[]){ 0x00, 0x50, 0xf2 }) 428 429#define IEEE80211_AUTH_ALGORITHM(auth) \ 430 ((auth)[0] | ((auth)[1] << 8)) 431#define IEEE80211_AUTH_TRANSACTION(auth) \ 432 ((auth)[2] | ((auth)[3] << 8)) 433#define IEEE80211_AUTH_STATUS(auth) \ 434 ((auth)[4] | ((auth)[5] << 8)) 435 436/* 437 * Authentication Algorithm Number field (see 7.3.1.1). 438 */ 439#define IEEE80211_AUTH_ALG_OPEN 0x0000 440#define IEEE80211_AUTH_ALG_SHARED 0x0001 441#define IEEE80211_AUTH_ALG_LEAP 0x0080 442 443/* 444 * Authentication Transaction Sequence Number field (see 7.3.1.2). 445 */ 446enum { 447 IEEE80211_AUTH_OPEN_REQUEST = 1, 448 IEEE80211_AUTH_OPEN_RESPONSE = 2 449}; 450enum { 451 IEEE80211_AUTH_SHARED_REQUEST = 1, 452 IEEE80211_AUTH_SHARED_CHALLENGE = 2, 453 IEEE80211_AUTH_SHARED_RESPONSE = 3, 454 IEEE80211_AUTH_SHARED_PASS = 4 455}; 456 457/* 458 * Reason codes (see Table 22). 459 */ 460enum { 461 IEEE80211_REASON_UNSPECIFIED = 1, 462 IEEE80211_REASON_AUTH_EXPIRE = 2, 463 IEEE80211_REASON_AUTH_LEAVE = 3, 464 IEEE80211_REASON_ASSOC_EXPIRE = 4, 465 IEEE80211_REASON_ASSOC_TOOMANY = 5, 466 IEEE80211_REASON_NOT_AUTHED = 6, 467 IEEE80211_REASON_NOT_ASSOCED = 7, 468 IEEE80211_REASON_ASSOC_LEAVE = 8, 469 IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, 470 471 /* XXX the following two reason codes are not correct */ 472 IEEE80211_REASON_RSN_REQUIRED = 11, 473 IEEE80211_REASON_RSN_INCONSISTENT = 12, 474 475 IEEE80211_REASON_IE_INVALID = 13, 476 IEEE80211_REASON_MIC_FAILURE = 14, 477 IEEE80211_REASON_4WAY_TIMEOUT = 15, 478 IEEE80211_REASON_GROUP_TIMEOUT = 16, 479 IEEE80211_REASON_RSN_DIFFERENT_IE = 17, 480 IEEE80211_REASON_BAD_GROUP_CIPHER = 18, 481 IEEE80211_REASON_BAD_PAIRWISE_CIPHER = 19, 482 IEEE80211_REASON_BAD_AKMP = 20, 483 IEEE80211_REASON_RSN_IE_VER_UNSUP = 21, 484 IEEE80211_REASON_RSN_IE_BAD_CAP = 22, 485 486 IEEE80211_REASON_CIPHER_REJ_POLICY = 24, 487 IEEE80211_REASON_BAD_GROUP_MGMT_CIPHER = 25, /* 11w */ 488 IEEE80211_REASON_MFP_POLICY = 26 /* 11w */ 489}; 490 491/* 492 * Status codes (see Table 23). 493 */ 494enum { 495 IEEE80211_STATUS_SUCCESS = 0, 496 IEEE80211_STATUS_UNSPECIFIED = 1, 497 IEEE80211_STATUS_CAPINFO = 10, 498 IEEE80211_STATUS_NOT_ASSOCED = 11, 499 IEEE80211_STATUS_OTHER = 12, 500 IEEE80211_STATUS_ALG = 13, 501 IEEE80211_STATUS_SEQUENCE = 14, 502 IEEE80211_STATUS_CHALLENGE = 15, 503 IEEE80211_STATUS_TIMEOUT = 16, 504 IEEE80211_STATUS_TOOMANY = 17, 505 IEEE80211_STATUS_BASIC_RATE = 18, 506 IEEE80211_STATUS_SP_REQUIRED = 19, 507 IEEE80211_STATUS_PBCC_REQUIRED = 20, 508 IEEE80211_STATUS_CA_REQUIRED = 21, 509 IEEE80211_STATUS_TOO_MANY_STATIONS = 22, 510 IEEE80211_STATUS_RATES = 23, 511 IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, 512 IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26, 513 514 IEEE80211_STATUS_IE_INVALID = 40, 515 IEEE80211_STATUS_BAD_GROUP_CIPHER = 41, 516 IEEE80211_STATUS_BAD_PAIRWISE_CIPHER = 42, 517 IEEE80211_STATUS_BAD_AKMP = 43, 518 IEEE80211_STATUS_RSN_IE_VER_UNSUP = 44, 519 520 IEEE80211_STATUS_CIPHER_REJ_POLICY = 46, 521}; 522 523#define IEEE80211_WEP_KEYLEN 5 /* 40bit */ 524#define IEEE80211_WEP_NKID 4 /* number of key ids */ 525#define IEEE80211_CHALLENGE_LEN 128 526 527/* WEP header constants */ 528#define IEEE80211_WEP_IVLEN 3 /* 24bit */ 529#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ 530#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ 531#define IEEE80211_CRC_LEN 4 532#define IEEE80211_WEP_TOTLEN (IEEE80211_WEP_IVLEN + \ 533 IEEE80211_WEP_KIDLEN + \ 534 IEEE80211_WEP_CRCLEN) 535 536/* 537 * 802.11i defines an extended IV for use with non-WEP ciphers. 538 * When the EXTIV bit is set in the key id byte an additional 539 * 4 bytes immediately follow the IV for TKIP. For CCMP the 540 * EXTIV bit is likewise set but the 8 bytes represent the 541 * CCMP header rather than IV+extended-IV. 542 */ 543#define IEEE80211_WEP_EXTIV 0x20 544#define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */ 545#define IEEE80211_WEP_MICLEN 8 /* trailing MIC */ 546 547/* 548 * Maximum acceptable MTU is: 549 * IEEE80211_MAX_LEN - WEP overhead - CRC - 550 * QoS overhead - RSN/WPA overhead 551 * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default 552 * mtu is Ethernet-compatible; it's set by ether_ifattach. 553 */ 554#define IEEE80211_MTU_MAX 2290 555#define IEEE80211_MTU_MIN 32 556 557#define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \ 558 (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN)) 559#define IEEE80211_ACK_LEN \ 560 (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) 561#define IEEE80211_MIN_LEN \ 562 (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN) 563 564/* 565 * The 802.11 spec says at most 2007 stations may be 566 * associated at once. For most AP's this is way more 567 * than is feasible so we use a default of 1800. This 568 * number may be overridden by the driver and/or by 569 * user configuration. 570 */ 571#define IEEE80211_AID_MAX 2007 572#define IEEE80211_AID_DEF 1800 573#define IEEE80211_AID(b) ((b) &~ 0xc000) 574 575/* 576 * RTS frame length parameters. The default is specified in 577 * the 802.11 spec. The max may be wrong for jumbo frames. 578 */ 579#define IEEE80211_RTS_DEFAULT 512 580#define IEEE80211_RTS_MIN 1 581#define IEEE80211_RTS_MAX IEEE80211_MAX_LEN 582 583#define IEEE80211_PLCP_SERVICE 0x00 584#define IEEE80211_PLCP_SERVICE_PBCC 0x08 /* PBCC encoded */ 585#define IEEE80211_PLCP_SERVICE_LENEXT 0x80 /* length extension bit */ 586 587/* One Time Unit (TU) is 1Kus = 1024 microseconds. */ 588#define IEEE80211_DUR_TU 1024 589 590/* IEEE 802.11b durations for DSSS PHY in microseconds */ 591#define IEEE80211_DUR_DS_LONG_PREAMBLE 144 592#define IEEE80211_DUR_DS_SHORT_PREAMBLE 72 593#define IEEE80211_DUR_DS_PREAMBLE_DIFFERENCE \ 594 (IEEE80211_DUR_DS_LONG_PREAMBLE - IEEE80211_DUR_DS_SHORT_PREAMBLE) 595#define IEEE80211_DUR_DS_FAST_PLCPHDR 24 596#define IEEE80211_DUR_DS_SLOW_PLCPHDR 48 597#define IEEE80211_DUR_DS_PLCPHDR_DIFFERENCE \ 598 (IEEE80211_DUR_DS_SLOW_PLCPHDR - IEEE80211_DUR_DS_FAST_PLCPHDR) 599#define IEEE80211_DUR_DS_SLOW_ACK 112 600#define IEEE80211_DUR_DS_FAST_ACK 56 601#define IEEE80211_DUR_DS_SLOW_CTS 112 602#define IEEE80211_DUR_DS_FAST_CTS 56 603#define IEEE80211_DUR_DS_SLOT 20 604#define IEEE80211_DUR_DS_SIFS 10 605#define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT) 606#define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \ 607 2 * IEEE80211_DUR_DS_SLOT) 608#define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \ 609 IEEE80211_DUR_DS_SLOW_ACK + \ 610 IEEE80211_DUR_DS_LONG_PREAMBLE + \ 611 IEEE80211_DUR_DS_SLOW_PLCPHDR + \ 612 IEEE80211_DUR_DIFS) 613 614/* 615 * The RSNA key descriptor used by IEEE 802.11 does not use the IEEE 802.1X 616 * key descriptor. Instead, it uses the key descriptor described in 8.5.2. 617 */ 618#define EAPOL_KEY_NONCE_LEN 32 619#define EAPOL_KEY_IV_LEN 16 620#define EAPOL_KEY_MIC_LEN 16 621 622struct ieee80211_eapol_key { 623 u_int8_t version; 624#define EAPOL_VERSION 1 625 626 u_int8_t type; 627/* IEEE Std 802.1X-2004, 7.5.4 (only type EAPOL-Key is used here) */ 628#define EAP_PACKET 0 629#define EAPOL_START 1 630#define EAPOL_LOGOFF 2 631#define EAPOL_KEY 3 632#define EAPOL_ASF_ALERT 4 633 634 u_int8_t len[2]; 635 u_int8_t desc; 636/* IEEE Std 802.1X-2004, 7.6.1 */ 637#define EAPOL_KEY_DESC_RC4 1 /* deprecated */ 638#define EAPOL_KEY_DESC_IEEE80211 2 639#define EAPOL_KEY_DESC_WPA 254 /* non-standard WPA */ 640 641 u_int8_t info[2]; 642#define EAPOL_KEY_VERSION_MASK 0x7 643#define EAPOL_KEY_DESC_V1 1 644#define EAPOL_KEY_DESC_V2 2 645#define EAPOL_KEY_DESC_V3 3 /* 11r */ 646#define EAPOL_KEY_PAIRWISE (1 << 3) 647#define EAPOL_KEY_INSTALL (1 << 6) /* I */ 648#define EAPOL_KEY_KEYACK (1 << 7) /* A */ 649#define EAPOL_KEY_KEYMIC (1 << 8) /* M */ 650#define EAPOL_KEY_SECURE (1 << 9) /* S */ 651#define EAPOL_KEY_ERROR (1 << 10) 652#define EAPOL_KEY_REQUEST (1 << 11) 653#define EAPOL_KEY_ENCRYPTED (1 << 12) 654#define EAPOL_KEY_SMK (1 << 13) 655/* WPA compatibility */ 656#define EAPOL_KEY_WPA_KID_MASK 0x3 657#define EAPOL_KEY_WPA_KID_SHIFT 4 658#define EAPOL_KEY_WPA_TX EAPOL_KEY_INSTALL 659 660 u_int8_t keylen[2]; 661 u_int8_t replaycnt[8]; 662 u_int8_t nonce[EAPOL_KEY_NONCE_LEN]; 663 u_int8_t iv[EAPOL_KEY_IV_LEN]; 664 u_int8_t rsc[8]; 665 u_int8_t reserved[8]; 666 u_int8_t mic[EAPOL_KEY_MIC_LEN]; 667 u_int8_t paylen[2]; 668} __packed; 669 670/* Pairwise Transient Key (see 8.5.1.2) */ 671struct ieee80211_ptk { 672 u_int8_t kck[16]; /* Key Confirmation Key */ 673 u_int8_t kek[16]; /* Key Encryption Key */ 674 u_int8_t tk[32]; /* Temporal Key */ 675} __packed; 676 677#define IEEE80211_PMKID_LEN 16 678#define IEEE80211_SMKID_LEN 16 679 680/* 681 * Key Data Encapsulation (see Table 62). 682 */ 683enum { 684 IEEE80211_KDE_GTK = 1, 685 IEEE80211_KDE_MACADDR = 3, 686 IEEE80211_KDE_PMKID = 4, 687 IEEE80211_KDE_SMK = 5, 688 IEEE80211_KDE_NONCE = 6, 689 IEEE80211_KDE_LIFETIME = 7, 690 IEEE80211_KDE_ERROR = 8, 691 IEEE80211_KDE_IGTK = 9 /* 11w */ 692}; 693 694#endif /* _NET80211_IEEE80211_H_ */ 695