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, 1);
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 (token && check_sae_token(hapd, sta->addr, token, token_len)
774 wpa_printf(MSG_DEBUG, "SAE: Drop commit message with "
775 "incorrect token from " MACSTR,
780 if (resp != WLAN_STATUS_SUCCESS)
783 if (!token && use_sae_anti_clogging(hapd)) {
784 wpa_printf(MSG_DEBUG,
785 "SAE: Request anti-clogging token from "
786 MACSTR, MAC2STR(sta->addr));
787 data = auth_build_token_req(hapd, sta->sae->group,
789 resp = WLAN_STATUS_ANTI_CLOGGING_TOKEN_REQ;
790 if (hapd->conf->mesh & MESH_ENABLED)
791 sta->sae->state = SAE_NOTHING;
795 resp = sae_sm_step(hapd, sta, mgmt->bssid, auth_transaction);
796 } else if (auth_transaction == 2) {
797 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
799 "SAE authentication (RX confirm, status=%u)",
801 if (status_code != WLAN_STATUS_SUCCESS)
803 if (sta->sae->state >= SAE_CONFIRMED ||
804 !(hapd->conf->mesh & MESH_ENABLED)) {
805 if (sae_check_confirm(sta->sae, mgmt->u.auth.variable,
806 ((u8 *) mgmt) + len -
807 mgmt->u.auth.variable) < 0) {
808 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
812 resp = sae_sm_step(hapd, sta, mgmt->bssid, auth_transaction);
814 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
816 "unexpected SAE authentication transaction %u (status=%u)",
817 auth_transaction, status_code);
818 if (status_code != WLAN_STATUS_SUCCESS)
820 resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
824 if (resp != WLAN_STATUS_SUCCESS) {
825 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, WLAN_AUTH_SAE,
826 auth_transaction, resp,
827 data ? wpabuf_head(data) : (u8 *) "",
828 data ? wpabuf_len(data) : 0);
835 * auth_sae_init_committed - Send COMMIT and start SAE in committed state
836 * @hapd: BSS data for the device initiating the authentication
837 * @sta: the peer to which commit authentication frame is sent
839 * This function implements Init event handling (IEEE Std 802.11-2012,
840 * 11.3.8.6.3) in which initial COMMIT message is sent. Prior to calling, the
841 * sta->sae structure should be initialized appropriately via a call to
842 * sae_prepare_commit().
844 int auth_sae_init_committed(struct hostapd_data *hapd, struct sta_info *sta)
848 if (!sta->sae || !sta->sae->tmp)
851 if (sta->sae->state != SAE_NOTHING)
854 ret = auth_sae_send_commit(hapd, sta, hapd->own_addr, 0);
858 sta->sae->state = SAE_COMMITTED;
860 sae_set_retransmit_timer(hapd, sta);
865 #endif /* CONFIG_SAE */
868 static void handle_auth(struct hostapd_data *hapd,
869 const struct ieee80211_mgmt *mgmt, size_t len)
871 u16 auth_alg, auth_transaction, status_code;
872 u16 resp = WLAN_STATUS_SUCCESS;
873 struct sta_info *sta = NULL;
876 const u8 *challenge = NULL;
877 u32 session_timeout, acct_interim_interval;
879 struct hostapd_sta_wpa_psk_short *psk = NULL;
880 u8 resp_ies[2 + WLAN_AUTH_CHALLENGE_LEN];
881 size_t resp_ies_len = 0;
882 char *identity = NULL;
883 char *radius_cui = NULL;
886 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
887 wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)",
888 (unsigned long) len);
892 #ifdef CONFIG_TESTING_OPTIONS
893 if (hapd->iconf->ignore_auth_probability > 0.0 &&
894 drand48() < hapd->iconf->ignore_auth_probability) {
896 "TESTING: ignoring auth frame from " MACSTR,
900 #endif /* CONFIG_TESTING_OPTIONS */
902 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
903 auth_transaction = le_to_host16(mgmt->u.auth.auth_transaction);
904 status_code = le_to_host16(mgmt->u.auth.status_code);
905 fc = le_to_host16(mgmt->frame_control);
906 seq_ctrl = le_to_host16(mgmt->seq_ctrl);
908 if (len >= IEEE80211_HDRLEN + sizeof(mgmt->u.auth) +
909 2 + WLAN_AUTH_CHALLENGE_LEN &&
910 mgmt->u.auth.variable[0] == WLAN_EID_CHALLENGE &&
911 mgmt->u.auth.variable[1] == WLAN_AUTH_CHALLENGE_LEN)
912 challenge = &mgmt->u.auth.variable[2];
914 wpa_printf(MSG_DEBUG, "authentication: STA=" MACSTR " auth_alg=%d "
915 "auth_transaction=%d status_code=%d wep=%d%s "
917 MAC2STR(mgmt->sa), auth_alg, auth_transaction,
918 status_code, !!(fc & WLAN_FC_ISWEP),
919 challenge ? " challenge" : "",
920 seq_ctrl, (fc & WLAN_FC_RETRY) ? " retry" : "");
922 if (hapd->tkip_countermeasures) {
923 resp = WLAN_REASON_MICHAEL_MIC_FAILURE;
927 if (!(((hapd->conf->auth_algs & WPA_AUTH_ALG_OPEN) &&
928 auth_alg == WLAN_AUTH_OPEN) ||
929 #ifdef CONFIG_IEEE80211R
930 (hapd->conf->wpa && wpa_key_mgmt_ft(hapd->conf->wpa_key_mgmt) &&
931 auth_alg == WLAN_AUTH_FT) ||
932 #endif /* CONFIG_IEEE80211R */
934 (hapd->conf->wpa && wpa_key_mgmt_sae(hapd->conf->wpa_key_mgmt) &&
935 auth_alg == WLAN_AUTH_SAE) ||
936 #endif /* CONFIG_SAE */
937 ((hapd->conf->auth_algs & WPA_AUTH_ALG_SHARED) &&
938 auth_alg == WLAN_AUTH_SHARED_KEY))) {
939 wpa_printf(MSG_INFO, "Unsupported authentication algorithm (%d)",
941 resp = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
945 if (!(auth_transaction == 1 || auth_alg == WLAN_AUTH_SAE ||
946 (auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 3))) {
947 wpa_printf(MSG_INFO, "Unknown authentication transaction number (%d)",
949 resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
953 if (os_memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) {
954 wpa_printf(MSG_INFO, "Station " MACSTR " not allowed to authenticate",
956 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
960 res = hostapd_allowed_address(hapd, mgmt->sa, (u8 *) mgmt, len,
962 &acct_interim_interval, &vlan_id,
963 &psk, &identity, &radius_cui);
965 if (res == HOSTAPD_ACL_REJECT) {
966 wpa_printf(MSG_INFO, "Station " MACSTR " not allowed to authenticate",
968 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
971 if (res == HOSTAPD_ACL_PENDING) {
972 wpa_printf(MSG_DEBUG, "Authentication frame from " MACSTR
973 " waiting for an external authentication",
975 /* Authentication code will re-send the authentication frame
976 * after it has received (and cached) information from the
977 * external source. */
981 sta = ap_get_sta(hapd, mgmt->sa);
983 if ((fc & WLAN_FC_RETRY) &&
984 sta->last_seq_ctrl != WLAN_INVALID_MGMT_SEQ &&
985 sta->last_seq_ctrl == seq_ctrl &&
986 sta->last_subtype == WLAN_FC_STYPE_AUTH) {
987 hostapd_logger(hapd, sta->addr,
988 HOSTAPD_MODULE_IEEE80211,
990 "Drop repeated authentication frame seq_ctrl=0x%x",
996 if (hapd->conf->mesh & MESH_ENABLED) {
997 /* if the mesh peer is not available, we don't do auth.
999 wpa_printf(MSG_DEBUG, "Mesh peer " MACSTR
1000 " not yet known - drop Authentiation frame",
1003 * Save a copy of the frame so that it can be processed
1004 * if a new peer entry is added shortly after this.
1006 wpabuf_free(hapd->mesh_pending_auth);
1007 hapd->mesh_pending_auth = wpabuf_alloc_copy(mgmt, len);
1008 os_get_reltime(&hapd->mesh_pending_auth_time);
1011 #endif /* CONFIG_MESH */
1013 sta = ap_sta_add(hapd, mgmt->sa);
1015 resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
1019 sta->last_seq_ctrl = seq_ctrl;
1020 sta->last_subtype = WLAN_FC_STYPE_AUTH;
1023 if (!hostapd_vlan_id_valid(hapd->conf->vlan, vlan_id)) {
1024 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS,
1025 HOSTAPD_LEVEL_INFO, "Invalid VLAN ID "
1026 "%d received from RADIUS server",
1028 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
1031 sta->vlan_id = vlan_id;
1032 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_RADIUS,
1033 HOSTAPD_LEVEL_INFO, "VLAN ID %d", sta->vlan_id);
1036 hostapd_free_psk_list(sta->psk);
1037 if (hapd->conf->wpa_psk_radius != PSK_RADIUS_IGNORED) {
1044 sta->identity = identity;
1046 sta->radius_cui = radius_cui;
1049 sta->flags &= ~WLAN_STA_PREAUTH;
1050 ieee802_1x_notify_pre_auth(sta->eapol_sm, 0);
1052 if (hapd->conf->acct_interim_interval == 0 && acct_interim_interval)
1053 sta->acct_interim_interval = acct_interim_interval;
1054 if (res == HOSTAPD_ACL_ACCEPT_TIMEOUT)
1055 ap_sta_session_timeout(hapd, sta, session_timeout);
1057 ap_sta_no_session_timeout(hapd, sta);
1060 case WLAN_AUTH_OPEN:
1061 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1062 HOSTAPD_LEVEL_DEBUG,
1063 "authentication OK (open system)");
1064 sta->flags |= WLAN_STA_AUTH;
1065 wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
1066 sta->auth_alg = WLAN_AUTH_OPEN;
1067 mlme_authenticate_indication(hapd, sta);
1069 case WLAN_AUTH_SHARED_KEY:
1070 resp = auth_shared_key(hapd, sta, auth_transaction, challenge,
1071 fc & WLAN_FC_ISWEP);
1072 sta->auth_alg = WLAN_AUTH_SHARED_KEY;
1073 mlme_authenticate_indication(hapd, sta);
1074 if (sta->challenge && auth_transaction == 1) {
1075 resp_ies[0] = WLAN_EID_CHALLENGE;
1076 resp_ies[1] = WLAN_AUTH_CHALLENGE_LEN;
1077 os_memcpy(resp_ies + 2, sta->challenge,
1078 WLAN_AUTH_CHALLENGE_LEN);
1079 resp_ies_len = 2 + WLAN_AUTH_CHALLENGE_LEN;
1082 #ifdef CONFIG_IEEE80211R
1084 sta->auth_alg = WLAN_AUTH_FT;
1085 if (sta->wpa_sm == NULL)
1086 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
1088 if (sta->wpa_sm == NULL) {
1089 wpa_printf(MSG_DEBUG, "FT: Failed to initialize WPA "
1091 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
1094 wpa_ft_process_auth(sta->wpa_sm, mgmt->bssid,
1095 auth_transaction, mgmt->u.auth.variable,
1096 len - IEEE80211_HDRLEN -
1097 sizeof(mgmt->u.auth),
1098 handle_auth_ft_finish, hapd);
1099 /* handle_auth_ft_finish() callback will complete auth. */
1101 #endif /* CONFIG_IEEE80211R */
1105 if (status_code == WLAN_STATUS_SUCCESS &&
1106 hapd->conf->mesh & MESH_ENABLED) {
1107 if (sta->wpa_sm == NULL)
1109 wpa_auth_sta_init(hapd->wpa_auth,
1111 if (sta->wpa_sm == NULL) {
1112 wpa_printf(MSG_DEBUG,
1113 "SAE: Failed to initialize WPA state machine");
1114 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
1118 #endif /* CONFIG_MESH */
1119 handle_auth_sae(hapd, sta, mgmt, len, auth_transaction,
1122 #endif /* CONFIG_SAE */
1127 os_free(radius_cui);
1128 hostapd_free_psk_list(psk);
1130 send_auth_reply(hapd, mgmt->sa, mgmt->bssid, auth_alg,
1131 auth_transaction + 1, resp, resp_ies, resp_ies_len);
1135 static int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta)
1139 /* get a unique AID */
1141 wpa_printf(MSG_DEBUG, " old AID %d", sta->aid);
1145 for (i = 0; i < AID_WORDS; i++) {
1146 if (hapd->sta_aid[i] == (u32) -1)
1148 for (j = 0; j < 32; j++) {
1149 if (!(hapd->sta_aid[i] & BIT(j)))
1157 aid = i * 32 + j + 1;
1162 hapd->sta_aid[i] |= BIT(j);
1163 wpa_printf(MSG_DEBUG, " new AID %d", sta->aid);
1168 static u16 check_ssid(struct hostapd_data *hapd, struct sta_info *sta,
1169 const u8 *ssid_ie, size_t ssid_ie_len)
1171 if (ssid_ie == NULL)
1172 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1174 if (ssid_ie_len != hapd->conf->ssid.ssid_len ||
1175 os_memcmp(ssid_ie, hapd->conf->ssid.ssid, ssid_ie_len) != 0) {
1176 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1178 "Station tried to associate with unknown SSID "
1179 "'%s'", wpa_ssid_txt(ssid_ie, ssid_ie_len));
1180 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1183 return WLAN_STATUS_SUCCESS;
1187 static u16 check_wmm(struct hostapd_data *hapd, struct sta_info *sta,
1188 const u8 *wmm_ie, size_t wmm_ie_len)
1190 sta->flags &= ~WLAN_STA_WMM;
1192 if (wmm_ie && hapd->conf->wmm_enabled) {
1193 struct wmm_information_element *wmm;
1195 if (!hostapd_eid_wmm_valid(hapd, wmm_ie, wmm_ie_len)) {
1196 hostapd_logger(hapd, sta->addr,
1198 HOSTAPD_LEVEL_DEBUG,
1199 "invalid WMM element in association "
1201 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1204 sta->flags |= WLAN_STA_WMM;
1205 wmm = (struct wmm_information_element *) wmm_ie;
1206 sta->qosinfo = wmm->qos_info;
1208 return WLAN_STATUS_SUCCESS;
1212 static u16 copy_supp_rates(struct hostapd_data *hapd, struct sta_info *sta,
1213 struct ieee802_11_elems *elems)
1215 if (!elems->supp_rates) {
1216 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1217 HOSTAPD_LEVEL_DEBUG,
1218 "No supported rates element in AssocReq");
1219 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1222 if (elems->supp_rates_len + elems->ext_supp_rates_len >
1223 sizeof(sta->supported_rates)) {
1224 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1225 HOSTAPD_LEVEL_DEBUG,
1226 "Invalid supported rates element length %d+%d",
1227 elems->supp_rates_len,
1228 elems->ext_supp_rates_len);
1229 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1232 sta->supported_rates_len = merge_byte_arrays(
1233 sta->supported_rates, sizeof(sta->supported_rates),
1234 elems->supp_rates, elems->supp_rates_len,
1235 elems->ext_supp_rates, elems->ext_supp_rates_len);
1237 return WLAN_STATUS_SUCCESS;
1241 static u16 check_ext_capab(struct hostapd_data *hapd, struct sta_info *sta,
1242 const u8 *ext_capab_ie, size_t ext_capab_ie_len)
1244 #ifdef CONFIG_INTERWORKING
1245 /* check for QoS Map support */
1246 if (ext_capab_ie_len >= 5) {
1247 if (ext_capab_ie[4] & 0x01)
1248 sta->qos_map_enabled = 1;
1250 #endif /* CONFIG_INTERWORKING */
1252 return WLAN_STATUS_SUCCESS;
1256 static u16 check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta,
1257 const u8 *ies, size_t ies_len, int reassoc)
1259 struct ieee802_11_elems elems;
1263 const u8 *p2p_dev_addr = NULL;
1265 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed) {
1266 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1267 HOSTAPD_LEVEL_INFO, "Station sent an invalid "
1268 "association request");
1269 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1272 resp = check_ssid(hapd, sta, elems.ssid, elems.ssid_len);
1273 if (resp != WLAN_STATUS_SUCCESS)
1275 resp = check_wmm(hapd, sta, elems.wmm, elems.wmm_len);
1276 if (resp != WLAN_STATUS_SUCCESS)
1278 resp = check_ext_capab(hapd, sta, elems.ext_capab, elems.ext_capab_len);
1279 if (resp != WLAN_STATUS_SUCCESS)
1281 resp = copy_supp_rates(hapd, sta, &elems);
1282 if (resp != WLAN_STATUS_SUCCESS)
1284 #ifdef CONFIG_IEEE80211N
1285 resp = copy_sta_ht_capab(hapd, sta, elems.ht_capabilities);
1286 if (resp != WLAN_STATUS_SUCCESS)
1288 if (hapd->iconf->ieee80211n && hapd->iconf->require_ht &&
1289 !(sta->flags & WLAN_STA_HT)) {
1290 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1291 HOSTAPD_LEVEL_INFO, "Station does not support "
1292 "mandatory HT PHY - reject association");
1293 return WLAN_STATUS_ASSOC_DENIED_NO_HT;
1295 #endif /* CONFIG_IEEE80211N */
1297 #ifdef CONFIG_IEEE80211AC
1298 resp = copy_sta_vht_capab(hapd, sta, elems.vht_capabilities);
1299 if (resp != WLAN_STATUS_SUCCESS)
1302 resp = set_sta_vht_opmode(hapd, sta, elems.vht_opmode_notif);
1303 if (resp != WLAN_STATUS_SUCCESS)
1306 if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht &&
1307 !(sta->flags & WLAN_STA_VHT)) {
1308 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1309 HOSTAPD_LEVEL_INFO, "Station does not support "
1310 "mandatory VHT PHY - reject association");
1311 return WLAN_STATUS_ASSOC_DENIED_NO_VHT;
1314 if (hapd->conf->vendor_vht && !elems.vht_capabilities) {
1315 resp = copy_sta_vendor_vht(hapd, sta, elems.vendor_vht,
1316 elems.vendor_vht_len);
1317 if (resp != WLAN_STATUS_SUCCESS)
1320 #endif /* CONFIG_IEEE80211AC */
1324 wpabuf_free(sta->p2p_ie);
1325 sta->p2p_ie = ieee802_11_vendor_ie_concat(ies, ies_len,
1326 P2P_IE_VENDOR_TYPE);
1328 p2p_dev_addr = p2p_get_go_dev_addr(sta->p2p_ie);
1330 wpabuf_free(sta->p2p_ie);
1333 #endif /* CONFIG_P2P */
1335 if ((hapd->conf->wpa & WPA_PROTO_RSN) && elems.rsn_ie) {
1336 wpa_ie = elems.rsn_ie;
1337 wpa_ie_len = elems.rsn_ie_len;
1338 } else if ((hapd->conf->wpa & WPA_PROTO_WPA) &&
1340 wpa_ie = elems.wpa_ie;
1341 wpa_ie_len = elems.wpa_ie_len;
1348 sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2);
1349 if (hapd->conf->wps_state && elems.wps_ie) {
1350 wpa_printf(MSG_DEBUG, "STA included WPS IE in (Re)Association "
1351 "Request - assume WPS is used");
1352 sta->flags |= WLAN_STA_WPS;
1353 wpabuf_free(sta->wps_ie);
1354 sta->wps_ie = ieee802_11_vendor_ie_concat(ies, ies_len,
1355 WPS_IE_VENDOR_TYPE);
1356 if (sta->wps_ie && wps_is_20(sta->wps_ie)) {
1357 wpa_printf(MSG_DEBUG, "WPS: STA supports WPS 2.0");
1358 sta->flags |= WLAN_STA_WPS2;
1362 if (sta->wps_ie && wps_validate_assoc_req(sta->wps_ie) < 0) {
1363 wpa_printf(MSG_DEBUG, "WPS: Invalid WPS IE in "
1364 "(Re)Association Request - reject");
1365 return WLAN_STATUS_INVALID_IE;
1367 } else if (hapd->conf->wps_state && wpa_ie == NULL) {
1368 wpa_printf(MSG_DEBUG, "STA did not include WPA/RSN IE in "
1369 "(Re)Association Request - possible WPS use");
1370 sta->flags |= WLAN_STA_MAYBE_WPS;
1372 #endif /* CONFIG_WPS */
1373 if (hapd->conf->wpa && wpa_ie == NULL) {
1374 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1376 "No WPA/RSN IE in association request");
1377 return WLAN_STATUS_INVALID_IE;
1380 if (hapd->conf->wpa && wpa_ie) {
1384 if (sta->wpa_sm == NULL)
1385 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
1388 if (sta->wpa_sm == NULL) {
1389 wpa_printf(MSG_WARNING, "Failed to initialize WPA "
1391 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1393 res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm,
1395 elems.mdie, elems.mdie_len);
1396 if (res == WPA_INVALID_GROUP)
1397 resp = WLAN_STATUS_GROUP_CIPHER_NOT_VALID;
1398 else if (res == WPA_INVALID_PAIRWISE)
1399 resp = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID;
1400 else if (res == WPA_INVALID_AKMP)
1401 resp = WLAN_STATUS_AKMP_NOT_VALID;
1402 else if (res == WPA_ALLOC_FAIL)
1403 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
1404 #ifdef CONFIG_IEEE80211W
1405 else if (res == WPA_MGMT_FRAME_PROTECTION_VIOLATION)
1406 resp = WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION;
1407 else if (res == WPA_INVALID_MGMT_GROUP_CIPHER)
1408 resp = WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION;
1409 #endif /* CONFIG_IEEE80211W */
1410 else if (res == WPA_INVALID_MDIE)
1411 resp = WLAN_STATUS_INVALID_MDIE;
1412 else if (res != WPA_IE_OK)
1413 resp = WLAN_STATUS_INVALID_IE;
1414 if (resp != WLAN_STATUS_SUCCESS)
1416 #ifdef CONFIG_IEEE80211W
1417 if ((sta->flags & WLAN_STA_MFP) && !sta->sa_query_timed_out &&
1418 sta->sa_query_count > 0)
1419 ap_check_sa_query_timeout(hapd, sta);
1420 if ((sta->flags & WLAN_STA_MFP) && !sta->sa_query_timed_out &&
1421 (!reassoc || sta->auth_alg != WLAN_AUTH_FT)) {
1423 * STA has already been associated with MFP and SA
1424 * Query timeout has not been reached. Reject the
1425 * association attempt temporarily and start SA Query,
1426 * if one is not pending.
1429 if (sta->sa_query_count == 0)
1430 ap_sta_start_sa_query(hapd, sta);
1432 return WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY;
1435 if (wpa_auth_uses_mfp(sta->wpa_sm))
1436 sta->flags |= WLAN_STA_MFP;
1438 sta->flags &= ~WLAN_STA_MFP;
1439 #endif /* CONFIG_IEEE80211W */
1441 #ifdef CONFIG_IEEE80211R
1442 if (sta->auth_alg == WLAN_AUTH_FT) {
1444 wpa_printf(MSG_DEBUG, "FT: " MACSTR " tried "
1445 "to use association (not "
1446 "re-association) with FT auth_alg",
1447 MAC2STR(sta->addr));
1448 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1451 resp = wpa_ft_validate_reassoc(sta->wpa_sm, ies,
1453 if (resp != WLAN_STATUS_SUCCESS)
1456 #endif /* CONFIG_IEEE80211R */
1459 if (wpa_auth_uses_sae(sta->wpa_sm) &&
1460 sta->auth_alg == WLAN_AUTH_OPEN) {
1461 struct rsn_pmksa_cache_entry *sa;
1462 sa = wpa_auth_sta_get_pmksa(sta->wpa_sm);
1463 if (!sa || sa->akmp != WPA_KEY_MGMT_SAE) {
1464 wpa_printf(MSG_DEBUG,
1465 "SAE: No PMKSA cache entry found for "
1466 MACSTR, MAC2STR(sta->addr));
1467 return WLAN_STATUS_INVALID_PMKID;
1469 wpa_printf(MSG_DEBUG, "SAE: " MACSTR
1470 " using PMKSA caching", MAC2STR(sta->addr));
1471 } else if (wpa_auth_uses_sae(sta->wpa_sm) &&
1472 sta->auth_alg != WLAN_AUTH_SAE &&
1473 !(sta->auth_alg == WLAN_AUTH_FT &&
1474 wpa_auth_uses_ft_sae(sta->wpa_sm))) {
1475 wpa_printf(MSG_DEBUG, "SAE: " MACSTR " tried to use "
1476 "SAE AKM after non-SAE auth_alg %u",
1477 MAC2STR(sta->addr), sta->auth_alg);
1478 return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
1480 #endif /* CONFIG_SAE */
1482 #ifdef CONFIG_IEEE80211N
1483 if ((sta->flags & (WLAN_STA_HT | WLAN_STA_VHT)) &&
1484 wpa_auth_get_pairwise(sta->wpa_sm) == WPA_CIPHER_TKIP) {
1485 hostapd_logger(hapd, sta->addr,
1486 HOSTAPD_MODULE_IEEE80211,
1488 "Station tried to use TKIP with HT "
1490 return WLAN_STATUS_CIPHER_REJECTED_PER_POLICY;
1492 #endif /* CONFIG_IEEE80211N */
1494 } else if (hapd->conf->osen) {
1495 if (elems.osen == NULL) {
1497 hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1499 "No HS 2.0 OSEN element in association request");
1500 return WLAN_STATUS_INVALID_IE;
1503 wpa_printf(MSG_DEBUG, "HS 2.0: OSEN association");
1504 if (sta->wpa_sm == NULL)
1505 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
1507 if (sta->wpa_sm == NULL) {
1508 wpa_printf(MSG_WARNING, "Failed to initialize WPA "
1510 return WLAN_STATUS_UNSPECIFIED_FAILURE;
1512 if (wpa_validate_osen(hapd->wpa_auth, sta->wpa_sm,
1513 elems.osen - 2, elems.osen_len + 2) < 0)
1514 return WLAN_STATUS_INVALID_IE;
1515 #endif /* CONFIG_HS20 */
1517 wpa_auth_sta_no_wpa(sta->wpa_sm);
1520 p2p_group_notif_assoc(hapd->p2p_group, sta->addr, ies, ies_len);
1521 #endif /* CONFIG_P2P */
1524 wpabuf_free(sta->hs20_ie);
1525 if (elems.hs20 && elems.hs20_len > 4) {
1526 sta->hs20_ie = wpabuf_alloc_copy(elems.hs20 + 4,
1527 elems.hs20_len - 4);
1529 sta->hs20_ie = NULL;
1530 #endif /* CONFIG_HS20 */
1532 return WLAN_STATUS_SUCCESS;
1536 static void send_deauth(struct hostapd_data *hapd, const u8 *addr,
1540 struct ieee80211_mgmt reply;
1542 os_memset(&reply, 0, sizeof(reply));
1543 reply.frame_control =
1544 IEEE80211_FC(WLAN_FC_TYPE_MGMT, WLAN_FC_STYPE_DEAUTH);
1545 os_memcpy(reply.da, addr, ETH_ALEN);
1546 os_memcpy(reply.sa, hapd->own_addr, ETH_ALEN);
1547 os_memcpy(reply.bssid, hapd->own_addr, ETH_ALEN);
1549 send_len = IEEE80211_HDRLEN + sizeof(reply.u.deauth);
1550 reply.u.deauth.reason_code = host_to_le16(reason_code);
1552 if (hostapd_drv_send_mlme(hapd, &reply, send_len, 0) < 0)
1553 wpa_printf(MSG_INFO, "Failed to send deauth: %s",
1558 static void send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta,
1559 u16 status_code, int reassoc, const u8 *ies,
1563 u8 buf[sizeof(struct ieee80211_mgmt) + 1024];
1564 struct ieee80211_mgmt *reply;
1567 os_memset(buf, 0, sizeof(buf));
1568 reply = (struct ieee80211_mgmt *) buf;
1569 reply->frame_control =
1570 IEEE80211_FC(WLAN_FC_TYPE_MGMT,
1571 (reassoc ? WLAN_FC_STYPE_REASSOC_RESP :
1572 WLAN_FC_STYPE_ASSOC_RESP));
1573 os_memcpy(reply->da, sta->addr, ETH_ALEN);
1574 os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
1575 os_memcpy(reply->bssid, hapd->own_addr, ETH_ALEN);
1577 send_len = IEEE80211_HDRLEN;
1578 send_len += sizeof(reply->u.assoc_resp);
1579 reply->u.assoc_resp.capab_info =
1580 host_to_le16(hostapd_own_capab_info(hapd));
1581 reply->u.assoc_resp.status_code = host_to_le16(status_code);
1582 reply->u.assoc_resp.aid = host_to_le16(sta->aid | BIT(14) | BIT(15));
1583 /* Supported rates */
1584 p = hostapd_eid_supp_rates(hapd, reply->u.assoc_resp.variable);
1585 /* Extended supported rates */
1586 p = hostapd_eid_ext_supp_rates(hapd, p);
1588 #ifdef CONFIG_IEEE80211R
1589 if (status_code == WLAN_STATUS_SUCCESS) {
1590 /* IEEE 802.11r: Mobility Domain Information, Fast BSS
1591 * Transition Information, RSN, [RIC Response] */
1592 p = wpa_sm_write_assoc_resp_ies(sta->wpa_sm, p,
1593 buf + sizeof(buf) - p,
1594 sta->auth_alg, ies, ies_len);
1596 #endif /* CONFIG_IEEE80211R */
1598 #ifdef CONFIG_IEEE80211W
1599 if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY)
1600 p = hostapd_eid_assoc_comeback_time(hapd, sta, p);
1601 #endif /* CONFIG_IEEE80211W */
1603 #ifdef CONFIG_IEEE80211N
1604 p = hostapd_eid_ht_capabilities(hapd, p);
1605 p = hostapd_eid_ht_operation(hapd, p);
1606 #endif /* CONFIG_IEEE80211N */
1608 #ifdef CONFIG_IEEE80211AC
1609 if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) {
1610 p = hostapd_eid_vht_capabilities(hapd, p);
1611 p = hostapd_eid_vht_operation(hapd, p);
1613 #endif /* CONFIG_IEEE80211AC */
1615 p = hostapd_eid_ext_capab(hapd, p);
1616 p = hostapd_eid_bss_max_idle_period(hapd, p);
1617 if (sta->qos_map_enabled)
1618 p = hostapd_eid_qos_map_set(hapd, p);
1620 #ifdef CONFIG_IEEE80211AC
1621 if (hapd->conf->vendor_vht && (sta->flags & WLAN_STA_VENDOR_VHT))
1622 p = hostapd_eid_vendor_vht(hapd, p);
1623 #endif /* CONFIG_IEEE80211AC */
1625 if (sta->flags & WLAN_STA_WMM)
1626 p = hostapd_eid_wmm(hapd, p);
1629 if ((sta->flags & WLAN_STA_WPS) ||
1630 ((sta->flags & WLAN_STA_MAYBE_WPS) && hapd->conf->wpa)) {
1631 struct wpabuf *wps = wps_build_assoc_resp_ie();
1633 os_memcpy(p, wpabuf_head(wps), wpabuf_len(wps));
1634 p += wpabuf_len(wps);
1638 #endif /* CONFIG_WPS */
1642 struct wpabuf *p2p_resp_ie;
1643 enum p2p_status_code status;
1644 switch (status_code) {
1645 case WLAN_STATUS_SUCCESS:
1646 status = P2P_SC_SUCCESS;
1648 case WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA:
1649 status = P2P_SC_FAIL_LIMIT_REACHED;
1652 status = P2P_SC_FAIL_INVALID_PARAMS;
1655 p2p_resp_ie = p2p_group_assoc_resp_ie(hapd->p2p_group, status);
1657 os_memcpy(p, wpabuf_head(p2p_resp_ie),
1658 wpabuf_len(p2p_resp_ie));
1659 p += wpabuf_len(p2p_resp_ie);
1660 wpabuf_free(p2p_resp_ie);
1663 #endif /* CONFIG_P2P */
1665 #ifdef CONFIG_P2P_MANAGER
1666 if (hapd->conf->p2p & P2P_MANAGE)
1667 p = hostapd_eid_p2p_manage(hapd, p);
1668 #endif /* CONFIG_P2P_MANAGER */
1670 send_len += p - reply->u.assoc_resp.variable;
1672 if (hostapd_drv_send_mlme(hapd, reply, send_len, 0) < 0)
1673 wpa_printf(MSG_INFO, "Failed to send assoc resp: %s",
1678 static void handle_assoc(struct hostapd_data *hapd,
1679 const struct ieee80211_mgmt *mgmt, size_t len,
1682 u16 capab_info, listen_interval, seq_ctrl, fc;
1683 u16 resp = WLAN_STATUS_SUCCESS;
1686 struct sta_info *sta;
1688 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
1689 sizeof(mgmt->u.assoc_req))) {
1690 wpa_printf(MSG_INFO, "handle_assoc(reassoc=%d) - too short payload (len=%lu)",
1691 reassoc, (unsigned long) len);
1695 #ifdef CONFIG_TESTING_OPTIONS
1697 if (hapd->iconf->ignore_reassoc_probability > 0.0 &&
1698 drand48() < hapd->iconf->ignore_reassoc_probability) {
1699 wpa_printf(MSG_INFO,
1700 "TESTING: ignoring reassoc request from "
1701 MACSTR, MAC2STR(mgmt->sa));
1705 if (hapd->iconf->ignore_assoc_probability > 0.0 &&
1706 drand48() < hapd->iconf->ignore_assoc_probability) {
1707 wpa_printf(MSG_INFO,
1708 "TESTING: ignoring assoc request from "
1709 MACSTR, MAC2STR(mgmt->sa));
1713 #endif /* CONFIG_TESTING_OPTIONS */
1715 fc = le_to_host16(mgmt->frame_control);
1716 seq_ctrl = le_to_host16(mgmt->seq_ctrl);
1719 capab_info = le_to_host16(mgmt->u.reassoc_req.capab_info);
1720 listen_interval = le_to_host16(
1721 mgmt->u.reassoc_req.listen_interval);
1722 wpa_printf(MSG_DEBUG, "reassociation request: STA=" MACSTR
1723 " capab_info=0x%02x listen_interval=%d current_ap="
1724 MACSTR " seq_ctrl=0x%x%s",
1725 MAC2STR(mgmt->sa), capab_info, listen_interval,
1726 MAC2STR(mgmt->u.reassoc_req.current_ap),
1727 seq_ctrl, (fc & WLAN_FC_RETRY) ? " retry" : "");
1728 left = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.reassoc_req));
1729 pos = mgmt->u.reassoc_req.variable;
1731 capab_info = le_to_host16(mgmt->u.assoc_req.capab_info);
1732 listen_interval = le_to_host16(
1733 mgmt->u.assoc_req.listen_interval);
1734 wpa_printf(MSG_DEBUG, "association request: STA=" MACSTR
1735 " capab_info=0x%02x listen_interval=%d "
1737 MAC2STR(mgmt->sa), capab_info, listen_interval,
1738 seq_ctrl, (fc & WLAN_FC_RETRY) ? " retry" : "");
1739 left = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.assoc_req));
1740 pos = mgmt->u.assoc_req.variable;
1743 sta = ap_get_sta(hapd, mgmt->sa);
1744 #ifdef CONFIG_IEEE80211R
1745 if (sta && sta->auth_alg == WLAN_AUTH_FT &&
1746 (sta->flags & WLAN_STA_AUTH) == 0) {
1747 wpa_printf(MSG_DEBUG, "FT: Allow STA " MACSTR " to associate "
1748 "prior to authentication since it is using "
1749 "over-the-DS FT", MAC2STR(mgmt->sa));
1751 #endif /* CONFIG_IEEE80211R */
1752 if (sta == NULL || (sta->flags & WLAN_STA_AUTH) == 0) {
1753 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1754 HOSTAPD_LEVEL_INFO, "Station tried to "
1755 "associate before authentication "
1756 "(aid=%d flags=0x%x)",
1757 sta ? sta->aid : -1,
1758 sta ? sta->flags : 0);
1759 send_deauth(hapd, mgmt->sa,
1760 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA);
1764 if ((fc & WLAN_FC_RETRY) &&
1765 sta->last_seq_ctrl != WLAN_INVALID_MGMT_SEQ &&
1766 sta->last_seq_ctrl == seq_ctrl &&
1767 sta->last_subtype == reassoc ? WLAN_FC_STYPE_REASSOC_REQ :
1768 WLAN_FC_STYPE_ASSOC_REQ) {
1769 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1770 HOSTAPD_LEVEL_DEBUG,
1771 "Drop repeated association frame seq_ctrl=0x%x",
1775 sta->last_seq_ctrl = seq_ctrl;
1776 sta->last_subtype = reassoc ? WLAN_FC_STYPE_REASSOC_REQ :
1777 WLAN_FC_STYPE_ASSOC_REQ;
1779 if (hapd->tkip_countermeasures) {
1780 resp = WLAN_REASON_MICHAEL_MIC_FAILURE;
1784 if (listen_interval > hapd->conf->max_listen_interval) {
1785 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1786 HOSTAPD_LEVEL_DEBUG,
1787 "Too large Listen Interval (%d)",
1789 resp = WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE;
1793 /* followed by SSID and Supported rates; and HT capabilities if 802.11n
1795 resp = check_assoc_ies(hapd, sta, pos, left, reassoc);
1796 if (resp != WLAN_STATUS_SUCCESS)
1799 if (hostapd_get_aid(hapd, sta) < 0) {
1800 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
1801 HOSTAPD_LEVEL_INFO, "No room for more AIDs");
1802 resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
1806 sta->capability = capab_info;
1807 sta->listen_interval = listen_interval;
1809 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
1810 sta->flags |= WLAN_STA_NONERP;
1811 for (i = 0; i < sta->supported_rates_len; i++) {
1812 if ((sta->supported_rates[i] & 0x7f) > 22) {
1813 sta->flags &= ~WLAN_STA_NONERP;
1817 if (sta->flags & WLAN_STA_NONERP && !sta->nonerp_set) {
1818 sta->nonerp_set = 1;
1819 hapd->iface->num_sta_non_erp++;
1820 if (hapd->iface->num_sta_non_erp == 1)
1821 ieee802_11_set_beacons(hapd->iface);
1824 if (!(sta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) &&
1825 !sta->no_short_slot_time_set) {
1826 sta->no_short_slot_time_set = 1;
1827 hapd->iface->num_sta_no_short_slot_time++;
1828 if (hapd->iface->current_mode->mode ==
1829 HOSTAPD_MODE_IEEE80211G &&
1830 hapd->iface->num_sta_no_short_slot_time == 1)
1831 ieee802_11_set_beacons(hapd->iface);
1834 if (sta->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
1835 sta->flags |= WLAN_STA_SHORT_PREAMBLE;
1837 sta->flags &= ~WLAN_STA_SHORT_PREAMBLE;
1839 if (!(sta->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) &&
1840 !sta->no_short_preamble_set) {
1841 sta->no_short_preamble_set = 1;
1842 hapd->iface->num_sta_no_short_preamble++;
1843 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
1844 && hapd->iface->num_sta_no_short_preamble == 1)
1845 ieee802_11_set_beacons(hapd->iface);
1848 #ifdef CONFIG_IEEE80211N
1849 update_ht_state(hapd, sta);
1850 #endif /* CONFIG_IEEE80211N */
1852 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1853 HOSTAPD_LEVEL_DEBUG,
1854 "association OK (aid %d)", sta->aid);
1855 /* Station will be marked associated, after it acknowledges AssocResp
1857 sta->flags |= WLAN_STA_ASSOC_REQ_OK;
1859 #ifdef CONFIG_IEEE80211W
1860 if ((sta->flags & WLAN_STA_MFP) && sta->sa_query_timed_out) {
1861 wpa_printf(MSG_DEBUG, "Allowing %sassociation after timed out "
1862 "SA Query procedure", reassoc ? "re" : "");
1863 /* TODO: Send a protected Disassociate frame to the STA using
1864 * the old key and Reason Code "Previous Authentication no
1865 * longer valid". Make sure this is only sent protected since
1866 * unprotected frame would be received by the STA that is now
1867 * trying to associate.
1870 #endif /* CONFIG_IEEE80211W */
1872 /* Make sure that the previously registered inactivity timer will not
1873 * remove the STA immediately. */
1874 sta->timeout_next = STA_NULLFUNC;
1877 send_assoc_resp(hapd, sta, resp, reassoc, pos, left);
1881 static void handle_disassoc(struct hostapd_data *hapd,
1882 const struct ieee80211_mgmt *mgmt, size_t len)
1884 struct sta_info *sta;
1886 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.disassoc)) {
1887 wpa_printf(MSG_INFO, "handle_disassoc - too short payload (len=%lu)",
1888 (unsigned long) len);
1892 wpa_printf(MSG_DEBUG, "disassocation: STA=" MACSTR " reason_code=%d",
1894 le_to_host16(mgmt->u.disassoc.reason_code));
1896 sta = ap_get_sta(hapd, mgmt->sa);
1898 wpa_printf(MSG_INFO, "Station " MACSTR " trying to disassociate, but it is not associated",
1903 ap_sta_set_authorized(hapd, sta, 0);
1904 sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
1905 sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
1906 wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
1907 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1908 HOSTAPD_LEVEL_INFO, "disassociated");
1909 sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
1910 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
1911 /* Stop Accounting and IEEE 802.1X sessions, but leave the STA
1913 accounting_sta_stop(hapd, sta);
1914 ieee802_1x_free_station(sta);
1916 hostapd_drv_br_delete_ip_neigh(hapd, 4, (u8 *) &sta->ipaddr);
1917 ap_sta_ip6addr_del(hapd, sta);
1918 hostapd_drv_sta_remove(hapd, sta->addr);
1920 if (sta->timeout_next == STA_NULLFUNC ||
1921 sta->timeout_next == STA_DISASSOC) {
1922 sta->timeout_next = STA_DEAUTH;
1923 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
1924 eloop_register_timeout(AP_DEAUTH_DELAY, 0, ap_handle_timer,
1928 mlme_disassociate_indication(
1929 hapd, sta, le_to_host16(mgmt->u.disassoc.reason_code));
1933 static void handle_deauth(struct hostapd_data *hapd,
1934 const struct ieee80211_mgmt *mgmt, size_t len)
1936 struct sta_info *sta;
1938 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.deauth)) {
1939 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "handle_deauth - too short "
1940 "payload (len=%lu)", (unsigned long) len);
1944 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "deauthentication: STA=" MACSTR
1946 MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
1948 sta = ap_get_sta(hapd, mgmt->sa);
1950 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR " trying "
1951 "to deauthenticate, but it is not authenticated",
1956 ap_sta_set_authorized(hapd, sta, 0);
1957 sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
1958 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
1959 WLAN_STA_ASSOC_REQ_OK);
1960 wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
1961 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1962 HOSTAPD_LEVEL_DEBUG, "deauthenticated");
1963 mlme_deauthenticate_indication(
1964 hapd, sta, le_to_host16(mgmt->u.deauth.reason_code));
1965 sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
1966 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
1967 ap_free_sta(hapd, sta);
1971 static void handle_beacon(struct hostapd_data *hapd,
1972 const struct ieee80211_mgmt *mgmt, size_t len,
1973 struct hostapd_frame_info *fi)
1975 struct ieee802_11_elems elems;
1977 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.beacon)) {
1978 wpa_printf(MSG_INFO, "handle_beacon - too short payload (len=%lu)",
1979 (unsigned long) len);
1983 (void) ieee802_11_parse_elems(mgmt->u.beacon.variable,
1984 len - (IEEE80211_HDRLEN +
1985 sizeof(mgmt->u.beacon)), &elems,
1988 ap_list_process_beacon(hapd->iface, mgmt, &elems, fi);
1992 #ifdef CONFIG_IEEE80211W
1994 static int hostapd_sa_query_action(struct hostapd_data *hapd,
1995 const struct ieee80211_mgmt *mgmt,
2000 end = mgmt->u.action.u.sa_query_resp.trans_id +
2001 WLAN_SA_QUERY_TR_ID_LEN;
2002 if (((u8 *) mgmt) + len < end) {
2003 wpa_printf(MSG_DEBUG, "IEEE 802.11: Too short SA Query Action "
2004 "frame (len=%lu)", (unsigned long) len);
2008 ieee802_11_sa_query_action(hapd, mgmt->sa,
2009 mgmt->u.action.u.sa_query_resp.action,
2010 mgmt->u.action.u.sa_query_resp.trans_id);
2015 static int robust_action_frame(u8 category)
2017 return category != WLAN_ACTION_PUBLIC &&
2018 category != WLAN_ACTION_HT;
2020 #endif /* CONFIG_IEEE80211W */
2023 static int handle_action(struct hostapd_data *hapd,
2024 const struct ieee80211_mgmt *mgmt, size_t len)
2026 struct sta_info *sta;
2027 sta = ap_get_sta(hapd, mgmt->sa);
2029 if (len < IEEE80211_HDRLEN + 1) {
2030 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
2031 HOSTAPD_LEVEL_DEBUG,
2032 "handle_action - too short payload (len=%lu)",
2033 (unsigned long) len);
2037 if (mgmt->u.action.category != WLAN_ACTION_PUBLIC &&
2038 (sta == NULL || !(sta->flags & WLAN_STA_ASSOC))) {
2039 wpa_printf(MSG_DEBUG, "IEEE 802.11: Ignored Action "
2040 "frame (category=%u) from unassociated STA " MACSTR,
2041 MAC2STR(mgmt->sa), mgmt->u.action.category);
2045 #ifdef CONFIG_IEEE80211W
2046 if (sta && (sta->flags & WLAN_STA_MFP) &&
2047 !(mgmt->frame_control & host_to_le16(WLAN_FC_ISWEP)) &&
2048 robust_action_frame(mgmt->u.action.category)) {
2049 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
2050 HOSTAPD_LEVEL_DEBUG,
2051 "Dropped unprotected Robust Action frame from "
2055 #endif /* CONFIG_IEEE80211W */
2058 u16 fc = le_to_host16(mgmt->frame_control);
2059 u16 seq_ctrl = le_to_host16(mgmt->seq_ctrl);
2061 if ((fc & WLAN_FC_RETRY) &&
2062 sta->last_seq_ctrl != WLAN_INVALID_MGMT_SEQ &&
2063 sta->last_seq_ctrl == seq_ctrl &&
2064 sta->last_subtype == WLAN_FC_STYPE_ACTION) {
2065 hostapd_logger(hapd, sta->addr,
2066 HOSTAPD_MODULE_IEEE80211,
2067 HOSTAPD_LEVEL_DEBUG,
2068 "Drop repeated action frame seq_ctrl=0x%x",
2073 sta->last_seq_ctrl = seq_ctrl;
2074 sta->last_subtype = WLAN_FC_STYPE_ACTION;
2077 switch (mgmt->u.action.category) {
2078 #ifdef CONFIG_IEEE80211R
2079 case WLAN_ACTION_FT:
2081 wpa_ft_action_rx(sta->wpa_sm, (u8 *) &mgmt->u.action,
2082 len - IEEE80211_HDRLEN))
2085 #endif /* CONFIG_IEEE80211R */
2086 case WLAN_ACTION_WMM:
2087 hostapd_wmm_action(hapd, mgmt, len);
2089 #ifdef CONFIG_IEEE80211W
2090 case WLAN_ACTION_SA_QUERY:
2091 return hostapd_sa_query_action(hapd, mgmt, len);
2092 #endif /* CONFIG_IEEE80211W */
2094 case WLAN_ACTION_WNM:
2095 ieee802_11_rx_wnm_action_ap(hapd, mgmt, len);
2097 #endif /* CONFIG_WNM */
2098 case WLAN_ACTION_PUBLIC:
2099 case WLAN_ACTION_PROTECTED_DUAL:
2100 #ifdef CONFIG_IEEE80211N
2101 if (mgmt->u.action.u.public_action.action ==
2102 WLAN_PA_20_40_BSS_COEX) {
2103 wpa_printf(MSG_DEBUG,
2104 "HT20/40 coex mgmt frame received from STA "
2105 MACSTR, MAC2STR(mgmt->sa));
2106 hostapd_2040_coex_action(hapd, mgmt, len);
2108 #endif /* CONFIG_IEEE80211N */
2109 if (hapd->public_action_cb) {
2110 hapd->public_action_cb(hapd->public_action_cb_ctx,
2114 if (hapd->public_action_cb2) {
2115 hapd->public_action_cb2(hapd->public_action_cb2_ctx,
2119 if (hapd->public_action_cb || hapd->public_action_cb2)
2122 case WLAN_ACTION_VENDOR_SPECIFIC:
2123 if (hapd->vendor_action_cb) {
2124 if (hapd->vendor_action_cb(hapd->vendor_action_cb_ctx,
2126 hapd->iface->freq) == 0)
2132 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
2133 HOSTAPD_LEVEL_DEBUG,
2134 "handle_action - unknown action category %d or invalid "
2136 mgmt->u.action.category);
2137 if (!(mgmt->da[0] & 0x01) && !(mgmt->u.action.category & 0x80) &&
2138 !(mgmt->sa[0] & 0x01)) {
2139 struct ieee80211_mgmt *resp;
2142 * IEEE 802.11-REVma/D9.0 - 7.3.1.11
2143 * Return the Action frame to the source without change
2144 * except that MSB of the Category set to 1.
2146 wpa_printf(MSG_DEBUG, "IEEE 802.11: Return unknown Action "
2147 "frame back to sender");
2148 resp = os_malloc(len);
2151 os_memcpy(resp, mgmt, len);
2152 os_memcpy(resp->da, resp->sa, ETH_ALEN);
2153 os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
2154 os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
2155 resp->u.action.category |= 0x80;
2157 if (hostapd_drv_send_mlme(hapd, resp, len, 0) < 0) {
2158 wpa_printf(MSG_ERROR, "IEEE 802.11: Failed to send "
2169 * ieee802_11_mgmt - process incoming IEEE 802.11 management frames
2170 * @hapd: hostapd BSS data structure (the BSS to which the management frame was
2172 * @buf: management frame data (starting from IEEE 802.11 header)
2173 * @len: length of frame data in octets
2174 * @fi: meta data about received frame (signal level, etc.)
2176 * Process all incoming IEEE 802.11 management frames. This will be called for
2177 * each frame received from the kernel driver through wlan#ap interface. In
2178 * addition, it can be called to re-inserted pending frames (e.g., when using
2179 * external RADIUS server as an MAC ACL).
2181 int ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
2182 struct hostapd_frame_info *fi)
2184 struct ieee80211_mgmt *mgmt;
2192 mgmt = (struct ieee80211_mgmt *) buf;
2193 fc = le_to_host16(mgmt->frame_control);
2194 stype = WLAN_FC_GET_STYPE(fc);
2196 if (stype == WLAN_FC_STYPE_BEACON) {
2197 handle_beacon(hapd, mgmt, len, fi);
2201 broadcast = mgmt->bssid[0] == 0xff && mgmt->bssid[1] == 0xff &&
2202 mgmt->bssid[2] == 0xff && mgmt->bssid[3] == 0xff &&
2203 mgmt->bssid[4] == 0xff && mgmt->bssid[5] == 0xff;
2207 /* Invitation responses can be sent with the peer MAC as BSSID */
2208 !((hapd->conf->p2p & P2P_GROUP_OWNER) &&
2209 stype == WLAN_FC_STYPE_ACTION) &&
2210 #endif /* CONFIG_P2P */
2212 !(hapd->conf->mesh & MESH_ENABLED) &&
2213 #endif /* CONFIG_MESH */
2214 os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0) {
2215 wpa_printf(MSG_INFO, "MGMT: BSSID=" MACSTR " not our address",
2216 MAC2STR(mgmt->bssid));
2221 if (stype == WLAN_FC_STYPE_PROBE_REQ) {
2222 handle_probe_req(hapd, mgmt, len, fi->ssi_signal);
2226 if (os_memcmp(mgmt->da, hapd->own_addr, ETH_ALEN) != 0) {
2227 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
2228 HOSTAPD_LEVEL_DEBUG,
2229 "MGMT: DA=" MACSTR " not our address",
2235 case WLAN_FC_STYPE_AUTH:
2236 wpa_printf(MSG_DEBUG, "mgmt::auth");
2237 handle_auth(hapd, mgmt, len);
2240 case WLAN_FC_STYPE_ASSOC_REQ:
2241 wpa_printf(MSG_DEBUG, "mgmt::assoc_req");
2242 handle_assoc(hapd, mgmt, len, 0);
2245 case WLAN_FC_STYPE_REASSOC_REQ:
2246 wpa_printf(MSG_DEBUG, "mgmt::reassoc_req");
2247 handle_assoc(hapd, mgmt, len, 1);
2250 case WLAN_FC_STYPE_DISASSOC:
2251 wpa_printf(MSG_DEBUG, "mgmt::disassoc");
2252 handle_disassoc(hapd, mgmt, len);
2255 case WLAN_FC_STYPE_DEAUTH:
2256 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "mgmt::deauth");
2257 handle_deauth(hapd, mgmt, len);
2260 case WLAN_FC_STYPE_ACTION:
2261 wpa_printf(MSG_DEBUG, "mgmt::action");
2262 ret = handle_action(hapd, mgmt, len);
2265 hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
2266 HOSTAPD_LEVEL_DEBUG,
2267 "unknown mgmt frame subtype %d", stype);
2275 static void handle_auth_cb(struct hostapd_data *hapd,
2276 const struct ieee80211_mgmt *mgmt,
2279 u16 auth_alg, auth_transaction, status_code;
2280 struct sta_info *sta;
2283 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
2284 HOSTAPD_LEVEL_NOTICE,
2285 "did not acknowledge authentication response");
2289 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
2290 wpa_printf(MSG_INFO, "handle_auth_cb - too short payload (len=%lu)",
2291 (unsigned long) len);
2295 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
2296 auth_transaction = le_to_host16(mgmt->u.auth.auth_transaction);
2297 status_code = le_to_host16(mgmt->u.auth.status_code);
2299 sta = ap_get_sta(hapd, mgmt->da);
2301 wpa_printf(MSG_INFO, "handle_auth_cb: STA " MACSTR " not found",
2306 if (status_code == WLAN_STATUS_SUCCESS &&
2307 ((auth_alg == WLAN_AUTH_OPEN && auth_transaction == 2) ||
2308 (auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 4))) {
2309 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
2310 HOSTAPD_LEVEL_INFO, "authenticated");
2311 sta->flags |= WLAN_STA_AUTH;
2316 static void hostapd_set_wds_encryption(struct hostapd_data *hapd,
2317 struct sta_info *sta,
2321 struct hostapd_ssid *ssid = &hapd->conf->ssid;
2323 if (hapd->conf->ieee802_1x || hapd->conf->wpa)
2326 for (i = 0; i < 4; i++) {
2327 if (ssid->wep.key[i] &&
2328 hostapd_drv_set_key(ifname_wds, hapd, WPA_ALG_WEP, NULL, i,
2329 i == ssid->wep.idx, NULL, 0,
2330 ssid->wep.key[i], ssid->wep.len[i])) {
2331 wpa_printf(MSG_WARNING,
2332 "Could not set WEP keys for WDS interface; %s",
2340 static void handle_assoc_cb(struct hostapd_data *hapd,
2341 const struct ieee80211_mgmt *mgmt,
2342 size_t len, int reassoc, int ok)
2345 struct sta_info *sta;
2347 struct ieee80211_ht_capabilities ht_cap;
2348 struct ieee80211_vht_capabilities vht_cap;
2350 if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_resp) :
2351 sizeof(mgmt->u.assoc_resp))) {
2352 wpa_printf(MSG_INFO, "handle_assoc_cb(reassoc=%d) - too short payload (len=%lu)",
2353 reassoc, (unsigned long) len);
2357 sta = ap_get_sta(hapd, mgmt->da);
2359 wpa_printf(MSG_INFO, "handle_assoc_cb: STA " MACSTR " not found",
2365 hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
2366 HOSTAPD_LEVEL_DEBUG,
2367 "did not acknowledge association response");
2368 sta->flags &= ~WLAN_STA_ASSOC_REQ_OK;
2373 status = le_to_host16(mgmt->u.reassoc_resp.status_code);
2375 status = le_to_host16(mgmt->u.assoc_resp.status_code);
2377 if (status != WLAN_STATUS_SUCCESS)
2380 /* Stop previous accounting session, if one is started, and allocate
2381 * new session id for the new session. */
2382 accounting_sta_stop(hapd, sta);
2384 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
2386 "associated (aid %d)",
2389 if (sta->flags & WLAN_STA_ASSOC)
2391 sta->flags |= WLAN_STA_ASSOC;
2392 sta->flags &= ~WLAN_STA_WNM_SLEEP_MODE;
2393 if ((!hapd->conf->ieee802_1x && !hapd->conf->wpa && !hapd->conf->osen) ||
2394 sta->auth_alg == WLAN_AUTH_FT) {
2396 * Open, static WEP, or FT protocol; no separate authorization
2399 ap_sta_set_authorized(hapd, sta, 1);
2403 mlme_reassociate_indication(hapd, sta);
2405 mlme_associate_indication(hapd, sta);
2407 #ifdef CONFIG_IEEE80211W
2408 sta->sa_query_timed_out = 0;
2409 #endif /* CONFIG_IEEE80211W */
2412 * Remove the STA entry in order to make sure the STA PS state gets
2413 * cleared and configuration gets updated in case of reassociation back
2416 hostapd_drv_sta_remove(hapd, sta->addr);
2418 #ifdef CONFIG_IEEE80211N
2419 if (sta->flags & WLAN_STA_HT)
2420 hostapd_get_ht_capab(hapd, sta->ht_capabilities, &ht_cap);
2421 #endif /* CONFIG_IEEE80211N */
2422 #ifdef CONFIG_IEEE80211AC
2423 if (sta->flags & WLAN_STA_VHT)
2424 hostapd_get_vht_capab(hapd, sta->vht_capabilities, &vht_cap);
2425 #endif /* CONFIG_IEEE80211AC */
2427 if (hostapd_sta_add(hapd, sta->addr, sta->aid, sta->capability,
2428 sta->supported_rates, sta->supported_rates_len,
2429 sta->listen_interval,
2430 sta->flags & WLAN_STA_HT ? &ht_cap : NULL,
2431 sta->flags & WLAN_STA_VHT ? &vht_cap : NULL,
2432 sta->flags, sta->qosinfo, sta->vht_opmode)) {
2433 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
2434 HOSTAPD_LEVEL_NOTICE,
2435 "Could not add STA to kernel driver");
2437 ap_sta_disconnect(hapd, sta, sta->addr,
2438 WLAN_REASON_DISASSOC_AP_BUSY);
2443 if (sta->flags & WLAN_STA_WDS) {
2445 char ifname_wds[IFNAMSIZ + 1];
2447 ret = hostapd_set_wds_sta(hapd, ifname_wds, sta->addr,
2450 hostapd_set_wds_encryption(hapd, sta, ifname_wds);
2453 if (sta->eapol_sm == NULL) {
2455 * This STA does not use RADIUS server for EAP authentication,
2456 * so bind it to the selected VLAN interface now, since the
2457 * interface selection is not going to change anymore.
2459 if (ap_sta_bind_vlan(hapd, sta) < 0)
2461 } else if (sta->vlan_id) {
2462 /* VLAN ID already set (e.g., by PMKSA caching), so bind STA */
2463 if (ap_sta_bind_vlan(hapd, sta) < 0)
2467 hostapd_set_sta_flags(hapd, sta);
2469 if (sta->auth_alg == WLAN_AUTH_FT)
2470 wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FT);
2472 wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC);
2473 hapd->new_assoc_sta_cb(hapd, sta, !new_assoc);
2475 ieee802_1x_notify_port_enabled(sta->eapol_sm, 1);
2479 static void handle_deauth_cb(struct hostapd_data *hapd,
2480 const struct ieee80211_mgmt *mgmt,
2483 struct sta_info *sta;
2484 if (mgmt->da[0] & 0x01)
2486 sta = ap_get_sta(hapd, mgmt->da);
2488 wpa_printf(MSG_DEBUG, "handle_deauth_cb: STA " MACSTR
2489 " not found", MAC2STR(mgmt->da));
2493 wpa_printf(MSG_DEBUG, "STA " MACSTR " acknowledged deauth",
2494 MAC2STR(sta->addr));
2496 wpa_printf(MSG_DEBUG, "STA " MACSTR " did not acknowledge "
2497 "deauth", MAC2STR(sta->addr));
2499 ap_sta_deauth_cb(hapd, sta);
2503 static void handle_disassoc_cb(struct hostapd_data *hapd,
2504 const struct ieee80211_mgmt *mgmt,
2507 struct sta_info *sta;
2508 if (mgmt->da[0] & 0x01)
2510 sta = ap_get_sta(hapd, mgmt->da);
2512 wpa_printf(MSG_DEBUG, "handle_disassoc_cb: STA " MACSTR
2513 " not found", MAC2STR(mgmt->da));
2517 wpa_printf(MSG_DEBUG, "STA " MACSTR " acknowledged disassoc",
2518 MAC2STR(sta->addr));
2520 wpa_printf(MSG_DEBUG, "STA " MACSTR " did not acknowledge "
2521 "disassoc", MAC2STR(sta->addr));
2523 ap_sta_disassoc_cb(hapd, sta);
2528 * ieee802_11_mgmt_cb - Process management frame TX status callback
2529 * @hapd: hostapd BSS data structure (the BSS from which the management frame
2531 * @buf: management frame data (starting from IEEE 802.11 header)
2532 * @len: length of frame data in octets
2533 * @stype: management frame subtype from frame control field
2534 * @ok: Whether the frame was ACK'ed
2536 void ieee802_11_mgmt_cb(struct hostapd_data *hapd, const u8 *buf, size_t len,
2539 const struct ieee80211_mgmt *mgmt;
2540 mgmt = (const struct ieee80211_mgmt *) buf;
2542 #ifdef CONFIG_TESTING_OPTIONS
2543 if (hapd->ext_mgmt_frame_handling) {
2544 wpa_msg(hapd->msg_ctx, MSG_INFO, "MGMT-TX-STATUS stype=%u ok=%d",
2548 #endif /* CONFIG_TESTING_OPTIONS */
2551 case WLAN_FC_STYPE_AUTH:
2552 wpa_printf(MSG_DEBUG, "mgmt::auth cb");
2553 handle_auth_cb(hapd, mgmt, len, ok);
2555 case WLAN_FC_STYPE_ASSOC_RESP:
2556 wpa_printf(MSG_DEBUG, "mgmt::assoc_resp cb");
2557 handle_assoc_cb(hapd, mgmt, len, 0, ok);
2559 case WLAN_FC_STYPE_REASSOC_RESP:
2560 wpa_printf(MSG_DEBUG, "mgmt::reassoc_resp cb");
2561 handle_assoc_cb(hapd, mgmt, len, 1, ok);
2563 case WLAN_FC_STYPE_PROBE_RESP:
2564 wpa_printf(MSG_EXCESSIVE, "mgmt::proberesp cb");
2566 case WLAN_FC_STYPE_DEAUTH:
2567 wpa_printf(MSG_DEBUG, "mgmt::deauth cb");
2568 handle_deauth_cb(hapd, mgmt, len, ok);
2570 case WLAN_FC_STYPE_DISASSOC:
2571 wpa_printf(MSG_DEBUG, "mgmt::disassoc cb");
2572 handle_disassoc_cb(hapd, mgmt, len, ok);
2574 case WLAN_FC_STYPE_ACTION:
2575 wpa_printf(MSG_DEBUG, "mgmt::action cb");
2578 wpa_printf(MSG_INFO, "unknown mgmt cb frame subtype %d", stype);
2584 int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
2591 int ieee802_11_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
2592 char *buf, size_t buflen)
2599 void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
2600 const u8 *buf, size_t len, int ack)
2602 struct sta_info *sta;
2603 struct hostapd_iface *iface = hapd->iface;
2605 sta = ap_get_sta(hapd, addr);
2606 if (sta == NULL && iface->num_bss > 1) {
2608 for (j = 0; j < iface->num_bss; j++) {
2609 hapd = iface->bss[j];
2610 sta = ap_get_sta(hapd, addr);
2615 if (sta == NULL || !(sta->flags & WLAN_STA_ASSOC))
2617 if (sta->flags & WLAN_STA_PENDING_POLL) {
2618 wpa_printf(MSG_DEBUG, "STA " MACSTR " %s pending "
2619 "activity poll", MAC2STR(sta->addr),
2620 ack ? "ACKed" : "did not ACK");
2622 sta->flags &= ~WLAN_STA_PENDING_POLL;
2625 ieee802_1x_tx_status(hapd, sta, buf, len, ack);
2629 void hostapd_eapol_tx_status(struct hostapd_data *hapd, const u8 *dst,
2630 const u8 *data, size_t len, int ack)
2632 struct sta_info *sta;
2633 struct hostapd_iface *iface = hapd->iface;
2635 sta = ap_get_sta(hapd, dst);
2636 if (sta == NULL && iface->num_bss > 1) {
2638 for (j = 0; j < iface->num_bss; j++) {
2639 hapd = iface->bss[j];
2640 sta = ap_get_sta(hapd, dst);
2645 if (sta == NULL || !(sta->flags & WLAN_STA_ASSOC)) {
2646 wpa_printf(MSG_DEBUG, "Ignore TX status for Data frame to STA "
2647 MACSTR " that is not currently associated",
2652 ieee802_1x_eapol_tx_status(hapd, sta, data, len, ack);
2656 void hostapd_client_poll_ok(struct hostapd_data *hapd, const u8 *addr)
2658 struct sta_info *sta;
2659 struct hostapd_iface *iface = hapd->iface;
2661 sta = ap_get_sta(hapd, addr);
2662 if (sta == NULL && iface->num_bss > 1) {
2664 for (j = 0; j < iface->num_bss; j++) {
2665 hapd = iface->bss[j];
2666 sta = ap_get_sta(hapd, addr);
2673 if (!(sta->flags & WLAN_STA_PENDING_POLL))
2676 wpa_printf(MSG_DEBUG, "STA " MACSTR " ACKed pending "
2677 "activity poll", MAC2STR(sta->addr));
2678 sta->flags &= ~WLAN_STA_PENDING_POLL;
2682 void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
2685 struct sta_info *sta;
2687 sta = ap_get_sta(hapd, src);
2688 if (sta && (sta->flags & WLAN_STA_ASSOC)) {
2689 if (!hapd->conf->wds_sta)
2692 if (wds && !(sta->flags & WLAN_STA_WDS)) {
2694 char ifname_wds[IFNAMSIZ + 1];
2696 wpa_printf(MSG_DEBUG, "Enable 4-address WDS mode for "
2697 "STA " MACSTR " (aid %u)",
2698 MAC2STR(sta->addr), sta->aid);
2699 sta->flags |= WLAN_STA_WDS;
2700 ret = hostapd_set_wds_sta(hapd, ifname_wds,
2701 sta->addr, sta->aid, 1);
2703 hostapd_set_wds_encryption(hapd, sta,
2709 wpa_printf(MSG_DEBUG, "Data/PS-poll frame from not associated STA "
2710 MACSTR, MAC2STR(src));
2711 if (src[0] & 0x01) {
2712 /* Broadcast bit set in SA?! Ignore the frame silently. */
2716 if (sta && (sta->flags & WLAN_STA_ASSOC_REQ_OK)) {
2717 wpa_printf(MSG_DEBUG, "Association Response to the STA has "
2718 "already been sent, but no TX status yet known - "
2719 "ignore Class 3 frame issue with " MACSTR,
2724 if (sta && (sta->flags & WLAN_STA_AUTH))
2725 hostapd_drv_sta_disassoc(
2727 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
2729 hostapd_drv_sta_deauth(
2731 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
2735 #endif /* CONFIG_NATIVE_WINDOWS */