_ieee80211.h revision 170360
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: head/sys/net80211/_ieee80211.h 170360 2007-06-06 04:56:04Z sam $
27 */
28#ifndef _NET80211__IEEE80211_H_
29#define _NET80211__IEEE80211_H_
30
31enum 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};
37#define	IEEE80211_T_CCK	IEEE80211_T_DS	/* more common nomenclature */
38
39/* XXX not really a mode; there are really multiple PHY's */
40enum ieee80211_phymode {
41	IEEE80211_MODE_AUTO	= 0,	/* autoselect */
42	IEEE80211_MODE_11A	= 1,	/* 5GHz, OFDM */
43	IEEE80211_MODE_11B	= 2,	/* 2GHz, CCK */
44	IEEE80211_MODE_11G	= 3,	/* 2GHz, OFDM */
45	IEEE80211_MODE_FH	= 4,	/* 2GHz, GFSK */
46	IEEE80211_MODE_TURBO_A	= 5,	/* 5GHz, OFDM, 2x clock */
47	IEEE80211_MODE_TURBO_G	= 6,	/* 2GHz, OFDM, 2x clock */
48};
49#define	IEEE80211_MODE_MAX	(IEEE80211_MODE_TURBO_G+1)
50
51enum ieee80211_opmode {
52	IEEE80211_M_STA		= 1,	/* infrastructure station */
53	IEEE80211_M_IBSS 	= 0,	/* IBSS (adhoc) station */
54	IEEE80211_M_AHDEMO	= 3,	/* Old lucent compatible adhoc demo */
55	IEEE80211_M_HOSTAP	= 6,	/* Software Access Point */
56	IEEE80211_M_MONITOR	= 8	/* Monitor mode */
57};
58#define	IEEE80211_OPMODE_MAX	(IEEE80211_M_MONITOR+1)
59
60/*
61 * 802.11g protection mode.
62 */
63enum ieee80211_protmode {
64	IEEE80211_PROT_NONE	= 0,	/* no protection */
65	IEEE80211_PROT_CTSONLY	= 1,	/* CTS to self */
66	IEEE80211_PROT_RTSCTS	= 2,	/* RTS-CTS */
67};
68
69/*
70 * Authentication mode.
71 */
72enum ieee80211_authmode {
73	IEEE80211_AUTH_NONE	= 0,
74	IEEE80211_AUTH_OPEN	= 1,		/* open */
75	IEEE80211_AUTH_SHARED	= 2,		/* shared-key */
76	IEEE80211_AUTH_8021X	= 3,		/* 802.1x */
77	IEEE80211_AUTH_AUTO	= 4,		/* auto-select/accept */
78	/* NB: these are used only for ioctls */
79	IEEE80211_AUTH_WPA	= 5,		/* WPA/RSN w/ 802.1x/PSK */
80};
81
82/*
83 * Roaming mode is effectively who controls the operation
84 * of the 802.11 state machine when operating as a station.
85 * State transitions are controlled either by the driver
86 * (typically when management frames are processed by the
87 * hardware/firmware), the host (auto/normal operation of
88 * the 802.11 layer), or explicitly through ioctl requests
89 * when applications like wpa_supplicant want control.
90 */
91enum ieee80211_roamingmode {
92	IEEE80211_ROAMING_DEVICE= 0,	/* driver/hardware control */
93	IEEE80211_ROAMING_AUTO	= 1,	/* 802.11 layer control */
94	IEEE80211_ROAMING_MANUAL= 2,	/* application control */
95};
96
97/*
98 * Channels are specified by frequency and attributes.
99 */
100struct ieee80211_channel {
101	u_int16_t	ic_freq;	/* setting in Mhz */
102	u_int16_t	ic_flags;	/* see below */
103};
104
105#define	IEEE80211_CHAN_MAX	255
106#define	IEEE80211_CHAN_BYTES	32	/* howmany(IEEE80211_CHAN_MAX, NBBY) */
107#define	IEEE80211_CHAN_ANY	0xffff	/* token for ``any channel'' */
108#define	IEEE80211_CHAN_ANYC \
109	((struct ieee80211_channel *) IEEE80211_CHAN_ANY)
110
111/* bits 0-3 are for private use by drivers */
112/* channel attributes */
113#define	IEEE80211_CHAN_TURBO	0x0010	/* Turbo channel */
114#define	IEEE80211_CHAN_CCK	0x0020	/* CCK channel */
115#define	IEEE80211_CHAN_OFDM	0x0040	/* OFDM channel */
116#define	IEEE80211_CHAN_2GHZ	0x0080	/* 2 GHz spectrum channel. */
117#define	IEEE80211_CHAN_5GHZ	0x0100	/* 5 GHz spectrum channel */
118#define	IEEE80211_CHAN_PASSIVE	0x0200	/* Only passive scan allowed */
119#define	IEEE80211_CHAN_DYN	0x0400	/* Dynamic CCK-OFDM channel */
120#define	IEEE80211_CHAN_GFSK	0x0800	/* GFSK channel (FHSS PHY) */
121#define	IEEE80211_CHAN_GSM	0x1000	/* 900 MHz spectrum channel */
122#define	IEEE80211_CHAN_HALF	0x4000	/* Half rate channel */
123#define	IEEE80211_CHAN_QUARTER	0x8000	/* Quarter rate channel */
124
125/*
126 * Useful combinations of channel characteristics.
127 */
128#define	IEEE80211_CHAN_FHSS \
129	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
130#define	IEEE80211_CHAN_A \
131	(IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
132#define	IEEE80211_CHAN_B \
133	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
134#define	IEEE80211_CHAN_PUREG \
135	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
136#define	IEEE80211_CHAN_G \
137	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
138#define	IEEE80211_CHAN_T \
139	(IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
140#define	IEEE80211_CHAN_108G \
141	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
142
143#define	IEEE80211_CHAN_ALL \
144	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \
145	 IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN)
146#define	IEEE80211_CHAN_ALLTURBO \
147	(IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO)
148
149#define	IEEE80211_IS_CHAN_FHSS(_c) \
150	(((_c)->ic_flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
151#define	IEEE80211_IS_CHAN_A(_c) \
152	(((_c)->ic_flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
153#define	IEEE80211_IS_CHAN_B(_c) \
154	(((_c)->ic_flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
155#define	IEEE80211_IS_CHAN_PUREG(_c) \
156	(((_c)->ic_flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
157#define	IEEE80211_IS_CHAN_G(_c) \
158	(((_c)->ic_flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
159#define	IEEE80211_IS_CHAN_ANYG(_c) \
160	(IEEE80211_IS_CHAN_PUREG(_c) || IEEE80211_IS_CHAN_G(_c))
161#define	IEEE80211_IS_CHAN_T(_c) \
162	(((_c)->ic_flags & IEEE80211_CHAN_T) == IEEE80211_CHAN_T)
163#define	IEEE80211_IS_CHAN_108G(_c) \
164	(((_c)->ic_flags & IEEE80211_CHAN_108G) == IEEE80211_CHAN_108G)
165
166#define	IEEE80211_IS_CHAN_2GHZ(_c) \
167	(((_c)->ic_flags & IEEE80211_CHAN_2GHZ) != 0)
168#define	IEEE80211_IS_CHAN_5GHZ(_c) \
169	(((_c)->ic_flags & IEEE80211_CHAN_5GHZ) != 0)
170#define	IEEE80211_IS_CHAN_OFDM(_c) \
171	(((_c)->ic_flags & IEEE80211_CHAN_OFDM) != 0)
172#define	IEEE80211_IS_CHAN_CCK(_c) \
173	(((_c)->ic_flags & IEEE80211_CHAN_CCK) != 0)
174#define	IEEE80211_IS_CHAN_GFSK(_c) \
175	(((_c)->ic_flags & IEEE80211_CHAN_GFSK) != 0)
176#define	IEEE80211_IS_CHAN_HALF(_c) \
177	(((_c)->ic_flags & IEEE80211_CHAN_HALF) != 0)
178#define	IEEE80211_IS_CHAN_QUARTER(_c) \
179	(((_c)->ic_flags & IEEE80211_CHAN_QUARTER) != 0)
180#define	IEEE80211_IS_CHAN_FULL(_c) \
181	(((_c)->ic_flags & (IEEE80211_CHAN_QUARTER | IEEE80211_CHAN_HALF)) == 0)
182#define	IEEE80211_IS_CHAN_GSM(_c) \
183	(((_c)->ic_flags & IEEE80211_CHAN_GSM) != 0)
184#define	IEEE80211_IS_CHAN_PASSIVE(_c) \
185	(((_c)->ic_flags & IEEE80211_CHAN_PASSIVE) != 0)
186
187/* ni_chan encoding for FH phy */
188#define	IEEE80211_FH_CHANMOD	80
189#define	IEEE80211_FH_CHAN(set,pat)	(((set)-1)*IEEE80211_FH_CHANMOD+(pat))
190#define	IEEE80211_FH_CHANSET(chan)	((chan)/IEEE80211_FH_CHANMOD+1)
191#define	IEEE80211_FH_CHANPAT(chan)	((chan)%IEEE80211_FH_CHANMOD)
192
193/*
194 * 802.11 rate set.
195 */
196#define	IEEE80211_RATE_SIZE	8		/* 802.11 standard */
197#define	IEEE80211_RATE_MAXSIZE	15		/* max rates we'll handle */
198
199struct ieee80211_rateset {
200	u_int8_t		rs_nrates;
201	u_int8_t		rs_rates[IEEE80211_RATE_MAXSIZE];
202};
203
204#endif /* _NET80211__IEEE80211_H_ */
205