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