include/asm-x86/user32.h: checkpatch cleanups - formatting only
[linux-2.6] / include / linux / ieee80211.h
1 /*
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>
19 #include <asm/byteorder.h>
20
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 */
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
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 */
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
91    6.2.1.1.2.
92
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
98
99 #define IEEE80211_MAX_SSID_LEN          32
100
101 struct ieee80211_hdr {
102         __le16 frame_control;
103         __le16 duration_id;
104         u8 addr1[6];
105         u8 addr2[6];
106         u8 addr3[6];
107         __le16 seq_ctrl;
108         u8 addr4[6];
109 } __attribute__ ((packed));
110
111
112 struct ieee80211_mgmt {
113         __le16 frame_control;
114         __le16 duration;
115         u8 da[6];
116         u8 sa[6];
117         u8 bssid[6];
118         __le16 seq_ctrl;
119         union {
120                 struct {
121                         __le16 auth_alg;
122                         __le16 auth_transaction;
123                         __le16 status_code;
124                         /* possibly followed by Challenge text */
125                         u8 variable[0];
126                 } __attribute__ ((packed)) auth;
127                 struct {
128                         __le16 reason_code;
129                 } __attribute__ ((packed)) deauth;
130                 struct {
131                         __le16 capab_info;
132                         __le16 listen_interval;
133                         /* followed by SSID and Supported rates */
134                         u8 variable[0];
135                 } __attribute__ ((packed)) assoc_req;
136                 struct {
137                         __le16 capab_info;
138                         __le16 status_code;
139                         __le16 aid;
140                         /* followed by Supported rates */
141                         u8 variable[0];
142                 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
143                 struct {
144                         __le16 capab_info;
145                         __le16 listen_interval;
146                         u8 current_ap[6];
147                         /* followed by SSID and Supported rates */
148                         u8 variable[0];
149                 } __attribute__ ((packed)) reassoc_req;
150                 struct {
151                         __le16 reason_code;
152                 } __attribute__ ((packed)) disassoc;
153                 struct {
154                         __le64 timestamp;
155                         __le16 beacon_int;
156                         __le16 capab_info;
157                         /* followed by some of SSID, Supported rates,
158                          * FH Params, DS Params, CF Params, IBSS Params, TIM */
159                         u8 variable[0];
160                 } __attribute__ ((packed)) beacon;
161                 struct {
162                         /* only variable items: SSID, Supported rates */
163                         u8 variable[0];
164                 } __attribute__ ((packed)) probe_req;
165                 struct {
166                         __le64 timestamp;
167                         __le16 beacon_int;
168                         __le16 capab_info;
169                         /* followed by some of SSID, Supported rates,
170                          * FH Params, DS Params, CF Params, IBSS Params */
171                         u8 variable[0];
172                 } __attribute__ ((packed)) probe_resp;
173                 struct {
174                         u8 category;
175                         union {
176                                 struct {
177                                         u8 action_code;
178                                         u8 dialog_token;
179                                         u8 status_code;
180                                         u8 variable[0];
181                                 } __attribute__ ((packed)) wme_action;
182                                 struct{
183                                         u8 action_code;
184                                         u8 element_id;
185                                         u8 length;
186                                         u8 switch_mode;
187                                         u8 new_chan;
188                                         u8 switch_count;
189                                 } __attribute__((packed)) chan_switch;
190                                 struct{
191                                         u8 action_code;
192                                         u8 dialog_token;
193                                         __le16 capab;
194                                         __le16 timeout;
195                                         __le16 start_seq_num;
196                                 } __attribute__((packed)) addba_req;
197                                 struct{
198                                         u8 action_code;
199                                         u8 dialog_token;
200                                         __le16 status;
201                                         __le16 capab;
202                                         __le16 timeout;
203                                 } __attribute__((packed)) addba_resp;
204                                 struct{
205                                         u8 action_code;
206                                         __le16 params;
207                                         __le16 reason_code;
208                                 } __attribute__((packed)) delba;
209                         } u;
210                 } __attribute__ ((packed)) action;
211         } u;
212 } __attribute__ ((packed));
213
214
215 /* Control frames */
216 struct ieee80211_rts {
217         __le16 frame_control;
218         __le16 duration;
219         u8 ra[6];
220         u8 ta[6];
221 } __attribute__ ((packed));
222
223 struct ieee80211_cts {
224         __le16 frame_control;
225         __le16 duration;
226         u8 ra[6];
227 } __attribute__ ((packed));
228
229 /**
230  * struct ieee80211_bar - HT Block Ack Request
231  *
232  * This structure refers to "HT BlockAckReq" as
233  * described in 802.11n draft section 7.2.1.7.1
234  */
235 struct ieee80211_bar {
236         __le16 frame_control;
237         __le16 duration;
238         __u8 ra[6];
239         __u8 ta[6];
240         __le16 control;
241         __le16 start_seq_num;
242 } __attribute__((packed));
243
244 /**
245  * struct ieee80211_ht_cap - HT capabilities
246  *
247  * This structure refers to "HT capabilities element" as
248  * described in 802.11n draft section 7.3.2.52
249  */
250 struct ieee80211_ht_cap {
251         __le16 cap_info;
252         u8 ampdu_params_info;
253         u8 supp_mcs_set[16];
254         __le16 extended_ht_cap_info;
255         __le32 tx_BF_cap_info;
256         u8 antenna_selection_info;
257 } __attribute__ ((packed));
258
259 /**
260  * struct ieee80211_ht_cap - HT additional information
261  *
262  * This structure refers to "HT information element" as
263  * described in 802.11n draft section 7.3.2.53
264  */
265 struct ieee80211_ht_addt_info {
266         u8 control_chan;
267         u8 ht_param;
268         __le16 operation_mode;
269         __le16 stbc_param;
270         u8 basic_set[16];
271 } __attribute__ ((packed));
272
273 /* 802.11n HT capabilities masks */
274 #define IEEE80211_HT_CAP_SUP_WIDTH              0x0002
275 #define IEEE80211_HT_CAP_MIMO_PS                0x000C
276 #define IEEE80211_HT_CAP_GRN_FLD                0x0010
277 #define IEEE80211_HT_CAP_SGI_20                 0x0020
278 #define IEEE80211_HT_CAP_SGI_40                 0x0040
279 #define IEEE80211_HT_CAP_DELAY_BA               0x0400
280 #define IEEE80211_HT_CAP_MAX_AMSDU              0x0800
281 #define IEEE80211_HT_CAP_AMPDU_FACTOR           0x03
282 #define IEEE80211_HT_CAP_AMPDU_DENSITY          0x1C
283 /* 802.11n HT IE masks */
284 #define IEEE80211_HT_IE_CHA_SEC_OFFSET          0x03
285 #define IEEE80211_HT_IE_CHA_WIDTH               0x04
286 #define IEEE80211_HT_IE_HT_PROTECTION           0x0003
287 #define IEEE80211_HT_IE_NON_GF_STA_PRSNT        0x0004
288 #define IEEE80211_HT_IE_NON_HT_STA_PRSNT        0x0010
289
290 /* MIMO Power Save Modes */
291 #define WLAN_HT_CAP_MIMO_PS_STATIC         0
292 #define WLAN_HT_CAP_MIMO_PS_DYNAMIC        1
293 #define WLAN_HT_CAP_MIMO_PS_INVALID        2
294 #define WLAN_HT_CAP_MIMO_PS_DISABLED       3
295
296 /* Authentication algorithms */
297 #define WLAN_AUTH_OPEN 0
298 #define WLAN_AUTH_SHARED_KEY 1
299 #define WLAN_AUTH_FAST_BSS_TRANSITION 2
300 #define WLAN_AUTH_LEAP 128
301
302 #define WLAN_AUTH_CHALLENGE_LEN 128
303
304 #define WLAN_CAPABILITY_ESS             (1<<0)
305 #define WLAN_CAPABILITY_IBSS            (1<<1)
306 #define WLAN_CAPABILITY_CF_POLLABLE     (1<<2)
307 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
308 #define WLAN_CAPABILITY_PRIVACY         (1<<4)
309 #define WLAN_CAPABILITY_SHORT_PREAMBLE  (1<<5)
310 #define WLAN_CAPABILITY_PBCC            (1<<6)
311 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
312 /* 802.11h */
313 #define WLAN_CAPABILITY_SPECTRUM_MGMT   (1<<8)
314 #define WLAN_CAPABILITY_QOS             (1<<9)
315 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
316 #define WLAN_CAPABILITY_DSSS_OFDM       (1<<13)
317
318 /* 802.11g ERP information element */
319 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
320 #define WLAN_ERP_USE_PROTECTION (1<<1)
321 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
322
323 /* WLAN_ERP_BARKER_PREAMBLE values */
324 enum {
325         WLAN_ERP_PREAMBLE_SHORT = 0,
326         WLAN_ERP_PREAMBLE_LONG = 1,
327 };
328
329 /* Status codes */
330 enum ieee80211_statuscode {
331         WLAN_STATUS_SUCCESS = 0,
332         WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
333         WLAN_STATUS_CAPS_UNSUPPORTED = 10,
334         WLAN_STATUS_REASSOC_NO_ASSOC = 11,
335         WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
336         WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
337         WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
338         WLAN_STATUS_CHALLENGE_FAIL = 15,
339         WLAN_STATUS_AUTH_TIMEOUT = 16,
340         WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
341         WLAN_STATUS_ASSOC_DENIED_RATES = 18,
342         /* 802.11b */
343         WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
344         WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
345         WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
346         /* 802.11h */
347         WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
348         WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
349         WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
350         /* 802.11g */
351         WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
352         WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
353         /* 802.11i */
354         WLAN_STATUS_INVALID_IE = 40,
355         WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
356         WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
357         WLAN_STATUS_INVALID_AKMP = 43,
358         WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
359         WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
360         WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
361         /* 802.11e */
362         WLAN_STATUS_UNSPECIFIED_QOS = 32,
363         WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
364         WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
365         WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
366         WLAN_STATUS_REQUEST_DECLINED = 37,
367         WLAN_STATUS_INVALID_QOS_PARAM = 38,
368         WLAN_STATUS_CHANGE_TSPEC = 39,
369         WLAN_STATUS_WAIT_TS_DELAY = 47,
370         WLAN_STATUS_NO_DIRECT_LINK = 48,
371         WLAN_STATUS_STA_NOT_PRESENT = 49,
372         WLAN_STATUS_STA_NOT_QSTA = 50,
373 };
374
375
376 /* Reason codes */
377 enum ieee80211_reasoncode {
378         WLAN_REASON_UNSPECIFIED = 1,
379         WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
380         WLAN_REASON_DEAUTH_LEAVING = 3,
381         WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
382         WLAN_REASON_DISASSOC_AP_BUSY = 5,
383         WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
384         WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
385         WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
386         WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
387         /* 802.11h */
388         WLAN_REASON_DISASSOC_BAD_POWER = 10,
389         WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
390         /* 802.11i */
391         WLAN_REASON_INVALID_IE = 13,
392         WLAN_REASON_MIC_FAILURE = 14,
393         WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
394         WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
395         WLAN_REASON_IE_DIFFERENT = 17,
396         WLAN_REASON_INVALID_GROUP_CIPHER = 18,
397         WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
398         WLAN_REASON_INVALID_AKMP = 20,
399         WLAN_REASON_UNSUPP_RSN_VERSION = 21,
400         WLAN_REASON_INVALID_RSN_IE_CAP = 22,
401         WLAN_REASON_IEEE8021X_FAILED = 23,
402         WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
403         /* 802.11e */
404         WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
405         WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
406         WLAN_REASON_DISASSOC_LOW_ACK = 34,
407         WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
408         WLAN_REASON_QSTA_LEAVE_QBSS = 36,
409         WLAN_REASON_QSTA_NOT_USE = 37,
410         WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
411         WLAN_REASON_QSTA_TIMEOUT = 39,
412         WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
413 };
414
415
416 /* Information Element IDs */
417 enum ieee80211_eid {
418         WLAN_EID_SSID = 0,
419         WLAN_EID_SUPP_RATES = 1,
420         WLAN_EID_FH_PARAMS = 2,
421         WLAN_EID_DS_PARAMS = 3,
422         WLAN_EID_CF_PARAMS = 4,
423         WLAN_EID_TIM = 5,
424         WLAN_EID_IBSS_PARAMS = 6,
425         WLAN_EID_CHALLENGE = 16,
426         /* 802.11d */
427         WLAN_EID_COUNTRY = 7,
428         WLAN_EID_HP_PARAMS = 8,
429         WLAN_EID_HP_TABLE = 9,
430         WLAN_EID_REQUEST = 10,
431         /* 802.11e */
432         WLAN_EID_QBSS_LOAD = 11,
433         WLAN_EID_EDCA_PARAM_SET = 12,
434         WLAN_EID_TSPEC = 13,
435         WLAN_EID_TCLAS = 14,
436         WLAN_EID_SCHEDULE = 15,
437         WLAN_EID_TS_DELAY = 43,
438         WLAN_EID_TCLAS_PROCESSING = 44,
439         WLAN_EID_QOS_CAPA = 46,
440         /* 802.11h */
441         WLAN_EID_PWR_CONSTRAINT = 32,
442         WLAN_EID_PWR_CAPABILITY = 33,
443         WLAN_EID_TPC_REQUEST = 34,
444         WLAN_EID_TPC_REPORT = 35,
445         WLAN_EID_SUPPORTED_CHANNELS = 36,
446         WLAN_EID_CHANNEL_SWITCH = 37,
447         WLAN_EID_MEASURE_REQUEST = 38,
448         WLAN_EID_MEASURE_REPORT = 39,
449         WLAN_EID_QUIET = 40,
450         WLAN_EID_IBSS_DFS = 41,
451         /* 802.11g */
452         WLAN_EID_ERP_INFO = 42,
453         WLAN_EID_EXT_SUPP_RATES = 50,
454         /* 802.11n */
455         WLAN_EID_HT_CAPABILITY = 45,
456         WLAN_EID_HT_EXTRA_INFO = 61,
457         /* 802.11i */
458         WLAN_EID_RSN = 48,
459         WLAN_EID_WPA = 221,
460         WLAN_EID_GENERIC = 221,
461         WLAN_EID_VENDOR_SPECIFIC = 221,
462         WLAN_EID_QOS_PARAMETER = 222
463 };
464
465 /* Action category code */
466 enum ieee80211_category {
467         WLAN_CATEGORY_SPECTRUM_MGMT = 0,
468         WLAN_CATEGORY_QOS = 1,
469         WLAN_CATEGORY_DLS = 2,
470         WLAN_CATEGORY_BACK = 3,
471         WLAN_CATEGORY_WMM = 17,
472 };
473
474 /* BACK action code */
475 enum ieee80211_back_actioncode {
476         WLAN_ACTION_ADDBA_REQ = 0,
477         WLAN_ACTION_ADDBA_RESP = 1,
478         WLAN_ACTION_DELBA = 2,
479 };
480
481 /* BACK (block-ack) parties */
482 enum ieee80211_back_parties {
483         WLAN_BACK_RECIPIENT = 0,
484         WLAN_BACK_INITIATOR = 1,
485         WLAN_BACK_TIMER = 2,
486 };
487
488 /* A-MSDU 802.11n */
489 #define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
490
491 /* cipher suite selectors */
492 #define WLAN_CIPHER_SUITE_USE_GROUP     0x000FAC00
493 #define WLAN_CIPHER_SUITE_WEP40         0x000FAC01
494 #define WLAN_CIPHER_SUITE_TKIP          0x000FAC02
495 /* reserved:                            0x000FAC03 */
496 #define WLAN_CIPHER_SUITE_CCMP          0x000FAC04
497 #define WLAN_CIPHER_SUITE_WEP104        0x000FAC05
498
499 #define WLAN_MAX_KEY_LEN                32
500
501 /**
502  * ieee80211_get_SA - get pointer to SA
503  *
504  * Given an 802.11 frame, this function returns the offset
505  * to the source address (SA). It does not verify that the
506  * header is long enough to contain the address, and the
507  * header must be long enough to contain the frame control
508  * field.
509  *
510  * @hdr: the frame
511  */
512 static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
513 {
514         u8 *raw = (u8 *) hdr;
515         u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */
516
517         switch (tofrom) {
518                 case 2:
519                         return hdr->addr3;
520                 case 3:
521                         return hdr->addr4;
522         }
523         return hdr->addr2;
524 }
525
526 /**
527  * ieee80211_get_DA - get pointer to DA
528  *
529  * Given an 802.11 frame, this function returns the offset
530  * to the destination address (DA). It does not verify that
531  * the header is long enough to contain the address, and the
532  * header must be long enough to contain the frame control
533  * field.
534  *
535  * @hdr: the frame
536  */
537 static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
538 {
539         u8 *raw = (u8 *) hdr;
540         u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */
541
542         if (to_ds)
543                 return hdr->addr3;
544         return hdr->addr1;
545 }
546
547 /**
548  * ieee80211_get_morefrag - determine whether the MOREFRAGS bit is set
549  *
550  * This function determines whether the "more fragments" bit is set
551  * in the frame.
552  *
553  * @hdr: the frame
554  */
555 static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr)
556 {
557         return (le16_to_cpu(hdr->frame_control) &
558                 IEEE80211_FCTL_MOREFRAGS) != 0;
559 }
560
561 #endif /* IEEE80211_H */