2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * Alternatively, this software may be distributed under the terms of the
18 * GNU General Public License ("GPL") version 2 as published by the Free
19 * Software Foundation.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * $Id: _ieee80211.h 3207 2008-01-18 21:25:05Z mtaylor $
34 #ifndef _NET80211__IEEE80211_H_
35 #define _NET80211__IEEE80211_H_
37 enum ieee80211_phytype
{
38 IEEE80211_T_DS
, /* direct sequence spread spectrum */
39 IEEE80211_T_FH
, /* frequency hopping */
40 IEEE80211_T_OFDM
, /* frequency division multiplexing */
41 IEEE80211_T_TURBO
, /* high rate OFDM, aka turbo mode */
43 #define IEEE80211_T_CCK IEEE80211_T_DS /* more common nomenclature */
45 /* XXX: not really a mode; there are really multiple PHYs */
46 enum ieee80211_phymode
{
47 IEEE80211_MODE_AUTO
= 0, /* autoselect */
48 IEEE80211_MODE_11A
= 1, /* 5GHz, OFDM */
49 IEEE80211_MODE_11B
= 2, /* 2GHz, CCK */
50 IEEE80211_MODE_11G
= 3, /* 2GHz, OFDM */
51 IEEE80211_MODE_FH
= 4, /* 2GHz, GFSK */
52 IEEE80211_MODE_TURBO_A
= 5, /* 5GHz, OFDM, 2x clock dynamic turbo */
53 IEEE80211_MODE_TURBO_G
= 6, /* 2GHz, OFDM, 2x clock dynamic turbo*/
55 #define IEEE80211_MODE_MAX (IEEE80211_MODE_TURBO_G+1)
57 enum ieee80211_opmode
{
58 IEEE80211_M_STA
= 1, /* infrastructure station */
59 IEEE80211_M_IBSS
= 0, /* IBSS (adhoc) station */
60 IEEE80211_M_AHDEMO
= 3, /* Old lucent compatible adhoc demo */
61 IEEE80211_M_HOSTAP
= 6, /* Software Access Point */
62 IEEE80211_M_MONITOR
= 8, /* Monitor mode */
63 IEEE80211_M_WDS
= 2 /* WDS link */
67 * True if this mode will send beacon on a regular interval, like AP
70 #define IEEE80211_IS_MODE_BEACON(_opmode) \
71 ((_opmode == IEEE80211_M_IBSS) || \
72 (_opmode == IEEE80211_M_HOSTAP))
75 * True if this mode must behave like a DFS master, ie do Channel
76 * Check Availability and In Service Monitoring. We need to make sure
77 * that all modes cannot send data without being authorized. Such
78 * enforcement is not done in monitor mode however.
81 #define IEEE80211_IS_MODE_DFS_MASTER(_opmode) \
82 ((_opmode == IEEE80211_M_IBSS) || \
83 (_opmode == IEEE80211_M_AHDEMO) || \
84 (_opmode == IEEE80211_M_HOSTAP) || \
85 (_opmode == IEEE80211_M_WDS))
88 * 802.11g protection mode.
90 enum ieee80211_protmode
{
91 IEEE80211_PROT_NONE
= 0, /* no protection */
92 IEEE80211_PROT_CTSONLY
= 1, /* CTS to self */
93 IEEE80211_PROT_RTSCTS
= 2, /* RTS-CTS */
97 * Authentication mode.
99 enum ieee80211_authmode
{
100 IEEE80211_AUTH_NONE
= 0,
101 IEEE80211_AUTH_OPEN
= 1, /* open */
102 IEEE80211_AUTH_SHARED
= 2, /* shared-key */
103 IEEE80211_AUTH_8021X
= 3, /* 802.1x */
104 IEEE80211_AUTH_AUTO
= 4, /* auto-select/accept */
105 /* NB: these are used only for ioctls */
106 IEEE80211_AUTH_WPA
= 5, /* WPA/RSN w/ 802.1x/PSK */
110 * Roaming mode is effectively who controls the operation
111 * of the 802.11 state machine when operating as a station.
112 * State transitions are controlled either by the driver
113 * (typically when management frames are processed by the
114 * hardware/firmware), the host (auto/normal operation of
115 * the 802.11 layer), or explicitly through ioctl requests
116 * when applications like wpa_supplicant want control.
118 enum ieee80211_roamingmode
{
119 IEEE80211_ROAMING_DEVICE
= 0, /* driver/hardware control */
120 IEEE80211_ROAMING_AUTO
= 1, /* 802.11 layer control */
121 IEEE80211_ROAMING_MANUAL
= 2, /* application control */
125 * Scanning mode controls station scanning work; this is
126 * used only when roaming mode permits the host to select
127 * the bss to join/channel to use.
129 enum ieee80211_scanmode
{
130 IEEE80211_SCAN_DEVICE
= 0, /* driver/hardware control */
131 IEEE80211_SCAN_BEST
= 1, /* 802.11 layer selects best */
132 IEEE80211_SCAN_FIRST
= 2, /* take first suitable candidate */
135 enum ieee80211_scanflags
{
136 IEEE80211_NOSCAN_DEFAULT
= (1 << 0),
137 IEEE80211_NOSCAN_SET
= (1 << 1),
141 * Channels are specified by frequency and attributes.
143 struct ieee80211_channel
{
144 u_int16_t ic_freq
; /* setting in MHz */
145 u_int16_t ic_flags
; /* see below */
146 u_int8_t ic_ieee
; /* IEEE channel number */
147 int8_t ic_maxregpower
; /* maximum regulatory tx power in dBm */
148 int8_t ic_maxpower
; /* maximum tx power in dBm */
149 int8_t ic_minpower
; /* minimum tx power in dBm */
150 u_int8_t ic_scanflags
;
151 u_int8_t ic_idletime
; /* phy idle time in % */
154 #define IEEE80211_CHAN_MAX 255
155 #define IEEE80211_CHAN_BYTES 32 /* howmany(IEEE80211_CHAN_MAX, NBBY) */
156 #define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */
157 #define IEEE80211_CHAN_ANYC ((struct ieee80211_channel *) IEEE80211_CHAN_ANY)
159 #define IEEE80211_RADAR_CHANCHANGE_TBTT_COUNT 0
160 #define IEEE80211_DEFAULT_CHANCHANGE_TBTT_COUNT 3
162 #define IEEE80211_RADAR_TEST_MUTE_CHAN 36 /* Move to channel 36 for mute test */
164 /* bits 0-3 are for private use by drivers */
165 /* channel attributes */
166 #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
167 #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
168 #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
169 #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
170 #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
171 #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
172 #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
173 #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
174 #define IEEE80211_CHAN_RADAR 0x1000 /* Radar found on channel */
175 #define IEEE80211_CHAN_STURBO 0x2000 /* 11a static turbo channel only */
176 #define IEEE80211_CHAN_HALF 0x4000 /* Half rate channel */
177 #define IEEE80211_CHAN_QUARTER 0x8000 /* Quarter rate channel */
180 * Useful combinations of channel characteristics.
182 #define IEEE80211_CHAN_FHSS \
183 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
184 #define IEEE80211_CHAN_A \
185 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
186 #define IEEE80211_CHAN_B \
187 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
188 #define IEEE80211_CHAN_PUREG \
189 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
190 #define IEEE80211_CHAN_G \
191 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
192 #define IEEE80211_CHAN_108A \
193 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
194 #define IEEE80211_CHAN_108G \
195 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
196 #define IEEE80211_CHAN_ST \
197 (IEEE80211_CHAN_108A | IEEE80211_CHAN_STURBO)
199 #define IEEE80211_CHAN_ALL \
200 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \
201 IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN)
202 #define IEEE80211_CHAN_ALLTURBO \
203 (IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)
205 #define IEEE80211_IS_CHAN_FHSS(_c) \
206 (((_c)->ic_flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
207 #define IEEE80211_IS_CHAN_A(_c) \
208 (((_c)->ic_flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
209 #define IEEE80211_IS_CHAN_B(_c) \
210 (((_c)->ic_flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
211 #define IEEE80211_IS_CHAN_PUREG(_c) \
212 (((_c)->ic_flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
213 #define IEEE80211_IS_CHAN_G(_c) \
214 (((_c)->ic_flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
215 #define IEEE80211_IS_CHAN_ANYG(_c) \
216 (IEEE80211_IS_CHAN_PUREG(_c) || IEEE80211_IS_CHAN_G(_c))
217 #define IEEE80211_IS_CHAN_ST(_c) \
218 (((_c)->ic_flags & IEEE80211_CHAN_ST) == IEEE80211_CHAN_ST)
219 #define IEEE80211_IS_CHAN_108A(_c) \
220 (((_c)->ic_flags & IEEE80211_CHAN_108A) == IEEE80211_CHAN_108A)
221 #define IEEE80211_IS_CHAN_108G(_c) \
222 (((_c)->ic_flags & IEEE80211_CHAN_108G) == IEEE80211_CHAN_108G)
224 #define IEEE80211_IS_CHAN_2GHZ(_c) \
225 (((_c)->ic_flags & IEEE80211_CHAN_2GHZ) != 0)
226 #define IEEE80211_IS_CHAN_5GHZ(_c) \
227 (((_c)->ic_flags & IEEE80211_CHAN_5GHZ) != 0)
228 #define IEEE80211_IS_CHAN_OFDM(_c) \
229 (((_c)->ic_flags & IEEE80211_CHAN_OFDM) != 0)
230 #define IEEE80211_IS_CHAN_CCK(_c) \
231 (((_c)->ic_flags & IEEE80211_CHAN_CCK) != 0)
232 #define IEEE80211_IS_CHAN_GFSK(_c) \
233 (((_c)->ic_flags & IEEE80211_CHAN_GFSK) != 0)
234 #define IEEE80211_IS_CHAN_TURBO(_c) \
235 (((_c)->ic_flags & IEEE80211_CHAN_TURBO) != 0)
236 #define IEEE80211_IS_CHAN_STURBO(_c) \
237 (((_c)->ic_flags & IEEE80211_CHAN_STURBO) != 0)
238 #define IEEE80211_IS_CHAN_DTURBO(_c) \
240 (IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)) == IEEE80211_CHAN_TURBO)
241 #define IEEE80211_IS_CHAN_HALF(_c) \
242 (((_c)->ic_flags & IEEE80211_CHAN_HALF) != 0)
243 #define IEEE80211_IS_CHAN_QUARTER(_c) \
244 (((_c)->ic_flags & IEEE80211_CHAN_QUARTER) != 0)
246 #define IEEE80211_IS_CHAN_RADAR(_c) \
247 (((_c)->ic_flags & IEEE80211_CHAN_RADAR) != 0)
248 #define IEEE80211_IS_CHAN_PASSIVE(_c) \
249 (((_c)->ic_flags & IEEE80211_CHAN_PASSIVE) != 0)
250 #define IEEE80211_ARE_CHANS_SAME_MODE(_a, _b) \
251 (((_a)->ic_flags & IEEE80211_CHAN_ALLTURBO) == ((_b)->ic_flags & IEEE80211_CHAN_ALLTURBO))
253 /* ni_chan encoding for FH phy */
254 #define IEEE80211_FH_CHANMOD 80
255 #define IEEE80211_FH_CHAN(set,pat) (((set) - 1) * IEEE80211_FH_CHANMOD + (pat))
256 #define IEEE80211_FH_CHANSET(chan) ((chan) / IEEE80211_FH_CHANMOD + 1)
257 #define IEEE80211_FH_CHANPAT(chan) ((chan) % IEEE80211_FH_CHANMOD)
260 * Spectrum Management (IEEE 802.11h-2003)
263 /* algorithm for (re)association based on supported channels
264 * (the one mentioned in 11.6.1 as out of scope of .11h) */
265 enum ieee80211_sc_algorithm
{
268 * Do not disallow anyone from associating. When needed, channel will
269 * be switched to the most suitable channel, no matter client stations
275 * Do not disallow anyone from associating. When needed, channel will
276 * be switched to a suitable channel, which will be chosen taking
277 * ni->ni_suppchans and ic->ic_sc_sldg under consideration.
282 * Allow to associate if there are at least ic->ic_mincom channels
283 * common to the associating station and all of the already associated
284 * stations. If the number of new common channels is less than
285 * required, consider disassociating some other STAs. Such a
286 * disassociation will be performed if (and only if) the association we
287 * are currently considering would be then possible and the count of
288 * the resultant set of common channels (ic_chan_nodes[i] ==
289 * ic_cn_total) would increase by some amount. Whether the number of
290 * the new channels that could be gained is enough to sacrifice a
291 * number of STAs is determined by the ic->ic_slcg parameter.
296 * Basically the same behavior as IEEE80211_SC_TIGHT, except that if a
297 * station does not specify Supported Channels, then it is denied to
305 #define IEEE80211_RATE_SIZE 8 /* 802.11 standard */
306 #define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */
307 #define IEEE80211_SANITISE_RATESIZE(_rsz) \
308 ((_rsz > IEEE80211_RATE_MAXSIZE) ? IEEE80211_RATE_MAXSIZE : _rsz)
310 struct ieee80211_rateset
{
312 u_int8_t rs_rates
[IEEE80211_RATE_MAXSIZE
];
315 struct ieee80211_roam
{
316 int8_t rssi11a
; /* rssi thresh for 11a bss */
317 int8_t rssi11b
; /* for 11g sta in 11b bss */
318 int8_t rssi11bOnly
; /* for 11b sta */
320 u_int8_t rate11a
; /* rate thresh for 11a bss */
321 u_int8_t rate11b
; /* for 11g sta in 11b bss */
322 u_int8_t rate11bOnly
; /* for 11b sta */
325 #endif /* _NET80211__IEEE80211_H_ */