mxs: enable uboot-mxs-duckbill build for duckbill profile
[15.05/openwrt.git] / package / network / services / hostapd / madwifi / net80211 / 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  * $Id: ieee80211.h 3268 2008-01-26 20:48:11Z mtaylor $
33  */
34 #ifndef _NET80211_IEEE80211_H_
35 #define _NET80211_IEEE80211_H_
36
37 /*
38  * 802.11 protocol definitions.
39  */
40
41 #define IEEE80211_ADDR_LEN              6               /* size of 802.11 address */
42 /* is 802.11 address multicast/broadcast? */
43 #define IEEE80211_IS_MULTICAST(_a)      (*(_a) & 0x01)
44
45 /* IEEE 802.11 PLCP header */
46 struct ieee80211_plcp_hdr {
47         u_int16_t i_sfd;
48         u_int8_t i_signal;
49         u_int8_t i_service;
50         u_int16_t i_length;
51         u_int16_t i_crc;
52 } __packed;
53
54 #define IEEE80211_PLCP_SFD      0xF3A0
55 #define IEEE80211_PLCP_SERVICE  0x00
56
57 /*
58  * generic definitions for IEEE 802.11 frames
59  */
60 struct ieee80211_frame {
61         u_int8_t i_fc[2];
62         __le16 i_dur;
63         u_int8_t i_addr1[IEEE80211_ADDR_LEN];
64         u_int8_t i_addr2[IEEE80211_ADDR_LEN];
65         u_int8_t i_addr3[IEEE80211_ADDR_LEN];
66         u_int8_t i_seq[2];
67         /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
68         /* see below */
69 } __packed;
70
71 struct ieee80211_qosframe {
72         u_int8_t i_fc[2];
73         __le16 i_dur;
74         u_int8_t i_addr1[IEEE80211_ADDR_LEN];
75         u_int8_t i_addr2[IEEE80211_ADDR_LEN];
76         u_int8_t i_addr3[IEEE80211_ADDR_LEN];
77         u_int8_t i_seq[2];
78         u_int8_t i_qos[2];
79         /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
80         /* see below */
81 } __packed;
82
83 struct ieee80211_qoscntl {
84         u_int8_t i_qos[2];
85 };
86
87 struct ieee80211_frame_addr4 {
88         u_int8_t i_fc[2];
89         __le16 i_dur;
90         u_int8_t i_addr1[IEEE80211_ADDR_LEN];
91         u_int8_t i_addr2[IEEE80211_ADDR_LEN];
92         u_int8_t i_addr3[IEEE80211_ADDR_LEN];
93         u_int8_t i_seq[2];
94         u_int8_t i_addr4[IEEE80211_ADDR_LEN];
95 } __packed;
96
97
98 struct ieee80211_qosframe_addr4 {
99         u_int8_t i_fc[2];
100         __le16 i_dur;
101         u_int8_t i_addr1[IEEE80211_ADDR_LEN];
102         u_int8_t i_addr2[IEEE80211_ADDR_LEN];
103         u_int8_t i_addr3[IEEE80211_ADDR_LEN];
104         u_int8_t i_seq[2];
105         u_int8_t i_addr4[IEEE80211_ADDR_LEN];
106         u_int8_t i_qos[2];
107 } __packed;
108
109 struct ieee80211_ctlframe_addr2 {
110         u_int8_t i_fc[2];
111         __le16 i_aidordur; /* AID or duration */
112         u_int8_t i_addr1[IEEE80211_ADDR_LEN];
113         u_int8_t i_addr2[IEEE80211_ADDR_LEN];
114 } __packed;
115
116 #define IEEE80211_FC0_VERSION_MASK              0x03
117 #define IEEE80211_FC0_VERSION_SHIFT             0
118 #define IEEE80211_FC0_VERSION_0                 0x00
119 #define IEEE80211_FC0_TYPE_MASK                 0x0c
120 #define IEEE80211_FC0_TYPE_SHIFT                2
121 #define IEEE80211_FC0_TYPE_MGT                  0x00
122 #define IEEE80211_FC0_TYPE_CTL                  0x04
123 #define IEEE80211_FC0_TYPE_DATA                 0x08
124
125 #define IEEE80211_FC0_SUBTYPE_MASK              0xf0
126 #define IEEE80211_FC0_SUBTYPE_SHIFT             4
127 /* for TYPE_MGT */
128 #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ         0x00
129 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP        0x10
130 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ       0x20
131 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP      0x30
132 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ         0x40
133 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP        0x50
134 #define IEEE80211_FC0_SUBTYPE_BEACON            0x80
135 #define IEEE80211_FC0_SUBTYPE_ATIM              0x90
136 #define IEEE80211_FC0_SUBTYPE_DISASSOC          0xa0
137 #define IEEE80211_FC0_SUBTYPE_AUTH              0xb0
138 #define IEEE80211_FC0_SUBTYPE_DEAUTH            0xc0
139 #define IEEE80211_FC0_SUBTYPE_ACTION            0xd0
140 /* for TYPE_CTL */
141 #define IEEE80211_FC0_SUBTYPE_PS_POLL           0xa0
142 #define IEEE80211_FC0_SUBTYPE_RTS               0xb0
143 #define IEEE80211_FC0_SUBTYPE_CTS               0xc0
144 #define IEEE80211_FC0_SUBTYPE_ACK               0xd0
145 #define IEEE80211_FC0_SUBTYPE_CF_END            0xe0
146 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK        0xf0
147 /* for TYPE_DATA (bit combination) */
148 #define IEEE80211_FC0_SUBTYPE_DATA              0x00
149 #define IEEE80211_FC0_SUBTYPE_CF_ACK            0x10
150 #define IEEE80211_FC0_SUBTYPE_CF_POLL           0x20
151 #define IEEE80211_FC0_SUBTYPE_CF_ACPL           0x30
152 #define IEEE80211_FC0_SUBTYPE_NODATA            0x40
153 #define IEEE80211_FC0_SUBTYPE_CFACK             0x50
154 #define IEEE80211_FC0_SUBTYPE_CFPOLL            0x60
155 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK     0x70
156 #define IEEE80211_FC0_SUBTYPE_QOS               0x80
157 #define IEEE80211_FC0_SUBTYPE_QOS_NULL          0xc0
158
159 #define IEEE80211_FC1_DIR_MASK                  0x03
160 #define IEEE80211_FC1_DIR_NODS                  0x00    /* STA->STA */
161 #define IEEE80211_FC1_DIR_TODS                  0x01    /* STA->AP  */
162 #define IEEE80211_FC1_DIR_FROMDS                0x02    /* AP ->STA */
163 #define IEEE80211_FC1_DIR_DSTODS                0x03    /* AP ->AP  */
164
165 #define IEEE80211_FC1_MORE_FRAG                 0x04
166 #define IEEE80211_FC1_RETRY                     0x08
167 #define IEEE80211_FC1_PWR_MGT                   0x10
168 #define IEEE80211_FC1_MORE_DATA                 0x20
169 #define IEEE80211_FC1_PROT                      0x40
170 #define IEEE80211_FC1_ORDER                     0x80
171
172 #define IEEE80211_SEQ_FRAG_MASK                 0x000f
173 #define IEEE80211_SEQ_FRAG_SHIFT                0
174 #define IEEE80211_SEQ_SEQ_MASK                  0xfff0
175 #define IEEE80211_SEQ_SEQ_SHIFT                 4
176
177 #define IEEE80211_NWID_LEN                      32
178
179 #define IEEE80211_QOS_TXOP                      0x00ff
180 /* bit 8 is reserved */
181 #define IEEE80211_QOS_ACKPOLICY                 0x60
182 #define IEEE80211_QOS_ACKPOLICY_S               5
183 #define IEEE80211_QOS_EOSP                      0x10
184 #define IEEE80211_QOS_EOSP_S                    4
185 #define IEEE80211_QOS_TID                       0x0f
186
187 #define IEEE80211_FRM_HAS_BODY(_wh)                     \
188         (((_wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=  \
189                         IEEE80211_FC0_TYPE_CTL)
190
191 /*
192  * Country/Region Codes from MS WINNLS.H
193  * Numbering from ISO 3166
194  * XXX belongs elsewhere
195  */
196 enum CountryCode {
197         CTRY_ALBANIA              = 8,       /* Albania */
198         CTRY_ALGERIA              = 12,      /* Algeria */
199         CTRY_ARGENTINA            = 32,      /* Argentina */
200         CTRY_ARMENIA              = 51,      /* Armenia */
201         CTRY_AUSTRALIA            = 36,      /* Australia */
202         CTRY_AUSTRIA              = 40,      /* Austria */
203         CTRY_AZERBAIJAN           = 31,      /* Azerbaijan */
204         CTRY_BAHRAIN              = 48,      /* Bahrain */
205         CTRY_BELARUS              = 112,     /* Belarus */
206         CTRY_BELGIUM              = 56,      /* Belgium */
207         CTRY_BELIZE               = 84,      /* Belize */
208         CTRY_BOLIVIA              = 68,      /* Bolivia */
209         CTRY_BRAZIL               = 76,      /* Brazil */
210         CTRY_BRUNEI_DARUSSALAM    = 96,      /* Brunei Darussalam */
211         CTRY_BULGARIA             = 100,     /* Bulgaria */
212         CTRY_CANADA               = 124,     /* Canada */
213         CTRY_CHILE                = 152,     /* Chile */
214         CTRY_CHINA                = 156,     /* People's Republic of China */
215         CTRY_COLOMBIA             = 170,     /* Colombia */
216         CTRY_COSTA_RICA           = 188,     /* Costa Rica */
217         CTRY_CROATIA              = 191,     /* Croatia */
218         CTRY_CYPRUS               = 196,
219         CTRY_CZECH                = 203,     /* Czech Republic */
220         CTRY_DENMARK              = 208,     /* Denmark */
221         CTRY_DOMINICAN_REPUBLIC   = 214,     /* Dominican Republic */
222         CTRY_ECUADOR              = 218,     /* Ecuador */
223         CTRY_EGYPT                = 818,     /* Egypt */
224         CTRY_EL_SALVADOR          = 222,     /* El Salvador */
225         CTRY_ESTONIA              = 233,     /* Estonia */
226         CTRY_FAEROE_ISLANDS       = 234,     /* Faeroe Islands */
227         CTRY_FINLAND              = 246,     /* Finland */
228         CTRY_FRANCE               = 250,     /* France */
229         CTRY_FRANCE2              = 255,     /* France2 */
230         CTRY_GEORGIA              = 268,     /* Georgia */
231         CTRY_GERMANY              = 276,     /* Germany */
232         CTRY_GREECE               = 300,     /* Greece */
233         CTRY_GUATEMALA            = 320,     /* Guatemala */
234         CTRY_HONDURAS             = 340,     /* Honduras */
235         CTRY_HONG_KONG            = 344,     /* Hong Kong S.A.R., P.R.C. */
236         CTRY_HUNGARY              = 348,     /* Hungary */
237         CTRY_ICELAND              = 352,     /* Iceland */
238         CTRY_INDIA                = 356,     /* India */
239         CTRY_INDONESIA            = 360,     /* Indonesia */
240         CTRY_IRAN                 = 364,     /* Iran */
241         CTRY_IRAQ                 = 368,     /* Iraq */
242         CTRY_IRELAND              = 372,     /* Ireland */
243         CTRY_ISRAEL               = 376,     /* Israel */
244         CTRY_ITALY                = 380,     /* Italy */
245         CTRY_JAMAICA              = 388,     /* Jamaica */
246         CTRY_JAPAN                = 392,     /* Japan */
247         CTRY_JAPAN1               = 393,     /* Japan (JP1) */
248         CTRY_JAPAN2               = 394,     /* Japan (JP0) */
249         CTRY_JAPAN3               = 395,     /* Japan (JP1-1) */
250         CTRY_JAPAN4               = 396,     /* Japan (JE1) */
251         CTRY_JAPAN5               = 397,     /* Japan (JE2) */
252         CTRY_JAPAN6               = 399,         /* Japan (JP6) */
253         CTRY_JAPAN7               = 900,         /* Japan */
254         CTRY_JAPAN8               = 901,         /* Japan */
255         CTRY_JAPAN9               = 902,         /* Japan */
256         CTRY_JAPAN10          = 903,     /* Japan */
257         CTRY_JAPAN11          = 904,     /* Japan */
258         CTRY_JAPAN12          = 905,     /* Japan */
259         CTRY_JAPAN13          = 906,     /* Japan */
260         CTRY_JAPAN14          = 907,     /* Japan */
261         CTRY_JAPAN15          = 908,     /* Japan */
262         CTRY_JAPAN16          = 909,     /* Japan */
263         CTRY_JAPAN17          = 910,     /* Japan */
264         CTRY_JAPAN18          = 911,     /* Japan */
265         CTRY_JAPAN19          = 912,     /* Japan */
266         CTRY_JAPAN20          = 913,     /* Japan */
267         CTRY_JAPAN21          = 914,     /* Japan */
268         CTRY_JAPAN22          = 915,     /* Japan */
269         CTRY_JAPAN23          = 916,     /* Japan */
270         CTRY_JAPAN24          = 917,     /* Japan */
271         CTRY_JAPAN25          = 918,     /* Japan */
272         CTRY_JAPAN26          = 919,     /* Japan */
273         CTRY_JAPAN27          = 920,     /* Japan */
274         CTRY_JAPAN28          = 921,     /* Japan */
275         CTRY_JAPAN29          = 922,     /* Japan */
276         CTRY_JAPAN30          = 923,     /* Japan */
277         CTRY_JAPAN31          = 924,     /* Japan */
278         CTRY_JAPAN32          = 925,     /* Japan */
279         CTRY_JAPAN33          = 926,     /* Japan */
280         CTRY_JAPAN34          = 927,     /* Japan */
281         CTRY_JAPAN35          = 928,     /* Japan */
282         CTRY_JAPAN36          = 929,     /* Japan */
283         CTRY_JAPAN37          = 930,     /* Japan */
284         CTRY_JAPAN38          = 931,     /* Japan */
285         CTRY_JAPAN39          = 932,     /* Japan */
286         CTRY_JAPAN40          = 933,     /* Japan */
287         CTRY_JAPAN41          = 934,     /* Japan */
288         CTRY_JAPAN42          = 935,     /* Japan */
289         CTRY_JAPAN43          = 936,     /* Japan */
290         CTRY_JAPAN44          = 937,     /* Japan */
291         CTRY_JAPAN45          = 938,     /* Japan */
292         CTRY_JAPAN46          = 939,     /* Japan */
293         CTRY_JAPAN47          = 940,     /* Japan */
294         CTRY_JAPAN48          = 941,     /* Japan */
295         CTRY_JORDAN               = 400,     /* Jordan */
296         CTRY_KAZAKHSTAN           = 398,     /* Kazakhstan */
297         CTRY_KENYA                = 404,     /* Kenya */
298         CTRY_KOREA_NORTH          = 408,     /* North Korea */
299         CTRY_KOREA_ROC            = 410,     /* South Korea */
300         CTRY_KOREA_ROC2           = 411,     /* South Korea */
301         CTRY_KUWAIT               = 414,     /* Kuwait */
302         CTRY_LATVIA               = 428,     /* Latvia */
303         CTRY_LEBANON              = 422,     /* Lebanon */
304         CTRY_LIBYA                = 434,     /* Libya */
305         CTRY_LIECHTENSTEIN        = 438,     /* Liechtenstein */
306         CTRY_LITHUANIA            = 440,     /* Lithuania */
307         CTRY_LUXEMBOURG           = 442,     /* Luxembourg */
308         CTRY_MACAU                = 446,     /* Macau */
309         CTRY_MACEDONIA            = 807,     /* the Former Yugoslav Republic of Macedonia */
310         CTRY_MALAYSIA             = 458,     /* Malaysia */
311         CTRY_MEXICO               = 484,     /* Mexico */
312         CTRY_MONACO               = 492,     /* Principality of Monaco */
313         CTRY_MOROCCO              = 504,     /* Morocco */
314         CTRY_NETHERLANDS          = 528,     /* Netherlands */
315         CTRY_NEW_ZEALAND          = 554,     /* New Zealand */
316         CTRY_NICARAGUA            = 558,     /* Nicaragua */
317         CTRY_NORWAY               = 578,     /* Norway */
318         CTRY_OMAN                 = 512,     /* Oman */
319         CTRY_PAKISTAN             = 586,     /* Islamic Republic of Pakistan */
320         CTRY_PANAMA               = 591,     /* Panama */
321         CTRY_PARAGUAY             = 600,     /* Paraguay */
322         CTRY_PERU                 = 604,     /* Peru */
323         CTRY_PHILIPPINES          = 608,     /* Republic of the Philippines */
324         CTRY_POLAND               = 616,     /* Poland */
325         CTRY_PORTUGAL             = 620,     /* Portugal */
326         CTRY_PUERTO_RICO          = 630,     /* Puerto Rico */
327         CTRY_QATAR                = 634,     /* Qatar */
328         CTRY_ROMANIA              = 642,     /* Romania */
329         CTRY_RUSSIA               = 643,     /* Russia */
330         CTRY_SAUDI_ARABIA         = 682,     /* Saudi Arabia */
331         CTRY_SINGAPORE            = 702,     /* Singapore */
332         CTRY_SLOVAKIA             = 703,     /* Slovak Republic */
333         CTRY_SLOVENIA             = 705,     /* Slovenia */
334         CTRY_SOUTH_AFRICA         = 710,     /* South Africa */
335         CTRY_SPAIN                = 724,     /* Spain */
336         CTRY_SWEDEN               = 752,     /* Sweden */
337         CTRY_SWITZERLAND          = 756,     /* Switzerland */
338         CTRY_SYRIA                = 760,     /* Syria */
339         CTRY_TAIWAN               = 158,     /* Taiwan */
340         CTRY_THAILAND             = 764,     /* Thailand */
341         CTRY_TRINIDAD_Y_TOBAGO    = 780,     /* Trinidad y Tobago */
342         CTRY_TUNISIA              = 788,     /* Tunisia */
343         CTRY_TURKEY               = 792,     /* Turkey */
344         CTRY_UAE                  = 784,     /* U.A.E. */
345         CTRY_UKRAINE              = 804,     /* Ukraine */
346         CTRY_UNITED_KINGDOM       = 826,     /* United Kingdom */
347         CTRY_UNITED_STATES        = 840,     /* United States */
348         CTRY_UNITED_STATES_FCC49  = 842,     /* United States (Public Safety)*/
349         CTRY_URUGUAY              = 858,     /* Uruguay */
350         CTRY_UZBEKISTAN           = 860,     /* Uzbekistan */
351         CTRY_VENEZUELA            = 862,     /* Venezuela */
352         CTRY_VIET_NAM             = 704,     /* Viet Nam */
353         CTRY_YEMEN                = 887,     /* Yemen */
354         CTRY_ZIMBABWE             = 716      /* Zimbabwe */
355 };
356
357 /* 
358  * Generic information element
359  */
360 struct ieee80211_ie {
361         u_int8_t id;
362         u_int8_t len;
363         u_int8_t info[0];
364 } __packed;
365
366 /* 
367  * Country information element.
368  */
369 #define IEEE80211_COUNTRY_MAX_TRIPLETS (83)
370 struct ieee80211_ie_country {
371         u_int8_t country_id;
372         u_int8_t country_len;
373         u_int8_t country_str[3];
374         u_int8_t country_triplet[IEEE80211_COUNTRY_MAX_TRIPLETS * 3];
375 } __packed;
376
377 /*
378  * Power Constraint information element.
379  */
380 struct ieee80211_ie_pwrcnstr {
381         u_int8_t pc_id;                 /* IEEE80211_ELEMID_PWRCNSTR */
382         u_int8_t pc_len;                /* == 2 */
383         u_int8_t pc_lpc;                /* Local Power Constraint [dB] */
384 } __packed;
385
386 /*
387  * Power Capability information element.
388  */
389 struct ieee80211_ie_pwrcap {
390         u_int8_t pc_id;                 /* IEEE80211_ELEMID_PWRCAP */
391         u_int8_t pc_len;                /* == 2 */
392         int8_t pc_mintxpow;             /* Minimum Transmit Power Capability [dBm] */
393         int8_t pc_maxtxpow;             /* Maximum Transmit Power Capability [dBm] */
394 } __packed;
395
396 /*
397  * Supported Channels information element.
398  */
399 #define IEEE80211_SUPPCHAN_MAX_PAIRS (127)
400 struct ieee80211_ie_sc {
401         u_int8_t sc_id;                 /* IEEE80211_ELEMID_SUPPCHAN */
402         u_int8_t sc_len;                /* == 2 * number of sc_subband elements */
403         struct {
404                 u_int8_t sc_first;      /* First Channel Number */
405                 u_int8_t sc_number;     /* Number of Channels */
406         } __packed sc_subband[IEEE80211_SUPPCHAN_MAX_PAIRS];
407 } __packed;
408
409 /*
410  * Channel Switch Announcement information element.
411  */
412 struct ieee80211_ie_csa {
413         u_int8_t csa_id;        /* IEEE80211_ELEMID_CHANSWITCHANN */
414         u_int8_t csa_len;       /* == 3 */
415         u_int8_t csa_mode;      /* Channel Switch Mode: 1 == stop transmission until CS */
416         u_int8_t csa_chan;      /* New Channel Number */
417         u_int8_t csa_count;     /* TBTTs until Channel Switch happens */
418 } __packed;
419
420 /* minimal Channel Switch Count in the initial announcement */
421 #define IEEE80211_CSA_PROTECTION_PERIOD 3
422
423 /* maximum allowed deviance of measurement of intervals between CSA in Beacons */
424 #define IEEE80211_CSA_SANITY_THRESHOLD 100
425
426
427 /* does frame have QoS sequence control data */
428 #define IEEE80211_QOS_HAS_SEQ(wh) \
429         (((wh)->i_fc[0] & \
430           (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \
431           (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
432
433 #define WME_QOSINFO_COUNT       0x0f  /* Mask for Param Set Count field */
434 /*
435  * WME/802.11e information element.
436  */
437 struct ieee80211_ie_wme {
438         u_int8_t wme_id;                /* IEEE80211_ELEMID_VENDOR */
439         u_int8_t wme_len;       /* length in bytes */
440         u_int8_t wme_oui[3];    /* 0x00, 0x50, 0xf2 */
441         u_int8_t wme_type;      /* OUI type */
442         u_int8_t wme_subtype;   /* OUI subtype */
443         u_int8_t wme_version;   /* spec revision */
444         u_int8_t wme_info;      /* QoS info */
445 } __packed;
446
447 /*
448  * WME/802.11e Tspec Element
449  */
450 struct ieee80211_wme_tspec {
451         u_int8_t ts_id;
452         u_int8_t ts_len;
453         u_int8_t ts_oui[3];
454         u_int8_t ts_oui_type;
455         u_int8_t ts_oui_subtype;
456         u_int8_t ts_version;
457         u_int8_t ts_tsinfo[3];
458         u_int8_t ts_nom_msdu[2];
459         u_int8_t ts_max_msdu[2];
460         u_int8_t ts_min_svc[4];
461         u_int8_t ts_max_svc[4];
462         u_int8_t ts_inactv_intv[4];
463         u_int8_t ts_susp_intv[4];
464         u_int8_t ts_start_svc[4];
465         u_int8_t ts_min_rate[4];
466         u_int8_t ts_mean_rate[4];
467         u_int8_t ts_max_burst[4];
468         u_int8_t ts_min_phy[4];
469         u_int8_t ts_peak_rate[4];
470         u_int8_t ts_delay[4];
471         u_int8_t ts_surplus[2];
472         u_int8_t ts_medium_time[2];
473 } __packed;
474
475 /*
476  * WME AC parameter field
477  */
478
479 struct ieee80211_wme_acparams {
480         u_int8_t acp_aci_aifsn;
481         u_int8_t acp_logcwminmax;
482         u_int16_t acp_txop;
483 } __packed;
484
485 #define IEEE80211_WME_PARAM_LEN 24
486 #define WME_NUM_AC              4       /* 4 AC categories */
487
488 #define WME_PARAM_ACI           0x60    /* Mask for ACI field */
489 #define WME_PARAM_ACI_S         5       /* Shift for ACI field */
490 #define WME_PARAM_ACM           0x10    /* Mask for ACM bit */
491 #define WME_PARAM_ACM_S         4       /* Shift for ACM bit */
492 #define WME_PARAM_AIFSN         0x0f    /* Mask for aifsn field */
493 #define WME_PARAM_AIFSN_S       0       /* Shift for aifsn field */
494 #define WME_PARAM_LOGCWMIN      0x0f    /* Mask for CwMin field (in log) */
495 #define WME_PARAM_LOGCWMIN_S    0       /* Shift for CwMin field */
496 #define WME_PARAM_LOGCWMAX      0xf0    /* Mask for CwMax field (in log) */
497 #define WME_PARAM_LOGCWMAX_S    4       /* Shift for CwMax field */
498
499 #define WME_AC_TO_TID(_ac) (       \
500         ((_ac) == WME_AC_VO) ? 6 : \
501         ((_ac) == WME_AC_VI) ? 5 : \
502         ((_ac) == WME_AC_BK) ? 1 : \
503         0)
504
505 #define TID_TO_WME_AC(_tid) (      \
506         ((_tid) < 1) ? WME_AC_BE : \
507         ((_tid) < 3) ? WME_AC_BK : \
508         ((_tid) < 6) ? WME_AC_VI : \
509         WME_AC_VO)
510
511 /*
512  * WME Parameter Element
513  */
514
515 struct ieee80211_wme_param {
516         u_int8_t param_id;
517         u_int8_t param_len;
518         u_int8_t param_oui[3];
519         u_int8_t param_oui_type;
520         u_int8_t param_oui_sybtype;
521         u_int8_t param_version;
522         u_int8_t param_qosInfo;
523         u_int8_t param_reserved;
524         struct ieee80211_wme_acparams   params_acParams[WME_NUM_AC];
525 } __packed;
526
527 /*
528  * WME U-APSD qos info field defines
529  */
530 #define WME_CAPINFO_UAPSD_EN                    0x00000080
531 #define WME_CAPINFO_UAPSD_VO                    0x00000001
532 #define WME_CAPINFO_UAPSD_VI                    0x00000002
533 #define WME_CAPINFO_UAPSD_BK                    0x00000004
534 #define WME_CAPINFO_UAPSD_BE                    0x00000008
535 #define WME_CAPINFO_UAPSD_ACFLAGS_SHIFT         0
536 #define WME_CAPINFO_UAPSD_ACFLAGS_MASK          0xF
537 #define WME_CAPINFO_UAPSD_MAXSP_SHIFT           5
538 #define WME_CAPINFO_UAPSD_MAXSP_MASK            0x3
539 #define WME_CAPINFO_IE_OFFSET                   8
540 #define WME_UAPSD_MAXSP(_qosinfo)                                       \
541                 (((_qosinfo) >> WME_CAPINFO_UAPSD_MAXSP_SHIFT) &        \
542                  WME_CAPINFO_UAPSD_MAXSP_MASK)
543 #define WME_UAPSD_AC_ENABLED(_ac, _qosinfo)                             \
544                 ((1 << (3 - (_ac))) & (                                 \
545                  ((_qosinfo) >> WME_CAPINFO_UAPSD_ACFLAGS_SHIFT) &      \
546                  WME_CAPINFO_UAPSD_ACFLAGS_MASK))
547
548 /*
549  * Atheros Advanced Capability information element.
550  */
551 struct ieee80211_ie_athAdvCap {
552         u_int8_t athAdvCap_id;          /* IEEE80211_ELEMID_VENDOR */
553         u_int8_t athAdvCap_len;         /* length in bytes */
554         u_int8_t athAdvCap_oui[3];      /* 0x00, 0x03, 0x7f */
555         u_int8_t athAdvCap_type;        /* OUI type */
556         u_int8_t athAdvCap_subtype;     /* OUI subtype */
557         u_int8_t athAdvCap_version;     /* spec revision */
558         u_int8_t athAdvCap_capability;  /* Capability info */
559         u_int16_t athAdvCap_defKeyIndex;
560 } __packed;
561
562 /*
563  * Atheros XR information element.
564  */
565 struct ieee80211_xr_param {
566         u_int8_t param_id;
567         u_int8_t param_len;
568         u_int8_t param_oui[3];
569         u_int8_t param_oui_type;
570         u_int8_t param_oui_sybtype;
571         u_int8_t param_version;
572         u_int8_t param_Info;
573         u_int8_t param_base_bssid[IEEE80211_ADDR_LEN];
574         u_int8_t param_xr_bssid[IEEE80211_ADDR_LEN];
575         u_int16_t param_xr_beacon_interval;
576         u_int8_t param_base_ath_capability;
577         u_int8_t param_xr_ath_capability;
578 } __packed;
579
580 /* Atheros capabilities */
581 #define IEEE80211_ATHC_TURBOP   0x0001          /* Turbo Prime */
582 #define IEEE80211_ATHC_COMP     0x0002          /* Compression */
583 #define IEEE80211_ATHC_FF       0x0004          /* Fast Frames */
584 #define IEEE80211_ATHC_XR       0x0008          /* Xtended Range support */
585 #define IEEE80211_ATHC_AR       0x0010          /* Advanced Radar support */
586 #define IEEE80211_ATHC_BURST    0x0020          /* Bursting - not negotiated */
587 #define IEEE80211_ATHC_WME      0x0040          /* CWMin tuning */
588 #define IEEE80211_ATHC_BOOST    0x0080          /* Boost */
589
590 /*
591  * Management Notification Frame
592  */
593 struct ieee80211_mnf {
594         u_int8_t mnf_category;
595         u_int8_t mnf_action;
596         u_int8_t mnf_dialog;
597         u_int8_t mnf_status;
598 } __packed;
599 #define MNF_SETUP_REQ   0
600 #define MNF_SETUP_RESP  1
601 #define MNF_TEARDOWN    2
602
603 /*
604  * Control frames.
605  */
606 struct ieee80211_frame_min {
607         u_int8_t i_fc[2];
608         __le16 i_dur;
609         u_int8_t i_addr1[IEEE80211_ADDR_LEN];
610         u_int8_t i_addr2[IEEE80211_ADDR_LEN];
611         /* FCS */
612 } __packed;
613
614 struct ieee80211_frame_rts {
615         u_int8_t i_fc[2];
616         __le16 i_dur;
617         u_int8_t i_ra[IEEE80211_ADDR_LEN];
618         u_int8_t i_ta[IEEE80211_ADDR_LEN];
619         /* FCS */
620 } __packed;
621
622 struct ieee80211_frame_cts {
623         u_int8_t i_fc[2];
624         __le16 i_dur;
625         u_int8_t i_ra[IEEE80211_ADDR_LEN];
626         /* FCS */
627 } __packed;
628
629 struct ieee80211_frame_ack {
630         u_int8_t i_fc[2];
631         __le16 i_dur;
632         u_int8_t i_ra[IEEE80211_ADDR_LEN];
633         /* FCS */
634 } __packed;
635
636 struct ieee80211_frame_pspoll {
637         u_int8_t i_fc[2];
638         u_int8_t i_aid[2];
639         u_int8_t i_bssid[IEEE80211_ADDR_LEN];
640         u_int8_t i_ta[IEEE80211_ADDR_LEN];
641         /* FCS */
642 } __packed;
643
644 struct ieee80211_frame_cfend {          /* NB: also CF-End+CF-Ack */
645         u_int8_t i_fc[2];
646         __le16 i_dur;   /* should be zero */
647         u_int8_t i_ra[IEEE80211_ADDR_LEN];
648         u_int8_t i_bssid[IEEE80211_ADDR_LEN];
649         /* FCS */
650 } __packed;
651
652 /*
653  * BEACON management packets
654  *
655  *      octet timestamp[8]
656  *      octet beacon interval[2]
657  *      octet capability information[2]
658  *      information element
659  *              octet elemid
660  *              octet length
661  *              octet information[length]
662  */
663
664 typedef u_int8_t *ieee80211_mgt_beacon_t;
665
666 #define IEEE80211_BEACON_INTERVAL(beacon) \
667         ((beacon)[8] | ((beacon)[9] << 8))
668 #define IEEE80211_BEACON_CAPABILITY(beacon) \
669         ((beacon)[10] | ((beacon)[11] << 8))
670
671 #define IEEE80211_CAPINFO_ESS                   0x0001
672 #define IEEE80211_CAPINFO_IBSS                  0x0002
673 #define IEEE80211_CAPINFO_CF_POLLABLE           0x0004
674 #define IEEE80211_CAPINFO_CF_POLLREQ            0x0008
675 #define IEEE80211_CAPINFO_PRIVACY               0x0010
676 #define IEEE80211_CAPINFO_SHORT_PREAMBLE        0x0020
677 #define IEEE80211_CAPINFO_PBCC                  0x0040
678 #define IEEE80211_CAPINFO_CHNL_AGILITY          0x0080
679 /* bits 8-9 are reserved (8 now for spectrum management) */
680 #define IEEE80211_CAPINFO_SPECTRUM_MGMT         0x0100
681 #define IEEE80211_CAPINFO_SHORT_SLOTTIME        0x0400
682 #define IEEE80211_CAPINFO_RSN                   0x0800
683 /* bit 12 is reserved */
684 #define IEEE80211_CAPINFO_DSSSOFDM              0x2000
685 /* bits 14-15 are reserved */
686
687 /*
688  * 802.11i/WPA information element (maximally sized).
689  */
690 struct ieee80211_ie_wpa {
691         u_int8_t wpa_id;                        /* IEEE80211_ELEMID_VENDOR */
692         u_int8_t wpa_len;               /* length in bytes */
693         u_int8_t wpa_oui[3];            /* 0x00, 0x50, 0xf2 */
694         u_int8_t wpa_type;              /* OUI type */
695         u_int16_t wpa_version;          /* spec revision */
696         u_int32_t wpa_mcipher[1];       /* multicast/group key cipher */
697         u_int16_t wpa_uciphercnt;       /* # pairwise key ciphers */
698         u_int32_t wpa_uciphers[8];      /* ciphers */
699         u_int16_t wpa_authselcnt;       /* authentication selector cnt*/
700         u_int32_t wpa_authsels[8];      /* selectors */
701         u_int16_t wpa_caps;             /* 802.11i capabilities */
702         u_int16_t wpa_pmkidcnt;         /* 802.11i pmkid count */
703         u_int16_t wpa_pmkids[8];        /* 802.11i pmkids */
704 } __packed;
705
706 /*
707  * Management information element payloads.
708  */
709
710 enum {
711         IEEE80211_ELEMID_SSID           = 0,
712         IEEE80211_ELEMID_RATES          = 1,
713         IEEE80211_ELEMID_FHPARMS        = 2,
714         IEEE80211_ELEMID_DSPARMS        = 3,
715         IEEE80211_ELEMID_CFPARMS        = 4,
716         IEEE80211_ELEMID_TIM            = 5,
717         IEEE80211_ELEMID_IBSSPARMS      = 6,
718         IEEE80211_ELEMID_COUNTRY        = 7,
719         IEEE80211_ELEMID_HOPPATRNPARMS  = 8,
720         IEEE80211_ELEMID_HOPPATRNTABLE  = 9,
721         IEEE80211_ELEMID_REQINFO        = 10,
722         IEEE80211_ELEMID_QBSSLOAD       = 11,
723         IEEE80211_ELEMID_EDCAPARAM      = 12,
724         IEEE80211_ELEMID_TSPEC          = 13,
725         IEEE80211_ELEMID_TRAFCLASS      = 14,
726         IEEE80211_ELEMID_SCHEDULE       = 15,
727         IEEE80211_ELEMID_CHALLENGE      = 16,
728         /* 17-31 reserved for challenge text extension */
729         IEEE80211_ELEMID_PWRCNSTR       = 32,
730         IEEE80211_ELEMID_PWRCAP         = 33,
731         IEEE80211_ELEMID_TPCREQ         = 34,
732         IEEE80211_ELEMID_TPCREP         = 35,
733         IEEE80211_ELEMID_SUPPCHAN       = 36,
734         IEEE80211_ELEMID_CHANSWITCHANN  = 37,
735         IEEE80211_ELEMID_MEASREQ        = 38,
736         IEEE80211_ELEMID_MEASREP        = 39,
737         IEEE80211_ELEMID_QUIET          = 40,
738         IEEE80211_ELEMID_IBSSDFS        = 41,
739         IEEE80211_ELEMID_ERP            = 42,
740         IEEE80211_ELEMID_TSDELAY        = 43,
741         IEEE80211_ELEMID_TCLASSPROC     = 44,
742         IEEE80211_ELEMID_QOS            = 46,
743         IEEE80211_ELEMID_RSN            = 48,
744         /* 49 reserved */
745         IEEE80211_ELEMID_XRATES         = 50,
746         /* 128-129 proprietary elements used by Agere chipsets */
747         IEEE80211_ELEMID_AGERE1         = 128,
748         IEEE80211_ELEMID_AGERE2         = 129,
749         IEEE80211_ELEMID_TPC            = 150,
750         IEEE80211_ELEMID_CCKM           = 156,
751         IEEE80211_ELEMID_VENDOR         = 221,  /* vendor private */
752 };
753
754 #define IEEE80211_CHANSWITCHANN_BYTES   5
755 #define BITCTL_BUFD_MCAST               1
756 #define BITCTL_BUFD_UCAST_AID_MASK      ((u_int8_t)~(BITCTL_BUFD_MCAST))
757 #define BITCTL_BUFD_UCAST_AID_SHIFT     1
758
759 struct ieee80211_tim_ie {
760         u_int8_t        tim_ie;                 /* IEEE80211_ELEMID_TIM */
761         u_int8_t        tim_len;
762         u_int8_t        tim_count;              /* DTIM count */
763         u_int8_t        tim_period;             /* DTIM period */
764         u_int8_t        tim_bitctl;             /* bitmap control */
765         u_int8_t        tim_bitmap[1];          /* variable-length bitmap */
766 } __packed;
767
768 struct ieee80211_country_ie {
769         u_int8_t        ie;                     /* IEEE80211_ELEMID_COUNTRY */
770         u_int8_t        len;
771         u_int8_t        cc[3];                  /* ISO CC+(I)ndoor/(O)utdoor */
772         struct {
773                 u_int8_t schan;                 /* starting channel */
774                 u_int8_t nchan;                 /* number channels */
775                 u_int8_t maxtxpwr;              /* tx power cap */
776         } __packed band[4];                     /* up to 4 sub bands */
777 } __packed;
778
779 #define IEEE80211_CHALLENGE_LEN         128
780
781 #define IEEE80211_SUPPCHAN_LEN          26
782
783 #define IEEE80211_RATE_BASIC            0x80
784 #define IEEE80211_RATE_VAL              0x7f
785
786 /* EPR information element flags */
787 #define IEEE80211_ERP_NON_ERP_PRESENT   0x01
788 #define IEEE80211_ERP_USE_PROTECTION    0x02
789 #define IEEE80211_ERP_LONG_PREAMBLE     0x04
790
791 /* Atheros private advanced capabilities info */
792 #define ATHEROS_CAP_TURBO_PRIME         0x01
793 #define ATHEROS_CAP_COMPRESSION         0x02
794 #define ATHEROS_CAP_FAST_FRAME          0x04
795 /* bits 3-6 reserved */
796 #define ATHEROS_CAP_BOOST               0x80
797
798 #define ATH_OUI                 0x7f0300                /* Atheros OUI */
799 #define ATH_OUI_TYPE            0x01
800 #define ATH_OUI_SUBTYPE         0x01
801 #define ATH_OUI_VERSION         0x00
802 #define ATH_OUI_TYPE_XR         0x03
803 #define ATH_OUI_SUBTYPE_XR      0x01
804 #define ATH_OUI_VER_XR          0x00
805
806 #define WPA_OUI                 0xf25000
807 #define WPA_OUI_TYPE            0x01
808 #define WPA_VERSION             1               /* current supported version */
809
810 #define WPA_CSE_NULL            0x00
811 #define WPA_CSE_WEP40           0x01
812 #define WPA_CSE_TKIP            0x02
813 #define WPA_CSE_CCMP            0x04
814 #define WPA_CSE_WEP104          0x05
815
816 #define WPA_ASE_NONE            0x00
817 #define WPA_ASE_8021X_UNSPEC    0x01
818 #define WPA_ASE_8021X_PSK       0x02
819
820 #define RSN_OUI                 0xac0f00
821 #define RSN_VERSION             1               /* current supported version */
822
823 #define RSN_CSE_NULL            0x00
824 #define RSN_CSE_WEP40           0x01
825 #define RSN_CSE_TKIP            0x02
826 #define RSN_CSE_WRAP            0x03
827 #define RSN_CSE_CCMP            0x04
828 #define RSN_CSE_WEP104          0x05
829
830 #define RSN_ASE_NONE            0x00
831 #define RSN_ASE_8021X_UNSPEC    0x01
832 #define RSN_ASE_8021X_PSK       0x02
833
834 #define RSN_CAP_PREAUTH         0x01
835
836 #define WME_OUI                 0xf25000
837 #define WME_OUI_TYPE            0x02
838 #define WME_INFO_OUI_SUBTYPE    0x00
839 #define WME_PARAM_OUI_SUBTYPE   0x01
840 #define WME_VERSION             1
841
842 /* WME stream classes */
843 #define WME_AC_BE       0               /* best effort */
844 #define WME_AC_BK       1               /* background */
845 #define WME_AC_VI       2               /* video */
846 #define WME_AC_VO       3               /* voice */
847
848 /*
849  * AUTH management packets
850  *
851  *      octet algo[2]
852  *      octet seq[2]
853  *      octet status[2]
854  *      octet chal.id
855  *      octet chal.length
856  *      octet chal.text[253]
857  */
858
859 typedef u_int8_t *ieee80211_mgt_auth_t;
860
861 #define IEEE80211_AUTH_ALGORITHM(auth) \
862         ((auth)[0] | ((auth)[1] << 8))
863 #define IEEE80211_AUTH_TRANSACTION(auth) \
864         ((auth)[2] | ((auth)[3] << 8))
865 #define IEEE80211_AUTH_STATUS(auth) \
866         ((auth)[4] | ((auth)[5] << 8))
867
868 #define IEEE80211_AUTH_ALG_OPEN         0x0000
869 #define IEEE80211_AUTH_ALG_SHARED       0x0001
870 #define IEEE80211_AUTH_ALG_LEAP         0x0080
871
872 enum {
873         IEEE80211_AUTH_OPEN_REQUEST             = 1,
874         IEEE80211_AUTH_OPEN_RESPONSE            = 2,
875 };
876
877 enum {
878         IEEE80211_AUTH_SHARED_REQUEST           = 1,
879         IEEE80211_AUTH_SHARED_CHALLENGE         = 2,
880         IEEE80211_AUTH_SHARED_RESPONSE          = 3,
881         IEEE80211_AUTH_SHARED_PASS              = 4,
882 };
883
884 /*
885  * Reason codes
886  *
887  * Unlisted codes are reserved
888  */
889
890 enum {
891         IEEE80211_REASON_UNSPECIFIED            = 1,
892         IEEE80211_REASON_AUTH_EXPIRE            = 2,
893         IEEE80211_REASON_AUTH_LEAVE             = 3,
894         IEEE80211_REASON_ASSOC_EXPIRE           = 4,
895         IEEE80211_REASON_ASSOC_TOOMANY          = 5,
896         IEEE80211_REASON_NOT_AUTHED             = 6,
897         IEEE80211_REASON_NOT_ASSOCED            = 7,
898         IEEE80211_REASON_ASSOC_LEAVE            = 8,
899         IEEE80211_REASON_ASSOC_NOT_AUTHED       = 9,
900
901         IEEE80211_REASON_PWRCAP_UNACCEPTABLE    = 10,
902         IEEE80211_REASON_SUPPCHAN_UNACCEPTABLE  = 11,
903         IEEE80211_REASON_RSN_REQUIRED           = 11,
904         IEEE80211_REASON_RSN_INCONSISTENT       = 12,
905         IEEE80211_REASON_IE_INVALID             = 13,
906         IEEE80211_REASON_MIC_FAILURE            = 14,
907
908         IEEE80211_STATUS_SUCCESS                = 0,
909         IEEE80211_STATUS_UNSPECIFIED            = 1,
910         IEEE80211_STATUS_CAPINFO                = 10,
911         IEEE80211_STATUS_NOT_ASSOCED            = 11,
912         IEEE80211_STATUS_OTHER                  = 12,
913         IEEE80211_STATUS_ALG                    = 13,
914         IEEE80211_STATUS_SEQUENCE               = 14,
915         IEEE80211_STATUS_CHALLENGE              = 15,
916         IEEE80211_STATUS_TIMEOUT                = 16,
917         IEEE80211_STATUS_TOOMANY                = 17,
918         IEEE80211_STATUS_BASIC_RATE             = 18,
919         IEEE80211_STATUS_SP_REQUIRED            = 19,
920         IEEE80211_STATUS_PBCC_REQUIRED          = 20,
921         IEEE80211_STATUS_CA_REQUIRED            = 21,
922         IEEE80211_STATUS_SM_REQUIRED            = 22,
923         IEEE80211_STATUS_PWRCAP_UNACCEPTABLE    = 23,
924         IEEE80211_STATUS_SUPPCHAN_UNACCEPTABLE  = 24,
925         IEEE80211_STATUS_TOO_MANY_STATIONS      = 22,
926         IEEE80211_STATUS_RATES                  = 23,
927         IEEE80211_STATUS_SHORTSLOT_REQUIRED     = 25,
928         IEEE80211_STATUS_DSSSOFDM_REQUIRED      = 26,
929 };
930
931 #define IEEE80211_WEP_KEYLEN            5       /* 40bit */
932 #define IEEE80211_WEP_IVLEN             3       /* 24bit */
933 #define IEEE80211_WEP_KIDLEN            1       /* 1 octet */
934 #define IEEE80211_WEP_CRCLEN            4       /* CRC-32 */
935 #define IEEE80211_WEP_NKID              4       /* number of key ids */
936
937 /*
938  * 802.11i defines an extended IV for use with non-WEP ciphers.
939  * When the EXTIV bit is set in the key id byte an additional
940  * 4 bytes immediately follow the IV for TKIP.  For CCMP the
941  * EXTIV bit is likewise set but the 8 bytes represent the
942  * CCMP header rather than IV+extended-IV.
943  */
944 #define IEEE80211_WEP_EXTIV             0x20
945 #define IEEE80211_WEP_EXTIVLEN          4       /* extended IV length */
946 #define IEEE80211_WEP_MICLEN            8       /* trailing MIC */
947
948 #define IEEE80211_CRC_LEN               4
949
950 /*
951  * Maximum acceptable MTU is:
952  *      IEEE80211_MAX_LEN - WEP overhead - CRC -
953  *              QoS overhead - RSN/WPA overhead
954  * Min is arbitrarily chosen > IEEE80211_MIN_LEN.  The default
955  * mtu is Ethernet-compatible; it's set by ether_ifattach.
956  */
957 #define IEEE80211_MTU_MAX               2290
958 #define IEEE80211_MTU_MIN               32
959
960 #define IEEE80211_MAX_LEN               (2300 + IEEE80211_CRC_LEN + \
961         (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
962 #define IEEE80211_ACK_LEN \
963         (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
964 #define IEEE80211_MIN_LEN \
965         (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
966
967 /*
968  * The 802.11 spec says at most 2007 stations may be
969  * associated at once.  For most APs this is way more
970  * than is feasible so we use a default of 128.  This
971  * number may be overridden by the driver and/or by
972  * user configuration.
973  */
974 #define IEEE80211_AID_MAX               2007
975 #define IEEE80211_AID_DEF               128
976
977 #define IEEE80211_AID(b)        ((b) &~ 0xc000)
978
979 /* 
980  * RTS frame length parameters.  The default is specified in
981  * the 802.11 spec.  The max may be wrong for jumbo frames.
982  */
983 #define IEEE80211_RTS_DEFAULT           512
984 #define IEEE80211_RTS_MIN               1
985 #define IEEE80211_RTS_MAX               2346
986
987 /* 
988  * Regulatory extension identifier for country IE.
989  */
990 #define IEEE80211_REG_EXT_ID            201
991
992 /*
993  * IEEE 802.11 timer synchronization function (TSF) timestamp length
994  */
995 #define IEEE80211_TSF_LEN               8
996
997 #endif /* _NET80211_IEEE80211_H_ */