]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/net80211/_ieee80211.h
This commit was generated by cvs2svn to compensate for changes in r171322,
[FreeBSD/FreeBSD.git] / sys / net80211 / _ieee80211.h
1 /*-
2  * Copyright (c) 2001 Atsushi Onoe
3  * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 #ifndef _NET80211__IEEE80211_H_
29 #define _NET80211__IEEE80211_H_
30
31 enum ieee80211_phytype {
32         IEEE80211_T_DS,                 /* direct sequence spread spectrum */
33         IEEE80211_T_FH,                 /* frequency hopping */
34         IEEE80211_T_OFDM,               /* frequency division multiplexing */
35         IEEE80211_T_TURBO,              /* high rate OFDM, aka turbo mode */
36         IEEE80211_T_HT,                 /* high throughput, full GI */
37 };
38 #define IEEE80211_T_CCK IEEE80211_T_DS  /* more common nomenclature */
39
40 /* XXX not really a mode; there are really multiple PHY's */
41 enum ieee80211_phymode {
42         IEEE80211_MODE_AUTO     = 0,    /* autoselect */
43         IEEE80211_MODE_11A      = 1,    /* 5GHz, OFDM */
44         IEEE80211_MODE_11B      = 2,    /* 2GHz, CCK */
45         IEEE80211_MODE_11G      = 3,    /* 2GHz, OFDM */
46         IEEE80211_MODE_FH       = 4,    /* 2GHz, GFSK */
47         IEEE80211_MODE_TURBO_A  = 5,    /* 5GHz, OFDM, 2x clock */
48         IEEE80211_MODE_TURBO_G  = 6,    /* 2GHz, OFDM, 2x clock */
49         IEEE80211_MODE_STURBO_A = 7,    /* 5GHz, OFDM, 2x clock, static */
50         IEEE80211_MODE_11NA     = 8,    /* 5GHz, w/ HT */
51         IEEE80211_MODE_11NG     = 9,    /* 2GHz, w/ HT */
52 };
53 #define IEEE80211_MODE_MAX      (IEEE80211_MODE_11NG+1)
54
55 enum ieee80211_opmode {
56         IEEE80211_M_STA         = 1,    /* infrastructure station */
57         IEEE80211_M_IBSS        = 0,    /* IBSS (adhoc) station */
58         IEEE80211_M_AHDEMO      = 3,    /* Old lucent compatible adhoc demo */
59         IEEE80211_M_HOSTAP      = 6,    /* Software Access Point */
60         IEEE80211_M_MONITOR     = 8,    /* Monitor mode */
61         IEEE80211_M_WDS         = 2     /* WDS link */
62 };
63 #define IEEE80211_OPMODE_MAX    (IEEE80211_M_MONITOR+1)
64
65 /*
66  * 802.11g/802.11n protection mode.
67  */
68 enum ieee80211_protmode {
69         IEEE80211_PROT_NONE     = 0,    /* no protection */
70         IEEE80211_PROT_CTSONLY  = 1,    /* CTS to self */
71         IEEE80211_PROT_RTSCTS   = 2,    /* RTS-CTS */
72 };
73
74 /*
75  * Authentication mode.
76  */
77 enum ieee80211_authmode {
78         IEEE80211_AUTH_NONE     = 0,
79         IEEE80211_AUTH_OPEN     = 1,            /* open */
80         IEEE80211_AUTH_SHARED   = 2,            /* shared-key */
81         IEEE80211_AUTH_8021X    = 3,            /* 802.1x */
82         IEEE80211_AUTH_AUTO     = 4,            /* auto-select/accept */
83         /* NB: these are used only for ioctls */
84         IEEE80211_AUTH_WPA      = 5,            /* WPA/RSN w/ 802.1x/PSK */
85 };
86
87 /*
88  * Roaming mode is effectively who controls the operation
89  * of the 802.11 state machine when operating as a station.
90  * State transitions are controlled either by the driver
91  * (typically when management frames are processed by the
92  * hardware/firmware), the host (auto/normal operation of
93  * the 802.11 layer), or explicitly through ioctl requests
94  * when applications like wpa_supplicant want control.
95  */
96 enum ieee80211_roamingmode {
97         IEEE80211_ROAMING_DEVICE= 0,    /* driver/hardware control */
98         IEEE80211_ROAMING_AUTO  = 1,    /* 802.11 layer control */
99         IEEE80211_ROAMING_MANUAL= 2,    /* application control */
100 };
101
102 /*
103  * Channels are specified by frequency and attributes.
104  */
105 struct ieee80211_channel {
106         uint32_t        ic_flags;       /* see below */
107         uint16_t        ic_freq;        /* setting in Mhz */
108         uint8_t         ic_ieee;        /* IEEE channel number */
109         int8_t          ic_maxregpower; /* maximum regulatory tx power in dBm */
110         int8_t          ic_maxpower;    /* maximum tx power in .5 dBm */
111         int8_t          ic_minpower;    /* minimum tx power in .5 dBm */
112         /* NB: hole, to be used for dfs */
113 };
114
115 #define IEEE80211_CHAN_MAX      255
116 #define IEEE80211_CHAN_BYTES    32      /* howmany(IEEE80211_CHAN_MAX, NBBY) */
117 #define IEEE80211_CHAN_ANY      0xffff  /* token for ``any channel'' */
118 #define IEEE80211_CHAN_ANYC \
119         ((struct ieee80211_channel *) IEEE80211_CHAN_ANY)
120
121 /* bits 0-3 are for private use by drivers */
122 /* channel attributes */
123 #define IEEE80211_CHAN_TURBO    0x00010 /* Turbo channel */
124 #define IEEE80211_CHAN_CCK      0x00020 /* CCK channel */
125 #define IEEE80211_CHAN_OFDM     0x00040 /* OFDM channel */
126 #define IEEE80211_CHAN_2GHZ     0x00080 /* 2 GHz spectrum channel. */
127 #define IEEE80211_CHAN_5GHZ     0x00100 /* 5 GHz spectrum channel */
128 #define IEEE80211_CHAN_PASSIVE  0x00200 /* Only passive scan allowed */
129 #define IEEE80211_CHAN_DYN      0x00400 /* Dynamic CCK-OFDM channel */
130 #define IEEE80211_CHAN_GFSK     0x00800 /* GFSK channel (FHSS PHY) */
131 #define IEEE80211_CHAN_GSM      0x01000 /* 900 MHz spectrum channel */
132 #define IEEE80211_CHAN_STURBO   0x02000 /* 11a static turbo channel only */
133 #define IEEE80211_CHAN_HALF     0x04000 /* Half rate channel */
134 #define IEEE80211_CHAN_QUARTER  0x08000 /* Quarter rate channel */
135 #define IEEE80211_CHAN_HT20     0x10000 /* HT 20 channel */
136 #define IEEE80211_CHAN_HT40U    0x20000 /* HT 40 channel w/ ext above */
137 #define IEEE80211_CHAN_HT40D    0x40000 /* HT 40 channel w/ ext below */
138
139 #define IEEE80211_CHAN_HT40     (IEEE80211_CHAN_HT40U | IEEE80211_CHAN_HT40D)
140 #define IEEE80211_CHAN_HT       (IEEE80211_CHAN_HT20 | IEEE80211_CHAN_HT40)
141
142 /*
143  * Useful combinations of channel characteristics.
144  */
145 #define IEEE80211_CHAN_FHSS \
146         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
147 #define IEEE80211_CHAN_A \
148         (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
149 #define IEEE80211_CHAN_B \
150         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
151 #define IEEE80211_CHAN_PUREG \
152         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
153 #define IEEE80211_CHAN_G \
154         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
155 #define IEEE80211_CHAN_108A \
156         (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
157 #define IEEE80211_CHAN_108G \
158         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
159 #define IEEE80211_CHAN_ST \
160         (IEEE80211_CHAN_108A | IEEE80211_CHAN_STURBO)
161
162 #define IEEE80211_CHAN_ALL \
163         (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \
164          IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN | \
165          IEEE80211_CHAN_HT)
166 #define IEEE80211_CHAN_ALLTURBO \
167         (IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)
168
169 #define IEEE80211_IS_CHAN_FHSS(_c) \
170         (((_c)->ic_flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
171 #define IEEE80211_IS_CHAN_A(_c) \
172         (((_c)->ic_flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
173 #define IEEE80211_IS_CHAN_B(_c) \
174         (((_c)->ic_flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
175 #define IEEE80211_IS_CHAN_PUREG(_c) \
176         (((_c)->ic_flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
177 #define IEEE80211_IS_CHAN_G(_c) \
178         (((_c)->ic_flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
179 #define IEEE80211_IS_CHAN_ANYG(_c) \
180         (IEEE80211_IS_CHAN_PUREG(_c) || IEEE80211_IS_CHAN_G(_c))
181 #define IEEE80211_IS_CHAN_ST(_c) \
182         (((_c)->ic_flags & IEEE80211_CHAN_ST) == IEEE80211_CHAN_ST)
183 #define IEEE80211_IS_CHAN_108A(_c) \
184         (((_c)->ic_flags & IEEE80211_CHAN_108A) == IEEE80211_CHAN_108A)
185 #define IEEE80211_IS_CHAN_108G(_c) \
186         (((_c)->ic_flags & IEEE80211_CHAN_108G) == IEEE80211_CHAN_108G)
187
188 #define IEEE80211_IS_CHAN_2GHZ(_c) \
189         (((_c)->ic_flags & IEEE80211_CHAN_2GHZ) != 0)
190 #define IEEE80211_IS_CHAN_5GHZ(_c) \
191         (((_c)->ic_flags & IEEE80211_CHAN_5GHZ) != 0)
192 #define IEEE80211_IS_CHAN_PASSIVE(_c) \
193         (((_c)->ic_flags & IEEE80211_CHAN_PASSIVE) != 0)
194 #define IEEE80211_IS_CHAN_OFDM(_c) \
195         (((_c)->ic_flags & IEEE80211_CHAN_OFDM) != 0)
196 #define IEEE80211_IS_CHAN_CCK(_c) \
197         (((_c)->ic_flags & IEEE80211_CHAN_CCK) != 0)
198 #define IEEE80211_IS_CHAN_GFSK(_c) \
199         (((_c)->ic_flags & IEEE80211_CHAN_GFSK) != 0)
200 #define IEEE80211_IS_CHAN_TURBO(_c) \
201         (((_c)->ic_flags & IEEE80211_CHAN_TURBO) != 0)
202 #define IEEE80211_IS_CHAN_STURBO(_c) \
203         (((_c)->ic_flags & IEEE80211_CHAN_STURBO) != 0)
204 #define IEEE80211_IS_CHAN_DTURBO(_c) \
205         (((_c)->ic_flags & \
206         (IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)) == IEEE80211_CHAN_TURBO)
207 #define IEEE80211_IS_CHAN_HALF(_c) \
208         (((_c)->ic_flags & IEEE80211_CHAN_HALF) != 0)
209 #define IEEE80211_IS_CHAN_QUARTER(_c) \
210         (((_c)->ic_flags & IEEE80211_CHAN_QUARTER) != 0)
211 #define IEEE80211_IS_CHAN_FULL(_c) \
212         (((_c)->ic_flags & (IEEE80211_CHAN_QUARTER | IEEE80211_CHAN_HALF)) == 0)
213 #define IEEE80211_IS_CHAN_GSM(_c) \
214         (((_c)->ic_flags & IEEE80211_CHAN_GSM) != 0)
215 #define IEEE80211_IS_CHAN_HT(_c) \
216         (((_c)->ic_flags & IEEE80211_CHAN_HT) != 0)
217 #define IEEE80211_IS_CHAN_HT20(_c) \
218         (((_c)->ic_flags & IEEE80211_CHAN_HT20) != 0)
219 #define IEEE80211_IS_CHAN_HT40(_c) \
220         (((_c)->ic_flags & IEEE80211_CHAN_HT40) != 0)
221 #define IEEE80211_IS_CHAN_HT40U(_c) \
222         (((_c)->ic_flags & IEEE80211_CHAN_HT40U) != 0)
223 #define IEEE80211_IS_CHAN_HT40D(_c) \
224         (((_c)->ic_flags & IEEE80211_CHAN_HT40D) != 0)
225 #define IEEE80211_IS_CHAN_HTA(_c) \
226         (IEEE80211_IS_CHAN_5GHZ(_c) && \
227          ((_c)->ic_flags & IEEE80211_CHAN_HT) != 0)
228 #define IEEE80211_IS_CHAN_HTG(_c) \
229         (IEEE80211_IS_CHAN_2GHZ(_c) && \
230          ((_c)->ic_flags & IEEE80211_CHAN_HT) != 0)
231
232 #define IEEE80211_CHAN2IEEE(_c)         (_c)->ic_ieee
233
234 /* ni_chan encoding for FH phy */
235 #define IEEE80211_FH_CHANMOD    80
236 #define IEEE80211_FH_CHAN(set,pat)      (((set)-1)*IEEE80211_FH_CHANMOD+(pat))
237 #define IEEE80211_FH_CHANSET(chan)      ((chan)/IEEE80211_FH_CHANMOD+1)
238 #define IEEE80211_FH_CHANPAT(chan)      ((chan)%IEEE80211_FH_CHANMOD)
239
240 /*
241  * 802.11 rate set.
242  */
243 #define IEEE80211_RATE_SIZE     8               /* 802.11 standard */
244 #define IEEE80211_RATE_MAXSIZE  15              /* max rates we'll handle */
245
246 struct ieee80211_rateset {
247         uint8_t                 rs_nrates;
248         uint8_t                 rs_rates[IEEE80211_RATE_MAXSIZE];
249 };
250
251 /*
252  * 802.11n variant of ieee80211_rateset.  Instead
253  * legacy rates the entries are MCS rates.  We define
254  * the structure such that it can be used interchangeably
255  * with an ieee80211_rateset (modulo structure size).
256  */
257 #define IEEE80211_HTRATE_MAXSIZE 127
258
259 struct ieee80211_htrateset {
260         uint8_t                 rs_nrates;
261         uint8_t                 rs_rates[IEEE80211_HTRATE_MAXSIZE];
262 };
263
264 /*
265  * Roaming state visible to user space.  There are two
266  * thresholds that control whether roaming is considered;
267  * when either is exceeded the 802.11 layer will check
268  * the scan cache for another AP.  If the cache is stale
269  * then a scan may be triggered.
270  */
271 struct ieee80211_roam {
272         int8_t                  rssi11a;        /* rssi thresh for 11a bss */
273         int8_t                  rssi11b;        /* for 11g sta in 11b bss */
274         int8_t                  rssi11bOnly;    /* for 11b sta */
275         uint8_t                 pad1;
276         uint8_t                 rate11a;        /* rate thresh for 11a bss */
277         uint8_t                 rate11b;        /* for 11g sta in 11b bss */
278         uint8_t                 rate11bOnly;    /* for 11b sta */
279         uint8_t                 pad2;
280 };
281 #endif /* _NET80211__IEEE80211_H_ */