blob: aa603c3d76d161e55a7fe1bed6fbc4c11354daf5 [file] [log] [blame]
Jiri Benca9de8ce2007-05-05 11:43:04 -07001/*
2 * IEEE 802.11 defines
3 *
4 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
5 * <jkmaline@cc.hut.fi>
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>
9 *
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.
13 */
14
15#ifndef IEEE80211_H
16#define IEEE80211_H
17
18#include <linux/types.h>
Johannes Bergf97df022007-09-18 17:29:20 -040019#include <asm/byteorder.h>
Jiri Benca9de8ce2007-05-05 11:43:04 -070020
21#define FCS_LEN 4
22
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
34
35#define IEEE80211_SCTL_FRAG 0x000F
36#define IEEE80211_SCTL_SEQ 0xFFF0
37
38#define IEEE80211_FTYPE_MGMT 0x0000
39#define IEEE80211_FTYPE_CTL 0x0004
40#define IEEE80211_FTYPE_DATA 0x0008
41
42/* management */
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
55
56/* control */
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +020057#define IEEE80211_STYPE_BACK_REQ 0x0080
58#define IEEE80211_STYPE_BACK 0x0090
Jiri Benca9de8ce2007-05-05 11:43:04 -070059#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
65
66/* data */
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
83
84
85/* miscellaneous IEEE 802.11 constants */
Michael Wuc2378992007-10-30 16:50:05 -040086#define IEEE80211_MAX_FRAG_THRESHOLD 2352
87#define IEEE80211_MAX_RTS_THRESHOLD 2353
Jiri Benca9de8ce2007-05-05 11:43:04 -070088#define IEEE80211_MAX_AID 2007
89#define IEEE80211_MAX_TIM_LEN 251
Jiri Benca9de8ce2007-05-05 11:43:04 -070090/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
91 6.2.1.1.2.
92
Michael Wuc2378992007-10-30 16:50:05 -040093 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
Jiri Benca9de8ce2007-05-05 11:43:04 -070098
99#define IEEE80211_MAX_SSID_LEN 32
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100100#define IEEE80211_MAX_MESH_ID_LEN 32
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -0700101#define IEEE80211_QOS_CTL_LEN 2
Jiri Benca9de8ce2007-05-05 11:43:04 -0700102
103struct ieee80211_hdr {
104 __le16 frame_control;
105 __le16 duration_id;
106 u8 addr1[6];
107 u8 addr2[6];
108 u8 addr3[6];
109 __le16 seq_ctrl;
110 u8 addr4[6];
111} __attribute__ ((packed));
112
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -0700113/**
114 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
115 * @fc: frame control bytes in little-endian byteorder
116 */
117static inline int ieee80211_has_tods(__le16 fc)
118{
119 return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
120}
121
122/**
123 * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
124 * @fc: frame control bytes in little-endian byteorder
125 */
126static inline int ieee80211_has_fromds(__le16 fc)
127{
128 return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
129}
130
131/**
132 * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
133 * @fc: frame control bytes in little-endian byteorder
134 */
135static inline int ieee80211_has_a4(__le16 fc)
136{
137 __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
138 return (fc & tmp) == tmp;
139}
140
141/**
142 * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
143 * @fc: frame control bytes in little-endian byteorder
144 */
145static inline int ieee80211_has_morefrags(__le16 fc)
146{
147 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
148}
149
150/**
151 * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
152 * @fc: frame control bytes in little-endian byteorder
153 */
154static inline int ieee80211_has_retry(__le16 fc)
155{
156 return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
157}
158
159/**
160 * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
161 * @fc: frame control bytes in little-endian byteorder
162 */
163static inline int ieee80211_has_pm(__le16 fc)
164{
165 return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
166}
167
168/**
169 * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
170 * @fc: frame control bytes in little-endian byteorder
171 */
172static inline int ieee80211_has_moredata(__le16 fc)
173{
174 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
175}
176
177/**
178 * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
179 * @fc: frame control bytes in little-endian byteorder
180 */
181static inline int ieee80211_has_protected(__le16 fc)
182{
183 return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
184}
185
186/**
187 * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
188 * @fc: frame control bytes in little-endian byteorder
189 */
190static inline int ieee80211_has_order(__le16 fc)
191{
192 return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
193}
194
195/**
196 * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
197 * @fc: frame control bytes in little-endian byteorder
198 */
199static inline int ieee80211_is_mgmt(__le16 fc)
200{
201 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
202 cpu_to_le16(IEEE80211_FTYPE_MGMT);
203}
204
205/**
206 * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
207 * @fc: frame control bytes in little-endian byteorder
208 */
209static inline int ieee80211_is_ctl(__le16 fc)
210{
211 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
212 cpu_to_le16(IEEE80211_FTYPE_CTL);
213}
214
215/**
216 * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
217 * @fc: frame control bytes in little-endian byteorder
218 */
219static inline int ieee80211_is_data(__le16 fc)
220{
221 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
222 cpu_to_le16(IEEE80211_FTYPE_DATA);
223}
224
225/**
226 * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
227 * @fc: frame control bytes in little-endian byteorder
228 */
229static inline int ieee80211_is_data_qos(__le16 fc)
230{
231 /*
232 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
233 * to check the one bit
234 */
235 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
236 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
237}
238
239/**
240 * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
241 * @fc: frame control bytes in little-endian byteorder
242 */
243static inline int ieee80211_is_data_present(__le16 fc)
244{
245 /*
246 * mask with 0x40 and test that that bit is clear to only return true
247 * for the data-containing substypes.
248 */
249 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
250 cpu_to_le16(IEEE80211_FTYPE_DATA);
251}
252
253/**
254 * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
255 * @fc: frame control bytes in little-endian byteorder
256 */
257static inline int ieee80211_is_assoc_req(__le16 fc)
258{
259 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
260 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
261}
262
263/**
264 * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
265 * @fc: frame control bytes in little-endian byteorder
266 */
267static inline int ieee80211_is_assoc_resp(__le16 fc)
268{
269 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
270 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
271}
272
273/**
274 * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
275 * @fc: frame control bytes in little-endian byteorder
276 */
277static inline int ieee80211_is_reassoc_req(__le16 fc)
278{
279 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
280 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
281}
282
283/**
284 * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
285 * @fc: frame control bytes in little-endian byteorder
286 */
287static inline int ieee80211_is_reassoc_resp(__le16 fc)
288{
289 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
290 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
291}
292
293/**
294 * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
295 * @fc: frame control bytes in little-endian byteorder
296 */
297static inline int ieee80211_is_probe_req(__le16 fc)
298{
299 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
300 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
301}
302
303/**
304 * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
305 * @fc: frame control bytes in little-endian byteorder
306 */
307static inline int ieee80211_is_probe_resp(__le16 fc)
308{
309 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
310 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
311}
312
313/**
314 * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
315 * @fc: frame control bytes in little-endian byteorder
316 */
317static inline int ieee80211_is_beacon(__le16 fc)
318{
319 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
320 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
321}
322
323/**
324 * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
325 * @fc: frame control bytes in little-endian byteorder
326 */
327static inline int ieee80211_is_atim(__le16 fc)
328{
329 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
330 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
331}
332
333/**
334 * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
335 * @fc: frame control bytes in little-endian byteorder
336 */
337static inline int ieee80211_is_disassoc(__le16 fc)
338{
339 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
340 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
341}
342
343/**
344 * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
345 * @fc: frame control bytes in little-endian byteorder
346 */
347static inline int ieee80211_is_auth(__le16 fc)
348{
349 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
350 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
351}
352
353/**
354 * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
355 * @fc: frame control bytes in little-endian byteorder
356 */
357static inline int ieee80211_is_deauth(__le16 fc)
358{
359 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
360 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
361}
362
363/**
364 * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
365 * @fc: frame control bytes in little-endian byteorder
366 */
367static inline int ieee80211_is_action(__le16 fc)
368{
369 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
370 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
371}
372
373/**
374 * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
375 * @fc: frame control bytes in little-endian byteorder
376 */
377static inline int ieee80211_is_back_req(__le16 fc)
378{
379 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
380 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
381}
382
383/**
384 * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
385 * @fc: frame control bytes in little-endian byteorder
386 */
387static inline int ieee80211_is_back(__le16 fc)
388{
389 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
390 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
391}
392
393/**
394 * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
395 * @fc: frame control bytes in little-endian byteorder
396 */
397static inline int ieee80211_is_pspoll(__le16 fc)
398{
399 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
400 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
401}
402
403/**
404 * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
405 * @fc: frame control bytes in little-endian byteorder
406 */
407static inline int ieee80211_is_rts(__le16 fc)
408{
409 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
410 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
411}
412
413/**
414 * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
415 * @fc: frame control bytes in little-endian byteorder
416 */
417static inline int ieee80211_is_cts(__le16 fc)
418{
419 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
420 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
421}
422
423/**
424 * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
425 * @fc: frame control bytes in little-endian byteorder
426 */
427static inline int ieee80211_is_ack(__le16 fc)
428{
429 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
430 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
431}
432
433/**
434 * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
435 * @fc: frame control bytes in little-endian byteorder
436 */
437static inline int ieee80211_is_cfend(__le16 fc)
438{
439 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
440 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
441}
442
443/**
444 * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
445 * @fc: frame control bytes in little-endian byteorder
446 */
447static inline int ieee80211_is_cfendack(__le16 fc)
448{
449 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
450 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
451}
452
453/**
454 * ieee80211_is_nullfunc - check if FTYPE=IEEE80211_FTYPE_DATA and STYPE=IEEE80211_STYPE_NULLFUNC
455 * @fc: frame control bytes in little-endian byteorder
456 */
457static inline int ieee80211_is_nullfunc(__le16 fc)
458{
459 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
460 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
461}
Jiri Benca9de8ce2007-05-05 11:43:04 -0700462
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100463struct ieee80211s_hdr {
464 u8 flags;
465 u8 ttl;
Luis Carlos Cobo51cedda2008-04-23 12:15:29 -0700466 __le32 seqnum;
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100467 u8 eaddr1[6];
468 u8 eaddr2[6];
469 u8 eaddr3[6];
470} __attribute__ ((packed));
471
Assaf Kraussf2df3852008-06-15 18:23:29 +0300472/**
473 * struct ieee80211_quiet_ie
474 *
475 * This structure refers to "Quiet information element"
476 */
477struct ieee80211_quiet_ie {
478 u8 count;
479 u8 period;
480 __le16 duration;
481 __le16 offset;
482} __attribute__ ((packed));
483
484/**
485 * struct ieee80211_msrment_ie
486 *
487 * This structure refers to "Measurement Request/Report information element"
488 */
489struct ieee80211_msrment_ie {
490 u8 token;
491 u8 mode;
492 u8 type;
493 u8 request[0];
494} __attribute__ ((packed));
495
496/**
497 * struct ieee80211_channel_sw_ie
498 *
499 * This structure refers to "Channel Switch Announcement information element"
500 */
501struct ieee80211_channel_sw_ie {
502 u8 mode;
503 u8 new_ch_num;
504 u8 count;
505} __attribute__ ((packed));
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100506
Jiri Benca9de8ce2007-05-05 11:43:04 -0700507struct ieee80211_mgmt {
508 __le16 frame_control;
509 __le16 duration;
510 u8 da[6];
511 u8 sa[6];
512 u8 bssid[6];
513 __le16 seq_ctrl;
514 union {
515 struct {
516 __le16 auth_alg;
517 __le16 auth_transaction;
518 __le16 status_code;
519 /* possibly followed by Challenge text */
520 u8 variable[0];
521 } __attribute__ ((packed)) auth;
522 struct {
523 __le16 reason_code;
524 } __attribute__ ((packed)) deauth;
525 struct {
526 __le16 capab_info;
527 __le16 listen_interval;
528 /* followed by SSID and Supported rates */
529 u8 variable[0];
530 } __attribute__ ((packed)) assoc_req;
531 struct {
532 __le16 capab_info;
533 __le16 status_code;
534 __le16 aid;
535 /* followed by Supported rates */
536 u8 variable[0];
537 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
538 struct {
539 __le16 capab_info;
540 __le16 listen_interval;
541 u8 current_ap[6];
542 /* followed by SSID and Supported rates */
543 u8 variable[0];
544 } __attribute__ ((packed)) reassoc_req;
545 struct {
546 __le16 reason_code;
547 } __attribute__ ((packed)) disassoc;
548 struct {
549 __le64 timestamp;
550 __le16 beacon_int;
551 __le16 capab_info;
552 /* followed by some of SSID, Supported rates,
553 * FH Params, DS Params, CF Params, IBSS Params, TIM */
554 u8 variable[0];
555 } __attribute__ ((packed)) beacon;
556 struct {
557 /* only variable items: SSID, Supported rates */
558 u8 variable[0];
559 } __attribute__ ((packed)) probe_req;
560 struct {
561 __le64 timestamp;
562 __le16 beacon_int;
563 __le16 capab_info;
564 /* followed by some of SSID, Supported rates,
565 * FH Params, DS Params, CF Params, IBSS Params */
566 u8 variable[0];
567 } __attribute__ ((packed)) probe_resp;
568 struct {
569 u8 category;
570 union {
571 struct {
572 u8 action_code;
573 u8 dialog_token;
574 u8 status_code;
575 u8 variable[0];
576 } __attribute__ ((packed)) wme_action;
577 struct{
578 u8 action_code;
579 u8 element_id;
580 u8 length;
Assaf Kraussf2df3852008-06-15 18:23:29 +0300581 struct ieee80211_channel_sw_ie sw_elem;
Jiri Benca9de8ce2007-05-05 11:43:04 -0700582 } __attribute__((packed)) chan_switch;
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200583 struct{
584 u8 action_code;
585 u8 dialog_token;
Assaf Kraussf2df3852008-06-15 18:23:29 +0300586 u8 element_id;
587 u8 length;
588 struct ieee80211_msrment_ie msr_elem;
589 } __attribute__((packed)) measurement;
590 struct{
591 u8 action_code;
592 u8 dialog_token;
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200593 __le16 capab;
594 __le16 timeout;
595 __le16 start_seq_num;
596 } __attribute__((packed)) addba_req;
597 struct{
598 u8 action_code;
599 u8 dialog_token;
600 __le16 status;
601 __le16 capab;
602 __le16 timeout;
603 } __attribute__((packed)) addba_resp;
604 struct{
605 u8 action_code;
606 __le16 params;
607 __le16 reason_code;
608 } __attribute__((packed)) delba;
Luis Carlos Cobo37c57982008-02-23 15:17:04 +0100609 struct{
610 u8 action_code;
611 /* capab_info for open and confirm,
612 * reason for close
613 */
614 __le16 aux;
615 /* Followed in plink_confirm by status
616 * code, AID and supported rates,
617 * and directly by supported rates in
618 * plink_open and plink_close
619 */
620 u8 variable[0];
621 } __attribute__((packed)) plink_action;
622 struct{
623 u8 action_code;
624 u8 variable[0];
625 } __attribute__((packed)) mesh_action;
Jiri Benca9de8ce2007-05-05 11:43:04 -0700626 } u;
627 } __attribute__ ((packed)) action;
628 } u;
629} __attribute__ ((packed));
630
631
632/* Control frames */
633struct ieee80211_rts {
634 __le16 frame_control;
635 __le16 duration;
636 u8 ra[6];
637 u8 ta[6];
638} __attribute__ ((packed));
639
640struct ieee80211_cts {
641 __le16 frame_control;
642 __le16 duration;
643 u8 ra[6];
644} __attribute__ ((packed));
645
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200646/**
647 * struct ieee80211_bar - HT Block Ack Request
648 *
649 * This structure refers to "HT BlockAckReq" as
650 * described in 802.11n draft section 7.2.1.7.1
651 */
652struct ieee80211_bar {
653 __le16 frame_control;
654 __le16 duration;
655 __u8 ra[6];
656 __u8 ta[6];
Ron Rindjunskya8b47ea2008-01-21 12:39:11 +0200657 __le16 control;
658 __le16 start_seq_num;
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200659} __attribute__((packed));
660
Ron Rindjunsky429a3802008-07-01 14:16:03 +0300661/* 802.11 BAR control masks */
662#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
663#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
664
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200665/**
666 * struct ieee80211_ht_cap - HT capabilities
667 *
668 * This structure refers to "HT capabilities element" as
669 * described in 802.11n draft section 7.3.2.52
670 */
671struct ieee80211_ht_cap {
672 __le16 cap_info;
673 u8 ampdu_params_info;
674 u8 supp_mcs_set[16];
675 __le16 extended_ht_cap_info;
676 __le32 tx_BF_cap_info;
677 u8 antenna_selection_info;
678} __attribute__ ((packed));
679
680/**
681 * struct ieee80211_ht_cap - HT additional information
682 *
683 * This structure refers to "HT information element" as
684 * described in 802.11n draft section 7.3.2.53
685 */
686struct ieee80211_ht_addt_info {
687 u8 control_chan;
688 u8 ht_param;
689 __le16 operation_mode;
690 __le16 stbc_param;
691 u8 basic_set[16];
692} __attribute__ ((packed));
693
694/* 802.11n HT capabilities masks */
695#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
696#define IEEE80211_HT_CAP_MIMO_PS 0x000C
697#define IEEE80211_HT_CAP_GRN_FLD 0x0010
698#define IEEE80211_HT_CAP_SGI_20 0x0020
699#define IEEE80211_HT_CAP_SGI_40 0x0040
700#define IEEE80211_HT_CAP_DELAY_BA 0x0400
701#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
Ron Rindjunskyedcdf8b2008-05-15 13:53:55 +0800702/* 802.11n HT capability AMPDU settings */
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200703#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
704#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
Ron Rindjunskyedcdf8b2008-05-15 13:53:55 +0800705/* 802.11n HT capability MSC set */
706#define IEEE80211_SUPP_MCS_SET_UEQM 4
707#define IEEE80211_HT_CAP_MAX_STREAMS 4
708#define IEEE80211_SUPP_MCS_SET_LEN 10
709/* maximum streams the spec allows */
710#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01
711#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02
712#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C
713#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200714/* 802.11n HT IE masks */
715#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
Emmanuel Grumbach963f5512008-06-12 09:47:00 +0800716#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00
Emmanuel Grumbach93061022008-05-29 16:35:23 +0800717#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01
718#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200719#define IEEE80211_HT_IE_CHA_WIDTH 0x04
720#define IEEE80211_HT_IE_HT_PROTECTION 0x0003
721#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
722#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
Jiri Benca9de8ce2007-05-05 11:43:04 -0700723
Tomas Winklere53cfe02008-01-30 22:05:13 -0800724/* MIMO Power Save Modes */
Ron Rindjunskyedcdf8b2008-05-15 13:53:55 +0800725#define WLAN_HT_CAP_MIMO_PS_STATIC 0
726#define WLAN_HT_CAP_MIMO_PS_DYNAMIC 1
727#define WLAN_HT_CAP_MIMO_PS_INVALID 2
728#define WLAN_HT_CAP_MIMO_PS_DISABLED 3
Tomas Winklere53cfe02008-01-30 22:05:13 -0800729
Jiri Benca9de8ce2007-05-05 11:43:04 -0700730/* Authentication algorithms */
731#define WLAN_AUTH_OPEN 0
732#define WLAN_AUTH_SHARED_KEY 1
733#define WLAN_AUTH_FAST_BSS_TRANSITION 2
734#define WLAN_AUTH_LEAP 128
735
736#define WLAN_AUTH_CHALLENGE_LEN 128
737
738#define WLAN_CAPABILITY_ESS (1<<0)
739#define WLAN_CAPABILITY_IBSS (1<<1)
740#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
741#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
742#define WLAN_CAPABILITY_PRIVACY (1<<4)
743#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
744#define WLAN_CAPABILITY_PBCC (1<<6)
745#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
Assaf Kraussb6623482008-06-16 16:09:49 +0300746
Jiri Benca9de8ce2007-05-05 11:43:04 -0700747/* 802.11h */
748#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
749#define WLAN_CAPABILITY_QOS (1<<9)
750#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
751#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
Assaf Kraussb6623482008-06-16 16:09:49 +0300752/* measurement */
753#define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
754#define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
755#define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
756
757#define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
758#define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
759#define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
760
Jiri Benca9de8ce2007-05-05 11:43:04 -0700761
Daniel Drake56282212007-07-10 19:32:10 +0200762/* 802.11g ERP information element */
763#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
764#define WLAN_ERP_USE_PROTECTION (1<<1)
765#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
766
767/* WLAN_ERP_BARKER_PREAMBLE values */
768enum {
769 WLAN_ERP_PREAMBLE_SHORT = 0,
770 WLAN_ERP_PREAMBLE_LONG = 1,
771};
772
Jiri Benca9de8ce2007-05-05 11:43:04 -0700773/* Status codes */
774enum ieee80211_statuscode {
775 WLAN_STATUS_SUCCESS = 0,
776 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
777 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
778 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
779 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
780 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
781 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
782 WLAN_STATUS_CHALLENGE_FAIL = 15,
783 WLAN_STATUS_AUTH_TIMEOUT = 16,
784 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
785 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
786 /* 802.11b */
787 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
788 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
789 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
790 /* 802.11h */
791 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
792 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
793 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
794 /* 802.11g */
795 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
796 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
797 /* 802.11i */
798 WLAN_STATUS_INVALID_IE = 40,
799 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
800 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
801 WLAN_STATUS_INVALID_AKMP = 43,
802 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
803 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
804 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200805 /* 802.11e */
806 WLAN_STATUS_UNSPECIFIED_QOS = 32,
807 WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
808 WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
809 WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
810 WLAN_STATUS_REQUEST_DECLINED = 37,
811 WLAN_STATUS_INVALID_QOS_PARAM = 38,
812 WLAN_STATUS_CHANGE_TSPEC = 39,
813 WLAN_STATUS_WAIT_TS_DELAY = 47,
814 WLAN_STATUS_NO_DIRECT_LINK = 48,
815 WLAN_STATUS_STA_NOT_PRESENT = 49,
816 WLAN_STATUS_STA_NOT_QSTA = 50,
Jiri Benca9de8ce2007-05-05 11:43:04 -0700817};
818
819
820/* Reason codes */
821enum ieee80211_reasoncode {
822 WLAN_REASON_UNSPECIFIED = 1,
823 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
824 WLAN_REASON_DEAUTH_LEAVING = 3,
825 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
826 WLAN_REASON_DISASSOC_AP_BUSY = 5,
827 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
828 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
829 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
830 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
831 /* 802.11h */
832 WLAN_REASON_DISASSOC_BAD_POWER = 10,
833 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
834 /* 802.11i */
835 WLAN_REASON_INVALID_IE = 13,
836 WLAN_REASON_MIC_FAILURE = 14,
837 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
838 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
839 WLAN_REASON_IE_DIFFERENT = 17,
840 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
841 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
842 WLAN_REASON_INVALID_AKMP = 20,
843 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
844 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
845 WLAN_REASON_IEEE8021X_FAILED = 23,
846 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200847 /* 802.11e */
848 WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
849 WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
850 WLAN_REASON_DISASSOC_LOW_ACK = 34,
851 WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
852 WLAN_REASON_QSTA_LEAVE_QBSS = 36,
853 WLAN_REASON_QSTA_NOT_USE = 37,
854 WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
855 WLAN_REASON_QSTA_TIMEOUT = 39,
856 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
Jiri Benca9de8ce2007-05-05 11:43:04 -0700857};
858
859
860/* Information Element IDs */
861enum ieee80211_eid {
862 WLAN_EID_SSID = 0,
863 WLAN_EID_SUPP_RATES = 1,
864 WLAN_EID_FH_PARAMS = 2,
865 WLAN_EID_DS_PARAMS = 3,
866 WLAN_EID_CF_PARAMS = 4,
867 WLAN_EID_TIM = 5,
868 WLAN_EID_IBSS_PARAMS = 6,
869 WLAN_EID_CHALLENGE = 16,
870 /* 802.11d */
871 WLAN_EID_COUNTRY = 7,
872 WLAN_EID_HP_PARAMS = 8,
873 WLAN_EID_HP_TABLE = 9,
874 WLAN_EID_REQUEST = 10,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200875 /* 802.11e */
876 WLAN_EID_QBSS_LOAD = 11,
877 WLAN_EID_EDCA_PARAM_SET = 12,
878 WLAN_EID_TSPEC = 13,
879 WLAN_EID_TCLAS = 14,
880 WLAN_EID_SCHEDULE = 15,
881 WLAN_EID_TS_DELAY = 43,
882 WLAN_EID_TCLAS_PROCESSING = 44,
883 WLAN_EID_QOS_CAPA = 46,
Luis Carlos Cobod619ee02008-04-23 12:34:59 -0700884 /* 802.11s
885 *
886 * All mesh EID numbers are pending IEEE 802.11 ANA approval.
887 * The numbers have been incremented from those suggested in
888 * 802.11s/D2.0 so that MESH_CONFIG does not conflict with
889 * EXT_SUPP_RATES.
890 */
891 WLAN_EID_MESH_CONFIG = 51,
892 WLAN_EID_MESH_ID = 52,
893 WLAN_EID_PEER_LINK = 55,
894 WLAN_EID_PREQ = 68,
895 WLAN_EID_PREP = 69,
896 WLAN_EID_PERR = 70,
Jiri Benca9de8ce2007-05-05 11:43:04 -0700897 /* 802.11h */
898 WLAN_EID_PWR_CONSTRAINT = 32,
899 WLAN_EID_PWR_CAPABILITY = 33,
900 WLAN_EID_TPC_REQUEST = 34,
901 WLAN_EID_TPC_REPORT = 35,
902 WLAN_EID_SUPPORTED_CHANNELS = 36,
903 WLAN_EID_CHANNEL_SWITCH = 37,
904 WLAN_EID_MEASURE_REQUEST = 38,
905 WLAN_EID_MEASURE_REPORT = 39,
906 WLAN_EID_QUIET = 40,
907 WLAN_EID_IBSS_DFS = 41,
908 /* 802.11g */
909 WLAN_EID_ERP_INFO = 42,
910 WLAN_EID_EXT_SUPP_RATES = 50,
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200911 /* 802.11n */
912 WLAN_EID_HT_CAPABILITY = 45,
913 WLAN_EID_HT_EXTRA_INFO = 61,
Jiri Benca9de8ce2007-05-05 11:43:04 -0700914 /* 802.11i */
915 WLAN_EID_RSN = 48,
916 WLAN_EID_WPA = 221,
917 WLAN_EID_GENERIC = 221,
918 WLAN_EID_VENDOR_SPECIFIC = 221,
919 WLAN_EID_QOS_PARAMETER = 222
920};
921
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200922/* Action category code */
923enum ieee80211_category {
924 WLAN_CATEGORY_SPECTRUM_MGMT = 0,
925 WLAN_CATEGORY_QOS = 1,
926 WLAN_CATEGORY_DLS = 2,
927 WLAN_CATEGORY_BACK = 3,
928 WLAN_CATEGORY_WMM = 17,
929};
930
Assaf Kraussf2df3852008-06-15 18:23:29 +0300931/* SPECTRUM_MGMT action code */
932enum ieee80211_spectrum_mgmt_actioncode {
933 WLAN_ACTION_SPCT_MSR_REQ = 0,
934 WLAN_ACTION_SPCT_MSR_RPRT = 1,
935 WLAN_ACTION_SPCT_TPC_REQ = 2,
936 WLAN_ACTION_SPCT_TPC_RPRT = 3,
937 WLAN_ACTION_SPCT_CHL_SWITCH = 4,
938};
939
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200940/* BACK action code */
941enum ieee80211_back_actioncode {
942 WLAN_ACTION_ADDBA_REQ = 0,
943 WLAN_ACTION_ADDBA_RESP = 1,
944 WLAN_ACTION_DELBA = 2,
945};
946
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200947/* BACK (block-ack) parties */
948enum ieee80211_back_parties {
949 WLAN_BACK_RECIPIENT = 0,
950 WLAN_BACK_INITIATOR = 1,
951 WLAN_BACK_TIMER = 2,
952};
953
Ron Rindjunsky6b4e3242007-11-14 19:57:38 +0200954/* A-MSDU 802.11n */
955#define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
956
Jiri Benca9de8ce2007-05-05 11:43:04 -0700957/* cipher suite selectors */
958#define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
959#define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
960#define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
961/* reserved: 0x000FAC03 */
962#define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
963#define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
964
965#define WLAN_MAX_KEY_LEN 32
966
Johannes Bergf97df022007-09-18 17:29:20 -0400967/**
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -0700968 * ieee80211_get_qos_ctl - get pointer to qos control bytes
969 * @hdr: the frame
970 *
971 * The qos ctrl bytes come after the frame_control, duration, seq_num
972 * and 3 or 4 addresses of length ETH_ALEN.
973 * 3 addr: 2 + 2 + 2 + 3*6 = 24
974 * 4 addr: 2 + 2 + 2 + 4*6 = 30
975 */
976static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
977{
978 if (ieee80211_has_a4(hdr->frame_control))
979 return (u8 *)hdr + 30;
980 else
981 return (u8 *)hdr + 24;
982}
983
984/**
Johannes Bergf97df022007-09-18 17:29:20 -0400985 * ieee80211_get_SA - get pointer to SA
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -0700986 * @hdr: the frame
Johannes Bergf97df022007-09-18 17:29:20 -0400987 *
988 * Given an 802.11 frame, this function returns the offset
989 * to the source address (SA). It does not verify that the
990 * header is long enough to contain the address, and the
991 * header must be long enough to contain the frame control
992 * field.
Johannes Bergf97df022007-09-18 17:29:20 -0400993 */
994static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
995{
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -0700996 if (ieee80211_has_a4(hdr->frame_control))
Harvey Harrison5a433b32008-04-21 10:41:10 -0700997 return hdr->addr4;
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -0700998 if (ieee80211_has_fromds(hdr->frame_control))
999 return hdr->addr3;
1000 return hdr->addr2;
Johannes Bergf97df022007-09-18 17:29:20 -04001001}
1002
1003/**
1004 * ieee80211_get_DA - get pointer to DA
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001005 * @hdr: the frame
Johannes Bergf97df022007-09-18 17:29:20 -04001006 *
1007 * Given an 802.11 frame, this function returns the offset
1008 * to the destination address (DA). It does not verify that
1009 * the header is long enough to contain the address, and the
1010 * header must be long enough to contain the frame control
1011 * field.
Johannes Bergf97df022007-09-18 17:29:20 -04001012 */
1013static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1014{
Harvey Harrisonfd7c8a42008-06-11 14:21:56 -07001015 if (ieee80211_has_tods(hdr->frame_control))
Johannes Bergf97df022007-09-18 17:29:20 -04001016 return hdr->addr3;
Harvey Harrison5a433b32008-04-21 10:41:10 -07001017 else
1018 return hdr->addr1;
Johannes Bergf97df022007-09-18 17:29:20 -04001019}
1020
Jiri Benca9de8ce2007-05-05 11:43:04 -07001021#endif /* IEEE80211_H */