f7c47d9823e8bb4236d805ce00ef4eb15cc566ca
[wpasupplicant] / src / common / ieee802_11_defs.h
1 /*
2  * IEEE 802.11 Frame type definitions
3  * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #ifndef IEEE802_11_DEFS_H
16 #define IEEE802_11_DEFS_H
17
18 /* IEEE 802.11 defines */
19
20 #define WLAN_FC_PVER            0x0003
21 #define WLAN_FC_TODS            0x0100
22 #define WLAN_FC_FROMDS          0x0200
23 #define WLAN_FC_MOREFRAG        0x0400
24 #define WLAN_FC_RETRY           0x0800
25 #define WLAN_FC_PWRMGT          0x1000
26 #define WLAN_FC_MOREDATA        0x2000
27 #define WLAN_FC_ISWEP           0x4000
28 #define WLAN_FC_ORDER           0x8000
29
30 #define WLAN_FC_GET_TYPE(fc)    (((fc) & 0x000c) >> 2)
31 #define WLAN_FC_GET_STYPE(fc)   (((fc) & 0x00f0) >> 4)
32
33 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & (BIT(3) | BIT(2) | BIT(1) | BIT(0)))
34 #define WLAN_GET_SEQ_SEQ(seq) \
35         (((seq) & (~(BIT(3) | BIT(2) | BIT(1) | BIT(0)))) >> 4)
36
37 #define WLAN_FC_TYPE_MGMT               0
38 #define WLAN_FC_TYPE_CTRL               1
39 #define WLAN_FC_TYPE_DATA               2
40
41 /* management */
42 #define WLAN_FC_STYPE_ASSOC_REQ         0
43 #define WLAN_FC_STYPE_ASSOC_RESP        1
44 #define WLAN_FC_STYPE_REASSOC_REQ       2
45 #define WLAN_FC_STYPE_REASSOC_RESP      3
46 #define WLAN_FC_STYPE_PROBE_REQ         4
47 #define WLAN_FC_STYPE_PROBE_RESP        5
48 #define WLAN_FC_STYPE_BEACON            8
49 #define WLAN_FC_STYPE_ATIM              9
50 #define WLAN_FC_STYPE_DISASSOC          10
51 #define WLAN_FC_STYPE_AUTH              11
52 #define WLAN_FC_STYPE_DEAUTH            12
53 #define WLAN_FC_STYPE_ACTION            13
54
55 /* control */
56 #define WLAN_FC_STYPE_PSPOLL            10
57 #define WLAN_FC_STYPE_RTS               11
58 #define WLAN_FC_STYPE_CTS               12
59 #define WLAN_FC_STYPE_ACK               13
60 #define WLAN_FC_STYPE_CFEND             14
61 #define WLAN_FC_STYPE_CFENDACK          15
62
63 /* data */
64 #define WLAN_FC_STYPE_DATA              0
65 #define WLAN_FC_STYPE_DATA_CFACK        1
66 #define WLAN_FC_STYPE_DATA_CFPOLL       2
67 #define WLAN_FC_STYPE_DATA_CFACKPOLL    3
68 #define WLAN_FC_STYPE_NULLFUNC          4
69 #define WLAN_FC_STYPE_CFACK             5
70 #define WLAN_FC_STYPE_CFPOLL            6
71 #define WLAN_FC_STYPE_CFACKPOLL         7
72 #define WLAN_FC_STYPE_QOS_DATA          8
73
74 /* Authentication algorithms */
75 #define WLAN_AUTH_OPEN                  0
76 #define WLAN_AUTH_SHARED_KEY            1
77 #define WLAN_AUTH_FT                    2
78 #define WLAN_AUTH_LEAP                  128
79
80 #define WLAN_AUTH_CHALLENGE_LEN 128
81
82 #define WLAN_CAPABILITY_ESS BIT(0)
83 #define WLAN_CAPABILITY_IBSS BIT(1)
84 #define WLAN_CAPABILITY_CF_POLLABLE BIT(2)
85 #define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)
86 #define WLAN_CAPABILITY_PRIVACY BIT(4)
87 #define WLAN_CAPABILITY_SHORT_PREAMBLE BIT(5)
88 #define WLAN_CAPABILITY_PBCC BIT(6)
89 #define WLAN_CAPABILITY_CHANNEL_AGILITY BIT(7)
90 #define WLAN_CAPABILITY_SPECTRUM_MGMT BIT(8)
91 #define WLAN_CAPABILITY_SHORT_SLOT_TIME BIT(10)
92 #define WLAN_CAPABILITY_DSSS_OFDM BIT(13)
93
94 /* Status codes */
95 #define WLAN_STATUS_SUCCESS 0
96 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1
97 #define WLAN_STATUS_CAPS_UNSUPPORTED 10
98 #define WLAN_STATUS_REASSOC_NO_ASSOC 11
99 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
100 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
101 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
102 #define WLAN_STATUS_CHALLENGE_FAIL 15
103 #define WLAN_STATUS_AUTH_TIMEOUT 16
104 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
105 #define WLAN_STATUS_ASSOC_DENIED_RATES 18
106 /* IEEE 802.11b */
107 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
108 #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
109 #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
110 /* IEEE 802.11h */
111 #define WLAN_STATUS_SPEC_MGMT_REQUIRED 22
112 #define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23
113 #define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24
114 /* 802.11g */
115 #define WLAN_STATUS_ASSOC_DENIED_NO_SHORT_SLOT_TIME 25
116 #define WLAN_STATUS_ASSOC_DENIED_NO_ER_PBCC 26
117 #define WLAN_STATUS_ASSOC_DENIED_NO_DSSS_OFDM 27
118 /* IEEE 802.11i */
119 #define WLAN_STATUS_INVALID_IE 40
120 #define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41
121 #define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42
122 #define WLAN_STATUS_AKMP_NOT_VALID 43
123 #define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44
124 #define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45
125 #define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46
126 #define WLAN_STATUS_TS_NOT_CREATED 47
127 #define WLAN_STATUS_DIRECT_LINK_NOT_ALLOWED 48
128 #define WLAN_STATUS_DEST_STA_NOT_PRESENT 49
129 #define WLAN_STATUS_DEST_STA_NOT_QOS_STA 50
130 #define WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE 51
131 /* IEEE 802.11r */
132 #define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52
133 #define WLAN_STATUS_EXPECTED_RESOURCE_REQ_FT 53
134 #define WLAN_STATUS_INVALID_PMKID 54
135 #define WLAN_STATUS_INVALID_MDIE 55
136 #define WLAN_STATUS_INVALID_FTIE 56
137
138 /* Reason codes */
139 #define WLAN_REASON_UNSPECIFIED 1
140 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
141 #define WLAN_REASON_DEAUTH_LEAVING 3
142 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
143 #define WLAN_REASON_DISASSOC_AP_BUSY 5
144 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
145 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
146 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
147 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
148 /* 802.11h */
149 #define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10
150 #define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11
151 /* IEEE 802.11i */
152 #define WLAN_REASON_INVALID_IE 13
153 #define WLAN_REASON_MICHAEL_MIC_FAILURE 14
154 #define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15
155 #define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16
156 #define WLAN_REASON_IE_IN_4WAY_DIFFERS 17
157 #define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18
158 #define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19
159 #define WLAN_REASON_AKMP_NOT_VALID 20
160 #define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21
161 #define WLAN_REASON_INVALID_RSN_IE_CAPAB 22
162 #define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23
163 #define WLAN_REASON_CIPHER_SUITE_REJECTED 24
164
165
166 /* Information Element IDs */
167 #define WLAN_EID_SSID 0
168 #define WLAN_EID_SUPP_RATES 1
169 #define WLAN_EID_FH_PARAMS 2
170 #define WLAN_EID_DS_PARAMS 3
171 #define WLAN_EID_CF_PARAMS 4
172 #define WLAN_EID_TIM 5
173 #define WLAN_EID_IBSS_PARAMS 6
174 #define WLAN_EID_COUNTRY 7
175 #define WLAN_EID_CHALLENGE 16
176 /* EIDs defined by IEEE 802.11h - START */
177 #define WLAN_EID_PWR_CONSTRAINT 32
178 #define WLAN_EID_PWR_CAPABILITY 33
179 #define WLAN_EID_TPC_REQUEST 34
180 #define WLAN_EID_TPC_REPORT 35
181 #define WLAN_EID_SUPPORTED_CHANNELS 36
182 #define WLAN_EID_CHANNEL_SWITCH 37
183 #define WLAN_EID_MEASURE_REQUEST 38
184 #define WLAN_EID_MEASURE_REPORT 39
185 #define WLAN_EID_QUITE 40
186 #define WLAN_EID_IBSS_DFS 41
187 /* EIDs defined by IEEE 802.11h - END */
188 #define WLAN_EID_ERP_INFO 42
189 #define WLAN_EID_RSN 48
190 #define WLAN_EID_EXT_SUPP_RATES 50
191 #define WLAN_EID_MOBILITY_DOMAIN 54
192 #define WLAN_EID_FAST_BSS_TRANSITION 55
193 #define WLAN_EID_TIMEOUT_INTERVAL 56
194 #define WLAN_EID_RIC_DATA 57
195 #define WLAN_EID_VENDOR_SPECIFIC 221
196
197
198 /* Action frame categories */
199 #define WLAN_ACTION_SPECTRUM_MGMT 0
200 #define WLAN_ACTION_QOS 1
201 #define WLAN_ACTION_DLS 2
202 #define WLAN_ACTION_BLOCK_ACK 3
203 #define WLAN_ACTION_RADIO_MEASUREMENT 5
204 #define WLAN_ACTION_FT 6
205
206
207 #ifdef _MSC_VER
208 #pragma pack(push, 1)
209 #endif /* _MSC_VER */
210
211 struct ieee80211_mgmt {
212         le16 frame_control;
213         le16 duration;
214         u8 da[6];
215         u8 sa[6];
216         u8 bssid[6];
217         le16 seq_ctrl;
218         union {
219                 struct {
220                         le16 auth_alg;
221                         le16 auth_transaction;
222                         le16 status_code;
223                         /* possibly followed by Challenge text */
224                         u8 variable[0];
225                 } STRUCT_PACKED auth;
226                 struct {
227                         le16 reason_code;
228                 } STRUCT_PACKED deauth;
229                 struct {
230                         le16 capab_info;
231                         le16 listen_interval;
232                         /* followed by SSID and Supported rates */
233                         u8 variable[0];
234                 } STRUCT_PACKED assoc_req;
235                 struct {
236                         le16 capab_info;
237                         le16 status_code;
238                         le16 aid;
239                         /* followed by Supported rates */
240                         u8 variable[0];
241                 } STRUCT_PACKED assoc_resp, reassoc_resp;
242                 struct {
243                         le16 capab_info;
244                         le16 listen_interval;
245                         u8 current_ap[6];
246                         /* followed by SSID and Supported rates */
247                         u8 variable[0];
248                 } STRUCT_PACKED reassoc_req;
249                 struct {
250                         le16 reason_code;
251                 } STRUCT_PACKED disassoc;
252                 struct {
253                         u8 timestamp[8];
254                         le16 beacon_int;
255                         le16 capab_info;
256                         /* followed by some of SSID, Supported rates,
257                          * FH Params, DS Params, CF Params, IBSS Params, TIM */
258                         u8 variable[0];
259                 } STRUCT_PACKED beacon;
260                 struct {
261                         /* only variable items: SSID, Supported rates */
262                         u8 variable[0];
263                 } STRUCT_PACKED probe_req;
264                 struct {
265                         u8 timestamp[8];
266                         le16 beacon_int;
267                         le16 capab_info;
268                         /* followed by some of SSID, Supported rates,
269                          * FH Params, DS Params, CF Params, IBSS Params */
270                         u8 variable[0];
271                 } STRUCT_PACKED probe_resp;
272                 struct {
273                         u8 category;
274                         union {
275                                 struct {
276                                         u8 action_code;
277                                         u8 dialog_token;
278                                         u8 status_code;
279                                         u8 variable[0];
280                                 } STRUCT_PACKED wme_action;
281                                 struct{
282                                         u8 action_code;
283                                         u8 element_id;
284                                         u8 length;
285                                         u8 switch_mode;
286                                         u8 new_chan;
287                                         u8 switch_count;
288                                 } STRUCT_PACKED chan_switch;
289                                 struct {
290                                         u8 action;
291                                         u8 sta_addr[ETH_ALEN];
292                                         u8 target_ap_addr[ETH_ALEN];
293                                         u8 variable[0]; /* FT Request */
294                                 } STRUCT_PACKED ft_action_req;
295                                 struct {
296                                         u8 action;
297                                         u8 sta_addr[ETH_ALEN];
298                                         u8 target_ap_addr[ETH_ALEN];
299                                         le16 status_code;
300                                         u8 variable[0]; /* FT Request */
301                                 } STRUCT_PACKED ft_action_resp;
302                         } u;
303                 } STRUCT_PACKED action;
304         } u;
305 } STRUCT_PACKED;
306
307 #ifdef _MSC_VER
308 #pragma pack(pop)
309 #endif /* _MSC_VER */
310
311 #define ERP_INFO_NON_ERP_PRESENT BIT(0)
312 #define ERP_INFO_USE_PROTECTION BIT(1)
313 #define ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
314
315 #endif /* IEEE802_11_DEFS_H */