2 * hostapd / IEEE 802.11 Management
3 * Copyright (c) 2002-2014, 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 "crypto/sha256.h"
17 #include "crypto/random.h"
18 #include "common/ieee802_11_defs.h"
19 #include "common/ieee802_11_common.h"
20 #include "common/wpa_ctrl.h"
21 #include "common/sae.h"
22 #include "radius/radius.h"
23 #include "radius/radius_client.h"
28 #include "ieee802_11_auth.h"
30 #include "ieee802_1x.h"
32 #include "pmksa_cache_auth.h"
35 #include "accounting.h"
36 #include "ap_config.h"
38 #include "p2p_hostapd.h"
39 #include "ap_drv_ops.h"
41 #include "ieee802_11.h"
45 u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid)
50 if (hapd->iface->current_rates == NULL)
53 *pos++ = WLAN_EID_SUPP_RATES;
54 num = hapd->iface->num_rates;
55 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht)
57 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht)
60 /* rest of the rates are encoded in Extended supported
66 for (i = 0, count = 0; i < hapd->iface->num_rates && count < num;
69 *pos = hapd->iface->current_rates[i].rate / 5;
70 if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC)
75 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht && count < 8) {
77 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_HT_PHY;
80 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht && count < 8) {
82 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_VHT_PHY;
89 u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid)
94 if (hapd->iface->current_rates == NULL)
97 num = hapd->iface->num_rates;
98 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht)
100 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht)
106 *pos++ = WLAN_EID_EXT_SUPP_RATES;
108 for (i = 0, count = 0; i < hapd->iface->num_rates && count < num + 8;
112 continue; /* already in SuppRates IE */
113 *pos = hapd->iface->current_rates[i].rate / 5;
114 if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC)
119 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht) {
122 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_HT_PHY;
125 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht) {
128 *pos++ = 0x80 | BSS_MEMBERSHIP_SELECTOR_VHT_PHY;
135 u16 hostapd_own_capab_info(struct hostapd_data *hapd)
137 int capab = WLAN_CAPABILITY_ESS;
141 /* Check if any of configured channels require DFS */
142 dfs = hostapd_is_dfs_required(hapd->iface);
144 wpa_printf(MSG_WARNING, "Failed to check if DFS is required; ret=%d",
149 if (hapd->iface->num_sta_no_short_preamble == 0 &&
150 hapd->iconf->preamble == SHORT_PREAMBLE)
151 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
153 privacy = hapd->conf->ssid.wep.keys_set;
155 if (hapd->conf->ieee802_1x &&
156 (hapd->conf->default_wep_key_len ||
157 hapd->conf->individual_wep_key_len))
164 if (hapd->conf->osen)
166 #endif /* CONFIG_HS20 */
169 capab |= WLAN_CAPABILITY_PRIVACY;
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;
177 * Currently, Spectrum Management capability bit is set when directly
178 * requested in configuration by spectrum_mgmt_required or when AP is
179 * running on DFS channel.
180 * TODO: Also consider driver support for TPC to set Spectrum Mgmt bit
182 if (hapd->iface->current_mode &&
183 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A &&
184 (hapd->iconf->spectrum_mgmt_required || dfs))
185 capab |= WLAN_CAPABILITY_SPECTRUM_MGMT;
187 if (hapd->conf->radio_measurements)
188 capab |= IEEE80211_CAP_RRM;
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_const(sta->challenge, challenge,
229 WLAN_AUTH_CHALLENGE_LEN)) {
230 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
232 "shared key authentication - invalid "
233 "challenge-response");
234 return WLAN_STATUS_CHALLENGE_FAIL;
237 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
239 "authentication OK (shared key)");
240 sta->flags |= WLAN_STA_AUTH;
241 wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
242 os_free(sta->challenge);
243 sta->challenge = NULL;
249 static void send_auth_reply(struct hostapd_data *hapd,
250 const u8 *dst, const u8 *bssid,
251 u16 auth_alg, u16 auth_transaction, u16 resp,
252 const u8 *ies, size_t ies_len)
254 struct ieee80211_mgmt *reply;
258 rlen = IEEE80211_HDRLEN + sizeof(reply->u.auth) + ies_len;
259 buf = os_zalloc(rlen);
263 reply = (struct ieee80211_mgmt *) buf;
264 reply->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
266 os_memcpy(reply->da, dst, ETH_ALEN);
267 os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
268 os_memcpy(reply->bssid, bssid, ETH_ALEN);
270 reply->u.auth.auth_alg = host_to_le16(auth_alg);
271 reply->u.auth.auth_transaction = host_to_le16(auth_transaction);
272 reply->u.auth.status_code = host_to_le16(resp);
275 os_memcpy(reply->u.auth.variable, ies, ies_len);
277 wpa_printf(MSG_DEBUG, "authentication reply: STA=" MACSTR
278 " auth_alg=%d auth_transaction=%d resp=%d (IE len=%lu)",
279 MAC2STR(dst), auth_alg, auth_transaction,
280 resp, (unsigned long) ies_len);
281 if (hostapd_drv_send_mlme(hapd, reply, rlen, 0) < 0)
282 wpa_printf(MSG_INFO, "send_auth_reply: send");
288 #ifdef CONFIG_IEEE80211R
289 static void handle_auth_ft_finish(void *ctx, const u8 *dst, const u8 *bssid,
290 u16 auth_transaction, u16 status,
291 const u8 *ies, size_t ies_len)
293 struct hostapd_data *hapd = ctx;
294 struct sta_info *sta;
296 send_auth_reply(hapd, dst, bssid, WLAN_AUTH_FT, auth_transaction,
297 status, ies, ies_len);
299 if (status != WLAN_STATUS_SUCCESS)
302 sta = ap_get_sta(hapd, dst);
306 hostapd_logger(hapd, dst, HOSTAPD_MODULE_IEEE80211,
307 HOSTAPD_LEVEL_DEBUG, "authentication OK (FT)");
308 sta->flags |= WLAN_STA_AUTH;
309 mlme_authenticate_indication(hapd, sta);
311 #endif /* CONFIG_IEEE80211R */
316 #define dot11RSNASAERetransPeriod 40 /* msec */
317 #define dot11RSNASAESync 5 /* attempts */
320 static struct wpabuf * auth_build_sae_commit(struct hostapd_data *hapd,
321 struct sta_info *sta, int update)
325 if (hapd->conf->ssid.wpa_passphrase == NULL) {
326 wpa_printf(MSG_DEBUG, "SAE: No password available");
331 sae_prepare_commit(hapd->own_addr, sta->addr,
332 (u8 *) hapd->conf->ssid.wpa_passphrase,
333 os_strlen(hapd->conf->ssid.wpa_passphrase),
335 wpa_printf(MSG_DEBUG, "SAE: Could not pick PWE");
339 buf = wpabuf_alloc(SAE_COMMIT_MAX_LEN);
342 sae_write_commit(sta->sae, buf, sta->sae->tmp ?
343 sta->sae->tmp->anti_clogging_token : NULL);
349 static struct wpabuf * auth_build_sae_confirm(struct hostapd_data *hapd,
350 struct sta_info *sta)
354 buf = wpabuf_alloc(SAE_CONFIRM_MAX_LEN);
358 sae_write_confirm(sta->sae, buf);
364 static int auth_sae_send_commit(struct hostapd_data *hapd,
365 struct sta_info *sta,
366 const u8 *bssid, int update)
370 data = auth_build_sae_commit(hapd, sta, update);
372 return WLAN_STATUS_UNSPECIFIED_FAILURE;
374 send_auth_reply(hapd, sta->addr, bssid,
375 WLAN_AUTH_SAE, 1, WLAN_STATUS_SUCCESS,
376 wpabuf_head(data), wpabuf_len(data));
380 return WLAN_STATUS_SUCCESS;
384 static int auth_sae_send_confirm(struct hostapd_data *hapd,
385 struct sta_info *sta,
390 data = auth_build_sae_confirm(hapd, sta);
392 return WLAN_STATUS_UNSPECIFIED_FAILURE;
394 send_auth_reply(hapd, sta->addr, bssid,
395 WLAN_AUTH_SAE, 2, WLAN_STATUS_SUCCESS,
396 wpabuf_head(data), wpabuf_len(data));
400 return WLAN_STATUS_SUCCESS;
404 static int use_sae_anti_clogging(struct hostapd_data *hapd)
406 struct sta_info *sta;
407 unsigned int open = 0;
409 if (hapd->conf->sae_anti_clogging_threshold == 0)
412 for (sta = hapd->sta_list; sta; sta = sta->next) {
415 if (sta->sae->state != SAE_COMMITTED &&
416 sta->sae->state != SAE_CONFIRMED)
419 if (open >= hapd->conf->sae_anti_clogging_threshold)
427 static int check_sae_token(struct hostapd_data *hapd, const u8 *addr,
428 const u8 *token, size_t token_len)
430 u8 mac[SHA256_MAC_LEN];
432 if (token_len != SHA256_MAC_LEN)
434 if (hmac_sha256(hapd->sae_token_key, sizeof(hapd->sae_token_key),
435 addr, ETH_ALEN, mac) < 0 ||
436 os_memcmp_const(token, mac, SHA256_MAC_LEN) != 0)
443 static struct wpabuf * auth_build_token_req(struct hostapd_data *hapd,
444 int group, const u8 *addr)
448 struct os_reltime now;
450 os_get_reltime(&now);
451 if (!os_reltime_initialized(&hapd->last_sae_token_key_update) ||
452 os_reltime_expired(&now, &hapd->last_sae_token_key_update, 60)) {
453 if (random_get_bytes(hapd->sae_token_key,
454 sizeof(hapd->sae_token_key)) < 0)
456 wpa_hexdump(MSG_DEBUG, "SAE: Updated token key",
457 hapd->sae_token_key, sizeof(hapd->sae_token_key));
458 hapd->last_sae_token_key_update = now;
461 buf = wpabuf_alloc(sizeof(le16) + SHA256_MAC_LEN);
465 wpabuf_put_le16(buf, group); /* Finite Cyclic Group */
467 token = wpabuf_put(buf, SHA256_MAC_LEN);
468 hmac_sha256(hapd->sae_token_key, sizeof(hapd->sae_token_key),
469 addr, ETH_ALEN, token);
475 static int sae_check_big_sync(struct sta_info *sta)
477 if (sta->sae->sync > dot11RSNASAESync) {
478 sta->sae->state = SAE_NOTHING;
486 static void auth_sae_retransmit_timer(void *eloop_ctx, void *eloop_data)
488 struct hostapd_data *hapd = eloop_ctx;
489 struct sta_info *sta = eloop_data;
492 if (sae_check_big_sync(sta))
496 switch (sta->sae->state) {
498 ret = auth_sae_send_commit(hapd, sta, hapd->own_addr, 0);
499 eloop_register_timeout(0, dot11RSNASAERetransPeriod * 1000,
500 auth_sae_retransmit_timer, hapd, sta);
503 ret = auth_sae_send_confirm(hapd, sta, hapd->own_addr);
504 eloop_register_timeout(0, dot11RSNASAERetransPeriod * 1000,
505 auth_sae_retransmit_timer, hapd, sta);
512 if (ret != WLAN_STATUS_SUCCESS)
513 wpa_printf(MSG_INFO, "SAE: Failed to retransmit: ret=%d", ret);
517 void sae_clear_retransmit_timer(struct hostapd_data *hapd, struct sta_info *sta)
519 eloop_cancel_timeout(auth_sae_retransmit_timer, hapd, sta);
523 static void sae_set_retransmit_timer(struct hostapd_data *hapd,
524 struct sta_info *sta)
526 if (!(hapd->conf->mesh & MESH_ENABLED))
529 eloop_cancel_timeout(auth_sae_retransmit_timer, hapd, sta);
530 eloop_register_timeout(0, dot11RSNASAERetransPeriod * 1000,
531 auth_sae_retransmit_timer, hapd, sta);
535 static int sae_sm_step(struct hostapd_data *hapd, struct sta_info *sta,
536 const u8 *bssid, u8 auth_transaction)
540 if (auth_transaction != 1 && auth_transaction != 2)
541 return WLAN_STATUS_UNSPECIFIED_FAILURE;
543 switch (sta->sae->state) {
545 if (auth_transaction == 1) {
546 ret = auth_sae_send_commit(hapd, sta, bssid, 1);
549 sta->sae->state = SAE_COMMITTED;
551 if (sae_process_commit(sta->sae) < 0)
552 return WLAN_STATUS_UNSPECIFIED_FAILURE;
555 * In mesh case, both Commit and Confirm can be sent
556 * immediately. In infrastructure BSS, only a single
557 * Authentication frame (Commit) is expected from the AP
558 * here and the second one (Confirm) will be sent once
559 * the STA has sent its second Authentication frame
562 if (hapd->conf->mesh & MESH_ENABLED) {
564 * Send both Commit and Confirm immediately
565 * based on SAE finite state machine
566 * Nothing -> Confirm transition.
568 ret = auth_sae_send_confirm(hapd, sta, bssid);
571 sta->sae->state = SAE_CONFIRMED;
574 * For infrastructure BSS, send only the Commit
575 * message now to get alternating sequence of
576 * Authentication frames between the AP and STA.
577 * Confirm will be sent in
578 * Commited -> Confirmed/Accepted transition
579 * when receiving Confirm from STA.
583 sae_set_retransmit_timer(hapd, sta);
585 hostapd_logger(hapd, sta->addr,
586 HOSTAPD_MODULE_IEEE80211,
588 "SAE confirm before commit");
592 sae_clear_retransmit_timer(hapd, sta);
593 if (auth_transaction == 1) {
594 if (sae_process_commit(sta->sae) < 0)
595 return WLAN_STATUS_UNSPECIFIED_FAILURE;
597 ret = auth_sae_send_confirm(hapd, sta, bssid);
600 sta->sae->state = SAE_CONFIRMED;
602 sae_set_retransmit_timer(hapd, sta);
603 } else if (hapd->conf->mesh & MESH_ENABLED) {
605 * In mesh case, follow SAE finite state machine and
606 * send Commit now, if sync count allows.
608 if (sae_check_big_sync(sta))
609 return WLAN_STATUS_SUCCESS;
612 ret = auth_sae_send_commit(hapd, sta, bssid, 0);
616 sae_set_retransmit_timer(hapd, sta);
619 * For instructure BSS, send the postponed Confirm from
620 * Nothing -> Confirmed transition that was reduced to
621 * Nothing -> Committed above.
623 ret = auth_sae_send_confirm(hapd, sta, bssid);
627 sta->sae->state = SAE_CONFIRMED;
630 * Since this was triggered on Confirm RX, run another
631 * step to get to Accepted without waiting for
634 return sae_sm_step(hapd, sta, bssid, auth_transaction);
638 sae_clear_retransmit_timer(hapd, sta);
639 if (auth_transaction == 1) {
640 if (sae_check_big_sync(sta))
641 return WLAN_STATUS_SUCCESS;
644 ret = auth_sae_send_commit(hapd, sta, bssid, 1);
648 if (sae_process_commit(sta->sae) < 0)
649 return WLAN_STATUS_UNSPECIFIED_FAILURE;
651 ret = auth_sae_send_confirm(hapd, sta, bssid);
655 sae_set_retransmit_timer(hapd, sta);
657 sta->flags |= WLAN_STA_AUTH;
658 sta->auth_alg = WLAN_AUTH_SAE;
659 mlme_authenticate_indication(hapd, sta);
660 wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
661 sta->sae->state = SAE_ACCEPTED;
662 wpa_auth_pmksa_add_sae(hapd->wpa_auth, sta->addr,
667 if (auth_transaction == 1) {
668 wpa_printf(MSG_DEBUG, "SAE: remove the STA (" MACSTR
669 ") doing reauthentication",
671 ap_free_sta(hapd, sta);
673 if (sae_check_big_sync(sta))
674 return WLAN_STATUS_SUCCESS;
677 ret = auth_sae_send_confirm(hapd, sta, bssid);
678 sae_clear_temp_data(sta->sae);
684 wpa_printf(MSG_ERROR, "SAE: invalid state %d",
686 return WLAN_STATUS_UNSPECIFIED_FAILURE;
688 return WLAN_STATUS_SUCCESS;
692 static void handle_auth_sae(struct hostapd_data *hapd, struct sta_info *sta,
693 const struct ieee80211_mgmt *mgmt, size_t len,
694 u16 auth_transaction, u16 status_code)
696 u16 resp = WLAN_STATUS_SUCCESS;
697 struct wpabuf *data = NULL;
700 if (auth_transaction != 1 || status_code != WLAN_STATUS_SUCCESS)
702 sta->sae = os_zalloc(sizeof(*sta->sae));
703 if (sta->sae == NULL)
705 sta->sae->state = SAE_NOTHING;
709 if (auth_transaction == 1) {
710 const u8 *token = NULL, *pos, *end;
711 size_t token_len = 0;
712 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
714 "start SAE authentication (RX commit, status=%u)",
717 if ((hapd->conf->mesh & MESH_ENABLED) &&
718 status_code == WLAN_STATUS_ANTI_CLOGGING_TOKEN_REQ &&
720 pos = mgmt->u.auth.variable;
721 end = ((const u8 *) mgmt) + len;
722 if (pos + sizeof(le16) > end) {
723 wpa_printf(MSG_ERROR,
724 "SAE: Too short anti-clogging token request");
725 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
728 resp = sae_group_allowed(sta->sae,
729 hapd->conf->sae_groups,
731 if (resp != WLAN_STATUS_SUCCESS) {
732 wpa_printf(MSG_ERROR,
733 "SAE: Invalid group in anti-clogging token request");
738 wpabuf_free(sta->sae->tmp->anti_clogging_token);
739 sta->sae->tmp->anti_clogging_token =
740 wpabuf_alloc_copy(pos, end - pos);
741 if (sta->sae->tmp->anti_clogging_token == NULL) {
742 wpa_printf(MSG_ERROR,
743 "SAE: Failed to alloc for anti-clogging token");
748 * IEEE Std 802.11-2012, 11.3.8.6.4: If the Status code
749 * is 76, a new Commit Message shall be constructed
750 * with the Anti-Clogging Token from the received
751 * Authentication frame, and the commit-scalar and
752 * COMMIT-ELEMENT previously sent.
754 if (auth_sae_send_commit(hapd, sta, mgmt->bssid, 0)) {
755 wpa_printf(MSG_ERROR,
756 "SAE: Failed to send commit message");
759 sta->sae->state = SAE_COMMITTED;
761 sae_set_retransmit_timer(hapd, sta);
765 if (status_code != WLAN_STATUS_SUCCESS)
768 resp = sae_parse_commit(sta->sae, mgmt->u.auth.variable,
769 ((const u8 *) mgmt) + len -
770 mgmt->u.auth.variable, &token,
771 &token_len, hapd->conf->sae_groups);
772 if (resp == SAE_SILENTLY_DISCARD) {
773 wpa_printf(MSG_DEBUG,
774 "SAE: Drop commit message from " MACSTR " due to reflection attack",
778 if (token && check_sae_token(hapd, sta->addr, token, token_len)
780 wpa_printf(MSG_DEBUG, "SAE: Drop commit message with "
781 "incorrect token from " MACSTR,
786 if (resp != WLAN_STATUS_SUCCESS)
789 if (!token && use_sae_anti_clogging(hapd)) {
790 wpa_printf(MSG_DEBUG,
791 "SAE: Request anti-clogging token from "
792 MACSTR, MAC2STR(sta->addr));
793 data = auth_build_token_req(hapd, sta->sae->group,
795 resp = WLAN_STATUS_ANTI_CLOGGING_TOKEN_REQ;
796 if (hapd->conf->mesh & MESH_ENABLED)
797 sta->sae->state = SAE_NOTHING;
801 resp = sae_sm_step(hapd, sta, mgmt->bssid, auth_transaction);
802 } else if (auth_transaction == 2) {
803 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
805 "SAE authentication (RX confirm, status=%u)",
807 if (status_code != WLAN_STATUS_SUCCESS)
809 if (sta->sae->state >= SAE_CONFIRMED ||
810 !(hapd->conf->mesh & MESH_ENABLED)) {
811 if (sae_check_confirm(sta->sae, mgmt->u.auth.variable,
812 ((u8 *) mgmt) + len -
813 mgmt->u.auth.variable) < 0) {
814 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
818 resp = sae_sm_step(hapd, sta, mgmt->bssid, auth_transaction);
820 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
822 "unexpected SAE authentication transaction %u (status=%u)",
823 auth_transaction, status_code);
824 if (status_code != WLAN_STATUS_SUCCESS)
826 resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
830 if (resp != WLAN_STATUS_SUCCESS) {
831 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, WLAN_AUTH_SAE,
832 auth_transaction, resp,
833 data ? wpabuf_head(data) : (u8 *) "",
834 data ? wpabuf_len(data) : 0);
841 * auth_sae_init_committed - Send COMMIT and start SAE in committed state
842 * @hapd: BSS data for the device initiating the authentication
843 * @sta: the peer to which commit authentication frame is sent
845 * This function implements Init event handling (IEEE Std 802.11-2012,
846 * 11.3.8.6.3) in which initial COMMIT message is sent. Prior to calling, the
847 * sta->sae structure should be initialized appropriately via a call to
848 * sae_prepare_commit().
850 int auth_sae_init_committed(struct hostapd_data *hapd, struct sta_info *sta)
854 if (!sta->sae || !sta->sae->tmp)
857 if (sta->sae->state != SAE_NOTHING)
860 ret = auth_sae_send_commit(hapd, sta, hapd->own_addr, 0);
864 sta->sae->state = SAE_COMMITTED;
866 sae_set_retransmit_timer(hapd, sta);
871 #endif /* CONFIG_SAE */
874 static void handle_auth(struct hostapd_data *hapd,
875 const struct ieee80211_mgmt *mgmt, size_t len)
877 u16 auth_alg, auth_transaction, status_code;
878 u16 resp = WLAN_STATUS_SUCCESS;
879 struct sta_info *sta = NULL;
882 const u8 *challenge = NULL;
883 u32 session_timeout, acct_interim_interval;
885 struct hostapd_sta_wpa_psk_short *psk = NULL;
886 u8 resp_ies[2 + WLAN_AUTH_CHALLENGE_LEN];
887 size_t resp_ies_len = 0;
888 char *identity = NULL;
889 char *radius_cui = NULL;
892 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
893 wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)",
894 (unsigned long) len);
898 #ifdef CONFIG_TESTING_OPTIONS
899 if (hapd->iconf->ignore_auth_probability > 0.0 &&
900 drand48() < hapd->iconf->ignore_auth_probability) {
902 "TESTING: ignoring auth frame from " MACSTR,
906 #endif /* CONFIG_TESTING_OPTIONS */
908 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
909 auth_transaction = le_to_host16(mgmt->u.auth.auth_transaction);
910 status_code = le_to_host16(mgmt->u.auth.status_code);
911 fc = le_to_host16(mgmt->frame_control);
912 seq_ctrl = le_to_host16(mgmt->seq_ctrl);
914 if (len >= IEEE80211_HDRLEN + sizeof(mgmt->u.auth) +
915 2 + WLAN_AUTH_CHALLENGE_LEN &&
916 mgmt->u.auth.variable[0] == WLAN_EID_CHALLENGE &&
917 mgmt->u.auth.variable[1] == WLAN_AUTH_CHALLENGE_LEN)
918 challenge = &mgmt->u.auth.variable[2];
920 wpa_printf(MSG_DEBUG, "authentication: STA=" MACSTR " auth_alg=%d "
921 "auth_transaction=%d status_code=%d wep=%d%s "
923 MAC2STR(mgmt->sa), auth_alg, auth_transaction,
924 status_code, !!(fc & WLAN_FC_ISWEP),
925 challenge ? " challenge" : "",
926 seq_ctrl, (fc & WLAN_FC_RETRY) ? " retry" : "");
928 if (hapd->tkip_countermeasures) {
929 resp = WLAN_REASON_MICHAEL_MIC_FAILURE;
933 if (!(((hapd->conf->auth_algs & WPA_AUTH_ALG_OPEN) &&
934 auth_alg == WLAN_AUTH_OPEN) ||
935 #ifdef CONFIG_IEEE80211R
936 (hapd->conf->wpa && wpa_key_mgmt_ft(hapd->conf->wpa_key_mgmt) &&
937 auth_alg == WLAN_AUTH_FT) ||
938 #endif /* CONFIG_IEEE80211R */
940 (hapd->conf->wpa && wpa_key_mgmt_sae(hapd->conf->wpa_key_mgmt) &&
941 auth_alg == WLAN_AUTH_SAE) ||
942 #endif /* CONFIG_SAE */
943 ((hapd->conf->auth_algs & WPA_AUTH_ALG_SHARED) &&
944 auth_alg == WLAN_AUTH_SHARED_KEY))) {
945 wpa_printf(MSG_INFO, "Unsupported authentication algorithm (%d)",
947 resp = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
951 if (!(auth_transaction == 1 || auth_alg == WLAN_AUTH_SAE ||
952 (auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 3))) {
953 wpa_printf(MSG_INFO, "Unknown authentication transaction number (%d)",
955 resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
959 if (os_memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) {
960 wpa_printf(MSG_INFO, "Station " MACSTR " not allowed to authenticate",
962 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
966 res = hostapd_allowed_address(hapd, mgmt->sa, (u8 *) mgmt, len,
968 &acct_interim_interval, &vlan_id,
969 &psk, &identity, &radius_cui);
971 if (res == HOSTAPD_ACL_REJECT) {
972 wpa_printf(MSG_INFO, "Station " MACSTR " not allowed to authenticate",
974 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
977 if (res == HOSTAPD_ACL_PENDING) {
978 wpa_printf(MSG_DEBUG, "Authentication frame from " MACSTR
979 " waiting for an external authentication",
981 /* Authentication code will re-send the authentication frame
982 * after it has received (and cached) information from the
983 * external source. */
987 sta = ap_get_sta(hapd, mgmt->sa);
989 if ((fc & WLAN_FC_RETRY) &&
990 sta->last_seq_ctrl != WLAN_INVALID_MGMT_SEQ &&
991 sta->last_seq_ctrl == seq_ctrl &&
992 sta->last_subtype == WLAN_FC_STYPE_AUTH) {
993 hostapd_logger(hapd, sta->addr,
994 HOSTAPD_MODULE_IEEE80211,
996 "Drop repeated authentication frame seq_ctrl=0x%x",
1002 if (hapd->conf->mesh & MESH_ENABLED) {
1003 /* if the mesh peer is not available, we don't do auth.
1005 wpa_printf(MSG_DEBUG, "Mesh peer " MACSTR
1006 " not yet known - drop Authentiation frame",
1009 * Save a copy of the frame so that it can be processed
1010 * if a new peer entry is added shortly after this.
1012 wpabuf_free(hapd->mesh_pending_auth);
1013 hapd->mesh_pending_auth = wpabuf_alloc_copy(mgmt, len);
1014 os_get_reltime(&hapd->mesh_pending_auth_time);
1017 #endif /* CONFIG_MESH */
1019 sta = ap_sta_add(hapd, mgmt->sa);
1021 resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
1025 sta->last_seq_ctrl = seq_ctrl;
1026 sta->last_subtype = WLAN_FC_STYPE_AUTH;
1029 if (!hostapd_vlan_id_valid(hapd->conf->vlan, vlan_id)) {
1030 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS,
1031 HOSTAPD_LEVEL_INFO, "Invalid VLAN ID "
1032 "%d received from RADIUS server",
1034 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
1037 sta->vlan_id = vlan_id;
1038 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS,
1039 HOSTAPD_LEVEL_INFO, "VLAN ID %d", sta->vlan_id);
1042 hostapd_free_psk_list(sta->psk);
1043 if (hapd->conf->wpa_psk_radius != PSK_RADIUS_IGNORED) {
1050 sta->identity = identity;
1052 sta->radius_cui = radius_cui;
1055 sta->flags &= ~WLAN_STA_PREAUTH;
1056 ieee802_1x_notify_pre_auth(sta->eapol_sm, 0);
1058 if (hapd->conf->acct_interim_interval == 0 && acct_interim_interval)
1059 sta->acct_interim_interval = acct_interim_interval;
1060 if (res == HOSTAPD_ACL_ACCEPT_TIMEOUT)
1061 ap_sta_session_timeout(hapd, sta, session_timeout);
1063 ap_sta_no_session_timeout(hapd, sta);
1066 case WLAN_AUTH_OPEN:
1067 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1068 HOSTAPD_LEVEL_DEBUG,
1069 "authentication OK (open system)");
1070 sta->flags |= WLAN_STA_AUTH;
1071 wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
1072 sta->auth_alg = WLAN_AUTH_OPEN;
1073 mlme_authenticate_indication(hapd, sta);
1075 case WLAN_AUTH_SHARED_KEY:
1076 resp = auth_shared_key(hapd, sta, auth_transaction, challenge,
1077 fc & WLAN_FC_ISWEP);
1078 sta->auth_alg = WLAN_AUTH_SHARED_KEY;
1079 mlme_authenticate_indication(hapd, sta);
1080 if (sta->challenge && auth_transaction == 1) {
1081 resp_ies[0] = WLAN_EID_CHALLENGE;
1082 resp_ies[1] = WLAN_AUTH_CHALLENGE_LEN;
1083 os_memcpy(resp_ies + 2, sta->challenge,
1084 WLAN_AUTH_CHALLENGE_LEN);
1085 resp_ies_len = 2 + WLAN_AUTH_CHALLENGE_LEN;
1088 #ifdef CONFIG_IEEE80211R
1090 sta->auth_alg = WLAN_AUTH_FT;
1091 if (sta->wpa_sm == NULL)
1092 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
1094 if (sta->wpa_sm == NULL) {
1095 wpa_printf(MSG_DEBUG, "FT: Failed to initialize WPA "
1097 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
1100 wpa_ft_process_auth(sta->wpa_sm, mgmt->bssid,
1101 auth_transaction, mgmt->u.auth.variable,
1102 len - IEEE80211_HDRLEN -
1103 sizeof(mgmt->u.auth),
1104 handle_auth_ft_finish, hapd);
1105 /* handle_auth_ft_finish() callback will complete auth. */
1107 #endif /* CONFIG_IEEE80211R */
1111 if (status_code == WLAN_STATUS_SUCCESS &&
1112 hapd->conf->mesh & MESH_ENABLED) {
1113 if (sta->wpa_sm == NULL)
1115 wpa_auth_sta_init(hapd->wpa_auth,
1117 if (sta->wpa_sm == NULL) {
1118 wpa_printf(MSG_DEBUG,
1119 "SAE: Failed to initialize WPA state machine");
1120 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
1124 #endif /* CONFIG_MESH */
1125 handle_auth_sae(hapd, sta, mgmt, len, auth_transaction,
1128 #endif /* CONFIG_SAE */
1133 os_free(radius_cui);
1134 hostapd_free_psk_list(psk);
1136 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, auth_alg,
1137 auth_transaction + 1, resp, resp_ies, resp_ies_len);
1141 static int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta)
1145 /* get a unique AID */
1147 wpa_printf(MSG_DEBUG, " old AID %d", sta->aid);
1151 for (i = 0; i < AID_WORDS; i++) {
1152 if (hapd->sta_aid[i] == (u32) -1)
1154 for (j = 0; j < 32; j++) {
1155 if (!(hapd->sta_aid[i] & BIT(j)))
1163 aid = i * 32 + j + 1;
1168 hapd->sta_aid[i] |= BIT(j);
1169 wpa_printf(MSG_DEBUG, " new AID %d", sta->aid);
1174 static u16 check_ssid(struct hostapd_data *hapd, struct sta_info *sta,
1175 const u8 *ssid_ie, size_t ssid_ie_len)
1177 if (ssid_ie == NULL)
1178 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1180 if (ssid_ie_len != hapd->conf->ssid.ssid_len ||
1181 os_memcmp(ssid_ie, hapd->conf->ssid.ssid, ssid_ie_len) != 0) {
1182 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1184 "Station tried to associate with unknown SSID "
1185 "'%s'", wpa_ssid_txt(ssid_ie, ssid_ie_len));
1186 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1189 return WLAN_STATUS_SUCCESS;
1193 static u16 check_wmm(struct hostapd_data *hapd, struct sta_info *sta,
1194 const u8 *wmm_ie, size_t wmm_ie_len)
1196 sta->flags &= ~WLAN_STA_WMM;
1198 if (wmm_ie && hapd->conf->wmm_enabled) {
1199 struct wmm_information_element *wmm;
1201 if (!hostapd_eid_wmm_valid(hapd, wmm_ie, wmm_ie_len)) {
1202 hostapd_logger(hapd, sta->addr,
1204 HOSTAPD_LEVEL_DEBUG,
1205 "invalid WMM element in association "
1207 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1210 sta->flags |= WLAN_STA_WMM;
1211 wmm = (struct wmm_information_element *) wmm_ie;
1212 sta->qosinfo = wmm->qos_info;
1214 return WLAN_STATUS_SUCCESS;
1218 static u16 copy_supp_rates(struct hostapd_data *hapd, struct sta_info *sta,
1219 struct ieee802_11_elems *elems)
1221 if (!elems->supp_rates) {
1222 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1223 HOSTAPD_LEVEL_DEBUG,
1224 "No supported rates element in AssocReq");
1225 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1228 if (elems->supp_rates_len + elems->ext_supp_rates_len >
1229 sizeof(sta->supported_rates)) {
1230 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1231 HOSTAPD_LEVEL_DEBUG,
1232 "Invalid supported rates element length %d+%d",
1233 elems->supp_rates_len,
1234 elems->ext_supp_rates_len);
1235 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1238 sta->supported_rates_len = merge_byte_arrays(
1239 sta->supported_rates, sizeof(sta->supported_rates),
1240 elems->supp_rates, elems->supp_rates_len,
1241 elems->ext_supp_rates, elems->ext_supp_rates_len);
1243 return WLAN_STATUS_SUCCESS;
1247 static u16 check_ext_capab(struct hostapd_data *hapd, struct sta_info *sta,
1248 const u8 *ext_capab_ie, size_t ext_capab_ie_len)
1250 #ifdef CONFIG_INTERWORKING
1251 /* check for QoS Map support */
1252 if (ext_capab_ie_len >= 5) {
1253 if (ext_capab_ie[4] & 0x01)
1254 sta->qos_map_enabled = 1;
1256 #endif /* CONFIG_INTERWORKING */
1258 return WLAN_STATUS_SUCCESS;
1262 static u16 check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta,
1263 const u8 *ies, size_t ies_len, int reassoc)
1265 struct ieee802_11_elems elems;
1269 const u8 *p2p_dev_addr = NULL;
1271 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed) {
1272 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1273 HOSTAPD_LEVEL_INFO, "Station sent an invalid "
1274 "association request");
1275 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1278 resp = check_ssid(hapd, sta, elems.ssid, elems.ssid_len);
1279 if (resp != WLAN_STATUS_SUCCESS)
1281 resp = check_wmm(hapd, sta, elems.wmm, elems.wmm_len);
1282 if (resp != WLAN_STATUS_SUCCESS)
1284 resp = check_ext_capab(hapd, sta, elems.ext_capab, elems.ext_capab_len);
1285 if (resp != WLAN_STATUS_SUCCESS)
1287 resp = copy_supp_rates(hapd, sta, &elems);
1288 if (resp != WLAN_STATUS_SUCCESS)
1290 #ifdef CONFIG_IEEE80211N
1291 resp = copy_sta_ht_capab(hapd, sta, elems.ht_capabilities);
1292 if (resp != WLAN_STATUS_SUCCESS)
1294 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht &&
1295 !(sta->flags & WLAN_STA_HT)) {
1296 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1297 HOSTAPD_LEVEL_INFO, "Station does not support "
1298 "mandatory HT PHY - reject association");
1299 return WLAN_STATUS_ASSOC_DENIED_NO_HT;
1301 #endif /* CONFIG_IEEE80211N */
1303 #ifdef CONFIG_IEEE80211AC
1304 resp = copy_sta_vht_capab(hapd, sta, elems.vht_capabilities);
1305 if (resp != WLAN_STATUS_SUCCESS)
1308 resp = set_sta_vht_opmode(hapd, sta, elems.vht_opmode_notif);
1309 if (resp != WLAN_STATUS_SUCCESS)
1312 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht &&
1313 !(sta->flags & WLAN_STA_VHT)) {
1314 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1315 HOSTAPD_LEVEL_INFO, "Station does not support "
1316 "mandatory VHT PHY - reject association");
1317 return WLAN_STATUS_ASSOC_DENIED_NO_VHT;
1320 if (hapd->conf->vendor_vht && !elems.vht_capabilities) {
1321 resp = copy_sta_vendor_vht(hapd, sta, elems.vendor_vht,
1322 elems.vendor_vht_len);
1323 if (resp != WLAN_STATUS_SUCCESS)
1326 #endif /* CONFIG_IEEE80211AC */
1330 wpabuf_free(sta->p2p_ie);
1331 sta->p2p_ie = ieee802_11_vendor_ie_concat(ies, ies_len,
1332 P2P_IE_VENDOR_TYPE);
1334 p2p_dev_addr = p2p_get_go_dev_addr(sta->p2p_ie);
1336 wpabuf_free(sta->p2p_ie);
1339 #endif /* CONFIG_P2P */
1341 if ((hapd->conf->wpa & WPA_PROTO_RSN) && elems.rsn_ie) {
1342 wpa_ie = elems.rsn_ie;
1343 wpa_ie_len = elems.rsn_ie_len;
1344 } else if ((hapd->conf->wpa & WPA_PROTO_WPA) &&
1346 wpa_ie = elems.wpa_ie;
1347 wpa_ie_len = elems.wpa_ie_len;
1354 sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2);
1355 if (hapd->conf->wps_state && elems.wps_ie) {
1356 wpa_printf(MSG_DEBUG, "STA included WPS IE in (Re)Association "
1357 "Request - assume WPS is used");
1358 sta->flags |= WLAN_STA_WPS;
1359 wpabuf_free(sta->wps_ie);
1360 sta->wps_ie = ieee802_11_vendor_ie_concat(ies, ies_len,
1361 WPS_IE_VENDOR_TYPE);
1362 if (sta->wps_ie && wps_is_20(sta->wps_ie)) {
1363 wpa_printf(MSG_DEBUG, "WPS: STA supports WPS 2.0");
1364 sta->flags |= WLAN_STA_WPS2;
1368 if (sta->wps_ie && wps_validate_assoc_req(sta->wps_ie) < 0) {
1369 wpa_printf(MSG_DEBUG, "WPS: Invalid WPS IE in "
1370 "(Re)Association Request - reject");
1371 return WLAN_STATUS_INVALID_IE;
1373 } else if (hapd->conf->wps_state && wpa_ie == NULL) {
1374 wpa_printf(MSG_DEBUG, "STA did not include WPA/RSN IE in "
1375 "(Re)Association Request - possible WPS use");
1376 sta->flags |= WLAN_STA_MAYBE_WPS;
1378 #endif /* CONFIG_WPS */
1379 if (hapd->conf->wpa && wpa_ie == NULL) {
1380 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1382 "No WPA/RSN IE in association request");
1383 return WLAN_STATUS_INVALID_IE;
1386 if (hapd->conf->wpa && wpa_ie) {
1390 if (sta->wpa_sm == NULL)
1391 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
1394 if (sta->wpa_sm == NULL) {
1395 wpa_printf(MSG_WARNING, "Failed to initialize WPA "
1397 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1399 res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm,
1401 elems.mdie, elems.mdie_len);
1402 if (res == WPA_INVALID_GROUP)
1403 resp = WLAN_STATUS_GROUP_CIPHER_NOT_VALID;
1404 else if (res == WPA_INVALID_PAIRWISE)
1405 resp = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID;
1406 else if (res == WPA_INVALID_AKMP)
1407 resp = WLAN_STATUS_AKMP_NOT_VALID;
1408 else if (res == WPA_ALLOC_FAIL)
1409 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
1410 #ifdef CONFIG_IEEE80211W
1411 else if (res == WPA_MGMT_FRAME_PROTECTION_VIOLATION)
1412 resp = WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION;
1413 else if (res == WPA_INVALID_MGMT_GROUP_CIPHER)
1414 resp = WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION;
1415 #endif /* CONFIG_IEEE80211W */
1416 else if (res == WPA_INVALID_MDIE)
1417 resp = WLAN_STATUS_INVALID_MDIE;
1418 else if (res != WPA_IE_OK)
1419 resp = WLAN_STATUS_INVALID_IE;
1420 if (resp != WLAN_STATUS_SUCCESS)
1422 #ifdef CONFIG_IEEE80211W
1423 if ((sta->flags & WLAN_STA_MFP) && !sta->sa_query_timed_out &&
1424 sta->sa_query_count > 0)
1425 ap_check_sa_query_timeout(hapd, sta);
1426 if ((sta->flags & WLAN_STA_MFP) && !sta->sa_query_timed_out &&
1427 (!reassoc || sta->auth_alg != WLAN_AUTH_FT)) {
1429 * STA has already been associated with MFP and SA
1430 * Query timeout has not been reached. Reject the
1431 * association attempt temporarily and start SA Query,
1432 * if one is not pending.
1435 if (sta->sa_query_count == 0)
1436 ap_sta_start_sa_query(hapd, sta);
1438 return WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY;
1441 if (wpa_auth_uses_mfp(sta->wpa_sm))
1442 sta->flags |= WLAN_STA_MFP;
1444 sta->flags &= ~WLAN_STA_MFP;
1445 #endif /* CONFIG_IEEE80211W */
1447 #ifdef CONFIG_IEEE80211R
1448 if (sta->auth_alg == WLAN_AUTH_FT) {
1450 wpa_printf(MSG_DEBUG, "FT: " MACSTR " tried "
1451 "to use association (not "
1452 "re-association) with FT auth_alg",
1453 MAC2STR(sta->addr));
1454 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1457 resp = wpa_ft_validate_reassoc(sta->wpa_sm, ies,
1459 if (resp != WLAN_STATUS_SUCCESS)
1462 #endif /* CONFIG_IEEE80211R */
1465 if (wpa_auth_uses_sae(sta->wpa_sm) &&
1466 sta->auth_alg == WLAN_AUTH_OPEN) {
1467 struct rsn_pmksa_cache_entry *sa;
1468 sa = wpa_auth_sta_get_pmksa(sta->wpa_sm);
1469 if (!sa || sa->akmp != WPA_KEY_MGMT_SAE) {
1470 wpa_printf(MSG_DEBUG,
1471 "SAE: No PMKSA cache entry found for "
1472 MACSTR, MAC2STR(sta->addr));
1473 return WLAN_STATUS_INVALID_PMKID;
1475 wpa_printf(MSG_DEBUG, "SAE: " MACSTR
1476 " using PMKSA caching", MAC2STR(sta->addr));
1477 } else if (wpa_auth_uses_sae(sta->wpa_sm) &&
1478 sta->auth_alg != WLAN_AUTH_SAE &&
1479 !(sta->auth_alg == WLAN_AUTH_FT &&
1480 wpa_auth_uses_ft_sae(sta->wpa_sm))) {
1481 wpa_printf(MSG_DEBUG, "SAE: " MACSTR " tried to use "
1482 "SAE AKM after non-SAE auth_alg %u",
1483 MAC2STR(sta->addr), sta->auth_alg);
1484 return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
1486 #endif /* CONFIG_SAE */
1488 #ifdef CONFIG_IEEE80211N
1489 if ((sta->flags & (WLAN_STA_HT | WLAN_STA_VHT)) &&
1490 wpa_auth_get_pairwise(sta->wpa_sm) == WPA_CIPHER_TKIP) {
1491 hostapd_logger(hapd, sta->addr,
1492 HOSTAPD_MODULE_IEEE80211,
1494 "Station tried to use TKIP with HT "
1496 return WLAN_STATUS_CIPHER_REJECTED_PER_POLICY;
1498 #endif /* CONFIG_IEEE80211N */
1500 } else if (hapd->conf->osen) {
1501 if (elems.osen == NULL) {
1503 hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1505 "No HS 2.0 OSEN element in association request");
1506 return WLAN_STATUS_INVALID_IE;
1509 wpa_printf(MSG_DEBUG, "HS 2.0: OSEN association");
1510 if (sta->wpa_sm == NULL)
1511 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
1513 if (sta->wpa_sm == NULL) {
1514 wpa_printf(MSG_WARNING, "Failed to initialize WPA "
1516 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1518 if (wpa_validate_osen(hapd->wpa_auth, sta->wpa_sm,
1519 elems.osen - 2, elems.osen_len + 2) < 0)
1520 return WLAN_STATUS_INVALID_IE;
1521 #endif /* CONFIG_HS20 */
1523 wpa_auth_sta_no_wpa(sta->wpa_sm);
1526 p2p_group_notif_assoc(hapd->p2p_group, sta->addr, ies, ies_len);
1527 #endif /* CONFIG_P2P */
1530 wpabuf_free(sta->hs20_ie);
1531 if (elems.hs20 && elems.hs20_len > 4) {
1532 sta->hs20_ie = wpabuf_alloc_copy(elems.hs20 + 4,
1533 elems.hs20_len - 4);
1535 sta->hs20_ie = NULL;
1536 #endif /* CONFIG_HS20 */
1538 return WLAN_STATUS_SUCCESS;
1542 static void send_deauth(struct hostapd_data *hapd, const u8 *addr,
1546 struct ieee80211_mgmt reply;
1548 os_memset(&reply, 0, sizeof(reply));
1549 reply.frame_control =
1550 IEEE80211_FC(WLAN_FC_TYPE_MGMT, WLAN_FC_STYPE_DEAUTH);
1551 os_memcpy(reply.da, addr, ETH_ALEN);
1552 os_memcpy(reply.sa, hapd->own_addr, ETH_ALEN);
1553 os_memcpy(reply.bssid, hapd->own_addr, ETH_ALEN);
1555 send_len = IEEE80211_HDRLEN + sizeof(reply.u.deauth);
1556 reply.u.deauth.reason_code = host_to_le16(reason_code);
1558 if (hostapd_drv_send_mlme(hapd, &reply, send_len, 0) < 0)
1559 wpa_printf(MSG_INFO, "Failed to send deauth: %s",
1564 static void send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta,
1565 u16 status_code, int reassoc, const u8 *ies,
1569 u8 buf[sizeof(struct ieee80211_mgmt) + 1024];
1570 struct ieee80211_mgmt *reply;
1573 os_memset(buf, 0, sizeof(buf));
1574 reply = (struct ieee80211_mgmt *) buf;
1575 reply->frame_control =
1576 IEEE80211_FC(WLAN_FC_TYPE_MGMT,
1577 (reassoc ? WLAN_FC_STYPE_REASSOC_RESP :
1578 WLAN_FC_STYPE_ASSOC_RESP));
1579 os_memcpy(reply->da, sta->addr, ETH_ALEN);
1580 os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
1581 os_memcpy(reply->bssid, hapd->own_addr, ETH_ALEN);
1583 send_len = IEEE80211_HDRLEN;
1584 send_len += sizeof(reply->u.assoc_resp);
1585 reply->u.assoc_resp.capab_info =
1586 host_to_le16(hostapd_own_capab_info(hapd));
1587 reply->u.assoc_resp.status_code = host_to_le16(status_code);
1588 reply->u.assoc_resp.aid = host_to_le16(sta->aid | BIT(14) | BIT(15));
1589 /* Supported rates */
1590 p = hostapd_eid_supp_rates(hapd, reply->u.assoc_resp.variable);
1591 /* Extended supported rates */
1592 p = hostapd_eid_ext_supp_rates(hapd, p);
1594 #ifdef CONFIG_IEEE80211R
1595 if (status_code == WLAN_STATUS_SUCCESS) {
1596 /* IEEE 802.11r: Mobility Domain Information, Fast BSS
1597 * Transition Information, RSN, [RIC Response] */
1598 p = wpa_sm_write_assoc_resp_ies(sta->wpa_sm, p,
1599 buf + sizeof(buf) - p,
1600 sta->auth_alg, ies, ies_len);
1602 #endif /* CONFIG_IEEE80211R */
1604 #ifdef CONFIG_IEEE80211W
1605 if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY)
1606 p = hostapd_eid_assoc_comeback_time(hapd, sta, p);
1607 #endif /* CONFIG_IEEE80211W */
1609 #ifdef CONFIG_IEEE80211N
1610 p = hostapd_eid_ht_capabilities(hapd, p);
1611 p = hostapd_eid_ht_operation(hapd, p);
1612 #endif /* CONFIG_IEEE80211N */
1614 #ifdef CONFIG_IEEE80211AC
1615 if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) {
1616 p = hostapd_eid_vht_capabilities(hapd, p);
1617 p = hostapd_eid_vht_operation(hapd, p);
1619 #endif /* CONFIG_IEEE80211AC */
1621 p = hostapd_eid_ext_capab(hapd, p);
1622 p = hostapd_eid_bss_max_idle_period(hapd, p);
1623 if (sta->qos_map_enabled)
1624 p = hostapd_eid_qos_map_set(hapd, p);
1626 #ifdef CONFIG_IEEE80211AC
1627 if (hapd->conf->vendor_vht && (sta->flags & WLAN_STA_VENDOR_VHT))
1628 p = hostapd_eid_vendor_vht(hapd, p);
1629 #endif /* CONFIG_IEEE80211AC */
1631 if (sta->flags & WLAN_STA_WMM)
1632 p = hostapd_eid_wmm(hapd, p);
1635 if ((sta->flags & WLAN_STA_WPS) ||
1636 ((sta->flags & WLAN_STA_MAYBE_WPS) && hapd->conf->wpa)) {
1637 struct wpabuf *wps = wps_build_assoc_resp_ie();
1639 os_memcpy(p, wpabuf_head(wps), wpabuf_len(wps));
1640 p += wpabuf_len(wps);
1644 #endif /* CONFIG_WPS */
1648 struct wpabuf *p2p_resp_ie;
1649 enum p2p_status_code status;
1650 switch (status_code) {
1651 case WLAN_STATUS_SUCCESS:
1652 status = P2P_SC_SUCCESS;
1654 case WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA:
1655 status = P2P_SC_FAIL_LIMIT_REACHED;
1658 status = P2P_SC_FAIL_INVALID_PARAMS;
1661 p2p_resp_ie = p2p_group_assoc_resp_ie(hapd->p2p_group, status);
1663 os_memcpy(p, wpabuf_head(p2p_resp_ie),
1664 wpabuf_len(p2p_resp_ie));
1665 p += wpabuf_len(p2p_resp_ie);
1666 wpabuf_free(p2p_resp_ie);
1669 #endif /* CONFIG_P2P */
1671 #ifdef CONFIG_P2P_MANAGER
1672 if (hapd->conf->p2p & P2P_MANAGE)
1673 p = hostapd_eid_p2p_manage(hapd, p);
1674 #endif /* CONFIG_P2P_MANAGER */
1676 send_len += p - reply->u.assoc_resp.variable;
1678 if (hostapd_drv_send_mlme(hapd, reply, send_len, 0) < 0)
1679 wpa_printf(MSG_INFO, "Failed to send assoc resp: %s",
1684 static void handle_assoc(struct hostapd_data *hapd,
1685 const struct ieee80211_mgmt *mgmt, size_t len,
1688 u16 capab_info, listen_interval, seq_ctrl, fc;
1689 u16 resp = WLAN_STATUS_SUCCESS;
1692 struct sta_info *sta;
1694 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
1695 sizeof(mgmt->u.assoc_req))) {
1696 wpa_printf(MSG_INFO, "handle_assoc(reassoc=%d) - too short payload (len=%lu)",
1697 reassoc, (unsigned long) len);
1701 #ifdef CONFIG_TESTING_OPTIONS
1703 if (hapd->iconf->ignore_reassoc_probability > 0.0 &&
1704 drand48() < hapd->iconf->ignore_reassoc_probability) {
1705 wpa_printf(MSG_INFO,
1706 "TESTING: ignoring reassoc request from "
1707 MACSTR, MAC2STR(mgmt->sa));
1711 if (hapd->iconf->ignore_assoc_probability > 0.0 &&
1712 drand48() < hapd->iconf->ignore_assoc_probability) {
1713 wpa_printf(MSG_INFO,
1714 "TESTING: ignoring assoc request from "
1715 MACSTR, MAC2STR(mgmt->sa));
1719 #endif /* CONFIG_TESTING_OPTIONS */
1721 fc = le_to_host16(mgmt->frame_control);
1722 seq_ctrl = le_to_host16(mgmt->seq_ctrl);
1725 capab_info = le_to_host16(mgmt->u.reassoc_req.capab_info);
1726 listen_interval = le_to_host16(
1727 mgmt->u.reassoc_req.listen_interval);
1728 wpa_printf(MSG_DEBUG, "reassociation request: STA=" MACSTR
1729 " capab_info=0x%02x listen_interval=%d current_ap="
1730 MACSTR " seq_ctrl=0x%x%s",
1731 MAC2STR(mgmt->sa), capab_info, listen_interval,
1732 MAC2STR(mgmt->u.reassoc_req.current_ap),
1733 seq_ctrl, (fc & WLAN_FC_RETRY) ? " retry" : "");
1734 left = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.reassoc_req));
1735 pos = mgmt->u.reassoc_req.variable;
1737 capab_info = le_to_host16(mgmt->u.assoc_req.capab_info);
1738 listen_interval = le_to_host16(
1739 mgmt->u.assoc_req.listen_interval);
1740 wpa_printf(MSG_DEBUG, "association request: STA=" MACSTR
1741 " capab_info=0x%02x listen_interval=%d "
1743 MAC2STR(mgmt->sa), capab_info, listen_interval,
1744 seq_ctrl, (fc & WLAN_FC_RETRY) ? " retry" : "");
1745 left = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.assoc_req));
1746 pos = mgmt->u.assoc_req.variable;
1749 sta = ap_get_sta(hapd, mgmt->sa);
1750 #ifdef CONFIG_IEEE80211R
1751 if (sta && sta->auth_alg == WLAN_AUTH_FT &&
1752 (sta->flags & WLAN_STA_AUTH) == 0) {
1753 wpa_printf(MSG_DEBUG, "FT: Allow STA " MACSTR " to associate "
1754 "prior to authentication since it is using "
1755 "over-the-DS FT", MAC2STR(mgmt->sa));
1757 #endif /* CONFIG_IEEE80211R */
1758 if (sta == NULL || (sta->flags & WLAN_STA_AUTH) == 0) {
1759 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1760 HOSTAPD_LEVEL_INFO, "Station tried to "
1761 "associate before authentication "
1762 "(aid=%d flags=0x%x)",
1763 sta ? sta->aid : -1,
1764 sta ? sta->flags : 0);
1765 send_deauth(hapd, mgmt->sa,
1766 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA);
1770 if ((fc & WLAN_FC_RETRY) &&
1771 sta->last_seq_ctrl != WLAN_INVALID_MGMT_SEQ &&
1772 sta->last_seq_ctrl == seq_ctrl &&
1773 sta->last_subtype == reassoc ? WLAN_FC_STYPE_REASSOC_REQ :
1774 WLAN_FC_STYPE_ASSOC_REQ) {
1775 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1776 HOSTAPD_LEVEL_DEBUG,
1777 "Drop repeated association frame seq_ctrl=0x%x",
1781 sta->last_seq_ctrl = seq_ctrl;
1782 sta->last_subtype = reassoc ? WLAN_FC_STYPE_REASSOC_REQ :
1783 WLAN_FC_STYPE_ASSOC_REQ;
1785 if (hapd->tkip_countermeasures) {
1786 resp = WLAN_REASON_MICHAEL_MIC_FAILURE;
1790 if (listen_interval > hapd->conf->max_listen_interval) {
1791 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1792 HOSTAPD_LEVEL_DEBUG,
1793 "Too large Listen Interval (%d)",
1795 resp = WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE;
1799 /* followed by SSID and Supported rates; and HT capabilities if 802.11n
1801 resp = check_assoc_ies(hapd, sta, pos, left, reassoc);
1802 if (resp != WLAN_STATUS_SUCCESS)
1805 if (hostapd_get_aid(hapd, sta) < 0) {
1806 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1807 HOSTAPD_LEVEL_INFO, "No room for more AIDs");
1808 resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
1812 sta->capability = capab_info;
1813 sta->listen_interval = listen_interval;
1815 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
1816 sta->flags |= WLAN_STA_NONERP;
1817 for (i = 0; i < sta->supported_rates_len; i++) {
1818 if ((sta->supported_rates[i] & 0x7f) > 22) {
1819 sta->flags &= ~WLAN_STA_NONERP;
1823 if (sta->flags & WLAN_STA_NONERP && !sta->nonerp_set) {
1824 sta->nonerp_set = 1;
1825 hapd->iface->num_sta_non_erp++;
1826 if (hapd->iface->num_sta_non_erp == 1)
1827 ieee802_11_set_beacons(hapd->iface);
1830 if (!(sta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) &&
1831 !sta->no_short_slot_time_set) {
1832 sta->no_short_slot_time_set = 1;
1833 hapd->iface->num_sta_no_short_slot_time++;
1834 if (hapd->iface->current_mode->mode ==
1835 HOSTAPD_MODE_IEEE80211G &&
1836 hapd->iface->num_sta_no_short_slot_time == 1)
1837 ieee802_11_set_beacons(hapd->iface);
1840 if (sta->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
1841 sta->flags |= WLAN_STA_SHORT_PREAMBLE;
1843 sta->flags &= ~WLAN_STA_SHORT_PREAMBLE;
1845 if (!(sta->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) &&
1846 !sta->no_short_preamble_set) {
1847 sta->no_short_preamble_set = 1;
1848 hapd->iface->num_sta_no_short_preamble++;
1849 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
1850 && hapd->iface->num_sta_no_short_preamble == 1)
1851 ieee802_11_set_beacons(hapd->iface);
1854 #ifdef CONFIG_IEEE80211N
1855 update_ht_state(hapd, sta);
1856 #endif /* CONFIG_IEEE80211N */
1858 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1859 HOSTAPD_LEVEL_DEBUG,
1860 "association OK (aid %d)", sta->aid);
1861 /* Station will be marked associated, after it acknowledges AssocResp
1863 sta->flags |= WLAN_STA_ASSOC_REQ_OK;
1865 #ifdef CONFIG_IEEE80211W
1866 if ((sta->flags & WLAN_STA_MFP) && sta->sa_query_timed_out) {
1867 wpa_printf(MSG_DEBUG, "Allowing %sassociation after timed out "
1868 "SA Query procedure", reassoc ? "re" : "");
1869 /* TODO: Send a protected Disassociate frame to the STA using
1870 * the old key and Reason Code "Previous Authentication no
1871 * longer valid". Make sure this is only sent protected since
1872 * unprotected frame would be received by the STA that is now
1873 * trying to associate.
1876 #endif /* CONFIG_IEEE80211W */
1878 /* Make sure that the previously registered inactivity timer will not
1879 * remove the STA immediately. */
1880 sta->timeout_next = STA_NULLFUNC;
1883 send_assoc_resp(hapd, sta, resp, reassoc, pos, left);
1887 static void handle_disassoc(struct hostapd_data *hapd,
1888 const struct ieee80211_mgmt *mgmt, size_t len)
1890 struct sta_info *sta;
1892 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.disassoc)) {
1893 wpa_printf(MSG_INFO, "handle_disassoc - too short payload (len=%lu)",
1894 (unsigned long) len);
1898 wpa_printf(MSG_DEBUG, "disassocation: STA=" MACSTR " reason_code=%d",
1900 le_to_host16(mgmt->u.disassoc.reason_code));
1902 sta = ap_get_sta(hapd, mgmt->sa);
1904 wpa_printf(MSG_INFO, "Station " MACSTR " trying to disassociate, but it is not associated",
1909 ap_sta_set_authorized(hapd, sta, 0);
1910 sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
1911 sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
1912 wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
1913 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1914 HOSTAPD_LEVEL_INFO, "disassociated");
1915 sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
1916 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
1917 /* Stop Accounting and IEEE 802.1X sessions, but leave the STA
1919 accounting_sta_stop(hapd, sta);
1920 ieee802_1x_free_station(sta);
1922 hostapd_drv_br_delete_ip_neigh(hapd, 4, (u8 *) &sta->ipaddr);
1923 ap_sta_ip6addr_del(hapd, sta);
1924 hostapd_drv_sta_remove(hapd, sta->addr);
1926 if (sta->timeout_next == STA_NULLFUNC ||
1927 sta->timeout_next == STA_DISASSOC) {
1928 sta->timeout_next = STA_DEAUTH;
1929 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
1930 eloop_register_timeout(AP_DEAUTH_DELAY, 0, ap_handle_timer,
1934 mlme_disassociate_indication(
1935 hapd, sta, le_to_host16(mgmt->u.disassoc.reason_code));
1939 static void handle_deauth(struct hostapd_data *hapd,
1940 const struct ieee80211_mgmt *mgmt, size_t len)
1942 struct sta_info *sta;
1944 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.deauth)) {
1945 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "handle_deauth - too short "
1946 "payload (len=%lu)", (unsigned long) len);
1950 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "deauthentication: STA=" MACSTR
1952 MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
1954 sta = ap_get_sta(hapd, mgmt->sa);
1956 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR " trying "
1957 "to deauthenticate, but it is not authenticated",
1962 ap_sta_set_authorized(hapd, sta, 0);
1963 sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
1964 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
1965 WLAN_STA_ASSOC_REQ_OK);
1966 wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
1967 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1968 HOSTAPD_LEVEL_DEBUG, "deauthenticated");
1969 mlme_deauthenticate_indication(
1970 hapd, sta, le_to_host16(mgmt->u.deauth.reason_code));
1971 sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
1972 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
1973 ap_free_sta(hapd, sta);
1977 static void handle_beacon(struct hostapd_data *hapd,
1978 const struct ieee80211_mgmt *mgmt, size_t len,
1979 struct hostapd_frame_info *fi)
1981 struct ieee802_11_elems elems;
1983 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.beacon)) {
1984 wpa_printf(MSG_INFO, "handle_beacon - too short payload (len=%lu)",
1985 (unsigned long) len);
1989 (void) ieee802_11_parse_elems(mgmt->u.beacon.variable,
1990 len - (IEEE80211_HDRLEN +
1991 sizeof(mgmt->u.beacon)), &elems,
1994 ap_list_process_beacon(hapd->iface, mgmt, &elems, fi);
1998 #ifdef CONFIG_IEEE80211W
2000 static int hostapd_sa_query_action(struct hostapd_data *hapd,
2001 const struct ieee80211_mgmt *mgmt,
2006 end = mgmt->u.action.u.sa_query_resp.trans_id +
2007 WLAN_SA_QUERY_TR_ID_LEN;
2008 if (((u8 *) mgmt) + len < end) {
2009 wpa_printf(MSG_DEBUG, "IEEE 802.11: Too short SA Query Action "
2010 "frame (len=%lu)", (unsigned long) len);
2014 ieee802_11_sa_query_action(hapd, mgmt->sa,
2015 mgmt->u.action.u.sa_query_resp.action,
2016 mgmt->u.action.u.sa_query_resp.trans_id);
2021 static int robust_action_frame(u8 category)
2023 return category != WLAN_ACTION_PUBLIC &&
2024 category != WLAN_ACTION_HT;
2026 #endif /* CONFIG_IEEE80211W */
2029 static int handle_action(struct hostapd_data *hapd,
2030 const struct ieee80211_mgmt *mgmt, size_t len)
2032 struct sta_info *sta;
2033 sta = ap_get_sta(hapd, mgmt->sa);
2035 if (len < IEEE80211_HDRLEN + 1) {
2036 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
2037 HOSTAPD_LEVEL_DEBUG,
2038 "handle_action - too short payload (len=%lu)",
2039 (unsigned long) len);
2043 if (mgmt->u.action.category != WLAN_ACTION_PUBLIC &&
2044 (sta == NULL || !(sta->flags & WLAN_STA_ASSOC))) {
2045 wpa_printf(MSG_DEBUG, "IEEE 802.11: Ignored Action "
2046 "frame (category=%u) from unassociated STA " MACSTR,
2047 MAC2STR(mgmt->sa), mgmt->u.action.category);
2051 #ifdef CONFIG_IEEE80211W
2052 if (sta && (sta->flags & WLAN_STA_MFP) &&
2053 !(mgmt->frame_control & host_to_le16(WLAN_FC_ISWEP)) &&
2054 robust_action_frame(mgmt->u.action.category)) {
2055 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
2056 HOSTAPD_LEVEL_DEBUG,
2057 "Dropped unprotected Robust Action frame from "
2061 #endif /* CONFIG_IEEE80211W */
2064 u16 fc = le_to_host16(mgmt->frame_control);
2065 u16 seq_ctrl = le_to_host16(mgmt->seq_ctrl);
2067 if ((fc & WLAN_FC_RETRY) &&
2068 sta->last_seq_ctrl != WLAN_INVALID_MGMT_SEQ &&
2069 sta->last_seq_ctrl == seq_ctrl &&
2070 sta->last_subtype == WLAN_FC_STYPE_ACTION) {
2071 hostapd_logger(hapd, sta->addr,
2072 HOSTAPD_MODULE_IEEE80211,
2073 HOSTAPD_LEVEL_DEBUG,
2074 "Drop repeated action frame seq_ctrl=0x%x",
2079 sta->last_seq_ctrl = seq_ctrl;
2080 sta->last_subtype = WLAN_FC_STYPE_ACTION;
2083 switch (mgmt->u.action.category) {
2084 #ifdef CONFIG_IEEE80211R
2085 case WLAN_ACTION_FT:
2087 wpa_ft_action_rx(sta->wpa_sm, (u8 *) &mgmt->u.action,
2088 len - IEEE80211_HDRLEN))
2091 #endif /* CONFIG_IEEE80211R */
2092 case WLAN_ACTION_WMM:
2093 hostapd_wmm_action(hapd, mgmt, len);
2095 #ifdef CONFIG_IEEE80211W
2096 case WLAN_ACTION_SA_QUERY:
2097 return hostapd_sa_query_action(hapd, mgmt, len);
2098 #endif /* CONFIG_IEEE80211W */
2100 case WLAN_ACTION_WNM:
2101 ieee802_11_rx_wnm_action_ap(hapd, mgmt, len);
2103 #endif /* CONFIG_WNM */
2104 case WLAN_ACTION_PUBLIC:
2105 case WLAN_ACTION_PROTECTED_DUAL:
2106 #ifdef CONFIG_IEEE80211N
2107 if (len >= IEEE80211_HDRLEN + 2 &&
2108 mgmt->u.action.u.public_action.action ==
2109 WLAN_PA_20_40_BSS_COEX) {
2110 wpa_printf(MSG_DEBUG,
2111 "HT20/40 coex mgmt frame received from STA "
2112 MACSTR, MAC2STR(mgmt->sa));
2113 hostapd_2040_coex_action(hapd, mgmt, len);
2115 #endif /* CONFIG_IEEE80211N */
2116 if (hapd->public_action_cb) {
2117 hapd->public_action_cb(hapd->public_action_cb_ctx,
2121 if (hapd->public_action_cb2) {
2122 hapd->public_action_cb2(hapd->public_action_cb2_ctx,
2126 if (hapd->public_action_cb || hapd->public_action_cb2)
2129 case WLAN_ACTION_VENDOR_SPECIFIC:
2130 if (hapd->vendor_action_cb) {
2131 if (hapd->vendor_action_cb(hapd->vendor_action_cb_ctx,
2133 hapd->iface->freq) == 0)
2139 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
2140 HOSTAPD_LEVEL_DEBUG,
2141 "handle_action - unknown action category %d or invalid "
2143 mgmt->u.action.category);
2144 if (!(mgmt->da[0] & 0x01) && !(mgmt->u.action.category & 0x80) &&
2145 !(mgmt->sa[0] & 0x01)) {
2146 struct ieee80211_mgmt *resp;
2149 * IEEE 802.11-REVma/D9.0 - 7.3.1.11
2150 * Return the Action frame to the source without change
2151 * except that MSB of the Category set to 1.
2153 wpa_printf(MSG_DEBUG, "IEEE 802.11: Return unknown Action "
2154 "frame back to sender");
2155 resp = os_malloc(len);
2158 os_memcpy(resp, mgmt, len);
2159 os_memcpy(resp->da, resp->sa, ETH_ALEN);
2160 os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
2161 os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
2162 resp->u.action.category |= 0x80;
2164 if (hostapd_drv_send_mlme(hapd, resp, len, 0) < 0) {
2165 wpa_printf(MSG_ERROR, "IEEE 802.11: Failed to send "
2176 * ieee802_11_mgmt - process incoming IEEE 802.11 management frames
2177 * @hapd: hostapd BSS data structure (the BSS to which the management frame was
2179 * @buf: management frame data (starting from IEEE 802.11 header)
2180 * @len: length of frame data in octets
2181 * @fi: meta data about received frame (signal level, etc.)
2183 * Process all incoming IEEE 802.11 management frames. This will be called for
2184 * each frame received from the kernel driver through wlan#ap interface. In
2185 * addition, it can be called to re-inserted pending frames (e.g., when using
2186 * external RADIUS server as an MAC ACL).
2188 int ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
2189 struct hostapd_frame_info *fi)
2191 struct ieee80211_mgmt *mgmt;
2199 mgmt = (struct ieee80211_mgmt *) buf;
2200 fc = le_to_host16(mgmt->frame_control);
2201 stype = WLAN_FC_GET_STYPE(fc);
2203 if (stype == WLAN_FC_STYPE_BEACON) {
2204 handle_beacon(hapd, mgmt, len, fi);
2208 broadcast = mgmt->bssid[0] == 0xff && mgmt->bssid[1] == 0xff &&
2209 mgmt->bssid[2] == 0xff && mgmt->bssid[3] == 0xff &&
2210 mgmt->bssid[4] == 0xff && mgmt->bssid[5] == 0xff;
2214 /* Invitation responses can be sent with the peer MAC as BSSID */
2215 !((hapd->conf->p2p & P2P_GROUP_OWNER) &&
2216 stype == WLAN_FC_STYPE_ACTION) &&
2217 #endif /* CONFIG_P2P */
2219 !(hapd->conf->mesh & MESH_ENABLED) &&
2220 #endif /* CONFIG_MESH */
2221 os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0) {
2222 wpa_printf(MSG_INFO, "MGMT: BSSID=" MACSTR " not our address",
2223 MAC2STR(mgmt->bssid));
2228 if (stype == WLAN_FC_STYPE_PROBE_REQ) {
2229 handle_probe_req(hapd, mgmt, len, fi->ssi_signal);
2233 if (os_memcmp(mgmt->da, hapd->own_addr, ETH_ALEN) != 0) {
2234 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
2235 HOSTAPD_LEVEL_DEBUG,
2236 "MGMT: DA=" MACSTR " not our address",
2242 case WLAN_FC_STYPE_AUTH:
2243 wpa_printf(MSG_DEBUG, "mgmt::auth");
2244 handle_auth(hapd, mgmt, len);
2247 case WLAN_FC_STYPE_ASSOC_REQ:
2248 wpa_printf(MSG_DEBUG, "mgmt::assoc_req");
2249 handle_assoc(hapd, mgmt, len, 0);
2252 case WLAN_FC_STYPE_REASSOC_REQ:
2253 wpa_printf(MSG_DEBUG, "mgmt::reassoc_req");
2254 handle_assoc(hapd, mgmt, len, 1);
2257 case WLAN_FC_STYPE_DISASSOC:
2258 wpa_printf(MSG_DEBUG, "mgmt::disassoc");
2259 handle_disassoc(hapd, mgmt, len);
2262 case WLAN_FC_STYPE_DEAUTH:
2263 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "mgmt::deauth");
2264 handle_deauth(hapd, mgmt, len);
2267 case WLAN_FC_STYPE_ACTION:
2268 wpa_printf(MSG_DEBUG, "mgmt::action");
2269 ret = handle_action(hapd, mgmt, len);
2272 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
2273 HOSTAPD_LEVEL_DEBUG,
2274 "unknown mgmt frame subtype %d", stype);
2282 static void handle_auth_cb(struct hostapd_data *hapd,
2283 const struct ieee80211_mgmt *mgmt,
2286 u16 auth_alg, auth_transaction, status_code;
2287 struct sta_info *sta;
2290 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
2291 HOSTAPD_LEVEL_NOTICE,
2292 "did not acknowledge authentication response");
2296 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
2297 wpa_printf(MSG_INFO, "handle_auth_cb - too short payload (len=%lu)",
2298 (unsigned long) len);
2302 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
2303 auth_transaction = le_to_host16(mgmt->u.auth.auth_transaction);
2304 status_code = le_to_host16(mgmt->u.auth.status_code);
2306 sta = ap_get_sta(hapd, mgmt->da);
2308 wpa_printf(MSG_INFO, "handle_auth_cb: STA " MACSTR " not found",
2313 if (status_code == WLAN_STATUS_SUCCESS &&
2314 ((auth_alg == WLAN_AUTH_OPEN && auth_transaction == 2) ||
2315 (auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 4))) {
2316 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
2317 HOSTAPD_LEVEL_INFO, "authenticated");
2318 sta->flags |= WLAN_STA_AUTH;
2323 static void hostapd_set_wds_encryption(struct hostapd_data *hapd,
2324 struct sta_info *sta,
2328 struct hostapd_ssid *ssid = &hapd->conf->ssid;
2330 if (hapd->conf->ieee802_1x || hapd->conf->wpa)
2333 for (i = 0; i < 4; i++) {
2334 if (ssid->wep.key[i] &&
2335 hostapd_drv_set_key(ifname_wds, hapd, WPA_ALG_WEP, NULL, i,
2336 i == ssid->wep.idx, NULL, 0,
2337 ssid->wep.key[i], ssid->wep.len[i])) {
2338 wpa_printf(MSG_WARNING,
2339 "Could not set WEP keys for WDS interface; %s",
2347 static void handle_assoc_cb(struct hostapd_data *hapd,
2348 const struct ieee80211_mgmt *mgmt,
2349 size_t len, int reassoc, int ok)
2352 struct sta_info *sta;
2354 struct ieee80211_ht_capabilities ht_cap;
2355 struct ieee80211_vht_capabilities vht_cap;
2357 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_resp) :
2358 sizeof(mgmt->u.assoc_resp))) {
2359 wpa_printf(MSG_INFO, "handle_assoc_cb(reassoc=%d) - too short payload (len=%lu)",
2360 reassoc, (unsigned long) len);
2364 sta = ap_get_sta(hapd, mgmt->da);
2366 wpa_printf(MSG_INFO, "handle_assoc_cb: STA " MACSTR " not found",
2372 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
2373 HOSTAPD_LEVEL_DEBUG,
2374 "did not acknowledge association response");
2375 sta->flags &= ~WLAN_STA_ASSOC_REQ_OK;
2380 status = le_to_host16(mgmt->u.reassoc_resp.status_code);
2382 status = le_to_host16(mgmt->u.assoc_resp.status_code);
2384 if (status != WLAN_STATUS_SUCCESS)
2387 /* Stop previous accounting session, if one is started, and allocate
2388 * new session id for the new session. */
2389 accounting_sta_stop(hapd, sta);
2391 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
2393 "associated (aid %d)",
2396 if (sta->flags & WLAN_STA_ASSOC)
2398 sta->flags |= WLAN_STA_ASSOC;
2399 sta->flags &= ~WLAN_STA_WNM_SLEEP_MODE;
2400 if ((!hapd->conf->ieee802_1x && !hapd->conf->wpa && !hapd->conf->osen) ||
2401 sta->auth_alg == WLAN_AUTH_FT) {
2403 * Open, static WEP, or FT protocol; no separate authorization
2406 ap_sta_set_authorized(hapd, sta, 1);
2410 mlme_reassociate_indication(hapd, sta);
2412 mlme_associate_indication(hapd, sta);
2414 #ifdef CONFIG_IEEE80211W
2415 sta->sa_query_timed_out = 0;
2416 #endif /* CONFIG_IEEE80211W */
2419 * Remove the STA entry in order to make sure the STA PS state gets
2420 * cleared and configuration gets updated in case of reassociation back
2423 hostapd_drv_sta_remove(hapd, sta->addr);
2425 #ifdef CONFIG_IEEE80211N
2426 if (sta->flags & WLAN_STA_HT)
2427 hostapd_get_ht_capab(hapd, sta->ht_capabilities, &ht_cap);
2428 #endif /* CONFIG_IEEE80211N */
2429 #ifdef CONFIG_IEEE80211AC
2430 if (sta->flags & WLAN_STA_VHT)
2431 hostapd_get_vht_capab(hapd, sta->vht_capabilities, &vht_cap);
2432 #endif /* CONFIG_IEEE80211AC */
2434 if (hostapd_sta_add(hapd, sta->addr, sta->aid, sta->capability,
2435 sta->supported_rates, sta->supported_rates_len,
2436 sta->listen_interval,
2437 sta->flags & WLAN_STA_HT ? &ht_cap : NULL,
2438 sta->flags & WLAN_STA_VHT ? &vht_cap : NULL,
2439 sta->flags, sta->qosinfo, sta->vht_opmode)) {
2440 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
2441 HOSTAPD_LEVEL_NOTICE,
2442 "Could not add STA to kernel driver");
2444 ap_sta_disconnect(hapd, sta, sta->addr,
2445 WLAN_REASON_DISASSOC_AP_BUSY);
2450 if (sta->flags & WLAN_STA_WDS) {
2452 char ifname_wds[IFNAMSIZ + 1];
2454 ret = hostapd_set_wds_sta(hapd, ifname_wds, sta->addr,
2457 hostapd_set_wds_encryption(hapd, sta, ifname_wds);
2460 if (sta->eapol_sm == NULL) {
2462 * This STA does not use RADIUS server for EAP authentication,
2463 * so bind it to the selected VLAN interface now, since the
2464 * interface selection is not going to change anymore.
2466 if (ap_sta_bind_vlan(hapd, sta) < 0)
2468 } else if (sta->vlan_id) {
2469 /* VLAN ID already set (e.g., by PMKSA caching), so bind STA */
2470 if (ap_sta_bind_vlan(hapd, sta) < 0)
2474 hostapd_set_sta_flags(hapd, sta);
2476 if (sta->auth_alg == WLAN_AUTH_FT)
2477 wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FT);
2479 wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC);
2480 hapd->new_assoc_sta_cb(hapd, sta, !new_assoc);
2482 ieee802_1x_notify_port_enabled(sta->eapol_sm, 1);
2486 static void handle_deauth_cb(struct hostapd_data *hapd,
2487 const struct ieee80211_mgmt *mgmt,
2490 struct sta_info *sta;
2491 if (mgmt->da[0] & 0x01)
2493 sta = ap_get_sta(hapd, mgmt->da);
2495 wpa_printf(MSG_DEBUG, "handle_deauth_cb: STA " MACSTR
2496 " not found", MAC2STR(mgmt->da));
2500 wpa_printf(MSG_DEBUG, "STA " MACSTR " acknowledged deauth",
2501 MAC2STR(sta->addr));
2503 wpa_printf(MSG_DEBUG, "STA " MACSTR " did not acknowledge "
2504 "deauth", MAC2STR(sta->addr));
2506 ap_sta_deauth_cb(hapd, sta);
2510 static void handle_disassoc_cb(struct hostapd_data *hapd,
2511 const struct ieee80211_mgmt *mgmt,
2514 struct sta_info *sta;
2515 if (mgmt->da[0] & 0x01)
2517 sta = ap_get_sta(hapd, mgmt->da);
2519 wpa_printf(MSG_DEBUG, "handle_disassoc_cb: STA " MACSTR
2520 " not found", MAC2STR(mgmt->da));
2524 wpa_printf(MSG_DEBUG, "STA " MACSTR " acknowledged disassoc",
2525 MAC2STR(sta->addr));
2527 wpa_printf(MSG_DEBUG, "STA " MACSTR " did not acknowledge "
2528 "disassoc", MAC2STR(sta->addr));
2530 ap_sta_disassoc_cb(hapd, sta);
2535 * ieee802_11_mgmt_cb - Process management frame TX status callback
2536 * @hapd: hostapd BSS data structure (the BSS from which the management frame
2538 * @buf: management frame data (starting from IEEE 802.11 header)
2539 * @len: length of frame data in octets
2540 * @stype: management frame subtype from frame control field
2541 * @ok: Whether the frame was ACK'ed
2543 void ieee802_11_mgmt_cb(struct hostapd_data *hapd, const u8 *buf, size_t len,
2546 const struct ieee80211_mgmt *mgmt;
2547 mgmt = (const struct ieee80211_mgmt *) buf;
2549 #ifdef CONFIG_TESTING_OPTIONS
2550 if (hapd->ext_mgmt_frame_handling) {
2551 wpa_msg(hapd->msg_ctx, MSG_INFO, "MGMT-TX-STATUS stype=%u ok=%d",
2555 #endif /* CONFIG_TESTING_OPTIONS */
2558 case WLAN_FC_STYPE_AUTH:
2559 wpa_printf(MSG_DEBUG, "mgmt::auth cb");
2560 handle_auth_cb(hapd, mgmt, len, ok);
2562 case WLAN_FC_STYPE_ASSOC_RESP:
2563 wpa_printf(MSG_DEBUG, "mgmt::assoc_resp cb");
2564 handle_assoc_cb(hapd, mgmt, len, 0, ok);
2566 case WLAN_FC_STYPE_REASSOC_RESP:
2567 wpa_printf(MSG_DEBUG, "mgmt::reassoc_resp cb");
2568 handle_assoc_cb(hapd, mgmt, len, 1, ok);
2570 case WLAN_FC_STYPE_PROBE_RESP:
2571 wpa_printf(MSG_EXCESSIVE, "mgmt::proberesp cb");
2573 case WLAN_FC_STYPE_DEAUTH:
2574 wpa_printf(MSG_DEBUG, "mgmt::deauth cb");
2575 handle_deauth_cb(hapd, mgmt, len, ok);
2577 case WLAN_FC_STYPE_DISASSOC:
2578 wpa_printf(MSG_DEBUG, "mgmt::disassoc cb");
2579 handle_disassoc_cb(hapd, mgmt, len, ok);
2581 case WLAN_FC_STYPE_ACTION:
2582 wpa_printf(MSG_DEBUG, "mgmt::action cb");
2585 wpa_printf(MSG_INFO, "unknown mgmt cb frame subtype %d", stype);
2591 int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
2598 int ieee802_11_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
2599 char *buf, size_t buflen)
2606 void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
2607 const u8 *buf, size_t len, int ack)
2609 struct sta_info *sta;
2610 struct hostapd_iface *iface = hapd->iface;
2612 sta = ap_get_sta(hapd, addr);
2613 if (sta == NULL && iface->num_bss > 1) {
2615 for (j = 0; j < iface->num_bss; j++) {
2616 hapd = iface->bss[j];
2617 sta = ap_get_sta(hapd, addr);
2622 if (sta == NULL || !(sta->flags & WLAN_STA_ASSOC))
2624 if (sta->flags & WLAN_STA_PENDING_POLL) {
2625 wpa_printf(MSG_DEBUG, "STA " MACSTR " %s pending "
2626 "activity poll", MAC2STR(sta->addr),
2627 ack ? "ACKed" : "did not ACK");
2629 sta->flags &= ~WLAN_STA_PENDING_POLL;
2632 ieee802_1x_tx_status(hapd, sta, buf, len, ack);
2636 void hostapd_eapol_tx_status(struct hostapd_data *hapd, const u8 *dst,
2637 const u8 *data, size_t len, int ack)
2639 struct sta_info *sta;
2640 struct hostapd_iface *iface = hapd->iface;
2642 sta = ap_get_sta(hapd, dst);
2643 if (sta == NULL && iface->num_bss > 1) {
2645 for (j = 0; j < iface->num_bss; j++) {
2646 hapd = iface->bss[j];
2647 sta = ap_get_sta(hapd, dst);
2652 if (sta == NULL || !(sta->flags & WLAN_STA_ASSOC)) {
2653 wpa_printf(MSG_DEBUG, "Ignore TX status for Data frame to STA "
2654 MACSTR " that is not currently associated",
2659 ieee802_1x_eapol_tx_status(hapd, sta, data, len, ack);
2663 void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr)
2665 struct sta_info *sta;
2666 struct hostapd_iface *iface = hapd->iface;
2668 sta = ap_get_sta(hapd, addr);
2669 if (sta == NULL && iface->num_bss > 1) {
2671 for (j = 0; j < iface->num_bss; j++) {
2672 hapd = iface->bss[j];
2673 sta = ap_get_sta(hapd, addr);
2680 if (!(sta->flags & WLAN_STA_PENDING_POLL))
2683 wpa_printf(MSG_DEBUG, "STA " MACSTR " ACKed pending "
2684 "activity poll", MAC2STR(sta->addr));
2685 sta->flags &= ~WLAN_STA_PENDING_POLL;
2689 void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
2692 struct sta_info *sta;
2694 sta = ap_get_sta(hapd, src);
2695 if (sta && (sta->flags & WLAN_STA_ASSOC)) {
2696 if (!hapd->conf->wds_sta)
2699 if (wds && !(sta->flags & WLAN_STA_WDS)) {
2701 char ifname_wds[IFNAMSIZ + 1];
2703 wpa_printf(MSG_DEBUG, "Enable 4-address WDS mode for "
2704 "STA " MACSTR " (aid %u)",
2705 MAC2STR(sta->addr), sta->aid);
2706 sta->flags |= WLAN_STA_WDS;
2707 ret = hostapd_set_wds_sta(hapd, ifname_wds,
2708 sta->addr, sta->aid, 1);
2710 hostapd_set_wds_encryption(hapd, sta,
2716 wpa_printf(MSG_DEBUG, "Data/PS-poll frame from not associated STA "
2717 MACSTR, MAC2STR(src));
2718 if (src[0] & 0x01) {
2719 /* Broadcast bit set in SA?! Ignore the frame silently. */
2723 if (sta && (sta->flags & WLAN_STA_ASSOC_REQ_OK)) {
2724 wpa_printf(MSG_DEBUG, "Association Response to the STA has "
2725 "already been sent, but no TX status yet known - "
2726 "ignore Class 3 frame issue with " MACSTR,
2731 if (sta && (sta->flags & WLAN_STA_AUTH))
2732 hostapd_drv_sta_disassoc(
2734 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
2736 hostapd_drv_sta_deauth(
2738 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
2742 #endif /* CONFIG_NATIVE_WINDOWS */