ieee80211_var.h revision 173273
1116742Ssam/*- 2116904Ssam * Copyright (c) 2001 Atsushi Onoe 3170360Ssam * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting 4116742Ssam * All rights reserved. 5116742Ssam * 6116742Ssam * Redistribution and use in source and binary forms, with or without 7116742Ssam * modification, are permitted provided that the following conditions 8116742Ssam * are met: 9116742Ssam * 1. Redistributions of source code must retain the above copyright 10116742Ssam * notice, this list of conditions and the following disclaimer. 11116742Ssam * 2. Redistributions in binary form must reproduce the above copyright 12116742Ssam * notice, this list of conditions and the following disclaimer in the 13116742Ssam * documentation and/or other materials provided with the distribution. 14116742Ssam * 15116904Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16116904Ssam * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17116904Ssam * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18116904Ssam * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19116904Ssam * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20116904Ssam * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21116904Ssam * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22116904Ssam * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23116904Ssam * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24116904Ssam * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25116904Ssam * 26116742Ssam * $FreeBSD: head/sys/net80211/ieee80211_var.h 173273 2007-11-02 05:22:25Z sam $ 27116742Ssam */ 28116742Ssam#ifndef _NET80211_IEEE80211_VAR_H_ 29116742Ssam#define _NET80211_IEEE80211_VAR_H_ 30116742Ssam 31116742Ssam/* 32116742Ssam * Definitions for IEEE 802.11 drivers. 33116742Ssam */ 34138568Ssam#define IEEE80211_DEBUG 35138568Ssam#undef IEEE80211_DEBUG_REFCNT /* node refcnt stuff */ 36116742Ssam 37138568Ssam/* NB: portability glue must go first */ 38138568Ssam#ifdef __NetBSD__ 39138568Ssam#include <net80211/ieee80211_netbsd.h> 40138568Ssam#elif __FreeBSD__ 41138568Ssam#include <net80211/ieee80211_freebsd.h> 42138568Ssam#elif __linux__ 43138568Ssam#include <net80211/ieee80211_linux.h> 44138568Ssam#else 45138568Ssam#error "No support for your operating system!" 46138568Ssam#endif 47138568Ssam 48138568Ssam#include <net80211/_ieee80211.h> 49116742Ssam#include <net80211/ieee80211.h> 50116742Ssam#include <net80211/ieee80211_crypto.h> 51121180Ssam#include <net80211/ieee80211_ioctl.h> /* for ieee80211_stats */ 52116742Ssam#include <net80211/ieee80211_node.h> 53170530Ssam#include <net80211/ieee80211_power.h> 54116742Ssam#include <net80211/ieee80211_proto.h> 55170530Ssam#include <net80211/ieee80211_scan.h> 56116742Ssam 57138568Ssam#define IEEE80211_TXPOWER_MAX 100 /* .5 dbM (XXX units?) */ 58138568Ssam#define IEEE80211_TXPOWER_MIN 0 /* kill radio */ 59116742Ssam 60138568Ssam#define IEEE80211_DTIM_DEFAULT 1 /* default DTIM period */ 61140754Ssam#define IEEE80211_BINTVAL_DEFAULT 100 /* default beacon interval (TU's) */ 62116742Ssam 63153349Ssam#define IEEE80211_BMISS_MAX 2 /* maximum consecutive bmiss allowed */ 64155688Ssam#define IEEE80211_HWBMISS_DEFAULT 7 /* h/w bmiss threshold (beacons) */ 65153349Ssam 66170530Ssam#define IEEE80211_BGSCAN_INTVAL_MIN 15 /* min bg scan intvl (secs) */ 67170530Ssam#define IEEE80211_BGSCAN_INTVAL_DEFAULT (5*60) /* default bg scan intvl */ 68170530Ssam 69170530Ssam#define IEEE80211_BGSCAN_IDLE_MIN 100 /* min idle time (ms) */ 70170530Ssam#define IEEE80211_BGSCAN_IDLE_DEFAULT 250 /* default idle time (ms) */ 71170530Ssam 72170530Ssam#define IEEE80211_SCAN_VALID_MIN 10 /* min scan valid time (secs) */ 73170530Ssam#define IEEE80211_SCAN_VALID_DEFAULT 60 /* default scan valid time */ 74170530Ssam 75138568Ssam#define IEEE80211_PS_SLEEP 0x1 /* STA is in power saving mode */ 76138568Ssam#define IEEE80211_PS_MAX_QUEUE 50 /* maximum saved packets */ 77116742Ssam 78148290Ssam#define IEEE80211_FIXED_RATE_NONE -1 79153346Ssam#define IEEE80211_MCAST_RATE_DEFAULT (2*1) /* default mcast rate (1M) */ 80148290Ssam 81148291Ssam#define IEEE80211_RTS_DEFAULT IEEE80211_RTS_MAX 82148291Ssam#define IEEE80211_FRAG_DEFAULT IEEE80211_FRAG_MAX 83148291Ssam 84167242Ssam#define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024) 85167242Ssam#define IEEE80211_TU_TO_MS(x) (((x) * 1024) / 1000) 86167242Ssam#define IEEE80211_TU_TO_TICKS(x)(((x) * 1024 * hz) / (1000 * 1000)) 87140754Ssam 88138568Ssamstruct ieee80211_aclator; 89138568Ssamstruct sysctl_ctx_list; 90116742Ssam 91138568Ssamstruct ieee80211com { 92138568Ssam SLIST_ENTRY(ieee80211com) ic_next; 93138568Ssam struct ifnet *ic_ifp; /* associated device */ 94170530Ssam ieee80211_com_lock_t ic_comlock; /* state update lock */ 95170530Ssam ieee80211_beacon_lock_t ic_beaconlock; /* beacon update lock */ 96138568Ssam struct ieee80211_stats ic_stats; /* statistics */ 97138568Ssam struct sysctl_ctx_list *ic_sysctl; /* dynamic sysctl context */ 98170530Ssam uint32_t ic_debug; /* debug msg flags */ 99138568Ssam int ic_vap; /* virtual AP index */ 100170530Ssam int ic_headroom; /* driver tx headroom needs */ 101170530Ssam enum ieee80211_phytype ic_phytype; /* XXX wrong for multi-mode */ 102170530Ssam enum ieee80211_opmode ic_opmode; /* operation mode */ 103170530Ssam struct ifmedia ic_media; /* interface media config */ 104170530Ssam uint8_t ic_myaddr[IEEE80211_ADDR_LEN]; 105127648Ssam 106170530Ssam uint32_t ic_flags; /* state flags */ 107170530Ssam uint32_t ic_flags_ext; /* extended state flags */ 108173273Ssam uint32_t ic_flags_ven; /* vendor state flags */ 109170530Ssam uint32_t ic_caps; /* capabilities */ 110173273Ssam uint32_t ic_htcaps; /* HT capabilities */ 111170530Ssam uint8_t ic_modecaps[2]; /* set of mode capabilities */ 112170530Ssam uint16_t ic_curmode; /* current mode */ 113116742Ssam struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX]; 114170530Ssam uint16_t ic_bintval; /* beacon interval */ 115170530Ssam uint16_t ic_lintval; /* listen interval */ 116170530Ssam uint16_t ic_holdover; /* PM hold over duration */ 117170530Ssam uint16_t ic_txpowlimit; /* global tx power limit */ 118170530Ssam int ic_ampdu_rxmax; /* A-MPDU rx limit (bytes) */ 119170530Ssam int ic_ampdu_density;/* A-MPDU density */ 120170530Ssam int ic_ampdu_limit; /* A-MPDU tx limit (bytes) */ 121170530Ssam int ic_amsdu_limit; /* A-MSDU tx limit (bytes) */ 122170530Ssam 123170530Ssam /* 124170530Ssam * Channel state: 125170530Ssam * 126170530Ssam * ic_channels is the set of available channels for the device; 127170530Ssam * it is setup by the driver 128170530Ssam * ic_nchans is the number of valid entries in ic_channels 129170530Ssam * ic_chan_avail is a bit vector of these channels used to check 130170530Ssam * whether a channel is available w/o searching the channel table. 131170530Ssam * ic_chan_active is a (potentially) constrained subset of 132170530Ssam * ic_chan_avail that reflects any mode setting or user-specified 133170530Ssam * limit on the set of channels to use/scan 134170530Ssam * ic_curchan is the current channel the device is set to; it may 135170530Ssam * be different from ic_bsschan when we are off-channel scanning 136170530Ssam * or otherwise doing background work 137170530Ssam * ic_bsschan is the channel selected for operation; it may 138170530Ssam * be undefined (IEEE80211_CHAN_ANYC) 139170530Ssam * ic_prevchan is a cached ``previous channel'' used to optimize 140170530Ssam * lookups when switching back+forth between two channels 141170530Ssam * (e.g. for dynamic turbo) 142170530Ssam */ 143170530Ssam int ic_nchans; /* # entries in ic_channels */ 144116742Ssam struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX+1]; 145170530Ssam uint8_t ic_chan_avail[IEEE80211_CHAN_BYTES]; 146170530Ssam uint8_t ic_chan_active[IEEE80211_CHAN_BYTES]; 147170530Ssam uint8_t ic_chan_scan[IEEE80211_CHAN_BYTES]; 148170530Ssam struct ieee80211_channel *ic_curchan; /* current channel */ 149170530Ssam struct ieee80211_channel *ic_bsschan; /* bss channel */ 150170530Ssam struct ieee80211_channel *ic_prevchan; /* previous channel */ 151170530Ssam int ic_countrycode; /* ISO country code */ 152170530Ssam uint16_t ic_regdomain; /* regulatory domain */ 153170530Ssam uint8_t ic_location; /* unknown, indoor, outdoor */ 154170530Ssam 155170530Ssam struct ieee80211_scan_state *ic_scan; /* scan state */ 156170530Ssam enum ieee80211_roamingmode ic_roaming; /* roaming mode */ 157170530Ssam int ic_lastdata; /* time of last data frame */ 158170530Ssam int ic_lastscan; /* time last scan completed */ 159170530Ssam int ic_des_nssid; /* # desired ssids */ 160170530Ssam struct ieee80211_scan_ssid ic_des_ssid[1];/* desired ssid table */ 161170530Ssam uint8_t ic_des_bssid[IEEE80211_ADDR_LEN]; 162170530Ssam struct ieee80211_channel *ic_des_chan; /* desired channel */ 163170530Ssam int ic_des_mode; /* desired phymode */ 164170530Ssam u_int ic_bgscanidle; /* bg scan idle threshold */ 165170530Ssam u_int ic_bgscanintvl; /* bg scan min interval */ 166170530Ssam u_int ic_scanvalid; /* scan cache valid threshold */ 167170530Ssam struct ieee80211_roam ic_roam; /* sta-mode roaming state */ 168170530Ssam 169170530Ssam struct ieee80211_node_table ic_sta; /* stations/neighbors */ 170170530Ssam 171170530Ssam struct ieee80211_wme_state ic_wme; /* WME/WMM state */ 172170530Ssam const struct ieee80211_aclator *ic_acl; /* aclator glue */ 173170530Ssam void *ic_as; /* private aclator state */ 174170530Ssam 175170530Ssam enum ieee80211_protmode ic_protmode; /* 802.11g protection mode */ 176170530Ssam uint16_t ic_nonerpsta; /* # non-ERP stations */ 177170530Ssam uint16_t ic_longslotsta; /* # long slot time stations */ 178170530Ssam uint16_t ic_sta_assoc; /* stations associated */ 179173273Ssam uint16_t ic_ht_sta_assoc;/* HT stations associated */ 180173273Ssam uint16_t ic_ht40_sta_assoc;/* HT40 stations associated */ 181172211Ssam uint8_t ic_curhtprotmode;/* HTINFO bss state */ 182173273Ssam enum ieee80211_protmode ic_htprotmode; /* HT protection mode */ 183172211Ssam int ic_lastnonerp; /* last time non-ERP sta noted*/ 184173273Ssam int ic_lastnonht; /* last time non-HT sta noted */ 185170530Ssam 186116742Ssam struct ifqueue ic_mgtq; 187116742Ssam enum ieee80211_state ic_state; /* 802.11 state */ 188170530Ssam struct callout ic_mgtsend; /* mgmt frame response timer */ 189170530Ssam uint32_t *ic_aid_bitmap; /* association id map */ 190170530Ssam uint16_t ic_max_aid; 191170530Ssam uint16_t ic_ps_sta; /* stations in power save */ 192170530Ssam uint16_t ic_ps_pending; /* ps sta's w/ pending frames */ 193170530Ssam uint8_t *ic_tim_bitmap; /* power-save stations w/ data*/ 194170530Ssam uint16_t ic_tim_len; /* ic_tim_bitmap size (bytes) */ 195170530Ssam uint8_t ic_dtim_period; /* DTIM period */ 196170530Ssam uint8_t ic_dtim_count; /* DTIM count for last bcn */ 197116742Ssam struct bpf_if *ic_rawbpf; /* packet filter structure */ 198116742Ssam struct ieee80211_node *ic_bss; /* information for this node */ 199170530Ssam int ic_fixed_rate; /* 802.11 rate or -1 */ 200153346Ssam int ic_mcast_rate; /* rate for mcast frames */ 201170530Ssam uint16_t ic_rtsthreshold; 202170530Ssam uint16_t ic_fragthreshold; 203170530Ssam uint8_t ic_bmissthreshold; 204170530Ssam uint8_t ic_bmiss_count; /* current beacon miss count */ 205153349Ssam int ic_bmiss_max; /* max bmiss before scan */ 206170530Ssam uint16_t ic_swbmiss_count;/* beacons in last period */ 207170530Ssam uint16_t ic_swbmiss_period;/* s/w bmiss period */ 208154736Ssam struct callout ic_swbmiss; /* s/w beacon miss timer */ 209170530Ssam 210170530Ssam uint16_t ic_txmin; /* min tx retry count */ 211170530Ssam uint16_t ic_txmax; /* max tx retry count */ 212170530Ssam uint16_t ic_txlifetime; /* tx lifetime */ 213170530Ssam struct callout ic_inact; /* inactivity timer wait */ 214138568Ssam void *ic_opt_ie; /* user-specified IE's */ 215170530Ssam uint16_t ic_opt_ie_len; /* length of ni_opt_ie */ 216138568Ssam int ic_inact_init; /* initial setting */ 217138568Ssam int ic_inact_auth; /* auth but not assoc setting */ 218138568Ssam int ic_inact_run; /* authorized setting */ 219138568Ssam int ic_inact_probe; /* inactive probe time */ 220138568Ssam 221138568Ssam /* 222138568Ssam * Cipher state/configuration. 223138568Ssam */ 224138568Ssam struct ieee80211_crypto_state ic_crypto; 225138568Ssam#define ic_nw_keys ic_crypto.cs_nw_keys /* XXX compatibility */ 226138568Ssam#define ic_def_txkey ic_crypto.cs_def_txkey /* XXX compatibility */ 227138568Ssam /* 228138568Ssam * 802.1x glue. When an authenticator attaches it 229138568Ssam * fills in this section. We assume that when ic_ec 230138568Ssam * is setup that the methods are safe to call. 231138568Ssam */ 232138568Ssam const struct ieee80211_authenticator *ic_auth; 233138568Ssam struct eapolcom *ic_ec; 234138568Ssam 235170530Ssam /* send/recv 802.11 management frame */ 236170530Ssam int (*ic_send_mgmt)(struct ieee80211com *, 237170530Ssam struct ieee80211_node *, int, int); 238170530Ssam void (*ic_recv_mgmt)(struct ieee80211com *, 239170530Ssam struct mbuf *, struct ieee80211_node *, 240170530Ssam int, int, int, uint32_t); 241170530Ssam /* send raw 802.11 frame */ 242170530Ssam int (*ic_raw_xmit)(struct ieee80211_node *, 243170530Ssam struct mbuf *, 244170530Ssam const struct ieee80211_bpf_params *); 245170530Ssam /* reset device state after 802.11 parameter/state change */ 246170530Ssam int (*ic_reset)(struct ifnet *); 247172211Ssam /* [schedule] beacon frame update */ 248172211Ssam void (*ic_update_beacon)(struct ieee80211com *, int); 249170530Ssam /* update device state for 802.11 slot time change */ 250170530Ssam void (*ic_updateslot)(struct ifnet *); 251170530Ssam /* new station association callback/notification */ 252170530Ssam void (*ic_newassoc)(struct ieee80211_node *, int); 253170530Ssam /* node state management */ 254170530Ssam struct ieee80211_node *(*ic_node_alloc)(struct ieee80211_node_table*); 255170530Ssam void (*ic_node_free)(struct ieee80211_node *); 256170530Ssam void (*ic_node_cleanup)(struct ieee80211_node *); 257170530Ssam int8_t (*ic_node_getrssi)(const struct ieee80211_node*); 258170530Ssam void (*ic_node_getsignal)(const struct ieee80211_node*, 259170530Ssam int8_t *, int8_t *); 260170530Ssam /* scanning support */ 261170530Ssam void (*ic_scan_start)(struct ieee80211com *); 262170530Ssam void (*ic_scan_end)(struct ieee80211com *); 263170530Ssam void (*ic_set_channel)(struct ieee80211com *); 264170530Ssam void (*ic_scan_curchan)(struct ieee80211com *, 265170530Ssam unsigned long); 266170530Ssam void (*ic_scan_mindwell)(struct ieee80211com *); 267170530Ssam /* per-vap eventually... */ 268170530Ssam int (*ic_newstate)(struct ieee80211com *, 269170530Ssam enum ieee80211_state, int); 270170530Ssam void (*ic_set_tim)(struct ieee80211_node *, int); 271170530Ssam 272138568Ssam /* 273170530Ssam * 802.11n ADDBA support. A simple/generic implementation 274170530Ssam * of A-MPDU tx aggregation is provided; the driver may 275170530Ssam * override these methods to provide their own support. 276170530Ssam * A-MPDU rx re-ordering happens automatically if the 277170530Ssam * driver passes out-of-order frames to ieee80211_input 278170530Ssam * from an assocated HT station. 279138568Ssam */ 280170530Ssam void (*ic_recv_action)(struct ieee80211_node *, 281170530Ssam const uint8_t *frm, const uint8_t *efrm); 282170530Ssam int (*ic_send_action)(struct ieee80211_node *, 283170530Ssam int category, int action, 284170530Ssam uint16_t args[4]); 285170530Ssam /* start/stop doing A-MPDU tx aggregation for a station */ 286170530Ssam int (*ic_addba_request)(struct ieee80211_node *, 287170530Ssam struct ieee80211_tx_ampdu *, 288170530Ssam int dialogtoken, int baparamset, 289170530Ssam int batimeout); 290170530Ssam int (*ic_addba_response)(struct ieee80211_node *, 291170530Ssam struct ieee80211_tx_ampdu *, 292170530Ssam int status, int baparamset, int batimeout); 293170530Ssam void (*ic_addba_stop)(struct ieee80211_node *, 294170530Ssam struct ieee80211_tx_ampdu *); 295116742Ssam}; 296116742Ssam 297116742Ssam#define IEEE80211_ADDR_EQ(a1,a2) (memcmp(a1,a2,IEEE80211_ADDR_LEN) == 0) 298116742Ssam#define IEEE80211_ADDR_COPY(dst,src) memcpy(dst,src,IEEE80211_ADDR_LEN) 299116742Ssam 300116742Ssam/* ic_flags */ 301148288Ssam/* NB: bits 0x4c available */ 302170530Ssam#define IEEE80211_F_TURBOP 0x00000001 /* CONF: ATH Turbo enabled*/ 303170530Ssam#define IEEE80211_F_COMP 0x00000002 /* CONF: ATH comp enabled */ 304170530Ssam#define IEEE80211_F_FF 0x00000004 /* CONF: ATH FF enabled */ 305170530Ssam#define IEEE80211_F_BURST 0x00000008 /* CONF: bursting enabled */ 306138568Ssam/* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */ 307138568Ssam#define IEEE80211_F_PRIVACY 0x00000010 /* CONF: privacy enabled */ 308147794Ssam#define IEEE80211_F_PUREG 0x00000020 /* CONF: 11g w/o 11b sta's */ 309138568Ssam#define IEEE80211_F_SCAN 0x00000080 /* STATUS: scanning */ 310138568Ssam#define IEEE80211_F_ASCAN 0x00000100 /* STATUS: active scan */ 311138568Ssam#define IEEE80211_F_SIBSS 0x00000200 /* STATUS: start IBSS */ 312138568Ssam/* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */ 313138568Ssam#define IEEE80211_F_SHSLOT 0x00000400 /* STATUS: use short slot time*/ 314138568Ssam#define IEEE80211_F_PMGTON 0x00000800 /* CONF: Power mgmt enable */ 315138568Ssam#define IEEE80211_F_DESBSSID 0x00001000 /* CONF: des_bssid is set */ 316138568Ssam#define IEEE80211_F_WME 0x00002000 /* CONF: enable WME use */ 317148288Ssam#define IEEE80211_F_BGSCAN 0x00004000 /* CONF: bg scan enabled (???)*/ 318138568Ssam#define IEEE80211_F_SWRETRY 0x00008000 /* CONF: sw tx retry enabled */ 319138568Ssam#define IEEE80211_F_TXPOW_FIXED 0x00010000 /* TX Power: fixed rate */ 320138568Ssam#define IEEE80211_F_IBSSON 0x00020000 /* CONF: IBSS creation enable */ 321138568Ssam#define IEEE80211_F_SHPREAMBLE 0x00040000 /* STATUS: use short preamble */ 322138568Ssam#define IEEE80211_F_DATAPAD 0x00080000 /* CONF: do alignment pad */ 323127648Ssam#define IEEE80211_F_USEPROT 0x00100000 /* STATUS: protection enabled */ 324127648Ssam#define IEEE80211_F_USEBARKER 0x00200000 /* STATUS: use barker preamble*/ 325138568Ssam#define IEEE80211_F_WPA1 0x00800000 /* CONF: WPA enabled */ 326138568Ssam#define IEEE80211_F_WPA2 0x01000000 /* CONF: WPA2 enabled */ 327138568Ssam#define IEEE80211_F_WPA 0x01800000 /* CONF: WPA/WPA2 enabled */ 328138568Ssam#define IEEE80211_F_DROPUNENC 0x02000000 /* CONF: drop unencrypted */ 329138568Ssam#define IEEE80211_F_COUNTERM 0x04000000 /* CONF: TKIP countermeasures */ 330138568Ssam#define IEEE80211_F_HIDESSID 0x08000000 /* CONF: hide SSID in beacon */ 331138568Ssam#define IEEE80211_F_NOBRIDGE 0x10000000 /* CONF: dis. internal bridge */ 332170530Ssam#define IEEE80211_F_DOTH 0x40000000 /* CONF: 11h enabled */ 333116742Ssam 334170530Ssam/* Atheros protocol-specific flags */ 335170530Ssam#define IEEE80211_F_ATHEROS \ 336170530Ssam (IEEE80211_F_FF | IEEE80211_F_COMP | IEEE80211_F_TURBOP) 337170530Ssam/* Check if an Atheros capability was negotiated for use */ 338170530Ssam#define IEEE80211_ATH_CAP(ic, ni, bit) \ 339170530Ssam ((ic)->ic_flags & (ni)->ni_ath_flags & (bit)) 340170530Ssam 341148288Ssam/* ic_flags_ext */ 342173273Ssam#define IEEE80211_FEXT_NONHT_PR 0x00000001 /* STATUS: non-HT sta present */ 343172062Ssam#define IEEE80211_FEXT_INACT 0x00000002 /* CONF: sta inact handling */ 344148288Ssam/* 0x00000006 reserved */ 345170530Ssam#define IEEE80211_FEXT_BGSCAN 0x00000008 /* STATUS: complete bgscan */ 346172211Ssam#define IEEE80211_FEXT_NONERP_PR 0x00000200 /* STATUS: non-ERP sta present*/ 347170530Ssam#define IEEE80211_FEXT_SWBMISS 0x00000400 /* CONF: do bmiss in s/w */ 348156358Ssam#define IEEE80211_FEXT_PROBECHAN 0x00020000 /* CONF: probe passive channel*/ 349170530Ssam#define IEEE80211_FEXT_HT 0x00080000 /* CONF: HT supported */ 350170530Ssam#define IEEE80211_FEXT_AMPDU_TX 0x00100000 /* CONF: A-MPDU tx supported */ 351170530Ssam#define IEEE80211_FEXT_AMPDU_RX 0x00200000 /* CONF: A-MPDU tx supported */ 352170530Ssam#define IEEE80211_FEXT_AMSDU_TX 0x00400000 /* CONF: A-MSDU tx supported */ 353170530Ssam#define IEEE80211_FEXT_AMSDU_RX 0x00800000 /* CONF: A-MSDU tx supported */ 354170530Ssam#define IEEE80211_FEXT_USEHT40 0x01000000 /* CONF: 20/40 use enabled */ 355170530Ssam#define IEEE80211_FEXT_PUREN 0x02000000 /* CONF: 11n w/o legacy sta's */ 356170530Ssam#define IEEE80211_FEXT_SHORTGI20 0x04000000 /* CONF: short GI in HT20 */ 357170530Ssam#define IEEE80211_FEXT_SHORTGI40 0x08000000 /* CONF: short GI in HT40 */ 358170530Ssam#define IEEE80211_FEXT_HTCOMPAT 0x10000000 /* CONF: HT vendor OUI's */ 359148288Ssam 360121176Ssam/* ic_caps */ 361116742Ssam#define IEEE80211_C_WEP 0x00000001 /* CAPABILITY: WEP available */ 362138568Ssam#define IEEE80211_C_TKIP 0x00000002 /* CAPABILITY: TKIP available */ 363138568Ssam#define IEEE80211_C_AES 0x00000004 /* CAPABILITY: AES OCB avail */ 364138568Ssam#define IEEE80211_C_AES_CCM 0x00000008 /* CAPABILITY: AES CCM avail */ 365138568Ssam#define IEEE80211_C_CKIP 0x00000020 /* CAPABILITY: CKIP available */ 366148288Ssam#define IEEE80211_C_FF 0x00000040 /* CAPABILITY: ATH FF avail */ 367148288Ssam#define IEEE80211_C_TURBOP 0x00000080 /* CAPABILITY: ATH Turbo avail*/ 368138568Ssam#define IEEE80211_C_IBSS 0x00000100 /* CAPABILITY: IBSS available */ 369138568Ssam#define IEEE80211_C_PMGT 0x00000200 /* CAPABILITY: Power mgmt */ 370138568Ssam#define IEEE80211_C_HOSTAP 0x00000400 /* CAPABILITY: HOSTAP avail */ 371138568Ssam#define IEEE80211_C_AHDEMO 0x00000800 /* CAPABILITY: Old Adhoc Demo */ 372138568Ssam#define IEEE80211_C_SWRETRY 0x00001000 /* CAPABILITY: sw tx retry */ 373138568Ssam#define IEEE80211_C_TXPMGT 0x00002000 /* CAPABILITY: tx power mgmt */ 374138568Ssam#define IEEE80211_C_SHSLOT 0x00004000 /* CAPABILITY: short slottime */ 375138568Ssam#define IEEE80211_C_SHPREAMBLE 0x00008000 /* CAPABILITY: short preamble */ 376138568Ssam#define IEEE80211_C_MONITOR 0x00010000 /* CAPABILITY: monitor mode */ 377138568Ssam#define IEEE80211_C_TKIPMIC 0x00020000 /* CAPABILITY: TKIP MIC avail */ 378138568Ssam#define IEEE80211_C_WPA1 0x00800000 /* CAPABILITY: WPA1 avail */ 379138568Ssam#define IEEE80211_C_WPA2 0x01000000 /* CAPABILITY: WPA2 avail */ 380138568Ssam#define IEEE80211_C_WPA 0x01800000 /* CAPABILITY: WPA1+WPA2 avail*/ 381138568Ssam#define IEEE80211_C_BURST 0x02000000 /* CAPABILITY: frame bursting */ 382138568Ssam#define IEEE80211_C_WME 0x04000000 /* CAPABILITY: WME avail */ 383148288Ssam#define IEEE80211_C_WDS 0x08000000 /* CAPABILITY: 4-addr support */ 384148288Ssam/* 0x10000000 reserved */ 385148288Ssam#define IEEE80211_C_BGSCAN 0x20000000 /* CAPABILITY: bg scanning */ 386148288Ssam#define IEEE80211_C_TXFRAG 0x40000000 /* CAPABILITY: tx fragments */ 387138568Ssam/* XXX protection/barker? */ 388116742Ssam 389138568Ssam#define IEEE80211_C_CRYPTO 0x0000002f /* CAPABILITY: crypto alg's */ 390116742Ssam 391170530Ssam/* 392170530Ssam * ic_htcaps: HT-specific device/driver capabilities 393170530Ssam * 394170530Ssam * NB: the low 16-bits are the 802.11 definitions, the upper 395170530Ssam * 16-bits are used to define s/w/driver capabilities. 396170530Ssam */ 397170530Ssam#define IEEE80211_HTC_AMPDU 0x00010000 /* CAPABILITY: A-MPDU tx */ 398170530Ssam#define IEEE80211_HTC_AMSDU 0x00020000 /* CAPABILITY: A-MSDU tx */ 399173273Ssam/* NB: HT40 is implied by IEEE80211_HTCAP_CHWIDTH40 */ 400173273Ssam#define IEEE80211_HTC_HT 0x00040000 /* CAPABILITY: HT operation */ 401170530Ssam 402138568Ssamvoid ieee80211_ifattach(struct ieee80211com *); 403138568Ssamvoid ieee80211_ifdetach(struct ieee80211com *); 404170530Ssamconst struct ieee80211_rateset *ieee80211_get_suprates(struct ieee80211com *ic, 405165569Ssam const struct ieee80211_channel *); 406138568Ssamvoid ieee80211_announce(struct ieee80211com *); 407170530Ssamvoid ieee80211_announce_channels(struct ieee80211com *); 408138568Ssamvoid ieee80211_media_init(struct ieee80211com *, 409138568Ssam ifm_change_cb_t, ifm_stat_cb_t); 410170530Ssamstruct ieee80211com *ieee80211_find_vap(const uint8_t mac[IEEE80211_ADDR_LEN]); 411116742Ssamint ieee80211_media_change(struct ifnet *); 412116742Ssamvoid ieee80211_media_status(struct ifnet *, struct ifmediareq *); 413138568Ssamint ieee80211_ioctl(struct ieee80211com *, u_long, caddr_t); 414138568Ssamint ieee80211_cfgget(struct ieee80211com *, u_long, caddr_t); 415138568Ssamint ieee80211_cfgset(struct ieee80211com *, u_long, caddr_t); 416116742Ssamint ieee80211_rate2media(struct ieee80211com *, int, 417116742Ssam enum ieee80211_phymode); 418116742Ssamint ieee80211_media2rate(int); 419152450Ssamint ieee80211_mhz2ieee(u_int, u_int); 420170530Ssamint ieee80211_chan2ieee(struct ieee80211com *, 421170530Ssam const struct ieee80211_channel *); 422116742Ssamu_int ieee80211_ieee2mhz(u_int, u_int); 423170530Ssamstruct ieee80211_channel *ieee80211_find_channel(struct ieee80211com *, 424170530Ssam int freq, int flags); 425116742Ssamint ieee80211_setmode(struct ieee80211com *, enum ieee80211_phymode); 426170530Ssamenum ieee80211_phymode ieee80211_chan2mode(const struct ieee80211_channel *); 427116742Ssam 428138568Ssam/* 429138568Ssam * Key update synchronization methods. XXX should not be visible. 430138568Ssam */ 431138568Ssamstatic __inline void 432138568Ssamieee80211_key_update_begin(struct ieee80211com *ic) 433138568Ssam{ 434138568Ssam ic->ic_crypto.cs_key_update_begin(ic); 435138568Ssam} 436138568Ssamstatic __inline void 437138568Ssamieee80211_key_update_end(struct ieee80211com *ic) 438138568Ssam{ 439138568Ssam ic->ic_crypto.cs_key_update_end(ic); 440138568Ssam} 441138568Ssam 442139509Ssam/* 443139509Ssam * XXX these need to be here for IEEE80211_F_DATAPAD 444139509Ssam */ 445139509Ssam 446139509Ssam/* 447139509Ssam * Return the space occupied by the 802.11 header and any 448139509Ssam * padding required by the driver. This works for a 449139509Ssam * management or data frame. 450139509Ssam */ 451139509Ssamstatic __inline int 452139509Ssamieee80211_hdrspace(struct ieee80211com *ic, const void *data) 453139509Ssam{ 454139509Ssam int size = ieee80211_hdrsize(data); 455139509Ssam if (ic->ic_flags & IEEE80211_F_DATAPAD) 456170530Ssam size = roundup(size, sizeof(uint32_t)); 457139509Ssam return size; 458139509Ssam} 459139509Ssam 460139509Ssam/* 461139509Ssam * Like ieee80211_hdrspace, but handles any type of frame. 462139509Ssam */ 463139509Ssamstatic __inline int 464139509Ssamieee80211_anyhdrspace(struct ieee80211com *ic, const void *data) 465139509Ssam{ 466139509Ssam int size = ieee80211_anyhdrsize(data); 467139509Ssam if (ic->ic_flags & IEEE80211_F_DATAPAD) 468170530Ssam size = roundup(size, sizeof(uint32_t)); 469139509Ssam return size; 470139509Ssam} 471139509Ssam 472172211Ssam/* 473172211Ssam * Notify a driver that beacon state has been updated. 474172211Ssam */ 475172211Ssamstatic __inline void 476172211Ssamieee80211_beacon_notify(struct ieee80211com *ic, int what) 477172211Ssam{ 478172211Ssam if (ic->ic_state == IEEE80211_S_RUN) 479172211Ssam ic->ic_update_beacon(ic, what); 480172211Ssam} 481172211Ssam 482173273Ssam/* 483173273Ssam * Debugging facilities compiled in when IEEE80211_DEBUG is defined. 484173273Ssam * 485173273Ssam * The intent is that any problem in the net80211 layer can be 486173273Ssam * diagnosed by inspecting the statistics (dumped by the wlanstats 487173273Ssam * program) and/or the msgs generated by net80211. Messages are 488173273Ssam * broken into functional classes and can be controlled with the 489173273Ssam * wlandebug program. Certain of these msg groups are for facilities 490173273Ssam * that are no longer part of net80211 (e.g. IEEE80211_MSG_DOT1X). 491173273Ssam */ 492170530Ssam#define IEEE80211_MSG_11N 0x80000000 /* 11n mode debug */ 493138568Ssam#define IEEE80211_MSG_DEBUG 0x40000000 /* IFF_DEBUG equivalent */ 494138568Ssam#define IEEE80211_MSG_DUMPPKTS 0x20000000 /* IFF_LINK2 equivalant */ 495138568Ssam#define IEEE80211_MSG_CRYPTO 0x10000000 /* crypto work */ 496138568Ssam#define IEEE80211_MSG_INPUT 0x08000000 /* input handling */ 497138568Ssam#define IEEE80211_MSG_XRATE 0x04000000 /* rate set handling */ 498138568Ssam#define IEEE80211_MSG_ELEMID 0x02000000 /* element id parsing */ 499138568Ssam#define IEEE80211_MSG_NODE 0x01000000 /* node handling */ 500138568Ssam#define IEEE80211_MSG_ASSOC 0x00800000 /* association handling */ 501138568Ssam#define IEEE80211_MSG_AUTH 0x00400000 /* authentication handling */ 502138568Ssam#define IEEE80211_MSG_SCAN 0x00200000 /* scanning */ 503138568Ssam#define IEEE80211_MSG_OUTPUT 0x00100000 /* output handling */ 504138568Ssam#define IEEE80211_MSG_STATE 0x00080000 /* state machine */ 505138568Ssam#define IEEE80211_MSG_POWER 0x00040000 /* power save handling */ 506138568Ssam#define IEEE80211_MSG_DOT1X 0x00020000 /* 802.1x authenticator */ 507138568Ssam#define IEEE80211_MSG_DOT1XSM 0x00010000 /* 802.1x state machine */ 508138568Ssam#define IEEE80211_MSG_RADIUS 0x00008000 /* 802.1x radius client */ 509138568Ssam#define IEEE80211_MSG_RADDUMP 0x00004000 /* dump 802.1x radius packets */ 510138568Ssam#define IEEE80211_MSG_RADKEYS 0x00002000 /* dump 802.1x keys */ 511138568Ssam#define IEEE80211_MSG_WPA 0x00001000 /* WPA/RSN protocol */ 512138568Ssam#define IEEE80211_MSG_ACL 0x00000800 /* ACL handling */ 513138568Ssam#define IEEE80211_MSG_WME 0x00000400 /* WME protocol */ 514148288Ssam#define IEEE80211_MSG_SUPERG 0x00000200 /* Atheros SuperG protocol */ 515148288Ssam#define IEEE80211_MSG_DOTH 0x00000100 /* 802.11h support */ 516148288Ssam#define IEEE80211_MSG_INACT 0x00000080 /* inactivity handling */ 517148288Ssam#define IEEE80211_MSG_ROAM 0x00000040 /* sta-mode roaming */ 518164634Ssam#define IEEE80211_MSG_RATECTL 0x00000020 /* tx rate control */ 519170530Ssam#define IEEE80211_MSG_ACTION 0x00000010 /* action frame handling */ 520173273Ssam#define IEEE80211_MSG_WDS 0x00000008 /* WDS handling */ 521173273Ssam#define IEEE80211_MSG_IOCTL 0x00000004 /* ioctl handling */ 522138568Ssam 523138568Ssam#define IEEE80211_MSG_ANY 0xffffffff /* anything */ 524138568Ssam 525116742Ssam#ifdef IEEE80211_DEBUG 526148288Ssam#define ieee80211_msg(_ic, _m) ((_ic)->ic_debug & (_m)) 527148288Ssam#define IEEE80211_DPRINTF(_ic, _m, _fmt, ...) do { \ 528148288Ssam if (ieee80211_msg(_ic, _m)) \ 529148288Ssam ieee80211_note(_ic, _fmt, __VA_ARGS__); \ 530138568Ssam} while (0) 531148288Ssam#define IEEE80211_NOTE(_ic, _m, _ni, _fmt, ...) do { \ 532148288Ssam if (ieee80211_msg(_ic, _m)) \ 533148288Ssam ieee80211_note_mac(_ic, (_ni)->ni_macaddr, _fmt, __VA_ARGS__);\ 534148288Ssam} while (0) 535148288Ssam#define IEEE80211_NOTE_MAC(_ic, _m, _mac, _fmt, ...) do { \ 536148288Ssam if (ieee80211_msg(_ic, _m)) \ 537148288Ssam ieee80211_note_mac(_ic, _mac, _fmt, __VA_ARGS__); \ 538148288Ssam} while (0) 539148288Ssam#define IEEE80211_NOTE_FRAME(_ic, _m, _wh, _fmt, ...) do { \ 540148288Ssam if (ieee80211_msg(_ic, _m)) \ 541148288Ssam ieee80211_note_frame(_ic, _wh, _fmt, __VA_ARGS__); \ 542148288Ssam} while (0) 543148288Ssamvoid ieee80211_note(struct ieee80211com *ic, const char *fmt, ...); 544148288Ssamvoid ieee80211_note_mac(struct ieee80211com *ic, 545170530Ssam const uint8_t mac[IEEE80211_ADDR_LEN], const char *fmt, ...); 546148288Ssamvoid ieee80211_note_frame(struct ieee80211com *ic, 547148288Ssam const struct ieee80211_frame *wh, const char *fmt, ...); 548138568Ssam#define ieee80211_msg_debug(_ic) \ 549138568Ssam ((_ic)->ic_debug & IEEE80211_MSG_DEBUG) 550138568Ssam#define ieee80211_msg_dumppkts(_ic) \ 551138568Ssam ((_ic)->ic_debug & IEEE80211_MSG_DUMPPKTS) 552138568Ssam#define ieee80211_msg_input(_ic) \ 553138568Ssam ((_ic)->ic_debug & IEEE80211_MSG_INPUT) 554138568Ssam#define ieee80211_msg_radius(_ic) \ 555138568Ssam ((_ic)->ic_debug & IEEE80211_MSG_RADIUS) 556138568Ssam#define ieee80211_msg_dumpradius(_ic) \ 557138568Ssam ((_ic)->ic_debug & IEEE80211_MSG_RADDUMP) 558138568Ssam#define ieee80211_msg_dumpradkeys(_ic) \ 559138568Ssam ((_ic)->ic_debug & IEEE80211_MSG_RADKEYS) 560138568Ssam#define ieee80211_msg_scan(_ic) \ 561138568Ssam ((_ic)->ic_debug & IEEE80211_MSG_SCAN) 562148288Ssam#define ieee80211_msg_assoc(_ic) \ 563148288Ssam ((_ic)->ic_debug & IEEE80211_MSG_ASSOC) 564167441Ssam 565167441Ssam/* 566167441Ssam * Emit a debug message about discarding a frame or information 567167441Ssam * element. One format is for extracting the mac address from 568167441Ssam * the frame header; the other is for when a header is not 569167441Ssam * available or otherwise appropriate. 570167441Ssam */ 571167441Ssam#define IEEE80211_DISCARD(_ic, _m, _wh, _type, _fmt, ...) do { \ 572167441Ssam if ((_ic)->ic_debug & (_m)) \ 573167441Ssam ieee80211_discard_frame(_ic, _wh, _type, _fmt, __VA_ARGS__);\ 574167441Ssam} while (0) 575167441Ssam#define IEEE80211_DISCARD_IE(_ic, _m, _wh, _type, _fmt, ...) do { \ 576167441Ssam if ((_ic)->ic_debug & (_m)) \ 577167441Ssam ieee80211_discard_ie(_ic, _wh, _type, _fmt, __VA_ARGS__);\ 578167441Ssam} while (0) 579167441Ssam#define IEEE80211_DISCARD_MAC(_ic, _m, _mac, _type, _fmt, ...) do { \ 580167441Ssam if ((_ic)->ic_debug & (_m)) \ 581167441Ssam ieee80211_discard_mac(_ic, _mac, _type, _fmt, __VA_ARGS__);\ 582167441Ssam} while (0) 583167441Ssam 584167441Ssamvoid ieee80211_discard_frame(struct ieee80211com *, 585167441Ssam const struct ieee80211_frame *, const char *type, const char *fmt, ...); 586167441Ssamvoid ieee80211_discard_ie(struct ieee80211com *, 587167441Ssam const struct ieee80211_frame *, const char *type, const char *fmt, ...); 588167441Ssamvoid ieee80211_discard_mac(struct ieee80211com *, 589170530Ssam const uint8_t mac[IEEE80211_ADDR_LEN], const char *type, 590167441Ssam const char *fmt, ...); 591116742Ssam#else 592138568Ssam#define IEEE80211_DPRINTF(_ic, _m, _fmt, ...) 593170530Ssam#define IEEE80211_NOTE(_ic, _m, _ni, _fmt, ...) 594148288Ssam#define IEEE80211_NOTE_FRAME(_ic, _m, _wh, _fmt, ...) 595148288Ssam#define IEEE80211_NOTE_MAC(_ic, _m, _mac, _fmt, ...) 596148288Ssam#define ieee80211_msg_dumppkts(_ic) 0 597148288Ssam#define ieee80211_msg(_ic, _m) 0 598167441Ssam 599167441Ssam#define IEEE80211_DISCARD(_ic, _m, _wh, _type, _fmt, ...) 600167441Ssam#define IEEE80211_DISCARD_IE(_ic, _m, _wh, _type, _fmt, ...) 601167441Ssam#define IEEE80211_DISCARD_MAC(_ic, _m, _mac, _type, _fmt, ...) 602116742Ssam#endif 603116742Ssam 604116742Ssam#endif /* _NET80211_IEEE80211_VAR_H_ */ 605