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