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