Re-initialize hostapd/wpa_supplicant git repository based on 0.6.3 release
[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_DENOED_NO_SHORT_SLOT_TIME 25
116 #define WLAN_STATUS_ASSOC_DENOED_NO_ER_PBCC 26
117 #define WLAN_STATUS_ASSOC_DENOED_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 /* IEEE 802.11r */
127 #define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52
128 #define WLAN_STATUS_EXPECTED_RESOURCE_REQ_FT 53
129 #define WLAN_STATUS_INVALID_PMKID 54
130 #define WLAN_STATUS_INVALID_MDIE 55
131 #define WLAN_STATUS_INVALID_FTIE 56
132
133 /* Reason codes */
134 #define WLAN_REASON_UNSPECIFIED 1
135 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
136 #define WLAN_REASON_DEAUTH_LEAVING 3
137 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
138 #define WLAN_REASON_DISASSOC_AP_BUSY 5
139 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
140 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
141 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
142 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
143 /* 802.11h */
144 #define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10
145 #define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11
146 /* IEEE 802.11i */
147 #define WLAN_REASON_INVALID_IE 13
148 #define WLAN_REASON_MICHAEL_MIC_FAILURE 14
149 #define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15
150 #define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16
151 #define WLAN_REASON_IE_IN_4WAY_DIFFERS 17
152 #define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18
153 #define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19
154 #define WLAN_REASON_AKMP_NOT_VALID 20
155 #define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21
156 #define WLAN_REASON_INVALID_RSN_IE_CAPAB 22
157 #define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23
158 #define WLAN_REASON_CIPHER_SUITE_REJECTED 24
159
160
161 /* Information Element IDs */
162 #define WLAN_EID_SSID 0
163 #define WLAN_EID_SUPP_RATES 1
164 #define WLAN_EID_FH_PARAMS 2
165 #define WLAN_EID_DS_PARAMS 3
166 #define WLAN_EID_CF_PARAMS 4
167 #define WLAN_EID_TIM 5
168 #define WLAN_EID_IBSS_PARAMS 6
169 #define WLAN_EID_COUNTRY 7
170 #define WLAN_EID_CHALLENGE 16
171 /* EIDs defined by IEEE 802.11h - START */
172 #define WLAN_EID_PWR_CONSTRAINT 32
173 #define WLAN_EID_PWR_CAPABILITY 33
174 #define WLAN_EID_TPC_REQUEST 34
175 #define WLAN_EID_TPC_REPORT 35
176 #define WLAN_EID_SUPPORTED_CHANNELS 36
177 #define WLAN_EID_CHANNEL_SWITCH 37
178 #define WLAN_EID_MEASURE_REQUEST 38
179 #define WLAN_EID_MEASURE_REPORT 39
180 #define WLAN_EID_QUITE 40
181 #define WLAN_EID_IBSS_DFS 41
182 /* EIDs defined by IEEE 802.11h - END */
183 #define WLAN_EID_ERP_INFO 42
184 #define WLAN_EID_RSN 48
185 #define WLAN_EID_EXT_SUPP_RATES 50
186 #define WLAN_EID_MOBILITY_DOMAIN 54
187 #define WLAN_EID_FAST_BSS_TRANSITION 55
188 #define WLAN_EID_TIMEOUT_INTERVAL 56
189 #define WLAN_EID_RIC_DATA 57
190 #define WLAN_EID_VENDOR_SPECIFIC 221
191
192
193 /* Action frame categories */
194 #define WLAN_ACTION_SPECTRUM_MGMT 0
195 #define WLAN_ACTION_QOS 1
196 #define WLAN_ACTION_DLS 2
197 #define WLAN_ACTION_BLOCK_ACK 3
198 #define WLAN_ACTION_RADIO_MEASUREMENT 5
199 #define WLAN_ACTION_FT 6
200
201
202 #ifdef _MSC_VER
203 #pragma pack(push, 1)
204 #endif /* _MSC_VER */
205
206 struct ieee80211_mgmt {
207         le16 frame_control;
208         le16 duration;
209         u8 da[6];
210         u8 sa[6];
211         u8 bssid[6];
212         le16 seq_ctrl;
213         union {
214                 struct {
215                         le16 auth_alg;
216                         le16 auth_transaction;
217                         le16 status_code;
218                         /* possibly followed by Challenge text */
219                         u8 variable[0];
220                 } STRUCT_PACKED auth;
221                 struct {
222                         le16 reason_code;
223                 } STRUCT_PACKED deauth;
224                 struct {
225                         le16 capab_info;
226                         le16 listen_interval;
227                         /* followed by SSID and Supported rates */
228                         u8 variable[0];
229                 } STRUCT_PACKED assoc_req;
230                 struct {
231                         le16 capab_info;
232                         le16 status_code;
233                         le16 aid;
234                         /* followed by Supported rates */
235                         u8 variable[0];
236                 } STRUCT_PACKED assoc_resp, reassoc_resp;
237                 struct {
238                         le16 capab_info;
239                         le16 listen_interval;
240                         u8 current_ap[6];
241                         /* followed by SSID and Supported rates */
242                         u8 variable[0];
243                 } STRUCT_PACKED reassoc_req;
244                 struct {
245                         le16 reason_code;
246                 } STRUCT_PACKED disassoc;
247                 struct {
248                         u8 timestamp[8];
249                         le16 beacon_int;
250                         le16 capab_info;
251                         /* followed by some of SSID, Supported rates,
252                          * FH Params, DS Params, CF Params, IBSS Params, TIM */
253                         u8 variable[0];
254                 } STRUCT_PACKED beacon;
255                 struct {
256                         /* only variable items: SSID, Supported rates */
257                         u8 variable[0];
258                 } STRUCT_PACKED probe_req;
259                 struct {
260                         u8 timestamp[8];
261                         le16 beacon_int;
262                         le16 capab_info;
263                         /* followed by some of SSID, Supported rates,
264                          * FH Params, DS Params, CF Params, IBSS Params */
265                         u8 variable[0];
266                 } STRUCT_PACKED probe_resp;
267                 struct {
268                         u8 category;
269                         union {
270                                 struct {
271                                         u8 action_code;
272                                         u8 dialog_token;
273                                         u8 status_code;
274                                         u8 variable[0];
275                                 } STRUCT_PACKED wme_action;
276                                 struct{
277                                         u8 action_code;
278                                         u8 element_id;
279                                         u8 length;
280                                         u8 switch_mode;
281                                         u8 new_chan;
282                                         u8 switch_count;
283                                 } STRUCT_PACKED chan_switch;
284                                 struct {
285                                         u8 action;
286                                         u8 sta_addr[ETH_ALEN];
287                                         u8 target_ap_addr[ETH_ALEN];
288                                         u8 variable[0]; /* FT Request */
289                                 } STRUCT_PACKED ft_action_req;
290                                 struct {
291                                         u8 action;
292                                         u8 sta_addr[ETH_ALEN];
293                                         u8 target_ap_addr[ETH_ALEN];
294                                         le16 status_code;
295                                         u8 variable[0]; /* FT Request */
296                                 } STRUCT_PACKED ft_action_resp;
297                         } u;
298                 } STRUCT_PACKED action;
299         } u;
300 } STRUCT_PACKED;
301
302 #ifdef _MSC_VER
303 #pragma pack(pop)
304 #endif /* _MSC_VER */
305
306 #define ERP_INFO_NON_ERP_PRESENT BIT(0)
307 #define ERP_INFO_USE_PROTECTION BIT(1)
308 #define ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
309
310 #endif /* IEEE802_11_DEFS_H */