Lines Matching +full:fuzz +full:- +full:seconds
3 * Copyright (c) 2002-2017, Jouni Malinen <j@w1.fi>
60 for (sta = hapd->sta_list; sta; sta = sta->next) { in ap_for_each_sta()
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()
75 s = s->hnext; in ap_get_sta()
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()
108 if (hapd->sta_list == sta) { in ap_sta_list_del()
109 hapd->sta_list = sta->next; in ap_sta_list_del()
113 tmp = hapd->sta_list; in ap_sta_list_del()
114 while (tmp != NULL && tmp->next != sta) in ap_sta_list_del()
115 tmp = tmp->next; 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()
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()
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()
142 while (s->hnext != NULL && in ap_sta_hash_del()
143 !ether_addr_equal(s->hnext->addr, sta->addr)) in ap_sta_hash_del()
144 s = s->hnext; in ap_sta_hash_del()
145 if (s->hnext != NULL) in ap_sta_hash_del()
146 s->hnext = s->hnext->hnext; in ap_sta_hash_del()
149 " from hash table", MAC2STR(sta->addr)); in ap_sta_hash_del()
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()
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()
217 lsta = ap_get_sta(lhapd, psta->addr); in clear_wpa_sm_for_each_partner_link()
219 lsta->wpa_sm = NULL; in clear_wpa_sm_for_each_partner_link()
235 if ((sta->flags & WLAN_STA_WDS) || in ap_free_sta()
236 (sta->flags & WLAN_STA_MULTI_AP && in ap_free_sta()
237 (hapd->conf->multi_ap & BACKHAUL_BSS) && in ap_free_sta()
238 hapd->conf->wds_sta && 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()
246 if (!hapd->iface->driver_ap_teardown && in ap_free_sta()
247 !(sta->flags & WLAN_STA_PREAUTH)) { in ap_free_sta()
249 sta->added_unassoc = 0; 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()
259 hapd->num_sta--; in ap_free_sta()
260 if (sta->nonerp_set) { in ap_free_sta()
261 sta->nonerp_set = 0; in ap_free_sta()
262 hapd->iface->num_sta_non_erp--; in ap_free_sta()
263 if (hapd->iface->num_sta_non_erp == 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()
269 hapd->iface->num_sta_no_short_slot_time--; in ap_free_sta()
270 if (hapd->iface->current_mode && in ap_free_sta()
271 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G in ap_free_sta()
272 && hapd->iface->num_sta_no_short_slot_time == 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()
278 hapd->iface->num_sta_no_short_preamble--; in ap_free_sta()
279 if (hapd->iface->current_mode && in ap_free_sta()
280 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G in ap_free_sta()
281 && hapd->iface->num_sta_no_short_preamble == 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()
287 hapd->iface->num_sta_ht_no_gf--; in ap_free_sta()
290 if (sta->no_ht_set) { in ap_free_sta()
291 sta->no_ht_set = 0; in ap_free_sta()
292 hapd->iface->num_sta_no_ht--; in ap_free_sta()
295 if (sta->ht_20mhz_set) { in ap_free_sta()
296 sta->ht_20mhz_set = 0; in ap_free_sta()
297 hapd->iface->num_sta_ht_20mhz--; 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()
312 hapd->num_sta_no_p2p--; in ap_free_sta()
313 if (hapd->num_sta_no_p2p == 0) in ap_free_sta()
319 if (hostapd_ht_operation_update(hapd->iface) > 0) in ap_free_sta()
324 if (hapd->mesh_sta_free_cb) in ap_free_sta()
325 hapd->mesh_sta_free_cb(hapd, sta); in ap_free_sta()
329 ieee802_11_update_beacons(hapd->iface); in ap_free_sta()
332 __func__, MAC2STR(sta->addr)); 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()
349 /* Release group references in case non-association link STA is removed 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()
359 if (hapd->radius) in ap_free_sta()
360 radius_client_flush_auth(hapd->radius, sta->addr); in ap_free_sta()
365 * sta->wpa_sm->group needs to be released before so that 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()
376 if (hapd->iface->driver_ap_teardown && 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()
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()
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()
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()
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()
485 sta = hapd->sta_list; in hostapd_free_stas()
489 if (sta->flags & WLAN_STA_AUTH) { in hostapd_free_stas()
493 sta = sta->next; in hostapd_free_stas()
495 MAC2STR(prev->addr)); in hostapd_free_stas()
506 sta = hapd->sta_list; in hostapd_free_link_stas()
509 sta = sta->next; in hostapd_free_link_stas()
515 MAC2STR(prev->addr)); in hostapd_free_link_stas()
523 * ap_handle_timer - Per STA timer handler
536 int max_inactivity = hapd->conf->ap_max_inactivity; in ap_handle_timer()
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()
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()
559 * stations that are idle (but keep re-associating). in ap_handle_timer()
561 int fuzz = os_random() % 20; in ap_handle_timer() local
562 inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr); in ap_handle_timer()
563 if (inactive_sec == -1) { in ap_handle_timer()
564 wpa_msg(hapd->msg_ctx, MSG_DEBUG, in ap_handle_timer()
567 MACSTR, MAC2STR(sta->addr)); in ap_handle_timer()
573 next_time = max_inactivity + fuzz; in ap_handle_timer()
574 } else if (inactive_sec == -ENOENT) { in ap_handle_timer()
575 wpa_msg(hapd->msg_ctx, MSG_DEBUG, in ap_handle_timer()
577 MAC2STR(sta->addr)); in ap_handle_timer()
580 sta->timeout_next = STA_DISASSOC; in ap_handle_timer()
584 wpa_msg(hapd->msg_ctx, MSG_DEBUG, in ap_handle_timer()
586 MAC2STR(sta->addr), inactive_sec); in ap_handle_timer()
587 sta->timeout_next = STA_NULLFUNC; in ap_handle_timer()
588 next_time = max_inactivity + fuzz - inactive_sec; in ap_handle_timer()
590 wpa_msg(hapd->msg_ctx, MSG_DEBUG, in ap_handle_timer()
593 MAC2STR(sta->addr), inactive_sec, in ap_handle_timer()
596 if (hapd->conf->skip_inactivity_poll) 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()
604 !hapd->conf->skip_inactivity_poll) { in ap_handle_timer()
605 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR 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()
616 "for " MACSTR " (%lu seconds)", in ap_handle_timer()
617 __func__, MAC2STR(sta->addr), next_time); 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()
633 /* Cannot disassociate not-associated STA, so move in ap_handle_timer()
635 sta->timeout_next = STA_DEAUTH; in ap_handle_timer()
639 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, 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()
661 "for " MACSTR " (%d seconds - AP_DISASSOC_DELAY)", in ap_handle_timer()
662 __func__, MAC2STR(sta->addr), AP_DISASSOC_DELAY); in ap_handle_timer()
669 sta->flags &= ~WLAN_STA_ASSOC; 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()
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()
685 "for " MACSTR " (%d seconds - AP_DEAUTH_DELAY)", in ap_handle_timer()
686 __func__, MAC2STR(sta->addr), AP_DEAUTH_DELAY); 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()
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()
725 hostapd_drv_sta_deauth(hapd, sta->addr, 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()
743 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_sta_replenish_timeout()
745 "to %d seconds", session_timeout); in ap_sta_replenish_timeout()
753 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_sta_session_timeout()
755 "seconds", session_timeout); in ap_sta_session_timeout()
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()
798 int max_inactivity = hapd->conf->ap_max_inactivity; in ap_sta_add()
805 if (hapd->num_sta >= hapd->conf->max_num_sta) { in ap_sta_add()
808 hapd->num_sta, hapd->conf->max_num_sta); in ap_sta_add()
817 sta->acct_interim_interval = hapd->conf->acct_interim_interval; in ap_sta_add()
824 if (!hapd->iface->basic_rates) in ap_sta_add()
826 if (hapd->iface->basic_rates[i] < 0) 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()
835 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_INACTIVITY_TIMER)) { in ap_sta_add()
837 "for " MACSTR " (%d seconds - ap_max_inactivity)", 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()
848 hapd->num_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()
855 sta_track_claim_taxonomy_info(hapd->iface, addr, in ap_sta_add()
856 &sta->probe_ie_taxonomy); in ap_sta_add()
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()
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()
878 return -1; in ap_sta_remove()
880 sta->added_unassoc = 0; in ap_sta_remove()
888 struct hostapd_iface *iface = hapd->iface; in ap_sta_remove_in_other_bss()
891 for (i = 0; i < iface->num_bss; i++) { in ap_sta_remove_in_other_bss()
892 struct hostapd_data *bss = iface->bss[i]; in ap_sta_remove_in_other_bss()
900 sta2 = ap_get_sta(bss, sta->addr); in ap_sta_remove_in_other_bss()
906 hapd->conf->iface, MAC2STR(sta2->addr), in ap_sta_remove_in_other_bss()
907 bss->conf->iface); in ap_sta_remove_in_other_bss()
908 ap_sta_disconnect(bss, sta2, sta2->addr, in ap_sta_remove_in_other_bss()
920 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_disassoc_cb_timeout()
922 mlme_disassociate_indication(hapd, sta, sta->disassoc_reason); in ap_sta_disassoc_cb_timeout()
929 sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ; in ap_sta_disconnect_common()
936 MAC2STR(sta->addr), timeout); in ap_sta_disconnect_common()
943 if (!hapd->conf->mld_ap || 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()
949 wpa_auth_sta_deinit(sta->wpa_sm); in ap_sta_disconnect_common()
952 sta->wpa_sm = NULL; in ap_sta_disconnect_common()
960 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_handle_disassociate()
962 if (hapd->iface->current_mode && in ap_sta_handle_disassociate()
963 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211AD) { 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()
975 sta->disassoc_reason = reason; in ap_sta_handle_disassociate()
976 sta->flags |= WLAN_STA_PENDING_DISASSOC_CB; in ap_sta_handle_disassociate()
978 eloop_register_timeout(hapd->iface->drv_flags & in ap_sta_handle_disassociate()
990 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_deauth_cb_timeout()
992 mlme_deauthenticate_indication(hapd, sta, sta->deauth_reason); in ap_sta_deauth_cb_timeout()
999 if (hapd->iface->current_mode && in ap_sta_handle_deauthenticate()
1000 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211AD) { 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()
1015 sta->deauth_reason = reason; in ap_sta_handle_deauthenticate()
1016 sta->flags |= WLAN_STA_PENDING_DEAUTH_CB; in ap_sta_handle_deauthenticate()
1018 eloop_register_timeout(hapd->iface->drv_flags & in ap_sta_handle_deauthenticate()
1044 interfaces = assoc_hapd->iface->interfaces; in ap_sta_ml_disconnect()
1047 if (!assoc_sta->mld_info.links[link_id].valid) in ap_sta_ml_disconnect()
1050 for (i = 0; i < interfaces->count; i++) { in ap_sta_ml_disconnect()
1053 tmp_hapd = interfaces->iface[i]->bss[0]; in ap_sta_ml_disconnect()
1058 for (tmp_sta = tmp_hapd->sta_list; tmp_sta; in ap_sta_ml_disconnect()
1059 tmp_sta = tmp_sta->next) { in ap_sta_ml_disconnect()
1070 if (tmp_sta->mld_assoc_link_id != in ap_sta_ml_disconnect()
1071 assoc_sta->mld_assoc_link_id || in ap_sta_ml_disconnect()
1072 tmp_sta->aid != assoc_sta->aid) in ap_sta_ml_disconnect()
1126 if (sta && (sta->flags & WLAN_STA_WPS)) { in ap_sta_wps_cancel()
1130 __func__, MAC2STR(sta->addr)); in ap_sta_wps_cancel()
1145 for (vlan = hapd->conf->vlan; vlan; vlan = vlan->next) { in ap_sta_get_free_vlan_id()
1146 if (vlan->vlan_id == vlan_id) { in ap_sta_get_free_vlan_id()
1162 if (hapd->conf->ssid.per_sta_vif && !sta->vlan_id) { in ap_sta_set_vlan()
1164 } else if (hapd->conf->ssid.dynamic_vlan == DYNAMIC_VLAN_DISABLED && in ap_sta_set_vlan()
1165 !hapd->conf->ssid.per_sta_vif && sta->vlan_id) { in ap_sta_set_vlan()
1166 /* sta->vlan_id needs to be reset */ in ap_sta_set_vlan()
1167 } else if (!vlan_compare(vlan_desc, sta->vlan_desc)) { in ap_sta_set_vlan()
1172 if (hapd->conf->ssid.per_sta_vif) { in ap_sta_set_vlan()
1177 for (vlan = hapd->conf->vlan; vlan; vlan = vlan->next) { in ap_sta_set_vlan()
1178 if (vlan->vlan_id == VLAN_ID_WILDCARD) in ap_sta_set_vlan()
1182 hostapd_logger(hapd, sta->addr, in ap_sta_set_vlan()
1187 ret = -1; in ap_sta_set_vlan()
1190 } else if (vlan_desc && vlan_desc->notempty) { in ap_sta_set_vlan()
1191 for (vlan = hapd->conf->vlan; vlan; vlan = vlan->next) { in ap_sta_set_vlan()
1192 if (!vlan_compare(&vlan->vlan_desc, vlan_desc)) in ap_sta_set_vlan()
1194 if (vlan->vlan_id == VLAN_ID_WILDCARD) in ap_sta_set_vlan()
1198 vlan_id = vlan->vlan_id; in ap_sta_set_vlan()
1201 vlan_id = vlan_desc->untagged; in ap_sta_set_vlan()
1202 if (vlan_desc->tagged[0]) { in ap_sta_set_vlan()
1207 hostapd_logger(hapd, sta->addr, in ap_sta_set_vlan()
1211 vlan_desc->untagged, in ap_sta_set_vlan()
1212 vlan_desc->tagged[0] ? "+" : ""); in ap_sta_set_vlan()
1214 ret = -1; in ap_sta_set_vlan()
1219 if (vlan && vlan->vlan_id == VLAN_ID_WILDCARD) { in ap_sta_set_vlan()
1222 hostapd_logger(hapd, sta->addr, in ap_sta_set_vlan()
1226 vlan_desc ? vlan_desc->untagged : -1, in ap_sta_set_vlan()
1227 (vlan_desc && vlan_desc->tagged[0]) ? in ap_sta_set_vlan()
1230 ret = -1; in ap_sta_set_vlan()
1234 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, in ap_sta_set_vlan()
1237 vlan->ifname); in ap_sta_set_vlan()
1238 } else if (vlan && vlan->dynamic_vlan > 0) { in ap_sta_set_vlan()
1239 vlan->dynamic_vlan++; in ap_sta_set_vlan()
1240 hostapd_logger(hapd, sta->addr, in ap_sta_set_vlan()
1244 vlan->ifname); 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()
1264 int old_vlanid = sta->vlan_id_bound; in ap_sta_bind_vlan()
1265 int mld_link_id = -1; in ap_sta_bind_vlan()
1268 if (hapd->conf->mld_ap) in ap_sta_bind_vlan()
1269 mld_link_id = hapd->mld_link_id; 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()
1279 iface = hapd->conf->iface; in ap_sta_bind_vlan()
1280 if (hapd->conf->ssid.vlan[0]) in ap_sta_bind_vlan()
1281 iface = hapd->conf->ssid.vlan; in ap_sta_bind_vlan()
1283 if (sta->vlan_id > 0) { in ap_sta_bind_vlan()
1284 for (vlan = hapd->conf->vlan; vlan; vlan = vlan->next) { in ap_sta_bind_vlan()
1285 if (vlan->vlan_id == sta->vlan_id) in ap_sta_bind_vlan()
1289 iface = vlan->ifname; 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()
1301 !(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_VLAN_OFFLOAD)) { 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()
1306 ret = -1; in ap_sta_bind_vlan()
1308 } else if (vlan && vlan->dynamic_vlan > 0) { in ap_sta_bind_vlan()
1309 vlan->dynamic_vlan++; 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()
1326 wpa_printf(MSG_INFO, "Failed to update VLAN-ID for WPA"); 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()
1353 os_reltime_sub(&now, &sta->sa_query_start, &passed); in ap_check_sa_query_timeout()
1355 if (hapd->conf->assoc_sa_query_max_timeout < tu) { 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()
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()
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()
1412 timeout = hapd->conf->assoc_sa_query_retry_timeout; 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()
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()
1448 ssid = &hapd->conf->ssid; in ap_sta_wpa_get_keyid()
1450 pmk = wpa_auth_get_pmk(sta->wpa_sm, &pmk_len); in ap_sta_wpa_get_keyid()
1454 for (psk = ssid->wpa_psk; psk; psk = psk->next) in ap_sta_wpa_get_keyid()
1455 if (os_memcmp(pmk, psk->psk, PMK_LEN) == 0) in ap_sta_wpa_get_keyid()
1457 if (!psk || !psk->keyid[0]) in ap_sta_wpa_get_keyid()
1460 return psk->keyid; in ap_sta_wpa_get_keyid()
1467 return wpa_auth_get_dpp_pkhash(sta->wpa_sm); in ap_sta_wpa_get_dpp_pkhash()
1474 if (!!authorized == !!(sta->flags & WLAN_STA_AUTHORIZED)) in ap_sta_set_authorized_flag()
1478 int mld_assoc_link_id = -1; 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()
1485 mld_assoc_link_id = -2; in ap_sta_set_authorized_flag()
1488 if (mld_assoc_link_id != -2) 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()
1512 if (hapd->p2p_group == NULL) { in ap_sta_set_authorized_event()
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()
1560 sizeof(dpp_pkhash_buf) - plen, in ap_sta_set_authorized_event()
1564 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s", in ap_sta_set_authorized_event()
1567 if (hapd->msg_ctx_parent && in ap_sta_set_authorized_event()
1568 hapd->msg_ctx_parent != hapd->msg_ctx) in ap_sta_set_authorized_event()
1569 wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO, in ap_sta_set_authorized_event()
1574 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf); in ap_sta_set_authorized_event()
1576 if (hapd->msg_ctx_parent && in ap_sta_set_authorized_event()
1577 hapd->msg_ctx_parent != hapd->msg_ctx) in ap_sta_set_authorized_event()
1578 wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO, in ap_sta_set_authorized_event()
1582 if (hapd->sta_authorized_cb) in ap_sta_set_authorized_event()
1583 hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx, in ap_sta_set_authorized_event()
1584 sta->addr, authorized, dev_addr, in ap_sta_set_authorized_event()
1588 if (hapd->iface->fst) { in ap_sta_set_authorized_event()
1590 fst_notify_peer_connected(hapd->iface->fst, sta->addr); in ap_sta_set_authorized_event()
1592 fst_notify_peer_disconnected(hapd->iface->fst, in ap_sta_set_authorized_event()
1593 sta->addr); in ap_sta_set_authorized_event()
1613 hapd->conf->iface, __func__, MAC2STR(sta->addr), in ap_sta_disconnect()
1617 hapd->conf->iface, __func__, MAC2STR(addr), in ap_sta_disconnect()
1629 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC); 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()
1634 "for " MACSTR " (%d seconds - " in ap_sta_disconnect()
1636 hapd->conf->iface, __func__, MAC2STR(sta->addr), in ap_sta_disconnect()
1641 sta->timeout_next = STA_REMOVE; in ap_sta_disconnect()
1643 if (hapd->iface->current_mode && in ap_sta_disconnect()
1644 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211AD) { 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()
1650 eloop_register_timeout(hapd->iface->drv_flags & 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()
1660 eloop_register_timeout(hapd->iface->drv_flags & in ap_sta_disconnect()
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()
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()
1697 hapd->conf->iface, MAC2STR(sta->addr)); in ap_sta_clear_disconnect_timeouts()
1702 hapd->conf->iface, MAC2STR(sta->addr)); 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()
1747 res = -1; in ap_sta_flags_txt()
1759 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, in ap_sta_delayed_1x_auth_fail_cb()
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()
1776 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, in ap_sta_delayed_1x_auth_fail_disconnect()
1778 " after EAP-Failure in %u ms", MAC2STR(sta->addr), timeout); in ap_sta_delayed_1x_auth_fail_disconnect()
1782 * EAP-Failure TX getting out before this should the driver reorder in ap_sta_delayed_1x_auth_fail_disconnect()
1811 for (tmp_sta = tmp_hapd->sta_list; tmp_sta; in ap_sta_remove_link_sta()
1812 tmp_sta = tmp_sta->next) { in ap_sta_remove_link_sta()
1814 !ether_addr_equal(tmp_sta->addr, sta->addr)) in ap_sta_remove_link_sta()
1840 u8 mld_link_id = hapd->mld_link_id; 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()
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()
1867 return -1; in ap_sta_re_add()
1870 sta->added_unassoc = 1; in ap_sta_re_add()
1884 os_free(info->links[i].resp_sta_profile); in ap_sta_free_sta_profile()
1885 info->links[i].resp_sta_profile = NULL; in ap_sta_free_sta_profile()