1*0ba2cbe9Sxc151355 /* 2*0ba2cbe9Sxc151355 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 3*0ba2cbe9Sxc151355 * Use is subject to license terms. 4*0ba2cbe9Sxc151355 */ 5*0ba2cbe9Sxc151355 6*0ba2cbe9Sxc151355 /* 7*0ba2cbe9Sxc151355 * Copyright (c) 2001 Atsushi Onoe 8*0ba2cbe9Sxc151355 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting 9*0ba2cbe9Sxc151355 * All rights reserved. 10*0ba2cbe9Sxc151355 * 11*0ba2cbe9Sxc151355 * Redistribution and use in source and binary forms, with or without 12*0ba2cbe9Sxc151355 * modification, are permitted provided that the following conditions 13*0ba2cbe9Sxc151355 * are met: 14*0ba2cbe9Sxc151355 * 1. Redistributions of source code must retain the above copyright 15*0ba2cbe9Sxc151355 * notice, this list of conditions and the following disclaimer. 16*0ba2cbe9Sxc151355 * 2. Redistributions in binary form must reproduce the above copyright 17*0ba2cbe9Sxc151355 * notice, this list of conditions and the following disclaimer in the 18*0ba2cbe9Sxc151355 * documentation and/or other materials provided with the distribution. 19*0ba2cbe9Sxc151355 * 3. The name of the author may not be used to endorse or promote products 20*0ba2cbe9Sxc151355 * derived from this software without specific prior written permission. 21*0ba2cbe9Sxc151355 * 22*0ba2cbe9Sxc151355 * Alternatively, this software may be distributed under the terms of the 23*0ba2cbe9Sxc151355 * GNU General Public License ("GPL") version 2 as published by the Free 24*0ba2cbe9Sxc151355 * Software Foundation. 25*0ba2cbe9Sxc151355 * 26*0ba2cbe9Sxc151355 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 27*0ba2cbe9Sxc151355 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 28*0ba2cbe9Sxc151355 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 29*0ba2cbe9Sxc151355 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 30*0ba2cbe9Sxc151355 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31*0ba2cbe9Sxc151355 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32*0ba2cbe9Sxc151355 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33*0ba2cbe9Sxc151355 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34*0ba2cbe9Sxc151355 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35*0ba2cbe9Sxc151355 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36*0ba2cbe9Sxc151355 */ 37*0ba2cbe9Sxc151355 38*0ba2cbe9Sxc151355 #pragma ident "%Z%%M% %I% %E% SMI" 39*0ba2cbe9Sxc151355 40*0ba2cbe9Sxc151355 #ifndef _SYS_NET80211_H 41*0ba2cbe9Sxc151355 #define _SYS_NET80211_H 42*0ba2cbe9Sxc151355 43*0ba2cbe9Sxc151355 #include <sys/mac.h> 44*0ba2cbe9Sxc151355 #include <sys/ethernet.h> 45*0ba2cbe9Sxc151355 #include <sys/net80211_proto.h> 46*0ba2cbe9Sxc151355 #include <sys/net80211_crypto.h> 47*0ba2cbe9Sxc151355 48*0ba2cbe9Sxc151355 /* 49*0ba2cbe9Sxc151355 * IEEE802.11 kernel support module 50*0ba2cbe9Sxc151355 */ 51*0ba2cbe9Sxc151355 52*0ba2cbe9Sxc151355 #ifdef __cplusplus 53*0ba2cbe9Sxc151355 extern "C" { 54*0ba2cbe9Sxc151355 #endif 55*0ba2cbe9Sxc151355 56*0ba2cbe9Sxc151355 /* ic_caps */ 57*0ba2cbe9Sxc151355 #define IEEE80211_C_WEP 0x00000001 /* CAPABILITY: WEP available */ 58*0ba2cbe9Sxc151355 #define IEEE80211_C_TKIP 0x00000002 /* CAPABILITY: TKIP available */ 59*0ba2cbe9Sxc151355 #define IEEE80211_C_AES 0x00000004 /* CAPABILITY: AES OCB avail */ 60*0ba2cbe9Sxc151355 #define IEEE80211_C_AES_CCM 0x00000008 /* CAPABILITY: AES CCM avail */ 61*0ba2cbe9Sxc151355 #define IEEE80211_C_CKIP 0x00000010 /* CAPABILITY: CKIP available */ 62*0ba2cbe9Sxc151355 #define IEEE80211_C_FF 0x00000040 /* CAPABILITY: ATH FF avail */ 63*0ba2cbe9Sxc151355 #define IEEE80211_C_TURBOP 0x00000080 64*0ba2cbe9Sxc151355 /* CAPABILITY: ATH Turbo available */ 65*0ba2cbe9Sxc151355 #define IEEE80211_C_IBSS 0x00000100 /* CAPABILITY: IBSS available */ 66*0ba2cbe9Sxc151355 #define IEEE80211_C_PMGT 0x00000200 /* CAPABILITY: Power mgmt */ 67*0ba2cbe9Sxc151355 #define IEEE80211_C_HOSTAP 0x00000400 /* CAPABILITY: HOSTAP avail */ 68*0ba2cbe9Sxc151355 #define IEEE80211_C_AHDEMO 0x00000800 /* CAPABILITY: Old Adhoc Demo */ 69*0ba2cbe9Sxc151355 #define IEEE80211_C_SWRETRY 0x00001000 /* CAPABILITY: sw tx retry */ 70*0ba2cbe9Sxc151355 #define IEEE80211_C_TXPMGT 0x00002000 /* CAPABILITY: tx power mgmt */ 71*0ba2cbe9Sxc151355 #define IEEE80211_C_SHSLOT 0x00004000 /* CAPABILITY: short slottime */ 72*0ba2cbe9Sxc151355 #define IEEE80211_C_SHPREAMBLE 0x00008000 /* CAPABILITY: short preamble */ 73*0ba2cbe9Sxc151355 #define IEEE80211_C_MONITOR 0x00010000 /* CAPABILITY: monitor mode */ 74*0ba2cbe9Sxc151355 #define IEEE80211_C_TKIPMIC 0x00020000 /* CAPABILITY: TKIP MIC avail */ 75*0ba2cbe9Sxc151355 #define IEEE80211_C_WPA1 0x00800000 /* CAPABILITY: WPA1 avail */ 76*0ba2cbe9Sxc151355 #define IEEE80211_C_WPA2 0x01000000 /* CAPABILITY: WPA2 avail */ 77*0ba2cbe9Sxc151355 #define IEEE80211_C_WPA 0x01800000 78*0ba2cbe9Sxc151355 /* CAPABILITY: WPA1+WPA2 avail */ 79*0ba2cbe9Sxc151355 #define IEEE80211_C_BURST 0x02000000 /* CAPABILITY: frame bursting */ 80*0ba2cbe9Sxc151355 #define IEEE80211_C_WME 0x04000000 /* CAPABILITY: WME avail */ 81*0ba2cbe9Sxc151355 #define IEEE80211_C_WDS 0x08000000 /* CAPABILITY: 4-addr support */ 82*0ba2cbe9Sxc151355 /* 0x10000000 reserved */ 83*0ba2cbe9Sxc151355 #define IEEE80211_C_BGSCAN 0x20000000 /* CAPABILITY: bg scanning */ 84*0ba2cbe9Sxc151355 #define IEEE80211_C_TXFRAG 0x40000000 /* CAPABILITY: tx fragments */ 85*0ba2cbe9Sxc151355 /* XXX protection/barker? */ 86*0ba2cbe9Sxc151355 87*0ba2cbe9Sxc151355 #define IEEE80211_C_CRYPTO 0x0000001f /* CAPABILITY: crypto alg's */ 88*0ba2cbe9Sxc151355 89*0ba2cbe9Sxc151355 /* ic_flags */ 90*0ba2cbe9Sxc151355 /* NB: bits 0x4c available */ 91*0ba2cbe9Sxc151355 #define IEEE80211_F_FF 0x00000001 /* CONF: ATH FF enabled */ 92*0ba2cbe9Sxc151355 #define IEEE80211_F_TURBOP 0x00000002 /* CONF: ATH Turbo enabled */ 93*0ba2cbe9Sxc151355 #define IEEE80211_F_BURST 0x00000004 /* CONF: bursting enabled */ 94*0ba2cbe9Sxc151355 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */ 95*0ba2cbe9Sxc151355 #define IEEE80211_F_PRIVACY 0x00000010 /* CONF: privacy enabled */ 96*0ba2cbe9Sxc151355 #define IEEE80211_F_PUREG 0x00000020 /* CONF: 11g w/o 11b sta's */ 97*0ba2cbe9Sxc151355 #define IEEE80211_F_SCANONLY 0x00000040 /* CONF: scan only */ 98*0ba2cbe9Sxc151355 #define IEEE80211_F_SCAN 0x00000080 /* STATUS: scanning */ 99*0ba2cbe9Sxc151355 #define IEEE80211_F_ASCAN 0x00000100 /* STATUS: active scan */ 100*0ba2cbe9Sxc151355 #define IEEE80211_F_SIBSS 0x00000200 /* STATUS: start IBSS */ 101*0ba2cbe9Sxc151355 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */ 102*0ba2cbe9Sxc151355 #define IEEE80211_F_SHSLOT 0x00000400 103*0ba2cbe9Sxc151355 /* STATUS: use short slot time */ 104*0ba2cbe9Sxc151355 #define IEEE80211_F_PMGTON 0x00000800 /* CONF: Power mgmt enable */ 105*0ba2cbe9Sxc151355 #define IEEE80211_F_DESBSSID 0x00001000 /* CONF: des_bssid is set */ 106*0ba2cbe9Sxc151355 #define IEEE80211_F_WME 0x00002000 /* CONF: enable WME use */ 107*0ba2cbe9Sxc151355 #define IEEE80211_F_BGSCAN 0x00004000 108*0ba2cbe9Sxc151355 /* CONF: bg scan enabled (???) */ 109*0ba2cbe9Sxc151355 #define IEEE80211_F_SWRETRY 0x00008000 /* CONF: sw tx retry enabled */ 110*0ba2cbe9Sxc151355 #define IEEE80211_F_TXPOW_FIXED 0x00010000 /* TX Power: fixed rate */ 111*0ba2cbe9Sxc151355 #define IEEE80211_F_IBSSON 0x00020000 /* CONF: IBSS creation enable */ 112*0ba2cbe9Sxc151355 #define IEEE80211_F_SHPREAMBLE 0x00040000 /* STATUS: use short preamble */ 113*0ba2cbe9Sxc151355 #define IEEE80211_F_DATAPAD 0x00080000 /* CONF: do alignment pad */ 114*0ba2cbe9Sxc151355 #define IEEE80211_F_USEPROT 0x00100000 /* STATUS: protection enabled */ 115*0ba2cbe9Sxc151355 #define IEEE80211_F_USEBARKER 0x00200000 116*0ba2cbe9Sxc151355 /* STATUS: use barker preamble */ 117*0ba2cbe9Sxc151355 #define IEEE80211_F_TIMUPDATE 0x00400000 /* STATUS: update beacon tim */ 118*0ba2cbe9Sxc151355 #define IEEE80211_F_WPA1 0x00800000 /* CONF: WPA enabled */ 119*0ba2cbe9Sxc151355 #define IEEE80211_F_WPA2 0x01000000 /* CONF: WPA2 enabled */ 120*0ba2cbe9Sxc151355 #define IEEE80211_F_WPA 0x01800000 /* CONF: WPA/WPA2 enabled */ 121*0ba2cbe9Sxc151355 #define IEEE80211_F_DROPUNENC 0x02000000 /* CONF: drop unencrypted */ 122*0ba2cbe9Sxc151355 #define IEEE80211_F_COUNTERM 0x04000000 /* CONF: TKIP countermeasures */ 123*0ba2cbe9Sxc151355 #define IEEE80211_F_HIDESSID 0x08000000 /* CONF: hide SSID in beacon */ 124*0ba2cbe9Sxc151355 #define IEEE80211_F_NOBRIDGE 0x10000000 /* CONF: dis. internal bridge */ 125*0ba2cbe9Sxc151355 #define IEEE80211_F_WMEUPDATE 0x20000000 /* STATUS: update beacon wme */ 126*0ba2cbe9Sxc151355 127*0ba2cbe9Sxc151355 /* ic_flags_ext */ 128*0ba2cbe9Sxc151355 #define IEEE80211_FEXT_WDS 0x00000001 /* CONF: 4 addr allowed */ 129*0ba2cbe9Sxc151355 /* 0x00000006 reserved */ 130*0ba2cbe9Sxc151355 #define IEEE80211_FEXT_BGSCAN 0x00000008 131*0ba2cbe9Sxc151355 /* STATUS: enable full bgscan completion */ 132*0ba2cbe9Sxc151355 #define IEEE80211_FEXT_ERPUPDATE 0x00000200 /* STATUS: update ERP element */ 133*0ba2cbe9Sxc151355 #define IEEE80211_FEXT_SWBMISS 0x00000400 /* CONF: do bmiss in s/w */ 134*0ba2cbe9Sxc151355 135*0ba2cbe9Sxc151355 /* 136*0ba2cbe9Sxc151355 * Channel attributes (ich_flags) 137*0ba2cbe9Sxc151355 * bits 0-3 are for private use by drivers 138*0ba2cbe9Sxc151355 */ 139*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ 140*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ 141*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ 142*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ 143*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ 144*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ 145*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ 146*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ 147*0ba2cbe9Sxc151355 148*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_MAX 255 149*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_BYTES 32 /* howmany(IEEE80211_CHAN_MAX, NBBY) */ 150*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */ 151*0ba2cbe9Sxc151355 #define IEEE80211_CHAN_ANYC \ 152*0ba2cbe9Sxc151355 ((struct ieee80211_channel *)IEEE80211_CHAN_ANY) 153*0ba2cbe9Sxc151355 154*0ba2cbe9Sxc151355 #define IEEE80211_IS_CHAN_2GHZ(_c) \ 155*0ba2cbe9Sxc151355 (((_c)->ich_flags & IEEE80211_CHAN_2GHZ) != 0) 156*0ba2cbe9Sxc151355 #define IEEE80211_IS_CHAN_5GHZ(_c) \ 157*0ba2cbe9Sxc151355 (((_c)->ich_flags & IEEE80211_CHAN_5GHZ) != 0) 158*0ba2cbe9Sxc151355 159*0ba2cbe9Sxc151355 #define IEEE80211_NODE_HASHSIZE 32 160*0ba2cbe9Sxc151355 161*0ba2cbe9Sxc151355 #define IEEE80211_FIXED_RATE_NONE 0 162*0ba2cbe9Sxc151355 #define IEEE80211_MCAST_RATE_DEFAULT (2*1) /* default mcast rate (1M) */ 163*0ba2cbe9Sxc151355 164*0ba2cbe9Sxc151355 /* WME stream classes */ 165*0ba2cbe9Sxc151355 #define WME_AC_BE 0 /* best effort */ 166*0ba2cbe9Sxc151355 #define WME_AC_BK 1 /* background */ 167*0ba2cbe9Sxc151355 #define WME_AC_VI 2 /* video */ 168*0ba2cbe9Sxc151355 #define WME_AC_VO 3 /* voice */ 169*0ba2cbe9Sxc151355 170*0ba2cbe9Sxc151355 /* 171*0ba2cbe9Sxc151355 * Authentication mode. 172*0ba2cbe9Sxc151355 */ 173*0ba2cbe9Sxc151355 enum ieee80211_authmode { 174*0ba2cbe9Sxc151355 IEEE80211_AUTH_NONE = 0, 175*0ba2cbe9Sxc151355 IEEE80211_AUTH_OPEN = 1, /* open */ 176*0ba2cbe9Sxc151355 IEEE80211_AUTH_SHARED = 2, /* shared-key */ 177*0ba2cbe9Sxc151355 IEEE80211_AUTH_8021X = 3, /* 802.1x */ 178*0ba2cbe9Sxc151355 IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */ 179*0ba2cbe9Sxc151355 /* NB: these are used only for ioctls */ 180*0ba2cbe9Sxc151355 IEEE80211_AUTH_WPA = 5 /* WPA/RSN w/ 802.1x/PSK */ 181*0ba2cbe9Sxc151355 }; 182*0ba2cbe9Sxc151355 183*0ba2cbe9Sxc151355 enum ieee80211_state { 184*0ba2cbe9Sxc151355 IEEE80211_S_INIT = 0, /* default state */ 185*0ba2cbe9Sxc151355 IEEE80211_S_SCAN = 1, /* scanning */ 186*0ba2cbe9Sxc151355 IEEE80211_S_AUTH = 2, /* try to authenticate */ 187*0ba2cbe9Sxc151355 IEEE80211_S_ASSOC = 3, /* try to assoc */ 188*0ba2cbe9Sxc151355 IEEE80211_S_RUN = 4 /* associated */ 189*0ba2cbe9Sxc151355 }; 190*0ba2cbe9Sxc151355 #define IEEE80211_S_MAX (IEEE80211_S_RUN+1) 191*0ba2cbe9Sxc151355 192*0ba2cbe9Sxc151355 /* 193*0ba2cbe9Sxc151355 * 802.11 rate set. 194*0ba2cbe9Sxc151355 */ 195*0ba2cbe9Sxc151355 #define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */ 196*0ba2cbe9Sxc151355 #define IEEE80211_RATE_SIZE 8 /* 802.11 standard */ 197*0ba2cbe9Sxc151355 #define IEEE80211_XRATE_SIZE (IEEE80211_RATE_MAXSIZE - IEEE80211_RATE_SIZE) 198*0ba2cbe9Sxc151355 /* size of extended supported rates */ 199*0ba2cbe9Sxc151355 struct ieee80211_rateset { 200*0ba2cbe9Sxc151355 uint8_t ir_nrates; 201*0ba2cbe9Sxc151355 uint8_t ir_rates[IEEE80211_RATE_MAXSIZE]; 202*0ba2cbe9Sxc151355 }; 203*0ba2cbe9Sxc151355 204*0ba2cbe9Sxc151355 /* 205*0ba2cbe9Sxc151355 * Channels are specified by frequency and attributes. 206*0ba2cbe9Sxc151355 */ 207*0ba2cbe9Sxc151355 struct ieee80211_channel { 208*0ba2cbe9Sxc151355 uint16_t ich_freq; /* setting in Mhz */ 209*0ba2cbe9Sxc151355 uint16_t ich_flags; /* see below */ 210*0ba2cbe9Sxc151355 }; 211*0ba2cbe9Sxc151355 212*0ba2cbe9Sxc151355 struct ieee80211_device_stats { 213*0ba2cbe9Sxc151355 uint32_t is_tx_frags; 214*0ba2cbe9Sxc151355 uint32_t is_tx_bytes; 215*0ba2cbe9Sxc151355 uint32_t is_tx_mcast; 216*0ba2cbe9Sxc151355 uint32_t is_tx_failed; 217*0ba2cbe9Sxc151355 uint32_t is_tx_retries; 218*0ba2cbe9Sxc151355 uint32_t is_rts_success; 219*0ba2cbe9Sxc151355 uint32_t is_rts_failure; 220*0ba2cbe9Sxc151355 uint32_t is_ack_failure; 221*0ba2cbe9Sxc151355 uint32_t is_rx_frags; 222*0ba2cbe9Sxc151355 uint32_t is_rx_bytes; 223*0ba2cbe9Sxc151355 uint32_t is_rx_mcast; 224*0ba2cbe9Sxc151355 uint32_t is_rx_dups; 225*0ba2cbe9Sxc151355 uint32_t is_fcs_errors; 226*0ba2cbe9Sxc151355 uint32_t is_wep_errors; 227*0ba2cbe9Sxc151355 uint32_t is_tx_nobuf; 228*0ba2cbe9Sxc151355 uint32_t is_tx_unknownmgt; 229*0ba2cbe9Sxc151355 }; 230*0ba2cbe9Sxc151355 231*0ba2cbe9Sxc151355 struct ieee80211_crypto_state; 232*0ba2cbe9Sxc151355 typedef struct ieee80211_node_table ieee80211_node_table_t; 233*0ba2cbe9Sxc151355 typedef struct ieee80211_node ieee80211_node_t; 234*0ba2cbe9Sxc151355 typedef struct ieee80211com ieee80211com_t; 235*0ba2cbe9Sxc151355 236*0ba2cbe9Sxc151355 struct ieee80211_node_table { 237*0ba2cbe9Sxc151355 struct ieee80211com *nt_ic; /* back reference */ 238*0ba2cbe9Sxc151355 239*0ba2cbe9Sxc151355 const char *nt_name; /* for debugging */ 240*0ba2cbe9Sxc151355 /* For node inactivity processing */ 241*0ba2cbe9Sxc151355 int nt_inact_timer; /* inactivity timer */ 242*0ba2cbe9Sxc151355 int nt_inact_init; /* initial node inact setting */ 243*0ba2cbe9Sxc151355 void (*nt_timeout)(struct ieee80211_node_table *); 244*0ba2cbe9Sxc151355 uint32_t nt_scangen; /* gen# for timeout scan */ 245*0ba2cbe9Sxc151355 kmutex_t nt_scanlock; /* on nt_scangen */ 246*0ba2cbe9Sxc151355 kmutex_t nt_nodelock; /* on node table */ 247*0ba2cbe9Sxc151355 248*0ba2cbe9Sxc151355 int nt_keyixmax; /* keyixmap size */ 249*0ba2cbe9Sxc151355 struct ieee80211_node **nt_keyixmap; /* key ix -> node map */ 250*0ba2cbe9Sxc151355 251*0ba2cbe9Sxc151355 list_t nt_node; /* information of all nodes */ 252*0ba2cbe9Sxc151355 list_t nt_hash[IEEE80211_NODE_HASHSIZE]; 253*0ba2cbe9Sxc151355 }; 254*0ba2cbe9Sxc151355 255*0ba2cbe9Sxc151355 /* 256*0ba2cbe9Sxc151355 * Node specific information. Note that drivers are expected 257*0ba2cbe9Sxc151355 * to derive from this structure to add device-specific per-node 258*0ba2cbe9Sxc151355 * state. This is done by overriding the ic_node_* methods in 259*0ba2cbe9Sxc151355 * the ieee80211com structure. 260*0ba2cbe9Sxc151355 */ 261*0ba2cbe9Sxc151355 struct ieee80211_node { 262*0ba2cbe9Sxc151355 struct ieee80211com *in_ic; 263*0ba2cbe9Sxc151355 struct ieee80211_node_table *in_table; 264*0ba2cbe9Sxc151355 265*0ba2cbe9Sxc151355 uint8_t in_authmode; /* authentication algorithm */ 266*0ba2cbe9Sxc151355 uint16_t in_flags; /* special purpose state */ 267*0ba2cbe9Sxc151355 uint16_t in_associd; /* assoc response */ 268*0ba2cbe9Sxc151355 uint16_t in_txpower; /* current transmit power */ 269*0ba2cbe9Sxc151355 uint16_t in_vlan; /* vlan tag */ 270*0ba2cbe9Sxc151355 /* 271*0ba2cbe9Sxc151355 * Tx/Rx sequence number. 272*0ba2cbe9Sxc151355 * index 0 is used when QoS is not enabled. index 1-16 is used 273*0ba2cbe9Sxc151355 * when QoS is enabled. 1-16 corresponds to TID 0-15. 274*0ba2cbe9Sxc151355 */ 275*0ba2cbe9Sxc151355 uint16_t in_txseqs[17]; /* tx seq per-tid */ 276*0ba2cbe9Sxc151355 uint16_t in_rxseqs[17]; /* rx seq previous per-tid */ 277*0ba2cbe9Sxc151355 clock_t in_rxfragstamp; /* time stamp of last rx frag */ 278*0ba2cbe9Sxc151355 mblk_t *in_rxfrag; /* rx frag reassembly */ 279*0ba2cbe9Sxc151355 uint32_t in_scangen; /* gen# for timeout scan */ 280*0ba2cbe9Sxc151355 uint32_t in_refcnt; 281*0ba2cbe9Sxc151355 282*0ba2cbe9Sxc151355 /* hardware */ 283*0ba2cbe9Sxc151355 uint32_t in_rstamp; /* recv timestamp */ 284*0ba2cbe9Sxc151355 uint8_t in_rssi; /* recv ssi */ 285*0ba2cbe9Sxc151355 286*0ba2cbe9Sxc151355 /* header */ 287*0ba2cbe9Sxc151355 uint8_t in_macaddr[IEEE80211_ADDR_LEN]; 288*0ba2cbe9Sxc151355 uint8_t in_bssid[IEEE80211_ADDR_LEN]; 289*0ba2cbe9Sxc151355 290*0ba2cbe9Sxc151355 /* beacon, probe response */ 291*0ba2cbe9Sxc151355 union { 292*0ba2cbe9Sxc151355 uint8_t data[8]; 293*0ba2cbe9Sxc151355 uint64_t tsf; 294*0ba2cbe9Sxc151355 } in_tstamp; /* from last rcv'd beacon */ 295*0ba2cbe9Sxc151355 uint16_t in_intval; /* beacon interval */ 296*0ba2cbe9Sxc151355 uint16_t in_capinfo; /* capabilities */ 297*0ba2cbe9Sxc151355 uint8_t in_esslen; 298*0ba2cbe9Sxc151355 uint8_t in_essid[IEEE80211_NWID_LEN]; 299*0ba2cbe9Sxc151355 struct ieee80211_rateset in_rates; /* negotiated rate set */ 300*0ba2cbe9Sxc151355 struct ieee80211_channel *in_chan; /* XXX multiple uses */ 301*0ba2cbe9Sxc151355 enum ieee80211_phytype in_phytype; 302*0ba2cbe9Sxc151355 uint16_t in_fhdwell; /* FH only */ 303*0ba2cbe9Sxc151355 uint8_t in_fhindex; /* FH only */ 304*0ba2cbe9Sxc151355 uint8_t in_erp; /* ERP from beacon/probe resp */ 305*0ba2cbe9Sxc151355 uint16_t in_tim_off; /* byte offset to TIM ie */ 306*0ba2cbe9Sxc151355 uint8_t in_dtim_period; /* DTIM period */ 307*0ba2cbe9Sxc151355 uint8_t in_dtim_count; /* DTIM count for last bcn */ 308*0ba2cbe9Sxc151355 309*0ba2cbe9Sxc151355 uint32_t *in_challenge; /* shared-key challenge */ 310*0ba2cbe9Sxc151355 struct ieee80211_key in_ucastkey; /* unicast key */ 311*0ba2cbe9Sxc151355 312*0ba2cbe9Sxc151355 /* others */ 313*0ba2cbe9Sxc151355 int32_t in_fails; /* failure count to associate */ 314*0ba2cbe9Sxc151355 int16_t in_inact; /* inactivity mark count */ 315*0ba2cbe9Sxc151355 int16_t in_inact_reload; /* inactivity reload value */ 316*0ba2cbe9Sxc151355 int32_t in_txrate; /* index to ni_rates[] */ 317*0ba2cbe9Sxc151355 318*0ba2cbe9Sxc151355 list_node_t in_node; /* element of nt->nt_node */ 319*0ba2cbe9Sxc151355 list_node_t in_hash; /* element of nt->nt_hash */ 320*0ba2cbe9Sxc151355 }; 321*0ba2cbe9Sxc151355 322*0ba2cbe9Sxc151355 struct ieee80211com { 323*0ba2cbe9Sxc151355 mac_handle_t ic_mach; 324*0ba2cbe9Sxc151355 325*0ba2cbe9Sxc151355 /* Initialized by driver */ 326*0ba2cbe9Sxc151355 uint8_t ic_macaddr[IEEE80211_ADDR_LEN]; 327*0ba2cbe9Sxc151355 uint32_t ic_caps; /* capabilities */ 328*0ba2cbe9Sxc151355 enum ieee80211_phytype ic_phytype; /* XXX wrong for multi-mode */ 329*0ba2cbe9Sxc151355 enum ieee80211_opmode ic_opmode; /* current operation mode */ 330*0ba2cbe9Sxc151355 enum ieee80211_state ic_state; /* current 802.11 state */ 331*0ba2cbe9Sxc151355 struct ieee80211_channel ic_sup_channels[IEEE80211_CHAN_MAX+1]; 332*0ba2cbe9Sxc151355 struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX]; 333*0ba2cbe9Sxc151355 enum ieee80211_phymode ic_curmode; /* OPT current mode */ 334*0ba2cbe9Sxc151355 struct ieee80211_channel *ic_curchan; /* OPT current channel */ 335*0ba2cbe9Sxc151355 struct ieee80211_channel *ic_ibss_chan; /* OPT bss channel */ 336*0ba2cbe9Sxc151355 uint8_t ic_maxrssi; /* maximum hardware RSSI */ 337*0ba2cbe9Sxc151355 338*0ba2cbe9Sxc151355 /* INITIALIZED by IEEE80211, used/overridden by driver */ 339*0ba2cbe9Sxc151355 uint16_t ic_modecaps; /* set of mode capabilities */ 340*0ba2cbe9Sxc151355 uint8_t ic_chan_active[IEEE80211_CHAN_BYTES]; 341*0ba2cbe9Sxc151355 enum ieee80211_protmode ic_protmode; /* 802.11g protection mode */ 342*0ba2cbe9Sxc151355 uint16_t ic_bintval; /* beacon interval */ 343*0ba2cbe9Sxc151355 uint16_t ic_lintval; /* listen interval */ 344*0ba2cbe9Sxc151355 uint16_t ic_txpowlimit; /* global tx power limit */ 345*0ba2cbe9Sxc151355 uint8_t ic_bmissthreshold; 346*0ba2cbe9Sxc151355 uint16_t ic_rtsthreshold; 347*0ba2cbe9Sxc151355 uint16_t ic_fragthreshold; 348*0ba2cbe9Sxc151355 int32_t ic_mcast_rate; /* rate for mcast frames */ 349*0ba2cbe9Sxc151355 uint8_t ic_fixed_rate; /* value of fixed rate */ 350*0ba2cbe9Sxc151355 int32_t ic_des_esslen; /* length of desired essid */ 351*0ba2cbe9Sxc151355 uint8_t ic_des_essid[IEEE80211_NWID_LEN]; 352*0ba2cbe9Sxc151355 uint8_t ic_des_bssid[IEEE80211_ADDR_LEN]; 353*0ba2cbe9Sxc151355 struct ieee80211_channel *ic_des_chan; /* desired channel */ 354*0ba2cbe9Sxc151355 void *ic_opt_ie; /* user-specified IE's */ 355*0ba2cbe9Sxc151355 uint16_t ic_opt_ie_len; /* length of ic_opt_ie */ 356*0ba2cbe9Sxc151355 uint8_t ic_nickname[IEEE80211_NWID_LEN]; 357*0ba2cbe9Sxc151355 uint16_t ic_tim_len; /* ic_tim_bitmap size (bytes) */ 358*0ba2cbe9Sxc151355 uint8_t *ic_tim_bitmap; /* powersave stations w/ data */ 359*0ba2cbe9Sxc151355 timeout_id_t ic_watchdog_timer; /* watchdog timer */ 360*0ba2cbe9Sxc151355 /* Cipher state/configuration. */ 361*0ba2cbe9Sxc151355 struct ieee80211_crypto_state ic_crypto; 362*0ba2cbe9Sxc151355 363*0ba2cbe9Sxc151355 /* Runtime states */ 364*0ba2cbe9Sxc151355 uint32_t ic_flags; /* state/conf flags */ 365*0ba2cbe9Sxc151355 uint32_t ic_flags_ext; /* extended state flags */ 366*0ba2cbe9Sxc151355 struct ieee80211_node *ic_bss; /* information for this node */ 367*0ba2cbe9Sxc151355 struct ieee80211_device_stats ic_stats; 368*0ba2cbe9Sxc151355 struct ieee80211_node_table ic_scan; /* STA: scan candidates */ 369*0ba2cbe9Sxc151355 struct ieee80211_node_table ic_sta; /* AP:stations/IBSS:neighbors */ 370*0ba2cbe9Sxc151355 371*0ba2cbe9Sxc151355 /* callback functions */ 372*0ba2cbe9Sxc151355 /* 373*0ba2cbe9Sxc151355 * Functions initialized by driver before calling ieee80211_attach() 374*0ba2cbe9Sxc151355 * Those must be initialized are marked with M(andatory) 375*0ba2cbe9Sxc151355 * 376*0ba2cbe9Sxc151355 * ic_xmit - [M] transmit a management or null data frame 377*0ba2cbe9Sxc151355 * return 0 on success, non-zero on error 378*0ba2cbe9Sxc151355 * ic_watchdog - [O] periodic run function, enabled by 379*0ba2cbe9Sxc151355 * ieee80211_start_watchdog() 380*0ba2cbe9Sxc151355 * ic_set_tim - [O] set/clear traffic indication map 381*0ba2cbe9Sxc151355 * ic_set_shortslot - [O] enable/disable short slot timing 382*0ba2cbe9Sxc151355 * ic_node_newassoc - [O] driver specific operation on a newly 383*0ba2cbe9Sxc151355 * associated or re-assoced node 384*0ba2cbe9Sxc151355 */ 385*0ba2cbe9Sxc151355 int (*ic_xmit)(ieee80211com_t *, mblk_t *, uint8_t); 386*0ba2cbe9Sxc151355 void (*ic_watchdog)(void *); 387*0ba2cbe9Sxc151355 void (*ic_set_tim)(ieee80211com_t *, 388*0ba2cbe9Sxc151355 ieee80211_node_t *, int); 389*0ba2cbe9Sxc151355 void (*ic_set_shortslot)(ieee80211com_t *, int); 390*0ba2cbe9Sxc151355 void (*ic_node_newassoc)(ieee80211_node_t *, int); 391*0ba2cbe9Sxc151355 /* 392*0ba2cbe9Sxc151355 * Functions initialized by ieee80211_attach(), driver could 393*0ba2cbe9Sxc151355 * override these functions after calling ieee80211_attach() 394*0ba2cbe9Sxc151355 * 395*0ba2cbe9Sxc151355 * ic_reset - reset 396*0ba2cbe9Sxc151355 * ic_recv_mgmt - handle received management frames 397*0ba2cbe9Sxc151355 * ic_send_mgmt - construct and transmit management frames 398*0ba2cbe9Sxc151355 * ic_newstate - handle state transition 399*0ba2cbe9Sxc151355 * ic_node_alloc - allocate a new BSS info node 400*0ba2cbe9Sxc151355 * ic_node_cleanup - cleanup or free memory spaces of a node 401*0ba2cbe9Sxc151355 * ic_node_free - free a node 402*0ba2cbe9Sxc151355 * ic_node_getrssi - get node's rssi 403*0ba2cbe9Sxc151355 */ 404*0ba2cbe9Sxc151355 int (*ic_reset)(ieee80211com_t *); 405*0ba2cbe9Sxc151355 void (*ic_recv_mgmt)(ieee80211com_t *, 406*0ba2cbe9Sxc151355 mblk_t *, ieee80211_node_t *, 407*0ba2cbe9Sxc151355 int, int, uint32_t); 408*0ba2cbe9Sxc151355 int (*ic_send_mgmt)(ieee80211com_t *, 409*0ba2cbe9Sxc151355 ieee80211_node_t *, int, int); 410*0ba2cbe9Sxc151355 int (*ic_newstate)(ieee80211com_t *, 411*0ba2cbe9Sxc151355 enum ieee80211_state, int); 412*0ba2cbe9Sxc151355 struct ieee80211_node *(*ic_node_alloc)(ieee80211com_t *); 413*0ba2cbe9Sxc151355 void (*ic_node_cleanup)(ieee80211_node_t *); 414*0ba2cbe9Sxc151355 void (*ic_node_free)(ieee80211_node_t *); 415*0ba2cbe9Sxc151355 uint8_t (*ic_node_getrssi)(const ieee80211_node_t *); 416*0ba2cbe9Sxc151355 417*0ba2cbe9Sxc151355 kmutex_t ic_genlock; 418*0ba2cbe9Sxc151355 void *ic_private; /* ieee80211 private data */ 419*0ba2cbe9Sxc151355 }; 420*0ba2cbe9Sxc151355 #define ic_nw_keys ic_crypto.cs_nw_keys 421*0ba2cbe9Sxc151355 #define ic_def_txkey ic_crypto.cs_def_txkey 422*0ba2cbe9Sxc151355 423*0ba2cbe9Sxc151355 extern const char *ieee80211_state_name[IEEE80211_S_MAX]; 424*0ba2cbe9Sxc151355 425*0ba2cbe9Sxc151355 #define IEEE80211_RATE(_ix) \ 426*0ba2cbe9Sxc151355 (in->in_rates.ir_rates[(_ix)] & IEEE80211_RATE_VAL) 427*0ba2cbe9Sxc151355 428*0ba2cbe9Sxc151355 #define ieee80211_new_state(_ic, _nstate, _arg) \ 429*0ba2cbe9Sxc151355 (((_ic)->ic_newstate)((_ic), (_nstate), (_arg))) 430*0ba2cbe9Sxc151355 431*0ba2cbe9Sxc151355 #define ieee80211_macaddr_sprintf(_addr) \ 432*0ba2cbe9Sxc151355 ether_sprintf((struct ether_addr *)(_addr)) 433*0ba2cbe9Sxc151355 434*0ba2cbe9Sxc151355 /* 435*0ba2cbe9Sxc151355 * Node reference counting definitions. 436*0ba2cbe9Sxc151355 * 437*0ba2cbe9Sxc151355 * ieee80211_node_initref initialize the reference count to 1 438*0ba2cbe9Sxc151355 * ieee80211_node_incref add a reference 439*0ba2cbe9Sxc151355 * ieee80211_node_decref remove a reference 440*0ba2cbe9Sxc151355 * ieee80211_node_decref_nv remove a reference and return new value 441*0ba2cbe9Sxc151355 * ieee80211_node_refcnt reference count for printing (only) 442*0ba2cbe9Sxc151355 */ 443*0ba2cbe9Sxc151355 #include <sys/atomic.h> 444*0ba2cbe9Sxc151355 #define ieee80211_node_initref(_in) \ 445*0ba2cbe9Sxc151355 ((_in)->in_refcnt = 1) 446*0ba2cbe9Sxc151355 #define ieee80211_node_incref(_in) \ 447*0ba2cbe9Sxc151355 atomic_inc_uint(&(_in)->in_refcnt) 448*0ba2cbe9Sxc151355 #define ieee80211_node_decref(_in) \ 449*0ba2cbe9Sxc151355 atomic_dec_uint(&(_in)->in_refcnt) 450*0ba2cbe9Sxc151355 #define ieee80211_node_decref_nv(_in) \ 451*0ba2cbe9Sxc151355 atomic_dec_uint_nv(&(_in)->in_refcnt) 452*0ba2cbe9Sxc151355 #define ieee80211_node_refcnt(_in) \ 453*0ba2cbe9Sxc151355 (_in)->in_refcnt 454*0ba2cbe9Sxc151355 455*0ba2cbe9Sxc151355 typedef void ieee80211_iter_func(void *, ieee80211_node_t *); 456*0ba2cbe9Sxc151355 457*0ba2cbe9Sxc151355 /* Initialization */ 458*0ba2cbe9Sxc151355 void ieee80211_attach(ieee80211com_t *); 459*0ba2cbe9Sxc151355 void ieee80211_detach(ieee80211com_t *); 460*0ba2cbe9Sxc151355 void ieee80211_media_init(ieee80211com_t *); 461*0ba2cbe9Sxc151355 int ieee80211_ioctl(ieee80211com_t *, queue_t *, mblk_t *); 462*0ba2cbe9Sxc151355 463*0ba2cbe9Sxc151355 /* Protocol Processing */ 464*0ba2cbe9Sxc151355 int ieee80211_input(ieee80211com_t *, mblk_t *, ieee80211_node_t *, 465*0ba2cbe9Sxc151355 int32_t, uint32_t); 466*0ba2cbe9Sxc151355 mblk_t *ieee80211_encap(ieee80211com_t *, mblk_t *, ieee80211_node_t *); 467*0ba2cbe9Sxc151355 468*0ba2cbe9Sxc151355 mblk_t *ieee80211_beacon_alloc(ieee80211com_t *, ieee80211_node_t *, 469*0ba2cbe9Sxc151355 struct ieee80211_beacon_offsets *); 470*0ba2cbe9Sxc151355 int ieee80211_beacon_update(ieee80211com_t *, ieee80211_node_t *, 471*0ba2cbe9Sxc151355 struct ieee80211_beacon_offsets *, mblk_t *, int); 472*0ba2cbe9Sxc151355 void ieee80211_beacon_miss(ieee80211com_t *); 473*0ba2cbe9Sxc151355 474*0ba2cbe9Sxc151355 void ieee80211_begin_scan(ieee80211com_t *, boolean_t); 475*0ba2cbe9Sxc151355 void ieee80211_next_scan(ieee80211com_t *); 476*0ba2cbe9Sxc151355 void ieee80211_end_scan(ieee80211com_t *); 477*0ba2cbe9Sxc151355 void ieee80211_cancel_scan(ieee80211com_t *); 478*0ba2cbe9Sxc151355 479*0ba2cbe9Sxc151355 void ieee80211_sta_join(ieee80211com_t *, ieee80211_node_t *); 480*0ba2cbe9Sxc151355 void ieee80211_sta_leave(ieee80211com_t *, ieee80211_node_t *); 481*0ba2cbe9Sxc151355 boolean_t ieee80211_ibss_merge(ieee80211_node_t *); 482*0ba2cbe9Sxc151355 483*0ba2cbe9Sxc151355 /* Node Operation */ 484*0ba2cbe9Sxc151355 ieee80211_node_t *ieee80211_ref_node(ieee80211_node_t *); 485*0ba2cbe9Sxc151355 void ieee80211_unref_node(ieee80211_node_t **); 486*0ba2cbe9Sxc151355 void ieee80211_node_authorize(ieee80211_node_t *); 487*0ba2cbe9Sxc151355 void ieee80211_node_unauthorize(ieee80211_node_t *); 488*0ba2cbe9Sxc151355 ieee80211_node_t *ieee80211_alloc_node(ieee80211com_t *, 489*0ba2cbe9Sxc151355 ieee80211_node_table_t *, const uint8_t *); 490*0ba2cbe9Sxc151355 void ieee80211_free_node(ieee80211_node_t *); 491*0ba2cbe9Sxc151355 void ieee80211_node_table_reset(ieee80211_node_table_t *); 492*0ba2cbe9Sxc151355 void ieee80211_iterate_nodes(ieee80211_node_table_t *, ieee80211_iter_func *, 493*0ba2cbe9Sxc151355 void *); 494*0ba2cbe9Sxc151355 ieee80211_node_t *ieee80211_find_node(ieee80211_node_table_t *, 495*0ba2cbe9Sxc151355 const uint8_t *); 496*0ba2cbe9Sxc151355 ieee80211_node_t *ieee80211_find_txnode(ieee80211com_t *, 497*0ba2cbe9Sxc151355 const uint8_t daddr[IEEE80211_ADDR_LEN]); 498*0ba2cbe9Sxc151355 ieee80211_node_t *ieee80211_find_rxnode(ieee80211com_t *, 499*0ba2cbe9Sxc151355 const struct ieee80211_frame *); 500*0ba2cbe9Sxc151355 501*0ba2cbe9Sxc151355 502*0ba2cbe9Sxc151355 /* Crypto */ 503*0ba2cbe9Sxc151355 extern struct ieee80211_key *ieee80211_crypto_encap(ieee80211com_t *, mblk_t *); 504*0ba2cbe9Sxc151355 extern struct ieee80211_key *ieee80211_crypto_decap(ieee80211com_t *, mblk_t *, 505*0ba2cbe9Sxc151355 int); 506*0ba2cbe9Sxc151355 extern int ieee80211_crypto_newkey(ieee80211com_t *, int, int, 507*0ba2cbe9Sxc151355 struct ieee80211_key *); 508*0ba2cbe9Sxc151355 extern int ieee80211_crypto_delkey(ieee80211com_t *, struct ieee80211_key *); 509*0ba2cbe9Sxc151355 extern int ieee80211_crypto_setkey(ieee80211com_t *, struct ieee80211_key *, 510*0ba2cbe9Sxc151355 const uint8_t macaddr[IEEE80211_ADDR_LEN]); 511*0ba2cbe9Sxc151355 512*0ba2cbe9Sxc151355 /* Helper Functions */ 513*0ba2cbe9Sxc151355 int ieee80211_stat(ieee80211com_t *ic, uint_t stat, uint64_t *val); 514*0ba2cbe9Sxc151355 uint32_t ieee80211_chan2ieee(ieee80211com_t *, struct ieee80211_channel *); 515*0ba2cbe9Sxc151355 enum ieee80211_phymode ieee80211_chan2mode(ieee80211com_t *, 516*0ba2cbe9Sxc151355 struct ieee80211_channel *); 517*0ba2cbe9Sxc151355 uint32_t ieee80211_ieee2mhz(uint32_t, uint32_t); 518*0ba2cbe9Sxc151355 void ieee80211_reset_chan(ieee80211com_t *); 519*0ba2cbe9Sxc151355 void ieee80211_dump_pkt(const uint8_t *, int32_t, int32_t, int32_t); 520*0ba2cbe9Sxc151355 void ieee80211_watchdog(void *); 521*0ba2cbe9Sxc151355 void ieee80211_start_watchdog(ieee80211com_t *, uint32_t); 522*0ba2cbe9Sxc151355 void ieee80211_stop_watchdog(ieee80211com_t *); 523*0ba2cbe9Sxc151355 524*0ba2cbe9Sxc151355 #ifdef __cplusplus 525*0ba2cbe9Sxc151355 } 526*0ba2cbe9Sxc151355 #endif 527*0ba2cbe9Sxc151355 528*0ba2cbe9Sxc151355 #endif /* _SYS_NET80211_H */ 529