1 /* $OpenBSD: if_ieee80211.h,v 1.10 2004/01/07 00:13:22 fgsch Exp $ */ 2 /* $NetBSD: if_ieee80211.h,v 1.36 2003/07/06 20:54:24 dyoung Exp $ */ 3 4 /*- 5 * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by the NetBSD 19 * Foundation, Inc. and its contributors. 20 * 4. Neither the name of The NetBSD Foundation nor the names of its 21 * contributors may be used to endorse or promote products derived 22 * from this software without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * POSSIBILITY OF SUCH DAMAGE. 35 */ 36 37 #ifndef _NET_IF_IEEE80211_H_ 38 #define _NET_IF_IEEE80211_H_ 39 40 #define IEEE80211_ADDR_LEN ETHER_ADDR_LEN 41 42 /* IEEE 802.11 PLCP header */ 43 struct ieee80211_plcp_hdr { 44 u_int16_t i_sfd; /* IEEE80211_PLCP_SFD */ 45 u_int8_t i_signal; /* MPDU data rate in 100Kb/s */ 46 u_int8_t i_service; /* IEEE80211_PLCP_SERVICE */ 47 u_int16_t i_length; /* MPDU duration in microseconds */ 48 u_int16_t i_crc; /* CRC16 of i_signal, i_service, 49 * i_length 50 */ 51 } __packed; 52 53 #define IEEE80211_PLCP_SFD 0xF3A0 54 #define IEEE80211_PLCP_SERVICE 0x00 55 56 /* 57 * generic definitions for IEEE 802.11 frames 58 */ 59 struct ieee80211_frame { 60 u_int8_t i_fc[2]; 61 u_int8_t i_dur[2]; 62 u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 63 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 64 u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 65 u_int8_t i_seq[2]; 66 /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ 67 /* see below */ 68 }; 69 70 struct ieee80211_frame_addr4 { 71 u_int8_t i_fc[2]; 72 u_int8_t i_dur[2]; 73 u_int8_t i_addr1[IEEE80211_ADDR_LEN]; 74 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 75 u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 76 u_int8_t i_seq[2]; 77 u_int8_t i_addr4[IEEE80211_ADDR_LEN]; 78 }; 79 80 #define IEEE80211_FC0_VERSION_MASK 0x03 81 #define IEEE80211_FC0_VERSION_SHIFT 0 82 #define IEEE80211_FC0_VERSION_0 0x00 83 #define IEEE80211_FC0_TYPE_MASK 0x0c 84 #define IEEE80211_FC0_TYPE_SHIFT 2 85 #define IEEE80211_FC0_TYPE_MGT 0x00 86 #define IEEE80211_FC0_TYPE_CTL 0x04 87 #define IEEE80211_FC0_TYPE_DATA 0x08 88 89 #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 90 #define IEEE80211_FC0_SUBTYPE_SHIFT 4 91 /* for TYPE_MGT */ 92 #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 93 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 94 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 95 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 96 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 97 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 98 #define IEEE80211_FC0_SUBTYPE_BEACON 0x80 99 #define IEEE80211_FC0_SUBTYPE_ATIM 0x90 100 #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 101 #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 102 #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 103 /* for TYPE_CTL */ 104 #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 105 #define IEEE80211_FC0_SUBTYPE_RTS 0xb0 106 #define IEEE80211_FC0_SUBTYPE_CTS 0xc0 107 #define IEEE80211_FC0_SUBTYPE_ACK 0xd0 108 #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 109 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 110 /* for TYPE_DATA (bit combination) */ 111 #define IEEE80211_FC0_SUBTYPE_DATA 0x00 112 #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 113 #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 114 #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 115 #define IEEE80211_FC0_SUBTYPE_NODATA 0x40 116 #define IEEE80211_FC0_SUBTYPE_CFACK 0x50 117 #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 118 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_POLL 0x70 119 120 #define IEEE80211_FC1_DIR_MASK 0x03 121 #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ 122 #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ 123 #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ 124 #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ 125 126 #define IEEE80211_FC1_MORE_FRAG 0x04 127 #define IEEE80211_FC1_RETRY 0x08 128 #define IEEE80211_FC1_PWR_MGT 0x10 129 #define IEEE80211_FC1_MORE_DATA 0x20 130 #define IEEE80211_FC1_WEP 0x40 131 #define IEEE80211_FC1_ORDER 0x80 132 133 #define IEEE80211_SEQ_FRAG_MASK 0x000f 134 #define IEEE80211_SEQ_FRAG_SHIFT 0 135 #define IEEE80211_SEQ_SEQ_MASK 0xfff0 136 #define IEEE80211_SEQ_SEQ_SHIFT 4 137 138 #define IEEE80211_NWID_LEN 32 139 140 /* 141 * BEACON management packets 142 * 143 * octet timestamp[8] 144 * octet beacon interval[2] 145 * octet capability information[2] 146 * information element 147 * octet elemid 148 * octet length 149 * octet information[length] 150 */ 151 152 typedef uint8_t *ieee80211_mgt_beacon_t; 153 154 #define IEEE80211_BEACON_INTERVAL(beacon) \ 155 ((beacon)[8] | ((beacon)[9] << 8)) 156 #define IEEE80211_BEACON_CAPABILITY(beacon) \ 157 ((beacon)[10] | ((beacon)[11] << 8)) 158 159 #define IEEE80211_CAPINFO_ESS 0x0001 160 #define IEEE80211_CAPINFO_IBSS 0x0002 161 #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004 162 #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008 163 #define IEEE80211_CAPINFO_PRIVACY 0x0010 164 #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020 165 #define IEEE80211_CAPINFO_PBCC 0x0040 166 #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080 167 #define IEEE80211_CAPINFO_BITS "\20\01ESS\02IBSS\03POLLABLE\04POLLREQ\05PRIVACY\06SHORT_PREAMBLE\07PBCC\08CHNL_AGILITY" 168 169 #define IEEE80211_RATE_BASIC 0x80 170 #define IEEE80211_RATE_VAL 0x7f 171 172 /* One Time Unit (TU) is 1Kus = 1024 microseconds. */ 173 #define IEEE80211_DUR_TU 1024 174 175 /* IEEE 802.11b durations for DSSS PHY in microseconds */ 176 #define IEEE80211_DUR_DS_LONG_PREAMBLE 144 177 #define IEEE80211_DUR_DS_SHORT_PREAMBLE 72 178 #define IEEE80211_DUR_DS_FAST_PLCPHDR 24 179 #define IEEE80211_DUR_DS_SLOW_PLCPHDR 48 180 #define IEEE80211_DUR_DS_SLOW_ACK 112 181 #define IEEE80211_DUR_DS_FAST_ACK 56 182 #define IEEE80211_DUR_DS_SLOW_CTS 112 183 #define IEEE80211_DUR_DS_FAST_CTS 56 184 #define IEEE80211_DUR_DS_SLOT 20 185 #define IEEE80211_DUR_DS_SIFS 10 186 #define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT) 187 #define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \ 188 2 * IEEE80211_DUR_DS_SLOT) 189 #define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \ 190 IEEE80211_DUR_DS_SLOW_ACK + \ 191 IEEE80211_DUR_DS_LONG_PREAMBLE + \ 192 IEEE80211_DUR_DS_SLOW_PLCPHDR + \ 193 IEEE80211_DUR_DIFS) 194 195 /* 196 * Management information elements 197 */ 198 199 struct ieee80211_information { 200 char ssid[IEEE80211_NWID_LEN+1]; 201 struct rates { 202 u_int8_t *p; 203 } rates; 204 struct fh { 205 u_int16_t dwell; 206 u_int8_t set; 207 u_int8_t pattern; 208 u_int8_t index; 209 } fh; 210 struct ds { 211 u_int8_t channel; 212 } ds; 213 struct cf { 214 u_int8_t count; 215 u_int8_t period; 216 u_int8_t maxdur[2]; 217 u_int8_t dur[2]; 218 } cf; 219 struct tim { 220 u_int8_t count; 221 u_int8_t period; 222 u_int8_t bitctl; 223 /* u_int8_t pvt[251]; The driver needs to use this. */ 224 } tim; 225 struct ibss { 226 u_int16_t atim; 227 } ibss; 228 struct challenge { 229 u_int8_t *p; 230 u_int8_t len; 231 } challenge; 232 }; 233 234 #define IEEE80211_ELEMID_SSID 0 235 #define IEEE80211_ELEMID_RATES 1 236 #define IEEE80211_ELEMID_FHPARMS 2 237 #define IEEE80211_ELEMID_DSPARMS 3 238 #define IEEE80211_ELEMID_CFPARMS 4 239 #define IEEE80211_ELEMID_TIM 5 240 #define IEEE80211_ELEMID_IBSSPARMS 6 241 #define IEEE80211_ELEMID_CHALLENGE 16 242 243 /* 244 * AUTH management packets 245 * 246 * octet algo[2] 247 * octet seq[2] 248 * octet status[2] 249 * octet chal.id 250 * octet chal.length 251 * octet chal.text[253] 252 */ 253 254 typedef u_int8_t *ieee80211_mgt_auth_t; 255 256 #define IEEE80211_AUTH_ALGORITHM(auth) \ 257 ((auth)[0] | ((auth)[1] << 8)) 258 #define IEEE80211_AUTH_TRANSACTION(auth) \ 259 ((auth)[2] | ((auth)[3] << 8)) 260 #define IEEE80211_AUTH_STATUS(auth) \ 261 ((auth)[4] | ((auth)[5] << 8)) 262 263 #define IEEE80211_AUTH_ALG_OPEN 0x0000 264 #define IEEE80211_AUTH_ALG_SHARED 0x0001 265 266 #define IEEE80211_AUTH_OPEN_REQUEST 1 267 #define IEEE80211_AUTH_OPEN_RESPONSE 2 268 269 #define IEEE80211_AUTH_SHARED_REQUEST 1 270 #define IEEE80211_AUTH_SHARED_CHALLENGE 2 271 #define IEEE80211_AUTH_SHARED_RESPONSE 3 272 #define IEEE80211_AUTH_SHARED_PASS 4 273 274 /* 275 * Reason codes 276 * 277 * Unlisted codes are reserved 278 */ 279 280 #define IEEE80211_REASON_UNSPECIFIED 1 281 #define IEEE80211_REASON_AUTH_EXPIRE 2 282 #define IEEE80211_REASON_AUTH_LEAVE 3 283 #define IEEE80211_REASON_ASSOC_EXPIRE 4 284 #define IEEE80211_REASON_ASSOC_TOOMANY 5 285 #define IEEE80211_REASON_NOT_AUTHED 6 286 #define IEEE80211_REASON_NOT_ASSOCED 7 287 #define IEEE80211_REASON_ASSOC_LEAVE 8 288 #define IEEE80211_REASON_ASSOC_NOT_AUTHED 9 289 290 #define IEEE80211_STATUS_SUCCESS 0 291 #define IEEE80211_STATUS_UNSPECIFIED 1 292 #define IEEE80211_STATUS_CAPINFO 10 293 #define IEEE80211_STATUS_NOT_ASSOCED 11 294 #define IEEE80211_STATUS_OTHER 12 295 #define IEEE80211_STATUS_ALG 13 296 #define IEEE80211_STATUS_SEQUENCE 14 297 #define IEEE80211_STATUS_CHALLENGE 15 298 #define IEEE80211_STATUS_TIMEOUT 16 299 #define IEEE80211_STATUS_TOOMANY 17 300 #define IEEE80211_STATUS_BASIC_RATE 18 301 #define IEEE80211_STATUS_SP_REQUIRED 19 302 #define IEEE80211_STATUS_PBCC_REQUIRED 20 303 #define IEEE80211_STATUS_CA_REQUIRED 21 304 #define IEEE80211_STATUS_TOO_MANY_STATIONS 22 305 #define IEEE80211_STATUS_RATES 23 306 307 #define IEEE80211_WEP_KEYLEN 5 /* 40bit */ 308 #define IEEE80211_WEP_IVLEN 3 /* 24bit */ 309 #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ 310 #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ 311 #define IEEE80211_WEP_NKID 4 /* number of key ids */ 312 313 #define IEEE80211_CRC_LEN 4 314 315 #define IEEE80211_MTU 1500 316 #define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \ 317 (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN)) 318 319 #define IEEE80211_MAX_AID 2007 320 321 #define IEEE80211_AID_SET(b, w) \ 322 ((w)[((b) & ~0xc000) / 32] |= (1 << (((b) & ~0xc000) % 32))) 323 #define IEEE80211_AID_CLR(b, w) \ 324 ((w)[((b) & ~0xc000) / 32] &= ~(1 << (((b) & ~0xc000) % 32))) 325 #define IEEE80211_AID_ISSET(b, w) \ 326 ((w)[((b) & ~0xc000) / 32] & (1 << (((b) & ~0xc000) % 32))) 327 328 329 /* 330 * ioctls 331 */ 332 333 /* nwid is pointed at by ifr.ifr_data */ 334 struct ieee80211_nwid { 335 u_int8_t i_len; 336 u_int8_t i_nwid[IEEE80211_NWID_LEN]; 337 }; 338 339 #define SIOCS80211NWID _IOWR('i', 230, struct ifreq) 340 #define SIOCG80211NWID _IOWR('i', 231, struct ifreq) 341 342 /* the first member must be matched with struct ifreq */ 343 struct ieee80211_nwkey { 344 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 345 int i_wepon; /* wep enabled flag */ 346 int i_defkid; /* default encrypt key id */ 347 struct { 348 int i_keylen; 349 u_int8_t *i_keydat; 350 } i_key[IEEE80211_WEP_NKID]; 351 }; 352 #define SIOCS80211NWKEY _IOW('i', 232, struct ieee80211_nwkey) 353 #define SIOCG80211NWKEY _IOWR('i', 233, struct ieee80211_nwkey) 354 /* i_wepon */ 355 #define IEEE80211_NWKEY_OPEN 0 /* No privacy */ 356 #define IEEE80211_NWKEY_WEP 1 /* WEP enabled */ 357 #define IEEE80211_NWKEY_EAP 2 /* EAP enabled */ 358 #define IEEE80211_NWKEY_PERSIST 0x100 /* designate persist keyset */ 359 360 /* power management parameters */ 361 struct ieee80211_power { 362 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 363 int i_enabled; /* 1 == on, 0 == off */ 364 int i_maxsleep; /* max sleep in ms */ 365 }; 366 #define SIOCS80211POWER _IOW('i', 234, struct ieee80211_power) 367 #define SIOCG80211POWER _IOWR('i', 235, struct ieee80211_power) 368 369 struct ieee80211_auth { 370 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 371 int i_authtype; 372 }; 373 374 #define IEEE80211_AUTH_NONE 0 375 #define IEEE80211_AUTH_OPEN 1 376 #define IEEE80211_AUTH_SHARED 2 377 378 #define SIOCS80211AUTH _IOW('i', 236, struct ieee80211_auth) 379 #define SIOCG80211AUTH _IOWR('i', 237, struct ieee80211_auth) 380 381 struct ieee80211_channel { 382 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 383 u_int16_t i_channel; 384 }; 385 386 #define IEEE80211_CHAN_ANY 0xffff 387 388 #define SIOCS80211CHANNEL _IOW('i', 238, struct ieee80211_channel) 389 #define SIOCG80211CHANNEL _IOWR('i', 239, struct ieee80211_channel) 390 391 struct ieee80211_bssid { 392 char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ 393 u_int8_t i_bssid[IEEE80211_ADDR_LEN]; 394 }; 395 396 #define SIOCS80211BSSID _IOW('i', 240, struct ieee80211_bssid) 397 #define SIOCG80211BSSID _IOWR('i', 241, struct ieee80211_bssid) 398 399 #ifdef _KERNEL 400 401 #define IEEE80211_ASCAN_WAIT 2 /* active scan wait */ 402 #define IEEE80211_PSCAN_WAIT 5 /* passive scan wait */ 403 #define IEEE80211_TRANS_WAIT 5 /* transition wait */ 404 #define IEEE80211_INACT_WAIT 5 /* inactivity timer interval */ 405 #define IEEE80211_INACT_MAX (300/IEEE80211_INACT_WAIT) 406 407 /* 408 * Structure for IEEE 802.11 drivers. 409 */ 410 411 #define IEEE80211_CHAN_MAX 255 412 #define IEEE80211_RATE_SIZE 12 413 #define IEEE80211_KEYBUF_SIZE 16 414 #define IEEE80211_NODE_HASHSIZE 32 415 /* simple hash is enough for variation of macaddr */ 416 #define IEEE80211_NODE_HASH(addr) \ 417 (((u_int8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % IEEE80211_NODE_HASHSIZE) 418 419 enum ieee80211_phytype { 420 IEEE80211_T_DS, 421 IEEE80211_T_FH, 422 IEEE80211_T_OFDM 423 }; 424 425 enum ieee80211_opmode { 426 IEEE80211_M_STA = 1, /* infrastructure station */ 427 IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */ 428 IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */ 429 IEEE80211_M_HOSTAP = 6, /* Software Access Point */ 430 IEEE80211_M_MONITOR = 8 /* Monitor mode (doesn't correspond 431 to a PRISM port like the others) */ 432 }; 433 434 enum ieee80211_state { 435 IEEE80211_S_INIT, /* default state */ 436 IEEE80211_S_SCAN, /* scanning */ 437 IEEE80211_S_AUTH, /* try to authenticate */ 438 IEEE80211_S_ASSOC, /* try to assoc */ 439 IEEE80211_S_RUN /* associated */ 440 }; 441 442 /* 443 * Node specific information. 444 */ 445 struct ieee80211_node { 446 TAILQ_ENTRY(ieee80211_node) ni_list; 447 LIST_ENTRY(ieee80211_node) ni_hash; 448 449 /* hardware */ 450 u_int8_t ni_rssi; 451 u_int32_t ni_rstamp; 452 453 /* header */ 454 u_int8_t ni_macaddr[IEEE80211_ADDR_LEN]; 455 u_int8_t ni_bssid[IEEE80211_ADDR_LEN]; 456 457 /* beacon, probe response */ 458 u_int8_t ni_tstamp[8]; 459 u_int16_t ni_intval; 460 u_int16_t ni_capinfo; 461 u_int8_t ni_esslen; 462 u_int8_t ni_essid[IEEE80211_NWID_LEN]; 463 int ni_nrate; 464 u_int8_t ni_rates[IEEE80211_RATE_SIZE]; 465 u_int8_t ni_chan; 466 u_int16_t ni_fhdwell; /* FH only */ 467 u_int8_t ni_fhindex; /* FH only */ 468 469 /* power saving mode */ 470 471 u_int8_t ni_pwrsave; 472 struct ifqueue ni_savedq; /* packets queued for pspoll */ 473 474 /* others */ 475 u_int16_t ni_associd; /* assoc response */ 476 u_int16_t ni_txseq; /* seq to be transmitted */ 477 u_int16_t ni_rxseq; /* seq previous received */ 478 int ni_fails; /* failure count to associate */ 479 int ni_inact; /* inactivity mark count */ 480 int ni_txrate; /* index to ni_rates[] */ 481 void *ni_private; /* driver private */ 482 }; 483 484 /* ni_chan encoding for FH phy */ 485 #define IEEE80211_FH_CHANMOD 80 486 #define IEEE80211_FH_CHAN(set,pat) (((set)-1)*IEEE80211_FH_CHANMOD+(pat)) 487 #define IEEE80211_FH_CHANSET(chan) ((chan)/IEEE80211_FH_CHANMOD+1) 488 #define IEEE80211_FH_CHANPAT(chan) ((chan)%IEEE80211_FH_CHANMOD) 489 490 #define IEEE80211_PS_SLEEP 0x1 /* STA is in power saving mode */ 491 492 #define IEEE80211_PS_MAX_QUEUE 50 /* maximum saved packets */ 493 494 struct ieee80211_wepkey { 495 int wk_len; 496 u_int8_t wk_key[IEEE80211_KEYBUF_SIZE]; 497 }; 498 499 struct ieee80211com { 500 #ifdef __NetBSD__ 501 struct ethercom ic_ec; 502 #endif 503 #ifdef __FreeBSD__ 504 struct arpcom ic_ac; 505 struct mtx ic_mtx; 506 #endif 507 #ifdef __OpenBSD__ 508 struct arpcom ic_ac; 509 #endif 510 void (*ic_recv_mgmt[16])(struct ieee80211com *, 511 struct mbuf *, int, u_int32_t); 512 int (*ic_send_mgmt[16])(struct ieee80211com *, 513 struct ieee80211_node *, int, int); 514 int (*ic_newstate)(void *, enum ieee80211_state); 515 int (*ic_chancheck)(void *, u_char *); 516 int (*ic_set_tim)(struct ieee80211com *, int, int); 517 u_int8_t ic_myaddr[IEEE80211_ADDR_LEN]; 518 u_int8_t ic_sup_rates[IEEE80211_RATE_SIZE]; 519 u_char ic_chan_avail[roundup(IEEE80211_CHAN_MAX,NBBY)]; 520 u_char ic_chan_active[roundup(IEEE80211_CHAN_MAX, NBBY)]; 521 u_char ic_chan_scan[roundup(IEEE80211_CHAN_MAX, NBBY)]; 522 struct ifqueue ic_mgtq; 523 struct ifqueue ic_pwrsaveq; 524 int ic_flags; 525 int ic_hdrlen; /* either 0 or extended header 526 * length, e.g. for addr4 527 */ 528 529 enum ieee80211_phytype ic_phytype; 530 enum ieee80211_opmode ic_opmode; 531 enum ieee80211_state ic_state; 532 caddr_t ic_rawbpf; /* packet filter structure */ 533 struct ieee80211_node ic_bss; /* information for this node */ 534 int ic_node_privlen;/* size for ni_private */ 535 void (*ic_node_free)(struct ieee80211com *, 536 struct ieee80211_node *); /* callback */ 537 u_int8_t ic_ibss_chan; 538 int ic_fixed_rate; /* index to ic_sup_rates[] */ 539 TAILQ_HEAD(, ieee80211_node) ic_node; /* information of all nodes */ 540 LIST_HEAD(, ieee80211_node) ic_hash[IEEE80211_NODE_HASHSIZE]; 541 u_int16_t ic_lintval; /* listen interval */ 542 int ic_mgt_timer; /* mgmt timeout */ 543 int ic_scan_timer; /* scant wait */ 544 int ic_inact_timer; /* inactivity timer wait */ 545 int ic_des_esslen; 546 u_int8_t ic_des_essid[IEEE80211_NWID_LEN]; 547 int ic_des_chan; /* desired channel */ 548 u_int8_t ic_des_bssid[IEEE80211_ADDR_LEN]; 549 struct ieee80211_wepkey ic_nw_keys[IEEE80211_WEP_NKID]; 550 int ic_wep_txkey; /* default tx key index */ 551 void *ic_wep_ctx; /* wep crypt context */ 552 int ic_iv_flag; 553 u_int32_t ic_iv; /* initial vector for wep */ 554 u_int32_t ic_aid_bitmap[IEEE80211_MAX_AID / 32 + 1]; 555 u_int16_t ic_max_aid; 556 struct ifmedia ic_media; 557 }; 558 #ifdef __NetBSD__ 559 #define ic_if ic_ec.ec_if 560 #endif 561 #if defined(__FreeBSD__) || defined(__OpenBSD__) 562 #define ic_if ic_ac.ac_if 563 #endif 564 #define ic_softc ic_if.if_softc 565 566 #define IEEE80211_HEADER_LEN(ic) (((ic)->ic_hdrlen > 0) \ 567 ? (ic)->ic_hdrlen : sizeof(struct ieee80211_frame)) 568 569 #define IEEE80211_SEND_MGMT(ic,ni,type,arg) do { \ 570 if ((ic)->ic_send_mgmt[(type)>>IEEE80211_FC0_SUBTYPE_SHIFT] != NULL) \ 571 (*(ic)->ic_send_mgmt[(type)>>IEEE80211_FC0_SUBTYPE_SHIFT]) \ 572 (ic,ni,type,arg); \ 573 } while (/*CONSTCOND*/ 0) 574 575 #define IEEE80211_ADDR_EQ(a1,a2) (memcmp(a1,a2,IEEE80211_ADDR_LEN) == 0) 576 #define IEEE80211_ADDR_COPY(dst,src) memcpy(dst,src,IEEE80211_ADDR_LEN) 577 578 #define IEEE80211_IS_MULTICAST(a) ETHER_IS_MULTICAST(a) 579 580 /* ic_flags */ 581 #define IEEE80211_F_ASCAN 0x00000001 /* STATUS: active scan */ 582 #define IEEE80211_F_SIBSS 0x00000002 /* STATUS: start IBSS */ 583 #define IEEE80211_F_WEPON 0x00000100 /* CONF: WEP enabled */ 584 #define IEEE80211_F_IBSSON 0x00000200 /* CONF: IBSS creation enable */ 585 #define IEEE80211_F_PMGTON 0x00000400 /* CONF: Power mgmt enable */ 586 #define IEEE80211_F_DESBSSID 0x00000800 /* CONF: des_bssid is set */ 587 #define IEEE80211_F_SCANAP 0x00001000 /* CONF: Scanning AP */ 588 #define IEEE80211_F_HASWEP 0x00010000 /* CAPABILITY: WEP available */ 589 #define IEEE80211_F_HASIBSS 0x00020000 /* CAPABILITY: IBSS available */ 590 #define IEEE80211_F_HASPMGT 0x00040000 /* CAPABILITY: Power mgmt */ 591 #define IEEE80211_F_HASHOSTAP 0x00080000 /* CAPABILITY: HOSTAP avail */ 592 #define IEEE80211_F_HASAHDEMO 0x00100000 /* CAPABILITY: Old Adhoc Demo */ 593 #define IEEE80211_F_HASMONITOR 0x00200000 /* CAPABILITY: Monitor mode */ 594 595 /* flags for ieee80211_fix_rate() */ 596 #define IEEE80211_F_DOSORT 0x00000001 /* sort rate list */ 597 #define IEEE80211_F_DOFRATE 0x00000002 /* use fixed rate */ 598 #define IEEE80211_F_DONEGO 0x00000004 /* calc negotiated rate */ 599 #define IEEE80211_F_DODEL 0x00000008 /* delete ignore rate */ 600 601 void ieee80211_ifattach(struct ifnet *); 602 void ieee80211_ifdetach(struct ifnet *); 603 void ieee80211_input(struct ifnet *, struct mbuf *, int, u_int32_t); 604 int ieee80211_mgmt_output(struct ifnet *, struct ieee80211_node *, 605 struct mbuf *, int); 606 struct mbuf *ieee80211_encap(struct ifnet *, struct mbuf *); 607 struct mbuf *ieee80211_decap(struct ifnet *, struct mbuf *); 608 int ieee80211_ioctl(struct ifnet *, u_long, caddr_t); 609 void ieee80211_print_essid(u_int8_t *, int); 610 void ieee80211_dump_pkt(u_int8_t *, int, int, int); 611 void ieee80211_watchdog(struct ifnet *); 612 void ieee80211_next_scan(struct ifnet *); 613 void ieee80211_end_scan(struct ifnet *); 614 void ieee80211_create_ibss(struct ieee80211com *); 615 int ieee80211_match_bss(struct ieee80211com *, struct ieee80211_node *); 616 int ieee80211_get_rate(struct ieee80211com *); 617 int ieee80211_get_channel(struct ieee80211com *); 618 struct ieee80211_node *ieee80211_alloc_node(struct ieee80211com *, u_int8_t *, 619 int); 620 struct ieee80211_node *ieee80211_find_node(struct ieee80211com *, u_int8_t *); 621 void ieee80211_free_node(struct ieee80211com *, struct ieee80211_node *); 622 void ieee80211_free_allnodes(struct ieee80211com *); 623 int ieee80211_fix_rate(struct ieee80211com *, struct ieee80211_node *, int); 624 int ieee80211_new_state(struct ifnet *, enum ieee80211_state, int); 625 struct mbuf *ieee80211_wep_crypt(struct ifnet *, struct mbuf *, int); 626 int ieee80211_rate2media(int, enum ieee80211_phytype); 627 int ieee80211_media2rate(int, enum ieee80211_phytype); 628 629 int ieee80211_cfgget(struct ifnet *, u_long, caddr_t); 630 int ieee80211_cfgset(struct ifnet *, u_long, caddr_t); 631 632 void ieee80211_pwrsave(struct ieee80211com *, struct ieee80211_node *, 633 struct mbuf *); 634 635 int ieee80211_media_change(struct ifnet *); 636 void ieee80211_media_status(struct ifnet *, struct ifmediareq *); 637 638 #endif /* _KERNEL */ 639 640 #endif /* _NET_IF_IEEE80211_H_ */ 641