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