hammer.8: Mention that rebalance is part of cleanup.
[dragonfly.git] / contrib / hostapd-0.5.8 / ieee802_11.h
blob37bd711d0194df160e9cd9785e67ab611240b6f5
1 /*
2 * hostapd / IEEE 802.11 Management
3 * Copyright (c) 2002-2006, Jouni Malinen <j@w1.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #ifndef IEEE802_11_H
16 #define IEEE802_11_H
18 /* IEEE 802.11 defines */
20 #define WLAN_FC_PVER (BIT(1) | BIT(0))
21 #define WLAN_FC_TODS BIT(8)
22 #define WLAN_FC_FROMDS BIT(9)
23 #define WLAN_FC_MOREFRAG BIT(10)
24 #define WLAN_FC_RETRY BIT(11)
25 #define WLAN_FC_PWRMGT BIT(12)
26 #define WLAN_FC_MOREDATA BIT(13)
27 #define WLAN_FC_ISWEP BIT(14)
28 #define WLAN_FC_ORDER BIT(15)
30 #define WLAN_FC_GET_TYPE(fc) (((fc) & (BIT(3) | BIT(2))) >> 2)
31 #define WLAN_FC_GET_STYPE(fc) \
32 (((fc) & (BIT(7) | BIT(6) | BIT(5) | BIT(4))) >> 4)
34 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & (BIT(3) | BIT(2) | BIT(1) | BIT(0)))
35 #define WLAN_GET_SEQ_SEQ(seq) \
36 (((seq) & (~(BIT(3) | BIT(2) | BIT(1) | BIT(0)))) >> 4)
38 #define WLAN_FC_TYPE_MGMT 0
39 #define WLAN_FC_TYPE_CTRL 1
40 #define WLAN_FC_TYPE_DATA 2
42 /* management */
43 #define WLAN_FC_STYPE_ASSOC_REQ 0
44 #define WLAN_FC_STYPE_ASSOC_RESP 1
45 #define WLAN_FC_STYPE_REASSOC_REQ 2
46 #define WLAN_FC_STYPE_REASSOC_RESP 3
47 #define WLAN_FC_STYPE_PROBE_REQ 4
48 #define WLAN_FC_STYPE_PROBE_RESP 5
49 #define WLAN_FC_STYPE_BEACON 8
50 #define WLAN_FC_STYPE_ATIM 9
51 #define WLAN_FC_STYPE_DISASSOC 10
52 #define WLAN_FC_STYPE_AUTH 11
53 #define WLAN_FC_STYPE_DEAUTH 12
54 #define WLAN_FC_STYPE_ACTION 13
56 /* control */
57 #define WLAN_FC_STYPE_PSPOLL 10
58 #define WLAN_FC_STYPE_RTS 11
59 #define WLAN_FC_STYPE_CTS 12
60 #define WLAN_FC_STYPE_ACK 13
61 #define WLAN_FC_STYPE_CFEND 14
62 #define WLAN_FC_STYPE_CFENDACK 15
64 /* data */
65 #define WLAN_FC_STYPE_DATA 0
66 #define WLAN_FC_STYPE_DATA_CFACK 1
67 #define WLAN_FC_STYPE_DATA_CFPOLL 2
68 #define WLAN_FC_STYPE_DATA_CFACKPOLL 3
69 #define WLAN_FC_STYPE_NULLFUNC 4
70 #define WLAN_FC_STYPE_CFACK 5
71 #define WLAN_FC_STYPE_CFPOLL 6
72 #define WLAN_FC_STYPE_CFACKPOLL 7
73 #define WLAN_FC_STYPE_QOS_DATA 8
75 /* Authentication algorithms */
76 #define WLAN_AUTH_OPEN 0
77 #define WLAN_AUTH_SHARED_KEY 1
79 #define WLAN_AUTH_CHALLENGE_LEN 128
81 #define WLAN_CAPABILITY_ESS BIT(0)
82 #define WLAN_CAPABILITY_IBSS BIT(1)
83 #define WLAN_CAPABILITY_CF_POLLABLE BIT(2)
84 #define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)
85 #define WLAN_CAPABILITY_PRIVACY BIT(4)
86 #define WLAN_CAPABILITY_SHORT_PREAMBLE BIT(5)
87 #define WLAN_CAPABILITY_PBCC BIT(6)
88 #define WLAN_CAPABILITY_CHANNEL_AGILITY BIT(7)
89 #define WLAN_CAPABILITY_SPECTRUM_MGMT BIT(8)
90 #define WLAN_CAPABILITY_SHORT_SLOT_TIME BIT(10)
91 #define WLAN_CAPABILITY_DSSS_OFDM BIT(13)
93 /* Status codes */
94 #define WLAN_STATUS_SUCCESS 0
95 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1
96 #define WLAN_STATUS_CAPS_UNSUPPORTED 10
97 #define WLAN_STATUS_REASSOC_NO_ASSOC 11
98 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
99 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
100 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
101 #define WLAN_STATUS_CHALLENGE_FAIL 15
102 #define WLAN_STATUS_AUTH_TIMEOUT 16
103 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
104 #define WLAN_STATUS_ASSOC_DENIED_RATES 18
105 /* IEEE 802.11b */
106 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
107 #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
108 #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
109 /* IEEE 802.11h */
110 #define WLAN_STATUS_SPEC_MGMT_REQUIRED 22
111 #define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23
112 #define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24
113 /* IEEE 802.11i */
114 #define WLAN_STATUS_INVALID_IE 40
115 #define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41
116 #define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42
117 #define WLAN_STATUS_AKMP_NOT_VALID 43
118 #define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44
119 #define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45
120 #define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46
122 /* Reason codes */
123 #define WLAN_REASON_UNSPECIFIED 1
124 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
125 #define WLAN_REASON_DEAUTH_LEAVING 3
126 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
127 #define WLAN_REASON_DISASSOC_AP_BUSY 5
128 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
129 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
130 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
131 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
132 /* IEEE 802.11i */
133 #define WLAN_REASON_INVALID_IE 13
134 #define WLAN_REASON_MICHAEL_MIC_FAILURE 14
135 #define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15
136 #define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16
137 #define WLAN_REASON_IE_IN_4WAY_DIFFERS 17
138 #define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18
139 #define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19
140 #define WLAN_REASON_AKMP_NOT_VALID 20
141 #define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21
142 #define WLAN_REASON_INVALID_RSN_IE_CAPAB 22
143 #define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23
144 #define WLAN_REASON_CIPHER_SUITE_REJECTED 24
147 /* Information Element IDs */
148 #define WLAN_EID_SSID 0
149 #define WLAN_EID_SUPP_RATES 1
150 #define WLAN_EID_FH_PARAMS 2
151 #define WLAN_EID_DS_PARAMS 3
152 #define WLAN_EID_CF_PARAMS 4
153 #define WLAN_EID_TIM 5
154 #define WLAN_EID_IBSS_PARAMS 6
155 #define WLAN_EID_COUNTRY 7
156 #define WLAN_EID_CHALLENGE 16
157 /* EIDs defined by IEEE 802.11h - START */
158 #define WLAN_EID_PWR_CONSTRAINT 32
159 #define WLAN_EID_PWR_CAPABILITY 33
160 #define WLAN_EID_TPC_REQUEST 34
161 #define WLAN_EID_TPC_REPORT 35
162 #define WLAN_EID_SUPPORTED_CHANNELS 36
163 #define WLAN_EID_CHANNEL_SWITCH 37
164 #define WLAN_EID_MEASURE_REQUEST 38
165 #define WLAN_EID_MEASURE_REPORT 39
166 #define WLAN_EID_QUITE 40
167 #define WLAN_EID_IBSS_DFS 41
168 /* EIDs defined by IEEE 802.11h - END */
169 #define WLAN_EID_ERP_INFO 42
170 #define WLAN_EID_RSN 48
171 #define WLAN_EID_EXT_SUPP_RATES 50
172 #define WLAN_EID_GENERIC 221
173 #define WLAN_EID_VENDOR_SPECIFIC 221
176 struct ieee80211_mgmt {
177 u16 frame_control;
178 u16 duration;
179 u8 da[6];
180 u8 sa[6];
181 u8 bssid[6];
182 u16 seq_ctrl;
183 union {
184 struct {
185 u16 auth_alg;
186 u16 auth_transaction;
187 u16 status_code;
188 /* possibly followed by Challenge text */
189 u8 variable[0];
190 } __attribute__ ((packed)) auth;
191 struct {
192 u16 reason_code;
193 } __attribute__ ((packed)) deauth;
194 struct {
195 u16 capab_info;
196 u16 listen_interval;
197 /* followed by SSID and Supported rates */
198 u8 variable[0];
199 } __attribute__ ((packed)) assoc_req;
200 struct {
201 u16 capab_info;
202 u16 status_code;
203 u16 aid;
204 /* followed by Supported rates */
205 u8 variable[0];
206 } __attribute__ ((packed)) assoc_resp, reassoc_resp;
207 struct {
208 u16 capab_info;
209 u16 listen_interval;
210 u8 current_ap[6];
211 /* followed by SSID and Supported rates */
212 u8 variable[0];
213 } __attribute__ ((packed)) reassoc_req;
214 struct {
215 u16 reason_code;
216 } __attribute__ ((packed)) disassoc;
217 struct {
218 /* only variable items: SSID, Supported rates */
219 u8 variable[0];
220 } __attribute__ ((packed)) probe_req;
221 struct {
222 u8 timestamp[8];
223 u16 beacon_int;
224 u16 capab_info;
225 /* followed by some of SSID, Supported rates,
226 * FH Params, DS Params, CF Params, IBSS Params */
227 u8 variable[0];
228 } __attribute__ ((packed)) probe_resp;
229 struct {
230 u8 timestamp[8];
231 u16 beacon_int;
232 u16 capab_info;
233 /* followed by some of SSID, Supported rates,
234 * FH Params, DS Params, CF Params, IBSS Params, TIM */
235 u8 variable[0];
236 } __attribute__ ((packed)) beacon;
237 struct {
238 u8 category;
239 union {
240 struct {
241 u8 action_code;
242 u8 dialog_token;
243 u8 status_code;
244 u8 variable[0];
245 } __attribute__ ((packed)) wme_action;
246 struct{
247 u8 action_code;
248 u8 element_id;
249 u8 length;
250 u8 switch_mode;
251 u8 new_chan;
252 u8 switch_count;
253 } __attribute__ ((packed)) chan_switch;
254 } u;
255 } __attribute__ ((packed)) action;
256 } u;
257 } __attribute__ ((packed));
260 #define ERP_INFO_NON_ERP_PRESENT BIT(0)
261 #define ERP_INFO_USE_PROTECTION BIT(1)
262 #define ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
264 /* Parsed Information Elements */
265 struct ieee802_11_elems {
266 u8 *ssid;
267 u8 ssid_len;
268 u8 *supp_rates;
269 u8 supp_rates_len;
270 u8 *fh_params;
271 u8 fh_params_len;
272 u8 *ds_params;
273 u8 ds_params_len;
274 u8 *cf_params;
275 u8 cf_params_len;
276 u8 *tim;
277 u8 tim_len;
278 u8 *ibss_params;
279 u8 ibss_params_len;
280 u8 *challenge;
281 u8 challenge_len;
282 u8 *erp_info;
283 u8 erp_info_len;
284 u8 *ext_supp_rates;
285 u8 ext_supp_rates_len;
286 u8 *wpa_ie;
287 u8 wpa_ie_len;
288 u8 *rsn_ie;
289 u8 rsn_ie_len;
290 u8 *wme;
291 u8 wme_len;
292 u8 *wme_tspec;
293 u8 wme_tspec_len;
294 u8 *power_cap;
295 u8 power_cap_len;
296 u8 *supp_channels;
297 u8 supp_channels_len;
300 typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
303 struct hostapd_frame_info {
304 u32 phytype;
305 u32 channel;
306 u32 datarate;
307 u32 ssi_signal;
309 unsigned int passive_scan:1;
313 void ieee802_11_send_deauth(struct hostapd_data *hapd, u8 *addr, u16 reason);
314 void ieee802_11_mgmt(struct hostapd_data *hapd, u8 *buf, size_t len,
315 u16 stype, struct hostapd_frame_info *fi);
316 void ieee802_11_mgmt_cb(struct hostapd_data *hapd, u8 *buf, size_t len,
317 u16 stype, int ok);
318 ParseRes ieee802_11_parse_elems(struct hostapd_data *hapd, u8 *start,
319 size_t len,
320 struct ieee802_11_elems *elems,
321 int show_errors);
322 void ieee802_11_print_ssid(const u8 *ssid, u8 len);
323 void ieee80211_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr,
324 int local);
325 int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen);
326 int ieee802_11_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
327 char *buf, size_t buflen);
328 u16 hostapd_own_capab_info(struct hostapd_data *hapd, struct sta_info *sta,
329 int probe);
330 u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid);
331 u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid);
333 #endif /* IEEE802_11_H */