_ieee80211.h revision 1.2 1 1.1 dyoung /*-
2 1.1 dyoung * Copyright (c) 2001 Atsushi Onoe
3 1.1 dyoung * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
4 1.1 dyoung * All rights reserved.
5 1.1 dyoung *
6 1.1 dyoung * Redistribution and use in source and binary forms, with or without
7 1.1 dyoung * modification, are permitted provided that the following conditions
8 1.1 dyoung * are met:
9 1.1 dyoung * 1. Redistributions of source code must retain the above copyright
10 1.1 dyoung * notice, this list of conditions and the following disclaimer.
11 1.1 dyoung * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 dyoung * notice, this list of conditions and the following disclaimer in the
13 1.1 dyoung * documentation and/or other materials provided with the distribution.
14 1.1 dyoung * 3. The name of the author may not be used to endorse or promote products
15 1.1 dyoung * derived from this software without specific prior written permission.
16 1.1 dyoung *
17 1.1 dyoung * Alternatively, this software may be distributed under the terms of the
18 1.1 dyoung * GNU General Public License ("GPL") version 2 as published by the Free
19 1.1 dyoung * Software Foundation.
20 1.1 dyoung *
21 1.1 dyoung * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 dyoung * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 dyoung * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 dyoung * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 dyoung * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 dyoung * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 dyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 dyoung * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 dyoung * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 dyoung * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 dyoung *
32 1.2 dyoung * $FreeBSD: src/sys/net80211/_ieee80211.h,v 1.3 2005/08/10 17:42:13 sam Exp $
33 1.1 dyoung */
34 1.1 dyoung #ifndef _NET80211__IEEE80211_H_
35 1.1 dyoung #define _NET80211__IEEE80211_H_
36 1.1 dyoung
37 1.1 dyoung enum ieee80211_phytype {
38 1.1 dyoung IEEE80211_T_DS, /* direct sequence spread spectrum */
39 1.1 dyoung IEEE80211_T_FH, /* frequency hopping */
40 1.1 dyoung IEEE80211_T_OFDM, /* frequency division multiplexing */
41 1.1 dyoung IEEE80211_T_TURBO, /* high rate OFDM, aka turbo mode */
42 1.1 dyoung };
43 1.1 dyoung #define IEEE80211_T_CCK IEEE80211_T_DS /* more common nomenclature */
44 1.1 dyoung
45 1.1 dyoung /* XXX not really a mode; there are really multiple PHY's */
46 1.1 dyoung enum ieee80211_phymode {
47 1.1 dyoung IEEE80211_MODE_AUTO = 0, /* autoselect */
48 1.1 dyoung IEEE80211_MODE_11A = 1, /* 5GHz, OFDM */
49 1.1 dyoung IEEE80211_MODE_11B = 2, /* 2GHz, CCK */
50 1.1 dyoung IEEE80211_MODE_11G = 3, /* 2GHz, OFDM */
51 1.1 dyoung IEEE80211_MODE_FH = 4, /* 2GHz, GFSK */
52 1.1 dyoung IEEE80211_MODE_TURBO_A = 5, /* 5GHz, OFDM, 2x clock */
53 1.1 dyoung IEEE80211_MODE_TURBO_G = 6, /* 2GHz, OFDM, 2x clock */
54 1.1 dyoung };
55 1.1 dyoung #define IEEE80211_MODE_MAX (IEEE80211_MODE_TURBO_G+1)
56 1.1 dyoung
57 1.1 dyoung enum ieee80211_opmode {
58 1.1 dyoung IEEE80211_M_STA = 1, /* infrastructure station */
59 1.1 dyoung IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */
60 1.1 dyoung IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */
61 1.1 dyoung IEEE80211_M_HOSTAP = 6, /* Software Access Point */
62 1.1 dyoung IEEE80211_M_MONITOR = 8 /* Monitor mode */
63 1.1 dyoung };
64 1.1 dyoung
65 1.1 dyoung /*
66 1.1 dyoung * 802.11g protection mode.
67 1.1 dyoung */
68 1.1 dyoung enum ieee80211_protmode {
69 1.1 dyoung IEEE80211_PROT_NONE = 0, /* no protection */
70 1.1 dyoung IEEE80211_PROT_CTSONLY = 1, /* CTS to self */
71 1.1 dyoung IEEE80211_PROT_RTSCTS = 2, /* RTS-CTS */
72 1.1 dyoung };
73 1.1 dyoung
74 1.1 dyoung /*
75 1.1 dyoung * Authentication mode.
76 1.1 dyoung */
77 1.1 dyoung enum ieee80211_authmode {
78 1.1 dyoung IEEE80211_AUTH_NONE = 0,
79 1.1 dyoung IEEE80211_AUTH_OPEN = 1, /* open */
80 1.1 dyoung IEEE80211_AUTH_SHARED = 2, /* shared-key */
81 1.1 dyoung IEEE80211_AUTH_8021X = 3, /* 802.1x */
82 1.1 dyoung IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */
83 1.1 dyoung /* NB: these are used only for ioctls */
84 1.1 dyoung IEEE80211_AUTH_WPA = 5, /* WPA/RSN w/ 802.1x/PSK */
85 1.1 dyoung };
86 1.1 dyoung
87 1.1 dyoung /*
88 1.1 dyoung * Roaming mode is effectively who controls the operation
89 1.1 dyoung * of the 802.11 state machine when operating as a station.
90 1.1 dyoung * State transitions are controlled either by the driver
91 1.1 dyoung * (typically when management frames are processed by the
92 1.1 dyoung * hardware/firmware), the host (auto/normal operation of
93 1.1 dyoung * the 802.11 layer), or explicitly through ioctl requests
94 1.1 dyoung * when applications like wpa_supplicant want control.
95 1.1 dyoung */
96 1.1 dyoung enum ieee80211_roamingmode {
97 1.1 dyoung IEEE80211_ROAMING_DEVICE= 0, /* driver/hardware control */
98 1.1 dyoung IEEE80211_ROAMING_AUTO = 1, /* 802.11 layer control */
99 1.1 dyoung IEEE80211_ROAMING_MANUAL= 2, /* application control */
100 1.1 dyoung };
101 1.1 dyoung
102 1.1 dyoung /*
103 1.1 dyoung * Channels are specified by frequency and attributes.
104 1.1 dyoung */
105 1.1 dyoung struct ieee80211_channel {
106 1.1 dyoung u_int16_t ic_freq; /* setting in Mhz */
107 1.1 dyoung u_int16_t ic_flags; /* see below */
108 1.1 dyoung };
109 1.1 dyoung
110 1.1 dyoung #define IEEE80211_CHAN_MAX 255
111 1.1 dyoung #define IEEE80211_CHAN_BYTES 32 /* howmany(IEEE80211_CHAN_MAX, NBBY) */
112 1.1 dyoung #define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */
113 1.1 dyoung #define IEEE80211_CHAN_ANYC \
114 1.2 dyoung ((struct ieee80211_channel *) 0x1)
115 1.1 dyoung
116 1.1 dyoung /* bits 0-3 are for private use by drivers */
117 1.1 dyoung /* channel attributes */
118 1.1 dyoung #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
119 1.1 dyoung #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
120 1.1 dyoung #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
121 1.1 dyoung #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
122 1.1 dyoung #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
123 1.1 dyoung #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
124 1.1 dyoung #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
125 1.1 dyoung #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
126 1.1 dyoung
127 1.1 dyoung /*
128 1.1 dyoung * Useful combinations of channel characteristics.
129 1.1 dyoung */
130 1.1 dyoung #define IEEE80211_CHAN_FHSS \
131 1.1 dyoung (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
132 1.1 dyoung #define IEEE80211_CHAN_A \
133 1.1 dyoung (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
134 1.1 dyoung #define IEEE80211_CHAN_B \
135 1.1 dyoung (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
136 1.1 dyoung #define IEEE80211_CHAN_PUREG \
137 1.1 dyoung (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
138 1.1 dyoung #define IEEE80211_CHAN_G \
139 1.1 dyoung (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
140 1.1 dyoung #define IEEE80211_CHAN_T \
141 1.1 dyoung (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
142 1.1 dyoung #define IEEE80211_CHAN_108G \
143 1.1 dyoung (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
144 1.1 dyoung
145 1.1 dyoung #define IEEE80211_IS_CHAN_FHSS(_c) \
146 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
147 1.1 dyoung #define IEEE80211_IS_CHAN_A(_c) \
148 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
149 1.1 dyoung #define IEEE80211_IS_CHAN_B(_c) \
150 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
151 1.1 dyoung #define IEEE80211_IS_CHAN_PUREG(_c) \
152 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
153 1.1 dyoung #define IEEE80211_IS_CHAN_G(_c) \
154 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
155 1.2 dyoung #define IEEE80211_IS_CHAN_ANYG(_c) \
156 1.2 dyoung (IEEE80211_IS_CHAN_PUREG(_c) || IEEE80211_IS_CHAN_G(_c))
157 1.1 dyoung #define IEEE80211_IS_CHAN_T(_c) \
158 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_T) == IEEE80211_CHAN_T)
159 1.1 dyoung #define IEEE80211_IS_CHAN_108G(_c) \
160 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_108G) == IEEE80211_CHAN_108G)
161 1.1 dyoung
162 1.1 dyoung #define IEEE80211_IS_CHAN_2GHZ(_c) \
163 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_2GHZ) != 0)
164 1.1 dyoung #define IEEE80211_IS_CHAN_5GHZ(_c) \
165 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_5GHZ) != 0)
166 1.1 dyoung #define IEEE80211_IS_CHAN_OFDM(_c) \
167 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_OFDM) != 0)
168 1.1 dyoung #define IEEE80211_IS_CHAN_CCK(_c) \
169 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_CCK) != 0)
170 1.1 dyoung #define IEEE80211_IS_CHAN_GFSK(_c) \
171 1.1 dyoung (((_c)->ic_flags & IEEE80211_CHAN_GFSK) != 0)
172 1.1 dyoung
173 1.1 dyoung /* ni_chan encoding for FH phy */
174 1.1 dyoung #define IEEE80211_FH_CHANMOD 80
175 1.1 dyoung #define IEEE80211_FH_CHAN(set,pat) (((set)-1)*IEEE80211_FH_CHANMOD+(pat))
176 1.1 dyoung #define IEEE80211_FH_CHANSET(chan) ((chan)/IEEE80211_FH_CHANMOD+1)
177 1.1 dyoung #define IEEE80211_FH_CHANPAT(chan) ((chan)%IEEE80211_FH_CHANMOD)
178 1.1 dyoung
179 1.1 dyoung /*
180 1.1 dyoung * 802.11 rate set.
181 1.1 dyoung */
182 1.1 dyoung #define IEEE80211_RATE_SIZE 8 /* 802.11 standard */
183 1.1 dyoung #define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */
184 1.1 dyoung
185 1.1 dyoung struct ieee80211_rateset {
186 1.1 dyoung u_int8_t rs_nrates;
187 1.1 dyoung u_int8_t rs_rates[IEEE80211_RATE_MAXSIZE];
188 1.1 dyoung };
189 1.1 dyoung
190 1.1 dyoung #endif /* _NET80211__IEEE80211_H_ */
191