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