ieee80211_var.h revision 116742
1116742Ssam/*- 2116742Ssam * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting 3116742Ssam * All rights reserved. 4116742Ssam * 5116742Ssam * Redistribution and use in source and binary forms, with or without 6116742Ssam * modification, are permitted provided that the following conditions 7116742Ssam * are met: 8116742Ssam * 1. Redistributions of source code must retain the above copyright 9116742Ssam * notice, this list of conditions and the following disclaimer. 10116742Ssam * 2. Redistributions in binary form must reproduce the above copyright 11116742Ssam * notice, this list of conditions and the following disclaimer in the 12116742Ssam * documentation and/or other materials provided with the distribution. 13116742Ssam * 14116742Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15116742Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16116742Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17116742Ssam * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18116742Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19116742Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20116742Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21116742Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22116742Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23116742Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24116742Ssam * SUCH DAMAGE. 25116742Ssam * 26116742Ssam * $FreeBSD: head/sys/net80211/ieee80211_var.h 116742 2003-06-23 16:55:01Z sam $ 27116742Ssam */ 28116742Ssam#ifndef _NET80211_IEEE80211_VAR_H_ 29116742Ssam#define _NET80211_IEEE80211_VAR_H_ 30116742Ssam 31116742Ssam/* 32116742Ssam * Definitions for IEEE 802.11 drivers. 33116742Ssam */ 34116742Ssam 35116742Ssam#include <net80211/ieee80211.h> 36116742Ssam#include <net80211/ieee80211_crypto.h> 37116742Ssam#include <net80211/ieee80211_node.h> 38116742Ssam#include <net80211/ieee80211_proto.h> 39116742Ssam 40116742Ssam#define IEEE80211_CHAN_MAX 255 41116742Ssam#define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */ 42116742Ssam#define IEEE80211_CHAN_ANYC \ 43116742Ssam ((struct ieee80211_channel *) IEEE80211_CHAN_ANY) 44116742Ssam 45116742Ssamenum ieee80211_phytype { 46116742Ssam IEEE80211_T_DS, /* direct sequence spread spectrum */ 47116742Ssam IEEE80211_T_FH, /* frequency hopping */ 48116742Ssam IEEE80211_T_OFDM, /* frequency division multiplexing */ 49116742Ssam IEEE80211_T_TURBO, /* high rate OFDM, aka turbo mode */ 50116742Ssam}; 51116742Ssam#define IEEE80211_T_CCK IEEE80211_T_DS /* more common nomenclature */ 52116742Ssam 53116742Ssam/* XXX not really a mode; there are really multiple PHY's */ 54116742Ssamenum ieee80211_phymode { 55116742Ssam IEEE80211_MODE_AUTO = 0, /* autoselect */ 56116742Ssam IEEE80211_MODE_11A = 1, /* 5GHz, OFDM */ 57116742Ssam IEEE80211_MODE_11B = 2, /* 2GHz, CCK */ 58116742Ssam IEEE80211_MODE_11G = 3, /* 2GHz, OFDM */ 59116742Ssam IEEE80211_MODE_TURBO = 4, /* 5GHz, OFDM, 2x clock */ 60116742Ssam}; 61116742Ssam#define IEEE80211_MODE_MAX (IEEE80211_MODE_TURBO+1) 62116742Ssam 63116742Ssamenum ieee80211_opmode { 64116742Ssam IEEE80211_M_STA = 1, /* infrastructure station */ 65116742Ssam IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */ 66116742Ssam IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */ 67116742Ssam IEEE80211_M_HOSTAP = 6 /* Software Access Point */ 68116742Ssam}; 69116742Ssam 70116742Ssam/* 71116742Ssam * Channels are specified by frequency and attributes. 72116742Ssam */ 73116742Ssamstruct ieee80211_channel { 74116742Ssam u_int16_t ic_freq; /* setting in Mhz */ 75116742Ssam u_int16_t ic_flags; /* see below */ 76116742Ssam}; 77116742Ssam 78116742Ssam/* bits 0-3 are for private use by drivers */ 79116742Ssam/* channel attributes */ 80116742Ssam#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ 81116742Ssam#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ 82116742Ssam#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ 83116742Ssam#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ 84116742Ssam#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ 85116742Ssam#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ 86116742Ssam#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ 87116742Ssam 88116742Ssam/* 89116742Ssam * Useful combinations of channel characteristics. 90116742Ssam */ 91116742Ssam#define IEEE80211_CHAN_A \ 92116742Ssam (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM) 93116742Ssam#define IEEE80211_CHAN_B \ 94116742Ssam (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK) 95116742Ssam#define IEEE80211_CHAN_PUREG \ 96116742Ssam (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM) 97116742Ssam#define IEEE80211_CHAN_G \ 98116742Ssam (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN) 99116742Ssam#define IEEE80211_CHAN_T \ 100116742Ssam (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO) 101116742Ssam 102116742Ssam#define IEEE80211_IS_CHAN_A(_c) \ 103116742Ssam (((_c)->ic_flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A) 104116742Ssam#define IEEE80211_IS_CHAN_B(_c) \ 105116742Ssam (((_c)->ic_flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B) 106116742Ssam#define IEEE80211_IS_CHAN_PUREG(_c) \ 107116742Ssam (((_c)->ic_flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG) 108116742Ssam#define IEEE80211_IS_CHAN_G(_c) \ 109116742Ssam (((_c)->ic_flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G) 110116742Ssam#define IEEE80211_IS_CHAN_T(_c) \ 111116742Ssam (((_c)->ic_flags & IEEE80211_CHAN_T) == IEEE80211_CHAN_T) 112116742Ssam 113116742Ssam#define IEEE80211_IS_CHAN_2GHZ(_c) \ 114116742Ssam (((_c)->ic_flags & IEEE80211_CHAN_2GHZ) != 0) 115116742Ssam#define IEEE80211_IS_CHAN_5GHZ(_c) \ 116116742Ssam (((_c)->ic_flags & IEEE80211_CHAN_5GHZ) != 0) 117116742Ssam#define IEEE80211_IS_CHAN_OFDM(_c) \ 118116742Ssam (((_c)->ic_flags & IEEE80211_CHAN_OFDM) != 0) 119116742Ssam#define IEEE80211_IS_CHAN_CCK(_c) \ 120116742Ssam (((_c)->ic_flags & IEEE80211_CHAN_CCK) != 0) 121116742Ssam 122116742Ssam/* ni_chan encoding for FH phy */ 123116742Ssam#define IEEE80211_FH_CHANMOD 80 124116742Ssam#define IEEE80211_FH_CHAN(set,pat) (((set)-1)*IEEE80211_FH_CHANMOD+(pat)) 125116742Ssam#define IEEE80211_FH_CHANSET(chan) ((chan)/IEEE80211_FH_CHANMOD+1) 126116742Ssam#define IEEE80211_FH_CHANPAT(chan) ((chan)%IEEE80211_FH_CHANMOD) 127116742Ssam 128116742Ssamstruct ieee80211com { 129116742Ssam struct arpcom ic_ac; 130116742Ssam void (*ic_recv_mgmt)(struct ieee80211com *, 131116742Ssam struct mbuf *, int, int, u_int32_t, u_int); 132116742Ssam int (*ic_send_mgmt)(struct ieee80211com *, 133116742Ssam struct ieee80211_node *, int, int); 134116742Ssam int (*ic_newstate)(void *, enum ieee80211_state); 135116742Ssam void (*ic_newassoc)(struct ieee80211com *, 136116742Ssam struct ieee80211_node *, int); 137116742Ssam u_int8_t ic_myaddr[IEEE80211_ADDR_LEN]; 138116742Ssam struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX]; 139116742Ssam struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX+1]; 140116742Ssam u_char ic_chan_avail[roundup(IEEE80211_CHAN_MAX,NBBY)]; 141116742Ssam u_char ic_chan_active[roundup(IEEE80211_CHAN_MAX, NBBY)]; 142116742Ssam u_char ic_chan_scan[roundup(IEEE80211_CHAN_MAX,NBBY)]; 143116742Ssam struct ifqueue ic_mgtq; 144116742Ssam u_int32_t ic_flags; /* state flags */ 145116742Ssam u_int32_t ic_caps; /* capabilities */ 146116742Ssam u_int16_t ic_modecaps; /* set of mode capabilities */ 147116742Ssam u_int16_t ic_curmode; /* current mode */ 148116742Ssam enum ieee80211_phytype ic_phytype; /* XXX wrong for multi-mode */ 149116742Ssam enum ieee80211_opmode ic_opmode; /* operation mode */ 150116742Ssam enum ieee80211_state ic_state; /* 802.11 state */ 151116742Ssam struct ifmedia ic_media; /* interface media config */ 152116742Ssam struct bpf_if *ic_rawbpf; /* packet filter structure */ 153116742Ssam struct ieee80211_node *ic_bss; /* information for this node */ 154116742Ssam struct ieee80211_channel *ic_ibss_chan; 155116742Ssam int ic_fixed_rate; /* index to ic_sup_rates[] */ 156116742Ssam u_int16_t ic_rtsthreshold; 157116742Ssam u_int16_t ic_fragthreshold; 158116742Ssam struct mtx ic_nodelock; /* on node table */ 159116742Ssam struct ieee80211_node *(*ic_node_alloc)(struct ieee80211com *); 160116742Ssam void (*ic_node_free)(struct ieee80211com *, 161116742Ssam struct ieee80211_node *); 162116742Ssam void (*ic_node_copy)(struct ieee80211com *, 163116742Ssam struct ieee80211_node *, 164116742Ssam const struct ieee80211_node *); 165116742Ssam TAILQ_HEAD(, ieee80211_node) ic_node; /* information of all nodes */ 166116742Ssam LIST_HEAD(, ieee80211_node) ic_hash[IEEE80211_NODE_HASHSIZE]; 167116742Ssam u_int16_t ic_lintval; /* listen interval */ 168116742Ssam u_int16_t ic_holdover; /* PM hold over duration */ 169116742Ssam u_int16_t ic_txmin; /* min tx retry count */ 170116742Ssam u_int16_t ic_txmax; /* max tx retry count */ 171116742Ssam u_int16_t ic_txlifetime; /* tx lifetime */ 172116742Ssam u_int16_t ic_txpower; /* tx power setting (dbM) */ 173116742Ssam u_int16_t ic_bmisstimeout;/* beacon miss threshold (ms) */ 174116742Ssam int ic_mgt_timer; /* mgmt timeout */ 175116742Ssam int ic_inact_timer; /* inactivity timer wait */ 176116742Ssam int ic_des_esslen; 177116742Ssam u_int8_t ic_des_essid[IEEE80211_NWID_LEN]; 178116742Ssam struct ieee80211_channel *ic_des_chan; /* desired channel */ 179116742Ssam u_int8_t ic_des_bssid[IEEE80211_ADDR_LEN]; 180116742Ssam struct ieee80211_wepkey ic_nw_keys[IEEE80211_WEP_NKID]; 181116742Ssam int ic_wep_txkey; /* default tx key index */ 182116742Ssam void *ic_wep_ctx; /* wep crypt context */ 183116742Ssam u_int32_t ic_iv; /* initial vector for wep */ 184116742Ssam}; 185116742Ssam#define ic_if ic_ac.ac_if 186116742Ssam#define ic_softc ic_if.if_softc 187116742Ssam 188116742Ssam#define IEEE80211_ADDR_EQ(a1,a2) (memcmp(a1,a2,IEEE80211_ADDR_LEN) == 0) 189116742Ssam#define IEEE80211_ADDR_COPY(dst,src) memcpy(dst,src,IEEE80211_ADDR_LEN) 190116742Ssam 191116742Ssam/* ic_flags */ 192116742Ssam#define IEEE80211_F_ASCAN 0x00000001 /* STATUS: active scan */ 193116742Ssam#define IEEE80211_F_SIBSS 0x00000002 /* STATUS: start IBSS */ 194116742Ssam#define IEEE80211_F_WEPON 0x00000100 /* CONF: WEP enabled */ 195116742Ssam#define IEEE80211_F_IBSSON 0x00000200 /* CONF: IBSS creation enable */ 196116742Ssam#define IEEE80211_F_PMGTON 0x00000400 /* CONF: Power mgmt enable */ 197116742Ssam#define IEEE80211_F_DESBSSID 0x00000800 /* CONF: des_bssid is set */ 198116742Ssam#define IEEE80211_F_SCANAP 0x00001000 /* CONF: Scanning AP */ 199116742Ssam#define IEEE80211_F_ROAMING 0x00002000 /* CONF: roaming enabled */ 200116742Ssam#define IEEE80211_F_SWRETRY 0x00004000 /* CONF: sw tx retry enabled */ 201116742Ssam#define IEEE80211_F_TXPMGT 0x00018000 /* STATUS: tx power */ 202116742Ssam#define IEEE80211_F_TXPOW_OFF 0x00000000 /* TX Power: radio disabled */ 203116742Ssam#define IEEE80211_F_TXPOW_FIXED 0x00008000 /* TX Power: fixed rate */ 204116742Ssam#define IEEE80211_F_TXPOW_AUTO 0x00010000 /* TX Power: undefined */ 205116742Ssam#define IEEE80211_F_SHSLOT 0x00020000 /* CONF: short slot time */ 206116742Ssam#define IEEE80211_F_SHPREAMBLE 0x00040000 /* CONF: short preamble */ 207116742Ssam 208116742Ssam/* ic_capabilities */ 209116742Ssam#define IEEE80211_C_WEP 0x00000001 /* CAPABILITY: WEP available */ 210116742Ssam#define IEEE80211_C_IBSS 0x00000002 /* CAPABILITY: IBSS available */ 211116742Ssam#define IEEE80211_C_PMGT 0x00000004 /* CAPABILITY: Power mgmt */ 212116742Ssam#define IEEE80211_C_HOSTAP 0x00000008 /* CAPABILITY: HOSTAP avail */ 213116742Ssam#define IEEE80211_C_AHDEMO 0x00000010 /* CAPABILITY: Old Adhoc Demo */ 214116742Ssam#define IEEE80211_C_SWRETRY 0x00000020 /* CAPABILITY: sw tx retry */ 215116742Ssam#define IEEE80211_C_TXPMGT 0x00000040 /* CAPABILITY: tx power mgmt */ 216116742Ssam#define IEEE80211_C_SHSLOT 0x00000080 /* CAPABILITY: short slottime */ 217116742Ssam#define IEEE80211_C_SHPREAMBLE 0x00000100 /* CAPABILITY: short preamble */ 218116742Ssam 219116742Ssam/* flags for ieee80211_fix_rate() */ 220116742Ssam#define IEEE80211_F_DOSORT 0x00000001 /* sort rate list */ 221116742Ssam#define IEEE80211_F_DOFRATE 0x00000002 /* use fixed rate */ 222116742Ssam#define IEEE80211_F_DONEGO 0x00000004 /* calc negotiated rate */ 223116742Ssam#define IEEE80211_F_DODEL 0x00000008 /* delete ignore rate */ 224116742Ssam 225116742Ssamvoid ieee80211_ifattach(struct ifnet *); 226116742Ssamvoid ieee80211_ifdetach(struct ifnet *); 227116742Ssamvoid ieee80211_media_init(struct ifnet *, ifm_change_cb_t, ifm_stat_cb_t); 228116742Ssamint ieee80211_media_change(struct ifnet *); 229116742Ssamvoid ieee80211_media_status(struct ifnet *, struct ifmediareq *); 230116742Ssamint ieee80211_ioctl(struct ifnet *, u_long, caddr_t); 231116742Ssamint ieee80211_cfgget(struct ifnet *, u_long, caddr_t); 232116742Ssamint ieee80211_cfgset(struct ifnet *, u_long, caddr_t); 233116742Ssamvoid ieee80211_watchdog(struct ifnet *); 234116742Ssamint ieee80211_fix_rate(struct ieee80211com *, struct ieee80211_node *, int); 235116742Ssamint ieee80211_rate2media(struct ieee80211com *, int, 236116742Ssam enum ieee80211_phymode); 237116742Ssamint ieee80211_media2rate(int); 238116742Ssamu_int ieee80211_mhz2ieee(u_int, u_int); 239116742Ssamu_int ieee80211_chan2ieee(struct ieee80211com *, struct ieee80211_channel *); 240116742Ssamu_int ieee80211_ieee2mhz(u_int, u_int); 241116742Ssamint ieee80211_setmode(struct ieee80211com *, enum ieee80211_phymode); 242116742Ssamenum ieee80211_phymode ieee80211_chan2mode(struct ieee80211com *, 243116742Ssam struct ieee80211_channel *); 244116742Ssam 245116742Ssam#define IEEE80211_DEBUG 246116742Ssam#ifdef IEEE80211_DEBUG 247116742Ssamextern int ieee80211_debug; 248116742Ssam#define IEEE80211_DPRINTF(X) if (ieee80211_debug) printf X 249116742Ssam#define IEEE80211_DPRINTF2(X) if (ieee80211_debug>1) printf X 250116742Ssam#else 251116742Ssam#define IEEE80211_DPRINTF(X) 252116742Ssam#define IEEE80211_DPRINTF2(X) 253116742Ssam#endif 254116742Ssam 255116742Ssam#endif /* _NET80211_IEEE80211_VAR_H_ */ 256