* Use id(1) instead of grep(1) to detect the presence of the smmsp
[dragonfly.git] / sys / net / if_ieee80211.h
1 /*      $NetBSD: if_ieee80211.h,v 1.5 2000/07/21 04:47:40 onoe Exp $    */
2 /* $FreeBSD: src/sys/net/if_ieee80211.h,v 1.3.2.5 2002/08/03 07:17:09 imp Exp $ */
3 /* $DragonFly: src/sys/net/Attic/if_ieee80211.h,v 1.3 2004/01/06 03:17:25 dillon Exp $ */
4
5 #ifndef _NET_IF_IEEE80211_H_
6 #define _NET_IF_IEEE80211_H_
7
8 /*
9  * generic definitions for IEEE 802.11 frames
10  */
11 struct ieee80211_frame {
12         u_int8_t        i_fc[2];
13         u_int8_t        i_dur[2];
14         u_int8_t        i_addr1[ETHER_ADDR_LEN];
15         u_int8_t        i_addr2[ETHER_ADDR_LEN];
16         u_int8_t        i_addr3[ETHER_ADDR_LEN];
17         u_int8_t        i_seq[2];
18         /* possibly followed by addr4[ETHER_ADDR_LEN]; */
19 };
20
21 #define IEEE80211_FC0_VERSION_MASK              0x03
22 #define IEEE80211_FC0_VERSION_0                 0x00
23 #define IEEE80211_FC0_TYPE_MASK                 0x0c
24 #define IEEE80211_FC0_TYPE_MGT                  0x00
25 #define IEEE80211_FC0_TYPE_CTL                  0x04
26 #define IEEE80211_FC0_TYPE_DATA                 0x08
27
28 #define IEEE80211_FC0_SUBTYPE_MASK              0xf0
29 /* for TYPE_MGT */
30 #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ         0x00
31 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP        0x10
32 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ       0x20
33 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP      0x30
34 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ         0x40
35 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP        0x50
36 #define IEEE80211_FC0_SUBTYPE_BEACON            0x80
37 #define IEEE80211_FC0_SUBTYPE_ATIM              0x90
38 #define IEEE80211_FC0_SUBTYPE_DISASSOC          0xa0
39 #define IEEE80211_FC0_SUBTYPE_AUTH              0xb0
40 #define IEEE80211_FC0_SUBTYPE_DEAUTH            0xc0
41 /* for TYPE_CTL */
42 #define IEEE80211_FC0_SUBTYPE_PS_POLL           0xa0
43 #define IEEE80211_FC0_SUBTYPE_RTS               0xb0
44 #define IEEE80211_FC0_SUBTYPE_CTS               0xc0
45 #define IEEE80211_FC0_SUBTYPE_ACK               0xd0
46 #define IEEE80211_FC0_SUBTYPE_CF_END            0xe0
47 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK        0xf0
48 /* for TYPE_DATA (bit combination) */
49 #define IEEE80211_FC0_SUBTYPE_DATA              0x00
50 #define IEEE80211_FC0_SUBTYPE_CF_ACK            0x10
51 #define IEEE80211_FC0_SUBTYPE_CF_POLL           0x20
52 #define IEEE80211_FC0_SUBTYPE_CF_ACPL           0x30
53 #define IEEE80211_FC0_SUBTYPE_NODATA            0x40
54 #define IEEE80211_FC0_SUBTYPE_CFACK             0x50
55 #define IEEE80211_FC0_SUBTYPE_CFPOLL            0x60
56 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK     0x70
57
58 #define IEEE80211_FC1_DIR_MASK                  0x03
59 #define IEEE80211_FC1_DIR_NODS                  0x00    /* STA->STA */
60 #define IEEE80211_FC1_DIR_TODS                  0x01    /* STA->AP  */
61 #define IEEE80211_FC1_DIR_FROMDS                0x02    /* AP ->STA */
62 #define IEEE80211_FC1_DIR_DSTODS                0x03    /* AP ->AP  */
63
64 #define IEEE80211_FC1_MORE_FRAG                 0x04
65 #define IEEE80211_FC1_RETRY                     0x08
66 #define IEEE80211_FC1_PWR_MGT                   0x10
67 #define IEEE80211_FC1_MORE_DATA                 0x20
68 #define IEEE80211_FC1_WEP                       0x40
69 #define IEEE80211_FC1_ORDER                     0x80
70
71 #define IEEE80211_NWID_LEN                      32
72
73 /*
74  * BEACON management packets
75  *
76  *      octect timestamp[8]
77  *      octect beacon interval[2]
78  *      octect capability information[2]
79  *      information element
80  *              octect elemid
81  *              octect length
82  *              octect information[length[
83  */
84 typedef u_int8_t *      ieee80211_mgt_beacon_t;
85
86 #define IEEE80211_BEACON_INTERVAL(beacon) \
87         (beacon[8] + (beacon[9] << 8))
88 #define IEEE80211_BEACON_CAPABILITY(beacon) \
89         (beacon[10] + (beacon[11] << 8))
90
91 #define IEEE80211_CAPINFO_ESS                   0x01
92 #define IEEE80211_CAPINFO_IBSS                  0x02
93 #define IEEE80211_CAPINFO_CF_POLLABLE           0x04
94 #define IEEE80211_CAPINFO_CF_POLLREQ            0x08
95 #define IEEE80211_CAPINFO_PRIVACY               0x10
96 #define IEEE80211_CAPINFO_BITS  "\20\01ESS\02IBSS\03POLLABLE\04POLLREQ\5PRIVACY"
97
98 /*
99  * Management information elements
100  */
101 struct ieee80211_information {
102         char    ssid[IEEE80211_NWID_LEN+1];
103         struct rates {
104                 u_int8_t        *p;
105         } rates;
106         struct fh {
107                 u_int16_t       dwell;
108                 u_int8_t        set;
109                 u_int8_t        pattern;
110                 u_int8_t        index;
111         } fh;
112         struct ds {
113                 u_int8_t        channel;
114         } ds;
115         struct cf {
116                 u_int8_t        count;
117                 u_int8_t        period;
118                 u_int8_t        maxdur[2];
119                 u_int8_t        dur[2];
120         } cf;
121         struct tim {
122                 u_int8_t        count;
123                 u_int8_t        period;
124                 u_int8_t        bitctl;
125                 /* u_int8_t     pvt[251]; The driver never needs to use this */
126         } tim;
127         struct ibss {
128                 u_int16_t       atim;
129         } ibss;
130         struct challenge {
131                 u_int8_t        *p;
132                 u_int8_t        len;
133         } challenge;
134 };
135
136 #define IEEE80211_ELEMID_SSID                   0
137 #define IEEE80211_ELEMID_RATES                  1
138 #define IEEE80211_ELEMID_FHPARMS                2
139 #define IEEE80211_ELEMID_DSPARMS                3
140 #define IEEE80211_ELEMID_CFPARMS                4
141 #define IEEE80211_ELEMID_TIM                    5
142 #define IEEE80211_ELEMID_IBSSPARMS              6
143 #define IEEE80211_ELEMID_CHALLENGE              16
144
145 /*
146  * AUTH management packets
147  *
148  *      octect algo[2]
149  *      octect seq[2]
150  *      octect status[2]
151  *      octect chal.id
152  *      octect chal.length
153  *      octect chal.text[253]
154  */
155 typedef u_int8_t *      ieee80211_mgt_auth_t;
156
157 #define IEEE80211_AUTH_ALGORITHM(auth) \
158     (auth[0] + (auth[1] << 8))
159 #define IEEE80211_AUTH_TRANSACTION(auth) \
160     (auth[2] + (auth[3] << 8))
161 #define IEEE80211_AUTH_STATUS(auth) \
162     (auth[4] + (auth[5] << 8))
163
164 #define IEEE80211_AUTH_ALG_OPEN                 0x0000
165 #define IEEE80211_AUTH_ALG_SHARED               0x0001
166
167 #define IEEE80211_AUTH_OPEN_REQUEST             1
168 #define IEEE80211_AUTH_OPEN_RESPONSE            2
169
170 #define IEEE80211_AUTH_SHARED_REQUEST           1
171 #define IEEE80211_AUTH_SHARED_CHALLENGE         2
172 #define IEEE80211_AUTH_SHARED_RESPONSE          3
173 #define IEEE80211_AUTH_SHARED_PASS              4
174
175 /*
176  * Reason codes
177  *
178  * Unlisted codes are reserved
179  */
180 #define IEEE80211_REASON_UNSPECIFIED            1
181 #define IEEE80211_REASON_AUTH_EXPIRE            2
182 #define IEEE80211_REASON_AUTH_LEAVE             3
183 #define IEEE80211_REASON_ASSOC_EXPIRE           4
184 #define IEEE80211_REASON_ASSOC_TOOMANY          5
185 #define IEEE80211_REASON_NOT_AUTHED             6  
186 #define IEEE80211_REASON_NOT_ASSOCED            7
187 #define IEEE80211_REASON_ASSOC_LEAVE            8
188 #define IEEE80211_REASON_ASSOC_NOT_AUTHED       9
189
190 /*
191  * Status code
192  *
193  * Unlisted codes are reserved
194  */
195 #define IEEE80211_STATUS_SUCCESS                0x0000
196 #define IEEE80211_STATUS_UNSPECIFIED            1
197 #define IEEE80211_STATUS_CAPINFO                10
198 #define IEEE80211_STATUS_NOT_ASSOCED            11
199 #define IEEE80211_STATUS_OTHER                  12
200 #define IEEE80211_STATUS_ALG                    13
201 #define IEEE80211_STATUS_SEQUENCE               14
202 #define IEEE80211_STATUS_CHALLENGE              15
203 #define IEEE80211_STATUS_TIMEOUT                16
204 #define IEEE80211_STATUS_TOO_MANY_STATIONS      17
205 #define IEEE80211_STATUS_RATES                  18
206
207 #define IEEE80211_WEP_KEYLEN                    5       /* 40bit */
208 #define IEEE80211_WEP_IVLEN                     3       /* 24bit */
209 #define IEEE80211_WEP_KIDLEN                    1       /* 1 octet */
210 #define IEEE80211_WEP_CRCLEN                    4       /* CRC-32 */
211 #define IEEE80211_WEP_NKID                      4       /* number of key ids */
212
213 /* nwid is pointed at by ifr.ifr_data */
214 struct ieee80211_nwid {
215         u_int8_t        i_len;
216         u_int8_t        i_nwid[IEEE80211_NWID_LEN];
217 };
218
219 #define SIOCS80211NWID          _IOWR('i', 230, struct ifreq)
220 #define SIOCG80211NWID          _IOWR('i', 231, struct ifreq)
221
222 /* the first member must be matched with struct ifreq */
223 struct ieee80211_nwkey {
224         char            i_name[IFNAMSIZ];       /* if_xname, e.g. "wi0" */
225         int             i_wepon;                /* wep enabled flag */
226         int             i_defkid;               /* default encrypt key id */
227         struct {
228                 int             i_keylen;
229                 u_int8_t        *i_keydat;
230         }               i_key[IEEE80211_WEP_NKID];
231 };
232 #define SIOCS80211NWKEY          _IOW('i', 232, struct ieee80211_nwkey)
233 #define SIOCG80211NWKEY         _IOWR('i', 233, struct ieee80211_nwkey)
234
235 #define IEEE80211_WEP_NOSUP     -1
236 #define IEEE80211_WEP_OFF       0
237 #define IEEE80211_WEP_ON        1
238 #define IEEE80211_WEP_MIXED     2
239
240 #define IEEE80211_AUTH_NONE     0
241 #define IEEE80211_AUTH_OPEN     1
242 #define IEEE80211_AUTH_SHARED   2
243
244 #define IEEE80211_POWERSAVE_NOSUP       -1
245 #define IEEE80211_POWERSAVE_OFF         0
246 #define IEEE80211_POWERSAVE_CAM         1
247 #define IEEE80211_POWERSAVE_PSP         2
248 #define IEEE80211_POWERSAVE_PSP_CAM     3
249 #define IEEE80211_POWERSAVE_ON          IEEE80211_POWERSAVE_CAM
250
251 /* the first member must be matched with struct ifreq */
252 struct ieee80211req {
253         char            i_name[IFNAMSIZ];       /* if_xname, e.g. "wi0" */
254         u_int16_t       i_type;                 /* req type */
255         int16_t         i_val;                  /* Index or simple value */
256         int16_t         i_len;                  /* Index or simple value */
257         void            *i_data;                /* Extra data */
258 };
259 #define SIOCS80211               _IOW('i', 234, struct ieee80211req)
260 #define SIOCG80211              _IOWR('i', 235, struct ieee80211req)
261
262 #define IEEE80211_IOC_SSID              1
263 #define IEEE80211_IOC_NUMSSIDS          2
264 #define IEEE80211_IOC_WEP               3
265 #define IEEE80211_IOC_WEPKEY            4
266 #define IEEE80211_IOC_NUMWEPKEYS        5
267 #define IEEE80211_IOC_WEPTXKEY          6
268 #define IEEE80211_IOC_AUTHMODE          7
269 #define IEEE80211_IOC_STATIONNAME       8
270 #define IEEE80211_IOC_CHANNEL           9
271 #define IEEE80211_IOC_POWERSAVE         10
272 #define IEEE80211_IOC_POWERSAVESLEEP    11
273
274 #endif /* !_NET_IF_IEEE80211_H_ */