Merge from vendor branch LIBARCHIVE:
[dragonfly.git] / sys / netproto / 802_11 / ieee80211.h
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.9.2.2 2006/08/10 06:07:49 sam Exp $
33  * $DragonFly: src/sys/netproto/802_11/ieee80211.h,v 1.9 2007/10/28 02:29:06 sephe Exp $
34  */
35 #ifndef _NET80211_IEEE80211_H_
36 #define _NET80211_IEEE80211_H_
37
38 /*
39  * 802.11 protocol definitions.
40  */
41
42 #define IEEE80211_ADDR_LEN      6               /* size of 802.11 address */
43
44 /* is 802.11 address multicast/broadcast? */
45 #define IEEE80211_IS_MULTICAST(_a)      (*(_a) & 0x01)
46
47 /* IEEE 802.11 PLCP header */
48 struct ieee80211_plcp_hdr {
49         uint16_t        i_sfd;
50         uint8_t         i_signal;
51         uint8_t         i_service;
52         uint16_t        i_length;
53         uint16_t        i_crc;
54 } __packed;
55
56 #define IEEE80211_PLCP_SFD      0xF3A0 
57 #define IEEE80211_PLCP_SERVICE  0x00
58
59 /*
60  * generic definitions for IEEE 802.11 frames
61  */
62 struct ieee80211_frame {
63         uint8_t         i_fc[2];
64         uint8_t         i_dur[2];
65         uint8_t         i_addr1[IEEE80211_ADDR_LEN];
66         uint8_t         i_addr2[IEEE80211_ADDR_LEN];
67         uint8_t         i_addr3[IEEE80211_ADDR_LEN];
68         uint8_t         i_seq[2];
69         /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
70         /* see below */
71 } __packed;
72
73 struct ieee80211_qosframe {
74         uint8_t         i_fc[2];
75         uint8_t         i_dur[2];
76         uint8_t         i_addr1[IEEE80211_ADDR_LEN];
77         uint8_t         i_addr2[IEEE80211_ADDR_LEN];
78         uint8_t         i_addr3[IEEE80211_ADDR_LEN];
79         uint8_t         i_seq[2];
80         uint8_t         i_qos[2];
81         /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
82         /* see below */
83 } __packed;
84
85 struct ieee80211_qoscntl {
86         uint8_t         i_qos[2];
87 };
88
89 struct ieee80211_frame_addr4 {
90         uint8_t         i_fc[2];
91         uint8_t         i_dur[2];
92         uint8_t         i_addr1[IEEE80211_ADDR_LEN];
93         uint8_t         i_addr2[IEEE80211_ADDR_LEN];
94         uint8_t         i_addr3[IEEE80211_ADDR_LEN];
95         uint8_t         i_seq[2];
96         uint8_t         i_addr4[IEEE80211_ADDR_LEN];
97 } __packed;
98
99
100 struct ieee80211_qosframe_addr4 {
101         uint8_t         i_fc[2];
102         uint8_t         i_dur[2];
103         uint8_t         i_addr1[IEEE80211_ADDR_LEN];
104         uint8_t         i_addr2[IEEE80211_ADDR_LEN];
105         uint8_t         i_addr3[IEEE80211_ADDR_LEN];
106         uint8_t         i_seq[2];
107         uint8_t         i_addr4[IEEE80211_ADDR_LEN];
108         uint8_t         i_qos[2];
109 } __packed;
110
111 #define IEEE80211_FC0_VERSION_MASK              0x03
112 #define IEEE80211_FC0_VERSION_SHIFT             0
113 #define IEEE80211_FC0_VERSION_0                 0x00
114 #define IEEE80211_FC0_TYPE_MASK                 0x0c
115 #define IEEE80211_FC0_TYPE_SHIFT                2
116 #define IEEE80211_FC0_TYPE_MGT                  0x00
117 #define IEEE80211_FC0_TYPE_CTL                  0x04
118 #define IEEE80211_FC0_TYPE_DATA                 0x08
119
120 #define IEEE80211_FC0_SUBTYPE_MASK              0xf0
121 #define IEEE80211_FC0_SUBTYPE_SHIFT             4
122 /* for TYPE_MGT */
123 #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ         0x00
124 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP        0x10
125 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ       0x20
126 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP      0x30
127 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ         0x40
128 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP        0x50
129 #define IEEE80211_FC0_SUBTYPE_BEACON            0x80
130 #define IEEE80211_FC0_SUBTYPE_ATIM              0x90
131 #define IEEE80211_FC0_SUBTYPE_DISASSOC          0xa0
132 #define IEEE80211_FC0_SUBTYPE_AUTH              0xb0
133 #define IEEE80211_FC0_SUBTYPE_DEAUTH            0xc0
134 /* for TYPE_CTL */
135 #define IEEE80211_FC0_SUBTYPE_PS_POLL           0xa0
136 #define IEEE80211_FC0_SUBTYPE_RTS               0xb0
137 #define IEEE80211_FC0_SUBTYPE_CTS               0xc0
138 #define IEEE80211_FC0_SUBTYPE_ACK               0xd0
139 #define IEEE80211_FC0_SUBTYPE_CF_END            0xe0
140 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK        0xf0
141 /* for TYPE_DATA (bit combination) */
142 #define IEEE80211_FC0_SUBTYPE_DATA              0x00
143 #define IEEE80211_FC0_SUBTYPE_CF_ACK            0x10
144 #define IEEE80211_FC0_SUBTYPE_CF_POLL           0x20
145 #define IEEE80211_FC0_SUBTYPE_CF_ACPL           0x30
146 #define IEEE80211_FC0_SUBTYPE_NODATA            0x40
147 #define IEEE80211_FC0_SUBTYPE_CFACK             0x50
148 #define IEEE80211_FC0_SUBTYPE_CFPOLL            0x60
149 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK     0x70
150 #define IEEE80211_FC0_SUBTYPE_QOS               0x80
151 #define IEEE80211_FC0_SUBTYPE_QOS_NULL          0xc0
152
153 #define IEEE80211_FC1_DIR_MASK                  0x03
154 #define IEEE80211_FC1_DIR_NODS                  0x00    /* STA->STA */
155 #define IEEE80211_FC1_DIR_TODS                  0x01    /* STA->AP  */
156 #define IEEE80211_FC1_DIR_FROMDS                0x02    /* AP ->STA */
157 #define IEEE80211_FC1_DIR_DSTODS                0x03    /* AP ->AP  */
158
159 #define IEEE80211_FC1_MORE_FRAG                 0x04
160 #define IEEE80211_FC1_RETRY                     0x08
161 #define IEEE80211_FC1_PWR_MGT                   0x10
162 #define IEEE80211_FC1_MORE_DATA                 0x20
163 #define IEEE80211_FC1_WEP                       0x40
164 #define IEEE80211_FC1_ORDER                     0x80
165
166 #define IEEE80211_SEQ_FRAG_MASK                 0x000f
167 #define IEEE80211_SEQ_FRAG_SHIFT                0
168 #define IEEE80211_SEQ_SEQ_MASK                  0xfff0
169 #define IEEE80211_SEQ_SEQ_SHIFT                 4
170
171 #define IEEE80211_NWID_LEN                      32
172
173 #define IEEE80211_QOS_TXOP                      0x00ff
174 /* bit 8 is reserved */
175 #define IEEE80211_QOS_ACKPOLICY                 0x60
176 #define IEEE80211_QOS_ACKPOLICY_S               5
177 #define IEEE80211_QOS_ESOP                      0x10
178 #define IEEE80211_QOS_ESOP_S                    4
179 #define IEEE80211_QOS_TID                       0x0f
180
181 /* does frame have QoS sequence control data */
182 #define IEEE80211_QOS_HAS_SEQ(wh) \
183         (((wh)->i_fc[0] & \
184           (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \
185           (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
186
187 /*
188  * WME/802.11e information element.
189  */
190 struct ieee80211_wme_info {
191         uint8_t         wme_id;         /* IEEE80211_ELEMID_VENDOR */
192         uint8_t         wme_len;        /* length in bytes */
193         uint8_t         wme_oui[3];     /* 0x00, 0x50, 0xf2 */
194         uint8_t         wme_type;       /* OUI type */
195         uint8_t         wme_subtype;    /* OUI subtype */
196         uint8_t         wme_version;    /* spec revision */
197         uint8_t         wme_info;       /* QoS info */
198 } __packed;
199
200 /*
201  * WME/802.11e Tspec Element
202  */
203 struct ieee80211_wme_tspec {
204         uint8_t         ts_id;
205         uint8_t         ts_len;
206         uint8_t         ts_oui[3];
207         uint8_t         ts_oui_type;
208         uint8_t         ts_oui_subtype;
209         uint8_t         ts_version;
210         uint8_t         ts_tsinfo[3];
211         uint8_t         ts_nom_msdu[2];
212         uint8_t         ts_max_msdu[2];
213         uint8_t         ts_min_svc[4];
214         uint8_t         ts_max_svc[4];
215         uint8_t         ts_inactv_intv[4];
216         uint8_t         ts_susp_intv[4];
217         uint8_t         ts_start_svc[4];
218         uint8_t         ts_min_rate[4];
219         uint8_t         ts_mean_rate[4];
220         uint8_t         ts_max_burst[4];
221         uint8_t         ts_min_phy[4];
222         uint8_t         ts_peak_rate[4];
223         uint8_t         ts_delay[4];
224         uint8_t         ts_surplus[2];
225         uint8_t         ts_medium_time[2];
226 } __packed;
227
228 /*
229  * WME AC parameter field
230  */
231 struct ieee80211_wme_acparams {
232         uint8_t         acp_aci_aifsn;
233         uint8_t         acp_logcwminmax;
234         uint16_t        acp_txop;
235 } __packed;
236
237 #define WME_NUM_AC              4       /* 4 AC categories */
238
239 #define WME_PARAM_ACI           0x60    /* Mask for ACI field */
240 #define WME_PARAM_ACI_S         5       /* Shift for ACI field */
241 #define WME_PARAM_ACM           0x10    /* Mask for ACM bit */
242 #define WME_PARAM_ACM_S         4       /* Shift for ACM bit */
243 #define WME_PARAM_AIFSN         0x0f    /* Mask for aifsn field */
244 #define WME_PARAM_AIFSN_S       0       /* Shift for aifsn field */
245 #define WME_PARAM_LOGCWMIN      0x0f    /* Mask for CwMin field (in log) */
246 #define WME_PARAM_LOGCWMIN_S    0       /* Shift for CwMin field */
247 #define WME_PARAM_LOGCWMAX      0xf0    /* Mask for CwMax field (in log) */
248 #define WME_PARAM_LOGCWMAX_S    4       /* Shift for CwMax field */
249
250 #define WME_AC_TO_TID(_ac) (       \
251         ((_ac) == WME_AC_VO) ? 6 : \
252         ((_ac) == WME_AC_VI) ? 5 : \
253         ((_ac) == WME_AC_BK) ? 1 : \
254         0)
255
256 #define TID_TO_WME_AC(_tid) (      \
257         ((_tid) < 1) ? WME_AC_BE : \
258         ((_tid) < 3) ? WME_AC_BK : \
259         ((_tid) < 6) ? WME_AC_VI : \
260         WME_AC_VO)
261
262 /*
263  * WME Parameter Element
264  */
265 struct ieee80211_wme_param {
266         uint8_t         param_id;
267         uint8_t         param_len;
268         uint8_t         param_oui[3];
269         uint8_t         param_oui_type;
270         uint8_t         param_oui_sybtype;
271         uint8_t         param_version;
272         uint8_t         param_qosInfo;
273 #define WME_QOSINFO_COUNT       0x0f    /* Mask for param count field */
274         uint8_t         param_reserved;
275         struct ieee80211_wme_acparams   params_acParams[WME_NUM_AC];
276 } __packed;
277
278 /*
279  * Management Notification Frame
280  */
281 struct ieee80211_mnf {
282         uint8_t         mnf_category;
283         uint8_t         mnf_action;
284         uint8_t         mnf_dialog;
285         uint8_t         mnf_status;
286 } __packed;
287 #define MNF_SETUP_REQ   0
288 #define MNF_SETUP_RESP  1
289 #define MNF_TEARDOWN    2
290
291 /*
292  * Control frames.
293  */
294 struct ieee80211_frame_min {
295         uint8_t         i_fc[2];
296         uint8_t         i_dur[2];
297         uint8_t         i_addr1[IEEE80211_ADDR_LEN];
298         uint8_t         i_addr2[IEEE80211_ADDR_LEN];
299         /* FCS */
300 } __packed;
301
302 struct ieee80211_frame_rts {
303         uint8_t         i_fc[2];
304         uint8_t         i_dur[2];
305         uint8_t         i_ra[IEEE80211_ADDR_LEN];
306         uint8_t         i_ta[IEEE80211_ADDR_LEN];
307         /* FCS */
308 } __packed;
309
310 struct ieee80211_frame_cts {
311         uint8_t         i_fc[2];
312         uint8_t         i_dur[2];
313         uint8_t         i_ra[IEEE80211_ADDR_LEN];
314         /* FCS */
315 } __packed;
316
317 struct ieee80211_frame_ack {
318         uint8_t         i_fc[2];
319         uint8_t         i_dur[2];
320         uint8_t         i_ra[IEEE80211_ADDR_LEN];
321         /* FCS */
322 } __packed;
323
324 struct ieee80211_frame_pspoll {
325         uint8_t         i_fc[2];
326         uint8_t         i_aid[2];
327         uint8_t         i_bssid[IEEE80211_ADDR_LEN];
328         uint8_t         i_ta[IEEE80211_ADDR_LEN];
329         /* FCS */
330 } __packed;
331
332 struct ieee80211_frame_cfend {          /* NB: also CF-End+CF-Ack */
333         uint8_t         i_fc[2];
334         uint8_t         i_dur[2];       /* should be zero */
335         uint8_t         i_ra[IEEE80211_ADDR_LEN];
336         uint8_t         i_bssid[IEEE80211_ADDR_LEN];
337         /* FCS */
338 } __packed;
339
340 /*
341  * BEACON management packets
342  *
343  *      octet timestamp[8]
344  *      octet beacon interval[2]
345  *      octet capability information[2]
346  *      information element
347  *              octet elemid
348  *              octet length
349  *              octet information[length]
350  */
351
352 typedef uint8_t *ieee80211_mgt_beacon_t;
353
354 #define IEEE80211_BEACON_INTERVAL(beacon) \
355         ((beacon)[8] | ((beacon)[9] << 8))
356 #define IEEE80211_BEACON_CAPABILITY(beacon) \
357         ((beacon)[10] | ((beacon)[11] << 8))
358
359 #define IEEE80211_CAPINFO_ESS                   0x0001
360 #define IEEE80211_CAPINFO_IBSS                  0x0002
361 #define IEEE80211_CAPINFO_CF_POLLABLE           0x0004
362 #define IEEE80211_CAPINFO_CF_POLLREQ            0x0008
363 #define IEEE80211_CAPINFO_PRIVACY               0x0010
364 #define IEEE80211_CAPINFO_SHORT_PREAMBLE        0x0020
365 #define IEEE80211_CAPINFO_PBCC                  0x0040
366 #define IEEE80211_CAPINFO_CHNL_AGILITY          0x0080
367 /* bits 8-9 are reserved */
368 #define IEEE80211_CAPINFO_SHORT_SLOTTIME        0x0400
369 #define IEEE80211_CAPINFO_RSN                   0x0800
370 /* bit 12 is reserved */
371 #define IEEE80211_CAPINFO_DSSSOFDM              0x2000
372 /* bits 14-15 are reserved */
373
374 /*
375  * 802.11i/WPA information element (maximally sized).
376  */
377 struct ieee80211_ie_wpa {
378         uint8_t         wpa_id;         /* IEEE80211_ELEMID_VENDOR */
379         uint8_t         wpa_len;        /* length in bytes */
380         uint8_t         wpa_oui[3];     /* 0x00, 0x50, 0xf2 */
381         uint8_t         wpa_type;       /* OUI type */
382         uint16_t        wpa_version;    /* spec revision */
383         uint32_t        wpa_mcipher[1]; /* multicast/group key cipher */
384         uint16_t        wpa_uciphercnt; /* # pairwise key ciphers */
385         uint32_t        wpa_uciphers[8];/* ciphers */
386         uint16_t        wpa_authselcnt; /* authentication selector cnt*/
387         uint32_t        wpa_authsels[8];/* selectors */
388         uint16_t        wpa_caps;       /* 802.11i capabilities */
389         uint16_t        wpa_pmkidcnt;   /* 802.11i pmkid count */
390         uint16_t        wpa_pmkids[8];  /* 802.11i pmkids */
391 } __packed;
392
393 /*
394  * Management information element payloads.
395  */
396
397 enum {
398         IEEE80211_ELEMID_SSID           = 0,
399         IEEE80211_ELEMID_RATES          = 1,
400         IEEE80211_ELEMID_FHPARMS        = 2,
401         IEEE80211_ELEMID_DSPARMS        = 3,
402         IEEE80211_ELEMID_CFPARMS        = 4,
403         IEEE80211_ELEMID_TIM            = 5,
404         IEEE80211_ELEMID_IBSSPARMS      = 6,
405         IEEE80211_ELEMID_COUNTRY        = 7,
406         IEEE80211_ELEMID_CHALLENGE      = 16,
407         /* 17-31 reserved for challenge text extension */
408         IEEE80211_ELEMID_ERP            = 42,
409         IEEE80211_ELEMID_RSN            = 48,
410         IEEE80211_ELEMID_XRATES         = 50,
411         IEEE80211_ELEMID_TPC            = 150,
412         IEEE80211_ELEMID_CCKM           = 156,
413         IEEE80211_ELEMID_VENDOR         = 221,  /* vendor private */
414 };
415
416 struct ieee80211_tim_ie {
417         uint8_t         tim_ie;                 /* IEEE80211_ELEMID_TIM */
418         uint8_t         tim_len;
419         uint8_t         tim_count;              /* DTIM count */
420         uint8_t         tim_period;             /* DTIM period */
421         uint8_t         tim_bitctl;             /* bitmap control */
422         uint8_t         tim_bitmap[1];          /* variable-length bitmap */
423 } __packed;
424
425 struct ieee80211_country_ie {
426         uint8_t         ie;                     /* IEEE80211_ELEMID_COUNTRY */
427         uint8_t         len;
428         uint8_t         cc[3];                  /* ISO CC+(I)ndoor/(O)utdoor */
429         struct {
430                 uint8_t schan;                  /* starting channel */
431                 uint8_t nchan;                  /* number channels */
432                 uint8_t maxtxpwr;               /* tx power cap */
433         } __packed band[4];                     /* up to 4 sub bands */
434 } __packed;
435
436 #define IEEE80211_CHALLENGE_LEN         128
437
438 #define IEEE80211_RATE_BASIC            0x80
439 #define IEEE80211_RATE_VAL              0x7f
440 #define IEEE80211_RS_RATE(rs, idx) \
441         ((rs)->rs_rates[idx] & IEEE80211_RATE_VAL)
442
443 /* EPR information element flags */
444 #define IEEE80211_ERP_NON_ERP_PRESENT   0x01
445 #define IEEE80211_ERP_USE_PROTECTION    0x02
446 #define IEEE80211_ERP_LONG_PREAMBLE     0x04
447
448 /* Atheros private advanced capabilities info */
449 #define ATHEROS_CAP_TURBO_PRIME         0x01
450 #define ATHEROS_CAP_COMPRESSION         0x02
451 #define ATHEROS_CAP_FAST_FRAME          0x04
452 /* bits 3-6 reserved */
453 #define ATHEROS_CAP_BOOST               0x80
454
455 #define ATH_OUI                 0x7f0300                /* Atheros OUI */
456 #define ATH_OUI_TYPE            0x01
457 #define ATH_OUI_VERSION         0x01
458
459 #define WPA_OUI                 0xf25000
460 #define WPA_OUI_TYPE            0x01
461 #define WPA_VERSION             1               /* current supported version */
462
463 #define WPA_CSE_NULL            0x00
464 #define WPA_CSE_WEP40           0x01
465 #define WPA_CSE_TKIP            0x02
466 #define WPA_CSE_CCMP            0x04
467 #define WPA_CSE_WEP104          0x05
468
469 #define WPA_ASE_NONE            0x00
470 #define WPA_ASE_8021X_UNSPEC    0x01
471 #define WPA_ASE_8021X_PSK       0x02
472
473 #define RSN_OUI                 0xac0f00
474 #define RSN_VERSION             1               /* current supported version */
475
476 #define RSN_CSE_NULL            0x00
477 #define RSN_CSE_WEP40           0x01
478 #define RSN_CSE_TKIP            0x02
479 #define RSN_CSE_WRAP            0x03
480 #define RSN_CSE_CCMP            0x04
481 #define RSN_CSE_WEP104          0x05
482
483 #define RSN_ASE_NONE            0x00
484 #define RSN_ASE_8021X_UNSPEC    0x01
485 #define RSN_ASE_8021X_PSK       0x02
486
487 #define RSN_CAP_PREAUTH         0x01
488
489 #define WME_OUI                 0xf25000
490 #define WME_OUI_TYPE            0x02
491 #define WME_INFO_OUI_SUBTYPE    0x00
492 #define WME_PARAM_OUI_SUBTYPE   0x01
493 #define WME_VERSION             1
494
495 /* WME stream classes */
496 #define WME_AC_BE       0               /* best effort */
497 #define WME_AC_BK       1               /* background */
498 #define WME_AC_VI       2               /* video */
499 #define WME_AC_VO       3               /* voice */
500
501 /*
502  * AUTH management packets
503  *
504  *      octet algo[2]
505  *      octet seq[2]
506  *      octet status[2]
507  *      octet chal.id
508  *      octet chal.length
509  *      octet chal.text[253]
510  */
511
512 typedef uint8_t *ieee80211_mgt_auth_t;
513
514 #define IEEE80211_AUTH_ALGORITHM(auth) \
515         ((auth)[0] | ((auth)[1] << 8))
516 #define IEEE80211_AUTH_TRANSACTION(auth) \
517         ((auth)[2] | ((auth)[3] << 8))
518 #define IEEE80211_AUTH_STATUS(auth) \
519         ((auth)[4] | ((auth)[5] << 8))
520
521 #define IEEE80211_AUTH_ALG_OPEN         0x0000
522 #define IEEE80211_AUTH_ALG_SHARED       0x0001
523 #define IEEE80211_AUTH_ALG_LEAP         0x0080
524
525 enum {
526         IEEE80211_AUTH_OPEN_REQUEST             = 1,
527         IEEE80211_AUTH_OPEN_RESPONSE            = 2,
528 };
529
530 enum {
531         IEEE80211_AUTH_SHARED_REQUEST           = 1,
532         IEEE80211_AUTH_SHARED_CHALLENGE         = 2,
533         IEEE80211_AUTH_SHARED_RESPONSE          = 3,
534         IEEE80211_AUTH_SHARED_PASS              = 4,
535 };
536
537 /*
538  * Reason codes
539  *
540  * Unlisted codes are reserved
541  */
542
543 enum {
544         IEEE80211_REASON_UNSPECIFIED            = 1,
545         IEEE80211_REASON_AUTH_EXPIRE            = 2,
546         IEEE80211_REASON_AUTH_LEAVE             = 3,
547         IEEE80211_REASON_ASSOC_EXPIRE           = 4,
548         IEEE80211_REASON_ASSOC_TOOMANY          = 5,
549         IEEE80211_REASON_NOT_AUTHED             = 6,
550         IEEE80211_REASON_NOT_ASSOCED            = 7,
551         IEEE80211_REASON_ASSOC_LEAVE            = 8,
552         IEEE80211_REASON_ASSOC_NOT_AUTHED       = 9,
553
554         IEEE80211_REASON_RSN_REQUIRED           = 11,
555         IEEE80211_REASON_RSN_INCONSISTENT       = 12,
556         IEEE80211_REASON_IE_INVALID             = 13,
557         IEEE80211_REASON_MIC_FAILURE            = 14,
558
559         IEEE80211_STATUS_SUCCESS                = 0,
560         IEEE80211_STATUS_UNSPECIFIED            = 1,
561         IEEE80211_STATUS_CAPINFO                = 10,
562         IEEE80211_STATUS_NOT_ASSOCED            = 11,
563         IEEE80211_STATUS_OTHER                  = 12,
564         IEEE80211_STATUS_ALG                    = 13,
565         IEEE80211_STATUS_SEQUENCE               = 14,
566         IEEE80211_STATUS_CHALLENGE              = 15,
567         IEEE80211_STATUS_TIMEOUT                = 16,
568         IEEE80211_STATUS_TOOMANY                = 17,
569         IEEE80211_STATUS_BASIC_RATE             = 18,
570         IEEE80211_STATUS_SP_REQUIRED            = 19,
571         IEEE80211_STATUS_PBCC_REQUIRED          = 20,
572         IEEE80211_STATUS_CA_REQUIRED            = 21,
573         IEEE80211_STATUS_TOO_MANY_STATIONS      = 22,
574         IEEE80211_STATUS_RATES                  = 23,
575         IEEE80211_STATUS_SHORTSLOT_REQUIRED     = 25,
576         IEEE80211_STATUS_DSSSOFDM_REQUIRED      = 26,
577 };
578
579 #define IEEE80211_WEP_KEYLEN            5       /* 40bit */
580 #define IEEE80211_WEP_IVLEN             3       /* 24bit */
581 #define IEEE80211_WEP_KIDLEN            1       /* 1 octet */
582 #define IEEE80211_WEP_CRCLEN            4       /* CRC-32 */
583 #define IEEE80211_WEP_NKID              4       /* number of key ids */
584
585 /*
586  * 802.11i defines an extended IV for use with non-WEP ciphers.
587  * When the EXTIV bit is set in the key id byte an additional
588  * 4 bytes immediately follow the IV for TKIP.  For CCMP the
589  * EXTIV bit is likewise set but the 8 bytes represent the
590  * CCMP header rather than IV+extended-IV.
591  */
592 #define IEEE80211_WEP_EXTIV             0x20
593 #define IEEE80211_WEP_EXTIVLEN          4       /* extended IV length */
594 #define IEEE80211_WEP_MICLEN            8       /* trailing MIC */
595
596 #define IEEE80211_CRC_LEN               4
597
598 /*
599  * Maximum acceptable MTU is:
600  *      IEEE80211_MAX_LEN - WEP overhead - CRC -
601  *              QoS overhead - RSN/WPA overhead
602  * Min is arbitrarily chosen > IEEE80211_MIN_LEN.  The default
603  * mtu is Ethernet-compatible; it's set by ether_ifattach.
604  */
605 #define IEEE80211_MTU_MAX               2290
606 #define IEEE80211_MTU_MIN               32
607
608 #define IEEE80211_MAX_LEN               (2300 + IEEE80211_CRC_LEN + \
609     (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
610 #define IEEE80211_ACK_LEN \
611         (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
612 #define IEEE80211_MIN_LEN \
613         (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
614
615 /*
616  * The 802.11 spec says at most 2007 stations may be
617  * associated at once.  For most AP's this is way more
618  * than is feasible so we use a default of 128.  This
619  * number may be overridden by the driver and/or by
620  * user configuration.
621  */
622 #define IEEE80211_AID_MAX               2007
623 #define IEEE80211_AID_DEF               128
624
625 #define IEEE80211_AID(b)        ((b) &~ 0xc000)
626
627 /* 
628  * RTS frame length parameters.  The default is specified in
629  * the 802.11 spec as 512; we treat it as implementation-dependent
630  * so it's defined in ieee80211_var.h.  The max may be wrong
631  * for jumbo frames.
632  */
633 #define IEEE80211_RTS_MIN               1
634 #define IEEE80211_RTS_MAX               2346
635
636 /* 
637  * TX fragmentation parameters.  As above for RTS, we treat
638  * default as implementation-dependent so define it elsewhere.
639  */
640 #define IEEE80211_FRAG_MIN              256
641 #define IEEE80211_FRAG_MAX              2346
642
643 /*
644  * Beacon interval (TU's).  Min+max come from WiFi requirements.
645  * As above, we treat default as implementation-dependent so
646  * define it elsewhere.
647  */
648 #define IEEE80211_BINTVAL_MAX   1000    /* max beacon interval (TU's) */
649 #define IEEE80211_BINTVAL_MIN   25      /* min beacon interval (TU's) */
650
651 /*
652  * DTIM period (beacons).  Min+max are not really defined
653  * by the protocol but we want them publicly visible so
654  * define them here.
655  */
656 #define IEEE80211_DTIM_MAX      15      /* max DTIM period */
657 #define IEEE80211_DTIM_MIN      1       /* min DTIM period */
658
659 /*
660  * Beacon miss threshold (beacons).  As for DTIM, we define
661  * them here to be publicly visible.  Note the max may be
662  * clamped depending on device capabilities.
663  */
664 #define IEEE80211_HWBMISS_MIN   1
665 #define IEEE80211_HWBMISS_MAX   255
666
667 /*
668  * Contention window (slots).
669  */
670 #define IEEE80211_CW_MAX        1023    /* aCWmax */
671 #define IEEE80211_CW_MIN_0      31      /* DS/CCK aCWmin, ERP aCWmin(0) */
672 #define IEEE80211_CW_MIN_1      15      /* OFDM aCWmin, ERP aCWmin(1) */
673
674 /*
675  * SIFS (microseconds).
676  */
677 #define IEEE80211_DUR_SIFS      10      /* DS/CCK/ERP SIFS */
678 #define IEEE80211_DUR_OFDM_SIFS 16      /* OFDM SIFS */
679
680 /*
681  * Slot time (microseconds).
682  */
683 #define IEEE80211_DUR_SLOT      20      /* DS/CCK slottime, ERP long slottime */
684 #define IEEE80211_DUR_SHSLOT    9       /* ERP short slottime */
685 #define IEEE80211_DUR_OFDM_SLOT 9       /* OFDM slottime */
686
687 /*
688  * DIFS (microseconds).
689  */
690 #define IEEE80211_DUR_DIFS(sifs, slot)  ((sifs) + 2 * (slot))
691
692 #define IEEE80211_MGT_SUBTYPE_NAMES {                   \
693         "assoc-req",            "assoc-resp",           \
694         "reassoc-req",          "reassoc-resp",         \
695         "probe-req",            "probe-resp",           \
696         "reserved#6",           "reserved#7",           \
697         "beacon",               "atim",                 \
698         "disassoc",             "auth",                 \
699         "deauth",               "reserved#13",          \
700         "reserved#14",          "reserved#15"           \
701 }
702
703 #define IEEE80211_CTL_SUBTYPE_NAMES {                   \
704         "reserved#0",           "reserved#1",           \
705         "reserved#2",           "reserved#3",           \
706         "reserved#3",           "reserved#5",           \
707         "reserved#6",           "reserved#7",           \
708         "reserved#8",           "reserved#9",           \
709         "ps-poll",              "rts",                  \
710         "cts",                  "ack",                  \
711         "cf-end",               "cf-end-ack"            \
712 }
713
714 #define IEEE80211_DATA_SUBTYPE_NAMES {                  \
715         "data",                 "data-cf-ack",          \
716         "data-cf-poll",         "data-cf-ack-poll",     \
717         "null",                 "cf-ack",               \
718         "cf-poll",              "cf-ack-poll",          \
719         "qos-data",             "qos-data-cf-ack",      \
720         "qos-data-cf-poll",     "qos-data-cf-ack-poll", \
721         "qos",                  "reserved#13",          \
722         "qos-cf-poll",          "qos-cf-ack-poll"       \
723 }
724
725 #define IEEE80211_TYPE_NAMES    { "mgt", "ctl", "data", "reserved#4" }
726
727 #endif /* _NET80211_IEEE80211_H_ */