]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/net80211/ieee80211.h
This commit was generated by cvs2svn to compensate for changes in r171577,
[FreeBSD/FreeBSD.git] / sys / net80211 / ieee80211.h
1 /*-
2  * Copyright (c) 2001 Atsushi Onoe
3  * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 #ifndef _NET80211_IEEE80211_H_
29 #define _NET80211_IEEE80211_H_
30
31 /*
32  * 802.11 protocol definitions.
33  */
34
35 #define IEEE80211_ADDR_LEN      6               /* size of 802.11 address */
36 /* is 802.11 address multicast/broadcast? */
37 #define IEEE80211_IS_MULTICAST(_a)      (*(_a) & 0x01)
38
39 /* IEEE 802.11 PLCP header */
40 struct ieee80211_plcp_hdr {
41         uint16_t        i_sfd;
42         uint8_t         i_signal;
43         uint8_t         i_service;
44         uint16_t        i_length;
45         uint16_t        i_crc;
46 } __packed;
47
48 #define IEEE80211_PLCP_SFD      0xF3A0 
49 #define IEEE80211_PLCP_SERVICE  0x00
50
51 /*
52  * generic definitions for IEEE 802.11 frames
53  */
54 struct ieee80211_frame {
55         uint8_t         i_fc[2];
56         uint8_t         i_dur[2];
57         uint8_t         i_addr1[IEEE80211_ADDR_LEN];
58         uint8_t         i_addr2[IEEE80211_ADDR_LEN];
59         uint8_t         i_addr3[IEEE80211_ADDR_LEN];
60         uint8_t         i_seq[2];
61         /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
62         /* see below */
63 } __packed;
64
65 struct ieee80211_qosframe {
66         uint8_t         i_fc[2];
67         uint8_t         i_dur[2];
68         uint8_t         i_addr1[IEEE80211_ADDR_LEN];
69         uint8_t         i_addr2[IEEE80211_ADDR_LEN];
70         uint8_t         i_addr3[IEEE80211_ADDR_LEN];
71         uint8_t         i_seq[2];
72         uint8_t         i_qos[2];
73         /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
74         /* see below */
75 } __packed;
76
77 struct ieee80211_qoscntl {
78         uint8_t         i_qos[2];
79 };
80
81 struct ieee80211_frame_addr4 {
82         uint8_t         i_fc[2];
83         uint8_t         i_dur[2];
84         uint8_t         i_addr1[IEEE80211_ADDR_LEN];
85         uint8_t         i_addr2[IEEE80211_ADDR_LEN];
86         uint8_t         i_addr3[IEEE80211_ADDR_LEN];
87         uint8_t         i_seq[2];
88         uint8_t         i_addr4[IEEE80211_ADDR_LEN];
89 } __packed;
90
91
92 struct ieee80211_qosframe_addr4 {
93         uint8_t         i_fc[2];
94         uint8_t         i_dur[2];
95         uint8_t         i_addr1[IEEE80211_ADDR_LEN];
96         uint8_t         i_addr2[IEEE80211_ADDR_LEN];
97         uint8_t         i_addr3[IEEE80211_ADDR_LEN];
98         uint8_t         i_seq[2];
99         uint8_t         i_addr4[IEEE80211_ADDR_LEN];
100         uint8_t         i_qos[2];
101 } __packed;
102
103 #define IEEE80211_FC0_VERSION_MASK              0x03
104 #define IEEE80211_FC0_VERSION_SHIFT             0
105 #define IEEE80211_FC0_VERSION_0                 0x00
106 #define IEEE80211_FC0_TYPE_MASK                 0x0c
107 #define IEEE80211_FC0_TYPE_SHIFT                2
108 #define IEEE80211_FC0_TYPE_MGT                  0x00
109 #define IEEE80211_FC0_TYPE_CTL                  0x04
110 #define IEEE80211_FC0_TYPE_DATA                 0x08
111
112 #define IEEE80211_FC0_SUBTYPE_MASK              0xf0
113 #define IEEE80211_FC0_SUBTYPE_SHIFT             4
114 /* for TYPE_MGT */
115 #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ         0x00
116 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP        0x10
117 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ       0x20
118 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP      0x30
119 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ         0x40
120 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP        0x50
121 #define IEEE80211_FC0_SUBTYPE_BEACON            0x80
122 #define IEEE80211_FC0_SUBTYPE_ATIM              0x90
123 #define IEEE80211_FC0_SUBTYPE_DISASSOC          0xa0
124 #define IEEE80211_FC0_SUBTYPE_AUTH              0xb0
125 #define IEEE80211_FC0_SUBTYPE_DEAUTH            0xc0
126 #define IEEE80211_FC0_SUBTYPE_ACTION            0xd0
127 /* for TYPE_CTL */
128 #define IEEE80211_FC0_SUBTYPE_BAR               0x80
129 #define IEEE80211_FC0_SUBTYPE_PS_POLL           0xa0
130 #define IEEE80211_FC0_SUBTYPE_RTS               0xb0
131 #define IEEE80211_FC0_SUBTYPE_CTS               0xc0
132 #define IEEE80211_FC0_SUBTYPE_ACK               0xd0
133 #define IEEE80211_FC0_SUBTYPE_CF_END            0xe0
134 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK        0xf0
135 /* for TYPE_DATA (bit combination) */
136 #define IEEE80211_FC0_SUBTYPE_DATA              0x00
137 #define IEEE80211_FC0_SUBTYPE_CF_ACK            0x10
138 #define IEEE80211_FC0_SUBTYPE_CF_POLL           0x20
139 #define IEEE80211_FC0_SUBTYPE_CF_ACPL           0x30
140 #define IEEE80211_FC0_SUBTYPE_NODATA            0x40
141 #define IEEE80211_FC0_SUBTYPE_CFACK             0x50
142 #define IEEE80211_FC0_SUBTYPE_CFPOLL            0x60
143 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK     0x70
144 #define IEEE80211_FC0_SUBTYPE_QOS               0x80
145 #define IEEE80211_FC0_SUBTYPE_QOS_NULL          0xc0
146
147 #define IEEE80211_FC1_DIR_MASK                  0x03
148 #define IEEE80211_FC1_DIR_NODS                  0x00    /* STA->STA */
149 #define IEEE80211_FC1_DIR_TODS                  0x01    /* STA->AP  */
150 #define IEEE80211_FC1_DIR_FROMDS                0x02    /* AP ->STA */
151 #define IEEE80211_FC1_DIR_DSTODS                0x03    /* AP ->AP  */
152
153 #define IEEE80211_FC1_MORE_FRAG                 0x04
154 #define IEEE80211_FC1_RETRY                     0x08
155 #define IEEE80211_FC1_PWR_MGT                   0x10
156 #define IEEE80211_FC1_MORE_DATA                 0x20
157 #define IEEE80211_FC1_WEP                       0x40
158 #define IEEE80211_FC1_ORDER                     0x80
159
160 #define IEEE80211_SEQ_FRAG_MASK                 0x000f
161 #define IEEE80211_SEQ_FRAG_SHIFT                0
162 #define IEEE80211_SEQ_SEQ_MASK                  0xfff0
163 #define IEEE80211_SEQ_SEQ_SHIFT                 4
164 #define IEEE80211_SEQ_RANGE                     4096
165
166 #define IEEE80211_SEQ_ADD(seq, incr) \
167         (((seq) + (incr)) & (IEEE80211_SEQ_RANGE-1))
168 #define IEEE80211_SEQ_INC(seq)  IEEE80211_SEQ_ADD(seq,1)
169 #define IEEE80211_SEQ_SUB(a, b) \
170         (((a) + IEEE80211_SEQ_RANGE - (b)) & (IEEE80211_SEQ_RANGE-1))
171
172 #define IEEE80211_NWID_LEN                      32
173
174 #define IEEE80211_QOS_TXOP                      0x00ff
175 /* bit 8 is reserved */
176 #define IEEE80211_QOS_AMSDU                     0x80
177 #define IEEE80211_QOS_AMSDU_S                   7
178 #define IEEE80211_QOS_ACKPOLICY                 0x60
179 #define IEEE80211_QOS_ACKPOLICY_S               5
180 #define IEEE80211_QOS_ACKPOLICY_NOACK           0x20    /* No ACK required */
181 #define IEEE80211_QOS_ACKPOLICY_BA              0x60    /* Block ACK */
182 #define IEEE80211_QOS_ESOP                      0x10
183 #define IEEE80211_QOS_ESOP_S                    4
184 #define IEEE80211_QOS_TID                       0x0f
185
186 /* does frame have QoS sequence control data */
187 #define IEEE80211_QOS_HAS_SEQ(wh) \
188         (((wh)->i_fc[0] & \
189           (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \
190           (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
191
192 /*
193  * WME/802.11e information element.
194  */
195 struct ieee80211_wme_info {
196         uint8_t         wme_id;         /* IEEE80211_ELEMID_VENDOR */
197         uint8_t         wme_len;        /* length in bytes */
198         uint8_t         wme_oui[3];     /* 0x00, 0x50, 0xf2 */
199         uint8_t         wme_type;       /* OUI type */
200         uint8_t         wme_subtype;    /* OUI subtype */
201         uint8_t         wme_version;    /* spec revision */
202         uint8_t         wme_info;       /* QoS info */
203 } __packed;
204
205 /*
206  * WME/802.11e Tspec Element
207  */
208 struct ieee80211_wme_tspec {
209         uint8_t         ts_id;
210         uint8_t         ts_len;
211         uint8_t         ts_oui[3];
212         uint8_t         ts_oui_type;
213         uint8_t         ts_oui_subtype;
214         uint8_t         ts_version;
215         uint8_t         ts_tsinfo[3];
216         uint8_t         ts_nom_msdu[2];
217         uint8_t         ts_max_msdu[2];
218         uint8_t         ts_min_svc[4];
219         uint8_t         ts_max_svc[4];
220         uint8_t         ts_inactv_intv[4];
221         uint8_t         ts_susp_intv[4];
222         uint8_t         ts_start_svc[4];
223         uint8_t         ts_min_rate[4];
224         uint8_t         ts_mean_rate[4];
225         uint8_t         ts_max_burst[4];
226         uint8_t         ts_min_phy[4];
227         uint8_t         ts_peak_rate[4];
228         uint8_t         ts_delay[4];
229         uint8_t         ts_surplus[2];
230         uint8_t         ts_medium_time[2];
231 } __packed;
232
233 /*
234  * WME AC parameter field
235  */
236 struct ieee80211_wme_acparams {
237         uint8_t         acp_aci_aifsn;
238         uint8_t         acp_logcwminmax;
239         uint16_t        acp_txop;
240 } __packed;
241
242 #define WME_NUM_AC              4       /* 4 AC categories */
243 #define WME_NUM_TID             16      /* 16 tids */
244
245 #define WME_PARAM_ACI           0x60    /* Mask for ACI field */
246 #define WME_PARAM_ACI_S         5       /* Shift for ACI field */
247 #define WME_PARAM_ACM           0x10    /* Mask for ACM bit */
248 #define WME_PARAM_ACM_S         4       /* Shift for ACM bit */
249 #define WME_PARAM_AIFSN         0x0f    /* Mask for aifsn field */
250 #define WME_PARAM_AIFSN_S       0       /* Shift for aifsn field */
251 #define WME_PARAM_LOGCWMIN      0x0f    /* Mask for CwMin field (in log) */
252 #define WME_PARAM_LOGCWMIN_S    0       /* Shift for CwMin field */
253 #define WME_PARAM_LOGCWMAX      0xf0    /* Mask for CwMax field (in log) */
254 #define WME_PARAM_LOGCWMAX_S    4       /* Shift for CwMax field */
255
256 #define WME_AC_TO_TID(_ac) (       \
257         ((_ac) == WME_AC_VO) ? 6 : \
258         ((_ac) == WME_AC_VI) ? 5 : \
259         ((_ac) == WME_AC_BK) ? 1 : \
260         0)
261
262 #define TID_TO_WME_AC(_tid) (      \
263         ((_tid) < 1) ? WME_AC_BE : \
264         ((_tid) < 3) ? WME_AC_BK : \
265         ((_tid) < 6) ? WME_AC_VI : \
266         WME_AC_VO)
267
268 /*
269  * WME Parameter Element
270  */
271 struct ieee80211_wme_param {
272         uint8_t         param_id;
273         uint8_t         param_len;
274         uint8_t         param_oui[3];
275         uint8_t         param_oui_type;
276         uint8_t         param_oui_sybtype;
277         uint8_t         param_version;
278         uint8_t         param_qosInfo;
279 #define WME_QOSINFO_COUNT       0x0f    /* Mask for param count field */
280         uint8_t         param_reserved;
281         struct ieee80211_wme_acparams   params_acParams[WME_NUM_AC];
282 } __packed;
283
284 /*
285  * Management Notification Frame
286  */
287 struct ieee80211_mnf {
288         uint8_t         mnf_category;
289         uint8_t         mnf_action;
290         uint8_t         mnf_dialog;
291         uint8_t         mnf_status;
292 } __packed;
293 #define MNF_SETUP_REQ   0
294 #define MNF_SETUP_RESP  1
295 #define MNF_TEARDOWN    2
296
297 /* 
298  * 802.11n Management Action Frames 
299  */
300 /* generic frame format */
301 struct ieee80211_action {
302         uint8_t         ia_category;
303         uint8_t         ia_action;
304 } __packed;
305
306 #define IEEE80211_ACTION_CAT_QOS        0       /* QoS */
307 #define IEEE80211_ACTION_CAT_BA         3       /* BA */
308 #define IEEE80211_ACTION_CAT_HT         5       /* HT */
309
310 #define IEEE80211_ACTION_HT_TXCHWIDTH   0       /* recommended xmit chan width*/
311 #define IEEE80211_ACTION_HT_MIMOPWRSAVE 1       /* MIMO power save */
312
313 /* HT - recommended transmission channel width */
314 struct ieee80211_action_ht_txchwidth {
315         struct ieee80211_action at_header;
316         uint8_t         at_chwidth;     
317 } __packed;
318
319 #define IEEE80211_A_HT_TXCHWIDTH_20     0
320 #define IEEE80211_A_HT_TXCHWIDTH_2040   1
321
322 /* HT - MIMO Power Save */
323 struct ieee80211_action_ht_mimopowersave {
324         struct ieee80211_action am_header;
325         uint8_t         am_enable;      
326         uint8_t         am_mode;        
327 } __packed;
328
329 /* Block Ack actions */
330 #define IEEE80211_ACTION_BA_ADDBA_REQUEST       0   /* ADDBA request */
331 #define IEEE80211_ACTION_BA_ADDBA_RESPONSE      1   /* ADDBA response */
332 #define IEEE80211_ACTION_BA_DELBA               2   /* DELBA */
333
334 /* Block Ack Parameter Set */
335 #define IEEE80211_BAPS_BUFSIZ   0xffc0          /* buffer size */
336 #define IEEE80211_BAPS_BUFSIZ_S 6
337 #define IEEE80211_BAPS_TID      0x003c          /* TID */
338 #define IEEE80211_BAPS_TID_S    2
339 #define IEEE80211_BAPS_POLICY   0x0002          /* block ack policy */
340 #define IEEE80211_BAPS_POLICY_S 1
341
342 #define IEEE80211_BAPS_POLICY_DELAYED   (0<<IEEE80211_BAPS_POLICY_S)
343 #define IEEE80211_BAPS_POLICY_IMMEDIATE (1<<IEEE80211_BAPS_POLICY_S)
344
345 /* Block Ack Sequence Control */
346 #define IEEE80211_BASEQ_START   0xfff0          /* starting seqnum */
347 #define IEEE80211_BASEQ_START_S 4
348 #define IEEE80211_BASEQ_FRAG    0x000f          /* fragment number */
349 #define IEEE80211_BASEQ_FRAG_S  0
350
351 /* Delayed Block Ack Parameter Set */
352 #define IEEE80211_DELBAPS_TID   0xf000          /* TID */
353 #define IEEE80211_DELBAPS_TID_S 12
354 #define IEEE80211_DELBAPS_INIT  0x0800          /* initiator */
355 #define IEEE80211_DELBAPS_INIT_S 11
356
357 /* BA - ADDBA request */
358 struct ieee80211_action_ba_addbarequest {
359         struct ieee80211_action rq_header;
360         uint8_t         rq_dialogtoken;
361         uint16_t        rq_baparamset;
362         uint16_t        rq_batimeout;           /* in TUs */
363         uint16_t        rq_baseqctl;
364 } __packed;
365
366 /* BA - ADDBA response */
367 struct ieee80211_action_ba_addbaresponse {
368         struct ieee80211_action rs_header;
369         uint8_t         rs_dialogtoken;
370         uint16_t        rs_statuscode;
371         uint16_t        rs_baparamset; 
372         uint16_t        rs_batimeout;           /* in TUs */
373 } __packed;
374
375 /* BA - DELBA */
376 struct ieee80211_action_ba_delba {
377         struct ieee80211_action dl_header;
378         uint16_t        dl_baparamset;
379         uint16_t        dl_reasoncode;
380 } __packed;
381
382 /* BAR Control */
383 #define IEEE80211_BAR_TID       0xf000          /* TID */
384 #define IEEE80211_BAR_TID_S     12
385 #define IEEE80211_BAR_COMP      0x0004          /* compressed */
386 #define IEEE80211_BAR_MTID      0x0002
387 #define IEEE80211_BAR_NOACK     0x0001          /* no-ack policy */
388
389 struct ieee80211_ba_request {
390         uint16_t        rq_barctl;
391         uint16_t        rq_barseqctl;
392 } __packed;
393
394 /*
395  * Control frames.
396  */
397 struct ieee80211_frame_min {
398         uint8_t         i_fc[2];
399         uint8_t         i_dur[2];
400         uint8_t         i_addr1[IEEE80211_ADDR_LEN];
401         uint8_t         i_addr2[IEEE80211_ADDR_LEN];
402         /* FCS */
403 } __packed;
404
405 struct ieee80211_frame_rts {
406         uint8_t         i_fc[2];
407         uint8_t         i_dur[2];
408         uint8_t         i_ra[IEEE80211_ADDR_LEN];
409         uint8_t         i_ta[IEEE80211_ADDR_LEN];
410         /* FCS */
411 } __packed;
412
413 struct ieee80211_frame_cts {
414         uint8_t         i_fc[2];
415         uint8_t         i_dur[2];
416         uint8_t         i_ra[IEEE80211_ADDR_LEN];
417         /* FCS */
418 } __packed;
419
420 struct ieee80211_frame_ack {
421         uint8_t         i_fc[2];
422         uint8_t         i_dur[2];
423         uint8_t         i_ra[IEEE80211_ADDR_LEN];
424         /* FCS */
425 } __packed;
426
427 struct ieee80211_frame_pspoll {
428         uint8_t         i_fc[2];
429         uint8_t         i_aid[2];
430         uint8_t         i_bssid[IEEE80211_ADDR_LEN];
431         uint8_t         i_ta[IEEE80211_ADDR_LEN];
432         /* FCS */
433 } __packed;
434
435 struct ieee80211_frame_cfend {          /* NB: also CF-End+CF-Ack */
436         uint8_t         i_fc[2];
437         uint8_t         i_dur[2];       /* should be zero */
438         uint8_t         i_ra[IEEE80211_ADDR_LEN];
439         uint8_t         i_bssid[IEEE80211_ADDR_LEN];
440         /* FCS */
441 } __packed;
442
443 struct ieee80211_frame_bar {
444         uint8_t         i_fc[2];
445         uint8_t         i_dur[2];
446         uint8_t         i_ra[IEEE80211_ADDR_LEN];
447         uint8_t         i_ta[IEEE80211_ADDR_LEN];
448         uint16_t        i_ctl;
449         uint16_t        i_seq;
450         /* FCS */
451 } __packed;
452
453 /*
454  * BEACON management packets
455  *
456  *      octet timestamp[8]
457  *      octet beacon interval[2]
458  *      octet capability information[2]
459  *      information element
460  *              octet elemid
461  *              octet length
462  *              octet information[length]
463  */
464
465 typedef uint8_t *ieee80211_mgt_beacon_t;
466
467 #define IEEE80211_BEACON_INTERVAL(beacon) \
468         ((beacon)[8] | ((beacon)[9] << 8))
469 #define IEEE80211_BEACON_CAPABILITY(beacon) \
470         ((beacon)[10] | ((beacon)[11] << 8))
471
472 #define IEEE80211_CAPINFO_ESS                   0x0001
473 #define IEEE80211_CAPINFO_IBSS                  0x0002
474 #define IEEE80211_CAPINFO_CF_POLLABLE           0x0004
475 #define IEEE80211_CAPINFO_CF_POLLREQ            0x0008
476 #define IEEE80211_CAPINFO_PRIVACY               0x0010
477 #define IEEE80211_CAPINFO_SHORT_PREAMBLE        0x0020
478 #define IEEE80211_CAPINFO_PBCC                  0x0040
479 #define IEEE80211_CAPINFO_CHNL_AGILITY          0x0080
480 /* bits 8-9 are reserved */
481 #define IEEE80211_CAPINFO_SHORT_SLOTTIME        0x0400
482 #define IEEE80211_CAPINFO_RSN                   0x0800
483 /* bit 12 is reserved */
484 #define IEEE80211_CAPINFO_DSSSOFDM              0x2000
485 /* bits 14-15 are reserved */
486
487 /*
488  * 802.11i/WPA information element (maximally sized).
489  */
490 struct ieee80211_ie_wpa {
491         uint8_t         wpa_id;         /* IEEE80211_ELEMID_VENDOR */
492         uint8_t         wpa_len;        /* length in bytes */
493         uint8_t         wpa_oui[3];     /* 0x00, 0x50, 0xf2 */
494         uint8_t         wpa_type;       /* OUI type */
495         uint16_t        wpa_version;    /* spec revision */
496         uint32_t        wpa_mcipher[1]; /* multicast/group key cipher */
497         uint16_t        wpa_uciphercnt; /* # pairwise key ciphers */
498         uint32_t        wpa_uciphers[8];/* ciphers */
499         uint16_t        wpa_authselcnt; /* authentication selector cnt*/
500         uint32_t        wpa_authsels[8];/* selectors */
501         uint16_t        wpa_caps;       /* 802.11i capabilities */
502         uint16_t        wpa_pmkidcnt;   /* 802.11i pmkid count */
503         uint16_t        wpa_pmkids[8];  /* 802.11i pmkids */
504 } __packed;
505
506 /*
507  * 802.11n HT Capability IE
508  * NB: these reflect D1.10 
509  */
510 struct ieee80211_ie_htcap {
511         uint8_t         hc_id;                  /* element ID */
512         uint8_t         hc_len;                 /* length in bytes */
513         uint16_t        hc_cap;                 /* HT caps (see below) */
514         uint8_t         hc_param;               /* HT params (see below) */
515         uint8_t         hc_mcsset[16];          /* supported MCS set */
516         uint16_t        hc_extcap;              /* extended HT capabilities */
517         uint32_t        hc_txbf;                /* txbf capabilities */
518         uint8_t         hc_antenna;             /* antenna capabilities */
519 } __packed;
520
521 /* HT capability flags (ht_cap) */
522 #define IEEE80211_HTCAP_LDPC            0x0001  /* LDPC supported */
523 #define IEEE80211_HTCAP_CHWIDTH40       0x0002  /* 20/40 supported */
524 #define IEEE80211_HTCAP_SMPS            0x000c  /* SM Power Save mode */
525 #define IEEE80211_HTCAP_SMPS_OFF        0x0000  /* none (static mode) */
526 #define IEEE80211_HTCAP_SMPS_DYNAMIC    0x0004  /* send RTS first */
527 /* NB: SMPS value 2 is reserved */
528 #define IEEE80211_HTCAP_SMPS_ENA        0x000c  /* enabled */
529 #define IEEE80211_HTCAP_GREENFIELD      0x0010  /* Greenfield supported */
530 #define IEEE80211_HTCAP_SHORTGI20       0x0020  /* Short GI in 20MHz */
531 #define IEEE80211_HTCAP_SHORTGI40       0x0040  /* Short GI in 40MHz */
532 #define IEEE80211_HTCAP_TXSTBC          0x0080  /* STBC tx ok */
533 #define IEEE80211_HTCAP_RXSTBC          0x0300  /* STBC rx support */
534 #define IEEE80211_HTCAP_RXSTBC_S        8
535 #define IEEE80211_HTCAP_RXSTBC_1STREAM  0x0100  /* 1 spatial stream */
536 #define IEEE80211_HTCAP_RXSTBC_2STREAM  0x0200  /* 1-2 spatial streams*/
537 #define IEEE80211_HTCAP_RXSTBC_3STREAM  0x0300  /* 1-3 spatial streams*/
538 #define IEEE80211_HTCAP_DELBA           0x0400  /* HT DELBA supported */
539 #define IEEE80211_HTCAP_MAXAMSDU        0x0800  /* max A-MSDU length */
540 #define IEEE80211_HTCAP_MAXAMSDU_7935   0x0800  /* 7935 octets */
541 #define IEEE80211_HTCAP_MAXAMSDU_3839   0x0000  /* 3839 octets */
542 #define IEEE80211_HTCAP_DSSSCCK40       0x1000  /* DSSS/CCK in 40MHz */
543 #define IEEE80211_HTCAP_PSMP            0x2000  /* PSMP supported */
544 #define IEEE80211_HTCAP_40INTOLERANT    0x4000  /* 40MHz intolerant */
545 #define IEEE80211_HTCAP_LSIGTXOPPROT    0x8000  /* L-SIG TXOP prot */
546
547 /* HT parameters (hc_param) */
548 #define IEEE80211_HTCAP_MAXRXAMPDU      0x03    /* max rx A-MPDU factor */
549 #define IEEE80211_HTCAP_MAXRXAMPDU_S    0
550 #define IEEE80211_HTCAP_MAXRXAMPDU_8K   0x00
551 #define IEEE80211_HTCAP_MAXRXAMPDU_16K  0x01
552 #define IEEE80211_HTCAP_MAXRXAMPDU_32K  0x02
553 #define IEEE80211_HTCAP_MAXRXAMPDU_64K  0x03
554 #define IEEE80211_HTCAP_MPDUDENSITY     0x1c    /* min MPDU start spacing */
555 #define IEEE80211_HTCAP_MPDUDENSITY_S   2
556 #define IEEE80211_HTCAP_MPDUDENSITY_NA  0x00    /* no time restriction */
557 #define IEEE80211_HTCAP_MPDUDENSITY_025 0x04    /* 1/4 us */
558 #define IEEE80211_HTCAP_MPDUDENSITY_05  0x08    /* 1/2 us */
559 #define IEEE80211_HTCAP_MPDUDENSITY_1   0x0c    /* 1 us */
560 #define IEEE80211_HTCAP_MPDUDENSITY_2   0x10    /* 2 us */
561 #define IEEE80211_HTCAP_MPDUDENSITY_4   0x14    /* 4 us */
562 #define IEEE80211_HTCAP_MPDUDENSITY_8   0x18    /* 8 us */
563 #define IEEE80211_HTCAP_MPDUDENSITY_16  0x1c    /* 16 us */
564
565 /* HT extended capabilities (hc_extcap) */
566 #define IEEE80211_HTCAP_PCO             0x0001  /* PCO capable */
567 #define IEEE80211_HTCAP_PCOTRANS        0x0006  /* PCO transition time */
568 #define IEEE80211_HTCAP_PCOTRANS_S      1
569 #define IEEE80211_HTCAP_PCOTRANS_04     0x0002  /* 400 us */
570 #define IEEE80211_HTCAP_PCOTRANS_15     0x0004  /* 1.5 ms */
571 #define IEEE80211_HTCAP_PCOTRANS_5      0x0006  /* 5 ms */
572 /* bits 3-7 reserved */
573 #define IEEE80211_HTCAP_MCSFBACK        0x0300  /* MCS feedback */
574 #define IEEE80211_HTCAP_MCSFBACK_S      8
575 #define IEEE80211_HTCAP_MCSFBACK_NONE   0x0000  /* nothing provided */
576 #define IEEE80211_HTCAP_MCSFBACK_UNSOL  0x0200  /* unsolicited feedback */
577 #define IEEE80211_HTCAP_MCSFBACK_MRQ    0x0300  /* " "+respond to MRQ */
578 #define IEEE80211_HTCAP_HTC             0x0400  /* +HTC support */
579 #define IEEE80211_HTCAP_RDR             0x0800  /* reverse direction responder*/
580 /* bits 12-15 reserved */
581
582 /*
583  * 802.11n HT Information IE
584  */
585 struct ieee80211_ie_htinfo {
586         uint8_t         hi_id;                  /* element ID */
587         uint8_t         hi_len;                 /* length in bytes */
588         uint8_t         hi_ctrlchannel;         /* primary channel */
589         uint8_t         hi_byte1;               /* ht ie byte 1 */
590         uint16_t        hi_byte23;              /* ht ie bytes 2+3 */
591         uint16_t        hi_byte45;              /* ht ie bytes 4+5 */
592         uint8_t         hi_basicmcsset[16];     /* basic MCS set */
593 } __packed;
594
595 /* byte1 */
596 #define IEEE80211_HTINFO_2NDCHAN        0x03    /* secondary/ext chan offset */
597 #define IEEE80211_HTINFO_2NDCHAN_S      0
598 #define IEEE80211_HTINFO_2NDCHAN_NONE   0x00    /* no secondary/ext channel */
599 #define IEEE80211_HTINFO_2NDCHAN_ABOVE  0x01    /* above private channel */
600 /* NB: 2 is reserved */
601 #define IEEE80211_HTINFO_2NDCHAN_BELOW  0x03    /* below primary channel */ 
602 #define IEEE80211_HTINFO_TXWIDTH        0x04    /* tx channel width */
603 #define IEEE80211_HTINFO_TXWIDTH_20     0x00    /* 20MHz width */
604 #define IEEE80211_HTINFO_TXWIDTH_2040   0x04    /* any supported width */
605 #define IEEE80211_HTINFO_RIFSMODE       0x08    /* Reduced IFS (RIFS) use */
606 #define IEEE80211_HTINFO_RIFSMODE_PROH  0x00    /* RIFS use prohibited */
607 #define IEEE80211_HTINFO_RIFSMODE_PERM  0x08    /* RIFS use permitted */
608 #define IEEE80211_HTINFO_PMSPONLY       0x10    /* PSMP required to associate */
609 #define IEEE80211_HTINFO_SIGRAN         0xe0    /* shortest Service Interval */
610 #define IEEE80211_HTINFO_SIGRAN_S       5
611 #define IEEE80211_HTINFO_SIGRAN_5       0x00    /* 5 ms */
612 /* XXX add rest */
613
614 /* bytes 2+3 */
615 #define IEEE80211_HTINFO_OPMODE         0x03    /* operating mode */
616 #define IEEE80211_HTINFO_OPMODE_S       0
617 #define IEEE80211_HTINFO_OPMODE_PURE    0x00    /* no protection */
618 #define IEEE80211_HTINFO_OPMODE_MIXED   0x01    /* protection required */       
619 #define IEEE80211_HTINFO_OPMODE_PROTOPT 0x02    /* protection optional */       
620 #define IEEE80211_HTINFO_OPMODE_TBD     0x03
621 #define IEEE80211_HTINFO_NONGF_PRESENT  0x04    /* non-GF sta's present */
622 #define IEEE80211_HTINFO_TXBL           0x08    /* transmit burst limit */
623 #define IEEE80211_HTINFO_NONHT_PRESENT  0x10    /* non-HT sta's present */
624 /* bits 5-15 reserved */
625
626 /* bytes 4+5 */
627 #define IEEE80211_HTINFO_2NDARYBEACON   0x01
628 #define IEEE80211_HTINFO_LSIGTXOPPROT   0x02
629 #define IEEE80211_HTINFO_PCO_ACTIVE     0x04
630 #define IEEE80211_HTINFO_40MHZPHASE     0x08
631
632 /* byte5 */
633 #define IEEE80211_HTINFO_BASIC_STBCMCS  0x7f
634 #define IEEE80211_HTINFO_BASIC_STBCMCS_S 0
635 #define IEEE80211_HTINFO_DUALPROTECTED  0x80
636
637 /*
638  * Management information element payloads.
639  */
640
641 enum {
642         IEEE80211_ELEMID_SSID           = 0,
643         IEEE80211_ELEMID_RATES          = 1,
644         IEEE80211_ELEMID_FHPARMS        = 2,
645         IEEE80211_ELEMID_DSPARMS        = 3,
646         IEEE80211_ELEMID_CFPARMS        = 4,
647         IEEE80211_ELEMID_TIM            = 5,
648         IEEE80211_ELEMID_IBSSPARMS      = 6,
649         IEEE80211_ELEMID_COUNTRY        = 7,
650         IEEE80211_ELEMID_CHALLENGE      = 16,
651         /* 17-31 reserved for challenge text extension */
652         IEEE80211_ELEMID_PWRCNSTR       = 32,
653         IEEE80211_ELEMID_PWRCAP         = 33,
654         IEEE80211_ELEMID_TPCREQ         = 34,
655         IEEE80211_ELEMID_TPCREP         = 35,
656         IEEE80211_ELEMID_SUPPCHAN       = 36,
657         IEEE80211_ELEMID_CHANSWITCHANN  = 37,
658         IEEE80211_ELEMID_MEASREQ        = 38,
659         IEEE80211_ELEMID_MEASREP        = 39,
660         IEEE80211_ELEMID_QUIET          = 40,
661         IEEE80211_ELEMID_IBSSDFS        = 41,
662         IEEE80211_ELEMID_ERP            = 42,
663         IEEE80211_ELEMID_HTCAP          = 45,
664         IEEE80211_ELEMID_RSN            = 48,
665         IEEE80211_ELEMID_XRATES         = 50,
666         IEEE80211_ELEMID_HTINFO         = 61,
667         IEEE80211_ELEMID_TPC            = 150,
668         IEEE80211_ELEMID_CCKM           = 156,
669         IEEE80211_ELEMID_VENDOR         = 221,  /* vendor private */
670 };
671
672 struct ieee80211_tim_ie {
673         uint8_t         tim_ie;                 /* IEEE80211_ELEMID_TIM */
674         uint8_t         tim_len;
675         uint8_t         tim_count;              /* DTIM count */
676         uint8_t         tim_period;             /* DTIM period */
677         uint8_t         tim_bitctl;             /* bitmap control */
678         uint8_t         tim_bitmap[1];          /* variable-length bitmap */
679 } __packed;
680
681 struct ieee80211_country_ie {
682         uint8_t         ie;                     /* IEEE80211_ELEMID_COUNTRY */
683         uint8_t         len;
684         uint8_t         cc[3];                  /* ISO CC+(I)ndoor/(O)utdoor */
685         struct {
686                 uint8_t schan;                  /* starting channel */
687                 uint8_t nchan;                  /* number channels */
688                 uint8_t maxtxpwr;               /* tx power cap */
689         } __packed band[4];                     /* up to 4 sub bands */
690 } __packed;
691
692 /*
693  * Atheros advanced capability information element.
694  */
695 struct ieee80211_ath_ie {
696         uint8_t         ath_id;                 /* IEEE80211_ELEMID_VENDOR */
697         uint8_t         ath_len;                /* length in bytes */
698         uint8_t         ath_oui[3];             /* 0x00, 0x03, 0x7f */
699         uint8_t         ath_oui_type;           /* OUI type */
700         uint8_t         ath_oui_subtype;        /* OUI subtype */
701         uint8_t         ath_version;            /* spec revision */
702         uint8_t         ath_capability;         /* capability info */
703 #define ATHEROS_CAP_TURBO_PRIME         0x01    /* dynamic turbo--aka Turbo' */
704 #define ATHEROS_CAP_COMPRESSION         0x02    /* data compression */
705 #define ATHEROS_CAP_FAST_FRAME          0x04    /* fast (jumbo) frames */
706 #define ATHEROS_CAP_XR                  0x08    /* Xtended Range support */
707 #define ATHEROS_CAP_AR                  0x10    /* Advanded Radar support */
708 #define ATHEROS_CAP_BURST               0x20    /* Bursting - not negotiated */
709 #define ATHEROS_CAP_WME                 0x40    /* CWMin tuning */
710 #define ATHEROS_CAP_BOOST               0x80    /* use turbo/!turbo mode */
711         uint8_t         ath_defkeyix[2];
712 } __packed;
713
714 #define IEEE80211_CHALLENGE_LEN         128
715
716 #define IEEE80211_RATE_BASIC            0x80
717 #define IEEE80211_RATE_VAL              0x7f
718
719 /* EPR information element flags */
720 #define IEEE80211_ERP_NON_ERP_PRESENT   0x01
721 #define IEEE80211_ERP_USE_PROTECTION    0x02
722 #define IEEE80211_ERP_LONG_PREAMBLE     0x04
723
724 #define ATH_OUI                 0x7f0300        /* Atheros OUI */
725 #define ATH_OUI_TYPE            0x01
726 #define ATH_OUI_SUBTYPE         0x01
727 #define ATH_OUI_VERSION         0x00
728
729 #define BCM_OUI                 0x4c9000        /* Broadcom OUI */
730 #define BCM_OUI_HTCAP           51              /* pre-draft HTCAP ie */
731 #define BCM_OUI_HTINFO          52              /* pre-draft HTINFO ie */
732
733 #define WPA_OUI                 0xf25000
734 #define WPA_OUI_TYPE            0x01
735 #define WPA_VERSION             1               /* current supported version */
736
737 #define WPA_CSE_NULL            0x00
738 #define WPA_CSE_WEP40           0x01
739 #define WPA_CSE_TKIP            0x02
740 #define WPA_CSE_CCMP            0x04
741 #define WPA_CSE_WEP104          0x05
742
743 #define WPA_ASE_NONE            0x00
744 #define WPA_ASE_8021X_UNSPEC    0x01
745 #define WPA_ASE_8021X_PSK       0x02
746
747 #define RSN_OUI                 0xac0f00
748 #define RSN_VERSION             1               /* current supported version */
749
750 #define RSN_CSE_NULL            0x00
751 #define RSN_CSE_WEP40           0x01
752 #define RSN_CSE_TKIP            0x02
753 #define RSN_CSE_WRAP            0x03
754 #define RSN_CSE_CCMP            0x04
755 #define RSN_CSE_WEP104          0x05
756
757 #define RSN_ASE_NONE            0x00
758 #define RSN_ASE_8021X_UNSPEC    0x01
759 #define RSN_ASE_8021X_PSK       0x02
760
761 #define RSN_CAP_PREAUTH         0x01
762
763 #define WME_OUI                 0xf25000
764 #define WME_OUI_TYPE            0x02
765 #define WME_INFO_OUI_SUBTYPE    0x00
766 #define WME_PARAM_OUI_SUBTYPE   0x01
767 #define WME_VERSION             1
768
769 /* WME stream classes */
770 #define WME_AC_BE       0               /* best effort */
771 #define WME_AC_BK       1               /* background */
772 #define WME_AC_VI       2               /* video */
773 #define WME_AC_VO       3               /* voice */
774
775 /*
776  * AUTH management packets
777  *
778  *      octet algo[2]
779  *      octet seq[2]
780  *      octet status[2]
781  *      octet chal.id
782  *      octet chal.length
783  *      octet chal.text[253]
784  */
785
786 typedef uint8_t *ieee80211_mgt_auth_t;
787
788 #define IEEE80211_AUTH_ALGORITHM(auth) \
789         ((auth)[0] | ((auth)[1] << 8))
790 #define IEEE80211_AUTH_TRANSACTION(auth) \
791         ((auth)[2] | ((auth)[3] << 8))
792 #define IEEE80211_AUTH_STATUS(auth) \
793         ((auth)[4] | ((auth)[5] << 8))
794
795 #define IEEE80211_AUTH_ALG_OPEN         0x0000
796 #define IEEE80211_AUTH_ALG_SHARED       0x0001
797 #define IEEE80211_AUTH_ALG_LEAP         0x0080
798
799 enum {
800         IEEE80211_AUTH_OPEN_REQUEST             = 1,
801         IEEE80211_AUTH_OPEN_RESPONSE            = 2,
802 };
803
804 enum {
805         IEEE80211_AUTH_SHARED_REQUEST           = 1,
806         IEEE80211_AUTH_SHARED_CHALLENGE         = 2,
807         IEEE80211_AUTH_SHARED_RESPONSE          = 3,
808         IEEE80211_AUTH_SHARED_PASS              = 4,
809 };
810
811 /*
812  * Reason codes
813  *
814  * Unlisted codes are reserved
815  */
816
817 enum {
818         IEEE80211_REASON_UNSPECIFIED            = 1,
819         IEEE80211_REASON_AUTH_EXPIRE            = 2,
820         IEEE80211_REASON_AUTH_LEAVE             = 3,
821         IEEE80211_REASON_ASSOC_EXPIRE           = 4,
822         IEEE80211_REASON_ASSOC_TOOMANY          = 5,
823         IEEE80211_REASON_NOT_AUTHED             = 6,
824         IEEE80211_REASON_NOT_ASSOCED            = 7,
825         IEEE80211_REASON_ASSOC_LEAVE            = 8,
826         IEEE80211_REASON_ASSOC_NOT_AUTHED       = 9,
827
828         IEEE80211_REASON_RSN_REQUIRED           = 11,
829         IEEE80211_REASON_RSN_INCONSISTENT       = 12,
830         IEEE80211_REASON_IE_INVALID             = 13,
831         IEEE80211_REASON_MIC_FAILURE            = 14,
832
833         IEEE80211_STATUS_SUCCESS                = 0,
834         IEEE80211_STATUS_UNSPECIFIED            = 1,
835         IEEE80211_STATUS_CAPINFO                = 10,
836         IEEE80211_STATUS_NOT_ASSOCED            = 11,
837         IEEE80211_STATUS_OTHER                  = 12,
838         IEEE80211_STATUS_ALG                    = 13,
839         IEEE80211_STATUS_SEQUENCE               = 14,
840         IEEE80211_STATUS_CHALLENGE              = 15,
841         IEEE80211_STATUS_TIMEOUT                = 16,
842         IEEE80211_STATUS_TOOMANY                = 17,
843         IEEE80211_STATUS_BASIC_RATE             = 18,
844         IEEE80211_STATUS_SP_REQUIRED            = 19,
845         IEEE80211_STATUS_PBCC_REQUIRED          = 20,
846         IEEE80211_STATUS_CA_REQUIRED            = 21,
847         IEEE80211_STATUS_TOO_MANY_STATIONS      = 22,
848         IEEE80211_STATUS_RATES                  = 23,
849         IEEE80211_STATUS_SHORTSLOT_REQUIRED     = 25,
850         IEEE80211_STATUS_DSSSOFDM_REQUIRED      = 26,
851 };
852
853 #define IEEE80211_WEP_KEYLEN            5       /* 40bit */
854 #define IEEE80211_WEP_IVLEN             3       /* 24bit */
855 #define IEEE80211_WEP_KIDLEN            1       /* 1 octet */
856 #define IEEE80211_WEP_CRCLEN            4       /* CRC-32 */
857 #define IEEE80211_WEP_NKID              4       /* number of key ids */
858
859 /*
860  * 802.11i defines an extended IV for use with non-WEP ciphers.
861  * When the EXTIV bit is set in the key id byte an additional
862  * 4 bytes immediately follow the IV for TKIP.  For CCMP the
863  * EXTIV bit is likewise set but the 8 bytes represent the
864  * CCMP header rather than IV+extended-IV.
865  */
866 #define IEEE80211_WEP_EXTIV             0x20
867 #define IEEE80211_WEP_EXTIVLEN          4       /* extended IV length */
868 #define IEEE80211_WEP_MICLEN            8       /* trailing MIC */
869
870 #define IEEE80211_CRC_LEN               4
871
872 /*
873  * Maximum acceptable MTU is:
874  *      IEEE80211_MAX_LEN - WEP overhead - CRC -
875  *              QoS overhead - RSN/WPA overhead
876  * Min is arbitrarily chosen > IEEE80211_MIN_LEN.  The default
877  * mtu is Ethernet-compatible; it's set by ether_ifattach.
878  */
879 #define IEEE80211_MTU_MAX               2290
880 #define IEEE80211_MTU_MIN               32
881
882 #define IEEE80211_MAX_LEN               (2300 + IEEE80211_CRC_LEN + \
883     (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
884 #define IEEE80211_ACK_LEN \
885         (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
886 #define IEEE80211_MIN_LEN \
887         (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
888
889 /*
890  * The 802.11 spec says at most 2007 stations may be
891  * associated at once.  For most AP's this is way more
892  * than is feasible so we use a default of 128.  This
893  * number may be overridden by the driver and/or by
894  * user configuration.
895  */
896 #define IEEE80211_AID_MAX               2007
897 #define IEEE80211_AID_DEF               128
898
899 #define IEEE80211_AID(b)        ((b) &~ 0xc000)
900
901 /* 
902  * RTS frame length parameters.  The default is specified in
903  * the 802.11 spec as 512; we treat it as implementation-dependent
904  * so it's defined in ieee80211_var.h.  The max may be wrong
905  * for jumbo frames.
906  */
907 #define IEEE80211_RTS_MIN               1
908 #define IEEE80211_RTS_MAX               2346
909
910 /* 
911  * TX fragmentation parameters.  As above for RTS, we treat
912  * default as implementation-dependent so define it elsewhere.
913  */
914 #define IEEE80211_FRAG_MIN              256
915 #define IEEE80211_FRAG_MAX              2346
916
917 /*
918  * Beacon interval (TU's).  Min+max come from WiFi requirements.
919  * As above, we treat default as implementation-dependent so
920  * define it elsewhere.
921  */
922 #define IEEE80211_BINTVAL_MAX   1000    /* max beacon interval (TU's) */
923 #define IEEE80211_BINTVAL_MIN   25      /* min beacon interval (TU's) */
924
925 /*
926  * DTIM period (beacons).  Min+max are not really defined
927  * by the protocol but we want them publicly visible so
928  * define them here.
929  */
930 #define IEEE80211_DTIM_MAX      15      /* max DTIM period */
931 #define IEEE80211_DTIM_MIN      1       /* min DTIM period */
932
933 /*
934  * Beacon miss threshold (beacons).  As for DTIM, we define
935  * them here to be publicly visible.  Note the max may be
936  * clamped depending on device capabilities.
937  */
938 #define IEEE80211_HWBMISS_MIN   1
939 #define IEEE80211_HWBMISS_MAX   255
940
941 /*
942  * 802.11 frame duration definitions.
943  */
944
945 struct ieee80211_duration {
946         uint16_t        d_rts_dur;
947         uint16_t        d_data_dur;
948         uint16_t        d_plcp_len;
949         uint8_t         d_residue;      /* unused octets in time slot */
950 };
951
952 /* One Time Unit (TU) is 1Kus = 1024 microseconds. */
953 #define IEEE80211_DUR_TU                1024
954
955 /* IEEE 802.11b durations for DSSS PHY in microseconds */
956 #define IEEE80211_DUR_DS_LONG_PREAMBLE  144
957 #define IEEE80211_DUR_DS_SHORT_PREAMBLE 72
958
959 #define IEEE80211_DUR_DS_SLOW_PLCPHDR   48
960 #define IEEE80211_DUR_DS_FAST_PLCPHDR   24
961 #define IEEE80211_DUR_DS_SLOW_ACK       112
962 #define IEEE80211_DUR_DS_FAST_ACK       56
963 #define IEEE80211_DUR_DS_SLOW_CTS       112
964 #define IEEE80211_DUR_DS_FAST_CTS       56
965
966 #define IEEE80211_DUR_DS_SLOT           20
967 #define IEEE80211_DUR_DS_SIFS           10
968 #define IEEE80211_DUR_DS_PIFS   (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT)
969 #define IEEE80211_DUR_DS_DIFS   (IEEE80211_DUR_DS_SIFS + \
970                                  2 * IEEE80211_DUR_DS_SLOT)
971 #define IEEE80211_DUR_DS_EIFS   (IEEE80211_DUR_DS_SIFS + \
972                                  IEEE80211_DUR_DS_SLOW_ACK + \
973                                  IEEE80211_DUR_DS_LONG_PREAMBLE + \
974                                  IEEE80211_DUR_DS_SLOW_PLCPHDR + \
975                                  IEEE80211_DUR_DIFS)
976
977 /*
978  * Atheros fast-frame encapsulation format.
979  * FF max payload:
980  * 802.2 + FFHDR + HPAD + 802.3 + 802.2 + 1500 + SPAD + 802.3 + 802.2 + 1500:
981  *   8   +   4   +  4   +   14  +   8   + 1500 +  6   +   14  +   8   + 1500
982  * = 3066
983  */
984 /* fast frame header is 32-bits */
985 #define ATH_FF_PROTO    0x0000003f      /* protocol */
986 #define ATH_FF_PROTO_S  0
987 #define ATH_FF_FTYPE    0x000000c0      /* frame type */
988 #define ATH_FF_FTYPE_S  6
989 #define ATH_FF_HLEN32   0x00000300      /* optional hdr length */
990 #define ATH_FF_HLEN32_S 8
991 #define ATH_FF_SEQNUM   0x001ffc00      /* sequence number */
992 #define ATH_FF_SEQNUM_S 10
993 #define ATH_FF_OFFSET   0xffe00000      /* offset to 2nd payload */
994 #define ATH_FF_OFFSET_S 21
995
996 #define ATH_FF_MAX_HDR_PAD      4
997 #define ATH_FF_MAX_SEP_PAD      6
998 #define ATH_FF_MAX_HDR          30
999
1000 #define ATH_FF_PROTO_L2TUNNEL   0       /* L2 tunnel protocol */
1001 #define ATH_FF_ETH_TYPE         0x88bd  /* Ether type for encapsulated frames */
1002 #define ATH_FF_SNAP_ORGCODE_0   0x00
1003 #define ATH_FF_SNAP_ORGCODE_1   0x03
1004 #define ATH_FF_SNAP_ORGCODE_2   0x7f
1005
1006 #endif /* _NET80211_IEEE80211_H_ */