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