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