]> git.ipfire.org Git - thirdparty/hostap.git/blame - src/ap/ieee802_11.c
SAE: Move related operations next to each other
[thirdparty/hostap.git] / src / ap / ieee802_11.c
CommitLineData
6fc6879b
JM
1/*
2 * hostapd / IEEE 802.11 Management
d9a38716 3 * Copyright (c) 2002-2012, Jouni Malinen <j@w1.fi>
6fc6879b 4 *
0f3d578e
JM
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
6fc6879b
JM
7 */
8
1057d78e 9#include "utils/includes.h"
6fc6879b
JM
10
11#ifndef CONFIG_NATIVE_WINDOWS
12
1057d78e
JM
13#include "utils/common.h"
14#include "utils/eloop.h"
03da66bd 15#include "crypto/crypto.h"
2ce86d9d 16#include "drivers/driver.h"
81f4f619
JM
17#include "common/ieee802_11_defs.h"
18#include "common/ieee802_11_common.h"
03da66bd 19#include "common/wpa_ctrl.h"
98efcc41 20#include "common/sae.h"
03da66bd
JM
21#include "radius/radius.h"
22#include "radius/radius_client.h"
e44f8bf2 23#include "p2p/p2p.h"
ed7a09f9 24#include "wps/wps.h"
6fc6879b 25#include "hostapd.h"
6fc6879b 26#include "beacon.h"
6fc6879b
JM
27#include "ieee802_11_auth.h"
28#include "sta_info.h"
6fc6879b 29#include "ieee802_1x.h"
6226e38d 30#include "wpa_auth.h"
1057d78e 31#include "wmm.h"
6fc6879b
JM
32#include "ap_list.h"
33#include "accounting.h"
6226e38d
JM
34#include "ap_config.h"
35#include "ap_mlme.h"
dce044cc 36#include "p2p_hostapd.h"
cee7d66b 37#include "ap_drv_ops.h"
c79938a5 38#include "wnm_ap.h"
6226e38d 39#include "ieee802_11.h"
6fc6879b
JM
40
41
42u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid)
43{
44 u8 *pos = eid;
45 int i, num, count;
46
47 if (hapd->iface->current_rates == NULL)
48 return eid;
49
50 *pos++ = WLAN_EID_SUPP_RATES;
51 num = hapd->iface->num_rates;
29448243
JM
52 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht)
53 num++;
202d97d4
JB
54 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht)
55 num++;
6fc6879b
JM
56 if (num > 8) {
57 /* rest of the rates are encoded in Extended supported
58 * rates element */
59 num = 8;
60 }
61
62 *pos++ = num;
63 count = 0;
64 for (i = 0, count = 0; i < hapd->iface->num_rates && count < num;
65 i++) {
66 count++;
67 *pos = hapd->iface->current_rates[i].rate / 5;
68 if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC)
69 *pos |= 0x80;
70 pos++;
71 }
72
202d97d4
JB
73 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht && count < 8) {
74 count++;
29448243 75 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_HT_PHY;
202d97d4
JB
76 }
77
78 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht && count < 8) {
79 count++;
80 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_VHT_PHY;
81 }
29448243 82
6fc6879b
JM
83 return pos;
84}
85
86
87u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid)
88{
89 u8 *pos = eid;
90 int i, num, count;
91
92 if (hapd->iface->current_rates == NULL)
93 return eid;
94
95 num = hapd->iface->num_rates;
29448243
JM
96 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht)
97 num++;
202d97d4
JB
98 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht)
99 num++;
6fc6879b
JM
100 if (num <= 8)
101 return eid;
102 num -= 8;
103
104 *pos++ = WLAN_EID_EXT_SUPP_RATES;
105 *pos++ = num;
106 count = 0;
107 for (i = 0, count = 0; i < hapd->iface->num_rates && count < num + 8;
108 i++) {
109 count++;
110 if (count <= 8)
111 continue; /* already in SuppRates IE */
112 *pos = hapd->iface->current_rates[i].rate / 5;
113 if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC)
114 *pos |= 0x80;
115 pos++;
116 }
117
202d97d4
JB
118 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht) {
119 count++;
120 if (count > 8)
121 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_HT_PHY;
122 }
123
124 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht) {
125 count++;
126 if (count > 8)
127 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_VHT_PHY;
128 }
29448243 129
6fc6879b
JM
130 return pos;
131}
132
133
134u16 hostapd_own_capab_info(struct hostapd_data *hapd, struct sta_info *sta,
135 int probe)
136{
137 int capab = WLAN_CAPABILITY_ESS;
138 int privacy;
139
140 if (hapd->iface->num_sta_no_short_preamble == 0 &&
141 hapd->iconf->preamble == SHORT_PREAMBLE)
142 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
143
144 privacy = hapd->conf->ssid.wep.keys_set;
145
146 if (hapd->conf->ieee802_1x &&
147 (hapd->conf->default_wep_key_len ||
148 hapd->conf->individual_wep_key_len))
149 privacy = 1;
150
151 if (hapd->conf->wpa)
152 privacy = 1;
153
154 if (sta) {
155 int policy, def_klen;
156 if (probe && sta->ssid_probe) {
157 policy = sta->ssid_probe->security_policy;
158 def_klen = sta->ssid_probe->wep.default_len;
159 } else {
160 policy = sta->ssid->security_policy;
161 def_klen = sta->ssid->wep.default_len;
162 }
163 privacy = policy != SECURITY_PLAINTEXT;
164 if (policy == SECURITY_IEEE_802_1X && def_klen == 0)
165 privacy = 0;
166 }
167
168 if (privacy)
169 capab |= WLAN_CAPABILITY_PRIVACY;
170
171 if (hapd->iface->current_mode &&
172 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
173 hapd->iface->num_sta_no_short_slot_time == 0)
174 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
175
6fc6879b
JM
176 return capab;
177}
178
179
6fc6879b
JM
180void ieee802_11_print_ssid(char *buf, const u8 *ssid, u8 len)
181{
182 int i;
183 if (len > HOSTAPD_MAX_SSID_LEN)
184 len = HOSTAPD_MAX_SSID_LEN;
185 for (i = 0; i < len; i++) {
186 if (ssid[i] >= 32 && ssid[i] < 127)
187 buf[i] = ssid[i];
188 else
189 buf[i] = '.';
190 }
191 buf[len] = '\0';
192}
193
194
6fc6879b 195static u16 auth_shared_key(struct hostapd_data *hapd, struct sta_info *sta,
b57e086c
JM
196 u16 auth_transaction, const u8 *challenge,
197 int iswep)
6fc6879b
JM
198{
199 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
200 HOSTAPD_LEVEL_DEBUG,
201 "authentication (shared key, transaction %d)",
202 auth_transaction);
203
204 if (auth_transaction == 1) {
205 if (!sta->challenge) {
206 /* Generate a pseudo-random challenge */
207 u8 key[8];
0b04889f 208 struct os_time now;
6fc6879b
JM
209 int r;
210 sta->challenge = os_zalloc(WLAN_AUTH_CHALLENGE_LEN);
211 if (sta->challenge == NULL)
212 return WLAN_STATUS_UNSPECIFIED_FAILURE;
213
0b04889f
PE
214 os_get_time(&now);
215 r = os_random();
216 os_memcpy(key, &now.sec, 4);
6fc6879b 217 os_memcpy(key + 4, &r, 4);
8ef16831
JM
218 rc4_skip(key, sizeof(key), 0,
219 sta->challenge, WLAN_AUTH_CHALLENGE_LEN);
6fc6879b
JM
220 }
221 return 0;
222 }
223
224 if (auth_transaction != 3)
225 return WLAN_STATUS_UNSPECIFIED_FAILURE;
226
227 /* Transaction 3 */
228 if (!iswep || !sta->challenge || !challenge ||
229 os_memcmp(sta->challenge, challenge, WLAN_AUTH_CHALLENGE_LEN)) {
230 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
231 HOSTAPD_LEVEL_INFO,
232 "shared key authentication - invalid "
233 "challenge-response");
234 return WLAN_STATUS_CHALLENGE_FAIL;
235 }
236
237 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
238 HOSTAPD_LEVEL_DEBUG,
239 "authentication OK (shared key)");
240#ifdef IEEE80211_REQUIRE_AUTH_ACK
241 /* Station will be marked authenticated if it ACKs the
242 * authentication reply. */
243#else
244 sta->flags |= WLAN_STA_AUTH;
245 wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
246#endif
247 os_free(sta->challenge);
248 sta->challenge = NULL;
249
250 return 0;
251}
252
253
254static void send_auth_reply(struct hostapd_data *hapd,
255 const u8 *dst, const u8 *bssid,
256 u16 auth_alg, u16 auth_transaction, u16 resp,
257 const u8 *ies, size_t ies_len)
258{
259 struct ieee80211_mgmt *reply;
260 u8 *buf;
261 size_t rlen;
262
263 rlen = IEEE80211_HDRLEN + sizeof(reply->u.auth) + ies_len;
264 buf = os_zalloc(rlen);
265 if (buf == NULL)
266 return;
267
268 reply = (struct ieee80211_mgmt *) buf;
269 reply->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
270 WLAN_FC_STYPE_AUTH);
6fc6879b
JM
271 os_memcpy(reply->da, dst, ETH_ALEN);
272 os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
273 os_memcpy(reply->bssid, bssid, ETH_ALEN);
274
275 reply->u.auth.auth_alg = host_to_le16(auth_alg);
276 reply->u.auth.auth_transaction = host_to_le16(auth_transaction);
277 reply->u.auth.status_code = host_to_le16(resp);
278
279 if (ies && ies_len)
280 os_memcpy(reply->u.auth.variable, ies, ies_len);
281
282 wpa_printf(MSG_DEBUG, "authentication reply: STA=" MACSTR
283 " auth_alg=%d auth_transaction=%d resp=%d (IE len=%lu)",
284 MAC2STR(dst), auth_alg, auth_transaction,
285 resp, (unsigned long) ies_len);
8cfa3527 286 if (hostapd_drv_send_mlme(hapd, reply, rlen, 0) < 0)
6fc6879b
JM
287 perror("send_auth_reply: send");
288
289 os_free(buf);
290}
291
292
293#ifdef CONFIG_IEEE80211R
294static void handle_auth_ft_finish(void *ctx, const u8 *dst, const u8 *bssid,
295 u16 auth_transaction, u16 status,
296 const u8 *ies, size_t ies_len)
297{
298 struct hostapd_data *hapd = ctx;
299 struct sta_info *sta;
300
301 send_auth_reply(hapd, dst, bssid, WLAN_AUTH_FT, auth_transaction,
302 status, ies, ies_len);
303
304 if (status != WLAN_STATUS_SUCCESS)
305 return;
306
307 sta = ap_get_sta(hapd, dst);
308 if (sta == NULL)
309 return;
310
311 hostapd_logger(hapd, dst, HOSTAPD_MODULE_IEEE80211,
312 HOSTAPD_LEVEL_DEBUG, "authentication OK (FT)");
313 sta->flags |= WLAN_STA_AUTH;
314 mlme_authenticate_indication(hapd, sta);
315}
316#endif /* CONFIG_IEEE80211R */
317
318
c10347f2 319#ifdef CONFIG_SAE
21af6d15
JM
320
321static struct wpabuf * auth_build_sae_commit(struct hostapd_data *hapd,
322 struct sta_info *sta)
323{
324 struct wpabuf *buf;
325
326 buf = wpabuf_alloc(2);
327 if (buf == NULL)
328 return NULL;
329
330 wpabuf_put_le16(buf, 19); /* Finite Cyclic Group */
331 /* TODO: Anti-Clogging Token (if requested) */
332 /* TODO: Scalar */
333 /* TODO: Element */
334
335 return buf;
336}
337
338
339static struct wpabuf * auth_build_sae_confirm(struct hostapd_data *hapd,
340 struct sta_info *sta)
341{
342 struct wpabuf *buf;
343
344 buf = wpabuf_alloc(2);
345 if (buf == NULL)
346 return NULL;
347
98efcc41
JM
348 wpabuf_put_le16(buf, sta->sae->send_confirm);
349 sta->sae->send_confirm++;
21af6d15
JM
350 /* TODO: Confirm */
351
352 return buf;
353}
354
355
356static u16 handle_sae_commit(struct hostapd_data *hapd, struct sta_info *sta,
357 const u8 *data, size_t len)
358{
359 wpa_hexdump(MSG_DEBUG, "SAE commit fields", data, len);
360
361 /* Check Finite Cyclic Group */
362 if (len < 2)
363 return WLAN_STATUS_UNSPECIFIED_FAILURE;
364 if (WPA_GET_LE16(data) != 19) {
365 wpa_printf(MSG_DEBUG, "SAE: Unsupported Finite Cyclic Group %u",
366 WPA_GET_LE16(data));
367 return WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED;
368 }
369
370 return WLAN_STATUS_SUCCESS;
371}
372
373
374static u16 handle_sae_confirm(struct hostapd_data *hapd, struct sta_info *sta,
375 const u8 *data, size_t len)
376{
377 u16 rc;
378
379 wpa_hexdump(MSG_DEBUG, "SAE confirm fields", data, len);
380
381 if (len < 2)
382 return WLAN_STATUS_UNSPECIFIED_FAILURE;
383 rc = WPA_GET_LE16(data);
384 wpa_printf(MSG_DEBUG, "SAE: peer-send-confirm %u", rc);
385
386 return WLAN_STATUS_SUCCESS;
387}
388
389
c10347f2
JM
390static void handle_auth_sae(struct hostapd_data *hapd, struct sta_info *sta,
391 const struct ieee80211_mgmt *mgmt, size_t len,
392 u8 auth_transaction)
393{
394 u16 resp = WLAN_STATUS_SUCCESS;
750efe6e 395 struct wpabuf *data = NULL;
c10347f2 396
98efcc41
JM
397 if (!sta->sae) {
398 sta->sae = os_zalloc(sizeof(*sta->sae));
399 if (sta->sae == NULL)
400 return;
401 }
402
c10347f2
JM
403 if (auth_transaction == 1) {
404 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
405 HOSTAPD_LEVEL_DEBUG,
406 "start SAE authentication (RX commit)");
21af6d15
JM
407 resp = handle_sae_commit(hapd, sta, mgmt->u.auth.variable,
408 ((u8 *) mgmt) + len -
409 mgmt->u.auth.variable);
750efe6e 410 if (resp == WLAN_STATUS_SUCCESS) {
98efcc41 411 sta->sae->state = SAE_COMMIT;
750efe6e
JM
412 data = auth_build_sae_commit(hapd, sta);
413 if (data == NULL)
414 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
415 }
c10347f2 416 } else if (auth_transaction == 2) {
98efcc41 417 if (sta->sae->state != SAE_COMMIT) {
c10347f2
JM
418 hostapd_logger(hapd, sta->addr,
419 HOSTAPD_MODULE_IEEE80211,
420 HOSTAPD_LEVEL_DEBUG,
421 "SAE confirm before commit");
422 resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
423 }
424 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
425 HOSTAPD_LEVEL_DEBUG,
426 "SAE authentication (RX confirm)");
21af6d15
JM
427 resp = handle_sae_confirm(hapd, sta, mgmt->u.auth.variable,
428 ((u8 *) mgmt) + len -
429 mgmt->u.auth.variable);
430 if (resp == WLAN_STATUS_SUCCESS) {
431 sta->flags |= WLAN_STA_AUTH;
432 wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
433 sta->auth_alg = WLAN_AUTH_SAE;
434 mlme_authenticate_indication(hapd, sta);
750efe6e
JM
435
436 data = auth_build_sae_confirm(hapd, sta);
437 if (data == NULL)
438 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
21af6d15 439 }
c10347f2
JM
440 } else {
441 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
442 HOSTAPD_LEVEL_DEBUG,
443 "unexpected SAE authentication transaction %u",
444 auth_transaction);
445 resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
446 }
447
448 sta->auth_alg = WLAN_AUTH_SAE;
449
450 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, WLAN_AUTH_SAE,
21af6d15
JM
451 auth_transaction, resp,
452 data ? wpabuf_head(data) : (u8 *) "",
453 data ? wpabuf_len(data) : 0);
454 wpabuf_free(data);
c10347f2
JM
455}
456#endif /* CONFIG_SAE */
457
458
b57e086c
JM
459static void handle_auth(struct hostapd_data *hapd,
460 const struct ieee80211_mgmt *mgmt, size_t len)
6fc6879b
JM
461{
462 u16 auth_alg, auth_transaction, status_code;
463 u16 resp = WLAN_STATUS_SUCCESS;
464 struct sta_info *sta = NULL;
465 int res;
466 u16 fc;
b57e086c 467 const u8 *challenge = NULL;
6fc6879b
JM
468 u32 session_timeout, acct_interim_interval;
469 int vlan_id = 0;
2ad3e6c8 470 struct hostapd_sta_wpa_psk_short *psk = NULL;
6fc6879b
JM
471 u8 resp_ies[2 + WLAN_AUTH_CHALLENGE_LEN];
472 size_t resp_ies_len = 0;
2092597f
MB
473 char *identity = NULL;
474 char *radius_cui = NULL;
6fc6879b
JM
475
476 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
477 printf("handle_auth - too short payload (len=%lu)\n",
478 (unsigned long) len);
479 return;
480 }
481
482 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
483 auth_transaction = le_to_host16(mgmt->u.auth.auth_transaction);
484 status_code = le_to_host16(mgmt->u.auth.status_code);
485 fc = le_to_host16(mgmt->frame_control);
486
487 if (len >= IEEE80211_HDRLEN + sizeof(mgmt->u.auth) +
488 2 + WLAN_AUTH_CHALLENGE_LEN &&
489 mgmt->u.auth.variable[0] == WLAN_EID_CHALLENGE &&
490 mgmt->u.auth.variable[1] == WLAN_AUTH_CHALLENGE_LEN)
491 challenge = &mgmt->u.auth.variable[2];
492
493 wpa_printf(MSG_DEBUG, "authentication: STA=" MACSTR " auth_alg=%d "
494 "auth_transaction=%d status_code=%d wep=%d%s",
495 MAC2STR(mgmt->sa), auth_alg, auth_transaction,
496 status_code, !!(fc & WLAN_FC_ISWEP),
497 challenge ? " challenge" : "");
498
6fc6879b
JM
499 if (hapd->tkip_countermeasures) {
500 resp = WLAN_REASON_MICHAEL_MIC_FAILURE;
501 goto fail;
502 }
503
504 if (!(((hapd->conf->auth_algs & WPA_AUTH_ALG_OPEN) &&
505 auth_alg == WLAN_AUTH_OPEN) ||
506#ifdef CONFIG_IEEE80211R
0bf927a0 507 (hapd->conf->wpa && wpa_key_mgmt_ft(hapd->conf->wpa_key_mgmt) &&
6fc6879b
JM
508 auth_alg == WLAN_AUTH_FT) ||
509#endif /* CONFIG_IEEE80211R */
c10347f2
JM
510#ifdef CONFIG_SAE
511 (hapd->conf->wpa && wpa_key_mgmt_sae(hapd->conf->wpa_key_mgmt) &&
512 auth_alg == WLAN_AUTH_SAE) ||
513#endif /* CONFIG_SAE */
6fc6879b
JM
514 ((hapd->conf->auth_algs & WPA_AUTH_ALG_SHARED) &&
515 auth_alg == WLAN_AUTH_SHARED_KEY))) {
516 printf("Unsupported authentication algorithm (%d)\n",
517 auth_alg);
518 resp = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
519 goto fail;
520 }
521
c10347f2 522 if (!(auth_transaction == 1 || auth_alg == WLAN_AUTH_SAE ||
6fc6879b
JM
523 (auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 3))) {
524 printf("Unknown authentication transaction number (%d)\n",
525 auth_transaction);
526 resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
527 goto fail;
528 }
529
530 if (os_memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) {
531 printf("Station " MACSTR " not allowed to authenticate.\n",
532 MAC2STR(mgmt->sa));
533 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
534 goto fail;
535 }
536
537 res = hostapd_allowed_address(hapd, mgmt->sa, (u8 *) mgmt, len,
538 &session_timeout,
05ab9712 539 &acct_interim_interval, &vlan_id,
2ad3e6c8 540 &psk, &identity, &radius_cui);
05ab9712 541
6fc6879b
JM
542 if (res == HOSTAPD_ACL_REJECT) {
543 printf("Station " MACSTR " not allowed to authenticate.\n",
544 MAC2STR(mgmt->sa));
545 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
546 goto fail;
547 }
548 if (res == HOSTAPD_ACL_PENDING) {
549 wpa_printf(MSG_DEBUG, "Authentication frame from " MACSTR
550 " waiting for an external authentication",
551 MAC2STR(mgmt->sa));
552 /* Authentication code will re-send the authentication frame
553 * after it has received (and cached) information from the
554 * external source. */
555 return;
556 }
557
558 sta = ap_sta_add(hapd, mgmt->sa);
559 if (!sta) {
560 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
561 goto fail;
562 }
563
564 if (vlan_id > 0) {
565 if (hostapd_get_vlan_id_ifname(hapd->conf->vlan,
1066c1ee 566 vlan_id) == NULL) {
6fc6879b
JM
567 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS,
568 HOSTAPD_LEVEL_INFO, "Invalid VLAN ID "
569 "%d received from RADIUS server",
570 vlan_id);
571 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
572 goto fail;
573 }
574 sta->vlan_id = vlan_id;
575 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS,
576 HOSTAPD_LEVEL_INFO, "VLAN ID %d", sta->vlan_id);
577 }
578
f2a14be7 579 hostapd_free_psk_list(sta->psk);
5ee56c4e
MB
580 if (hapd->conf->wpa_psk_radius != PSK_RADIUS_IGNORED) {
581 sta->psk = psk;
582 psk = NULL;
05ab9712 583 } else {
05ab9712
MB
584 sta->psk = NULL;
585 }
586
2092597f
MB
587 sta->identity = identity;
588 identity = NULL;
589 sta->radius_cui = radius_cui;
590 radius_cui = NULL;
591
6fc6879b
JM
592 sta->flags &= ~WLAN_STA_PREAUTH;
593 ieee802_1x_notify_pre_auth(sta->eapol_sm, 0);
594
5843e1c9 595 if (hapd->conf->acct_interim_interval == 0 && acct_interim_interval)
6fc6879b
JM
596 sta->acct_interim_interval = acct_interim_interval;
597 if (res == HOSTAPD_ACL_ACCEPT_TIMEOUT)
598 ap_sta_session_timeout(hapd, sta, session_timeout);
599 else
600 ap_sta_no_session_timeout(hapd, sta);
601
602 switch (auth_alg) {
603 case WLAN_AUTH_OPEN:
604 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
605 HOSTAPD_LEVEL_DEBUG,
606 "authentication OK (open system)");
607#ifdef IEEE80211_REQUIRE_AUTH_ACK
608 /* Station will be marked authenticated if it ACKs the
609 * authentication reply. */
610#else
611 sta->flags |= WLAN_STA_AUTH;
612 wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
613 sta->auth_alg = WLAN_AUTH_OPEN;
614 mlme_authenticate_indication(hapd, sta);
615#endif
616 break;
617 case WLAN_AUTH_SHARED_KEY:
618 resp = auth_shared_key(hapd, sta, auth_transaction, challenge,
619 fc & WLAN_FC_ISWEP);
620 sta->auth_alg = WLAN_AUTH_SHARED_KEY;
621 mlme_authenticate_indication(hapd, sta);
622 if (sta->challenge && auth_transaction == 1) {
623 resp_ies[0] = WLAN_EID_CHALLENGE;
624 resp_ies[1] = WLAN_AUTH_CHALLENGE_LEN;
625 os_memcpy(resp_ies + 2, sta->challenge,
626 WLAN_AUTH_CHALLENGE_LEN);
627 resp_ies_len = 2 + WLAN_AUTH_CHALLENGE_LEN;
628 }
629 break;
630#ifdef CONFIG_IEEE80211R
631 case WLAN_AUTH_FT:
632 sta->auth_alg = WLAN_AUTH_FT;
633 if (sta->wpa_sm == NULL)
634 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
635 sta->addr);
636 if (sta->wpa_sm == NULL) {
637 wpa_printf(MSG_DEBUG, "FT: Failed to initialize WPA "
638 "state machine");
639 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
640 goto fail;
641 }
642 wpa_ft_process_auth(sta->wpa_sm, mgmt->bssid,
643 auth_transaction, mgmt->u.auth.variable,
644 len - IEEE80211_HDRLEN -
645 sizeof(mgmt->u.auth),
646 handle_auth_ft_finish, hapd);
647 /* handle_auth_ft_finish() callback will complete auth. */
648 return;
649#endif /* CONFIG_IEEE80211R */
c10347f2
JM
650#ifdef CONFIG_SAE
651 case WLAN_AUTH_SAE:
652 handle_auth_sae(hapd, sta, mgmt, len, auth_transaction);
653 return;
654#endif /* CONFIG_SAE */
6fc6879b
JM
655 }
656
657 fail:
2092597f
MB
658 os_free(identity);
659 os_free(radius_cui);
f2a14be7 660 hostapd_free_psk_list(psk);
2092597f 661
6fc6879b
JM
662 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, auth_alg,
663 auth_transaction + 1, resp, resp_ies, resp_ies_len);
664}
665
666
d42a62b3
JM
667static int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta)
668{
2991469c
JM
669 int i, j = 32, aid;
670
d42a62b3
JM
671 /* get a unique AID */
672 if (sta->aid > 0) {
673 wpa_printf(MSG_DEBUG, " old AID %d", sta->aid);
674 return 0;
675 }
676
2991469c
JM
677 for (i = 0; i < AID_WORDS; i++) {
678 if (hapd->sta_aid[i] == (u32) -1)
679 continue;
680 for (j = 0; j < 32; j++) {
681 if (!(hapd->sta_aid[i] & BIT(j)))
682 break;
683 }
684 if (j < 32)
d42a62b3 685 break;
d42a62b3 686 }
2991469c
JM
687 if (j == 32)
688 return -1;
689 aid = i * 32 + j + 1;
690 if (aid > 2007)
691 return -1;
d42a62b3 692
2991469c
JM
693 sta->aid = aid;
694 hapd->sta_aid[i] |= BIT(j);
d42a62b3
JM
695 wpa_printf(MSG_DEBUG, " new AID %d", sta->aid);
696 return 0;
697}
698
699
5586f500
JM
700static u16 check_ssid(struct hostapd_data *hapd, struct sta_info *sta,
701 const u8 *ssid_ie, size_t ssid_ie_len)
6fc6879b 702{
5586f500
JM
703 if (ssid_ie == NULL)
704 return WLAN_STATUS_UNSPECIFIED_FAILURE;
6fc6879b 705
5586f500
JM
706 if (ssid_ie_len != hapd->conf->ssid.ssid_len ||
707 os_memcmp(ssid_ie, hapd->conf->ssid.ssid, ssid_ie_len) != 0) {
708 char ssid_txt[33];
709 ieee802_11_print_ssid(ssid_txt, ssid_ie, ssid_ie_len);
710 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
711 HOSTAPD_LEVEL_INFO,
712 "Station tried to associate with unknown SSID "
713 "'%s'", ssid_txt);
714 return WLAN_STATUS_UNSPECIFIED_FAILURE;
b0194fe0
JM
715 }
716
5586f500
JM
717 return WLAN_STATUS_SUCCESS;
718}
6fc6879b 719
6fc6879b 720
5586f500
JM
721static u16 check_wmm(struct hostapd_data *hapd, struct sta_info *sta,
722 const u8 *wmm_ie, size_t wmm_ie_len)
723{
3ae0800c 724 sta->flags &= ~WLAN_STA_WMM;
5d061637 725 sta->qosinfo = 0;
5586f500 726 if (wmm_ie && hapd->conf->wmm_enabled) {
5f32f79c 727 struct wmm_information_element *wmm;
5f32f79c 728
c84b868a 729 if (!hostapd_eid_wmm_valid(hapd, wmm_ie, wmm_ie_len)) {
6fc6879b
JM
730 hostapd_logger(hapd, sta->addr,
731 HOSTAPD_MODULE_WPA,
732 HOSTAPD_LEVEL_DEBUG,
3ae0800c 733 "invalid WMM element in association "
6fc6879b 734 "request");
5f32f79c
EP
735 return WLAN_STATUS_UNSPECIFIED_FAILURE;
736 }
737
738 sta->flags |= WLAN_STA_WMM;
739 wmm = (struct wmm_information_element *) wmm_ie;
5d061637 740 sta->qosinfo = wmm->qos_info;
6fc6879b 741 }
5586f500
JM
742 return WLAN_STATUS_SUCCESS;
743}
6fc6879b 744
5586f500
JM
745
746static u16 copy_supp_rates(struct hostapd_data *hapd, struct sta_info *sta,
747 struct ieee802_11_elems *elems)
748{
749 if (!elems->supp_rates) {
750 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
6fc6879b
JM
751 HOSTAPD_LEVEL_DEBUG,
752 "No supported rates element in AssocReq");
5586f500 753 return WLAN_STATUS_UNSPECIFIED_FAILURE;
6fc6879b
JM
754 }
755
3489cfb0
JM
756 if (elems->supp_rates_len + elems->ext_supp_rates_len >
757 sizeof(sta->supported_rates)) {
5586f500 758 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
6fc6879b 759 HOSTAPD_LEVEL_DEBUG,
3489cfb0
JM
760 "Invalid supported rates element length %d+%d",
761 elems->supp_rates_len,
762 elems->ext_supp_rates_len);
5586f500 763 return WLAN_STATUS_UNSPECIFIED_FAILURE;
6fc6879b
JM
764 }
765
3489cfb0
JM
766 sta->supported_rates_len = merge_byte_arrays(
767 sta->supported_rates, sizeof(sta->supported_rates),
768 elems->supp_rates, elems->supp_rates_len,
769 elems->ext_supp_rates, elems->ext_supp_rates_len);
6fc6879b 770
5586f500
JM
771 return WLAN_STATUS_SUCCESS;
772}
773
774
5586f500 775static u16 check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta,
b57e086c 776 const u8 *ies, size_t ies_len, int reassoc)
5586f500
JM
777{
778 struct ieee802_11_elems elems;
779 u16 resp;
ba091c06 780 const u8 *wpa_ie;
5586f500
JM
781 size_t wpa_ie_len;
782
783 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed) {
784 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
785 HOSTAPD_LEVEL_INFO, "Station sent an invalid "
786 "association request");
787 return WLAN_STATUS_UNSPECIFIED_FAILURE;
788 }
789
790 resp = check_ssid(hapd, sta, elems.ssid, elems.ssid_len);
791 if (resp != WLAN_STATUS_SUCCESS)
792 return resp;
793 resp = check_wmm(hapd, sta, elems.wmm, elems.wmm_len);
794 if (resp != WLAN_STATUS_SUCCESS)
795 return resp;
796 resp = copy_supp_rates(hapd, sta, &elems);
797 if (resp != WLAN_STATUS_SUCCESS)
798 return resp;
d45354be 799#ifdef CONFIG_IEEE80211N
f39b07d7 800 resp = copy_sta_ht_capab(hapd, sta, elems.ht_capabilities,
5586f500
JM
801 elems.ht_capabilities_len);
802 if (resp != WLAN_STATUS_SUCCESS)
803 return resp;
29448243
JM
804 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht &&
805 !(sta->flags & WLAN_STA_HT)) {
806 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
807 HOSTAPD_LEVEL_INFO, "Station does not support "
808 "mandatory HT PHY - reject association");
809 return WLAN_STATUS_ASSOC_DENIED_NO_HT;
810 }
d45354be 811#endif /* CONFIG_IEEE80211N */
5586f500 812
de3cdf35
MP
813#ifdef CONFIG_IEEE80211AC
814 resp = copy_sta_vht_capab(hapd, sta, elems.vht_capabilities,
815 elems.vht_capabilities_len);
816 if (resp != WLAN_STATUS_SUCCESS)
817 return resp;
140e850a
MP
818 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht &&
819 !(sta->flags & WLAN_STA_VHT)) {
820 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
821 HOSTAPD_LEVEL_INFO, "Station does not support "
822 "mandatory VHT PHY - reject association");
823 return WLAN_STATUS_UNSPECIFIED_FAILURE;
824 }
de3cdf35
MP
825#endif /* CONFIG_IEEE80211AC */
826
6fc6879b
JM
827 if ((hapd->conf->wpa & WPA_PROTO_RSN) && elems.rsn_ie) {
828 wpa_ie = elems.rsn_ie;
829 wpa_ie_len = elems.rsn_ie_len;
830 } else if ((hapd->conf->wpa & WPA_PROTO_WPA) &&
831 elems.wpa_ie) {
832 wpa_ie = elems.wpa_ie;
833 wpa_ie_len = elems.wpa_ie_len;
834 } else {
835 wpa_ie = NULL;
836 wpa_ie_len = 0;
837 }
5586f500 838
ad08c363 839#ifdef CONFIG_WPS
17f6b900 840 sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2);
c47cf42e
JM
841 if (hapd->conf->wps_state && elems.wps_ie) {
842 wpa_printf(MSG_DEBUG, "STA included WPS IE in (Re)Association "
843 "Request - assume WPS is used");
844 sta->flags |= WLAN_STA_WPS;
845 wpabuf_free(sta->wps_ie);
16e46ec0
JM
846 sta->wps_ie = ieee802_11_vendor_ie_concat(ies, ies_len,
847 WPS_IE_VENDOR_TYPE);
17f6b900
JM
848 if (sta->wps_ie && wps_is_20(sta->wps_ie)) {
849 wpa_printf(MSG_DEBUG, "WPS: STA supports WPS 2.0");
850 sta->flags |= WLAN_STA_WPS2;
851 }
c47cf42e
JM
852 wpa_ie = NULL;
853 wpa_ie_len = 0;
54f489be
JM
854 if (sta->wps_ie && wps_validate_assoc_req(sta->wps_ie) < 0) {
855 wpa_printf(MSG_DEBUG, "WPS: Invalid WPS IE in "
856 "(Re)Association Request - reject");
857 return WLAN_STATUS_INVALID_IE;
858 }
c47cf42e
JM
859 } else if (hapd->conf->wps_state && wpa_ie == NULL) {
860 wpa_printf(MSG_DEBUG, "STA did not include WPA/RSN IE in "
861 "(Re)Association Request - possible WPS use");
862 sta->flags |= WLAN_STA_MAYBE_WPS;
ad08c363
JM
863 } else
864#endif /* CONFIG_WPS */
6fc6879b 865 if (hapd->conf->wpa && wpa_ie == NULL) {
5586f500
JM
866 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
867 HOSTAPD_LEVEL_INFO,
868 "No WPA/RSN IE in association request");
869 return WLAN_STATUS_INVALID_IE;
6fc6879b
JM
870 }
871
872 if (hapd->conf->wpa && wpa_ie) {
873 int res;
874 wpa_ie -= 2;
875 wpa_ie_len += 2;
876 if (sta->wpa_sm == NULL)
877 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
878 sta->addr);
879 if (sta->wpa_sm == NULL) {
5586f500
JM
880 wpa_printf(MSG_WARNING, "Failed to initialize WPA "
881 "state machine");
882 return WLAN_STATUS_UNSPECIFIED_FAILURE;
6fc6879b
JM
883 }
884 res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm,
885 wpa_ie, wpa_ie_len,
886 elems.mdie, elems.mdie_len);
887 if (res == WPA_INVALID_GROUP)
888 resp = WLAN_STATUS_GROUP_CIPHER_NOT_VALID;
889 else if (res == WPA_INVALID_PAIRWISE)
890 resp = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID;
891 else if (res == WPA_INVALID_AKMP)
892 resp = WLAN_STATUS_AKMP_NOT_VALID;
893 else if (res == WPA_ALLOC_FAIL)
894 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
895#ifdef CONFIG_IEEE80211W
896 else if (res == WPA_MGMT_FRAME_PROTECTION_VIOLATION)
9a9876bf 897 resp = WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION;
6fc6879b 898 else if (res == WPA_INVALID_MGMT_GROUP_CIPHER)
9a9876bf 899 resp = WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION;
6fc6879b
JM
900#endif /* CONFIG_IEEE80211W */
901 else if (res == WPA_INVALID_MDIE)
902 resp = WLAN_STATUS_INVALID_MDIE;
903 else if (res != WPA_IE_OK)
904 resp = WLAN_STATUS_INVALID_IE;
905 if (resp != WLAN_STATUS_SUCCESS)
5586f500 906 return resp;
f3f7540e 907#ifdef CONFIG_IEEE80211W
45c94154
JM
908 if ((sta->flags & WLAN_STA_MFP) && !sta->sa_query_timed_out &&
909 sta->sa_query_count > 0)
910 ap_check_sa_query_timeout(hapd, sta);
8f4617c6
JM
911 if ((sta->flags & WLAN_STA_MFP) && !sta->sa_query_timed_out &&
912 (!reassoc || sta->auth_alg != WLAN_AUTH_FT)) {
5d22a1d5 913 /*
93b76319
JM
914 * STA has already been associated with MFP and SA
915 * Query timeout has not been reached. Reject the
916 * association attempt temporarily and start SA Query,
917 * if one is not pending.
5d22a1d5
JM
918 */
919
93b76319
JM
920 if (sta->sa_query_count == 0)
921 ap_sta_start_sa_query(hapd, sta);
5d22a1d5 922
5586f500 923 return WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY;
5d22a1d5
JM
924 }
925
f3f7540e
JM
926 if (wpa_auth_uses_mfp(sta->wpa_sm))
927 sta->flags |= WLAN_STA_MFP;
928 else
929 sta->flags &= ~WLAN_STA_MFP;
930#endif /* CONFIG_IEEE80211W */
6fc6879b
JM
931
932#ifdef CONFIG_IEEE80211R
933 if (sta->auth_alg == WLAN_AUTH_FT) {
934 if (!reassoc) {
935 wpa_printf(MSG_DEBUG, "FT: " MACSTR " tried "
936 "to use association (not "
937 "re-association) with FT auth_alg",
938 MAC2STR(sta->addr));
5586f500 939 return WLAN_STATUS_UNSPECIFIED_FAILURE;
6fc6879b
JM
940 }
941
5586f500
JM
942 resp = wpa_ft_validate_reassoc(sta->wpa_sm, ies,
943 ies_len);
6fc6879b 944 if (resp != WLAN_STATUS_SUCCESS)
5586f500 945 return resp;
6fc6879b
JM
946 }
947#endif /* CONFIG_IEEE80211R */
5586f500 948
c10347f2
JM
949#ifdef CONFIG_SAE
950 if (wpa_auth_uses_sae(sta->wpa_sm) &&
951 sta->auth_alg != WLAN_AUTH_SAE) {
952 wpa_printf(MSG_DEBUG, "SAE: " MACSTR " tried to use "
953 "SAE AKM after non-SAE auth_alg %u",
954 MAC2STR(sta->addr), sta->auth_alg);
955 return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
956 }
957#endif /* CONFIG_SAE */
958
ff36ff00 959#ifdef CONFIG_IEEE80211N
f0c7a986 960 if ((sta->flags & (WLAN_STA_HT | WLAN_STA_VHT)) &&
ff36ff00 961 wpa_auth_get_pairwise(sta->wpa_sm) == WPA_CIPHER_TKIP) {
5586f500
JM
962 hostapd_logger(hapd, sta->addr,
963 HOSTAPD_MODULE_IEEE80211,
964 HOSTAPD_LEVEL_INFO,
965 "Station tried to use TKIP with HT "
966 "association");
967 return WLAN_STATUS_CIPHER_REJECTED_PER_POLICY;
ff36ff00
JM
968 }
969#endif /* CONFIG_IEEE80211N */
a8d05fca
JM
970 } else
971 wpa_auth_sta_no_wpa(sta->wpa_sm);
6fc6879b 972
b305c684
JM
973#ifdef CONFIG_P2P
974 if (elems.p2p) {
975 wpabuf_free(sta->p2p_ie);
976 sta->p2p_ie = ieee802_11_vendor_ie_concat(ies, ies_len,
977 P2P_IE_VENDOR_TYPE);
8ccbe415 978
b305c684
JM
979 } else {
980 wpabuf_free(sta->p2p_ie);
981 sta->p2p_ie = NULL;
982 }
3f4ce13f
JM
983
984 p2p_group_notif_assoc(hapd->p2p_group, sta->addr, ies, ies_len);
b305c684
JM
985#endif /* CONFIG_P2P */
986
f403dcd6
JM
987#ifdef CONFIG_HS20
988 wpabuf_free(sta->hs20_ie);
989 if (elems.hs20 && elems.hs20_len > 4) {
990 sta->hs20_ie = wpabuf_alloc_copy(elems.hs20 + 4,
991 elems.hs20_len - 4);
992 } else
993 sta->hs20_ie = NULL;
994#endif /* CONFIG_HS20 */
995
5586f500
JM
996 return WLAN_STATUS_SUCCESS;
997}
998
999
1000static void send_deauth(struct hostapd_data *hapd, const u8 *addr,
1001 u16 reason_code)
1002{
1003 int send_len;
1004 struct ieee80211_mgmt reply;
1005
1006 os_memset(&reply, 0, sizeof(reply));
1007 reply.frame_control =
1008 IEEE80211_FC(WLAN_FC_TYPE_MGMT, WLAN_FC_STYPE_DEAUTH);
1009 os_memcpy(reply.da, addr, ETH_ALEN);
1010 os_memcpy(reply.sa, hapd->own_addr, ETH_ALEN);
1011 os_memcpy(reply.bssid, hapd->own_addr, ETH_ALEN);
1012
1013 send_len = IEEE80211_HDRLEN + sizeof(reply.u.deauth);
1014 reply.u.deauth.reason_code = host_to_le16(reason_code);
1015
8cfa3527 1016 if (hostapd_drv_send_mlme(hapd, &reply, send_len, 0) < 0)
5586f500
JM
1017 wpa_printf(MSG_INFO, "Failed to send deauth: %s",
1018 strerror(errno));
1019}
1020
1021
1022static void send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta,
b57e086c 1023 u16 status_code, int reassoc, const u8 *ies,
5586f500
JM
1024 size_t ies_len)
1025{
1026 int send_len;
1027 u8 buf[sizeof(struct ieee80211_mgmt) + 1024];
1028 struct ieee80211_mgmt *reply;
1029 u8 *p;
1030
1031 os_memset(buf, 0, sizeof(buf));
1032 reply = (struct ieee80211_mgmt *) buf;
1033 reply->frame_control =
1034 IEEE80211_FC(WLAN_FC_TYPE_MGMT,
1035 (reassoc ? WLAN_FC_STYPE_REASSOC_RESP :
1036 WLAN_FC_STYPE_ASSOC_RESP));
1037 os_memcpy(reply->da, sta->addr, ETH_ALEN);
1038 os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
1039 os_memcpy(reply->bssid, hapd->own_addr, ETH_ALEN);
1040
1041 send_len = IEEE80211_HDRLEN;
1042 send_len += sizeof(reply->u.assoc_resp);
1043 reply->u.assoc_resp.capab_info =
1044 host_to_le16(hostapd_own_capab_info(hapd, sta, 0));
1045 reply->u.assoc_resp.status_code = host_to_le16(status_code);
1046 reply->u.assoc_resp.aid = host_to_le16((sta ? sta->aid : 0)
1047 | BIT(14) | BIT(15));
1048 /* Supported rates */
1049 p = hostapd_eid_supp_rates(hapd, reply->u.assoc_resp.variable);
1050 /* Extended supported rates */
1051 p = hostapd_eid_ext_supp_rates(hapd, p);
5586f500
JM
1052
1053#ifdef CONFIG_IEEE80211R
1054 if (status_code == WLAN_STATUS_SUCCESS) {
1055 /* IEEE 802.11r: Mobility Domain Information, Fast BSS
1056 * Transition Information, RSN, [RIC Response] */
1057 p = wpa_sm_write_assoc_resp_ies(sta->wpa_sm, p,
1058 buf + sizeof(buf) - p,
1059 sta->auth_alg, ies, ies_len);
1060 }
1061#endif /* CONFIG_IEEE80211R */
1062
1063#ifdef CONFIG_IEEE80211W
1064 if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY)
1065 p = hostapd_eid_assoc_comeback_time(hapd, sta, p);
1066#endif /* CONFIG_IEEE80211W */
1067
1bc774a1
JM
1068#ifdef CONFIG_IEEE80211N
1069 p = hostapd_eid_ht_capabilities(hapd, p);
1070 p = hostapd_eid_ht_operation(hapd, p);
1071#endif /* CONFIG_IEEE80211N */
1072
14708b50
MP
1073#ifdef CONFIG_IEEE80211AC
1074 p = hostapd_eid_vht_capabilities(hapd, p);
1075 p = hostapd_eid_vht_operation(hapd, p);
1076#endif /* CONFIG_IEEE80211AC */
1077
1161ff1e 1078 p = hostapd_eid_ext_capab(hapd, p);
b6668734 1079 p = hostapd_eid_bss_max_idle_period(hapd, p);
1161ff1e 1080
1bc774a1
JM
1081 if (sta->flags & WLAN_STA_WMM)
1082 p = hostapd_eid_wmm(hapd, p);
1083
ed7a09f9 1084#ifdef CONFIG_WPS
71093e5e
JM
1085 if ((sta->flags & WLAN_STA_WPS) ||
1086 ((sta->flags & WLAN_STA_MAYBE_WPS) && hapd->conf->wpa)) {
ed7a09f9
JM
1087 struct wpabuf *wps = wps_build_assoc_resp_ie();
1088 if (wps) {
1089 os_memcpy(p, wpabuf_head(wps), wpabuf_len(wps));
1090 p += wpabuf_len(wps);
1091 wpabuf_free(wps);
1092 }
1093 }
1094#endif /* CONFIG_WPS */
1095
8ccbe415
JM
1096#ifdef CONFIG_P2P
1097 if (sta->p2p_ie) {
1098 struct wpabuf *p2p_resp_ie;
1099 enum p2p_status_code status;
1100 switch (status_code) {
1101 case WLAN_STATUS_SUCCESS:
1102 status = P2P_SC_SUCCESS;
1103 break;
1104 case WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA:
1105 status = P2P_SC_FAIL_LIMIT_REACHED;
1106 break;
1107 default:
1108 status = P2P_SC_FAIL_INVALID_PARAMS;
1109 break;
1110 }
1111 p2p_resp_ie = p2p_group_assoc_resp_ie(hapd->p2p_group, status);
1112 if (p2p_resp_ie) {
1113 os_memcpy(p, wpabuf_head(p2p_resp_ie),
1114 wpabuf_len(p2p_resp_ie));
1115 p += wpabuf_len(p2p_resp_ie);
1116 wpabuf_free(p2p_resp_ie);
1117 }
1118 }
1119#endif /* CONFIG_P2P */
1120
962473c1
JM
1121#ifdef CONFIG_P2P_MANAGER
1122 if (hapd->conf->p2p & P2P_MANAGE)
1123 p = hostapd_eid_p2p_manage(hapd, p);
1124#endif /* CONFIG_P2P_MANAGER */
1125
5586f500
JM
1126 send_len += p - reply->u.assoc_resp.variable;
1127
8cfa3527 1128 if (hostapd_drv_send_mlme(hapd, reply, send_len, 0) < 0)
5586f500
JM
1129 wpa_printf(MSG_INFO, "Failed to send assoc resp: %s",
1130 strerror(errno));
1131}
1132
1133
1134static void handle_assoc(struct hostapd_data *hapd,
b57e086c
JM
1135 const struct ieee80211_mgmt *mgmt, size_t len,
1136 int reassoc)
5586f500
JM
1137{
1138 u16 capab_info, listen_interval;
1139 u16 resp = WLAN_STATUS_SUCCESS;
b57e086c 1140 const u8 *pos;
5586f500
JM
1141 int left, i;
1142 struct sta_info *sta;
1143
1144 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
1145 sizeof(mgmt->u.assoc_req))) {
1146 printf("handle_assoc(reassoc=%d) - too short payload (len=%lu)"
1147 "\n", reassoc, (unsigned long) len);
1148 return;
1149 }
1150
1151 if (reassoc) {
1152 capab_info = le_to_host16(mgmt->u.reassoc_req.capab_info);
1153 listen_interval = le_to_host16(
1154 mgmt->u.reassoc_req.listen_interval);
1155 wpa_printf(MSG_DEBUG, "reassociation request: STA=" MACSTR
1156 " capab_info=0x%02x listen_interval=%d current_ap="
1157 MACSTR,
1158 MAC2STR(mgmt->sa), capab_info, listen_interval,
1159 MAC2STR(mgmt->u.reassoc_req.current_ap));
1160 left = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.reassoc_req));
1161 pos = mgmt->u.reassoc_req.variable;
1162 } else {
1163 capab_info = le_to_host16(mgmt->u.assoc_req.capab_info);
1164 listen_interval = le_to_host16(
1165 mgmt->u.assoc_req.listen_interval);
1166 wpa_printf(MSG_DEBUG, "association request: STA=" MACSTR
1167 " capab_info=0x%02x listen_interval=%d",
1168 MAC2STR(mgmt->sa), capab_info, listen_interval);
1169 left = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.assoc_req));
1170 pos = mgmt->u.assoc_req.variable;
1171 }
1172
1173 sta = ap_get_sta(hapd, mgmt->sa);
1174#ifdef CONFIG_IEEE80211R
1175 if (sta && sta->auth_alg == WLAN_AUTH_FT &&
1176 (sta->flags & WLAN_STA_AUTH) == 0) {
1177 wpa_printf(MSG_DEBUG, "FT: Allow STA " MACSTR " to associate "
1178 "prior to authentication since it is using "
1179 "over-the-DS FT", MAC2STR(mgmt->sa));
1180 } else
1181#endif /* CONFIG_IEEE80211R */
1182 if (sta == NULL || (sta->flags & WLAN_STA_AUTH) == 0) {
1183 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1184 HOSTAPD_LEVEL_INFO, "Station tried to "
1185 "associate before authentication "
1186 "(aid=%d flags=0x%x)",
1187 sta ? sta->aid : -1,
1188 sta ? sta->flags : 0);
1189 send_deauth(hapd, mgmt->sa,
1190 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA);
1191 return;
1192 }
1193
1194 if (hapd->tkip_countermeasures) {
1195 resp = WLAN_REASON_MICHAEL_MIC_FAILURE;
1196 goto fail;
1197 }
1198
1199 if (listen_interval > hapd->conf->max_listen_interval) {
1200 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1201 HOSTAPD_LEVEL_DEBUG,
1202 "Too large Listen Interval (%d)",
1203 listen_interval);
1204 resp = WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE;
1205 goto fail;
1206 }
1207
1208 /* followed by SSID and Supported rates; and HT capabilities if 802.11n
1209 * is used */
1210 resp = check_assoc_ies(hapd, sta, pos, left, reassoc);
1211 if (resp != WLAN_STATUS_SUCCESS)
1212 goto fail;
1213
1214 if (hostapd_get_aid(hapd, sta) < 0) {
1215 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1216 HOSTAPD_LEVEL_INFO, "No room for more AIDs");
1217 resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
1218 goto fail;
1219 }
1220
1221 sta->capability = capab_info;
1222 sta->listen_interval = listen_interval;
1223
6fc6879b
JM
1224 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
1225 sta->flags |= WLAN_STA_NONERP;
1226 for (i = 0; i < sta->supported_rates_len; i++) {
1227 if ((sta->supported_rates[i] & 0x7f) > 22) {
1228 sta->flags &= ~WLAN_STA_NONERP;
1229 break;
1230 }
1231 }
1232 if (sta->flags & WLAN_STA_NONERP && !sta->nonerp_set) {
1233 sta->nonerp_set = 1;
1234 hapd->iface->num_sta_non_erp++;
1235 if (hapd->iface->num_sta_non_erp == 1)
1236 ieee802_11_set_beacons(hapd->iface);
1237 }
1238
1239 if (!(sta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) &&
1240 !sta->no_short_slot_time_set) {
1241 sta->no_short_slot_time_set = 1;
1242 hapd->iface->num_sta_no_short_slot_time++;
1243 if (hapd->iface->current_mode->mode ==
1244 HOSTAPD_MODE_IEEE80211G &&
1245 hapd->iface->num_sta_no_short_slot_time == 1)
1246 ieee802_11_set_beacons(hapd->iface);
1247 }
1248
1249 if (sta->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
1250 sta->flags |= WLAN_STA_SHORT_PREAMBLE;
1251 else
1252 sta->flags &= ~WLAN_STA_SHORT_PREAMBLE;
1253
1254 if (!(sta->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) &&
1255 !sta->no_short_preamble_set) {
1256 sta->no_short_preamble_set = 1;
1257 hapd->iface->num_sta_no_short_preamble++;
1258 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
1259 && hapd->iface->num_sta_no_short_preamble == 1)
1260 ieee802_11_set_beacons(hapd->iface);
1261 }
1262
d45354be 1263#ifdef CONFIG_IEEE80211N
5586f500 1264 update_ht_state(hapd, sta);
d45354be 1265#endif /* CONFIG_IEEE80211N */
de9289c8 1266
6fc6879b
JM
1267 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1268 HOSTAPD_LEVEL_DEBUG,
1269 "association OK (aid %d)", sta->aid);
1270 /* Station will be marked associated, after it acknowledges AssocResp
1271 */
b8281964 1272 sta->flags |= WLAN_STA_ASSOC_REQ_OK;
6fc6879b 1273
6f5c8dbd
JM
1274#ifdef CONFIG_IEEE80211W
1275 if ((sta->flags & WLAN_STA_MFP) && sta->sa_query_timed_out) {
1276 wpa_printf(MSG_DEBUG, "Allowing %sassociation after timed out "
1277 "SA Query procedure", reassoc ? "re" : "");
1278 /* TODO: Send a protected Disassociate frame to the STA using
1279 * the old key and Reason Code "Previous Authentication no
1280 * longer valid". Make sure this is only sent protected since
1281 * unprotected frame would be received by the STA that is now
1282 * trying to associate.
1283 */
1284 }
1285#endif /* CONFIG_IEEE80211W */
1286
1e858f69
JM
1287 if (reassoc) {
1288 os_memcpy(sta->previous_ap, mgmt->u.reassoc_req.current_ap,
1289 ETH_ALEN);
1290 }
1291
6fc6879b
JM
1292 if (sta->last_assoc_req)
1293 os_free(sta->last_assoc_req);
1294 sta->last_assoc_req = os_malloc(len);
1295 if (sta->last_assoc_req)
1296 os_memcpy(sta->last_assoc_req, mgmt, len);
1297
1298 /* Make sure that the previously registered inactivity timer will not
1299 * remove the STA immediately. */
1300 sta->timeout_next = STA_NULLFUNC;
1301
1302 fail:
5586f500 1303 send_assoc_resp(hapd, sta, resp, reassoc, pos, left);
6fc6879b
JM
1304}
1305
1306
6fc6879b 1307static void handle_disassoc(struct hostapd_data *hapd,
f8b1f695 1308 const struct ieee80211_mgmt *mgmt, size_t len)
6fc6879b
JM
1309{
1310 struct sta_info *sta;
1311
1312 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.disassoc)) {
1313 printf("handle_disassoc - too short payload (len=%lu)\n",
1314 (unsigned long) len);
1315 return;
1316 }
1317
1318 wpa_printf(MSG_DEBUG, "disassocation: STA=" MACSTR " reason_code=%d",
1319 MAC2STR(mgmt->sa),
1320 le_to_host16(mgmt->u.disassoc.reason_code));
1321
6fc6879b
JM
1322 sta = ap_get_sta(hapd, mgmt->sa);
1323 if (sta == NULL) {
1324 printf("Station " MACSTR " trying to disassociate, but it "
1325 "is not associated.\n", MAC2STR(mgmt->sa));
1326 return;
1327 }
1328
ae055af4 1329 ap_sta_set_authorized(hapd, sta, 0);
b8281964 1330 sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
6fc6879b
JM
1331 wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
1332 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1333 HOSTAPD_LEVEL_INFO, "disassociated");
1334 sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
1335 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
1336 /* Stop Accounting and IEEE 802.1X sessions, but leave the STA
1337 * authenticated. */
1338 accounting_sta_stop(hapd, sta);
1339 ieee802_1x_free_station(sta);
51e2a27a 1340 hostapd_drv_sta_remove(hapd, sta->addr);
6fc6879b
JM
1341
1342 if (sta->timeout_next == STA_NULLFUNC ||
1343 sta->timeout_next == STA_DISASSOC) {
1344 sta->timeout_next = STA_DEAUTH;
1345 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
1346 eloop_register_timeout(AP_DEAUTH_DELAY, 0, ap_handle_timer,
1347 hapd, sta);
1348 }
1349
1350 mlme_disassociate_indication(
1351 hapd, sta, le_to_host16(mgmt->u.disassoc.reason_code));
1352}
1353
1354
1355static void handle_deauth(struct hostapd_data *hapd,
f8b1f695 1356 const struct ieee80211_mgmt *mgmt, size_t len)
6fc6879b
JM
1357{
1358 struct sta_info *sta;
1359
1360 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.deauth)) {
3ec1e902
JM
1361 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "handle_deauth - too short "
1362 "payload (len=%lu)", (unsigned long) len);
6fc6879b
JM
1363 return;
1364 }
1365
3ec1e902 1366 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "deauthentication: STA=" MACSTR
24d75245
BG
1367 " reason_code=%d",
1368 MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
6fc6879b 1369
6fc6879b
JM
1370 sta = ap_get_sta(hapd, mgmt->sa);
1371 if (sta == NULL) {
3ec1e902
JM
1372 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR " trying "
1373 "to deauthenticate, but it is not authenticated",
24d75245 1374 MAC2STR(mgmt->sa));
6fc6879b
JM
1375 return;
1376 }
1377
ae055af4 1378 ap_sta_set_authorized(hapd, sta, 0);
b8281964
JM
1379 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
1380 WLAN_STA_ASSOC_REQ_OK);
6fc6879b
JM
1381 wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
1382 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1383 HOSTAPD_LEVEL_DEBUG, "deauthenticated");
1384 mlme_deauthenticate_indication(
1385 hapd, sta, le_to_host16(mgmt->u.deauth.reason_code));
1386 sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
1387 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
1388 ap_free_sta(hapd, sta);
1389}
1390
1391
1392static void handle_beacon(struct hostapd_data *hapd,
b57e086c 1393 const struct ieee80211_mgmt *mgmt, size_t len,
6fc6879b
JM
1394 struct hostapd_frame_info *fi)
1395{
1396 struct ieee802_11_elems elems;
1397
1398 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.beacon)) {
1399 printf("handle_beacon - too short payload (len=%lu)\n",
1400 (unsigned long) len);
1401 return;
1402 }
1403
3d536eb4 1404 (void) ieee802_11_parse_elems(mgmt->u.beacon.variable,
6fc6879b
JM
1405 len - (IEEE80211_HDRLEN +
1406 sizeof(mgmt->u.beacon)), &elems,
1407 0);
1408
6fc6879b
JM
1409 ap_list_process_beacon(hapd->iface, mgmt, &elems, fi);
1410}
1411
1412
5d22a1d5 1413#ifdef CONFIG_IEEE80211W
88b4b424 1414
93b76319 1415static void hostapd_sa_query_action(struct hostapd_data *hapd,
b57e086c
JM
1416 const struct ieee80211_mgmt *mgmt,
1417 size_t len)
5d22a1d5 1418{
b57e086c 1419 const u8 *end;
5d22a1d5 1420
93b76319
JM
1421 end = mgmt->u.action.u.sa_query_resp.trans_id +
1422 WLAN_SA_QUERY_TR_ID_LEN;
5d22a1d5 1423 if (((u8 *) mgmt) + len < end) {
93b76319 1424 wpa_printf(MSG_DEBUG, "IEEE 802.11: Too short SA Query Action "
5d22a1d5
JM
1425 "frame (len=%lu)", (unsigned long) len);
1426 return;
1427 }
1428
d4370eac
MP
1429 ieee802_11_sa_query_action(hapd, mgmt->sa,
1430 mgmt->u.action.u.sa_query_resp.action,
1431 mgmt->u.action.u.sa_query_resp.trans_id);
5d22a1d5 1432}
5d22a1d5
JM
1433
1434
c4e281fd
JM
1435static int robust_action_frame(u8 category)
1436{
1437 return category != WLAN_ACTION_PUBLIC &&
1438 category != WLAN_ACTION_HT;
1439}
9f64b827 1440#endif /* CONFIG_IEEE80211W */
c4e281fd
JM
1441
1442
c79938a5
JM
1443#ifdef CONFIG_WNM
1444static void hostapd_wnm_action(struct hostapd_data *hapd, struct sta_info *sta,
1445 const struct ieee80211_mgmt *mgmt,
1446 size_t len)
1447{
1448 struct rx_action action;
1449 if (len < IEEE80211_HDRLEN + 2)
1450 return;
1451 os_memset(&action, 0, sizeof(action));
1452 action.da = mgmt->da;
1453 action.sa = mgmt->sa;
1454 action.bssid = mgmt->bssid;
1455 action.category = mgmt->u.action.category;
1456 action.data = (const u8 *) &mgmt->u.action.u.wnm_sleep_req.action;
1457 action.len = len - IEEE80211_HDRLEN - 1;
1458 action.freq = hapd->iface->freq;
1459 ieee802_11_rx_wnm_action_ap(hapd, &action);
1460}
1461#endif /* CONFIG_WNM */
1462
1463
6fc6879b 1464static void handle_action(struct hostapd_data *hapd,
b57e086c 1465 const struct ieee80211_mgmt *mgmt, size_t len)
6fc6879b 1466{
c4e281fd 1467 struct sta_info *sta;
46eeedac 1468 sta = ap_get_sta(hapd, mgmt->sa);
c4e281fd 1469
6fc6879b
JM
1470 if (len < IEEE80211_HDRLEN + 1) {
1471 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1472 HOSTAPD_LEVEL_DEBUG,
1473 "handle_action - too short payload (len=%lu)",
1474 (unsigned long) len);
1475 return;
1476 }
1477
c79938a5
JM
1478 if (mgmt->u.action.category != WLAN_ACTION_PUBLIC &&
1479 (sta == NULL || !(sta->flags & WLAN_STA_ASSOC))) {
1480 wpa_printf(MSG_DEBUG, "IEEE 802.11: Ignored Action "
1481 "frame (category=%u) from unassociated STA " MACSTR,
1482 MAC2STR(mgmt->sa), mgmt->u.action.category);
1483 return;
1484 }
1485
c4e281fd
JM
1486#ifdef CONFIG_IEEE80211W
1487 if (sta && (sta->flags & WLAN_STA_MFP) &&
1488 !(mgmt->frame_control & host_to_le16(WLAN_FC_ISWEP) &&
1489 robust_action_frame(mgmt->u.action.category))) {
1490 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1491 HOSTAPD_LEVEL_DEBUG,
1492 "Dropped unprotected Robust Action frame from "
1493 "an MFP STA");
1494 return;
1495 }
1496#endif /* CONFIG_IEEE80211W */
1497
6fc6879b
JM
1498 switch (mgmt->u.action.category) {
1499#ifdef CONFIG_IEEE80211R
1500 case WLAN_ACTION_FT:
6fc6879b
JM
1501 if (wpa_ft_action_rx(sta->wpa_sm, (u8 *) &mgmt->u.action,
1502 len - IEEE80211_HDRLEN))
1503 break;
6fc6879b 1504 return;
6fc6879b 1505#endif /* CONFIG_IEEE80211R */
c2a71408 1506 case WLAN_ACTION_WMM:
3ae0800c 1507 hostapd_wmm_action(hapd, mgmt, len);
6fc6879b 1508 return;
5d22a1d5 1509#ifdef CONFIG_IEEE80211W
93b76319
JM
1510 case WLAN_ACTION_SA_QUERY:
1511 hostapd_sa_query_action(hapd, mgmt, len);
5d22a1d5
JM
1512 return;
1513#endif /* CONFIG_IEEE80211W */
c79938a5
JM
1514#ifdef CONFIG_WNM
1515 case WLAN_ACTION_WNM:
1516 hostapd_wnm_action(hapd, sta, mgmt, len);
1517 return;
1518#endif /* CONFIG_WNM */
c706d5aa
JM
1519 case WLAN_ACTION_PUBLIC:
1520 if (hapd->public_action_cb) {
1521 hapd->public_action_cb(hapd->public_action_cb_ctx,
1522 (u8 *) mgmt, len,
1523 hapd->iface->freq);
1524 return;
1525 }
1526 break;
e44f8bf2
JM
1527 case WLAN_ACTION_VENDOR_SPECIFIC:
1528 if (hapd->vendor_action_cb) {
1529 if (hapd->vendor_action_cb(hapd->vendor_action_cb_ctx,
1530 (u8 *) mgmt, len,
1531 hapd->iface->freq) == 0)
1532 return;
1533 }
1534 break;
6fc6879b
JM
1535 }
1536
1537 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1538 HOSTAPD_LEVEL_DEBUG,
1539 "handle_action - unknown action category %d or invalid "
1540 "frame",
1541 mgmt->u.action.category);
1542 if (!(mgmt->da[0] & 0x01) && !(mgmt->u.action.category & 0x80) &&
1543 !(mgmt->sa[0] & 0x01)) {
b57e086c
JM
1544 struct ieee80211_mgmt *resp;
1545
6fc6879b
JM
1546 /*
1547 * IEEE 802.11-REVma/D9.0 - 7.3.1.11
1548 * Return the Action frame to the source without change
1549 * except that MSB of the Category set to 1.
1550 */
1551 wpa_printf(MSG_DEBUG, "IEEE 802.11: Return unknown Action "
1552 "frame back to sender");
b57e086c
JM
1553 resp = os_malloc(len);
1554 if (resp == NULL)
1555 return;
1556 os_memcpy(resp, mgmt, len);
1557 os_memcpy(resp->da, resp->sa, ETH_ALEN);
1558 os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
1559 os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
1560 resp->u.action.category |= 0x80;
1561
41fe8b42
JM
1562 if (hostapd_drv_send_mlme(hapd, resp, len, 0) < 0) {
1563 wpa_printf(MSG_ERROR, "IEEE 802.11: Failed to send "
1564 "Action frame");
1565 }
b57e086c 1566 os_free(resp);
6fc6879b
JM
1567 }
1568}
1569
1570
1571/**
1572 * ieee802_11_mgmt - process incoming IEEE 802.11 management frames
1573 * @hapd: hostapd BSS data structure (the BSS to which the management frame was
1574 * sent to)
1575 * @buf: management frame data (starting from IEEE 802.11 header)
1576 * @len: length of frame data in octets
a17df5fb 1577 * @fi: meta data about received frame (signal level, etc.)
6fc6879b
JM
1578 *
1579 * Process all incoming IEEE 802.11 management frames. This will be called for
1580 * each frame received from the kernel driver through wlan#ap interface. In
1581 * addition, it can be called to re-inserted pending frames (e.g., when using
1582 * external RADIUS server as an MAC ACL).
1583 */
b57e086c 1584void ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
6fc6879b
JM
1585 struct hostapd_frame_info *fi)
1586{
f8b1f695 1587 struct ieee80211_mgmt *mgmt;
6fc6879b 1588 int broadcast;
f8b1f695
JM
1589 u16 fc, stype;
1590
cbcf92b4
JM
1591 if (len < 24)
1592 return;
1593
f8b1f695
JM
1594 mgmt = (struct ieee80211_mgmt *) buf;
1595 fc = le_to_host16(mgmt->frame_control);
1596 stype = WLAN_FC_GET_STYPE(fc);
6fc6879b
JM
1597
1598 if (stype == WLAN_FC_STYPE_BEACON) {
1599 handle_beacon(hapd, mgmt, len, fi);
1600 return;
1601 }
1602
6fc6879b
JM
1603 broadcast = mgmt->bssid[0] == 0xff && mgmt->bssid[1] == 0xff &&
1604 mgmt->bssid[2] == 0xff && mgmt->bssid[3] == 0xff &&
1605 mgmt->bssid[4] == 0xff && mgmt->bssid[5] == 0xff;
1606
1607 if (!broadcast &&
3eeee931
AN
1608#ifdef CONFIG_P2P
1609 /* Invitation responses can be sent with the peer MAC as BSSID */
1610 !((hapd->conf->p2p & P2P_GROUP_OWNER) &&
1611 stype == WLAN_FC_STYPE_ACTION) &&
1612#endif /* CONFIG_P2P */
fe2c5241 1613 os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0) {
6fc6879b
JM
1614 printf("MGMT: BSSID=" MACSTR " not our address\n",
1615 MAC2STR(mgmt->bssid));
1616 return;
1617 }
1618
1619
1620 if (stype == WLAN_FC_STYPE_PROBE_REQ) {
baf513d6 1621 handle_probe_req(hapd, mgmt, len, fi->ssi_signal);
6fc6879b
JM
1622 return;
1623 }
1624
1625 if (os_memcmp(mgmt->da, hapd->own_addr, ETH_ALEN) != 0) {
1626 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1627 HOSTAPD_LEVEL_DEBUG,
1628 "MGMT: DA=" MACSTR " not our address",
1629 MAC2STR(mgmt->da));
1630 return;
1631 }
1632
1633 switch (stype) {
1634 case WLAN_FC_STYPE_AUTH:
1635 wpa_printf(MSG_DEBUG, "mgmt::auth");
1636 handle_auth(hapd, mgmt, len);
1637 break;
1638 case WLAN_FC_STYPE_ASSOC_REQ:
1639 wpa_printf(MSG_DEBUG, "mgmt::assoc_req");
1640 handle_assoc(hapd, mgmt, len, 0);
1641 break;
6fc6879b
JM
1642 case WLAN_FC_STYPE_REASSOC_REQ:
1643 wpa_printf(MSG_DEBUG, "mgmt::reassoc_req");
1644 handle_assoc(hapd, mgmt, len, 1);
1645 break;
1646 case WLAN_FC_STYPE_DISASSOC:
1647 wpa_printf(MSG_DEBUG, "mgmt::disassoc");
1648 handle_disassoc(hapd, mgmt, len);
1649 break;
1650 case WLAN_FC_STYPE_DEAUTH:
3ec1e902 1651 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "mgmt::deauth");
6fc6879b
JM
1652 handle_deauth(hapd, mgmt, len);
1653 break;
1654 case WLAN_FC_STYPE_ACTION:
1655 wpa_printf(MSG_DEBUG, "mgmt::action");
1656 handle_action(hapd, mgmt, len);
1657 break;
1658 default:
1659 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1660 HOSTAPD_LEVEL_DEBUG,
1661 "unknown mgmt frame subtype %d", stype);
1662 break;
1663 }
1664}
1665
1666
1667static void handle_auth_cb(struct hostapd_data *hapd,
f8b1f695 1668 const struct ieee80211_mgmt *mgmt,
6fc6879b
JM
1669 size_t len, int ok)
1670{
1671 u16 auth_alg, auth_transaction, status_code;
1672 struct sta_info *sta;
1673
1674 if (!ok) {
1675 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
1676 HOSTAPD_LEVEL_NOTICE,
1677 "did not acknowledge authentication response");
1678 return;
1679 }
1680
1681 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
1682 printf("handle_auth_cb - too short payload (len=%lu)\n",
1683 (unsigned long) len);
1684 return;
1685 }
1686
1687 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
1688 auth_transaction = le_to_host16(mgmt->u.auth.auth_transaction);
1689 status_code = le_to_host16(mgmt->u.auth.status_code);
1690
1691 sta = ap_get_sta(hapd, mgmt->da);
1692 if (!sta) {
1693 printf("handle_auth_cb: STA " MACSTR " not found\n",
1694 MAC2STR(mgmt->da));
1695 return;
1696 }
1697
1698 if (status_code == WLAN_STATUS_SUCCESS &&
1699 ((auth_alg == WLAN_AUTH_OPEN && auth_transaction == 2) ||
1700 (auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 4))) {
1701 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1702 HOSTAPD_LEVEL_INFO, "authenticated");
1703 sta->flags |= WLAN_STA_AUTH;
1704 }
1705}
1706
1707
1708static void handle_assoc_cb(struct hostapd_data *hapd,
f8b1f695 1709 const struct ieee80211_mgmt *mgmt,
6fc6879b
JM
1710 size_t len, int reassoc, int ok)
1711{
1712 u16 status;
1713 struct sta_info *sta;
1714 int new_assoc = 1;
fc4e2d95 1715 struct ieee80211_ht_capabilities ht_cap;
a9a1d0f0 1716 struct ieee80211_vht_capabilities vht_cap;
6fc6879b 1717
6fc6879b
JM
1718 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_resp) :
1719 sizeof(mgmt->u.assoc_resp))) {
1720 printf("handle_assoc_cb(reassoc=%d) - too short payload "
1721 "(len=%lu)\n", reassoc, (unsigned long) len);
1722 return;
1723 }
1724
6fc6879b
JM
1725 sta = ap_get_sta(hapd, mgmt->da);
1726 if (!sta) {
1727 printf("handle_assoc_cb: STA " MACSTR " not found\n",
1728 MAC2STR(mgmt->da));
1729 return;
1730 }
1731
22b42372
FF
1732 if (!ok) {
1733 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
1734 HOSTAPD_LEVEL_DEBUG,
1735 "did not acknowledge association response");
1736 sta->flags &= ~WLAN_STA_ASSOC_REQ_OK;
1737 return;
1738 }
1739
1740 if (reassoc)
1741 status = le_to_host16(mgmt->u.reassoc_resp.status_code);
1742 else
1743 status = le_to_host16(mgmt->u.assoc_resp.status_code);
1744
6fc6879b
JM
1745 if (status != WLAN_STATUS_SUCCESS)
1746 goto fail;
1747
1748 /* Stop previous accounting session, if one is started, and allocate
1749 * new session id for the new session. */
1750 accounting_sta_stop(hapd, sta);
6fc6879b
JM
1751
1752 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1753 HOSTAPD_LEVEL_INFO,
2fc98d02
JM
1754 "associated (aid %d)",
1755 sta->aid);
6fc6879b
JM
1756
1757 if (sta->flags & WLAN_STA_ASSOC)
1758 new_assoc = 0;
1759 sta->flags |= WLAN_STA_ASSOC;
ef580012
JM
1760 if ((!hapd->conf->ieee802_1x && !hapd->conf->wpa) ||
1761 sta->auth_alg == WLAN_AUTH_FT) {
1762 /*
1763 * Open, static WEP, or FT protocol; no separate authorization
1764 * step.
1765 */
6905dcb1 1766 ap_sta_set_authorized(hapd, sta, 1);
515cf93f 1767 }
6fc6879b
JM
1768
1769 if (reassoc)
1770 mlme_reassociate_indication(hapd, sta);
1771 else
1772 mlme_associate_indication(hapd, sta);
1773
5d22a1d5 1774#ifdef CONFIG_IEEE80211W
93b76319 1775 sta->sa_query_timed_out = 0;
5d22a1d5
JM
1776#endif /* CONFIG_IEEE80211W */
1777
c140a228
JM
1778 /*
1779 * Remove the STA entry in order to make sure the STA PS state gets
1780 * cleared and configuration gets updated in case of reassociation back
1781 * to the same AP.
1782 */
51e2a27a 1783 hostapd_drv_sta_remove(hapd, sta->addr);
c140a228 1784
d45354be
JM
1785#ifdef CONFIG_IEEE80211N
1786 if (sta->flags & WLAN_STA_HT)
1787 hostapd_get_ht_capab(hapd, sta->ht_capabilities, &ht_cap);
1788#endif /* CONFIG_IEEE80211N */
a9a1d0f0
JB
1789#ifdef CONFIG_IEEE80211AC
1790 if (sta->flags & WLAN_STA_VHT)
1791 hostapd_get_vht_capab(hapd, sta->vht_capabilities, &vht_cap);
1792#endif /* CONFIG_IEEE80211AC */
d45354be 1793
0e8a96a9
JM
1794 if (hostapd_sta_add(hapd, sta->addr, sta->aid, sta->capability,
1795 sta->supported_rates, sta->supported_rates_len,
1796 sta->listen_interval,
d83ab1fe 1797 sta->flags & WLAN_STA_HT ? &ht_cap : NULL,
a9a1d0f0 1798 sta->flags & WLAN_STA_VHT ? &vht_cap : NULL,
5d061637 1799 sta->flags, sta->qosinfo)) {
6fc6879b
JM
1800 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1801 HOSTAPD_LEVEL_NOTICE,
1802 "Could not add STA to kernel driver");
8666585b
YAP
1803
1804 ap_sta_disconnect(hapd, sta, sta->addr,
1805 WLAN_REASON_DISASSOC_AP_BUSY);
1806
1807 goto fail;
6fc6879b
JM
1808 }
1809
7826ceae 1810 if (sta->flags & WLAN_STA_WDS)
0e8a96a9 1811 hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 1);
7826ceae 1812
6fc6879b
JM
1813 if (sta->eapol_sm == NULL) {
1814 /*
1815 * This STA does not use RADIUS server for EAP authentication,
1816 * so bind it to the selected VLAN interface now, since the
1817 * interface selection is not going to change anymore.
1818 */
4254100d
JM
1819 if (ap_sta_bind_vlan(hapd, sta, 0) < 0)
1820 goto fail;
6fc6879b
JM
1821 } else if (sta->vlan_id) {
1822 /* VLAN ID already set (e.g., by PMKSA caching), so bind STA */
4254100d
JM
1823 if (ap_sta_bind_vlan(hapd, sta, 0) < 0)
1824 goto fail;
6fc6879b 1825 }
eddd8010 1826
0e8a96a9 1827 hostapd_set_sta_flags(hapd, sta);
6fc6879b
JM
1828
1829 if (sta->auth_alg == WLAN_AUTH_FT)
1830 wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FT);
1831 else
1832 wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC);
d24df7c3 1833 hapd->new_assoc_sta_cb(hapd, sta, !new_assoc);
6fc6879b
JM
1834
1835 ieee802_1x_notify_port_enabled(sta->eapol_sm, 1);
1836
1837 fail:
1838 /* Copy of the association request is not needed anymore */
1839 if (sta->last_assoc_req) {
1840 os_free(sta->last_assoc_req);
1841 sta->last_assoc_req = NULL;
1842 }
1843}
1844
1845
4dc03726
JM
1846static void handle_deauth_cb(struct hostapd_data *hapd,
1847 const struct ieee80211_mgmt *mgmt,
1848 size_t len, int ok)
1849{
1850 struct sta_info *sta;
1851 if (mgmt->da[0] & 0x01)
1852 return;
1853 sta = ap_get_sta(hapd, mgmt->da);
1854 if (!sta) {
1855 wpa_printf(MSG_DEBUG, "handle_deauth_cb: STA " MACSTR
1856 " not found", MAC2STR(mgmt->da));
1857 return;
1858 }
1859 if (ok)
1860 wpa_printf(MSG_DEBUG, "STA " MACSTR " acknowledged deauth",
1861 MAC2STR(sta->addr));
1862 else
1863 wpa_printf(MSG_DEBUG, "STA " MACSTR " did not acknowledge "
1864 "deauth", MAC2STR(sta->addr));
1865
1866 ap_sta_deauth_cb(hapd, sta);
1867}
1868
1869
1870static void handle_disassoc_cb(struct hostapd_data *hapd,
1871 const struct ieee80211_mgmt *mgmt,
1872 size_t len, int ok)
1873{
1874 struct sta_info *sta;
1875 if (mgmt->da[0] & 0x01)
1876 return;
1877 sta = ap_get_sta(hapd, mgmt->da);
1878 if (!sta) {
1879 wpa_printf(MSG_DEBUG, "handle_disassoc_cb: STA " MACSTR
1880 " not found", MAC2STR(mgmt->da));
1881 return;
1882 }
1883 if (ok)
1884 wpa_printf(MSG_DEBUG, "STA " MACSTR " acknowledged disassoc",
1885 MAC2STR(sta->addr));
1886 else
1887 wpa_printf(MSG_DEBUG, "STA " MACSTR " did not acknowledge "
1888 "disassoc", MAC2STR(sta->addr));
1889
1890 ap_sta_disassoc_cb(hapd, sta);
1891}
1892
1893
1c6e69cc
JM
1894/**
1895 * ieee802_11_mgmt_cb - Process management frame TX status callback
1896 * @hapd: hostapd BSS data structure (the BSS from which the management frame
1897 * was sent from)
1898 * @buf: management frame data (starting from IEEE 802.11 header)
1899 * @len: length of frame data in octets
1900 * @stype: management frame subtype from frame control field
1901 * @ok: Whether the frame was ACK'ed
1902 */
f8b1f695 1903void ieee802_11_mgmt_cb(struct hostapd_data *hapd, const u8 *buf, size_t len,
6fc6879b
JM
1904 u16 stype, int ok)
1905{
f8b1f695
JM
1906 const struct ieee80211_mgmt *mgmt;
1907 mgmt = (const struct ieee80211_mgmt *) buf;
6fc6879b
JM
1908
1909 switch (stype) {
1910 case WLAN_FC_STYPE_AUTH:
1911 wpa_printf(MSG_DEBUG, "mgmt::auth cb");
1912 handle_auth_cb(hapd, mgmt, len, ok);
1913 break;
1914 case WLAN_FC_STYPE_ASSOC_RESP:
1915 wpa_printf(MSG_DEBUG, "mgmt::assoc_resp cb");
1916 handle_assoc_cb(hapd, mgmt, len, 0, ok);
1917 break;
1918 case WLAN_FC_STYPE_REASSOC_RESP:
1919 wpa_printf(MSG_DEBUG, "mgmt::reassoc_resp cb");
1920 handle_assoc_cb(hapd, mgmt, len, 1, ok);
1921 break;
1922 case WLAN_FC_STYPE_PROBE_RESP:
2d8bf732 1923 wpa_printf(MSG_EXCESSIVE, "mgmt::proberesp cb");
6fc6879b
JM
1924 break;
1925 case WLAN_FC_STYPE_DEAUTH:
4dc03726
JM
1926 wpa_printf(MSG_DEBUG, "mgmt::deauth cb");
1927 handle_deauth_cb(hapd, mgmt, len, ok);
1928 break;
1929 case WLAN_FC_STYPE_DISASSOC:
1930 wpa_printf(MSG_DEBUG, "mgmt::disassoc cb");
1931 handle_disassoc_cb(hapd, mgmt, len, ok);
6fc6879b 1932 break;
5d22a1d5
JM
1933 case WLAN_FC_STYPE_ACTION:
1934 wpa_printf(MSG_DEBUG, "mgmt::action cb");
1935 break;
6fc6879b
JM
1936 default:
1937 printf("unknown mgmt cb frame subtype %d\n", stype);
1938 break;
1939 }
1940}
1941
1942
6fc6879b
JM
1943int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
1944{
1945 /* TODO */
1946 return 0;
1947}
1948
1949
1950int ieee802_11_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
1951 char *buf, size_t buflen)
1952{
1953 /* TODO */
1954 return 0;
1955}
1956
f8b1f695
JM
1957
1958void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
1959 const u8 *buf, size_t len, int ack)
1960{
1961 struct sta_info *sta;
1962 struct hostapd_iface *iface = hapd->iface;
1963
1964 sta = ap_get_sta(hapd, addr);
1965 if (sta == NULL && iface->num_bss > 1) {
1966 size_t j;
1967 for (j = 0; j < iface->num_bss; j++) {
1968 hapd = iface->bss[j];
1969 sta = ap_get_sta(hapd, addr);
1970 if (sta)
1971 break;
1972 }
1973 }
0c01d65d 1974 if (sta == NULL || !(sta->flags & WLAN_STA_ASSOC))
f8b1f695
JM
1975 return;
1976 if (sta->flags & WLAN_STA_PENDING_POLL) {
1977 wpa_printf(MSG_DEBUG, "STA " MACSTR " %s pending "
1978 "activity poll", MAC2STR(sta->addr),
1979 ack ? "ACKed" : "did not ACK");
1980 if (ack)
1981 sta->flags &= ~WLAN_STA_PENDING_POLL;
1982 }
1983
1984 ieee802_1x_tx_status(hapd, sta, buf, len, ack);
1985}
1986
1987
dd840f79
JB
1988void hostapd_eapol_tx_status(struct hostapd_data *hapd, const u8 *dst,
1989 const u8 *data, size_t len, int ack)
1990{
1991 struct sta_info *sta;
1992 struct hostapd_iface *iface = hapd->iface;
1993
1994 sta = ap_get_sta(hapd, dst);
1995 if (sta == NULL && iface->num_bss > 1) {
1996 size_t j;
1997 for (j = 0; j < iface->num_bss; j++) {
1998 hapd = iface->bss[j];
1999 sta = ap_get_sta(hapd, dst);
2000 if (sta)
2001 break;
2002 }
2003 }
d9a38716
JM
2004 if (sta == NULL || !(sta->flags & WLAN_STA_ASSOC)) {
2005 wpa_printf(MSG_DEBUG, "Ignore TX status for Data frame to STA "
2006 MACSTR " that is not currently associated",
2007 MAC2STR(dst));
dd840f79 2008 return;
d9a38716 2009 }
dd840f79
JB
2010
2011 ieee802_1x_eapol_tx_status(hapd, sta, data, len, ack);
2012}
2013
2014
bcf24348
JB
2015void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr)
2016{
2017 struct sta_info *sta;
2018 struct hostapd_iface *iface = hapd->iface;
2019
2020 sta = ap_get_sta(hapd, addr);
2021 if (sta == NULL && iface->num_bss > 1) {
2022 size_t j;
2023 for (j = 0; j < iface->num_bss; j++) {
2024 hapd = iface->bss[j];
2025 sta = ap_get_sta(hapd, addr);
2026 if (sta)
2027 break;
2028 }
2029 }
2030 if (sta == NULL)
2031 return;
2032 if (!(sta->flags & WLAN_STA_PENDING_POLL))
2033 return;
2034
2035 wpa_printf(MSG_DEBUG, "STA " MACSTR " ACKed pending "
2036 "activity poll", MAC2STR(sta->addr));
2037 sta->flags &= ~WLAN_STA_PENDING_POLL;
2038}
2039
2040
fbbfcbac
FF
2041void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
2042 int wds)
f8b1f695
JM
2043{
2044 struct sta_info *sta;
2045
2046 sta = ap_get_sta(hapd, src);
fbbfcbac 2047 if (sta && (sta->flags & WLAN_STA_ASSOC)) {
99743811
FF
2048 if (!hapd->conf->wds_sta)
2049 return;
2050
fbbfcbac
FF
2051 if (wds && !(sta->flags & WLAN_STA_WDS)) {
2052 wpa_printf(MSG_DEBUG, "Enable 4-address WDS mode for "
2053 "STA " MACSTR " (aid %u)",
2054 MAC2STR(sta->addr), sta->aid);
2055 sta->flags |= WLAN_STA_WDS;
0e8a96a9 2056 hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 1);
fbbfcbac 2057 }
f8b1f695 2058 return;
fbbfcbac 2059 }
f8b1f695
JM
2060
2061 wpa_printf(MSG_DEBUG, "Data/PS-poll frame from not associated STA "
2062 MACSTR, MAC2STR(src));
1df492df
JM
2063 if (src[0] & 0x01) {
2064 /* Broadcast bit set in SA?! Ignore the frame silently. */
2065 return;
2066 }
2067
b8281964
JM
2068 if (sta && (sta->flags & WLAN_STA_ASSOC_REQ_OK)) {
2069 wpa_printf(MSG_DEBUG, "Association Response to the STA has "
2070 "already been sent, but no TX status yet known - "
2071 "ignore Class 3 frame issue with " MACSTR,
2072 MAC2STR(src));
2073 return;
2074 }
2075
f8b1f695 2076 if (sta && (sta->flags & WLAN_STA_AUTH))
51e2a27a 2077 hostapd_drv_sta_disassoc(
f8b1f695
JM
2078 hapd, src,
2079 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
2080 else
51e2a27a 2081 hostapd_drv_sta_deauth(
f8b1f695
JM
2082 hapd, src,
2083 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
2084}
2085
2086
6fc6879b 2087#endif /* CONFIG_NATIVE_WINDOWS */