2 * hostapd / IEEE 802.11 Management
3 * Copyright (c) 2002-2012, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
11 #ifndef CONFIG_NATIVE_WINDOWS
13 #include "utils/common.h"
14 #include "utils/eloop.h"
15 #include "crypto/crypto.h"
16 #include "drivers/driver.h"
17 #include "common/ieee802_11_defs.h"
18 #include "common/ieee802_11_common.h"
19 #include "common/wpa_ctrl.h"
20 #include "radius/radius.h"
21 #include "radius/radius_client.h"
26 #include "ieee802_11_auth.h"
28 #include "ieee802_1x.h"
32 #include "accounting.h"
33 #include "ap_config.h"
35 #include "p2p_hostapd.h"
36 #include "ap_drv_ops.h"
38 #include "ieee802_11.h"
41 u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid)
46 if (hapd->iface->current_rates == NULL)
49 *pos++ = WLAN_EID_SUPP_RATES;
50 num = hapd->iface->num_rates;
51 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht)
53 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht)
56 /* rest of the rates are encoded in Extended supported
63 for (i = 0, count = 0; i < hapd->iface->num_rates && count < num;
66 *pos = hapd->iface->current_rates[i].rate / 5;
67 if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC)
72 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht && count < 8) {
74 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_HT_PHY;
77 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht && count < 8) {
79 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_VHT_PHY;
86 u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid)
91 if (hapd->iface->current_rates == NULL)
94 num = hapd->iface->num_rates;
95 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht)
97 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht)
103 *pos++ = WLAN_EID_EXT_SUPP_RATES;
106 for (i = 0, count = 0; i < hapd->iface->num_rates && count < num + 8;
110 continue; /* already in SuppRates IE */
111 *pos = hapd->iface->current_rates[i].rate / 5;
112 if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC)
117 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht) {
120 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_HT_PHY;
123 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht) {
126 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_VHT_PHY;
133 u16 hostapd_own_capab_info(struct hostapd_data *hapd, struct sta_info *sta,
136 int capab = WLAN_CAPABILITY_ESS;
139 if (hapd->iface->num_sta_no_short_preamble == 0 &&
140 hapd->iconf->preamble == SHORT_PREAMBLE)
141 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
143 privacy = hapd->conf->ssid.wep.keys_set;
145 if (hapd->conf->ieee802_1x &&
146 (hapd->conf->default_wep_key_len ||
147 hapd->conf->individual_wep_key_len))
154 int policy, def_klen;
155 if (probe && sta->ssid_probe) {
156 policy = sta->ssid_probe->security_policy;
157 def_klen = sta->ssid_probe->wep.default_len;
159 policy = sta->ssid->security_policy;
160 def_klen = sta->ssid->wep.default_len;
162 privacy = policy != SECURITY_PLAINTEXT;
163 if (policy == SECURITY_IEEE_802_1X && def_klen == 0)
168 capab |= WLAN_CAPABILITY_PRIVACY;
170 if (hapd->iface->current_mode &&
171 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
172 hapd->iface->num_sta_no_short_slot_time == 0)
173 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
179 void ieee802_11_print_ssid(char *buf, const u8 *ssid, u8 len)
182 if (len > HOSTAPD_MAX_SSID_LEN)
183 len = HOSTAPD_MAX_SSID_LEN;
184 for (i = 0; i < len; i++) {
185 if (ssid[i] >= 32 && ssid[i] < 127)
194 static u16 auth_shared_key(struct hostapd_data *hapd, struct sta_info *sta,
195 u16 auth_transaction, const u8 *challenge,
198 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
200 "authentication (shared key, transaction %d)",
203 if (auth_transaction == 1) {
204 if (!sta->challenge) {
205 /* Generate a pseudo-random challenge */
209 sta->challenge = os_zalloc(WLAN_AUTH_CHALLENGE_LEN);
210 if (sta->challenge == NULL)
211 return WLAN_STATUS_UNSPECIFIED_FAILURE;
215 os_memcpy(key, &now.sec, 4);
216 os_memcpy(key + 4, &r, 4);
217 rc4_skip(key, sizeof(key), 0,
218 sta->challenge, WLAN_AUTH_CHALLENGE_LEN);
223 if (auth_transaction != 3)
224 return WLAN_STATUS_UNSPECIFIED_FAILURE;
227 if (!iswep || !sta->challenge || !challenge ||
228 os_memcmp(sta->challenge, challenge, WLAN_AUTH_CHALLENGE_LEN)) {
229 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
231 "shared key authentication - invalid "
232 "challenge-response");
233 return WLAN_STATUS_CHALLENGE_FAIL;
236 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
238 "authentication OK (shared key)");
239 #ifdef IEEE80211_REQUIRE_AUTH_ACK
240 /* Station will be marked authenticated if it ACKs the
241 * authentication reply. */
243 sta->flags |= WLAN_STA_AUTH;
244 wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
246 os_free(sta->challenge);
247 sta->challenge = NULL;
253 static void send_auth_reply(struct hostapd_data *hapd,
254 const u8 *dst, const u8 *bssid,
255 u16 auth_alg, u16 auth_transaction, u16 resp,
256 const u8 *ies, size_t ies_len)
258 struct ieee80211_mgmt *reply;
262 rlen = IEEE80211_HDRLEN + sizeof(reply->u.auth) + ies_len;
263 buf = os_zalloc(rlen);
267 reply = (struct ieee80211_mgmt *) buf;
268 reply->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
270 os_memcpy(reply->da, dst, ETH_ALEN);
271 os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
272 os_memcpy(reply->bssid, bssid, ETH_ALEN);
274 reply->u.auth.auth_alg = host_to_le16(auth_alg);
275 reply->u.auth.auth_transaction = host_to_le16(auth_transaction);
276 reply->u.auth.status_code = host_to_le16(resp);
279 os_memcpy(reply->u.auth.variable, ies, ies_len);
281 wpa_printf(MSG_DEBUG, "authentication reply: STA=" MACSTR
282 " auth_alg=%d auth_transaction=%d resp=%d (IE len=%lu)",
283 MAC2STR(dst), auth_alg, auth_transaction,
284 resp, (unsigned long) ies_len);
285 if (hostapd_drv_send_mlme(hapd, reply, rlen, 0) < 0)
286 perror("send_auth_reply: send");
292 #ifdef CONFIG_IEEE80211R
293 static void handle_auth_ft_finish(void *ctx, const u8 *dst, const u8 *bssid,
294 u16 auth_transaction, u16 status,
295 const u8 *ies, size_t ies_len)
297 struct hostapd_data *hapd = ctx;
298 struct sta_info *sta;
300 send_auth_reply(hapd, dst, bssid, WLAN_AUTH_FT, auth_transaction,
301 status, ies, ies_len);
303 if (status != WLAN_STATUS_SUCCESS)
306 sta = ap_get_sta(hapd, dst);
310 hostapd_logger(hapd, dst, HOSTAPD_MODULE_IEEE80211,
311 HOSTAPD_LEVEL_DEBUG, "authentication OK (FT)");
312 sta->flags |= WLAN_STA_AUTH;
313 mlme_authenticate_indication(hapd, sta);
315 #endif /* CONFIG_IEEE80211R */
320 static struct wpabuf * auth_build_sae_commit(struct hostapd_data *hapd,
321 struct sta_info *sta)
325 buf = wpabuf_alloc(2);
329 wpabuf_put_le16(buf, 19); /* Finite Cyclic Group */
330 /* TODO: Anti-Clogging Token (if requested) */
338 static struct wpabuf * auth_build_sae_confirm(struct hostapd_data *hapd,
339 struct sta_info *sta)
343 buf = wpabuf_alloc(2);
347 wpabuf_put_le16(buf, sta->sae_send_confirm);
348 sta->sae_send_confirm++;
355 static u16 handle_sae_commit(struct hostapd_data *hapd, struct sta_info *sta,
356 const u8 *data, size_t len)
358 wpa_hexdump(MSG_DEBUG, "SAE commit fields", data, len);
360 /* Check Finite Cyclic Group */
362 return WLAN_STATUS_UNSPECIFIED_FAILURE;
363 if (WPA_GET_LE16(data) != 19) {
364 wpa_printf(MSG_DEBUG, "SAE: Unsupported Finite Cyclic Group %u",
366 return WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED;
369 return WLAN_STATUS_SUCCESS;
373 static u16 handle_sae_confirm(struct hostapd_data *hapd, struct sta_info *sta,
374 const u8 *data, size_t len)
378 wpa_hexdump(MSG_DEBUG, "SAE confirm fields", data, len);
381 return WLAN_STATUS_UNSPECIFIED_FAILURE;
382 rc = WPA_GET_LE16(data);
383 wpa_printf(MSG_DEBUG, "SAE: peer-send-confirm %u", rc);
385 return WLAN_STATUS_SUCCESS;
389 static void handle_auth_sae(struct hostapd_data *hapd, struct sta_info *sta,
390 const struct ieee80211_mgmt *mgmt, size_t len,
393 u16 resp = WLAN_STATUS_SUCCESS;
396 if (auth_transaction == 1) {
397 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
399 "start SAE authentication (RX commit)");
400 resp = handle_sae_commit(hapd, sta, mgmt->u.auth.variable,
401 ((u8 *) mgmt) + len -
402 mgmt->u.auth.variable);
403 if (resp == WLAN_STATUS_SUCCESS)
404 sta->sae_state = SAE_COMMIT;
405 } else if (auth_transaction == 2) {
406 if (sta->sae_state != SAE_COMMIT) {
407 hostapd_logger(hapd, sta->addr,
408 HOSTAPD_MODULE_IEEE80211,
410 "SAE confirm before commit");
411 resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
413 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
415 "SAE authentication (RX confirm)");
416 resp = handle_sae_confirm(hapd, sta, mgmt->u.auth.variable,
417 ((u8 *) mgmt) + len -
418 mgmt->u.auth.variable);
419 if (resp == WLAN_STATUS_SUCCESS) {
420 sta->flags |= WLAN_STA_AUTH;
421 wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
422 sta->auth_alg = WLAN_AUTH_SAE;
423 mlme_authenticate_indication(hapd, sta);
426 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
428 "unexpected SAE authentication transaction %u",
430 resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
433 sta->auth_alg = WLAN_AUTH_SAE;
435 if (resp == WLAN_STATUS_SUCCESS) {
436 if (auth_transaction == 1)
437 data = auth_build_sae_commit(hapd, sta);
439 data = auth_build_sae_confirm(hapd, sta);
441 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
445 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, WLAN_AUTH_SAE,
446 auth_transaction, resp,
447 data ? wpabuf_head(data) : (u8 *) "",
448 data ? wpabuf_len(data) : 0);
451 #endif /* CONFIG_SAE */
454 static void handle_auth(struct hostapd_data *hapd,
455 const struct ieee80211_mgmt *mgmt, size_t len)
457 u16 auth_alg, auth_transaction, status_code;
458 u16 resp = WLAN_STATUS_SUCCESS;
459 struct sta_info *sta = NULL;
462 const u8 *challenge = NULL;
463 u32 session_timeout, acct_interim_interval;
465 struct hostapd_sta_wpa_psk_short *psk = NULL;
466 u8 resp_ies[2 + WLAN_AUTH_CHALLENGE_LEN];
467 size_t resp_ies_len = 0;
468 char *identity = NULL;
469 char *radius_cui = NULL;
471 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
472 printf("handle_auth - too short payload (len=%lu)\n",
473 (unsigned long) len);
477 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
478 auth_transaction = le_to_host16(mgmt->u.auth.auth_transaction);
479 status_code = le_to_host16(mgmt->u.auth.status_code);
480 fc = le_to_host16(mgmt->frame_control);
482 if (len >= IEEE80211_HDRLEN + sizeof(mgmt->u.auth) +
483 2 + WLAN_AUTH_CHALLENGE_LEN &&
484 mgmt->u.auth.variable[0] == WLAN_EID_CHALLENGE &&
485 mgmt->u.auth.variable[1] == WLAN_AUTH_CHALLENGE_LEN)
486 challenge = &mgmt->u.auth.variable[2];
488 wpa_printf(MSG_DEBUG, "authentication: STA=" MACSTR " auth_alg=%d "
489 "auth_transaction=%d status_code=%d wep=%d%s",
490 MAC2STR(mgmt->sa), auth_alg, auth_transaction,
491 status_code, !!(fc & WLAN_FC_ISWEP),
492 challenge ? " challenge" : "");
494 if (hapd->tkip_countermeasures) {
495 resp = WLAN_REASON_MICHAEL_MIC_FAILURE;
499 if (!(((hapd->conf->auth_algs & WPA_AUTH_ALG_OPEN) &&
500 auth_alg == WLAN_AUTH_OPEN) ||
501 #ifdef CONFIG_IEEE80211R
502 (hapd->conf->wpa && wpa_key_mgmt_ft(hapd->conf->wpa_key_mgmt) &&
503 auth_alg == WLAN_AUTH_FT) ||
504 #endif /* CONFIG_IEEE80211R */
506 (hapd->conf->wpa && wpa_key_mgmt_sae(hapd->conf->wpa_key_mgmt) &&
507 auth_alg == WLAN_AUTH_SAE) ||
508 #endif /* CONFIG_SAE */
509 ((hapd->conf->auth_algs & WPA_AUTH_ALG_SHARED) &&
510 auth_alg == WLAN_AUTH_SHARED_KEY))) {
511 printf("Unsupported authentication algorithm (%d)\n",
513 resp = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
517 if (!(auth_transaction == 1 || auth_alg == WLAN_AUTH_SAE ||
518 (auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 3))) {
519 printf("Unknown authentication transaction number (%d)\n",
521 resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
525 if (os_memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) {
526 printf("Station " MACSTR " not allowed to authenticate.\n",
528 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
532 res = hostapd_allowed_address(hapd, mgmt->sa, (u8 *) mgmt, len,
534 &acct_interim_interval, &vlan_id,
535 &psk, &identity, &radius_cui);
537 if (res == HOSTAPD_ACL_REJECT) {
538 printf("Station " MACSTR " not allowed to authenticate.\n",
540 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
543 if (res == HOSTAPD_ACL_PENDING) {
544 wpa_printf(MSG_DEBUG, "Authentication frame from " MACSTR
545 " waiting for an external authentication",
547 /* Authentication code will re-send the authentication frame
548 * after it has received (and cached) information from the
549 * external source. */
553 sta = ap_sta_add(hapd, mgmt->sa);
555 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
560 if (hostapd_get_vlan_id_ifname(hapd->conf->vlan,
562 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS,
563 HOSTAPD_LEVEL_INFO, "Invalid VLAN ID "
564 "%d received from RADIUS server",
566 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
569 sta->vlan_id = vlan_id;
570 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS,
571 HOSTAPD_LEVEL_INFO, "VLAN ID %d", sta->vlan_id);
574 hostapd_free_psk_list(sta->psk);
575 if (hapd->conf->wpa_psk_radius != PSK_RADIUS_IGNORED) {
582 sta->identity = identity;
584 sta->radius_cui = radius_cui;
587 sta->flags &= ~WLAN_STA_PREAUTH;
588 ieee802_1x_notify_pre_auth(sta->eapol_sm, 0);
590 if (hapd->conf->acct_interim_interval == 0 && acct_interim_interval)
591 sta->acct_interim_interval = acct_interim_interval;
592 if (res == HOSTAPD_ACL_ACCEPT_TIMEOUT)
593 ap_sta_session_timeout(hapd, sta, session_timeout);
595 ap_sta_no_session_timeout(hapd, sta);
599 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
601 "authentication OK (open system)");
602 #ifdef IEEE80211_REQUIRE_AUTH_ACK
603 /* Station will be marked authenticated if it ACKs the
604 * authentication reply. */
606 sta->flags |= WLAN_STA_AUTH;
607 wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
608 sta->auth_alg = WLAN_AUTH_OPEN;
609 mlme_authenticate_indication(hapd, sta);
612 case WLAN_AUTH_SHARED_KEY:
613 resp = auth_shared_key(hapd, sta, auth_transaction, challenge,
615 sta->auth_alg = WLAN_AUTH_SHARED_KEY;
616 mlme_authenticate_indication(hapd, sta);
617 if (sta->challenge && auth_transaction == 1) {
618 resp_ies[0] = WLAN_EID_CHALLENGE;
619 resp_ies[1] = WLAN_AUTH_CHALLENGE_LEN;
620 os_memcpy(resp_ies + 2, sta->challenge,
621 WLAN_AUTH_CHALLENGE_LEN);
622 resp_ies_len = 2 + WLAN_AUTH_CHALLENGE_LEN;
625 #ifdef CONFIG_IEEE80211R
627 sta->auth_alg = WLAN_AUTH_FT;
628 if (sta->wpa_sm == NULL)
629 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
631 if (sta->wpa_sm == NULL) {
632 wpa_printf(MSG_DEBUG, "FT: Failed to initialize WPA "
634 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
637 wpa_ft_process_auth(sta->wpa_sm, mgmt->bssid,
638 auth_transaction, mgmt->u.auth.variable,
639 len - IEEE80211_HDRLEN -
640 sizeof(mgmt->u.auth),
641 handle_auth_ft_finish, hapd);
642 /* handle_auth_ft_finish() callback will complete auth. */
644 #endif /* CONFIG_IEEE80211R */
647 handle_auth_sae(hapd, sta, mgmt, len, auth_transaction);
649 #endif /* CONFIG_SAE */
655 hostapd_free_psk_list(psk);
657 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, auth_alg,
658 auth_transaction + 1, resp, resp_ies, resp_ies_len);
662 static int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta)
666 /* get a unique AID */
668 wpa_printf(MSG_DEBUG, " old AID %d", sta->aid);
672 for (i = 0; i < AID_WORDS; i++) {
673 if (hapd->sta_aid[i] == (u32) -1)
675 for (j = 0; j < 32; j++) {
676 if (!(hapd->sta_aid[i] & BIT(j)))
684 aid = i * 32 + j + 1;
689 hapd->sta_aid[i] |= BIT(j);
690 wpa_printf(MSG_DEBUG, " new AID %d", sta->aid);
695 static u16 check_ssid(struct hostapd_data *hapd, struct sta_info *sta,
696 const u8 *ssid_ie, size_t ssid_ie_len)
699 return WLAN_STATUS_UNSPECIFIED_FAILURE;
701 if (ssid_ie_len != hapd->conf->ssid.ssid_len ||
702 os_memcmp(ssid_ie, hapd->conf->ssid.ssid, ssid_ie_len) != 0) {
704 ieee802_11_print_ssid(ssid_txt, ssid_ie, ssid_ie_len);
705 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
707 "Station tried to associate with unknown SSID "
709 return WLAN_STATUS_UNSPECIFIED_FAILURE;
712 return WLAN_STATUS_SUCCESS;
716 static u16 check_wmm(struct hostapd_data *hapd, struct sta_info *sta,
717 const u8 *wmm_ie, size_t wmm_ie_len)
719 sta->flags &= ~WLAN_STA_WMM;
721 if (wmm_ie && hapd->conf->wmm_enabled) {
722 struct wmm_information_element *wmm;
724 if (!hostapd_eid_wmm_valid(hapd, wmm_ie, wmm_ie_len)) {
725 hostapd_logger(hapd, sta->addr,
728 "invalid WMM element in association "
730 return WLAN_STATUS_UNSPECIFIED_FAILURE;
733 sta->flags |= WLAN_STA_WMM;
734 wmm = (struct wmm_information_element *) wmm_ie;
735 sta->qosinfo = wmm->qos_info;
737 return WLAN_STATUS_SUCCESS;
741 static u16 copy_supp_rates(struct hostapd_data *hapd, struct sta_info *sta,
742 struct ieee802_11_elems *elems)
744 if (!elems->supp_rates) {
745 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
747 "No supported rates element in AssocReq");
748 return WLAN_STATUS_UNSPECIFIED_FAILURE;
751 if (elems->supp_rates_len + elems->ext_supp_rates_len >
752 sizeof(sta->supported_rates)) {
753 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
755 "Invalid supported rates element length %d+%d",
756 elems->supp_rates_len,
757 elems->ext_supp_rates_len);
758 return WLAN_STATUS_UNSPECIFIED_FAILURE;
761 sta->supported_rates_len = merge_byte_arrays(
762 sta->supported_rates, sizeof(sta->supported_rates),
763 elems->supp_rates, elems->supp_rates_len,
764 elems->ext_supp_rates, elems->ext_supp_rates_len);
766 return WLAN_STATUS_SUCCESS;
770 static u16 check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta,
771 const u8 *ies, size_t ies_len, int reassoc)
773 struct ieee802_11_elems elems;
778 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed) {
779 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
780 HOSTAPD_LEVEL_INFO, "Station sent an invalid "
781 "association request");
782 return WLAN_STATUS_UNSPECIFIED_FAILURE;
785 resp = check_ssid(hapd, sta, elems.ssid, elems.ssid_len);
786 if (resp != WLAN_STATUS_SUCCESS)
788 resp = check_wmm(hapd, sta, elems.wmm, elems.wmm_len);
789 if (resp != WLAN_STATUS_SUCCESS)
791 resp = copy_supp_rates(hapd, sta, &elems);
792 if (resp != WLAN_STATUS_SUCCESS)
794 #ifdef CONFIG_IEEE80211N
795 resp = copy_sta_ht_capab(hapd, sta, elems.ht_capabilities,
796 elems.ht_capabilities_len);
797 if (resp != WLAN_STATUS_SUCCESS)
799 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht &&
800 !(sta->flags & WLAN_STA_HT)) {
801 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
802 HOSTAPD_LEVEL_INFO, "Station does not support "
803 "mandatory HT PHY - reject association");
804 return WLAN_STATUS_ASSOC_DENIED_NO_HT;
806 #endif /* CONFIG_IEEE80211N */
808 #ifdef CONFIG_IEEE80211AC
809 resp = copy_sta_vht_capab(hapd, sta, elems.vht_capabilities,
810 elems.vht_capabilities_len);
811 if (resp != WLAN_STATUS_SUCCESS)
813 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht &&
814 !(sta->flags & WLAN_STA_VHT)) {
815 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
816 HOSTAPD_LEVEL_INFO, "Station does not support "
817 "mandatory VHT PHY - reject association");
818 return WLAN_STATUS_UNSPECIFIED_FAILURE;
820 #endif /* CONFIG_IEEE80211AC */
822 if ((hapd->conf->wpa & WPA_PROTO_RSN) && elems.rsn_ie) {
823 wpa_ie = elems.rsn_ie;
824 wpa_ie_len = elems.rsn_ie_len;
825 } else if ((hapd->conf->wpa & WPA_PROTO_WPA) &&
827 wpa_ie = elems.wpa_ie;
828 wpa_ie_len = elems.wpa_ie_len;
835 sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2);
836 if (hapd->conf->wps_state && elems.wps_ie) {
837 wpa_printf(MSG_DEBUG, "STA included WPS IE in (Re)Association "
838 "Request - assume WPS is used");
839 sta->flags |= WLAN_STA_WPS;
840 wpabuf_free(sta->wps_ie);
841 sta->wps_ie = ieee802_11_vendor_ie_concat(ies, ies_len,
843 if (sta->wps_ie && wps_is_20(sta->wps_ie)) {
844 wpa_printf(MSG_DEBUG, "WPS: STA supports WPS 2.0");
845 sta->flags |= WLAN_STA_WPS2;
849 if (sta->wps_ie && wps_validate_assoc_req(sta->wps_ie) < 0) {
850 wpa_printf(MSG_DEBUG, "WPS: Invalid WPS IE in "
851 "(Re)Association Request - reject");
852 return WLAN_STATUS_INVALID_IE;
854 } else if (hapd->conf->wps_state && wpa_ie == NULL) {
855 wpa_printf(MSG_DEBUG, "STA did not include WPA/RSN IE in "
856 "(Re)Association Request - possible WPS use");
857 sta->flags |= WLAN_STA_MAYBE_WPS;
859 #endif /* CONFIG_WPS */
860 if (hapd->conf->wpa && wpa_ie == NULL) {
861 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
863 "No WPA/RSN IE in association request");
864 return WLAN_STATUS_INVALID_IE;
867 if (hapd->conf->wpa && wpa_ie) {
871 if (sta->wpa_sm == NULL)
872 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
874 if (sta->wpa_sm == NULL) {
875 wpa_printf(MSG_WARNING, "Failed to initialize WPA "
877 return WLAN_STATUS_UNSPECIFIED_FAILURE;
879 res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm,
881 elems.mdie, elems.mdie_len);
882 if (res == WPA_INVALID_GROUP)
883 resp = WLAN_STATUS_GROUP_CIPHER_NOT_VALID;
884 else if (res == WPA_INVALID_PAIRWISE)
885 resp = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID;
886 else if (res == WPA_INVALID_AKMP)
887 resp = WLAN_STATUS_AKMP_NOT_VALID;
888 else if (res == WPA_ALLOC_FAIL)
889 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
890 #ifdef CONFIG_IEEE80211W
891 else if (res == WPA_MGMT_FRAME_PROTECTION_VIOLATION)
892 resp = WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION;
893 else if (res == WPA_INVALID_MGMT_GROUP_CIPHER)
894 resp = WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION;
895 #endif /* CONFIG_IEEE80211W */
896 else if (res == WPA_INVALID_MDIE)
897 resp = WLAN_STATUS_INVALID_MDIE;
898 else if (res != WPA_IE_OK)
899 resp = WLAN_STATUS_INVALID_IE;
900 if (resp != WLAN_STATUS_SUCCESS)
902 #ifdef CONFIG_IEEE80211W
903 if ((sta->flags & WLAN_STA_MFP) && !sta->sa_query_timed_out &&
904 sta->sa_query_count > 0)
905 ap_check_sa_query_timeout(hapd, sta);
906 if ((sta->flags & WLAN_STA_MFP) && !sta->sa_query_timed_out &&
907 (!reassoc || sta->auth_alg != WLAN_AUTH_FT)) {
909 * STA has already been associated with MFP and SA
910 * Query timeout has not been reached. Reject the
911 * association attempt temporarily and start SA Query,
912 * if one is not pending.
915 if (sta->sa_query_count == 0)
916 ap_sta_start_sa_query(hapd, sta);
918 return WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY;
921 if (wpa_auth_uses_mfp(sta->wpa_sm))
922 sta->flags |= WLAN_STA_MFP;
924 sta->flags &= ~WLAN_STA_MFP;
925 #endif /* CONFIG_IEEE80211W */
927 #ifdef CONFIG_IEEE80211R
928 if (sta->auth_alg == WLAN_AUTH_FT) {
930 wpa_printf(MSG_DEBUG, "FT: " MACSTR " tried "
931 "to use association (not "
932 "re-association) with FT auth_alg",
934 return WLAN_STATUS_UNSPECIFIED_FAILURE;
937 resp = wpa_ft_validate_reassoc(sta->wpa_sm, ies,
939 if (resp != WLAN_STATUS_SUCCESS)
942 #endif /* CONFIG_IEEE80211R */
945 if (wpa_auth_uses_sae(sta->wpa_sm) &&
946 sta->auth_alg != WLAN_AUTH_SAE) {
947 wpa_printf(MSG_DEBUG, "SAE: " MACSTR " tried to use "
948 "SAE AKM after non-SAE auth_alg %u",
949 MAC2STR(sta->addr), sta->auth_alg);
950 return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
952 #endif /* CONFIG_SAE */
954 #ifdef CONFIG_IEEE80211N
955 if ((sta->flags & (WLAN_STA_HT | WLAN_STA_VHT)) &&
956 wpa_auth_get_pairwise(sta->wpa_sm) == WPA_CIPHER_TKIP) {
957 hostapd_logger(hapd, sta->addr,
958 HOSTAPD_MODULE_IEEE80211,
960 "Station tried to use TKIP with HT "
962 return WLAN_STATUS_CIPHER_REJECTED_PER_POLICY;
964 #endif /* CONFIG_IEEE80211N */
966 wpa_auth_sta_no_wpa(sta->wpa_sm);
970 wpabuf_free(sta->p2p_ie);
971 sta->p2p_ie = ieee802_11_vendor_ie_concat(ies, ies_len,
975 wpabuf_free(sta->p2p_ie);
979 p2p_group_notif_assoc(hapd->p2p_group, sta->addr, ies, ies_len);
980 #endif /* CONFIG_P2P */
983 wpabuf_free(sta->hs20_ie);
984 if (elems.hs20 && elems.hs20_len > 4) {
985 sta->hs20_ie = wpabuf_alloc_copy(elems.hs20 + 4,
989 #endif /* CONFIG_HS20 */
991 return WLAN_STATUS_SUCCESS;
995 static void send_deauth(struct hostapd_data *hapd, const u8 *addr,
999 struct ieee80211_mgmt reply;
1001 os_memset(&reply, 0, sizeof(reply));
1002 reply.frame_control =
1003 IEEE80211_FC(WLAN_FC_TYPE_MGMT, WLAN_FC_STYPE_DEAUTH);
1004 os_memcpy(reply.da, addr, ETH_ALEN);
1005 os_memcpy(reply.sa, hapd->own_addr, ETH_ALEN);
1006 os_memcpy(reply.bssid, hapd->own_addr, ETH_ALEN);
1008 send_len = IEEE80211_HDRLEN + sizeof(reply.u.deauth);
1009 reply.u.deauth.reason_code = host_to_le16(reason_code);
1011 if (hostapd_drv_send_mlme(hapd, &reply, send_len, 0) < 0)
1012 wpa_printf(MSG_INFO, "Failed to send deauth: %s",
1017 static void send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta,
1018 u16 status_code, int reassoc, const u8 *ies,
1022 u8 buf[sizeof(struct ieee80211_mgmt) + 1024];
1023 struct ieee80211_mgmt *reply;
1026 os_memset(buf, 0, sizeof(buf));
1027 reply = (struct ieee80211_mgmt *) buf;
1028 reply->frame_control =
1029 IEEE80211_FC(WLAN_FC_TYPE_MGMT,
1030 (reassoc ? WLAN_FC_STYPE_REASSOC_RESP :
1031 WLAN_FC_STYPE_ASSOC_RESP));
1032 os_memcpy(reply->da, sta->addr, ETH_ALEN);
1033 os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
1034 os_memcpy(reply->bssid, hapd->own_addr, ETH_ALEN);
1036 send_len = IEEE80211_HDRLEN;
1037 send_len += sizeof(reply->u.assoc_resp);
1038 reply->u.assoc_resp.capab_info =
1039 host_to_le16(hostapd_own_capab_info(hapd, sta, 0));
1040 reply->u.assoc_resp.status_code = host_to_le16(status_code);
1041 reply->u.assoc_resp.aid = host_to_le16((sta ? sta->aid : 0)
1042 | BIT(14) | BIT(15));
1043 /* Supported rates */
1044 p = hostapd_eid_supp_rates(hapd, reply->u.assoc_resp.variable);
1045 /* Extended supported rates */
1046 p = hostapd_eid_ext_supp_rates(hapd, p);
1048 #ifdef CONFIG_IEEE80211R
1049 if (status_code == WLAN_STATUS_SUCCESS) {
1050 /* IEEE 802.11r: Mobility Domain Information, Fast BSS
1051 * Transition Information, RSN, [RIC Response] */
1052 p = wpa_sm_write_assoc_resp_ies(sta->wpa_sm, p,
1053 buf + sizeof(buf) - p,
1054 sta->auth_alg, ies, ies_len);
1056 #endif /* CONFIG_IEEE80211R */
1058 #ifdef CONFIG_IEEE80211W
1059 if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY)
1060 p = hostapd_eid_assoc_comeback_time(hapd, sta, p);
1061 #endif /* CONFIG_IEEE80211W */
1063 #ifdef CONFIG_IEEE80211N
1064 p = hostapd_eid_ht_capabilities(hapd, p);
1065 p = hostapd_eid_ht_operation(hapd, p);
1066 #endif /* CONFIG_IEEE80211N */
1068 #ifdef CONFIG_IEEE80211AC
1069 p = hostapd_eid_vht_capabilities(hapd, p);
1070 p = hostapd_eid_vht_operation(hapd, p);
1071 #endif /* CONFIG_IEEE80211AC */
1073 p = hostapd_eid_ext_capab(hapd, p);
1074 p = hostapd_eid_bss_max_idle_period(hapd, p);
1076 if (sta->flags & WLAN_STA_WMM)
1077 p = hostapd_eid_wmm(hapd, p);
1080 if ((sta->flags & WLAN_STA_WPS) ||
1081 ((sta->flags & WLAN_STA_MAYBE_WPS) && hapd->conf->wpa)) {
1082 struct wpabuf *wps = wps_build_assoc_resp_ie();
1084 os_memcpy(p, wpabuf_head(wps), wpabuf_len(wps));
1085 p += wpabuf_len(wps);
1089 #endif /* CONFIG_WPS */
1093 struct wpabuf *p2p_resp_ie;
1094 enum p2p_status_code status;
1095 switch (status_code) {
1096 case WLAN_STATUS_SUCCESS:
1097 status = P2P_SC_SUCCESS;
1099 case WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA:
1100 status = P2P_SC_FAIL_LIMIT_REACHED;
1103 status = P2P_SC_FAIL_INVALID_PARAMS;
1106 p2p_resp_ie = p2p_group_assoc_resp_ie(hapd->p2p_group, status);
1108 os_memcpy(p, wpabuf_head(p2p_resp_ie),
1109 wpabuf_len(p2p_resp_ie));
1110 p += wpabuf_len(p2p_resp_ie);
1111 wpabuf_free(p2p_resp_ie);
1114 #endif /* CONFIG_P2P */
1116 #ifdef CONFIG_P2P_MANAGER
1117 if (hapd->conf->p2p & P2P_MANAGE)
1118 p = hostapd_eid_p2p_manage(hapd, p);
1119 #endif /* CONFIG_P2P_MANAGER */
1121 send_len += p - reply->u.assoc_resp.variable;
1123 if (hostapd_drv_send_mlme(hapd, reply, send_len, 0) < 0)
1124 wpa_printf(MSG_INFO, "Failed to send assoc resp: %s",
1129 static void handle_assoc(struct hostapd_data *hapd,
1130 const struct ieee80211_mgmt *mgmt, size_t len,
1133 u16 capab_info, listen_interval;
1134 u16 resp = WLAN_STATUS_SUCCESS;
1137 struct sta_info *sta;
1139 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
1140 sizeof(mgmt->u.assoc_req))) {
1141 printf("handle_assoc(reassoc=%d) - too short payload (len=%lu)"
1142 "\n", reassoc, (unsigned long) len);
1147 capab_info = le_to_host16(mgmt->u.reassoc_req.capab_info);
1148 listen_interval = le_to_host16(
1149 mgmt->u.reassoc_req.listen_interval);
1150 wpa_printf(MSG_DEBUG, "reassociation request: STA=" MACSTR
1151 " capab_info=0x%02x listen_interval=%d current_ap="
1153 MAC2STR(mgmt->sa), capab_info, listen_interval,
1154 MAC2STR(mgmt->u.reassoc_req.current_ap));
1155 left = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.reassoc_req));
1156 pos = mgmt->u.reassoc_req.variable;
1158 capab_info = le_to_host16(mgmt->u.assoc_req.capab_info);
1159 listen_interval = le_to_host16(
1160 mgmt->u.assoc_req.listen_interval);
1161 wpa_printf(MSG_DEBUG, "association request: STA=" MACSTR
1162 " capab_info=0x%02x listen_interval=%d",
1163 MAC2STR(mgmt->sa), capab_info, listen_interval);
1164 left = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.assoc_req));
1165 pos = mgmt->u.assoc_req.variable;
1168 sta = ap_get_sta(hapd, mgmt->sa);
1169 #ifdef CONFIG_IEEE80211R
1170 if (sta && sta->auth_alg == WLAN_AUTH_FT &&
1171 (sta->flags & WLAN_STA_AUTH) == 0) {
1172 wpa_printf(MSG_DEBUG, "FT: Allow STA " MACSTR " to associate "
1173 "prior to authentication since it is using "
1174 "over-the-DS FT", MAC2STR(mgmt->sa));
1176 #endif /* CONFIG_IEEE80211R */
1177 if (sta == NULL || (sta->flags & WLAN_STA_AUTH) == 0) {
1178 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1179 HOSTAPD_LEVEL_INFO, "Station tried to "
1180 "associate before authentication "
1181 "(aid=%d flags=0x%x)",
1182 sta ? sta->aid : -1,
1183 sta ? sta->flags : 0);
1184 send_deauth(hapd, mgmt->sa,
1185 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA);
1189 if (hapd->tkip_countermeasures) {
1190 resp = WLAN_REASON_MICHAEL_MIC_FAILURE;
1194 if (listen_interval > hapd->conf->max_listen_interval) {
1195 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1196 HOSTAPD_LEVEL_DEBUG,
1197 "Too large Listen Interval (%d)",
1199 resp = WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE;
1203 /* followed by SSID and Supported rates; and HT capabilities if 802.11n
1205 resp = check_assoc_ies(hapd, sta, pos, left, reassoc);
1206 if (resp != WLAN_STATUS_SUCCESS)
1209 if (hostapd_get_aid(hapd, sta) < 0) {
1210 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1211 HOSTAPD_LEVEL_INFO, "No room for more AIDs");
1212 resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
1216 sta->capability = capab_info;
1217 sta->listen_interval = listen_interval;
1219 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
1220 sta->flags |= WLAN_STA_NONERP;
1221 for (i = 0; i < sta->supported_rates_len; i++) {
1222 if ((sta->supported_rates[i] & 0x7f) > 22) {
1223 sta->flags &= ~WLAN_STA_NONERP;
1227 if (sta->flags & WLAN_STA_NONERP && !sta->nonerp_set) {
1228 sta->nonerp_set = 1;
1229 hapd->iface->num_sta_non_erp++;
1230 if (hapd->iface->num_sta_non_erp == 1)
1231 ieee802_11_set_beacons(hapd->iface);
1234 if (!(sta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) &&
1235 !sta->no_short_slot_time_set) {
1236 sta->no_short_slot_time_set = 1;
1237 hapd->iface->num_sta_no_short_slot_time++;
1238 if (hapd->iface->current_mode->mode ==
1239 HOSTAPD_MODE_IEEE80211G &&
1240 hapd->iface->num_sta_no_short_slot_time == 1)
1241 ieee802_11_set_beacons(hapd->iface);
1244 if (sta->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
1245 sta->flags |= WLAN_STA_SHORT_PREAMBLE;
1247 sta->flags &= ~WLAN_STA_SHORT_PREAMBLE;
1249 if (!(sta->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) &&
1250 !sta->no_short_preamble_set) {
1251 sta->no_short_preamble_set = 1;
1252 hapd->iface->num_sta_no_short_preamble++;
1253 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
1254 && hapd->iface->num_sta_no_short_preamble == 1)
1255 ieee802_11_set_beacons(hapd->iface);
1258 #ifdef CONFIG_IEEE80211N
1259 update_ht_state(hapd, sta);
1260 #endif /* CONFIG_IEEE80211N */
1262 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1263 HOSTAPD_LEVEL_DEBUG,
1264 "association OK (aid %d)", sta->aid);
1265 /* Station will be marked associated, after it acknowledges AssocResp
1267 sta->flags |= WLAN_STA_ASSOC_REQ_OK;
1269 #ifdef CONFIG_IEEE80211W
1270 if ((sta->flags & WLAN_STA_MFP) && sta->sa_query_timed_out) {
1271 wpa_printf(MSG_DEBUG, "Allowing %sassociation after timed out "
1272 "SA Query procedure", reassoc ? "re" : "");
1273 /* TODO: Send a protected Disassociate frame to the STA using
1274 * the old key and Reason Code "Previous Authentication no
1275 * longer valid". Make sure this is only sent protected since
1276 * unprotected frame would be received by the STA that is now
1277 * trying to associate.
1280 #endif /* CONFIG_IEEE80211W */
1283 os_memcpy(sta->previous_ap, mgmt->u.reassoc_req.current_ap,
1287 if (sta->last_assoc_req)
1288 os_free(sta->last_assoc_req);
1289 sta->last_assoc_req = os_malloc(len);
1290 if (sta->last_assoc_req)
1291 os_memcpy(sta->last_assoc_req, mgmt, len);
1293 /* Make sure that the previously registered inactivity timer will not
1294 * remove the STA immediately. */
1295 sta->timeout_next = STA_NULLFUNC;
1298 send_assoc_resp(hapd, sta, resp, reassoc, pos, left);
1302 static void handle_disassoc(struct hostapd_data *hapd,
1303 const struct ieee80211_mgmt *mgmt, size_t len)
1305 struct sta_info *sta;
1307 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.disassoc)) {
1308 printf("handle_disassoc - too short payload (len=%lu)\n",
1309 (unsigned long) len);
1313 wpa_printf(MSG_DEBUG, "disassocation: STA=" MACSTR " reason_code=%d",
1315 le_to_host16(mgmt->u.disassoc.reason_code));
1317 sta = ap_get_sta(hapd, mgmt->sa);
1319 printf("Station " MACSTR " trying to disassociate, but it "
1320 "is not associated.\n", MAC2STR(mgmt->sa));
1324 ap_sta_set_authorized(hapd, sta, 0);
1325 sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
1326 wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
1327 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1328 HOSTAPD_LEVEL_INFO, "disassociated");
1329 sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
1330 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
1331 /* Stop Accounting and IEEE 802.1X sessions, but leave the STA
1333 accounting_sta_stop(hapd, sta);
1334 ieee802_1x_free_station(sta);
1335 hostapd_drv_sta_remove(hapd, sta->addr);
1337 if (sta->timeout_next == STA_NULLFUNC ||
1338 sta->timeout_next == STA_DISASSOC) {
1339 sta->timeout_next = STA_DEAUTH;
1340 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
1341 eloop_register_timeout(AP_DEAUTH_DELAY, 0, ap_handle_timer,
1345 mlme_disassociate_indication(
1346 hapd, sta, le_to_host16(mgmt->u.disassoc.reason_code));
1350 static void handle_deauth(struct hostapd_data *hapd,
1351 const struct ieee80211_mgmt *mgmt, size_t len)
1353 struct sta_info *sta;
1355 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.deauth)) {
1356 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "handle_deauth - too short "
1357 "payload (len=%lu)", (unsigned long) len);
1361 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "deauthentication: STA=" MACSTR
1363 MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
1365 sta = ap_get_sta(hapd, mgmt->sa);
1367 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR " trying "
1368 "to deauthenticate, but it is not authenticated",
1373 ap_sta_set_authorized(hapd, sta, 0);
1374 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
1375 WLAN_STA_ASSOC_REQ_OK);
1376 wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
1377 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1378 HOSTAPD_LEVEL_DEBUG, "deauthenticated");
1379 mlme_deauthenticate_indication(
1380 hapd, sta, le_to_host16(mgmt->u.deauth.reason_code));
1381 sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
1382 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
1383 ap_free_sta(hapd, sta);
1387 static void handle_beacon(struct hostapd_data *hapd,
1388 const struct ieee80211_mgmt *mgmt, size_t len,
1389 struct hostapd_frame_info *fi)
1391 struct ieee802_11_elems elems;
1393 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.beacon)) {
1394 printf("handle_beacon - too short payload (len=%lu)\n",
1395 (unsigned long) len);
1399 (void) ieee802_11_parse_elems(mgmt->u.beacon.variable,
1400 len - (IEEE80211_HDRLEN +
1401 sizeof(mgmt->u.beacon)), &elems,
1404 ap_list_process_beacon(hapd->iface, mgmt, &elems, fi);
1408 #ifdef CONFIG_IEEE80211W
1410 static void hostapd_sa_query_action(struct hostapd_data *hapd,
1411 const struct ieee80211_mgmt *mgmt,
1416 end = mgmt->u.action.u.sa_query_resp.trans_id +
1417 WLAN_SA_QUERY_TR_ID_LEN;
1418 if (((u8 *) mgmt) + len < end) {
1419 wpa_printf(MSG_DEBUG, "IEEE 802.11: Too short SA Query Action "
1420 "frame (len=%lu)", (unsigned long) len);
1424 ieee802_11_sa_query_action(hapd, mgmt->sa,
1425 mgmt->u.action.u.sa_query_resp.action,
1426 mgmt->u.action.u.sa_query_resp.trans_id);
1430 static int robust_action_frame(u8 category)
1432 return category != WLAN_ACTION_PUBLIC &&
1433 category != WLAN_ACTION_HT;
1435 #endif /* CONFIG_IEEE80211W */
1439 static void hostapd_wnm_action(struct hostapd_data *hapd, struct sta_info *sta,
1440 const struct ieee80211_mgmt *mgmt,
1443 struct rx_action action;
1444 if (len < IEEE80211_HDRLEN + 2)
1446 os_memset(&action, 0, sizeof(action));
1447 action.da = mgmt->da;
1448 action.sa = mgmt->sa;
1449 action.bssid = mgmt->bssid;
1450 action.category = mgmt->u.action.category;
1451 action.data = (const u8 *) &mgmt->u.action.u.wnm_sleep_req.action;
1452 action.len = len - IEEE80211_HDRLEN - 1;
1453 action.freq = hapd->iface->freq;
1454 ieee802_11_rx_wnm_action_ap(hapd, &action);
1456 #endif /* CONFIG_WNM */
1459 static void handle_action(struct hostapd_data *hapd,
1460 const struct ieee80211_mgmt *mgmt, size_t len)
1462 struct sta_info *sta;
1463 sta = ap_get_sta(hapd, mgmt->sa);
1465 if (len < IEEE80211_HDRLEN + 1) {
1466 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1467 HOSTAPD_LEVEL_DEBUG,
1468 "handle_action - too short payload (len=%lu)",
1469 (unsigned long) len);
1473 if (mgmt->u.action.category != WLAN_ACTION_PUBLIC &&
1474 (sta == NULL || !(sta->flags & WLAN_STA_ASSOC))) {
1475 wpa_printf(MSG_DEBUG, "IEEE 802.11: Ignored Action "
1476 "frame (category=%u) from unassociated STA " MACSTR,
1477 MAC2STR(mgmt->sa), mgmt->u.action.category);
1481 #ifdef CONFIG_IEEE80211W
1482 if (sta && (sta->flags & WLAN_STA_MFP) &&
1483 !(mgmt->frame_control & host_to_le16(WLAN_FC_ISWEP) &&
1484 robust_action_frame(mgmt->u.action.category))) {
1485 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1486 HOSTAPD_LEVEL_DEBUG,
1487 "Dropped unprotected Robust Action frame from "
1491 #endif /* CONFIG_IEEE80211W */
1493 switch (mgmt->u.action.category) {
1494 #ifdef CONFIG_IEEE80211R
1495 case WLAN_ACTION_FT:
1496 if (wpa_ft_action_rx(sta->wpa_sm, (u8 *) &mgmt->u.action,
1497 len - IEEE80211_HDRLEN))
1500 #endif /* CONFIG_IEEE80211R */
1501 case WLAN_ACTION_WMM:
1502 hostapd_wmm_action(hapd, mgmt, len);
1504 #ifdef CONFIG_IEEE80211W
1505 case WLAN_ACTION_SA_QUERY:
1506 hostapd_sa_query_action(hapd, mgmt, len);
1508 #endif /* CONFIG_IEEE80211W */
1510 case WLAN_ACTION_WNM:
1511 hostapd_wnm_action(hapd, sta, mgmt, len);
1513 #endif /* CONFIG_WNM */
1514 case WLAN_ACTION_PUBLIC:
1515 if (hapd->public_action_cb) {
1516 hapd->public_action_cb(hapd->public_action_cb_ctx,
1522 case WLAN_ACTION_VENDOR_SPECIFIC:
1523 if (hapd->vendor_action_cb) {
1524 if (hapd->vendor_action_cb(hapd->vendor_action_cb_ctx,
1526 hapd->iface->freq) == 0)
1532 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1533 HOSTAPD_LEVEL_DEBUG,
1534 "handle_action - unknown action category %d or invalid "
1536 mgmt->u.action.category);
1537 if (!(mgmt->da[0] & 0x01) && !(mgmt->u.action.category & 0x80) &&
1538 !(mgmt->sa[0] & 0x01)) {
1539 struct ieee80211_mgmt *resp;
1542 * IEEE 802.11-REVma/D9.0 - 7.3.1.11
1543 * Return the Action frame to the source without change
1544 * except that MSB of the Category set to 1.
1546 wpa_printf(MSG_DEBUG, "IEEE 802.11: Return unknown Action "
1547 "frame back to sender");
1548 resp = os_malloc(len);
1551 os_memcpy(resp, mgmt, len);
1552 os_memcpy(resp->da, resp->sa, ETH_ALEN);
1553 os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
1554 os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
1555 resp->u.action.category |= 0x80;
1557 if (hostapd_drv_send_mlme(hapd, resp, len, 0) < 0) {
1558 wpa_printf(MSG_ERROR, "IEEE 802.11: Failed to send "
1567 * ieee802_11_mgmt - process incoming IEEE 802.11 management frames
1568 * @hapd: hostapd BSS data structure (the BSS to which the management frame was
1570 * @buf: management frame data (starting from IEEE 802.11 header)
1571 * @len: length of frame data in octets
1572 * @fi: meta data about received frame (signal level, etc.)
1574 * Process all incoming IEEE 802.11 management frames. This will be called for
1575 * each frame received from the kernel driver through wlan#ap interface. In
1576 * addition, it can be called to re-inserted pending frames (e.g., when using
1577 * external RADIUS server as an MAC ACL).
1579 void ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
1580 struct hostapd_frame_info *fi)
1582 struct ieee80211_mgmt *mgmt;
1589 mgmt = (struct ieee80211_mgmt *) buf;
1590 fc = le_to_host16(mgmt->frame_control);
1591 stype = WLAN_FC_GET_STYPE(fc);
1593 if (stype == WLAN_FC_STYPE_BEACON) {
1594 handle_beacon(hapd, mgmt, len, fi);
1598 broadcast = mgmt->bssid[0] == 0xff && mgmt->bssid[1] == 0xff &&
1599 mgmt->bssid[2] == 0xff && mgmt->bssid[3] == 0xff &&
1600 mgmt->bssid[4] == 0xff && mgmt->bssid[5] == 0xff;
1604 /* Invitation responses can be sent with the peer MAC as BSSID */
1605 !((hapd->conf->p2p & P2P_GROUP_OWNER) &&
1606 stype == WLAN_FC_STYPE_ACTION) &&
1607 #endif /* CONFIG_P2P */
1608 os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0) {
1609 printf("MGMT: BSSID=" MACSTR " not our address\n",
1610 MAC2STR(mgmt->bssid));
1615 if (stype == WLAN_FC_STYPE_PROBE_REQ) {
1616 handle_probe_req(hapd, mgmt, len, fi->ssi_signal);
1620 if (os_memcmp(mgmt->da, hapd->own_addr, ETH_ALEN) != 0) {
1621 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1622 HOSTAPD_LEVEL_DEBUG,
1623 "MGMT: DA=" MACSTR " not our address",
1629 case WLAN_FC_STYPE_AUTH:
1630 wpa_printf(MSG_DEBUG, "mgmt::auth");
1631 handle_auth(hapd, mgmt, len);
1633 case WLAN_FC_STYPE_ASSOC_REQ:
1634 wpa_printf(MSG_DEBUG, "mgmt::assoc_req");
1635 handle_assoc(hapd, mgmt, len, 0);
1637 case WLAN_FC_STYPE_REASSOC_REQ:
1638 wpa_printf(MSG_DEBUG, "mgmt::reassoc_req");
1639 handle_assoc(hapd, mgmt, len, 1);
1641 case WLAN_FC_STYPE_DISASSOC:
1642 wpa_printf(MSG_DEBUG, "mgmt::disassoc");
1643 handle_disassoc(hapd, mgmt, len);
1645 case WLAN_FC_STYPE_DEAUTH:
1646 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "mgmt::deauth");
1647 handle_deauth(hapd, mgmt, len);
1649 case WLAN_FC_STYPE_ACTION:
1650 wpa_printf(MSG_DEBUG, "mgmt::action");
1651 handle_action(hapd, mgmt, len);
1654 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1655 HOSTAPD_LEVEL_DEBUG,
1656 "unknown mgmt frame subtype %d", stype);
1662 static void handle_auth_cb(struct hostapd_data *hapd,
1663 const struct ieee80211_mgmt *mgmt,
1666 u16 auth_alg, auth_transaction, status_code;
1667 struct sta_info *sta;
1670 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
1671 HOSTAPD_LEVEL_NOTICE,
1672 "did not acknowledge authentication response");
1676 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
1677 printf("handle_auth_cb - too short payload (len=%lu)\n",
1678 (unsigned long) len);
1682 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
1683 auth_transaction = le_to_host16(mgmt->u.auth.auth_transaction);
1684 status_code = le_to_host16(mgmt->u.auth.status_code);
1686 sta = ap_get_sta(hapd, mgmt->da);
1688 printf("handle_auth_cb: STA " MACSTR " not found\n",
1693 if (status_code == WLAN_STATUS_SUCCESS &&
1694 ((auth_alg == WLAN_AUTH_OPEN && auth_transaction == 2) ||
1695 (auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 4))) {
1696 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1697 HOSTAPD_LEVEL_INFO, "authenticated");
1698 sta->flags |= WLAN_STA_AUTH;
1703 static void handle_assoc_cb(struct hostapd_data *hapd,
1704 const struct ieee80211_mgmt *mgmt,
1705 size_t len, int reassoc, int ok)
1708 struct sta_info *sta;
1710 struct ieee80211_ht_capabilities ht_cap;
1712 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_resp) :
1713 sizeof(mgmt->u.assoc_resp))) {
1714 printf("handle_assoc_cb(reassoc=%d) - too short payload "
1715 "(len=%lu)\n", reassoc, (unsigned long) len);
1719 sta = ap_get_sta(hapd, mgmt->da);
1721 printf("handle_assoc_cb: STA " MACSTR " not found\n",
1727 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
1728 HOSTAPD_LEVEL_DEBUG,
1729 "did not acknowledge association response");
1730 sta->flags &= ~WLAN_STA_ASSOC_REQ_OK;
1735 status = le_to_host16(mgmt->u.reassoc_resp.status_code);
1737 status = le_to_host16(mgmt->u.assoc_resp.status_code);
1739 if (status != WLAN_STATUS_SUCCESS)
1742 /* Stop previous accounting session, if one is started, and allocate
1743 * new session id for the new session. */
1744 accounting_sta_stop(hapd, sta);
1746 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1748 "associated (aid %d)",
1751 if (sta->flags & WLAN_STA_ASSOC)
1753 sta->flags |= WLAN_STA_ASSOC;
1754 if ((!hapd->conf->ieee802_1x && !hapd->conf->wpa) ||
1755 sta->auth_alg == WLAN_AUTH_FT) {
1757 * Open, static WEP, or FT protocol; no separate authorization
1760 ap_sta_set_authorized(hapd, sta, 1);
1764 mlme_reassociate_indication(hapd, sta);
1766 mlme_associate_indication(hapd, sta);
1768 #ifdef CONFIG_IEEE80211W
1769 sta->sa_query_timed_out = 0;
1770 #endif /* CONFIG_IEEE80211W */
1773 * Remove the STA entry in order to make sure the STA PS state gets
1774 * cleared and configuration gets updated in case of reassociation back
1777 hostapd_drv_sta_remove(hapd, sta->addr);
1779 #ifdef CONFIG_IEEE80211N
1780 if (sta->flags & WLAN_STA_HT)
1781 hostapd_get_ht_capab(hapd, sta->ht_capabilities, &ht_cap);
1782 #endif /* CONFIG_IEEE80211N */
1784 if (hostapd_sta_add(hapd, sta->addr, sta->aid, sta->capability,
1785 sta->supported_rates, sta->supported_rates_len,
1786 sta->listen_interval,
1787 sta->flags & WLAN_STA_HT ? &ht_cap : NULL,
1788 sta->flags, sta->qosinfo)) {
1789 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1790 HOSTAPD_LEVEL_NOTICE,
1791 "Could not add STA to kernel driver");
1793 ap_sta_disconnect(hapd, sta, sta->addr,
1794 WLAN_REASON_DISASSOC_AP_BUSY);
1799 if (sta->flags & WLAN_STA_WDS)
1800 hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 1);
1802 if (sta->eapol_sm == NULL) {
1804 * This STA does not use RADIUS server for EAP authentication,
1805 * so bind it to the selected VLAN interface now, since the
1806 * interface selection is not going to change anymore.
1808 if (ap_sta_bind_vlan(hapd, sta, 0) < 0)
1810 } else if (sta->vlan_id) {
1811 /* VLAN ID already set (e.g., by PMKSA caching), so bind STA */
1812 if (ap_sta_bind_vlan(hapd, sta, 0) < 0)
1816 hostapd_set_sta_flags(hapd, sta);
1818 if (sta->auth_alg == WLAN_AUTH_FT)
1819 wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FT);
1821 wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC);
1822 hapd->new_assoc_sta_cb(hapd, sta, !new_assoc);
1824 ieee802_1x_notify_port_enabled(sta->eapol_sm, 1);
1827 /* Copy of the association request is not needed anymore */
1828 if (sta->last_assoc_req) {
1829 os_free(sta->last_assoc_req);
1830 sta->last_assoc_req = NULL;
1835 static void handle_deauth_cb(struct hostapd_data *hapd,
1836 const struct ieee80211_mgmt *mgmt,
1839 struct sta_info *sta;
1840 if (mgmt->da[0] & 0x01)
1842 sta = ap_get_sta(hapd, mgmt->da);
1844 wpa_printf(MSG_DEBUG, "handle_deauth_cb: STA " MACSTR
1845 " not found", MAC2STR(mgmt->da));
1849 wpa_printf(MSG_DEBUG, "STA " MACSTR " acknowledged deauth",
1850 MAC2STR(sta->addr));
1852 wpa_printf(MSG_DEBUG, "STA " MACSTR " did not acknowledge "
1853 "deauth", MAC2STR(sta->addr));
1855 ap_sta_deauth_cb(hapd, sta);
1859 static void handle_disassoc_cb(struct hostapd_data *hapd,
1860 const struct ieee80211_mgmt *mgmt,
1863 struct sta_info *sta;
1864 if (mgmt->da[0] & 0x01)
1866 sta = ap_get_sta(hapd, mgmt->da);
1868 wpa_printf(MSG_DEBUG, "handle_disassoc_cb: STA " MACSTR
1869 " not found", MAC2STR(mgmt->da));
1873 wpa_printf(MSG_DEBUG, "STA " MACSTR " acknowledged disassoc",
1874 MAC2STR(sta->addr));
1876 wpa_printf(MSG_DEBUG, "STA " MACSTR " did not acknowledge "
1877 "disassoc", MAC2STR(sta->addr));
1879 ap_sta_disassoc_cb(hapd, sta);
1884 * ieee802_11_mgmt_cb - Process management frame TX status callback
1885 * @hapd: hostapd BSS data structure (the BSS from which the management frame
1887 * @buf: management frame data (starting from IEEE 802.11 header)
1888 * @len: length of frame data in octets
1889 * @stype: management frame subtype from frame control field
1890 * @ok: Whether the frame was ACK'ed
1892 void ieee802_11_mgmt_cb(struct hostapd_data *hapd, const u8 *buf, size_t len,
1895 const struct ieee80211_mgmt *mgmt;
1896 mgmt = (const struct ieee80211_mgmt *) buf;
1899 case WLAN_FC_STYPE_AUTH:
1900 wpa_printf(MSG_DEBUG, "mgmt::auth cb");
1901 handle_auth_cb(hapd, mgmt, len, ok);
1903 case WLAN_FC_STYPE_ASSOC_RESP:
1904 wpa_printf(MSG_DEBUG, "mgmt::assoc_resp cb");
1905 handle_assoc_cb(hapd, mgmt, len, 0, ok);
1907 case WLAN_FC_STYPE_REASSOC_RESP:
1908 wpa_printf(MSG_DEBUG, "mgmt::reassoc_resp cb");
1909 handle_assoc_cb(hapd, mgmt, len, 1, ok);
1911 case WLAN_FC_STYPE_PROBE_RESP:
1912 wpa_printf(MSG_EXCESSIVE, "mgmt::proberesp cb");
1914 case WLAN_FC_STYPE_DEAUTH:
1915 wpa_printf(MSG_DEBUG, "mgmt::deauth cb");
1916 handle_deauth_cb(hapd, mgmt, len, ok);
1918 case WLAN_FC_STYPE_DISASSOC:
1919 wpa_printf(MSG_DEBUG, "mgmt::disassoc cb");
1920 handle_disassoc_cb(hapd, mgmt, len, ok);
1922 case WLAN_FC_STYPE_ACTION:
1923 wpa_printf(MSG_DEBUG, "mgmt::action cb");
1926 printf("unknown mgmt cb frame subtype %d\n", stype);
1932 int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
1939 int ieee802_11_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
1940 char *buf, size_t buflen)
1947 void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
1948 const u8 *buf, size_t len, int ack)
1950 struct sta_info *sta;
1951 struct hostapd_iface *iface = hapd->iface;
1953 sta = ap_get_sta(hapd, addr);
1954 if (sta == NULL && iface->num_bss > 1) {
1956 for (j = 0; j < iface->num_bss; j++) {
1957 hapd = iface->bss[j];
1958 sta = ap_get_sta(hapd, addr);
1963 if (sta == NULL || !(sta->flags & WLAN_STA_ASSOC))
1965 if (sta->flags & WLAN_STA_PENDING_POLL) {
1966 wpa_printf(MSG_DEBUG, "STA " MACSTR " %s pending "
1967 "activity poll", MAC2STR(sta->addr),
1968 ack ? "ACKed" : "did not ACK");
1970 sta->flags &= ~WLAN_STA_PENDING_POLL;
1973 ieee802_1x_tx_status(hapd, sta, buf, len, ack);
1977 void hostapd_eapol_tx_status(struct hostapd_data *hapd, const u8 *dst,
1978 const u8 *data, size_t len, int ack)
1980 struct sta_info *sta;
1981 struct hostapd_iface *iface = hapd->iface;
1983 sta = ap_get_sta(hapd, dst);
1984 if (sta == NULL && iface->num_bss > 1) {
1986 for (j = 0; j < iface->num_bss; j++) {
1987 hapd = iface->bss[j];
1988 sta = ap_get_sta(hapd, dst);
1993 if (sta == NULL || !(sta->flags & WLAN_STA_ASSOC)) {
1994 wpa_printf(MSG_DEBUG, "Ignore TX status for Data frame to STA "
1995 MACSTR " that is not currently associated",
2000 ieee802_1x_eapol_tx_status(hapd, sta, data, len, ack);
2004 void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr)
2006 struct sta_info *sta;
2007 struct hostapd_iface *iface = hapd->iface;
2009 sta = ap_get_sta(hapd, addr);
2010 if (sta == NULL && iface->num_bss > 1) {
2012 for (j = 0; j < iface->num_bss; j++) {
2013 hapd = iface->bss[j];
2014 sta = ap_get_sta(hapd, addr);
2021 if (!(sta->flags & WLAN_STA_PENDING_POLL))
2024 wpa_printf(MSG_DEBUG, "STA " MACSTR " ACKed pending "
2025 "activity poll", MAC2STR(sta->addr));
2026 sta->flags &= ~WLAN_STA_PENDING_POLL;
2030 void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
2033 struct sta_info *sta;
2035 sta = ap_get_sta(hapd, src);
2036 if (sta && (sta->flags & WLAN_STA_ASSOC)) {
2037 if (!hapd->conf->wds_sta)
2040 if (wds && !(sta->flags & WLAN_STA_WDS)) {
2041 wpa_printf(MSG_DEBUG, "Enable 4-address WDS mode for "
2042 "STA " MACSTR " (aid %u)",
2043 MAC2STR(sta->addr), sta->aid);
2044 sta->flags |= WLAN_STA_WDS;
2045 hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 1);
2050 wpa_printf(MSG_DEBUG, "Data/PS-poll frame from not associated STA "
2051 MACSTR, MAC2STR(src));
2052 if (src[0] & 0x01) {
2053 /* Broadcast bit set in SA?! Ignore the frame silently. */
2057 if (sta && (sta->flags & WLAN_STA_ASSOC_REQ_OK)) {
2058 wpa_printf(MSG_DEBUG, "Association Response to the STA has "
2059 "already been sent, but no TX status yet known - "
2060 "ignore Class 3 frame issue with " MACSTR,
2065 if (sta && (sta->flags & WLAN_STA_AUTH))
2066 hostapd_drv_sta_disassoc(
2068 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
2070 hostapd_drv_sta_deauth(
2072 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
2076 #endif /* CONFIG_NATIVE_WINDOWS */