4 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
6 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
7 * Copyright (c) 2005, Devicescape Software, Inc.
8 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #ifndef LINUX_IEEE80211_H
16 #define LINUX_IEEE80211_H
18 #include <linux/types.h>
19 #include <asm/byteorder.h>
23 #define IEEE80211_FCTL_VERS 0x0003
24 #define IEEE80211_FCTL_FTYPE 0x000c
25 #define IEEE80211_FCTL_STYPE 0x00f0
26 #define IEEE80211_FCTL_TODS 0x0100
27 #define IEEE80211_FCTL_FROMDS 0x0200
28 #define IEEE80211_FCTL_MOREFRAGS 0x0400
29 #define IEEE80211_FCTL_RETRY 0x0800
30 #define IEEE80211_FCTL_PM 0x1000
31 #define IEEE80211_FCTL_MOREDATA 0x2000
32 #define IEEE80211_FCTL_PROTECTED 0x4000
33 #define IEEE80211_FCTL_ORDER 0x8000
35 #define IEEE80211_SCTL_FRAG 0x000F
36 #define IEEE80211_SCTL_SEQ 0xFFF0
38 #define IEEE80211_FTYPE_MGMT 0x0000
39 #define IEEE80211_FTYPE_CTL 0x0004
40 #define IEEE80211_FTYPE_DATA 0x0008
43 #define IEEE80211_STYPE_ASSOC_REQ 0x0000
44 #define IEEE80211_STYPE_ASSOC_RESP 0x0010
45 #define IEEE80211_STYPE_REASSOC_REQ 0x0020
46 #define IEEE80211_STYPE_REASSOC_RESP 0x0030
47 #define IEEE80211_STYPE_PROBE_REQ 0x0040
48 #define IEEE80211_STYPE_PROBE_RESP 0x0050
49 #define IEEE80211_STYPE_BEACON 0x0080
50 #define IEEE80211_STYPE_ATIM 0x0090
51 #define IEEE80211_STYPE_DISASSOC 0x00A0
52 #define IEEE80211_STYPE_AUTH 0x00B0
53 #define IEEE80211_STYPE_DEAUTH 0x00C0
54 #define IEEE80211_STYPE_ACTION 0x00D0
57 #define IEEE80211_STYPE_BACK_REQ 0x0080
58 #define IEEE80211_STYPE_BACK 0x0090
59 #define IEEE80211_STYPE_PSPOLL 0x00A0
60 #define IEEE80211_STYPE_RTS 0x00B0
61 #define IEEE80211_STYPE_CTS 0x00C0
62 #define IEEE80211_STYPE_ACK 0x00D0
63 #define IEEE80211_STYPE_CFEND 0x00E0
64 #define IEEE80211_STYPE_CFENDACK 0x00F0
67 #define IEEE80211_STYPE_DATA 0x0000
68 #define IEEE80211_STYPE_DATA_CFACK 0x0010
69 #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
70 #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
71 #define IEEE80211_STYPE_NULLFUNC 0x0040
72 #define IEEE80211_STYPE_CFACK 0x0050
73 #define IEEE80211_STYPE_CFPOLL 0x0060
74 #define IEEE80211_STYPE_CFACKPOLL 0x0070
75 #define IEEE80211_STYPE_QOS_DATA 0x0080
76 #define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
77 #define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
78 #define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
79 #define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
80 #define IEEE80211_STYPE_QOS_CFACK 0x00D0
81 #define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
82 #define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
85 /* miscellaneous IEEE 802.11 constants */
86 #define IEEE80211_MAX_FRAG_THRESHOLD 2352
87 #define IEEE80211_MAX_RTS_THRESHOLD 2353
88 #define IEEE80211_MAX_AID 2007
89 #define IEEE80211_MAX_TIM_LEN 251
90 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
93 802.11e clarifies the figure in section 7.1.2. The frame body is
94 up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
95 #define IEEE80211_MAX_DATA_LEN 2304
96 /* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
97 #define IEEE80211_MAX_FRAME_LEN 2352
99 #define IEEE80211_MAX_SSID_LEN 32
101 #define IEEE80211_MAX_MESH_ID_LEN 32
102 #define IEEE80211_MESH_CONFIG_LEN 19
104 #define IEEE80211_QOS_CTL_LEN 2
105 #define IEEE80211_QOS_CTL_TID_MASK 0x000F
106 #define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
108 struct ieee80211_hdr {
109 __le16 frame_control;
116 } __attribute__ ((packed));
119 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
120 * @fc: frame control bytes in little-endian byteorder
122 static inline int ieee80211_has_tods(__le16 fc)
124 return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
128 * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
129 * @fc: frame control bytes in little-endian byteorder
131 static inline int ieee80211_has_fromds(__le16 fc)
133 return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
137 * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
138 * @fc: frame control bytes in little-endian byteorder
140 static inline int ieee80211_has_a4(__le16 fc)
142 __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
143 return (fc & tmp) == tmp;
147 * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
148 * @fc: frame control bytes in little-endian byteorder
150 static inline int ieee80211_has_morefrags(__le16 fc)
152 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
156 * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
157 * @fc: frame control bytes in little-endian byteorder
159 static inline int ieee80211_has_retry(__le16 fc)
161 return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
165 * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
166 * @fc: frame control bytes in little-endian byteorder
168 static inline int ieee80211_has_pm(__le16 fc)
170 return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
174 * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
175 * @fc: frame control bytes in little-endian byteorder
177 static inline int ieee80211_has_moredata(__le16 fc)
179 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
183 * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
184 * @fc: frame control bytes in little-endian byteorder
186 static inline int ieee80211_has_protected(__le16 fc)
188 return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
192 * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
193 * @fc: frame control bytes in little-endian byteorder
195 static inline int ieee80211_has_order(__le16 fc)
197 return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
201 * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
202 * @fc: frame control bytes in little-endian byteorder
204 static inline int ieee80211_is_mgmt(__le16 fc)
206 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
207 cpu_to_le16(IEEE80211_FTYPE_MGMT);
211 * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
212 * @fc: frame control bytes in little-endian byteorder
214 static inline int ieee80211_is_ctl(__le16 fc)
216 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
217 cpu_to_le16(IEEE80211_FTYPE_CTL);
221 * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
222 * @fc: frame control bytes in little-endian byteorder
224 static inline int ieee80211_is_data(__le16 fc)
226 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
227 cpu_to_le16(IEEE80211_FTYPE_DATA);
231 * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
232 * @fc: frame control bytes in little-endian byteorder
234 static inline int ieee80211_is_data_qos(__le16 fc)
237 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
238 * to check the one bit
240 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
241 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
245 * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
246 * @fc: frame control bytes in little-endian byteorder
248 static inline int ieee80211_is_data_present(__le16 fc)
251 * mask with 0x40 and test that that bit is clear to only return true
252 * for the data-containing substypes.
254 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
255 cpu_to_le16(IEEE80211_FTYPE_DATA);
259 * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
260 * @fc: frame control bytes in little-endian byteorder
262 static inline int ieee80211_is_assoc_req(__le16 fc)
264 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
265 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
269 * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
270 * @fc: frame control bytes in little-endian byteorder
272 static inline int ieee80211_is_assoc_resp(__le16 fc)
274 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
275 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
279 * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
280 * @fc: frame control bytes in little-endian byteorder
282 static inline int ieee80211_is_reassoc_req(__le16 fc)
284 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
285 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
289 * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
290 * @fc: frame control bytes in little-endian byteorder
292 static inline int ieee80211_is_reassoc_resp(__le16 fc)
294 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
295 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
299 * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
300 * @fc: frame control bytes in little-endian byteorder
302 static inline int ieee80211_is_probe_req(__le16 fc)
304 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
305 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
309 * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
310 * @fc: frame control bytes in little-endian byteorder
312 static inline int ieee80211_is_probe_resp(__le16 fc)
314 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
315 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
319 * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
320 * @fc: frame control bytes in little-endian byteorder
322 static inline int ieee80211_is_beacon(__le16 fc)
324 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
325 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
329 * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
330 * @fc: frame control bytes in little-endian byteorder
332 static inline int ieee80211_is_atim(__le16 fc)
334 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
335 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
339 * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
340 * @fc: frame control bytes in little-endian byteorder
342 static inline int ieee80211_is_disassoc(__le16 fc)
344 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
345 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
349 * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
350 * @fc: frame control bytes in little-endian byteorder
352 static inline int ieee80211_is_auth(__le16 fc)
354 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
355 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
359 * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
360 * @fc: frame control bytes in little-endian byteorder
362 static inline int ieee80211_is_deauth(__le16 fc)
364 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
365 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
369 * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
370 * @fc: frame control bytes in little-endian byteorder
372 static inline int ieee80211_is_action(__le16 fc)
374 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
375 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
379 * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
380 * @fc: frame control bytes in little-endian byteorder
382 static inline int ieee80211_is_back_req(__le16 fc)
384 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
385 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
389 * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
390 * @fc: frame control bytes in little-endian byteorder
392 static inline int ieee80211_is_back(__le16 fc)
394 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
395 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
399 * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
400 * @fc: frame control bytes in little-endian byteorder
402 static inline int ieee80211_is_pspoll(__le16 fc)
404 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
405 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
409 * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
410 * @fc: frame control bytes in little-endian byteorder
412 static inline int ieee80211_is_rts(__le16 fc)
414 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
415 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
419 * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
420 * @fc: frame control bytes in little-endian byteorder
422 static inline int ieee80211_is_cts(__le16 fc)
424 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
425 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
429 * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
430 * @fc: frame control bytes in little-endian byteorder
432 static inline int ieee80211_is_ack(__le16 fc)
434 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
435 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
439 * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
440 * @fc: frame control bytes in little-endian byteorder
442 static inline int ieee80211_is_cfend(__le16 fc)
444 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
445 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
449 * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
450 * @fc: frame control bytes in little-endian byteorder
452 static inline int ieee80211_is_cfendack(__le16 fc)
454 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
455 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
459 * ieee80211_is_nullfunc - check if FTYPE=IEEE80211_FTYPE_DATA and STYPE=IEEE80211_STYPE_NULLFUNC
460 * @fc: frame control bytes in little-endian byteorder
462 static inline int ieee80211_is_nullfunc(__le16 fc)
464 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
465 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
468 struct ieee80211s_hdr {
475 } __attribute__ ((packed));
478 #define MESH_FLAGS_AE_A4 0x1
479 #define MESH_FLAGS_AE_A5_A6 0x2
480 #define MESH_FLAGS_PS_DEEP 0x4
483 * struct ieee80211_quiet_ie
485 * This structure refers to "Quiet information element"
487 struct ieee80211_quiet_ie {
492 } __attribute__ ((packed));
495 * struct ieee80211_msrment_ie
497 * This structure refers to "Measurement Request/Report information element"
499 struct ieee80211_msrment_ie {
504 } __attribute__ ((packed));
507 * struct ieee80211_channel_sw_ie
509 * This structure refers to "Channel Switch Announcement information element"
511 struct ieee80211_channel_sw_ie {
515 } __attribute__ ((packed));
518 * struct ieee80211_tim
520 * This structure refers to "Traffic Indication Map information element"
522 struct ieee80211_tim_ie {
526 /* variable size: 1 - 251 bytes */
528 } __attribute__ ((packed));
530 struct ieee80211_mgmt {
531 __le16 frame_control;
540 __le16 auth_transaction;
542 /* possibly followed by Challenge text */
544 } __attribute__ ((packed)) auth;
547 } __attribute__ ((packed)) deauth;
550 __le16 listen_interval;
551 /* followed by SSID and Supported rates */
553 } __attribute__ ((packed)) assoc_req;
558 /* followed by Supported rates */
560 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
563 __le16 listen_interval;
565 /* followed by SSID and Supported rates */
567 } __attribute__ ((packed)) reassoc_req;
570 } __attribute__ ((packed)) disassoc;
575 /* followed by some of SSID, Supported rates,
576 * FH Params, DS Params, CF Params, IBSS Params, TIM */
578 } __attribute__ ((packed)) beacon;
580 /* only variable items: SSID, Supported rates */
582 } __attribute__ ((packed)) probe_req;
587 /* followed by some of SSID, Supported rates,
588 * FH Params, DS Params, CF Params, IBSS Params */
590 } __attribute__ ((packed)) probe_resp;
599 } __attribute__ ((packed)) wme_action;
604 struct ieee80211_channel_sw_ie sw_elem;
605 } __attribute__((packed)) chan_switch;
611 struct ieee80211_msrment_ie msr_elem;
612 } __attribute__((packed)) measurement;
618 __le16 start_seq_num;
619 } __attribute__((packed)) addba_req;
626 } __attribute__((packed)) addba_resp;
631 } __attribute__((packed)) delba;
634 /* capab_info for open and confirm,
638 /* Followed in plink_confirm by status
639 * code, AID and supported rates,
640 * and directly by supported rates in
641 * plink_open and plink_close
644 } __attribute__((packed)) plink_action;
648 } __attribute__((packed)) mesh_action;
650 } __attribute__ ((packed)) action;
652 } __attribute__ ((packed));
654 /* mgmt header + 1 byte category code */
655 #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
658 /* Management MIC information element (IEEE 802.11w) */
659 struct ieee80211_mmie {
663 u8 sequence_number[6];
665 } __attribute__ ((packed));
668 struct ieee80211_rts {
669 __le16 frame_control;
673 } __attribute__ ((packed));
675 struct ieee80211_cts {
676 __le16 frame_control;
679 } __attribute__ ((packed));
681 struct ieee80211_pspoll {
682 __le16 frame_control;
686 } __attribute__ ((packed));
689 * struct ieee80211_bar - HT Block Ack Request
691 * This structure refers to "HT BlockAckReq" as
692 * described in 802.11n draft section 7.2.1.7.1
694 struct ieee80211_bar {
695 __le16 frame_control;
700 __le16 start_seq_num;
701 } __attribute__((packed));
703 /* 802.11 BAR control masks */
704 #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
705 #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
708 #define IEEE80211_HT_MCS_MASK_LEN 10
711 * struct ieee80211_mcs_info - MCS information
713 * @rx_highest: highest supported RX rate
714 * @tx_params: TX parameters
716 struct ieee80211_mcs_info {
717 u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN];
721 } __attribute__((packed));
723 /* 802.11n HT capability MSC set */
724 #define IEEE80211_HT_MCS_RX_HIGHEST_MASK 0x3ff
725 #define IEEE80211_HT_MCS_TX_DEFINED 0x01
726 #define IEEE80211_HT_MCS_TX_RX_DIFF 0x02
727 /* value 0 == 1 stream etc */
728 #define IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK 0x0C
729 #define IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT 2
730 #define IEEE80211_HT_MCS_TX_MAX_STREAMS 4
731 #define IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION 0x10
734 * 802.11n D5.0 20.3.5 / 20.6 says:
735 * - indices 0 to 7 and 32 are single spatial stream
736 * - 8 to 31 are multiple spatial streams using equal modulation
737 * [8..15 for two streams, 16..23 for three and 24..31 for four]
738 * - remainder are multiple spatial streams using unequal modulation
740 #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START 33
741 #define IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE \
742 (IEEE80211_HT_MCS_UNEQUAL_MODULATION_START / 8)
745 * struct ieee80211_ht_cap - HT capabilities
747 * This structure is the "HT capabilities element" as
748 * described in 802.11n D5.0 7.3.2.57
750 struct ieee80211_ht_cap {
752 u8 ampdu_params_info;
754 /* 16 bytes MCS information */
755 struct ieee80211_mcs_info mcs;
757 __le16 extended_ht_cap_info;
758 __le32 tx_BF_cap_info;
759 u8 antenna_selection_info;
760 } __attribute__ ((packed));
762 /* 802.11n HT capabilities masks (for cap_info) */
763 #define IEEE80211_HT_CAP_LDPC_CODING 0x0001
764 #define IEEE80211_HT_CAP_SUP_WIDTH_20_40 0x0002
765 #define IEEE80211_HT_CAP_SM_PS 0x000C
766 #define IEEE80211_HT_CAP_GRN_FLD 0x0010
767 #define IEEE80211_HT_CAP_SGI_20 0x0020
768 #define IEEE80211_HT_CAP_SGI_40 0x0040
769 #define IEEE80211_HT_CAP_TX_STBC 0x0080
770 #define IEEE80211_HT_CAP_RX_STBC 0x0300
771 #define IEEE80211_HT_CAP_DELAY_BA 0x0400
772 #define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
773 #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
774 #define IEEE80211_HT_CAP_PSMP_SUPPORT 0x2000
775 #define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
776 #define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
778 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
779 #define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03
780 #define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C
783 * struct ieee80211_ht_info - HT information
785 * This structure is the "HT information element" as
786 * described in 802.11n D5.0 7.3.2.58
788 struct ieee80211_ht_info {
791 __le16 operation_mode;
794 } __attribute__ ((packed));
797 #define IEEE80211_HT_PARAM_CHA_SEC_OFFSET 0x03
798 #define IEEE80211_HT_PARAM_CHA_SEC_NONE 0x00
799 #define IEEE80211_HT_PARAM_CHA_SEC_ABOVE 0x01
800 #define IEEE80211_HT_PARAM_CHA_SEC_BELOW 0x03
801 #define IEEE80211_HT_PARAM_CHAN_WIDTH_ANY 0x04
802 #define IEEE80211_HT_PARAM_RIFS_MODE 0x08
803 #define IEEE80211_HT_PARAM_SPSMP_SUPPORT 0x10
804 #define IEEE80211_HT_PARAM_SERV_INTERVAL_GRAN 0xE0
806 /* for operation_mode */
807 #define IEEE80211_HT_OP_MODE_PROTECTION 0x0003
808 #define IEEE80211_HT_OP_MODE_PROTECTION_NONE 0
809 #define IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER 1
810 #define IEEE80211_HT_OP_MODE_PROTECTION_20MHZ 2
811 #define IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED 3
812 #define IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT 0x0004
813 #define IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT 0x0010
816 #define IEEE80211_HT_STBC_PARAM_DUAL_BEACON 0x0040
817 #define IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT 0x0080
818 #define IEEE80211_HT_STBC_PARAM_STBC_BEACON 0x0100
819 #define IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT 0x0200
820 #define IEEE80211_HT_STBC_PARAM_PCO_ACTIVE 0x0400
821 #define IEEE80211_HT_STBC_PARAM_PCO_PHASE 0x0800
824 /* block-ack parameters */
825 #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
826 #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
827 #define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
828 #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
829 #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
832 * A-PMDU buffer sizes
833 * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
835 #define IEEE80211_MIN_AMPDU_BUF 0x8
836 #define IEEE80211_MAX_AMPDU_BUF 0x40
839 /* Spatial Multiplexing Power Save Modes */
840 #define WLAN_HT_CAP_SM_PS_STATIC 0
841 #define WLAN_HT_CAP_SM_PS_DYNAMIC 1
842 #define WLAN_HT_CAP_SM_PS_INVALID 2
843 #define WLAN_HT_CAP_SM_PS_DISABLED 3
845 /* Authentication algorithms */
846 #define WLAN_AUTH_OPEN 0
847 #define WLAN_AUTH_SHARED_KEY 1
848 #define WLAN_AUTH_LEAP 128
850 #define WLAN_AUTH_CHALLENGE_LEN 128
852 #define WLAN_CAPABILITY_ESS (1<<0)
853 #define WLAN_CAPABILITY_IBSS (1<<1)
854 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
855 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
856 #define WLAN_CAPABILITY_PRIVACY (1<<4)
857 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
858 #define WLAN_CAPABILITY_PBCC (1<<6)
859 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
862 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
863 #define WLAN_CAPABILITY_QOS (1<<9)
864 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
865 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
867 #define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
868 #define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
869 #define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
871 #define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
872 #define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
873 #define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
876 /* 802.11g ERP information element */
877 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
878 #define WLAN_ERP_USE_PROTECTION (1<<1)
879 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
881 /* WLAN_ERP_BARKER_PREAMBLE values */
883 WLAN_ERP_PREAMBLE_SHORT = 0,
884 WLAN_ERP_PREAMBLE_LONG = 1,
888 enum ieee80211_statuscode {
889 WLAN_STATUS_SUCCESS = 0,
890 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
891 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
892 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
893 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
894 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
895 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
896 WLAN_STATUS_CHALLENGE_FAIL = 15,
897 WLAN_STATUS_AUTH_TIMEOUT = 16,
898 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
899 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
901 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
902 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
903 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
905 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
906 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
907 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
909 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
910 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
912 WLAN_STATUS_INVALID_IE = 40,
913 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
914 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
915 WLAN_STATUS_INVALID_AKMP = 43,
916 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
917 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
918 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
920 WLAN_STATUS_UNSPECIFIED_QOS = 32,
921 WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
922 WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
923 WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
924 WLAN_STATUS_REQUEST_DECLINED = 37,
925 WLAN_STATUS_INVALID_QOS_PARAM = 38,
926 WLAN_STATUS_CHANGE_TSPEC = 39,
927 WLAN_STATUS_WAIT_TS_DELAY = 47,
928 WLAN_STATUS_NO_DIRECT_LINK = 48,
929 WLAN_STATUS_STA_NOT_PRESENT = 49,
930 WLAN_STATUS_STA_NOT_QSTA = 50,
935 enum ieee80211_reasoncode {
936 WLAN_REASON_UNSPECIFIED = 1,
937 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
938 WLAN_REASON_DEAUTH_LEAVING = 3,
939 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
940 WLAN_REASON_DISASSOC_AP_BUSY = 5,
941 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
942 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
943 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
944 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
946 WLAN_REASON_DISASSOC_BAD_POWER = 10,
947 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
949 WLAN_REASON_INVALID_IE = 13,
950 WLAN_REASON_MIC_FAILURE = 14,
951 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
952 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
953 WLAN_REASON_IE_DIFFERENT = 17,
954 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
955 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
956 WLAN_REASON_INVALID_AKMP = 20,
957 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
958 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
959 WLAN_REASON_IEEE8021X_FAILED = 23,
960 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
962 WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
963 WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
964 WLAN_REASON_DISASSOC_LOW_ACK = 34,
965 WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
966 WLAN_REASON_QSTA_LEAVE_QBSS = 36,
967 WLAN_REASON_QSTA_NOT_USE = 37,
968 WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
969 WLAN_REASON_QSTA_TIMEOUT = 39,
970 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
974 /* Information Element IDs */
977 WLAN_EID_SUPP_RATES = 1,
978 WLAN_EID_FH_PARAMS = 2,
979 WLAN_EID_DS_PARAMS = 3,
980 WLAN_EID_CF_PARAMS = 4,
982 WLAN_EID_IBSS_PARAMS = 6,
983 WLAN_EID_CHALLENGE = 16,
985 WLAN_EID_COUNTRY = 7,
986 WLAN_EID_HP_PARAMS = 8,
987 WLAN_EID_HP_TABLE = 9,
988 WLAN_EID_REQUEST = 10,
990 WLAN_EID_QBSS_LOAD = 11,
991 WLAN_EID_EDCA_PARAM_SET = 12,
994 WLAN_EID_SCHEDULE = 15,
995 WLAN_EID_TS_DELAY = 43,
996 WLAN_EID_TCLAS_PROCESSING = 44,
997 WLAN_EID_QOS_CAPA = 46,
1000 * All mesh EID numbers are pending IEEE 802.11 ANA approval.
1001 * The numbers have been incremented from those suggested in
1002 * 802.11s/D2.0 so that MESH_CONFIG does not conflict with
1005 WLAN_EID_MESH_CONFIG = 51,
1006 WLAN_EID_MESH_ID = 52,
1007 WLAN_EID_PEER_LINK = 55,
1012 WLAN_EID_PWR_CONSTRAINT = 32,
1013 WLAN_EID_PWR_CAPABILITY = 33,
1014 WLAN_EID_TPC_REQUEST = 34,
1015 WLAN_EID_TPC_REPORT = 35,
1016 WLAN_EID_SUPPORTED_CHANNELS = 36,
1017 WLAN_EID_CHANNEL_SWITCH = 37,
1018 WLAN_EID_MEASURE_REQUEST = 38,
1019 WLAN_EID_MEASURE_REPORT = 39,
1020 WLAN_EID_QUIET = 40,
1021 WLAN_EID_IBSS_DFS = 41,
1023 WLAN_EID_ERP_INFO = 42,
1024 WLAN_EID_EXT_SUPP_RATES = 50,
1026 WLAN_EID_HT_CAPABILITY = 45,
1027 WLAN_EID_HT_INFORMATION = 61,
1030 WLAN_EID_MMIE = 76 /* 802.11w */,
1032 WLAN_EID_GENERIC = 221,
1033 WLAN_EID_VENDOR_SPECIFIC = 221,
1034 WLAN_EID_QOS_PARAMETER = 222
1037 /* Action category code */
1038 enum ieee80211_category {
1039 WLAN_CATEGORY_SPECTRUM_MGMT = 0,
1040 WLAN_CATEGORY_QOS = 1,
1041 WLAN_CATEGORY_DLS = 2,
1042 WLAN_CATEGORY_BACK = 3,
1043 WLAN_CATEGORY_PUBLIC = 4,
1044 WLAN_CATEGORY_WMM = 17,
1047 /* SPECTRUM_MGMT action code */
1048 enum ieee80211_spectrum_mgmt_actioncode {
1049 WLAN_ACTION_SPCT_MSR_REQ = 0,
1050 WLAN_ACTION_SPCT_MSR_RPRT = 1,
1051 WLAN_ACTION_SPCT_TPC_REQ = 2,
1052 WLAN_ACTION_SPCT_TPC_RPRT = 3,
1053 WLAN_ACTION_SPCT_CHL_SWITCH = 4,
1057 * IEEE 802.11-2007 7.3.2.9 Country information element
1059 * Minimum length is 8 octets, ie len must be evenly
1063 /* Although the spec says 8 I'm seeing 6 in practice */
1064 #define IEEE80211_COUNTRY_IE_MIN_LEN 6
1067 * For regulatory extension stuff see IEEE 802.11-2007
1068 * Annex I (page 1141) and Annex J (page 1147). Also
1071 * When dot11RegulatoryClassesRequired is true and the
1072 * first_channel/reg_extension_id is >= 201 then the IE
1073 * compromises of the 'ext' struct represented below:
1075 * - Regulatory extension ID - when generating IE this just needs
1076 * to be monotonically increasing for each triplet passed in
1078 * - Regulatory class - index into set of rules
1079 * - Coverage class - index into air propagation time (Table 7-27),
1080 * in microseconds, you can compute the air propagation time from
1081 * the index by multiplying by 3, so index 10 yields a propagation
1082 * of 10 us. Valid values are 0-31, values 32-255 are not defined
1083 * yet. A value of 0 inicates air propagation of <= 1 us.
1085 * See also Table I.2 for Emission limit sets and table
1086 * I.3 for Behavior limit sets. Table J.1 indicates how to map
1087 * a reg_class to an emission limit set and behavior limit set.
1089 #define IEEE80211_COUNTRY_EXTENSION_ID 201
1092 * Channels numbers in the IE must be monotonically increasing
1093 * if dot11RegulatoryClassesRequired is not true.
1095 * If dot11RegulatoryClassesRequired is true consecutive
1096 * subband triplets following a regulatory triplet shall
1097 * have monotonically increasing first_channel number fields.
1099 * Channel numbers shall not overlap.
1101 * Note that max_power is signed.
1103 struct ieee80211_country_ie_triplet {
1109 } __attribute__ ((packed)) chans;
1111 u8 reg_extension_id;
1114 } __attribute__ ((packed)) ext;
1116 } __attribute__ ((packed));
1118 /* BACK action code */
1119 enum ieee80211_back_actioncode {
1120 WLAN_ACTION_ADDBA_REQ = 0,
1121 WLAN_ACTION_ADDBA_RESP = 1,
1122 WLAN_ACTION_DELBA = 2,
1125 /* BACK (block-ack) parties */
1126 enum ieee80211_back_parties {
1127 WLAN_BACK_RECIPIENT = 0,
1128 WLAN_BACK_INITIATOR = 1,
1129 WLAN_BACK_TIMER = 2,
1132 /* A-MSDU 802.11n */
1133 #define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
1135 /* cipher suite selectors */
1136 #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
1137 #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
1138 #define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
1139 /* reserved: 0x000FAC03 */
1140 #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
1141 #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
1143 #define WLAN_MAX_KEY_LEN 32
1146 * ieee80211_get_qos_ctl - get pointer to qos control bytes
1149 * The qos ctrl bytes come after the frame_control, duration, seq_num
1150 * and 3 or 4 addresses of length ETH_ALEN.
1151 * 3 addr: 2 + 2 + 2 + 3*6 = 24
1152 * 4 addr: 2 + 2 + 2 + 4*6 = 30
1154 static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
1156 if (ieee80211_has_a4(hdr->frame_control))
1157 return (u8 *)hdr + 30;
1159 return (u8 *)hdr + 24;
1163 * ieee80211_get_SA - get pointer to SA
1166 * Given an 802.11 frame, this function returns the offset
1167 * to the source address (SA). It does not verify that the
1168 * header is long enough to contain the address, and the
1169 * header must be long enough to contain the frame control
1172 static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
1174 if (ieee80211_has_a4(hdr->frame_control))
1176 if (ieee80211_has_fromds(hdr->frame_control))
1182 * ieee80211_get_DA - get pointer to DA
1185 * Given an 802.11 frame, this function returns the offset
1186 * to the destination address (DA). It does not verify that
1187 * the header is long enough to contain the address, and the
1188 * header must be long enough to contain the frame control
1191 static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1193 if (ieee80211_has_tods(hdr->frame_control))
1200 * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
1201 * @hdr: the frame (buffer must include at least the first octet of payload)
1203 static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
1205 if (ieee80211_is_disassoc(hdr->frame_control) ||
1206 ieee80211_is_deauth(hdr->frame_control))
1209 if (ieee80211_is_action(hdr->frame_control)) {
1213 * Action frames, excluding Public Action frames, are Robust
1214 * Management Frames. However, if we are looking at a Protected
1215 * frame, skip the check since the data may be encrypted and
1216 * the frame has already been found to be a Robust Management
1217 * Frame (by the other end).
1219 if (ieee80211_has_protected(hdr->frame_control))
1221 category = ((u8 *) hdr) + 24;
1222 return *category != WLAN_CATEGORY_PUBLIC;
1229 * ieee80211_fhss_chan_to_freq - get channel frequency
1230 * @channel: the FHSS channel
1232 * Convert IEEE802.11 FHSS channel to frequency (MHz)
1233 * Ref IEEE 802.11-2007 section 14.6
1235 static inline int ieee80211_fhss_chan_to_freq(int channel)
1237 if ((channel > 1) && (channel < 96))
1238 return channel + 2400;
1244 * ieee80211_freq_to_fhss_chan - get channel
1245 * @freq: the channels frequency
1247 * Convert frequency (MHz) to IEEE802.11 FHSS channel
1248 * Ref IEEE 802.11-2007 section 14.6
1250 static inline int ieee80211_freq_to_fhss_chan(int freq)
1252 if ((freq > 2401) && (freq < 2496))
1259 * ieee80211_dsss_chan_to_freq - get channel center frequency
1260 * @channel: the DSSS channel
1262 * Convert IEEE802.11 DSSS channel to the center frequency (MHz).
1263 * Ref IEEE 802.11-2007 section 15.6
1265 static inline int ieee80211_dsss_chan_to_freq(int channel)
1267 if ((channel > 0) && (channel < 14))
1268 return 2407 + (channel * 5);
1269 else if (channel == 14)
1276 * ieee80211_freq_to_dsss_chan - get channel
1277 * @freq: the frequency
1279 * Convert frequency (MHz) to IEEE802.11 DSSS channel
1280 * Ref IEEE 802.11-2007 section 15.6
1282 * This routine selects the channel with the closest center frequency.
1284 static inline int ieee80211_freq_to_dsss_chan(int freq)
1286 if ((freq >= 2410) && (freq < 2475))
1287 return (freq - 2405) / 5;
1288 else if ((freq >= 2482) && (freq < 2487))
1294 /* Convert IEEE802.11 HR DSSS channel to frequency (MHz) and back
1295 * Ref IEEE 802.11-2007 section 18.4.6.2
1297 * The channels and frequencies are the same as those defined for DSSS
1299 #define ieee80211_hr_chan_to_freq(chan) ieee80211_dsss_chan_to_freq(chan)
1300 #define ieee80211_freq_to_hr_chan(freq) ieee80211_freq_to_dsss_chan(freq)
1302 /* Convert IEEE802.11 ERP channel to frequency (MHz) and back
1303 * Ref IEEE 802.11-2007 section 19.4.2
1305 #define ieee80211_erp_chan_to_freq(chan) ieee80211_hr_chan_to_freq(chan)
1306 #define ieee80211_freq_to_erp_chan(freq) ieee80211_freq_to_hr_chan(freq)
1309 * ieee80211_ofdm_chan_to_freq - get channel center frequency
1310 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
1311 * @channel: the OFDM channel
1313 * Convert IEEE802.11 OFDM channel to center frequency (MHz)
1314 * Ref IEEE 802.11-2007 section 17.3.8.3.2
1316 static inline int ieee80211_ofdm_chan_to_freq(int s_freq, int channel)
1318 if ((channel > 0) && (channel <= 200) &&
1320 return s_freq + (channel * 5);
1326 * ieee80211_freq_to_ofdm_channel - get channel
1327 * @s_freq: starting frequency == (dotChannelStartingFactor/2) MHz
1328 * @freq: the frequency
1330 * Convert frequency (MHz) to IEEE802.11 OFDM channel
1331 * Ref IEEE 802.11-2007 section 17.3.8.3.2
1333 * This routine selects the channel with the closest center frequency.
1335 static inline int ieee80211_freq_to_ofdm_chan(int s_freq, int freq)
1337 if ((freq > (s_freq + 2)) && (freq <= (s_freq + 1202)) &&
1339 return (freq + 2 - s_freq) / 5;
1344 #endif /* LINUX_IEEE80211_H */