10ba2cbe9Sxc151355 /* 2a399b765Szf162725 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 30ba2cbe9Sxc151355 * Use is subject to license terms. 40ba2cbe9Sxc151355 */ 50ba2cbe9Sxc151355 60ba2cbe9Sxc151355 /* 70ba2cbe9Sxc151355 * Copyright (c) 2001 Atsushi Onoe 80ba2cbe9Sxc151355 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting 90ba2cbe9Sxc151355 * All rights reserved. 100ba2cbe9Sxc151355 * 110ba2cbe9Sxc151355 * Redistribution and use in source and binary forms, with or without 120ba2cbe9Sxc151355 * modification, are permitted provided that the following conditions 130ba2cbe9Sxc151355 * are met: 140ba2cbe9Sxc151355 * 1. Redistributions of source code must retain the above copyright 150ba2cbe9Sxc151355 * notice, this list of conditions and the following disclaimer. 160ba2cbe9Sxc151355 * 2. Redistributions in binary form must reproduce the above copyright 170ba2cbe9Sxc151355 * notice, this list of conditions and the following disclaimer in the 180ba2cbe9Sxc151355 * documentation and/or other materials provided with the distribution. 190ba2cbe9Sxc151355 * 3. The name of the author may not be used to endorse or promote products 200ba2cbe9Sxc151355 * derived from this software without specific prior written permission. 210ba2cbe9Sxc151355 * 220ba2cbe9Sxc151355 * Alternatively, this software may be distributed under the terms of the 230ba2cbe9Sxc151355 * GNU General Public License ("GPL") version 2 as published by the Free 240ba2cbe9Sxc151355 * Software Foundation. 250ba2cbe9Sxc151355 * 260ba2cbe9Sxc151355 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 270ba2cbe9Sxc151355 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 280ba2cbe9Sxc151355 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 290ba2cbe9Sxc151355 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 300ba2cbe9Sxc151355 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 310ba2cbe9Sxc151355 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 320ba2cbe9Sxc151355 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 330ba2cbe9Sxc151355 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 340ba2cbe9Sxc151355 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 350ba2cbe9Sxc151355 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 360ba2cbe9Sxc151355 */ 370ba2cbe9Sxc151355 380ba2cbe9Sxc151355 #pragma ident "%Z%%M% %I% %E% SMI" 390ba2cbe9Sxc151355 400ba2cbe9Sxc151355 #ifndef _SYS_NET80211_H 410ba2cbe9Sxc151355 #define _SYS_NET80211_H 420ba2cbe9Sxc151355 430ba2cbe9Sxc151355 #include <sys/mac.h> 440ba2cbe9Sxc151355 #include <sys/ethernet.h> 450ba2cbe9Sxc151355 #include <sys/net80211_proto.h> 460ba2cbe9Sxc151355 #include <sys/net80211_crypto.h> 47a399b765Szf162725 #include <net/wpa.h> 480ba2cbe9Sxc151355 490ba2cbe9Sxc151355 /* 500ba2cbe9Sxc151355 * IEEE802.11 kernel support module 510ba2cbe9Sxc151355 */ 520ba2cbe9Sxc151355 530ba2cbe9Sxc151355 #ifdef __cplusplus 540ba2cbe9Sxc151355 extern "C" { 550ba2cbe9Sxc151355 #endif 560ba2cbe9Sxc151355 570ba2cbe9Sxc151355 /* ic_caps */ 580ba2cbe9Sxc151355 #define IEEE80211_C_WEP 0x00000001 /* CAPABILITY: WEP available */ 590ba2cbe9Sxc151355 #define IEEE80211_C_TKIP 0x00000002 /* CAPABILITY: TKIP available */ 600ba2cbe9Sxc151355 #define IEEE80211_C_AES 0x00000004 /* CAPABILITY: AES OCB avail */ 610ba2cbe9Sxc151355 #define IEEE80211_C_AES_CCM 0x00000008 /* CAPABILITY: AES CCM avail */ 620ba2cbe9Sxc151355 #define IEEE80211_C_CKIP 0x00000010 /* CAPABILITY: CKIP available */ 630ba2cbe9Sxc151355 #define IEEE80211_C_FF 0x00000040 /* CAPABILITY: ATH FF avail */ 640ba2cbe9Sxc151355 #define IEEE80211_C_TURBOP 0x00000080 650ba2cbe9Sxc151355 /* CAPABILITY: ATH Turbo available */ 660ba2cbe9Sxc151355 #define IEEE80211_C_IBSS 0x00000100 /* CAPABILITY: IBSS available */ 670ba2cbe9Sxc151355 #define IEEE80211_C_PMGT 0x00000200 /* CAPABILITY: Power mgmt */ 680ba2cbe9Sxc151355 #define IEEE80211_C_HOSTAP 0x00000400 /* CAPABILITY: HOSTAP avail */ 690ba2cbe9Sxc151355 #define IEEE80211_C_AHDEMO 0x00000800 /* CAPABILITY: Old Adhoc Demo */ 700ba2cbe9Sxc151355 #define IEEE80211_C_SWRETRY 0x00001000 /* CAPABILITY: sw tx retry */ 710ba2cbe9Sxc151355 #define IEEE80211_C_TXPMGT 0x00002000 /* CAPABILITY: tx power mgmt */ 720ba2cbe9Sxc151355 #define IEEE80211_C_SHSLOT 0x00004000 /* CAPABILITY: short slottime */ 730ba2cbe9Sxc151355 #define IEEE80211_C_SHPREAMBLE 0x00008000 /* CAPABILITY: short preamble */ 740ba2cbe9Sxc151355 #define IEEE80211_C_MONITOR 0x00010000 /* CAPABILITY: monitor mode */ 750ba2cbe9Sxc151355 #define IEEE80211_C_TKIPMIC 0x00020000 /* CAPABILITY: TKIP MIC avail */ 760ba2cbe9Sxc151355 #define IEEE80211_C_WPA1 0x00800000 /* CAPABILITY: WPA1 avail */ 770ba2cbe9Sxc151355 #define IEEE80211_C_WPA2 0x01000000 /* CAPABILITY: WPA2 avail */ 780ba2cbe9Sxc151355 #define IEEE80211_C_WPA 0x01800000 790ba2cbe9Sxc151355 /* CAPABILITY: WPA1+WPA2 avail */ 800ba2cbe9Sxc151355 #define IEEE80211_C_BURST 0x02000000 /* CAPABILITY: frame bursting */ 810ba2cbe9Sxc151355 #define IEEE80211_C_WME 0x04000000 /* CAPABILITY: WME avail */ 820ba2cbe9Sxc151355 #define IEEE80211_C_WDS 0x08000000 /* CAPABILITY: 4-addr support */ 830ba2cbe9Sxc151355 /* 0x10000000 reserved */ 840ba2cbe9Sxc151355 #define IEEE80211_C_BGSCAN 0x20000000 /* CAPABILITY: bg scanning */ 850ba2cbe9Sxc151355 #define IEEE80211_C_TXFRAG 0x40000000 /* CAPABILITY: tx fragments */ 860ba2cbe9Sxc151355 /* XXX protection/barker? */ 870ba2cbe9Sxc151355 880ba2cbe9Sxc151355 #define IEEE80211_C_CRYPTO 0x0000001f /* CAPABILITY: crypto alg's */ 890ba2cbe9Sxc151355 900ba2cbe9Sxc151355 /* ic_flags */ 910ba2cbe9Sxc151355 /* NB: bits 0x4c available */ 920ba2cbe9Sxc151355 #define IEEE80211_F_FF 0x00000001 /* CONF: ATH FF enabled */ 930ba2cbe9Sxc151355 #define IEEE80211_F_TURBOP 0x00000002 /* CONF: ATH Turbo enabled */ 940ba2cbe9Sxc151355 #define IEEE80211_F_BURST 0x00000004 /* CONF: bursting enabled */ 950ba2cbe9Sxc151355 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */ 960ba2cbe9Sxc151355 #define IEEE80211_F_PRIVACY 0x00000010 /* CONF: privacy enabled */ 970ba2cbe9Sxc151355 #define IEEE80211_F_PUREG 0x00000020 /* CONF: 11g w/o 11b sta's */ 980ba2cbe9Sxc151355 #define IEEE80211_F_SCANONLY 0x00000040 /* CONF: scan only */ 990ba2cbe9Sxc151355 #define IEEE80211_F_SCAN 0x00000080 /* STATUS: scanning */ 1000ba2cbe9Sxc151355 #define IEEE80211_F_ASCAN 0x00000100 /* STATUS: active scan */ 1010ba2cbe9Sxc151355 #define IEEE80211_F_SIBSS 0x00000200 /* STATUS: start IBSS */ 1020ba2cbe9Sxc151355 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */ 1030ba2cbe9Sxc151355 #define IEEE80211_F_SHSLOT 0x00000400 1040ba2cbe9Sxc151355 /* STATUS: use short slot time */ 1050ba2cbe9Sxc151355 #define IEEE80211_F_PMGTON 0x00000800 /* CONF: Power mgmt enable */ 1060ba2cbe9Sxc151355 #define IEEE80211_F_DESBSSID 0x00001000 /* CONF: des_bssid is set */ 1070ba2cbe9Sxc151355 #define IEEE80211_F_WME 0x00002000 /* CONF: enable WME use */ 1080ba2cbe9Sxc151355 #define IEEE80211_F_BGSCAN 0x00004000 1090ba2cbe9Sxc151355 /* CONF: bg scan enabled (???) */ 1100ba2cbe9Sxc151355 #define IEEE80211_F_SWRETRY 0x00008000 /* CONF: sw tx retry enabled */ 1110ba2cbe9Sxc151355 #define IEEE80211_F_TXPOW_FIXED 0x00010000 /* TX Power: fixed rate */ 1120ba2cbe9Sxc151355 #define IEEE80211_F_IBSSON 0x00020000 /* CONF: IBSS creation enable */ 1130ba2cbe9Sxc151355 #define IEEE80211_F_SHPREAMBLE 0x00040000 /* STATUS: use short preamble */ 1140ba2cbe9Sxc151355 #define IEEE80211_F_DATAPAD 0x00080000 /* CONF: do alignment pad */ 1150ba2cbe9Sxc151355 #define IEEE80211_F_USEPROT 0x00100000 /* STATUS: protection enabled */ 1160ba2cbe9Sxc151355 #define IEEE80211_F_USEBARKER 0x00200000 1170ba2cbe9Sxc151355 /* STATUS: use barker preamble */ 1180ba2cbe9Sxc151355 #define IEEE80211_F_TIMUPDATE 0x00400000 /* STATUS: update beacon tim */ 1190ba2cbe9Sxc151355 #define IEEE80211_F_WPA1 0x00800000 /* CONF: WPA enabled */ 1200ba2cbe9Sxc151355 #define IEEE80211_F_WPA2 0x01000000 /* CONF: WPA2 enabled */ 1210ba2cbe9Sxc151355 #define IEEE80211_F_WPA 0x01800000 /* CONF: WPA/WPA2 enabled */ 1220ba2cbe9Sxc151355 #define IEEE80211_F_DROPUNENC 0x02000000 /* CONF: drop unencrypted */ 1230ba2cbe9Sxc151355 #define IEEE80211_F_COUNTERM 0x04000000 /* CONF: TKIP countermeasures */ 1240ba2cbe9Sxc151355 #define IEEE80211_F_HIDESSID 0x08000000 /* CONF: hide SSID in beacon */ 1250ba2cbe9Sxc151355 #define IEEE80211_F_NOBRIDGE 0x10000000 /* CONF: dis. internal bridge */ 1260ba2cbe9Sxc151355 #define IEEE80211_F_WMEUPDATE 0x20000000 /* STATUS: update beacon wme */ 1270ba2cbe9Sxc151355 1280ba2cbe9Sxc151355 /* ic_flags_ext */ 1290ba2cbe9Sxc151355 #define IEEE80211_FEXT_WDS 0x00000001 /* CONF: 4 addr allowed */ 1300ba2cbe9Sxc151355 /* 0x00000006 reserved */ 1310ba2cbe9Sxc151355 #define IEEE80211_FEXT_BGSCAN 0x00000008 1320ba2cbe9Sxc151355 /* STATUS: enable full bgscan completion */ 1330ba2cbe9Sxc151355 #define IEEE80211_FEXT_ERPUPDATE 0x00000200 /* STATUS: update ERP element */ 1340ba2cbe9Sxc151355 #define IEEE80211_FEXT_SWBMISS 0x00000400 /* CONF: do bmiss in s/w */ 1350ba2cbe9Sxc151355 1360ba2cbe9Sxc151355 /* 1370ba2cbe9Sxc151355 * Channel attributes (ich_flags) 1380ba2cbe9Sxc151355 * bits 0-3 are for private use by drivers 1390ba2cbe9Sxc151355 */ 1400ba2cbe9Sxc151355 #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ 1410ba2cbe9Sxc151355 #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ 1420ba2cbe9Sxc151355 #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ 1430ba2cbe9Sxc151355 #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ 1440ba2cbe9Sxc151355 #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ 1450ba2cbe9Sxc151355 #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ 1460ba2cbe9Sxc151355 #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ 1470ba2cbe9Sxc151355 #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ 1480ba2cbe9Sxc151355 1490ba2cbe9Sxc151355 #define IEEE80211_CHAN_MAX 255 1500ba2cbe9Sxc151355 #define IEEE80211_CHAN_BYTES 32 /* howmany(IEEE80211_CHAN_MAX, NBBY) */ 1510ba2cbe9Sxc151355 #define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */ 1520ba2cbe9Sxc151355 #define IEEE80211_CHAN_ANYC \ 1530ba2cbe9Sxc151355 ((struct ieee80211_channel *)IEEE80211_CHAN_ANY) 1540ba2cbe9Sxc151355 1550ba2cbe9Sxc151355 #define IEEE80211_IS_CHAN_2GHZ(_c) \ 1560ba2cbe9Sxc151355 (((_c)->ich_flags & IEEE80211_CHAN_2GHZ) != 0) 1570ba2cbe9Sxc151355 #define IEEE80211_IS_CHAN_5GHZ(_c) \ 1580ba2cbe9Sxc151355 (((_c)->ich_flags & IEEE80211_CHAN_5GHZ) != 0) 1590ba2cbe9Sxc151355 1600ba2cbe9Sxc151355 #define IEEE80211_NODE_HASHSIZE 32 1610ba2cbe9Sxc151355 1620ba2cbe9Sxc151355 #define IEEE80211_FIXED_RATE_NONE 0 1630ba2cbe9Sxc151355 #define IEEE80211_MCAST_RATE_DEFAULT (2*1) /* default mcast rate (1M) */ 1640ba2cbe9Sxc151355 1650ba2cbe9Sxc151355 /* WME stream classes */ 1660ba2cbe9Sxc151355 #define WME_AC_BE 0 /* best effort */ 1670ba2cbe9Sxc151355 #define WME_AC_BK 1 /* background */ 1680ba2cbe9Sxc151355 #define WME_AC_VI 2 /* video */ 1690ba2cbe9Sxc151355 #define WME_AC_VO 3 /* voice */ 1700ba2cbe9Sxc151355 171a399b765Szf162725 #define MAX_EVENT 16 172a399b765Szf162725 #define MAX_IEEE80211STR 256 173a399b765Szf162725 1740ba2cbe9Sxc151355 /* 1750ba2cbe9Sxc151355 * Authentication mode. 1760ba2cbe9Sxc151355 */ 1770ba2cbe9Sxc151355 enum ieee80211_authmode { 1780ba2cbe9Sxc151355 IEEE80211_AUTH_NONE = 0, 1790ba2cbe9Sxc151355 IEEE80211_AUTH_OPEN = 1, /* open */ 1800ba2cbe9Sxc151355 IEEE80211_AUTH_SHARED = 2, /* shared-key */ 1810ba2cbe9Sxc151355 IEEE80211_AUTH_8021X = 3, /* 802.1x */ 1820ba2cbe9Sxc151355 IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */ 1830ba2cbe9Sxc151355 /* NB: these are used only for ioctls */ 1840ba2cbe9Sxc151355 IEEE80211_AUTH_WPA = 5 /* WPA/RSN w/ 802.1x/PSK */ 1850ba2cbe9Sxc151355 }; 1860ba2cbe9Sxc151355 1870ba2cbe9Sxc151355 enum ieee80211_state { 1880ba2cbe9Sxc151355 IEEE80211_S_INIT = 0, /* default state */ 1890ba2cbe9Sxc151355 IEEE80211_S_SCAN = 1, /* scanning */ 1900ba2cbe9Sxc151355 IEEE80211_S_AUTH = 2, /* try to authenticate */ 1910ba2cbe9Sxc151355 IEEE80211_S_ASSOC = 3, /* try to assoc */ 1920ba2cbe9Sxc151355 IEEE80211_S_RUN = 4 /* associated */ 1930ba2cbe9Sxc151355 }; 1940ba2cbe9Sxc151355 #define IEEE80211_S_MAX (IEEE80211_S_RUN+1) 1950ba2cbe9Sxc151355 1960ba2cbe9Sxc151355 /* 1970ba2cbe9Sxc151355 * 802.11 rate set. 1980ba2cbe9Sxc151355 */ 1990ba2cbe9Sxc151355 #define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */ 2000ba2cbe9Sxc151355 #define IEEE80211_RATE_SIZE 8 /* 802.11 standard */ 2010ba2cbe9Sxc151355 #define IEEE80211_XRATE_SIZE (IEEE80211_RATE_MAXSIZE - IEEE80211_RATE_SIZE) 2020ba2cbe9Sxc151355 /* size of extended supported rates */ 2030ba2cbe9Sxc151355 struct ieee80211_rateset { 2040ba2cbe9Sxc151355 uint8_t ir_nrates; 2050ba2cbe9Sxc151355 uint8_t ir_rates[IEEE80211_RATE_MAXSIZE]; 2060ba2cbe9Sxc151355 }; 2070ba2cbe9Sxc151355 2080ba2cbe9Sxc151355 /* 2090ba2cbe9Sxc151355 * Channels are specified by frequency and attributes. 2100ba2cbe9Sxc151355 */ 2110ba2cbe9Sxc151355 struct ieee80211_channel { 2120ba2cbe9Sxc151355 uint16_t ich_freq; /* setting in Mhz */ 2130ba2cbe9Sxc151355 uint16_t ich_flags; /* see below */ 2140ba2cbe9Sxc151355 }; 2150ba2cbe9Sxc151355 2160ba2cbe9Sxc151355 struct ieee80211_device_stats { 2170ba2cbe9Sxc151355 uint32_t is_tx_frags; 2180ba2cbe9Sxc151355 uint32_t is_tx_bytes; 2190ba2cbe9Sxc151355 uint32_t is_tx_mcast; 2200ba2cbe9Sxc151355 uint32_t is_tx_failed; 2210ba2cbe9Sxc151355 uint32_t is_tx_retries; 2220ba2cbe9Sxc151355 uint32_t is_rts_success; 2230ba2cbe9Sxc151355 uint32_t is_rts_failure; 2240ba2cbe9Sxc151355 uint32_t is_ack_failure; 2250ba2cbe9Sxc151355 uint32_t is_rx_frags; 2260ba2cbe9Sxc151355 uint32_t is_rx_bytes; 2270ba2cbe9Sxc151355 uint32_t is_rx_mcast; 2280ba2cbe9Sxc151355 uint32_t is_rx_dups; 2290ba2cbe9Sxc151355 uint32_t is_fcs_errors; 2300ba2cbe9Sxc151355 uint32_t is_wep_errors; 2310ba2cbe9Sxc151355 uint32_t is_tx_nobuf; 2320ba2cbe9Sxc151355 uint32_t is_tx_unknownmgt; 2330ba2cbe9Sxc151355 }; 2340ba2cbe9Sxc151355 2350ba2cbe9Sxc151355 struct ieee80211_crypto_state; 2360ba2cbe9Sxc151355 typedef struct ieee80211_node_table ieee80211_node_table_t; 2370ba2cbe9Sxc151355 typedef struct ieee80211_node ieee80211_node_t; 2380ba2cbe9Sxc151355 typedef struct ieee80211com ieee80211com_t; 2390ba2cbe9Sxc151355 2400ba2cbe9Sxc151355 struct ieee80211_node_table { 2410ba2cbe9Sxc151355 struct ieee80211com *nt_ic; /* back reference */ 2420ba2cbe9Sxc151355 2430ba2cbe9Sxc151355 const char *nt_name; /* for debugging */ 2440ba2cbe9Sxc151355 /* For node inactivity processing */ 2450ba2cbe9Sxc151355 int nt_inact_timer; /* inactivity timer */ 2460ba2cbe9Sxc151355 int nt_inact_init; /* initial node inact setting */ 2470ba2cbe9Sxc151355 void (*nt_timeout)(struct ieee80211_node_table *); 2480ba2cbe9Sxc151355 uint32_t nt_scangen; /* gen# for timeout scan */ 2490ba2cbe9Sxc151355 kmutex_t nt_scanlock; /* on nt_scangen */ 2500ba2cbe9Sxc151355 kmutex_t nt_nodelock; /* on node table */ 2510ba2cbe9Sxc151355 2520ba2cbe9Sxc151355 int nt_keyixmax; /* keyixmap size */ 2530ba2cbe9Sxc151355 struct ieee80211_node **nt_keyixmap; /* key ix -> node map */ 2540ba2cbe9Sxc151355 2550ba2cbe9Sxc151355 list_t nt_node; /* information of all nodes */ 2560ba2cbe9Sxc151355 list_t nt_hash[IEEE80211_NODE_HASHSIZE]; 2570ba2cbe9Sxc151355 }; 2580ba2cbe9Sxc151355 2590ba2cbe9Sxc151355 /* 2600ba2cbe9Sxc151355 * Node specific information. Note that drivers are expected 2610ba2cbe9Sxc151355 * to derive from this structure to add device-specific per-node 2620ba2cbe9Sxc151355 * state. This is done by overriding the ic_node_* methods in 2630ba2cbe9Sxc151355 * the ieee80211com structure. 2640ba2cbe9Sxc151355 */ 2650ba2cbe9Sxc151355 struct ieee80211_node { 2660ba2cbe9Sxc151355 struct ieee80211com *in_ic; 2670ba2cbe9Sxc151355 struct ieee80211_node_table *in_table; 2680ba2cbe9Sxc151355 2690ba2cbe9Sxc151355 uint8_t in_authmode; /* authentication algorithm */ 2700ba2cbe9Sxc151355 uint16_t in_flags; /* special purpose state */ 2710ba2cbe9Sxc151355 uint16_t in_associd; /* assoc response */ 2720ba2cbe9Sxc151355 uint16_t in_txpower; /* current transmit power */ 2730ba2cbe9Sxc151355 uint16_t in_vlan; /* vlan tag */ 2740ba2cbe9Sxc151355 /* 2750ba2cbe9Sxc151355 * Tx/Rx sequence number. 2760ba2cbe9Sxc151355 * index 0 is used when QoS is not enabled. index 1-16 is used 2770ba2cbe9Sxc151355 * when QoS is enabled. 1-16 corresponds to TID 0-15. 2780ba2cbe9Sxc151355 */ 2790ba2cbe9Sxc151355 uint16_t in_txseqs[17]; /* tx seq per-tid */ 2800ba2cbe9Sxc151355 uint16_t in_rxseqs[17]; /* rx seq previous per-tid */ 2810ba2cbe9Sxc151355 clock_t in_rxfragstamp; /* time stamp of last rx frag */ 2820ba2cbe9Sxc151355 mblk_t *in_rxfrag; /* rx frag reassembly */ 2830ba2cbe9Sxc151355 uint32_t in_scangen; /* gen# for timeout scan */ 2840ba2cbe9Sxc151355 uint32_t in_refcnt; 2850ba2cbe9Sxc151355 2860ba2cbe9Sxc151355 /* hardware */ 2870ba2cbe9Sxc151355 uint32_t in_rstamp; /* recv timestamp */ 2880ba2cbe9Sxc151355 uint8_t in_rssi; /* recv ssi */ 2890ba2cbe9Sxc151355 2900ba2cbe9Sxc151355 /* header */ 2910ba2cbe9Sxc151355 uint8_t in_macaddr[IEEE80211_ADDR_LEN]; 2920ba2cbe9Sxc151355 uint8_t in_bssid[IEEE80211_ADDR_LEN]; 2930ba2cbe9Sxc151355 2940ba2cbe9Sxc151355 /* beacon, probe response */ 2950ba2cbe9Sxc151355 union { 2960ba2cbe9Sxc151355 uint8_t data[8]; 2970ba2cbe9Sxc151355 uint64_t tsf; 2980ba2cbe9Sxc151355 } in_tstamp; /* from last rcv'd beacon */ 2990ba2cbe9Sxc151355 uint16_t in_intval; /* beacon interval */ 3000ba2cbe9Sxc151355 uint16_t in_capinfo; /* capabilities */ 3010ba2cbe9Sxc151355 uint8_t in_esslen; 3020ba2cbe9Sxc151355 uint8_t in_essid[IEEE80211_NWID_LEN]; 3030ba2cbe9Sxc151355 struct ieee80211_rateset in_rates; /* negotiated rate set */ 3040ba2cbe9Sxc151355 struct ieee80211_channel *in_chan; /* XXX multiple uses */ 3050ba2cbe9Sxc151355 enum ieee80211_phytype in_phytype; 3060ba2cbe9Sxc151355 uint16_t in_fhdwell; /* FH only */ 3070ba2cbe9Sxc151355 uint8_t in_fhindex; /* FH only */ 3080ba2cbe9Sxc151355 uint8_t in_erp; /* ERP from beacon/probe resp */ 3090ba2cbe9Sxc151355 uint16_t in_tim_off; /* byte offset to TIM ie */ 3100ba2cbe9Sxc151355 uint8_t in_dtim_period; /* DTIM period */ 3110ba2cbe9Sxc151355 uint8_t in_dtim_count; /* DTIM count for last bcn */ 3120ba2cbe9Sxc151355 3130ba2cbe9Sxc151355 uint32_t *in_challenge; /* shared-key challenge */ 3140ba2cbe9Sxc151355 struct ieee80211_key in_ucastkey; /* unicast key */ 315a399b765Szf162725 uint8_t *in_wpa_ie; /* captured WPA/RSN ie */ 3160ba2cbe9Sxc151355 3170ba2cbe9Sxc151355 /* others */ 3180ba2cbe9Sxc151355 int32_t in_fails; /* failure count to associate */ 3190ba2cbe9Sxc151355 int16_t in_inact; /* inactivity mark count */ 3200ba2cbe9Sxc151355 int16_t in_inact_reload; /* inactivity reload value */ 3210ba2cbe9Sxc151355 int32_t in_txrate; /* index to ni_rates[] */ 3220ba2cbe9Sxc151355 3230ba2cbe9Sxc151355 list_node_t in_node; /* element of nt->nt_node */ 3240ba2cbe9Sxc151355 list_node_t in_hash; /* element of nt->nt_hash */ 3250ba2cbe9Sxc151355 }; 3260ba2cbe9Sxc151355 3270ba2cbe9Sxc151355 struct ieee80211com { 3280ba2cbe9Sxc151355 mac_handle_t ic_mach; 3290ba2cbe9Sxc151355 3300ba2cbe9Sxc151355 /* Initialized by driver */ 3310ba2cbe9Sxc151355 uint8_t ic_macaddr[IEEE80211_ADDR_LEN]; 3320ba2cbe9Sxc151355 uint32_t ic_caps; /* capabilities */ 3330ba2cbe9Sxc151355 enum ieee80211_phytype ic_phytype; /* XXX wrong for multi-mode */ 3340ba2cbe9Sxc151355 enum ieee80211_opmode ic_opmode; /* current operation mode */ 3350ba2cbe9Sxc151355 enum ieee80211_state ic_state; /* current 802.11 state */ 3360ba2cbe9Sxc151355 struct ieee80211_channel ic_sup_channels[IEEE80211_CHAN_MAX+1]; 3370ba2cbe9Sxc151355 struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX]; 3380ba2cbe9Sxc151355 enum ieee80211_phymode ic_curmode; /* OPT current mode */ 3390ba2cbe9Sxc151355 struct ieee80211_channel *ic_curchan; /* OPT current channel */ 3400ba2cbe9Sxc151355 struct ieee80211_channel *ic_ibss_chan; /* OPT bss channel */ 3410ba2cbe9Sxc151355 uint8_t ic_maxrssi; /* maximum hardware RSSI */ 3420ba2cbe9Sxc151355 3430ba2cbe9Sxc151355 /* INITIALIZED by IEEE80211, used/overridden by driver */ 3440ba2cbe9Sxc151355 uint16_t ic_modecaps; /* set of mode capabilities */ 3450ba2cbe9Sxc151355 uint8_t ic_chan_active[IEEE80211_CHAN_BYTES]; 3460ba2cbe9Sxc151355 enum ieee80211_protmode ic_protmode; /* 802.11g protection mode */ 3470ba2cbe9Sxc151355 uint16_t ic_bintval; /* beacon interval */ 3480ba2cbe9Sxc151355 uint16_t ic_lintval; /* listen interval */ 3490ba2cbe9Sxc151355 uint16_t ic_txpowlimit; /* global tx power limit */ 3500ba2cbe9Sxc151355 uint8_t ic_bmissthreshold; 3510ba2cbe9Sxc151355 uint16_t ic_rtsthreshold; 3520ba2cbe9Sxc151355 uint16_t ic_fragthreshold; 3530ba2cbe9Sxc151355 int32_t ic_mcast_rate; /* rate for mcast frames */ 3540ba2cbe9Sxc151355 uint8_t ic_fixed_rate; /* value of fixed rate */ 3550ba2cbe9Sxc151355 int32_t ic_des_esslen; /* length of desired essid */ 3560ba2cbe9Sxc151355 uint8_t ic_des_essid[IEEE80211_NWID_LEN]; 3570ba2cbe9Sxc151355 uint8_t ic_des_bssid[IEEE80211_ADDR_LEN]; 3580ba2cbe9Sxc151355 struct ieee80211_channel *ic_des_chan; /* desired channel */ 3590ba2cbe9Sxc151355 void *ic_opt_ie; /* user-specified IE's */ 3600ba2cbe9Sxc151355 uint16_t ic_opt_ie_len; /* length of ic_opt_ie */ 3610ba2cbe9Sxc151355 uint8_t ic_nickname[IEEE80211_NWID_LEN]; 3620ba2cbe9Sxc151355 uint16_t ic_tim_len; /* ic_tim_bitmap size (bytes) */ 3630ba2cbe9Sxc151355 uint8_t *ic_tim_bitmap; /* powersave stations w/ data */ 3640ba2cbe9Sxc151355 timeout_id_t ic_watchdog_timer; /* watchdog timer */ 3650ba2cbe9Sxc151355 /* Cipher state/configuration. */ 3660ba2cbe9Sxc151355 struct ieee80211_crypto_state ic_crypto; 367239e91abShx147065 const struct ieee80211_cipher *ic_ciphers[IEEE80211_CIPHER_MAX]; 3680ba2cbe9Sxc151355 369a399b765Szf162725 kmutex_t ic_doorlock; 370a399b765Szf162725 char ic_wpadoor[MAX_IEEE80211STR]; 371a399b765Szf162725 372a399b765Szf162725 wpa_event_type ic_eventq[MAX_EVENT]; 373a399b765Szf162725 uint32_t ic_evq_head, ic_evq_tail; 374a399b765Szf162725 3750ba2cbe9Sxc151355 /* Runtime states */ 3760ba2cbe9Sxc151355 uint32_t ic_flags; /* state/conf flags */ 3770ba2cbe9Sxc151355 uint32_t ic_flags_ext; /* extended state flags */ 3780ba2cbe9Sxc151355 struct ieee80211_node *ic_bss; /* information for this node */ 3790ba2cbe9Sxc151355 struct ieee80211_device_stats ic_stats; 3800ba2cbe9Sxc151355 struct ieee80211_node_table ic_scan; /* STA: scan candidates */ 3810ba2cbe9Sxc151355 struct ieee80211_node_table ic_sta; /* AP:stations/IBSS:neighbors */ 3820ba2cbe9Sxc151355 3830ba2cbe9Sxc151355 /* callback functions */ 3840ba2cbe9Sxc151355 /* 3850ba2cbe9Sxc151355 * Functions initialized by driver before calling ieee80211_attach() 3860ba2cbe9Sxc151355 * Those must be initialized are marked with M(andatory) 3870ba2cbe9Sxc151355 * 3880ba2cbe9Sxc151355 * ic_xmit - [M] transmit a management or null data frame 3890ba2cbe9Sxc151355 * return 0 on success, non-zero on error 3900ba2cbe9Sxc151355 * ic_watchdog - [O] periodic run function, enabled by 3910ba2cbe9Sxc151355 * ieee80211_start_watchdog() 3920ba2cbe9Sxc151355 * ic_set_tim - [O] set/clear traffic indication map 3930ba2cbe9Sxc151355 * ic_set_shortslot - [O] enable/disable short slot timing 3940ba2cbe9Sxc151355 * ic_node_newassoc - [O] driver specific operation on a newly 3950ba2cbe9Sxc151355 * associated or re-assoced node 3960ba2cbe9Sxc151355 */ 3970ba2cbe9Sxc151355 int (*ic_xmit)(ieee80211com_t *, mblk_t *, uint8_t); 3980ba2cbe9Sxc151355 void (*ic_watchdog)(void *); 3990ba2cbe9Sxc151355 void (*ic_set_tim)(ieee80211com_t *, 4000ba2cbe9Sxc151355 ieee80211_node_t *, int); 4010ba2cbe9Sxc151355 void (*ic_set_shortslot)(ieee80211com_t *, int); 4020ba2cbe9Sxc151355 void (*ic_node_newassoc)(ieee80211_node_t *, int); 4030ba2cbe9Sxc151355 /* 4040ba2cbe9Sxc151355 * Functions initialized by ieee80211_attach(), driver could 4050ba2cbe9Sxc151355 * override these functions after calling ieee80211_attach() 4060ba2cbe9Sxc151355 * 4070ba2cbe9Sxc151355 * ic_reset - reset 4080ba2cbe9Sxc151355 * ic_recv_mgmt - handle received management frames 4090ba2cbe9Sxc151355 * ic_send_mgmt - construct and transmit management frames 4100ba2cbe9Sxc151355 * ic_newstate - handle state transition 4110ba2cbe9Sxc151355 * ic_node_alloc - allocate a new BSS info node 4120ba2cbe9Sxc151355 * ic_node_cleanup - cleanup or free memory spaces of a node 4130ba2cbe9Sxc151355 * ic_node_free - free a node 4140ba2cbe9Sxc151355 * ic_node_getrssi - get node's rssi 4150ba2cbe9Sxc151355 */ 4160ba2cbe9Sxc151355 int (*ic_reset)(ieee80211com_t *); 4170ba2cbe9Sxc151355 void (*ic_recv_mgmt)(ieee80211com_t *, 4180ba2cbe9Sxc151355 mblk_t *, ieee80211_node_t *, 4190ba2cbe9Sxc151355 int, int, uint32_t); 4200ba2cbe9Sxc151355 int (*ic_send_mgmt)(ieee80211com_t *, 4210ba2cbe9Sxc151355 ieee80211_node_t *, int, int); 4220ba2cbe9Sxc151355 int (*ic_newstate)(ieee80211com_t *, 4230ba2cbe9Sxc151355 enum ieee80211_state, int); 4240ba2cbe9Sxc151355 struct ieee80211_node *(*ic_node_alloc)(ieee80211com_t *); 4250ba2cbe9Sxc151355 void (*ic_node_cleanup)(ieee80211_node_t *); 4260ba2cbe9Sxc151355 void (*ic_node_free)(ieee80211_node_t *); 4270ba2cbe9Sxc151355 uint8_t (*ic_node_getrssi)(const ieee80211_node_t *); 4280ba2cbe9Sxc151355 4290ba2cbe9Sxc151355 kmutex_t ic_genlock; 4300ba2cbe9Sxc151355 void *ic_private; /* ieee80211 private data */ 4310ba2cbe9Sxc151355 }; 4320ba2cbe9Sxc151355 #define ic_nw_keys ic_crypto.cs_nw_keys 4330ba2cbe9Sxc151355 #define ic_def_txkey ic_crypto.cs_def_txkey 4340ba2cbe9Sxc151355 4350ba2cbe9Sxc151355 extern const char *ieee80211_state_name[IEEE80211_S_MAX]; 4360ba2cbe9Sxc151355 4370ba2cbe9Sxc151355 #define IEEE80211_RATE(_ix) \ 4380ba2cbe9Sxc151355 (in->in_rates.ir_rates[(_ix)] & IEEE80211_RATE_VAL) 4390ba2cbe9Sxc151355 4400ba2cbe9Sxc151355 #define ieee80211_new_state(_ic, _nstate, _arg) \ 4410ba2cbe9Sxc151355 (((_ic)->ic_newstate)((_ic), (_nstate), (_arg))) 4420ba2cbe9Sxc151355 4430ba2cbe9Sxc151355 #define ieee80211_macaddr_sprintf(_addr) \ 4440ba2cbe9Sxc151355 ether_sprintf((struct ether_addr *)(_addr)) 4450ba2cbe9Sxc151355 4460ba2cbe9Sxc151355 /* 4470ba2cbe9Sxc151355 * Node reference counting definitions. 4480ba2cbe9Sxc151355 * 4490ba2cbe9Sxc151355 * ieee80211_node_initref initialize the reference count to 1 4500ba2cbe9Sxc151355 * ieee80211_node_incref add a reference 4510ba2cbe9Sxc151355 * ieee80211_node_decref remove a reference 4520ba2cbe9Sxc151355 * ieee80211_node_decref_nv remove a reference and return new value 4530ba2cbe9Sxc151355 * ieee80211_node_refcnt reference count for printing (only) 4540ba2cbe9Sxc151355 */ 4550ba2cbe9Sxc151355 #include <sys/atomic.h> 4560ba2cbe9Sxc151355 #define ieee80211_node_initref(_in) \ 4570ba2cbe9Sxc151355 ((_in)->in_refcnt = 1) 4580ba2cbe9Sxc151355 #define ieee80211_node_incref(_in) \ 4590ba2cbe9Sxc151355 atomic_inc_uint(&(_in)->in_refcnt) 4600ba2cbe9Sxc151355 #define ieee80211_node_decref(_in) \ 4610ba2cbe9Sxc151355 atomic_dec_uint(&(_in)->in_refcnt) 4620ba2cbe9Sxc151355 #define ieee80211_node_decref_nv(_in) \ 4630ba2cbe9Sxc151355 atomic_dec_uint_nv(&(_in)->in_refcnt) 4640ba2cbe9Sxc151355 #define ieee80211_node_refcnt(_in) \ 4650ba2cbe9Sxc151355 (_in)->in_refcnt 4660ba2cbe9Sxc151355 4670ba2cbe9Sxc151355 typedef void ieee80211_iter_func(void *, ieee80211_node_t *); 4680ba2cbe9Sxc151355 4690ba2cbe9Sxc151355 /* Initialization */ 4700ba2cbe9Sxc151355 void ieee80211_attach(ieee80211com_t *); 4710ba2cbe9Sxc151355 void ieee80211_detach(ieee80211com_t *); 4720ba2cbe9Sxc151355 void ieee80211_media_init(ieee80211com_t *); 4730ba2cbe9Sxc151355 int ieee80211_ioctl(ieee80211com_t *, queue_t *, mblk_t *); 474*3a1a8936Szf162725 void ieee80211_register_door(ieee80211com_t *, const char *, int); 4750ba2cbe9Sxc151355 4760ba2cbe9Sxc151355 /* Protocol Processing */ 4770ba2cbe9Sxc151355 int ieee80211_input(ieee80211com_t *, mblk_t *, ieee80211_node_t *, 4780ba2cbe9Sxc151355 int32_t, uint32_t); 4790ba2cbe9Sxc151355 mblk_t *ieee80211_encap(ieee80211com_t *, mblk_t *, ieee80211_node_t *); 4800ba2cbe9Sxc151355 4810ba2cbe9Sxc151355 mblk_t *ieee80211_beacon_alloc(ieee80211com_t *, ieee80211_node_t *, 4820ba2cbe9Sxc151355 struct ieee80211_beacon_offsets *); 4830ba2cbe9Sxc151355 int ieee80211_beacon_update(ieee80211com_t *, ieee80211_node_t *, 4840ba2cbe9Sxc151355 struct ieee80211_beacon_offsets *, mblk_t *, int); 4850ba2cbe9Sxc151355 void ieee80211_beacon_miss(ieee80211com_t *); 4860ba2cbe9Sxc151355 4870ba2cbe9Sxc151355 void ieee80211_begin_scan(ieee80211com_t *, boolean_t); 4880ba2cbe9Sxc151355 void ieee80211_next_scan(ieee80211com_t *); 4890ba2cbe9Sxc151355 void ieee80211_end_scan(ieee80211com_t *); 4900ba2cbe9Sxc151355 void ieee80211_cancel_scan(ieee80211com_t *); 4910ba2cbe9Sxc151355 4920ba2cbe9Sxc151355 void ieee80211_sta_join(ieee80211com_t *, ieee80211_node_t *); 4930ba2cbe9Sxc151355 void ieee80211_sta_leave(ieee80211com_t *, ieee80211_node_t *); 4940ba2cbe9Sxc151355 boolean_t ieee80211_ibss_merge(ieee80211_node_t *); 4950ba2cbe9Sxc151355 4960ba2cbe9Sxc151355 /* Node Operation */ 4970ba2cbe9Sxc151355 ieee80211_node_t *ieee80211_ref_node(ieee80211_node_t *); 4980ba2cbe9Sxc151355 void ieee80211_unref_node(ieee80211_node_t **); 4990ba2cbe9Sxc151355 void ieee80211_node_authorize(ieee80211_node_t *); 5000ba2cbe9Sxc151355 void ieee80211_node_unauthorize(ieee80211_node_t *); 5010ba2cbe9Sxc151355 ieee80211_node_t *ieee80211_alloc_node(ieee80211com_t *, 5020ba2cbe9Sxc151355 ieee80211_node_table_t *, const uint8_t *); 5030ba2cbe9Sxc151355 void ieee80211_free_node(ieee80211_node_t *); 5040ba2cbe9Sxc151355 void ieee80211_node_table_reset(ieee80211_node_table_t *); 5050ba2cbe9Sxc151355 void ieee80211_iterate_nodes(ieee80211_node_table_t *, ieee80211_iter_func *, 5060ba2cbe9Sxc151355 void *); 5070ba2cbe9Sxc151355 ieee80211_node_t *ieee80211_find_node(ieee80211_node_table_t *, 5080ba2cbe9Sxc151355 const uint8_t *); 509a399b765Szf162725 ieee80211_node_t *ieee80211_find_node_with_ssid(ieee80211_node_table_t *, 510a399b765Szf162725 const uint8_t *, uint32_t, const uint8_t *); 5110ba2cbe9Sxc151355 ieee80211_node_t *ieee80211_find_txnode(ieee80211com_t *, 5120ba2cbe9Sxc151355 const uint8_t daddr[IEEE80211_ADDR_LEN]); 5130ba2cbe9Sxc151355 ieee80211_node_t *ieee80211_find_rxnode(ieee80211com_t *, 5140ba2cbe9Sxc151355 const struct ieee80211_frame *); 5150ba2cbe9Sxc151355 5160ba2cbe9Sxc151355 5170ba2cbe9Sxc151355 /* Crypto */ 5180ba2cbe9Sxc151355 extern struct ieee80211_key *ieee80211_crypto_encap(ieee80211com_t *, mblk_t *); 5190ba2cbe9Sxc151355 extern struct ieee80211_key *ieee80211_crypto_decap(ieee80211com_t *, mblk_t *, 5200ba2cbe9Sxc151355 int); 5210ba2cbe9Sxc151355 extern int ieee80211_crypto_newkey(ieee80211com_t *, int, int, 5220ba2cbe9Sxc151355 struct ieee80211_key *); 5230ba2cbe9Sxc151355 extern int ieee80211_crypto_delkey(ieee80211com_t *, struct ieee80211_key *); 5240ba2cbe9Sxc151355 extern int ieee80211_crypto_setkey(ieee80211com_t *, struct ieee80211_key *, 5250ba2cbe9Sxc151355 const uint8_t macaddr[IEEE80211_ADDR_LEN]); 5260ba2cbe9Sxc151355 5270ba2cbe9Sxc151355 /* Helper Functions */ 5280ba2cbe9Sxc151355 int ieee80211_stat(ieee80211com_t *ic, uint_t stat, uint64_t *val); 5290ba2cbe9Sxc151355 uint32_t ieee80211_chan2ieee(ieee80211com_t *, struct ieee80211_channel *); 5300ba2cbe9Sxc151355 enum ieee80211_phymode ieee80211_chan2mode(ieee80211com_t *, 5310ba2cbe9Sxc151355 struct ieee80211_channel *); 5320ba2cbe9Sxc151355 uint32_t ieee80211_ieee2mhz(uint32_t, uint32_t); 5330ba2cbe9Sxc151355 void ieee80211_reset_chan(ieee80211com_t *); 5340ba2cbe9Sxc151355 void ieee80211_dump_pkt(const uint8_t *, int32_t, int32_t, int32_t); 5350ba2cbe9Sxc151355 void ieee80211_watchdog(void *); 5360ba2cbe9Sxc151355 void ieee80211_start_watchdog(ieee80211com_t *, uint32_t); 5370ba2cbe9Sxc151355 void ieee80211_stop_watchdog(ieee80211com_t *); 5380ba2cbe9Sxc151355 539a399b765Szf162725 void *ieee80211_malloc(size_t); 540a399b765Szf162725 void ieee80211_free(void *); 541a399b765Szf162725 5420ba2cbe9Sxc151355 #ifdef __cplusplus 5430ba2cbe9Sxc151355 } 5440ba2cbe9Sxc151355 #endif 5450ba2cbe9Sxc151355 5460ba2cbe9Sxc151355 #endif /* _SYS_NET80211_H */ 547