Lines Matching refs:sta
44 struct sta_info *sta);
50 static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta);
54 int (*cb)(struct hostapd_data *hapd, struct sta_info *sta, in ap_for_each_sta() argument
58 struct sta_info *sta; in ap_for_each_sta() local
60 for (sta = hapd->sta_list; sta; sta = sta->next) { in ap_for_each_sta()
61 if (cb(hapd, sta, ctx)) in ap_for_each_sta()
69 struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta) in ap_get_sta() argument
73 s = hapd->sta_hash[STA_HASH(sta)]; in ap_get_sta()
74 while (s != NULL && os_memcmp(s->addr, sta, 6) != 0) in ap_get_sta()
83 struct sta_info *sta; in ap_get_sta_p2p() local
85 for (sta = hapd->sta_list; sta; sta = sta->next) { in ap_get_sta_p2p()
88 if (sta->p2p_ie == NULL) in ap_get_sta_p2p()
91 p2p_dev_addr = p2p_get_go_dev_addr(sta->p2p_ie); in ap_get_sta_p2p()
96 return sta; in ap_get_sta_p2p()
104 static void ap_sta_list_del(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_list_del() argument
108 if (hapd->sta_list == sta) { in ap_sta_list_del()
109 hapd->sta_list = sta->next; in ap_sta_list_del()
114 while (tmp != NULL && tmp->next != sta) in ap_sta_list_del()
118 "list.", MAC2STR(sta->addr)); in ap_sta_list_del()
120 tmp->next = sta->next; in ap_sta_list_del()
124 void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_hash_add() argument
126 sta->hnext = hapd->sta_hash[STA_HASH(sta->addr)]; in ap_sta_hash_add()
127 hapd->sta_hash[STA_HASH(sta->addr)] = sta; in ap_sta_hash_add()
131 static void ap_sta_hash_del(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_hash_del() argument
135 s = hapd->sta_hash[STA_HASH(sta->addr)]; in ap_sta_hash_del()
137 if (os_memcmp(s->addr, sta->addr, 6) == 0) { in ap_sta_hash_del()
138 hapd->sta_hash[STA_HASH(sta->addr)] = s->hnext; in ap_sta_hash_del()
143 !ether_addr_equal(s->hnext->addr, sta->addr)) in ap_sta_hash_del()
149 " from hash table", MAC2STR(sta->addr)); in ap_sta_hash_del()
153 void ap_sta_ip6addr_del(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_ip6addr_del() argument
155 sta_ip6addr_del(hapd, sta); in ap_sta_ip6addr_del()
161 void ap_free_sta_pasn(struct hostapd_data *hapd, struct sta_info *sta) in ap_free_sta_pasn() argument
163 if (sta->pasn) { in ap_free_sta_pasn()
165 MAC2STR(sta->addr)); in ap_free_sta_pasn()
167 if (sta->pasn->ecdh) in ap_free_sta_pasn()
168 crypto_ecdh_deinit(sta->pasn->ecdh); in ap_free_sta_pasn()
170 wpabuf_free(sta->pasn->secret); in ap_free_sta_pasn()
171 sta->pasn->secret = NULL; in ap_free_sta_pasn()
174 sae_clear_data(&sta->pasn->sae); in ap_free_sta_pasn()
179 wpabuf_free(sta->pasn->fils.erp_resp); in ap_free_sta_pasn()
180 sta->pasn->fils.erp_resp = NULL; in ap_free_sta_pasn()
183 pasn_data_deinit(sta->pasn); in ap_free_sta_pasn()
184 sta->pasn = NULL; in ap_free_sta_pasn()
191 static void __ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta) in __ap_free_sta() argument
194 if (hostapd_sta_is_link_sta(hapd, sta) && in __ap_free_sta()
195 !hostapd_drv_link_sta_remove(hapd, sta->addr)) in __ap_free_sta()
199 hostapd_drv_sta_remove(hapd, sta->addr); in __ap_free_sta()
225 void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta) in ap_free_sta() argument
229 accounting_sta_stop(hapd, sta); in ap_free_sta()
232 ap_sta_set_authorized(hapd, sta, 0); in ap_free_sta()
233 hostapd_set_sta_flags(hapd, sta); in ap_free_sta()
235 if ((sta->flags & WLAN_STA_WDS) || in ap_free_sta()
236 (sta->flags & WLAN_STA_MULTI_AP && in ap_free_sta()
239 !(sta->flags & WLAN_STA_WPS))) in ap_free_sta()
240 hostapd_set_wds_sta(hapd, NULL, sta->addr, sta->aid, 0); in ap_free_sta()
242 if (sta->ipaddr) in ap_free_sta()
243 hostapd_drv_br_delete_ip_neigh(hapd, 4, (u8 *) &sta->ipaddr); in ap_free_sta()
244 ap_sta_ip6addr_del(hapd, sta); in ap_free_sta()
247 !(sta->flags & WLAN_STA_PREAUTH)) { in ap_free_sta()
248 __ap_free_sta(hapd, sta); in ap_free_sta()
249 sta->added_unassoc = 0; in ap_free_sta()
252 ap_sta_hash_del(hapd, sta); in ap_free_sta()
253 ap_sta_list_del(hapd, sta); in ap_free_sta()
255 if (sta->aid > 0) in ap_free_sta()
256 hapd->sta_aid[(sta->aid - 1) / 32] &= in ap_free_sta()
257 ~BIT((sta->aid - 1) % 32); in ap_free_sta()
260 if (sta->nonerp_set) { in ap_free_sta()
261 sta->nonerp_set = 0; in ap_free_sta()
267 if (sta->no_short_slot_time_set) { in ap_free_sta()
268 sta->no_short_slot_time_set = 0; in ap_free_sta()
276 if (sta->no_short_preamble_set) { in ap_free_sta()
277 sta->no_short_preamble_set = 0; in ap_free_sta()
285 if (sta->no_ht_gf_set) { in ap_free_sta()
286 sta->no_ht_gf_set = 0; in ap_free_sta()
290 if (sta->no_ht_set) { in ap_free_sta()
291 sta->no_ht_set = 0; in ap_free_sta()
295 if (sta->ht_20mhz_set) { in ap_free_sta()
296 sta->ht_20mhz_set = 0; in ap_free_sta()
301 wpabuf_free(sta->probe_ie_taxonomy); in ap_free_sta()
302 sta->probe_ie_taxonomy = NULL; in ap_free_sta()
303 wpabuf_free(sta->assoc_ie_taxonomy); in ap_free_sta()
304 sta->assoc_ie_taxonomy = NULL; in ap_free_sta()
307 ht40_intolerant_remove(hapd->iface, sta); in ap_free_sta()
310 if (sta->no_p2p_set) { in ap_free_sta()
311 sta->no_p2p_set = 0; in ap_free_sta()
325 hapd->mesh_sta_free_cb(hapd, sta); in ap_free_sta()
332 __func__, MAC2STR(sta->addr)); in ap_free_sta()
333 eloop_cancel_timeout(ap_handle_timer, hapd, sta); in ap_free_sta()
334 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta); in ap_free_sta()
335 eloop_cancel_timeout(ap_handle_session_warning_timer, hapd, sta); in ap_free_sta()
336 ap_sta_clear_disconnect_timeouts(hapd, sta); in ap_free_sta()
337 sae_clear_retransmit_timer(hapd, sta); in ap_free_sta()
339 ieee802_1x_free_station(hapd, sta); in ap_free_sta()
342 if (!ap_sta_is_mld(hapd, sta) || in ap_free_sta()
343 hapd->mld_link_id == sta->mld_assoc_link_id) { in ap_free_sta()
344 wpa_auth_sta_deinit(sta->wpa_sm); in ap_free_sta()
346 clear_wpa_sm_for_each_partner_link(hapd, sta); in ap_free_sta()
351 if (hostapd_sta_is_link_sta(hapd, sta)) in ap_free_sta()
352 wpa_release_link_auth_ref(sta->wpa_sm, hapd->mld_link_id); in ap_free_sta()
354 wpa_auth_sta_deinit(sta->wpa_sm); in ap_free_sta()
357 rsn_preauth_free_station(hapd, sta); in ap_free_sta()
360 radius_client_flush_auth(hapd->radius, sta->addr); in ap_free_sta()
369 if (sta->vlan_id) in ap_free_sta()
370 vlan_remove_dynamic(hapd, sta->vlan_id); in ap_free_sta()
371 if (sta->vlan_id_bound) { in ap_free_sta()
377 !(sta->flags & WLAN_STA_PREAUTH)) { in ap_free_sta()
378 hostapd_drv_sta_remove(hapd, sta->addr); in ap_free_sta()
379 sta->added_unassoc = 0; in ap_free_sta()
381 vlan_remove_dynamic(hapd, sta->vlan_id_bound); in ap_free_sta()
385 os_free(sta->challenge); in ap_free_sta()
387 os_free(sta->sa_query_trans_id); in ap_free_sta()
388 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta); in ap_free_sta()
391 p2p_group_notif_disassoc(hapd->p2p_group, sta->addr); in ap_free_sta()
395 if (sta->gas_dialog) { in ap_free_sta()
399 gas_serv_dialog_clear(&sta->gas_dialog[i]); in ap_free_sta()
400 os_free(sta->gas_dialog); in ap_free_sta()
404 wpabuf_free(sta->wps_ie); in ap_free_sta()
405 wpabuf_free(sta->p2p_ie); in ap_free_sta()
406 wpabuf_free(sta->hs20_ie); in ap_free_sta()
407 wpabuf_free(sta->roaming_consortium); in ap_free_sta()
409 wpabuf_free(sta->mb_ies); in ap_free_sta()
412 os_free(sta->ht_capabilities); in ap_free_sta()
413 os_free(sta->vht_capabilities); in ap_free_sta()
414 os_free(sta->vht_operation); in ap_free_sta()
415 os_free(sta->he_capab); in ap_free_sta()
416 os_free(sta->he_6ghz_capab); in ap_free_sta()
417 os_free(sta->eht_capab); in ap_free_sta()
418 hostapd_free_psk_list(sta->psk); in ap_free_sta()
419 os_free(sta->identity); in ap_free_sta()
420 os_free(sta->radius_cui); in ap_free_sta()
421 os_free(sta->remediation_url); in ap_free_sta()
422 os_free(sta->t_c_url); in ap_free_sta()
423 wpabuf_free(sta->hs20_deauth_req); in ap_free_sta()
424 os_free(sta->hs20_session_info_url); in ap_free_sta()
427 sae_clear_data(sta->sae); in ap_free_sta()
428 os_free(sta->sae); in ap_free_sta()
431 mbo_ap_sta_free(sta); in ap_free_sta()
432 os_free(sta->supp_op_classes); in ap_free_sta()
435 os_free(sta->fils_pending_assoc_req); in ap_free_sta()
436 wpabuf_free(sta->fils_hlp_resp); in ap_free_sta()
437 wpabuf_free(sta->hlp_dhcp_discover); in ap_free_sta()
438 eloop_cancel_timeout(fils_hlp_timeout, hapd, sta); in ap_free_sta()
440 crypto_ecdh_deinit(sta->fils_ecdh); in ap_free_sta()
441 wpabuf_clear_free(sta->fils_dh_ss); in ap_free_sta()
442 wpabuf_free(sta->fils_g_sta); in ap_free_sta()
447 bin_clear_free(sta->owe_pmk, sta->owe_pmk_len); in ap_free_sta()
448 crypto_ecdh_deinit(sta->owe_ecdh); in ap_free_sta()
452 dpp_pfs_free(sta->dpp_pfs); in ap_free_sta()
453 sta->dpp_pfs = NULL; in ap_free_sta()
456 os_free(sta->ext_capability); in ap_free_sta()
459 eloop_cancel_timeout(ap_sta_reset_steer_flag_timer, hapd, sta); in ap_free_sta()
463 ap_free_sta_pasn(hapd, sta); in ap_free_sta()
466 os_free(sta->ifname_wds); in ap_free_sta()
469 ap_sta_free_sta_profile(&sta->mld_info); in ap_free_sta()
473 os_free(sta->sae_postponed_commit); in ap_free_sta()
474 forced_memzero(sta->last_tk, WPA_TK_MAX_LEN); in ap_free_sta()
477 os_free(sta); in ap_free_sta()
483 struct sta_info *sta, *prev; in hostapd_free_stas() local
485 sta = hapd->sta_list; in hostapd_free_stas()
487 while (sta) { in hostapd_free_stas()
488 prev = sta; in hostapd_free_stas()
489 if (sta->flags & WLAN_STA_AUTH) { in hostapd_free_stas()
491 hapd, sta, WLAN_REASON_UNSPECIFIED); in hostapd_free_stas()
493 sta = sta->next; in hostapd_free_stas()
504 struct sta_info *sta, *prev; in hostapd_free_link_stas() local
506 sta = hapd->sta_list; in hostapd_free_link_stas()
507 while (sta) { in hostapd_free_link_stas()
508 prev = sta; in hostapd_free_link_stas()
509 sta = sta->next; in hostapd_free_link_stas()
533 struct sta_info *sta = timeout_ctx; in ap_handle_timer() local
539 hapd->conf->iface, __func__, MAC2STR(sta->addr), sta->flags, in ap_handle_timer()
540 sta->timeout_next); in ap_handle_timer()
541 if (sta->timeout_next == STA_REMOVE) { in ap_handle_timer()
542 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_handle_timer()
545 ap_free_sta(hapd, sta); in ap_handle_timer()
549 if (sta->max_idle_period) in ap_handle_timer()
550 max_inactivity = (sta->max_idle_period * 1024 + 999) / 1000; in ap_handle_timer()
552 if ((sta->flags & WLAN_STA_ASSOC) && in ap_handle_timer()
553 (sta->timeout_next == STA_NULLFUNC || in ap_handle_timer()
554 sta->timeout_next == STA_DISASSOC)) { in ap_handle_timer()
562 inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr); in ap_handle_timer()
567 MACSTR, MAC2STR(sta->addr)); in ap_handle_timer()
577 MAC2STR(sta->addr)); in ap_handle_timer()
580 sta->timeout_next = STA_DISASSOC; in ap_handle_timer()
586 MAC2STR(sta->addr), inactive_sec); in ap_handle_timer()
587 sta->timeout_next = STA_NULLFUNC; in ap_handle_timer()
593 MAC2STR(sta->addr), inactive_sec, in ap_handle_timer()
597 sta->timeout_next = STA_DISASSOC; in ap_handle_timer()
601 if ((sta->flags & WLAN_STA_ASSOC) && in ap_handle_timer()
602 sta->timeout_next == STA_DISASSOC && in ap_handle_timer()
603 !(sta->flags & WLAN_STA_PENDING_POLL) && in ap_handle_timer()
606 " has ACKed data poll", MAC2STR(sta->addr)); in ap_handle_timer()
609 sta->timeout_next = STA_NULLFUNC; in ap_handle_timer()
617 __func__, MAC2STR(sta->addr), next_time); in ap_handle_timer()
619 sta); in ap_handle_timer()
623 if (sta->timeout_next == STA_NULLFUNC && in ap_handle_timer()
624 (sta->flags & WLAN_STA_ASSOC)) { in ap_handle_timer()
626 sta->flags |= WLAN_STA_PENDING_POLL; in ap_handle_timer()
627 hostapd_drv_poll_client(hapd, hapd->own_addr, sta->addr, in ap_handle_timer()
628 sta->flags & WLAN_STA_WMM); in ap_handle_timer()
629 } else if (sta->timeout_next != STA_REMOVE) { in ap_handle_timer()
630 int deauth = sta->timeout_next == STA_DEAUTH; in ap_handle_timer()
632 if (!deauth && !(sta->flags & WLAN_STA_ASSOC)) { in ap_handle_timer()
635 sta->timeout_next = STA_DEAUTH; in ap_handle_timer()
642 MAC2STR(sta->addr)); in ap_handle_timer()
646 hapd, sta->addr, in ap_handle_timer()
649 reason = (sta->timeout_next == STA_DISASSOC) ? in ap_handle_timer()
653 hostapd_drv_sta_disassoc(hapd, sta->addr, reason); in ap_handle_timer()
657 switch (sta->timeout_next) { in ap_handle_timer()
659 sta->timeout_next = STA_DISASSOC; in ap_handle_timer()
662 __func__, MAC2STR(sta->addr), AP_DISASSOC_DELAY); in ap_handle_timer()
664 hapd, sta); in ap_handle_timer()
668 ap_sta_set_authorized(hapd, sta, 0); in ap_handle_timer()
669 sta->flags &= ~WLAN_STA_ASSOC; in ap_handle_timer()
670 hostapd_set_sta_flags(hapd, sta); in ap_handle_timer()
671 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0); in ap_handle_timer()
672 if (!sta->acct_terminate_cause) in ap_handle_timer()
673 sta->acct_terminate_cause = in ap_handle_timer()
675 accounting_sta_stop(hapd, sta); in ap_handle_timer()
676 ieee802_1x_free_station(hapd, sta); in ap_handle_timer()
677 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_handle_timer()
680 reason = (sta->timeout_next == STA_DISASSOC) ? in ap_handle_timer()
683 sta->timeout_next = STA_DEAUTH; in ap_handle_timer()
686 __func__, MAC2STR(sta->addr), AP_DEAUTH_DELAY); in ap_handle_timer()
688 hapd, sta); in ap_handle_timer()
689 mlme_disassociate_indication(hapd, sta, reason); in ap_handle_timer()
693 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_handle_timer()
696 if (!sta->acct_terminate_cause) in ap_handle_timer()
697 sta->acct_terminate_cause = in ap_handle_timer()
700 hapd, sta, in ap_handle_timer()
702 ap_free_sta(hapd, sta); in ap_handle_timer()
711 struct sta_info *sta = timeout_ctx; in ap_handle_session_timer() local
714 hapd->conf->iface, MAC2STR(sta->addr)); in ap_handle_session_timer()
715 if (!(sta->flags & (WLAN_STA_AUTH | WLAN_STA_ASSOC | in ap_handle_session_timer()
717 if (sta->flags & WLAN_STA_GAS) { in ap_handle_session_timer()
719 "entry " MACSTR, MAC2STR(sta->addr)); in ap_handle_session_timer()
720 ap_free_sta(hapd, sta); in ap_handle_session_timer()
725 hostapd_drv_sta_deauth(hapd, sta->addr, in ap_handle_session_timer()
727 mlme_deauthenticate_indication(hapd, sta, in ap_handle_session_timer()
729 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_handle_session_timer()
732 sta->acct_terminate_cause = in ap_handle_session_timer()
734 ap_free_sta(hapd, sta); in ap_handle_session_timer()
738 void ap_sta_replenish_timeout(struct hostapd_data *hapd, struct sta_info *sta, in ap_sta_replenish_timeout() argument
742 ap_handle_session_timer, hapd, sta) == 1) { in ap_sta_replenish_timeout()
743 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_sta_replenish_timeout()
750 void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta, in ap_sta_session_timeout() argument
753 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_sta_session_timeout()
756 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta); in ap_sta_session_timeout()
758 hapd, sta); in ap_sta_session_timeout()
762 void ap_sta_no_session_timeout(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_no_session_timeout() argument
764 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta); in ap_sta_no_session_timeout()
772 struct sta_info *sta = timeout_ctx; in ap_handle_session_warning_timer() local
775 MACSTR, hapd->conf->iface, MAC2STR(sta->addr)); in ap_handle_session_warning_timer()
776 if (sta->hs20_session_info_url == NULL) in ap_handle_session_warning_timer()
779 wnm_send_ess_disassoc_imminent(hapd, sta, sta->hs20_session_info_url, in ap_handle_session_warning_timer()
780 sta->hs20_disassoc_timer); in ap_handle_session_warning_timer()
786 struct sta_info *sta, int warning_time) in ap_sta_session_warning_timeout() argument
788 eloop_cancel_timeout(ap_handle_session_warning_timer, hapd, sta); in ap_sta_session_warning_timeout()
790 hapd, sta); in ap_sta_session_warning_timeout()
796 struct sta_info *sta; in ap_sta_add() local
800 sta = ap_get_sta(hapd, addr); in ap_sta_add()
801 if (sta) in ap_sta_add()
802 return sta; in ap_sta_add()
812 sta = os_zalloc(sizeof(struct sta_info)); in ap_sta_add()
813 if (sta == NULL) { in ap_sta_add()
817 sta->acct_interim_interval = hapd->conf->acct_interim_interval; in ap_sta_add()
818 if (accounting_sta_get_id(hapd, sta) < 0) { in ap_sta_add()
819 os_free(sta); in ap_sta_add()
828 sta->supported_rates[i] = hapd->iface->basic_rates[i] / 5; in ap_sta_add()
830 sta->supported_rates_len = i; in ap_sta_add()
832 if (sta->max_idle_period) in ap_sta_add()
833 max_inactivity = (sta->max_idle_period * 1024 + 999) / 1000; in ap_sta_add()
841 ap_handle_timer, hapd, sta); in ap_sta_add()
845 os_memcpy(sta->addr, addr, ETH_ALEN); in ap_sta_add()
846 sta->next = hapd->sta_list; in ap_sta_add()
847 hapd->sta_list = sta; in ap_sta_add()
849 ap_sta_hash_add(hapd, sta); in ap_sta_add()
850 ap_sta_remove_in_other_bss(hapd, sta); in ap_sta_add()
851 sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ; in ap_sta_add()
852 dl_list_init(&sta->ip6addr); in ap_sta_add()
856 &sta->probe_ie_taxonomy); in ap_sta_add()
859 return sta; in ap_sta_add()
863 static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_remove() argument
865 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0); in ap_sta_remove()
867 if (sta->ipaddr) in ap_sta_remove()
868 hostapd_drv_br_delete_ip_neigh(hapd, 4, (u8 *) &sta->ipaddr); in ap_sta_remove()
869 ap_sta_ip6addr_del(hapd, sta); in ap_sta_remove()
872 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_remove()
873 if (hostapd_drv_sta_remove(hapd, sta->addr) && in ap_sta_remove()
874 sta->flags & WLAN_STA_ASSOC) { in ap_sta_remove()
877 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_remove()
880 sta->added_unassoc = 0; in ap_sta_remove()
886 struct sta_info *sta) in ap_sta_remove_in_other_bss() argument
900 sta2 = ap_get_sta(bss, sta->addr); in ap_sta_remove_in_other_bss()
917 struct sta_info *sta = timeout_ctx; in ap_sta_disassoc_cb_timeout() local
920 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_disassoc_cb_timeout()
921 ap_sta_remove(hapd, sta); in ap_sta_disassoc_cb_timeout()
922 mlme_disassociate_indication(hapd, sta, sta->disassoc_reason); in ap_sta_disassoc_cb_timeout()
927 struct sta_info *sta, unsigned int timeout) in ap_sta_disconnect_common() argument
929 sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ; in ap_sta_disconnect_common()
931 ap_sta_set_authorized(hapd, sta, 0); in ap_sta_disconnect_common()
932 hostapd_set_sta_flags(hapd, sta); in ap_sta_disconnect_common()
936 MAC2STR(sta->addr), timeout); in ap_sta_disconnect_common()
938 eloop_cancel_timeout(ap_handle_timer, hapd, sta); in ap_sta_disconnect_common()
939 eloop_register_timeout(timeout, 0, ap_handle_timer, hapd, sta); in ap_sta_disconnect_common()
940 accounting_sta_stop(hapd, sta); in ap_sta_disconnect_common()
941 ieee802_1x_free_station(hapd, sta); in ap_sta_disconnect_common()
944 hapd->mld_link_id == sta->mld_assoc_link_id) { in ap_sta_disconnect_common()
945 wpa_auth_sta_deinit(sta->wpa_sm); in ap_sta_disconnect_common()
946 clear_wpa_sm_for_each_partner_link(hapd, sta); in ap_sta_disconnect_common()
949 wpa_auth_sta_deinit(sta->wpa_sm); in ap_sta_disconnect_common()
952 sta->wpa_sm = NULL; in ap_sta_disconnect_common()
957 struct sta_info *sta, u16 reason) in ap_sta_handle_disassociate() argument
960 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_handle_disassociate()
965 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC | in ap_sta_handle_disassociate()
967 sta->timeout_next = STA_REMOVE; in ap_sta_handle_disassociate()
969 sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK); in ap_sta_handle_disassociate()
970 sta->timeout_next = STA_DEAUTH; in ap_sta_handle_disassociate()
973 ap_sta_disconnect_common(hapd, sta, AP_MAX_INACTIVITY_AFTER_DISASSOC); in ap_sta_handle_disassociate()
975 sta->disassoc_reason = reason; in ap_sta_handle_disassociate()
976 sta->flags |= WLAN_STA_PENDING_DISASSOC_CB; in ap_sta_handle_disassociate()
977 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta); in ap_sta_handle_disassociate()
980 ap_sta_disassoc_cb_timeout, hapd, sta); in ap_sta_handle_disassociate()
987 struct sta_info *sta = timeout_ctx; in ap_sta_deauth_cb_timeout() local
990 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_deauth_cb_timeout()
991 ap_sta_remove(hapd, sta); in ap_sta_deauth_cb_timeout()
992 mlme_deauthenticate_indication(hapd, sta, sta->deauth_reason); in ap_sta_deauth_cb_timeout()
997 struct sta_info *sta, u16 reason) in ap_sta_handle_deauthenticate() argument
1003 ap_sta_disassociate(hapd, sta, reason); in ap_sta_handle_deauthenticate()
1008 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_handle_deauthenticate()
1010 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK); in ap_sta_handle_deauthenticate()
1012 sta->timeout_next = STA_REMOVE; in ap_sta_handle_deauthenticate()
1013 ap_sta_disconnect_common(hapd, sta, AP_MAX_INACTIVITY_AFTER_DEAUTH); in ap_sta_handle_deauthenticate()
1015 sta->deauth_reason = reason; in ap_sta_handle_deauthenticate()
1016 sta->flags |= WLAN_STA_PENDING_DEAUTH_CB; in ap_sta_handle_deauthenticate()
1017 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta); in ap_sta_handle_deauthenticate()
1020 ap_sta_deauth_cb_timeout, hapd, sta); in ap_sta_handle_deauthenticate()
1025 struct sta_info *sta, u16 reason, in ap_sta_ml_disconnect() argument
1041 assoc_sta = hostapd_ml_get_assoc_sta(hapd, sta, &assoc_hapd); in ap_sta_ml_disconnect()
1102 void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta, in ap_sta_disassociate() argument
1105 if (ap_sta_ml_disconnect(hapd, sta, reason, true)) in ap_sta_disassociate()
1108 ap_sta_handle_disassociate(hapd, sta, reason); in ap_sta_disassociate()
1112 void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta, in ap_sta_deauthenticate() argument
1115 if (ap_sta_ml_disconnect(hapd, sta, reason, false)) in ap_sta_deauthenticate()
1118 ap_sta_handle_deauthenticate(hapd, sta, reason); in ap_sta_deauthenticate()
1124 struct sta_info *sta, void *ctx) in ap_sta_wps_cancel() argument
1126 if (sta && (sta->flags & WLAN_STA_WPS)) { in ap_sta_wps_cancel()
1127 ap_sta_deauthenticate(hapd, sta, in ap_sta_wps_cancel()
1130 __func__, MAC2STR(sta->addr)); in ap_sta_wps_cancel()
1155 int ap_sta_set_vlan(struct hostapd_data *hapd, struct sta_info *sta, in ap_sta_set_vlan() argument
1162 if (hapd->conf->ssid.per_sta_vif && !sta->vlan_id) { in ap_sta_set_vlan()
1165 !hapd->conf->ssid.per_sta_vif && sta->vlan_id) { in ap_sta_set_vlan()
1167 } else if (!vlan_compare(vlan_desc, sta->vlan_desc)) { in ap_sta_set_vlan()
1182 hostapd_logger(hapd, sta->addr, in ap_sta_set_vlan()
1207 hostapd_logger(hapd, sta->addr, in ap_sta_set_vlan()
1222 hostapd_logger(hapd, sta->addr, in ap_sta_set_vlan()
1234 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_sta_set_vlan()
1240 hostapd_logger(hapd, sta->addr, in ap_sta_set_vlan()
1247 old_vlan_id = sta->vlan_id; in ap_sta_set_vlan()
1248 sta->vlan_id = vlan_id; in ap_sta_set_vlan()
1249 sta->vlan_desc = vlan ? &vlan->vlan_desc : NULL; in ap_sta_set_vlan()
1258 int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_bind_vlan() argument
1264 int old_vlanid = sta->vlan_id_bound; in ap_sta_bind_vlan()
1272 if ((sta->flags & WLAN_STA_WDS) && sta->vlan_id == 0) { in ap_sta_bind_vlan()
1275 MACSTR, MAC2STR(sta->addr)); in ap_sta_bind_vlan()
1283 if (sta->vlan_id > 0) { in ap_sta_bind_vlan()
1285 if (vlan->vlan_id == sta->vlan_id) in ap_sta_bind_vlan()
1297 if (sta->vlan_id == old_vlanid) in ap_sta_bind_vlan()
1300 if (sta->vlan_id > 0 && !vlan && in ap_sta_bind_vlan()
1302 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_sta_bind_vlan()
1305 sta->vlan_id); in ap_sta_bind_vlan()
1310 hostapd_logger(hapd, sta->addr, in ap_sta_bind_vlan()
1318 sta->vlan_id_bound = sta->vlan_id; in ap_sta_bind_vlan()
1321 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_sta_bind_vlan()
1325 if (wpa_auth_sta_set_vlan(sta->wpa_sm, sta->vlan_id) < 0) in ap_sta_bind_vlan()
1328 ret = hostapd_drv_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id, in ap_sta_bind_vlan()
1331 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_sta_bind_vlan()
1333 "entry to vlan_id=%d", sta->vlan_id); in ap_sta_bind_vlan()
1337 if (old_vlanid > 0 && old_vlanid != sta->vlan_id) in ap_sta_bind_vlan()
1348 int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta) in ap_check_sa_query_timeout() argument
1353 os_reltime_sub(&now, &sta->sa_query_start, &passed); in ap_check_sa_query_timeout()
1356 hostapd_logger(hapd, sta->addr, in ap_check_sa_query_timeout()
1360 sta->sa_query_timed_out = 1; in ap_check_sa_query_timeout()
1361 os_free(sta->sa_query_trans_id); in ap_check_sa_query_timeout()
1362 sta->sa_query_trans_id = NULL; in ap_check_sa_query_timeout()
1363 sta->sa_query_count = 0; in ap_check_sa_query_timeout()
1364 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta); in ap_check_sa_query_timeout()
1375 struct sta_info *sta = timeout_ctx; in ap_sa_query_timer() local
1381 hapd->conf->iface, MAC2STR(sta->addr), sta->sa_query_count); in ap_sa_query_timer()
1383 if (sta->sa_query_count > 0 && in ap_sa_query_timer()
1384 ap_check_sa_query_timeout(hapd, sta)) in ap_sa_query_timer()
1386 if (sta->sa_query_count >= 1000) in ap_sa_query_timer()
1389 nbuf = os_realloc_array(sta->sa_query_trans_id, in ap_sa_query_timer()
1390 sta->sa_query_count + 1, in ap_sa_query_timer()
1394 if (sta->sa_query_count == 0) { in ap_sa_query_timer()
1396 os_get_reltime(&sta->sa_query_start); in ap_sa_query_timer()
1398 trans_id = nbuf + sta->sa_query_count * WLAN_SA_QUERY_TR_ID_LEN; in ap_sa_query_timer()
1399 sta->sa_query_trans_id = nbuf; in ap_sa_query_timer()
1400 sta->sa_query_count++; in ap_sa_query_timer()
1415 eloop_register_timeout(sec, usec, ap_sa_query_timer, hapd, sta); in ap_sa_query_timer()
1417 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_sa_query_timer()
1419 "association SA Query attempt %d", sta->sa_query_count); in ap_sa_query_timer()
1421 ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id); in ap_sa_query_timer()
1425 void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_start_sa_query() argument
1427 ap_sa_query_timer(hapd, sta); in ap_sta_start_sa_query()
1431 void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_stop_sa_query() argument
1433 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta); in ap_sta_stop_sa_query()
1434 os_free(sta->sa_query_trans_id); in ap_sta_stop_sa_query()
1435 sta->sa_query_trans_id = NULL; in ap_sta_stop_sa_query()
1436 sta->sa_query_count = 0; in ap_sta_stop_sa_query()
1441 struct sta_info *sta) in ap_sta_wpa_get_keyid() argument
1450 pmk = wpa_auth_get_pmk(sta->wpa_sm, &pmk_len); in ap_sta_wpa_get_keyid()
1465 struct sta_info *sta) in ap_sta_wpa_get_dpp_pkhash() argument
1467 return wpa_auth_get_dpp_pkhash(sta->wpa_sm); in ap_sta_wpa_get_dpp_pkhash()
1471 bool ap_sta_set_authorized_flag(struct hostapd_data *hapd, struct sta_info *sta, in ap_sta_set_authorized_flag() argument
1474 if (!!authorized == !!(sta->flags & WLAN_STA_AUTHORIZED)) in ap_sta_set_authorized_flag()
1481 if (ap_sta_is_mld(hapd, sta)) { in ap_sta_set_authorized_flag()
1482 if (sta->mld_assoc_link_id == hapd->mld_link_id) in ap_sta_set_authorized_flag()
1483 mld_assoc_link_id = sta->mld_assoc_link_id; in ap_sta_set_authorized_flag()
1489 hostapd_prune_associations(hapd, sta->addr, in ap_sta_set_authorized_flag()
1491 sta->flags |= WLAN_STA_AUTHORIZED; in ap_sta_set_authorized_flag()
1493 sta->flags &= ~WLAN_STA_AUTHORIZED; in ap_sta_set_authorized_flag()
1501 struct sta_info *sta, int authorized) in ap_sta_set_authorized_event() argument
1513 if (sta->p2p_ie != NULL && in ap_sta_set_authorized_event()
1514 p2p_parse_dev_addr_in_p2p_ie(sta->p2p_ie, addr) == 0) in ap_sta_set_authorized_event()
1517 dev_addr = p2p_group_get_dev_addr(hapd->p2p_group, sta->addr); in ap_sta_set_authorized_event()
1521 MAC2STR(sta->addr), MAC2STR(dev_addr)); in ap_sta_set_authorized_event()
1524 os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr)); in ap_sta_set_authorized_event()
1537 if (wpa_auth_get_ip_addr(sta->wpa_sm, ip_addr_buf) == 0) { in ap_sta_set_authorized_event()
1546 keyid = ap_sta_wpa_get_keyid(hapd, sta); in ap_sta_set_authorized_event()
1552 dpp_pkhash = ap_sta_wpa_get_dpp_pkhash(hapd, sta); in ap_sta_set_authorized_event()
1584 sta->addr, authorized, dev_addr, in ap_sta_set_authorized_event()
1590 fst_notify_peer_connected(hapd->iface->fst, sta->addr); in ap_sta_set_authorized_event()
1593 sta->addr); in ap_sta_set_authorized_event()
1599 void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta, in ap_sta_set_authorized() argument
1602 if (!ap_sta_set_authorized_flag(hapd, sta, authorized)) in ap_sta_set_authorized()
1604 ap_sta_set_authorized_event(hapd, sta, authorized); in ap_sta_set_authorized()
1608 void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta, in ap_sta_disconnect() argument
1611 if (sta) in ap_sta_disconnect()
1613 hapd->conf->iface, __func__, MAC2STR(sta->addr), in ap_sta_disconnect()
1620 if (sta == NULL && addr) in ap_sta_disconnect()
1621 sta = ap_get_sta(hapd, addr); in ap_sta_disconnect()
1626 if (sta == NULL) in ap_sta_disconnect()
1628 ap_sta_set_authorized(hapd, sta, 0); in ap_sta_disconnect()
1629 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC); in ap_sta_disconnect()
1630 hostapd_set_sta_flags(hapd, sta); in ap_sta_disconnect()
1631 wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH); in ap_sta_disconnect()
1632 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0); in ap_sta_disconnect()
1636 hapd->conf->iface, __func__, MAC2STR(sta->addr), in ap_sta_disconnect()
1638 eloop_cancel_timeout(ap_handle_timer, hapd, sta); in ap_sta_disconnect()
1640 ap_handle_timer, hapd, sta); in ap_sta_disconnect()
1641 sta->timeout_next = STA_REMOVE; in ap_sta_disconnect()
1647 sta->disassoc_reason = reason; in ap_sta_disconnect()
1648 sta->flags |= WLAN_STA_PENDING_DISASSOC_CB; in ap_sta_disconnect()
1649 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta); in ap_sta_disconnect()
1653 hapd, sta); in ap_sta_disconnect()
1657 sta->deauth_reason = reason; in ap_sta_disconnect()
1658 sta->flags |= WLAN_STA_PENDING_DEAUTH_CB; in ap_sta_disconnect()
1659 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta); in ap_sta_disconnect()
1662 ap_sta_deauth_cb_timeout, hapd, sta); in ap_sta_disconnect()
1666 void ap_sta_deauth_cb(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_deauth_cb() argument
1668 if (!(sta->flags & WLAN_STA_PENDING_DEAUTH_CB)) { in ap_sta_deauth_cb()
1672 sta->flags &= ~WLAN_STA_PENDING_DEAUTH_CB; in ap_sta_deauth_cb()
1673 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta); in ap_sta_deauth_cb()
1674 ap_sta_deauth_cb_timeout(hapd, sta); in ap_sta_deauth_cb()
1678 void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_disassoc_cb() argument
1680 if (!(sta->flags & WLAN_STA_PENDING_DISASSOC_CB)) { in ap_sta_disassoc_cb()
1684 sta->flags &= ~WLAN_STA_PENDING_DISASSOC_CB; in ap_sta_disassoc_cb()
1685 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta); in ap_sta_disassoc_cb()
1686 ap_sta_disassoc_cb_timeout(hapd, sta); in ap_sta_disassoc_cb()
1691 struct sta_info *sta) in ap_sta_clear_disconnect_timeouts() argument
1693 if (eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta) > 0) in ap_sta_clear_disconnect_timeouts()
1697 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_clear_disconnect_timeouts()
1698 if (eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta) > 0) in ap_sta_clear_disconnect_timeouts()
1702 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_clear_disconnect_timeouts()
1703 if (eloop_cancel_timeout(ap_sta_delayed_1x_auth_fail_cb, hapd, sta) > 0) in ap_sta_clear_disconnect_timeouts()
1708 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_clear_disconnect_timeouts()
1709 if (sta->flags & WLAN_STA_WPS) in ap_sta_clear_disconnect_timeouts()
1756 struct sta_info *sta = timeout_ctx; in ap_sta_delayed_1x_auth_fail_cb() local
1761 " after EAP-Failure", MAC2STR(sta->addr)); in ap_sta_delayed_1x_auth_fail_cb()
1763 reason = sta->disconnect_reason_code; in ap_sta_delayed_1x_auth_fail_cb()
1766 ap_sta_disconnect(hapd, sta, sta->addr, reason); in ap_sta_delayed_1x_auth_fail_cb()
1767 if (sta->flags & WLAN_STA_WPS) in ap_sta_delayed_1x_auth_fail_cb()
1773 struct sta_info *sta, in ap_sta_delayed_1x_auth_fail_disconnect() argument
1778 " after EAP-Failure in %u ms", MAC2STR(sta->addr), timeout); in ap_sta_delayed_1x_auth_fail_disconnect()
1785 eloop_cancel_timeout(ap_sta_delayed_1x_auth_fail_cb, hapd, sta); in ap_sta_delayed_1x_auth_fail_disconnect()
1787 ap_sta_delayed_1x_auth_fail_cb, hapd, sta); in ap_sta_delayed_1x_auth_fail_disconnect()
1792 struct sta_info *sta) in ap_sta_pending_delayed_1x_auth_fail_disconnect() argument
1795 hapd, sta); in ap_sta_pending_delayed_1x_auth_fail_disconnect()
1801 struct sta_info *sta) in ap_sta_remove_link_sta() argument
1813 if (tmp_sta == sta || in ap_sta_remove_link_sta()
1814 !ether_addr_equal(tmp_sta->addr, sta->addr)) in ap_sta_remove_link_sta()
1825 int ap_sta_re_add(struct hostapd_data *hapd, struct sta_info *sta) in ap_sta_re_add() argument
1839 if (ap_sta_is_mld(hapd, sta)) { in ap_sta_re_add()
1842 mld_link_sta = sta->mld_assoc_link_id != mld_link_id; in ap_sta_re_add()
1843 mld_link_addr = sta->mld_info.links[mld_link_id].peer_addr; in ap_sta_re_add()
1849 ap_sta_remove_link_sta(hapd, sta); in ap_sta_re_add()
1853 ap_sta_set_authorized(hapd, sta, 0); in ap_sta_re_add()
1854 hostapd_drv_sta_remove(hapd, sta->addr); in ap_sta_re_add()
1855 sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_AUTH | WLAN_STA_AUTHORIZED); in ap_sta_re_add()
1857 if (hostapd_sta_add(hapd, sta->addr, 0, 0, in ap_sta_re_add()
1858 sta->supported_rates, in ap_sta_re_add()
1859 sta->supported_rates_len, in ap_sta_re_add()
1861 sta->flags, 0, 0, 0, 0, in ap_sta_re_add()
1863 hostapd_logger(hapd, sta->addr, in ap_sta_re_add()
1870 sta->added_unassoc = 1; in ap_sta_re_add()