fix a typo in my netfilter commit - worked for iptables, didn't work for the kernel...
[openwrt/svn-archive/archive.git] / package / nvram / src / include / proto / 802.11.h
1 /*
2 * Copyright 2004, Broadcom Corporation
3 * All Rights Reserved.
4 *
5 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9 *
10 * Fundamental types and constants relating to 802.11
11 *
12 * $Id$
13 */
14
15 #ifndef _802_11_H_
16 #define _802_11_H_
17
18 #ifndef _TYPEDEFS_H_
19 #include <typedefs.h>
20 #endif
21
22 #ifndef _NET_ETHERNET_H_
23 #include <proto/ethernet.h>
24 #endif
25
26 /* enable structure packing */
27 #if !defined(__GNUC__)
28 #pragma pack(1)
29 #endif
30
31 /* some platforms require stronger medicine */
32 #if defined(__GNUC__)
33 #define PACKED __attribute__((packed))
34 #else
35 #define PACKED
36 #endif
37
38
39 #define DOT11_TU_TO_US 1024 /* 802.11 Time Unit is 1024 microseconds */
40
41 /* Generic 802.11 frame constants */
42 #define DOT11_A3_HDR_LEN 24
43 #define DOT11_A4_HDR_LEN 30
44 #define DOT11_MAC_HDR_LEN DOT11_A3_HDR_LEN
45 #define DOT11_FCS_LEN 4
46 #define DOT11_ICV_LEN 4
47 #define DOT11_ICV_AES_LEN 8
48 #define DOT11_QOS_LEN 2
49
50 #define DOT11_KEY_INDEX_SHIFT 6
51 #define DOT11_IV_LEN 4
52 #define DOT11_IV_TKIP_LEN 8
53 #define DOT11_IV_AES_OCB_LEN 4
54 #define DOT11_IV_AES_CCM_LEN 8
55
56 /* Includes MIC */
57 #define DOT11_MAX_MPDU_BODY_LEN 2304
58 /* A4 header + QoS + CCMP + PDU + ICV + FCS = 2352 */
59 #define DOT11_MAX_MPDU_LEN (DOT11_A4_HDR_LEN + \
60 DOT11_QOS_LEN + \
61 DOT11_IV_AES_CCM_LEN + \
62 DOT11_MAX_MPDU_BODY_LEN + \
63 DOT11_ICV_LEN + \
64 DOT11_FCS_LEN)
65
66 #define DOT11_MAX_SSID_LEN 32
67
68 /* dot11RTSThreshold */
69 #define DOT11_DEFAULT_RTS_LEN 2347
70 #define DOT11_MAX_RTS_LEN 2347
71
72 /* dot11FragmentationThreshold */
73 #define DOT11_MIN_FRAG_LEN 256
74 #define DOT11_MAX_FRAG_LEN 2346 /* Max frag is also limited by aMPDUMaxLength of the attached PHY */
75 #define DOT11_DEFAULT_FRAG_LEN 2346
76
77 /* dot11BeaconPeriod */
78 #define DOT11_MIN_BEACON_PERIOD 1
79 #define DOT11_MAX_BEACON_PERIOD 0xFFFF
80
81 /* dot11DTIMPeriod */
82 #define DOT11_MIN_DTIM_PERIOD 1
83 #define DOT11_MAX_DTIM_PERIOD 0xFF
84
85 /* 802.2 LLC/SNAP header used by 802.11 per 802.1H */
86 #define DOT11_LLC_SNAP_HDR_LEN 8
87 #define DOT11_OUI_LEN 3
88 struct dot11_llc_snap_header {
89 uint8 dsap; /* always 0xAA */
90 uint8 ssap; /* always 0xAA */
91 uint8 ctl; /* always 0x03 */
92 uint8 oui[DOT11_OUI_LEN]; /* RFC1042: 0x00 0x00 0x00
93 Bridge-Tunnel: 0x00 0x00 0xF8 */
94 uint16 type; /* ethertype */
95 } PACKED;
96
97 /* RFC1042 header used by 802.11 per 802.1H */
98 #define RFC1042_HDR_LEN (ETHER_HDR_LEN + DOT11_LLC_SNAP_HDR_LEN)
99
100 /* Generic 802.11 MAC header */
101 /*
102 * N.B.: This struct reflects the full 4 address 802.11 MAC header.
103 * The fields are defined such that the shorter 1, 2, and 3
104 * address headers just use the first k fields.
105 */
106 struct dot11_header {
107 uint16 fc; /* frame control */
108 uint16 durid; /* duration/ID */
109 struct ether_addr a1; /* address 1 */
110 struct ether_addr a2; /* address 2 */
111 struct ether_addr a3; /* address 3 */
112 uint16 seq; /* sequence control */
113 struct ether_addr a4; /* address 4 */
114 } PACKED;
115
116 /* Control frames */
117
118 struct dot11_rts_frame {
119 uint16 fc; /* frame control */
120 uint16 durid; /* duration/ID */
121 struct ether_addr ra; /* receiver address */
122 struct ether_addr ta; /* transmitter address */
123 } PACKED;
124 #define DOT11_RTS_LEN 16
125
126 struct dot11_cts_frame {
127 uint16 fc; /* frame control */
128 uint16 durid; /* duration/ID */
129 struct ether_addr ra; /* receiver address */
130 } PACKED;
131 #define DOT11_CTS_LEN 10
132
133 struct dot11_ack_frame {
134 uint16 fc; /* frame control */
135 uint16 durid; /* duration/ID */
136 struct ether_addr ra; /* receiver address */
137 } PACKED;
138 #define DOT11_ACK_LEN 10
139
140 struct dot11_ps_poll_frame {
141 uint16 fc; /* frame control */
142 uint16 durid; /* AID */
143 struct ether_addr bssid; /* receiver address, STA in AP */
144 struct ether_addr ta; /* transmitter address */
145 } PACKED;
146 #define DOT11_PS_POLL_LEN 16
147
148 struct dot11_cf_end_frame {
149 uint16 fc; /* frame control */
150 uint16 durid; /* duration/ID */
151 struct ether_addr ra; /* receiver address */
152 struct ether_addr bssid; /* transmitter address, STA in AP */
153 } PACKED;
154 #define DOT11_CS_END_LEN 16
155
156 /* Management frame header */
157 struct dot11_management_header {
158 uint16 fc; /* frame control */
159 uint16 durid; /* duration/ID */
160 struct ether_addr da; /* receiver address */
161 struct ether_addr sa; /* transmitter address */
162 struct ether_addr bssid; /* BSS ID */
163 uint16 seq; /* sequence control */
164 } PACKED;
165 #define DOT11_MGMT_HDR_LEN 24
166
167 /* Management frame payloads */
168
169 struct dot11_bcn_prb {
170 uint32 timestamp[2];
171 uint16 beacon_interval;
172 uint16 capability;
173 } PACKED;
174 #define DOT11_BCN_PRB_LEN 12
175
176 struct dot11_auth {
177 uint16 alg; /* algorithm */
178 uint16 seq; /* sequence control */
179 uint16 status; /* status code */
180 } PACKED;
181 #define DOT11_AUTH_FIXED_LEN 6 /* length of auth frame without challenge info elt */
182
183 struct dot11_assoc_req {
184 uint16 capability; /* capability information */
185 uint16 listen; /* listen interval */
186 } PACKED;
187
188 struct dot11_assoc_resp {
189 uint16 capability; /* capability information */
190 uint16 status; /* status code */
191 uint16 aid; /* association ID */
192 } PACKED;
193
194 struct dot11_action_measure {
195 uint8 category;
196 uint8 action;
197 uint8 token;
198 uint8 data[1];
199 } PACKED;
200 #define DOT11_ACTION_MEASURE_LEN 3
201
202 /**************
203 802.11h related definitions.
204 **************/
205 typedef struct {
206 uint8 id;
207 uint8 len;
208 uint8 power;
209 } dot11_power_cnst_t;
210
211 typedef struct {
212 uint8 min;
213 uint8 max;
214 } dot11_power_cap_t;
215
216 typedef struct {
217 uint8 id;
218 uint8 len;
219 uint8 tx_pwr;
220 uint8 margin;
221 } dot11_tpc_rep_t;
222 #define DOT11_MNG_IE_TPC_REPORT_LEN 2 /* length of IE data, not including 2 byte header */
223
224 typedef struct {
225 uint8 id;
226 uint8 len;
227 uint8 first_channel;
228 uint8 num_channels;
229 } dot11_supp_channels_t;
230
231 struct dot11_channel_switch {
232 uint8 id;
233 uint8 len;
234 uint8 mode;
235 uint8 channel;
236 uint8 count;
237 } PACKED;
238 typedef struct dot11_channel_switch dot11_channel_switch_t;
239
240 /* 802.11h Measurement Request/Report IEs */
241 /* Measurement Type field */
242 #define DOT11_MEASURE_TYPE_BASIC 0
243 #define DOT11_MEASURE_TYPE_CCA 1
244 #define DOT11_MEASURE_TYPE_RPI 2
245
246 /* Measurement Mode field */
247
248 /* Measurement Request Modes */
249 #define DOT11_MEASURE_MODE_ENABLE (1<<1)
250 #define DOT11_MEASURE_MODE_REQUEST (1<<2)
251 #define DOT11_MEASURE_MODE_REPORT (1<<3)
252 /* Measurement Report Modes */
253 #define DOT11_MEASURE_MODE_LATE (1<<0)
254 #define DOT11_MEASURE_MODE_INCAPABLE (1<<1)
255 #define DOT11_MEASURE_MODE_REFUSED (1<<2)
256 /* Basic Measurement Map bits */
257 #define DOT11_MEASURE_BASIC_MAP_BSS ((uint8)(1<<0))
258 #define DOT11_MEASURE_BASIC_MAP_OFDM ((uint8)(1<<1))
259 #define DOT11_MEASURE_BASIC_MAP_UKNOWN ((uint8)(1<<2))
260 #define DOT11_MEASURE_BASIC_MAP_RADAR ((uint8)(1<<3))
261 #define DOT11_MEASURE_BASIC_MAP_UNMEAS ((uint8)(1<<4))
262
263 typedef struct {
264 uint8 id;
265 uint8 len;
266 uint8 token;
267 uint8 mode;
268 uint8 type;
269 uint8 channel;
270 uint8 start_time[8];
271 uint16 duration;
272 } dot11_meas_req_t;
273 #define DOT11_MNG_IE_MREQ_LEN 14
274 /* length of Measure Request IE data not including variable len */
275 #define DOT11_MNG_IE_MREQ_FIXED_LEN 3
276
277 struct dot11_meas_rep {
278 uint8 id;
279 uint8 len;
280 uint8 token;
281 uint8 mode;
282 uint8 type;
283 union
284 {
285 struct {
286 uint8 channel;
287 uint8 start_time[8];
288 uint16 duration;
289 uint8 map;
290 } PACKED basic;
291 uint8 data[1];
292 } PACKED rep;
293 } PACKED;
294 typedef struct dot11_meas_rep dot11_meas_rep_t;
295
296 /* length of Measure Report IE data not including variable len */
297 #define DOT11_MNG_IE_MREP_FIXED_LEN 3
298
299 struct dot11_meas_rep_basic {
300 uint8 channel;
301 uint8 start_time[8];
302 uint16 duration;
303 uint8 map;
304 } PACKED;
305 typedef struct dot11_meas_rep_basic dot11_meas_rep_basic_t;
306 #define DOT11_MEASURE_BASIC_REP_LEN 12
307
308 struct dot11_quiet {
309 uint8 id;
310 uint8 len;
311 uint8 count; /* TBTTs until beacon interval in quiet starts */
312 uint8 period; /* Beacon intervals between periodic quiet periods ? */
313 uint16 duration;/* Length of quiet period, in TU's */
314 uint16 offset; /* TU's offset from TBTT in Count field */
315 } PACKED;
316 typedef struct dot11_quiet dot11_quiet_t;
317
318 typedef struct {
319 uint8 channel;
320 uint8 map;
321 } chan_map_tuple_t;
322
323 typedef struct {
324 uint8 id;
325 uint8 len;
326 uint8 eaddr[ETHER_ADDR_LEN];
327 uint8 interval;
328 chan_map_tuple_t map[1];
329 } dot11_ibss_dfs_t;
330
331 /* WME Elements */
332 #define WME_OUI "\x00\x50\xf2"
333 #define WME_VER 1
334 #define WME_TYPE 2
335 #define WME_SUBTYPE_IE 0 /* Information Element */
336 #define WME_SUBTYPE_PARAM_IE 1 /* Parameter Element */
337 #define WME_SUBTYPE_TSPEC 2 /* Traffic Specification */
338
339 /* WME Access Category Indices (ACIs) */
340 #define AC_BE 0 /* Best Effort */
341 #define AC_BK 1 /* Background */
342 #define AC_VI 2 /* Video */
343 #define AC_VO 3 /* Voice */
344 #define AC_MAX 4
345
346 /* WME Information Element (IE) */
347 struct wme_ie {
348 uint8 oui[3];
349 uint8 type;
350 uint8 subtype;
351 uint8 version;
352 uint8 acinfo;
353 } PACKED;
354 typedef struct wme_ie wme_ie_t;
355 #define WME_IE_LEN 7
356
357 struct wme_acparam {
358 uint8 ACI;
359 uint8 ECW;
360 uint16 TXOP; /* stored in network order (ls octet first) */
361 } PACKED;
362 typedef struct wme_acparam wme_acparam_t;
363
364 /* WME Parameter Element (PE) */
365 struct wme_params {
366 uint8 oui[3];
367 uint8 type;
368 uint8 subtype;
369 uint8 version;
370 uint8 acinfo;
371 uint8 rsvd;
372 wme_acparam_t acparam[4];
373 } PACKED;
374 typedef struct wme_params wme_params_t;
375 #define WME_PARAMS_IE_LEN 24
376
377 /* acinfo */
378 #define WME_COUNT_MASK 0x0f
379 /* ACI */
380 #define WME_AIFS_MASK 0x0f
381 #define WME_ACM_MASK 0x10
382 #define WME_ACI_MASK 0x60
383 #define WME_ACI_SHIFT 5
384 /* ECW */
385 #define WME_CWMIN_MASK 0x0f
386 #define WME_CWMAX_MASK 0xf0
387 #define WME_CWMAX_SHIFT 4
388
389 #define WME_TXOP_UNITS 32
390
391 /* WME Traffic Specification (TSPEC) element */
392 #define WME_SUBTYPE_TSPEC 2
393 #define WME_TSPEC_HDR_LEN 2
394 #define WME_TSPEC_BODY_OFF 2
395 struct wme_tspec {
396 uint8 oui[DOT11_OUI_LEN]; /* WME_OUI */
397 uint8 type; /* WME_TYPE */
398 uint8 subtype; /* WME_SUBTYPE_TSPEC */
399 uint8 version; /* WME_VERSION */
400 uint16 ts_info; /* TS Info */
401 uint16 nom_msdu_size; /* (Nominal or fixed) MSDU Size (bytes) */
402 uint16 max_msdu_size; /* Maximum MSDU Size (bytes) */
403 uint32 min_service_interval; /* Minimum Service Interval (us) */
404 uint32 max_service_interval; /* Maximum Service Interval (us) */
405 uint32 inactivity_interval; /* Inactivity Interval (us) */
406 uint32 service_start; /* Service Start Time (us) */
407 uint32 min_rate; /* Minimum Data Rate (bps) */
408 uint32 mean_rate; /* Mean Data Rate (bps) */
409 uint32 max_burst_size; /* Maximum Burst Size (bytes) */
410 uint32 min_phy_rate; /* Minimum PHY Rate (bps) */
411 uint32 peak_rate; /* Peak Data Rate (bps) */
412 uint32 delay_bound; /* Delay Bound (us) */
413 uint16 surplus_bandwidth; /* Surplus Bandwidth Allowance Factor */
414 uint16 medium_time; /* Medium Time (32 us/s periods) */
415 } PACKED;
416 typedef struct wme_tspec wme_tspec_t;
417 #define WME_TSPEC_LEN 56 /* not including 2-byte header */
418
419 /* ts_info */
420 /* 802.1D priority is duplicated - bits 13-11 AND bits 3-1 */
421 #define TS_INFO_PRIO_SHIFT_HI 11
422 #define TS_INFO_PRIO_MASK_HI (0x7 << TS_INFO_PRIO_SHIFT_HI)
423 #define TS_INFO_PRIO_SHIFT_LO 1
424 #define TS_INFO_PRIO_MASK_LO (0x7 << TS_INFO_PRIO_SHIFT_LO)
425 #define TS_INFO_CONTENTION_SHIFT 7
426 #define TS_INFO_CONTENTION_MASK (0x1 << TS_INFO_CONTENTION_SHIFT)
427 #define TS_INFO_DIRECTION_SHIFT 5
428 #define TS_INFO_DIRECTION_MASK (0x3 << TS_INFO_DIRECTION_SHIFT)
429 #define TS_INFO_UPLINK (0 << TS_INFO_DIRECTION_SHIFT)
430 #define TS_INFO_DOWNLINK (1 << TS_INFO_DIRECTION_SHIFT)
431 #define TS_INFO_BIDIRECTIONAL (3 << TS_INFO_DIRECTION_SHIFT)
432
433 /* nom_msdu_size */
434 #define FIXED_MSDU_SIZE 0x8000 /* MSDU size is fixed */
435 #define MSDU_SIZE_MASK 0x7fff /* (Nominal or fixed) MSDU size */
436
437 /* surplus_bandwidth */
438 /* Represented as 3 bits of integer, binary point, 13 bits fraction */
439 #define INTEGER_SHIFT 13
440 #define FRACTION_MASK 0x1FFF
441
442 /* Management Notification Frame */
443 struct dot11_management_notification {
444 uint8 category; /* DOT11_ACTION_NOTIFICATION */
445 uint8 action;
446 uint8 token;
447 uint8 status;
448 uint8 data[1]; /* Elements */
449 } PACKED;
450 #define DOT11_MGMT_NOTIFICATION_LEN 4 /* Fixed length */
451
452 /* WME Action Codes */
453 #define WME_SETUP_REQUEST 0
454 #define WME_SETUP_RESPONSE 1
455 #define WME_TEARDOWN 2
456
457 /* WME Setup Response Status Codes */
458 #define WME_ADMISSION_ACCEPTED 0
459 #define WME_INVALID_PARAMETERS 1
460 #define WME_ADMISSION_REFUSED 3
461
462 /* Macro to take a pointer to a beacon or probe response
463 * header and return the char* pointer to the SSID info element
464 */
465 #define BCN_PRB_SSID(hdr) ((char*)(hdr) + DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_LEN)
466
467 /* Authentication frame payload constants */
468 #define DOT11_OPEN_SYSTEM 0
469 #define DOT11_SHARED_KEY 1
470 #define DOT11_CHALLENGE_LEN 128
471
472 /* Frame control macros */
473 #define FC_PVER_MASK 0x3
474 #define FC_PVER_SHIFT 0
475 #define FC_TYPE_MASK 0xC
476 #define FC_TYPE_SHIFT 2
477 #define FC_SUBTYPE_MASK 0xF0
478 #define FC_SUBTYPE_SHIFT 4
479 #define FC_TODS 0x100
480 #define FC_TODS_SHIFT 8
481 #define FC_FROMDS 0x200
482 #define FC_FROMDS_SHIFT 9
483 #define FC_MOREFRAG 0x400
484 #define FC_MOREFRAG_SHIFT 10
485 #define FC_RETRY 0x800
486 #define FC_RETRY_SHIFT 11
487 #define FC_PM 0x1000
488 #define FC_PM_SHIFT 12
489 #define FC_MOREDATA 0x2000
490 #define FC_MOREDATA_SHIFT 13
491 #define FC_WEP 0x4000
492 #define FC_WEP_SHIFT 14
493 #define FC_ORDER 0x8000
494 #define FC_ORDER_SHIFT 15
495
496 /* sequence control macros */
497 #define SEQNUM_SHIFT 4
498 #define FRAGNUM_MASK 0xF
499
500 /* Frame Control type/subtype defs */
501
502 /* FC Types */
503 #define FC_TYPE_MNG 0
504 #define FC_TYPE_CTL 1
505 #define FC_TYPE_DATA 2
506
507 /* Management Subtypes */
508 #define FC_SUBTYPE_ASSOC_REQ 0
509 #define FC_SUBTYPE_ASSOC_RESP 1
510 #define FC_SUBTYPE_REASSOC_REQ 2
511 #define FC_SUBTYPE_REASSOC_RESP 3
512 #define FC_SUBTYPE_PROBE_REQ 4
513 #define FC_SUBTYPE_PROBE_RESP 5
514 #define FC_SUBTYPE_BEACON 8
515 #define FC_SUBTYPE_ATIM 9
516 #define FC_SUBTYPE_DISASSOC 10
517 #define FC_SUBTYPE_AUTH 11
518 #define FC_SUBTYPE_DEAUTH 12
519 #define FC_SUBTYPE_ACTION 13
520
521 /* Control Subtypes */
522 #define FC_SUBTYPE_PS_POLL 10
523 #define FC_SUBTYPE_RTS 11
524 #define FC_SUBTYPE_CTS 12
525 #define FC_SUBTYPE_ACK 13
526 #define FC_SUBTYPE_CF_END 14
527 #define FC_SUBTYPE_CF_END_ACK 15
528
529 /* Data Subtypes */
530 #define FC_SUBTYPE_DATA 0
531 #define FC_SUBTYPE_DATA_CF_ACK 1
532 #define FC_SUBTYPE_DATA_CF_POLL 2
533 #define FC_SUBTYPE_DATA_CF_ACK_POLL 3
534 #define FC_SUBTYPE_NULL 4
535 #define FC_SUBTYPE_CF_ACK 5
536 #define FC_SUBTYPE_CF_POLL 6
537 #define FC_SUBTYPE_CF_ACK_POLL 7
538 #define FC_SUBTYPE_QOS_DATA 8
539 #define FC_SUBTYPE_QOS_NULL 12
540
541 /* type-subtype combos */
542 #define FC_KIND_MASK (FC_TYPE_MASK | FC_SUBTYPE_MASK)
543
544 #define FC_KIND(t, s) (((t) << FC_TYPE_SHIFT) | ((s) << FC_SUBTYPE_SHIFT))
545
546 #define FC_ASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_REQ)
547 #define FC_ASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ASSOC_RESP)
548 #define FC_REASSOC_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_REQ)
549 #define FC_REASSOC_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_REASSOC_RESP)
550 #define FC_PROBE_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_REQ)
551 #define FC_PROBE_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_RESP)
552 #define FC_BEACON FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_BEACON)
553 #define FC_DISASSOC FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DISASSOC)
554 #define FC_AUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_AUTH)
555 #define FC_DEAUTH FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_DEAUTH)
556 #define FC_ACTION FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_ACTION)
557
558 #define FC_PS_POLL FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_PS_POLL)
559 #define FC_RTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_RTS)
560 #define FC_CTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CTS)
561 #define FC_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_ACK)
562 #define FC_CF_END FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END)
563 #define FC_CF_END_ACK FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CF_END_ACK)
564
565 #define FC_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA)
566 #define FC_NULL_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_NULL)
567 #define FC_DATA_CF_ACK FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_DATA_CF_ACK)
568 #define FC_QOS_DATA FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_DATA)
569 #define FC_QOS_NULL FC_KIND(FC_TYPE_DATA, FC_SUBTYPE_QOS_NULL)
570
571 /* QoS Control Field */
572
573 /* 802.1D Tag */
574 #define QOS_PRIO_SHIFT 0
575 #define QOS_PRIO_MASK 0x0007
576 #define QOS_PRIO(qos) (((qos) & QOS_PRIO_MASK) >> QOS_PRIO_SHIFT)
577
578 /* Ack Policy (0 means Acknowledge) */
579 #define QOS_ACK_SHIFT 5
580 #define QOS_ACK_MASK 0x0060
581 #define QOS_ACK(qos) (((qos) & QOS_ACK_MASK) >> QOS_ACK_SHIFT)
582
583 /* Management Frames */
584
585 /* Management Frame Constants */
586
587 /* Fixed fields */
588 #define DOT11_MNG_AUTH_ALGO_LEN 2
589 #define DOT11_MNG_AUTH_SEQ_LEN 2
590 #define DOT11_MNG_BEACON_INT_LEN 2
591 #define DOT11_MNG_CAP_LEN 2
592 #define DOT11_MNG_AP_ADDR_LEN 6
593 #define DOT11_MNG_LISTEN_INT_LEN 2
594 #define DOT11_MNG_REASON_LEN 2
595 #define DOT11_MNG_AID_LEN 2
596 #define DOT11_MNG_STATUS_LEN 2
597 #define DOT11_MNG_TIMESTAMP_LEN 8
598
599 /* DUR/ID field in assoc resp is 0xc000 | AID */
600 #define DOT11_AID_MASK 0x3fff
601
602 /* Reason Codes */
603 #define DOT11_RC_RESERVED 0
604 #define DOT11_RC_UNSPECIFIED 1 /* Unspecified reason */
605 #define DOT11_RC_AUTH_INVAL 2 /* Previous authentication no longer valid */
606 #define DOT11_RC_DEAUTH_LEAVING 3 /* Deauthenticated because sending station is
607 leaving (or has left) IBSS or ESS */
608 #define DOT11_RC_INACTIVITY 4 /* Disassociated due to inactivity */
609 #define DOT11_RC_BUSY 5 /* Disassociated because AP is unable to handle
610 all currently associated stations */
611 #define DOT11_RC_INVAL_CLASS_2 6 /* Class 2 frame received from
612 nonauthenticated station */
613 #define DOT11_RC_INVAL_CLASS_3 7 /* Class 3 frame received from
614 nonassociated station */
615 #define DOT11_RC_DISASSOC_LEAVING 8 /* Disassociated because sending station is
616 leaving (or has left) BSS */
617 #define DOT11_RC_NOT_AUTH 9 /* Station requesting (re)association is
618 not authenticated with responding station */
619 #define DOT11_RC_MAX 23 /* Reason codes > 23 are reserved */
620
621 /* Status Codes */
622 #define DOT11_STATUS_SUCCESS 0 /* Successful */
623 #define DOT11_STATUS_FAILURE 1 /* Unspecified failure */
624 #define DOT11_STATUS_CAP_MISMATCH 10 /* Cannot support all requested capabilities
625 in the Capability Information field */
626 #define DOT11_STATUS_REASSOC_FAIL 11 /* Reassociation denied due to inability to
627 confirm that association exists */
628 #define DOT11_STATUS_ASSOC_FAIL 12 /* Association denied due to reason outside
629 the scope of this standard */
630 #define DOT11_STATUS_AUTH_MISMATCH 13 /* Responding station does not support the
631 specified authentication algorithm */
632 #define DOT11_STATUS_AUTH_SEQ 14 /* Received an Authentication frame with
633 authentication transaction sequence number
634 out of expected sequence */
635 #define DOT11_STATUS_AUTH_CHALLENGE_FAIL 15 /* Authentication rejected because of challenge failure */
636 #define DOT11_STATUS_AUTH_TIMEOUT 16 /* Authentication rejected due to timeout waiting
637 for next frame in sequence */
638 #define DOT11_STATUS_ASSOC_BUSY_FAIL 17 /* Association denied because AP is unable to
639 handle additional associated stations */
640 #define DOT11_STATUS_ASSOC_RATE_MISMATCH 18 /* Association denied due to requesting station
641 not supporting all of the data rates in the
642 BSSBasicRateSet parameter */
643 #define DOT11_STATUS_ASSOC_SHORT_REQUIRED 19 /* Association denied due to requesting station
644 not supporting the Short Preamble option */
645 #define DOT11_STATUS_ASSOC_PBCC_REQUIRED 20 /* Association denied due to requesting station
646 not supporting the PBCC Modulation option */
647 #define DOT11_STATUS_ASSOC_AGILITY_REQUIRED 21 /* Association denied due to requesting station
648 not supporting the Channel Agility option */
649 #define DOT11_STATUS_ASSOC_SPECTRUM_REQUIRED 22 /* Association denied because Spectrum Management
650 capability is required. */
651 #define DOT11_STATUS_ASSOC_BAD_POWER_CAP 23 /* Association denied because the info in the
652 Power Cap element is unacceptable. */
653 #define DOT11_STATUS_ASSOC_BAD_SUP_CHANNELS 24 /* Association denied because the info in the
654 Supported Channel element is unacceptable */
655 #define DOT11_STATUS_ASSOC_SHORTSLOT_REQUIRED 25 /* Association denied due to requesting station
656 not supporting the Short Slot Time option */
657 #define DOT11_STATUS_ASSOC_ERPBCC_REQUIRED 26 /* Association denied due to requesting station
658 not supporting the ER-PBCC Modulation option */
659 #define DOT11_STATUS_ASSOC_DSSOFDM_REQUIRED 27 /* Association denied due to requesting station
660 not supporting the DSS-OFDM option */
661
662 /* Info Elts, length of INFORMATION portion of Info Elts */
663 #define DOT11_MNG_DS_PARAM_LEN 1
664 #define DOT11_MNG_IBSS_PARAM_LEN 2
665
666 /* TIM Info element has 3 bytes fixed info in INFORMATION field,
667 * followed by 1 to 251 bytes of Partial Virtual Bitmap */
668 #define DOT11_MNG_TIM_FIXED_LEN 3
669 #define DOT11_MNG_TIM_DTIM_COUNT 0
670 #define DOT11_MNG_TIM_DTIM_PERIOD 1
671 #define DOT11_MNG_TIM_BITMAP_CTL 2
672 #define DOT11_MNG_TIM_PVB 3
673
674 /* TLV defines */
675 #define TLV_TAG_OFF 0
676 #define TLV_LEN_OFF 1
677 #define TLV_HDR_LEN 2
678 #define TLV_BODY_OFF 2
679
680 /* Management Frame Information Element IDs */
681 #define DOT11_MNG_SSID_ID 0
682 #define DOT11_MNG_RATES_ID 1
683 #define DOT11_MNG_FH_PARMS_ID 2
684 #define DOT11_MNG_DS_PARMS_ID 3
685 #define DOT11_MNG_CF_PARMS_ID 4
686 #define DOT11_MNG_TIM_ID 5
687 #define DOT11_MNG_IBSS_PARMS_ID 6
688 #define DOT11_MNG_COUNTRY_ID 7
689 #define DOT11_MNG_HOPPING_PARMS_ID 8
690 #define DOT11_MNG_HOPPING_TABLE_ID 9
691 #define DOT11_MNG_REQUEST_ID 10
692 #define DOT11_MNG_CHALLENGE_ID 16
693 #define DOT11_MNG_PWR_CONSTRAINT_ID 32 /* 11H PowerConstraint */
694 #define DOT11_MNG_PWR_CAP_ID 33 /* 11H PowerCapability */
695 #define DOT11_MNG_TPC_REQUEST_ID 34 /* 11H TPC Request */
696 #define DOT11_MNG_TPC_REPORT_ID 35 /* 11H TPC Report */
697 #define DOT11_MNG_SUPP_CHANNELS_ID 36 /* 11H Supported Channels */
698 #define DOT11_MNG_CHANNEL_SWITCH_ID 37 /* 11H ChannelSwitch Announcement*/
699 #define DOT11_MNG_MEASURE_REQUEST_ID 38 /* 11H MeasurementRequest */
700 #define DOT11_MNG_MEASURE_REPORT_ID 39 /* 11H MeasurementReport */
701 #define DOT11_MNG_QUIET_ID 40 /* 11H Quiet */
702 #define DOT11_MNG_IBSS_DFS_ID 41 /* 11H IBSS_DFS */
703 #define DOT11_MNG_ERP_ID 42
704 #define DOT11_MNG_NONERP_ID 47
705 #define DOT11_MNG_EXT_RATES_ID 50
706 #define DOT11_MNG_WPA_ID 221
707 #define DOT11_MNG_PROPR_ID 221
708
709 /* ERP info element bit values */
710 #define DOT11_MNG_ERP_LEN 1 /* ERP is currently 1 byte long */
711 #define DOT11_MNG_NONERP_PRESENT 0x01 /* NonERP (802.11b) STAs are present in the BSS */
712 #define DOT11_MNG_USE_PROTECTION 0x02 /* Use protection mechanisms for ERP-OFDM frames */
713 #define DOT11_MNG_BARKER_PREAMBLE 0x04 /* Short Preambles: 0 == allowed, 1 == not allowed */
714
715 /* Capability Information Field */
716 #define DOT11_CAP_ESS 0x0001
717 #define DOT11_CAP_IBSS 0x0002
718 #define DOT11_CAP_POLLABLE 0x0004
719 #define DOT11_CAP_POLL_RQ 0x0008
720 #define DOT11_CAP_PRIVACY 0x0010
721 #define DOT11_CAP_SHORT 0x0020
722 #define DOT11_CAP_PBCC 0x0040
723 #define DOT11_CAP_AGILITY 0x0080
724 #define DOT11_CAP_SPECTRUM 0x0100
725 #define DOT11_CAP_SHORTSLOT 0x0400
726 #define DOT11_CAP_CCK_OFDM 0x2000
727
728 /* Action Frame Constants */
729 #define DOT11_ACTION_CAT_ERR_MASK 0x80
730 #define DOT11_ACTION_CAT_SPECT_MNG 0x00
731 #define DOT11_ACTION_NOTIFICATION 0x11 /* 17 */
732
733 #define DOT11_ACTION_ID_M_REQ 0
734 #define DOT11_ACTION_ID_M_REP 1
735 #define DOT11_ACTION_ID_TPC_REQ 2
736 #define DOT11_ACTION_ID_TPC_REP 3
737 #define DOT11_ACTION_ID_CHANNEL_SWITCH 4
738
739 /* MLME Enumerations */
740 #define DOT11_BSSTYPE_INFRASTRUCTURE 0
741 #define DOT11_BSSTYPE_INDEPENDENT 1
742 #define DOT11_BSSTYPE_ANY 2
743 #define DOT11_SCANTYPE_ACTIVE 0
744 #define DOT11_SCANTYPE_PASSIVE 1
745
746 /* 802.11 A PHY constants */
747 #define APHY_SLOT_TIME 9
748 #define APHY_SIFS_TIME 16
749 #define APHY_DIFS_TIME (APHY_SIFS_TIME + (2 * APHY_SLOT_TIME))
750 #define APHY_PREAMBLE_TIME 16
751 #define APHY_SIGNAL_TIME 4
752 #define APHY_SYMBOL_TIME 4
753 #define APHY_SERVICE_NBITS 16
754 #define APHY_TAIL_NBITS 6
755 #define APHY_CWMIN 15
756
757 /* 802.11 B PHY constants */
758 #define BPHY_SLOT_TIME 20
759 #define BPHY_SIFS_TIME 10
760 #define BPHY_DIFS_TIME 50
761 #define BPHY_PLCP_TIME 192
762 #define BPHY_PLCP_SHORT_TIME 96
763 #define BPHY_CWMIN 31
764
765 /* 802.11 G constants */
766 #define DOT11_OFDM_SIGNAL_EXTENSION 6
767
768 #define PHY_CWMAX 1023
769
770 #define DOT11_MAXNUMFRAGS 16 /* max # fragments per MSDU */
771
772 /* dot11Counters Table - 802.11 spec., Annex D */
773 typedef struct d11cnt {
774 uint32 txfrag; /* dot11TransmittedFragmentCount */
775 uint32 txmulti; /* dot11MulticastTransmittedFrameCount */
776 uint32 txfail; /* dot11FailedCount */
777 uint32 txretry; /* dot11RetryCount */
778 uint32 txretrie; /* dot11MultipleRetryCount */
779 uint32 rxdup; /* dot11FrameduplicateCount */
780 uint32 txrts; /* dot11RTSSuccessCount */
781 uint32 txnocts; /* dot11RTSFailureCount */
782 uint32 txnoack; /* dot11ACKFailureCount */
783 uint32 rxfrag; /* dot11ReceivedFragmentCount */
784 uint32 rxmulti; /* dot11MulticastReceivedFrameCount */
785 uint32 rxcrc; /* dot11FCSErrorCount */
786 uint32 txfrmsnt; /* dot11TransmittedFrameCount */
787 uint32 rxundec; /* dot11WEPUndecryptableCount */
788 } d11cnt_t;
789
790 /* BRCM OUI */
791 #define BRCM_OUI "\x00\x10\x18"
792
793 /* BRCM info element */
794 struct brcm_ie {
795 uchar id;
796 uchar len;
797 uchar oui[3];
798 uchar ver;
799 uchar assoc; /* # of assoc STAs */
800 uchar flags; /* misc flags */
801 } PACKED;
802 #define BRCM_IE_LEN 8
803 typedef struct brcm_ie brcm_ie_t;
804 #define BRCM_IE_VER 1
805
806 /* brcm_ie flags */
807 #define BRF_ABCAP 0x1 /* afterburner capable */
808 #define BRF_ABRQRD 0x2 /* afterburner requested */
809
810 /* WPA definitions */
811 #define WPA_VERSION 1
812 #define WPA_OUI "\x00\x50\xF2"
813
814 #define WPA_OUI_LEN 3
815
816 /* WPA authentication modes */
817 #define WPA_AUTH_NONE 0 /* None */
818 #define WPA_AUTH_UNSPECIFIED 1 /* Unspecified authentication over 802.1X: default for WPA */
819 #define WPA_AUTH_PSK 2 /* Pre-shared Key over 802.1X */
820 #define WPA_AUTH_DISABLED 255 /* Legacy (i.e., non-WPA) */
821
822 #define IS_WPA_AUTH(auth) ((auth) == WPA_AUTH_NONE || \
823 (auth) == WPA_AUTH_UNSPECIFIED || \
824 (auth) == WPA_AUTH_PSK)
825
826
827 /* Key related defines */
828 #define DOT11_MAX_DEFAULT_KEYS 4 /* number of default keys */
829 #define DOT11_MAX_KEY_SIZE 32 /* max size of any key */
830 #define DOT11_MAX_IV_SIZE 16 /* max size of any IV */
831 #define DOT11_EXT_IV_FLAG (1<<5) /* flag to indicate IV is > 4 bytes */
832
833 #define WEP1_KEY_SIZE 5 /* max size of any WEP key */
834 #define WEP1_KEY_HEX_SIZE 10 /* size of WEP key in hex. */
835 #define WEP128_KEY_SIZE 13 /* max size of any WEP key */
836 #define WEP128_KEY_HEX_SIZE 26 /* size of WEP key in hex. */
837 #define TKIP_MIC_SIZE 8 /* size of TKIP MIC */
838 #define TKIP_EOM_SIZE 7 /* max size of TKIP EOM */
839 #define TKIP_EOM_FLAG 0x5a /* TKIP EOM flag byte */
840 #define TKIP_KEY_SIZE 32 /* size of any TKIP key */
841 #define TKIP_MIC_AUTH_TX 16 /* offset to Authenticator MIC TX key */
842 #define TKIP_MIC_AUTH_RX 24 /* offset to Authenticator MIC RX key */
843 #define TKIP_MIC_SUP_RX 16 /* offset to Supplicant MIC RX key */
844 #define TKIP_MIC_SUP_TX 24 /* offset to Supplicant MIC TX key */
845 #define AES_KEY_SIZE 16 /* size of AES key */
846
847 #undef PACKED
848 #if !defined(__GNUC__)
849 #pragma pack()
850 #endif
851
852 #endif /* _802_11_H_ */