Lines Matching +full:multi +full:- +full:attr
3 * Copyright (c) 2002-2021, Jouni Malinen <j@w1.fi>
84 for (i = 0; i < interfaces->count; i++) { in hostapd_for_each_interface()
85 if (!interfaces->iface[i]) in hostapd_for_each_interface()
87 ret = cb(interfaces->iface[i], ctx); in hostapd_for_each_interface()
98 if (hapd->iconf->mbssid) in hostapd_mbssid_get_tx_bss()
99 return hapd->iface->bss[0]; in hostapd_mbssid_get_tx_bss()
107 if (hapd->iconf->mbssid) { in hostapd_mbssid_get_bss_index()
110 for (i = 1; i < hapd->iface->num_bss; i++) in hostapd_mbssid_get_bss_index()
111 if (hapd->iface->bss[i] == hapd) in hostapd_mbssid_get_bss_index()
121 if (hapd->wpa_auth) in hostapd_reconfig_encryption()
126 hostapd_setup_encryption(hapd->conf->iface, hapd); in hostapd_reconfig_encryption()
135 if (!hapd->started) in hostapd_reload_bss()
138 if (hapd->conf->wmm_enabled < 0) in hostapd_reload_bss()
139 hapd->conf->wmm_enabled = hapd->iconf->ieee80211n | in hostapd_reload_bss()
140 hapd->iconf->ieee80211ax; in hostapd_reload_bss()
143 radius_client_reconfig(hapd->radius, hapd->conf->radius); in hostapd_reload_bss()
146 ssid = &hapd->conf->ssid; in hostapd_reload_bss()
147 if (!ssid->wpa_psk_set && ssid->wpa_psk && !ssid->wpa_psk->next && in hostapd_reload_bss()
148 ssid->wpa_passphrase_set && ssid->wpa_passphrase) { in hostapd_reload_bss()
153 hostapd_config_clear_wpa_psk(&hapd->conf->ssid.wpa_psk); in hostapd_reload_bss()
155 if (hostapd_setup_wpa_psk(hapd->conf)) { in hostapd_reload_bss()
156 wpa_printf(MSG_ERROR, "Failed to re-configure WPA PSK " in hostapd_reload_bss()
160 if (hapd->conf->ieee802_1x || hapd->conf->wpa) in hostapd_reload_bss()
161 hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 1); in hostapd_reload_bss()
163 hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 0); in hostapd_reload_bss()
165 if ((hapd->conf->wpa || hapd->conf->osen) && hapd->wpa_auth == NULL) { in hostapd_reload_bss()
167 if (hapd->wpa_auth) in hostapd_reload_bss()
168 wpa_init_keys(hapd->wpa_auth); in hostapd_reload_bss()
169 } else if (hapd->conf->wpa) { in hostapd_reload_bss()
173 wpa_ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &wpa_ie_len); in hostapd_reload_bss()
177 } else if (hapd->wpa_auth) { in hostapd_reload_bss()
178 wpa_deinit(hapd->wpa_auth); in hostapd_reload_bss()
179 hapd->wpa_auth = NULL; in hostapd_reload_bss()
182 hostapd_setup_encryption(hapd->conf->iface, hapd); in hostapd_reload_bss()
192 if (hapd->conf->ssid.ssid_set && in hostapd_reload_bss()
193 hostapd_set_ssid(hapd, hapd->conf->ssid.ssid, in hostapd_reload_bss()
194 hapd->conf->ssid.ssid_len)) { in hostapd_reload_bss()
198 wpa_printf(MSG_DEBUG, "Reconfigured interface %s", hapd->conf->iface); in hostapd_reload_bss()
204 wpa_printf(MSG_DEBUG, "BSS %s changed - clear old state", in hostapd_clear_old_bss()
205 bss->conf->iface); in hostapd_clear_old_bss()
219 radius_client_flush(bss->radius, 0); in hostapd_clear_old_bss()
228 for (j = 0; j < iface->num_bss; j++) in hostapd_clear_old()
229 hostapd_clear_old_bss(iface->bss[j]); in hostapd_clear_old()
238 if (newconf->num_bss != oldconf->num_bss) in hostapd_iface_conf_changed()
241 for (i = 0; i < newconf->num_bss; i++) { in hostapd_iface_conf_changed()
242 if (os_strcmp(newconf->bss[i]->iface, in hostapd_iface_conf_changed()
243 oldconf->bss[i]->iface) != 0) in hostapd_iface_conf_changed()
253 struct hapd_interfaces *interfaces = iface->interfaces; in hostapd_reload_config()
254 struct hostapd_data *hapd = iface->bss[0]; in hostapd_reload_config()
258 if (iface->config_fname == NULL) { in hostapd_reload_config()
259 /* Only in-memory config in use - assume it has been updated */ in hostapd_reload_config()
261 for (j = 0; j < iface->num_bss; j++) in hostapd_reload_config()
262 hostapd_reload_bss(iface->bss[j]); in hostapd_reload_config()
266 if (iface->interfaces == NULL || in hostapd_reload_config()
267 iface->interfaces->config_read_cb == NULL) in hostapd_reload_config()
268 return -1; in hostapd_reload_config()
269 newconf = iface->interfaces->config_read_cb(iface->config_fname); in hostapd_reload_config()
271 return -1; in hostapd_reload_config()
273 oldconf = hapd->iconf; in hostapd_reload_config()
281 … "Configuration changes include interface/BSS modification - force full disable+enable sequence"); in hostapd_reload_config()
282 fname = os_strdup(iface->config_fname); in hostapd_reload_config()
285 return -1; in hostapd_reload_config()
287 hostapd_remove_iface(interfaces, hapd->conf->iface); in hostapd_reload_config()
294 return -1; in hostapd_reload_config()
296 iface->interfaces = interfaces; in hostapd_reload_config()
297 interfaces->iface[interfaces->count] = iface; in hostapd_reload_config()
298 interfaces->count++; in hostapd_reload_config()
305 iface->conf = newconf; in hostapd_reload_config()
307 for (j = 0; j < iface->num_bss; j++) { in hostapd_reload_config()
308 hapd = iface->bss[j]; in hostapd_reload_config()
309 if (!hapd->conf->config_id || !newconf->bss[j]->config_id || in hostapd_reload_config()
310 os_strcmp(hapd->conf->config_id, in hostapd_reload_config()
311 newconf->bss[j]->config_id) != 0) in hostapd_reload_config()
313 hapd->iconf = newconf; in hostapd_reload_config()
314 hapd->iconf->channel = oldconf->channel; in hostapd_reload_config()
315 hapd->iconf->acs = oldconf->acs; in hostapd_reload_config()
316 hapd->iconf->secondary_channel = oldconf->secondary_channel; in hostapd_reload_config()
317 hapd->iconf->ieee80211n = oldconf->ieee80211n; in hostapd_reload_config()
318 hapd->iconf->ieee80211ac = oldconf->ieee80211ac; in hostapd_reload_config()
319 hapd->iconf->ht_capab = oldconf->ht_capab; in hostapd_reload_config()
320 hapd->iconf->vht_capab = oldconf->vht_capab; in hostapd_reload_config()
321 hostapd_set_oper_chwidth(hapd->iconf, in hostapd_reload_config()
324 hapd->iconf, in hostapd_reload_config()
327 hapd->iconf, in hostapd_reload_config()
329 hapd->conf = newconf->bss[j]; in hostapd_reload_config()
347 if (!ifname || !hapd->drv_priv) in hostapd_broadcast_key_clear_iface()
357 if (hapd->conf->ieee80211w) { in hostapd_broadcast_key_clear_iface()
373 hostapd_broadcast_key_clear_iface(hapd, hapd->conf->iface); in hostapd_broadcast_wep_clear()
381 struct hostapd_ssid *ssid = &hapd->conf->ssid; in hostapd_broadcast_wep_set()
383 idx = ssid->wep.idx; in hostapd_broadcast_wep_set()
384 if (ssid->wep.default_len && ssid->wep.key[idx] && in hostapd_broadcast_wep_set()
385 hostapd_drv_set_key(hapd->conf->iface, in hostapd_broadcast_wep_set()
387 1, NULL, 0, ssid->wep.key[idx], in hostapd_broadcast_wep_set()
388 ssid->wep.len[idx], in hostapd_broadcast_wep_set()
410 if (hapd->eht_mld_link_removal_count == 0) in hostapd_link_remove_timeout_handler()
412 hapd->eht_mld_link_removal_count--; in hostapd_link_remove_timeout_handler()
415 hapd->mld_link_id, in hostapd_link_remove_timeout_handler()
416 hapd->eht_mld_link_removal_count); in hostapd_link_remove_timeout_handler()
420 if (!hapd->eht_mld_link_removal_count) { in hostapd_link_remove_timeout_handler()
422 hostapd_disable_iface(hapd->iface); in hostapd_link_remove_timeout_handler()
426 eloop_register_timeout(0, TU_TO_USEC(hapd->iconf->beacon_int), in hostapd_link_remove_timeout_handler()
434 if (!hapd->conf->mld_ap) in hostapd_link_remove()
435 return -1; in hostapd_link_remove()
439 hapd->mld_link_id, count); in hostapd_link_remove()
441 hapd->eht_mld_link_removal_count = count; in hostapd_link_remove()
442 hapd->eht_mld_bss_param_change++; in hostapd_link_remove()
444 eloop_register_timeout(0, TU_TO_USEC(hapd->iconf->beacon_int), in hostapd_link_remove()
458 os_free(hapd->probereq_cb); in hostapd_free_hapd_data()
459 hapd->probereq_cb = NULL; in hostapd_free_hapd_data()
460 hapd->num_probereq_cb = 0; in hostapd_free_hapd_data()
463 wpabuf_free(hapd->p2p_beacon_ie); in hostapd_free_hapd_data()
464 hapd->p2p_beacon_ie = NULL; in hostapd_free_hapd_data()
465 wpabuf_free(hapd->p2p_probe_resp_ie); in hostapd_free_hapd_data()
466 hapd->p2p_probe_resp_ie = NULL; in hostapd_free_hapd_data()
469 if (!hapd->started) { in hostapd_free_hapd_data()
471 __func__, hapd->conf ? hapd->conf->iface : "N/A"); in hostapd_free_hapd_data()
474 hapd->started = 0; in hostapd_free_hapd_data()
475 hapd->beacon_set_done = 0; in hostapd_free_hapd_data()
477 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface); in hostapd_free_hapd_data()
485 struct hapd_interfaces *ifaces = hapd->iface->interfaces; in hostapd_free_hapd_data()
488 for (i = 0; i < ifaces->count; i++) { in hostapd_free_hapd_data()
489 struct hostapd_iface *iface = ifaces->iface[i]; in hostapd_free_hapd_data()
492 for (j = 0; iface && j < iface->num_bss; j++) { in hostapd_free_hapd_data()
493 struct hostapd_data *h = iface->bss[j]; in hostapd_free_hapd_data()
497 if (h->radius == hapd->radius) in hostapd_free_hapd_data()
498 h->radius = NULL; in hostapd_free_hapd_data()
499 if (h->radius_das == hapd->radius_das) in hostapd_free_hapd_data()
500 h->radius_das = NULL; in hostapd_free_hapd_data()
504 radius_client_deinit(hapd->radius); in hostapd_free_hapd_data()
505 radius_das_deinit(hapd->radius_das); in hostapd_free_hapd_data()
507 hapd->radius = NULL; in hostapd_free_hapd_data()
508 hapd->radius_das = NULL; in hostapd_free_hapd_data()
515 gas_query_ap_deinit(hapd->gas); in hostapd_free_hapd_data()
516 hapd->gas = NULL; in hostapd_free_hapd_data()
524 if (hapd->interface_added) { in hostapd_free_hapd_data()
525 hapd->interface_added = 0; in hostapd_free_hapd_data()
526 if (hostapd_if_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface)) { in hostapd_free_hapd_data()
529 hapd->conf->iface); in hostapd_free_hapd_data()
530 hapd->interface_added = 1; in hostapd_free_hapd_data()
535 * and hapd->drv_priv is not valid anymore. in hostapd_free_hapd_data()
537 hapd->drv_priv = NULL; in hostapd_free_hapd_data()
545 if (hapd->conf->mld_ap && !hapd->interface_added && in hostapd_free_hapd_data()
546 hapd->iface->bss[0] != hapd) in hostapd_free_hapd_data()
547 hostapd_if_link_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface, in hostapd_free_hapd_data()
548 hapd->mld_link_id); in hostapd_free_hapd_data()
551 wpabuf_free(hapd->time_adv); in hostapd_free_hapd_data()
552 hapd->time_adv = NULL; in hostapd_free_hapd_data()
564 bin_clear_free(hapd->tmp_eap_user.identity, in hostapd_free_hapd_data()
565 hapd->tmp_eap_user.identity_len); in hostapd_free_hapd_data()
566 bin_clear_free(hapd->tmp_eap_user.password, in hostapd_free_hapd_data()
567 hapd->tmp_eap_user.password_len); in hostapd_free_hapd_data()
568 os_memset(&hapd->tmp_eap_user, 0, sizeof(hapd->tmp_eap_user)); in hostapd_free_hapd_data()
572 wpabuf_free(hapd->mesh_pending_auth); in hostapd_free_hapd_data()
573 hapd->mesh_pending_auth = NULL; in hostapd_free_hapd_data()
575 hapd->setup_complete_cb = NULL; in hostapd_free_hapd_data()
591 while ((q = dl_list_first(&hapd->sae_commit_queue, in hostapd_free_hapd_data()
594 dl_list_del(&q->list); in hostapd_free_hapd_data()
613 /* hostapd_bss_link_deinit - Per-BSS ML cleanup (deinitialization)
623 if (!hapd->conf || !hapd->conf->mld_ap) in hostapd_bss_link_deinit()
626 if (!hapd->mld->num_links) in hostapd_bss_link_deinit()
633 if (!hapd->started && hapd->iface->bss[0] != hapd) in hostapd_bss_link_deinit()
640 if (hapd->iface->bss[0] == hapd && !hapd->drv_priv) in hostapd_bss_link_deinit()
649 * hostapd_cleanup - Per-BSS cleanup (deinitialization)
652 * This function is used to free all per-BSS data structures and resources.
659 hapd->conf ? hapd->conf->iface : "N/A"); in hostapd_cleanup()
660 if (hapd->iface->interfaces && in hostapd_cleanup()
661 hapd->iface->interfaces->ctrl_iface_deinit) { in hostapd_cleanup()
662 wpa_msg(hapd->msg_ctx, MSG_INFO, WPA_EVENT_TERMINATING); in hostapd_cleanup()
663 hapd->iface->interfaces->ctrl_iface_deinit(hapd); in hostapd_cleanup()
673 if (!iface->num_sta_seen) in sta_track_deinit()
676 while ((info = dl_list_first(&iface->sta_seen, struct hostapd_sta_info, in sta_track_deinit()
678 dl_list_del(&info->list); in sta_track_deinit()
679 iface->num_sta_seen--; in sta_track_deinit()
692 if (iface->current_mode) in hostapd_cleanup_iface_partial()
694 hostapd_free_hw_features(iface->hw_features, iface->num_hw_features); in hostapd_cleanup_iface_partial()
695 iface->hw_features = NULL; in hostapd_cleanup_iface_partial()
696 iface->current_mode = NULL; in hostapd_cleanup_iface_partial()
697 os_free(iface->current_rates); in hostapd_cleanup_iface_partial()
698 iface->current_rates = NULL; in hostapd_cleanup_iface_partial()
699 os_free(iface->basic_rates); in hostapd_cleanup_iface_partial()
700 iface->basic_rates = NULL; in hostapd_cleanup_iface_partial()
701 iface->cac_started = 0; in hostapd_cleanup_iface_partial()
709 * hostapd_cleanup_iface - Complete per-interface cleanup
712 * This function is called after per-BSS data structures are deinitialized
722 hostapd_config_free(iface->conf); in hostapd_cleanup_iface()
723 iface->conf = NULL; in hostapd_cleanup_iface()
725 os_free(iface->config_fname); in hostapd_cleanup_iface()
726 os_free(iface->bss); in hostapd_cleanup_iface()
736 if (hapd->drv_priv && !hapd->iface->driver_ap_teardown && hapd->conf) { in hostapd_clear_wep()
749 if (hapd->conf->ssid.wep.default_len) { in hostapd_setup_encryption()
758 hostapd_drv_set_authmode(hapd, hapd->conf->auth_algs); in hostapd_setup_encryption()
761 if (hapd->conf->ssid.wep.key[i] && in hostapd_setup_encryption()
763 i == hapd->conf->ssid.wep.idx, NULL, 0, in hostapd_setup_encryption()
764 hapd->conf->ssid.wep.key[i], in hostapd_setup_encryption()
765 hapd->conf->ssid.wep.len[i], in hostapd_setup_encryption()
766 i == hapd->conf->ssid.wep.idx ? in hostapd_setup_encryption()
771 return -1; in hostapd_setup_encryption()
773 if (hapd->conf->ssid.wep.key[i] && in hostapd_setup_encryption()
774 i == hapd->conf->ssid.wep.idx) in hostapd_setup_encryption()
789 if (hostapd_drv_none(hapd) || hapd->drv_priv == NULL) in hostapd_flush_old_stations()
792 if (!hapd->iface->driver_ap_teardown) { in hostapd_flush_old_stations()
793 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, in hostapd_flush_old_stations()
797 wpa_msg(hapd->msg_ctx, MSG_WARNING, in hostapd_flush_old_stations()
799 ret = -1; in hostapd_flush_old_stations()
802 if (hapd->conf && hapd->conf->broadcast_deauth) { in hostapd_flush_old_stations()
803 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, in hostapd_flush_old_stations()
825 * hostapd_validate_bssid_configuration - Validate BSSID configuration
827 * Returns: 0 on success, -1 on failure
834 struct hostapd_data *hapd = iface->bss[0]; in hostapd_validate_bssid_configuration()
835 unsigned int i = iface->conf->num_bss, bits = 0, j; in hostapd_validate_bssid_configuration()
841 if (iface->conf->use_driver_iface_addr) in hostapd_validate_bssid_configuration()
847 for (i--; i; i >>= 1) in hostapd_validate_bssid_configuration()
852 for (j = 0; j < iface->conf->num_bss; j++) { in hostapd_validate_bssid_configuration()
853 if (is_zero_ether_addr(iface->conf->bss[j]->bssid)) { in hostapd_validate_bssid_configuration()
861 iface->conf->bss[j]->bssid[i] ^ in hostapd_validate_bssid_configuration()
862 hapd->own_addr[i]; in hostapd_validate_bssid_configuration()
873 j = (5 - i) * 8; in hostapd_validate_bssid_configuration()
887 return -1; in hostapd_validate_bssid_configuration()
892 for (i = 5; i > 5 - j; i--) in hostapd_validate_bssid_configuration()
896 j--; in hostapd_validate_bssid_configuration()
902 (unsigned long) iface->conf->num_bss, MAC2STR(mask), bits); in hostapd_validate_bssid_configuration()
908 if ((hapd->own_addr[i] & mask[i]) != hapd->own_addr[i]) { in hostapd_validate_bssid_configuration()
911 MAC2STR(mask), MAC2STR(hapd->own_addr)); in hostapd_validate_bssid_configuration()
915 return -1; in hostapd_validate_bssid_configuration()
927 for (i = 0; i < conf->num_bss; i++) { in mac_in_conf()
928 if (hostapd_mac_comp(conf->bss[i]->bssid, a) == 0) { in mac_in_conf()
940 struct radius_das_attrs *attr) in hostapd_das_nas_mismatch() argument
942 if (attr->nas_identifier && in hostapd_das_nas_mismatch()
943 (!hapd->conf->nas_identifier || in hostapd_das_nas_mismatch()
944 os_strlen(hapd->conf->nas_identifier) != in hostapd_das_nas_mismatch()
945 attr->nas_identifier_len || in hostapd_das_nas_mismatch()
946 os_memcmp(hapd->conf->nas_identifier, attr->nas_identifier, in hostapd_das_nas_mismatch()
947 attr->nas_identifier_len) != 0)) { in hostapd_das_nas_mismatch()
948 wpa_printf(MSG_DEBUG, "RADIUS DAS: NAS-Identifier mismatch"); in hostapd_das_nas_mismatch()
952 if (attr->nas_ip_addr && in hostapd_das_nas_mismatch()
953 (hapd->conf->own_ip_addr.af != AF_INET || in hostapd_das_nas_mismatch()
954 os_memcmp(&hapd->conf->own_ip_addr.u.v4, attr->nas_ip_addr, 4) != in hostapd_das_nas_mismatch()
956 wpa_printf(MSG_DEBUG, "RADIUS DAS: NAS-IP-Address mismatch"); in hostapd_das_nas_mismatch()
961 if (attr->nas_ipv6_addr && in hostapd_das_nas_mismatch()
962 (hapd->conf->own_ip_addr.af != AF_INET6 || in hostapd_das_nas_mismatch()
963 os_memcmp(&hapd->conf->own_ip_addr.u.v6, attr->nas_ipv6_addr, 16) in hostapd_das_nas_mismatch()
965 wpa_printf(MSG_DEBUG, "RADIUS DAS: NAS-IPv6-Address mismatch"); in hostapd_das_nas_mismatch()
975 struct radius_das_attrs *attr, in hostapd_das_find_sta() argument
976 int *multi) in hostapd_das_find_sta() argument
983 *multi = 0; in hostapd_das_find_sta()
985 for (sta = hapd->sta_list; sta; sta = sta->next) in hostapd_das_find_sta()
986 sta->radius_das_match = 1; in hostapd_das_find_sta()
988 if (attr->sta_addr) { in hostapd_das_find_sta()
990 sta = ap_get_sta(hapd, attr->sta_addr); in hostapd_das_find_sta()
993 "RADIUS DAS: No Calling-Station-Id match"); in hostapd_das_find_sta()
998 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1000 sta->radius_das_match = 0; in hostapd_das_find_sta()
1002 wpa_printf(MSG_DEBUG, "RADIUS DAS: Calling-Station-Id match"); in hostapd_das_find_sta()
1005 if (attr->acct_session_id) { in hostapd_das_find_sta()
1007 if (attr->acct_session_id_len != 16) { in hostapd_das_find_sta()
1009 "RADIUS DAS: Acct-Session-Id cannot match"); in hostapd_das_find_sta()
1014 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1015 if (!sta->radius_das_match) in hostapd_das_find_sta()
1018 (unsigned long long) sta->acct_session_id); in hostapd_das_find_sta()
1019 if (os_memcmp(attr->acct_session_id, buf, 16) != 0) in hostapd_das_find_sta()
1020 sta->radius_das_match = 0; in hostapd_das_find_sta()
1027 "RADIUS DAS: No matches remaining after Acct-Session-Id check"); in hostapd_das_find_sta()
1030 wpa_printf(MSG_DEBUG, "RADIUS DAS: Acct-Session-Id match"); in hostapd_das_find_sta()
1033 if (attr->acct_multi_session_id) { in hostapd_das_find_sta()
1035 if (attr->acct_multi_session_id_len != 16) { in hostapd_das_find_sta()
1037 "RADIUS DAS: Acct-Multi-Session-Id cannot match"); in hostapd_das_find_sta()
1042 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1043 if (!sta->radius_das_match) in hostapd_das_find_sta()
1045 if (!sta->eapol_sm || in hostapd_das_find_sta()
1046 !sta->eapol_sm->acct_multi_session_id) { in hostapd_das_find_sta()
1047 sta->radius_das_match = 0; in hostapd_das_find_sta()
1052 sta->eapol_sm->acct_multi_session_id); in hostapd_das_find_sta()
1053 if (os_memcmp(attr->acct_multi_session_id, buf, 16) != in hostapd_das_find_sta()
1055 sta->radius_das_match = 0; in hostapd_das_find_sta()
1062 "RADIUS DAS: No matches remaining after Acct-Multi-Session-Id check"); in hostapd_das_find_sta()
1066 "RADIUS DAS: Acct-Multi-Session-Id match"); in hostapd_das_find_sta()
1069 if (attr->cui) { in hostapd_das_find_sta()
1073 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1076 if (!sta->radius_das_match) in hostapd_das_find_sta()
1078 cui = ieee802_1x_get_radius_cui(sta->eapol_sm); in hostapd_das_find_sta()
1079 if (!cui || wpabuf_len(cui) != attr->cui_len || in hostapd_das_find_sta()
1080 os_memcmp(wpabuf_head(cui), attr->cui, in hostapd_das_find_sta()
1081 attr->cui_len) != 0) in hostapd_das_find_sta()
1082 sta->radius_das_match = 0; in hostapd_das_find_sta()
1089 "RADIUS DAS: No matches remaining after Chargeable-User-Identity check"); in hostapd_das_find_sta()
1093 "RADIUS DAS: Chargeable-User-Identity match"); in hostapd_das_find_sta()
1096 if (attr->user_name) { in hostapd_das_find_sta()
1100 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1104 if (!sta->radius_das_match) in hostapd_das_find_sta()
1106 identity = ieee802_1x_get_identity(sta->eapol_sm, in hostapd_das_find_sta()
1109 identity_len != attr->user_name_len || in hostapd_das_find_sta()
1110 os_memcmp(identity, attr->user_name, identity_len) in hostapd_das_find_sta()
1112 sta->radius_das_match = 0; in hostapd_das_find_sta()
1119 "RADIUS DAS: No matches remaining after User-Name check"); in hostapd_das_find_sta()
1123 "RADIUS DAS: User-Name match"); in hostapd_das_find_sta()
1138 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1139 if (sta->radius_das_match) { in hostapd_das_find_sta()
1141 *multi = 1; in hostapd_das_find_sta()
1153 struct radius_das_attrs *attr) in hostapd_das_disconnect_pmksa() argument
1155 if (!hapd->wpa_auth) in hostapd_das_disconnect_pmksa()
1156 return -1; in hostapd_das_disconnect_pmksa()
1157 return wpa_auth_radius_das_disconnect_pmksa(hapd->wpa_auth, attr); in hostapd_das_disconnect_pmksa()
1162 hostapd_das_disconnect(void *ctx, struct radius_das_attrs *attr) in hostapd_das_disconnect() argument
1166 int multi; in hostapd_das_disconnect() local
1168 if (hostapd_das_nas_mismatch(hapd, attr)) in hostapd_das_disconnect()
1171 sta = hostapd_das_find_sta(hapd, attr, &multi); in hostapd_das_disconnect()
1173 if (multi) { in hostapd_das_disconnect()
1175 "RADIUS DAS: Multiple sessions match - not supported"); in hostapd_das_disconnect()
1178 if (hostapd_das_disconnect_pmksa(hapd, attr) == 0) { in hostapd_das_disconnect()
1188 " - disconnecting", MAC2STR(sta->addr)); in hostapd_das_disconnect()
1189 wpa_auth_pmksa_remove(hapd->wpa_auth, sta->addr); in hostapd_das_disconnect()
1191 hostapd_drv_sta_deauth(hapd, sta->addr, in hostapd_das_disconnect()
1201 hostapd_das_coa(void *ctx, struct radius_das_attrs *attr) in hostapd_das_coa() argument
1205 int multi; in hostapd_das_coa() local
1207 if (hostapd_das_nas_mismatch(hapd, attr)) in hostapd_das_coa()
1210 sta = hostapd_das_find_sta(hapd, attr, &multi); in hostapd_das_coa()
1212 if (multi) { in hostapd_das_coa()
1214 "RADIUS DAS: Multiple sessions match - not supported"); in hostapd_das_coa()
1222 " - CoA", MAC2STR(sta->addr)); in hostapd_das_coa()
1224 if (attr->hs20_t_c_filtering) { in hostapd_das_coa()
1225 if (attr->hs20_t_c_filtering[0] & BIT(0)) { in hostapd_das_coa()
1227 "HS 2.0: Unexpected Terms and Conditions filtering required in CoA-Request"); in hostapd_das_coa()
1260 " attr TEXT" in db_table_create_radius_attributes()
1269 return -1; in db_table_create_radius_attributes()
1283 struct hostapd_bss_config *conf = hapd->conf; in hostapd_start_beacon()
1285 if (!conf->start_disabled && ieee802_11_set_beacon(hapd) < 0) in hostapd_start_beacon()
1286 return -1; in hostapd_start_beacon()
1288 if (flush_old_stations && !conf->start_disabled && in hostapd_start_beacon()
1289 conf->broadcast_deauth) { in hostapd_start_beacon()
1296 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, in hostapd_start_beacon()
1303 if (hapd->driver && hapd->driver->set_operstate) in hostapd_start_beacon()
1304 hapd->driver->set_operstate(hapd->drv_priv, 1); in hostapd_start_beacon()
1316 return -1; in hostapd_bss_radius_init()
1318 conf = hapd->conf; in hostapd_bss_radius_init()
1320 if (hapd->radius) { in hostapd_bss_radius_init()
1326 hapd->radius = radius_client_init(hapd, conf->radius); in hostapd_bss_radius_init()
1327 if (!hapd->radius) { in hostapd_bss_radius_init()
1330 return -1; in hostapd_bss_radius_init()
1333 if (conf->radius_das_port) { in hostapd_bss_radius_init()
1337 das_conf.port = conf->radius_das_port; in hostapd_bss_radius_init()
1338 das_conf.shared_secret = conf->radius_das_shared_secret; in hostapd_bss_radius_init()
1340 conf->radius_das_shared_secret_len; in hostapd_bss_radius_init()
1341 das_conf.client_addr = &conf->radius_das_client_addr; in hostapd_bss_radius_init()
1342 das_conf.time_window = conf->radius_das_time_window; in hostapd_bss_radius_init()
1344 conf->radius_das_require_event_timestamp; in hostapd_bss_radius_init()
1346 conf->radius_das_require_message_authenticator; in hostapd_bss_radius_init()
1350 hapd->radius_das = radius_das_init(&das_conf); in hostapd_bss_radius_init()
1351 if (!hapd->radius_das) { in hostapd_bss_radius_init()
1354 return -1; in hostapd_bss_radius_init()
1364 * hostapd_setup_bss - Per-BSS setup (initialization)
1366 * @first: Whether this BSS is the first BSS of an interface; -1 = not first,
1375 * This function is used to initialize all per-BSS data structures and
1383 struct hostapd_bss_config *conf = hapd->conf; in hostapd_setup_bss()
1392 "MLD: %s: Setting non-first BSS", __func__); in hostapd_setup_bss()
1395 __func__, hapd, conf->iface, first); in hostapd_setup_bss()
1398 if (conf->tnc && tncs_global_init() < 0) { in hostapd_setup_bss()
1400 return -1; in hostapd_setup_bss()
1404 if (hapd->started) { in hostapd_setup_bss()
1406 __func__, conf->iface); in hostapd_setup_bss()
1407 return -1; in hostapd_setup_bss()
1409 hapd->started = 1; in hostapd_setup_bss()
1411 if (!first || first == -1) { in hostapd_setup_bss()
1412 u8 *addr = hapd->own_addr; in hostapd_setup_bss()
1414 if (!is_zero_ether_addr(conf->bssid)) { in hostapd_setup_bss()
1416 os_memcpy(hapd->own_addr, conf->bssid, ETH_ALEN); in hostapd_setup_bss()
1418 if (hostapd_mac_comp(hapd->own_addr, in hostapd_setup_bss()
1419 hapd->iface->bss[0]->own_addr) == in hostapd_setup_bss()
1423 "the radio", conf->iface); in hostapd_setup_bss()
1424 return -1; in hostapd_setup_bss()
1426 } else if (hapd->iconf->use_driver_iface_addr) { in hostapd_setup_bss()
1431 inc_byte_array(hapd->own_addr, ETH_ALEN); in hostapd_setup_bss()
1432 } while (mac_in_conf(hapd->iconf, hapd->own_addr)); in hostapd_setup_bss()
1436 if (conf->mld_ap) { in hostapd_setup_bss()
1441 hapd->drv_priv = h_hapd->drv_priv; in hostapd_setup_bss()
1442 hapd->interface_added = h_hapd->interface_added; in hostapd_setup_bss()
1446 hapd->mld_link_id, hapd->conf->iface); in hostapd_setup_bss()
1452 hapd->interface_added = 1; in hostapd_setup_bss()
1453 if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS, in hostapd_setup_bss()
1454 conf->iface, addr, hapd, in hostapd_setup_bss()
1455 &hapd->drv_priv, force_ifname, if_addr, in hostapd_setup_bss()
1456 conf->bridge[0] ? conf->bridge : NULL, in hostapd_setup_bss()
1457 first == -1)) { in hostapd_setup_bss()
1459 MACSTR ")", MAC2STR(hapd->own_addr)); in hostapd_setup_bss()
1460 hapd->interface_added = 0; in hostapd_setup_bss()
1461 return -1; in hostapd_setup_bss()
1465 os_memcpy(hapd->own_addr, if_addr, ETH_ALEN); in hostapd_setup_bss()
1468 if (hapd->conf->mld_ap) { in hostapd_setup_bss()
1471 hapd->mld_link_id, hapd->conf->iface); in hostapd_setup_bss()
1472 os_memcpy(hapd->mld->mld_addr, hapd->own_addr, in hostapd_setup_bss()
1481 if (hapd->conf->mld_ap && !first) { in hostapd_setup_bss()
1485 hapd->mld_link_id, MAC2STR(hapd->mld->mld_addr), in hostapd_setup_bss()
1486 MAC2STR(hapd->own_addr)); in hostapd_setup_bss()
1488 if (hostapd_drv_link_add(hapd, hapd->mld_link_id, in hostapd_setup_bss()
1489 hapd->own_addr)) in hostapd_setup_bss()
1490 return -1; in hostapd_setup_bss()
1494 if (conf->wmm_enabled < 0) in hostapd_setup_bss()
1495 conf->wmm_enabled = hapd->iconf->ieee80211n | in hostapd_setup_bss()
1496 hapd->iconf->ieee80211ax; in hostapd_setup_bss()
1499 if (is_zero_ether_addr(conf->r1_key_holder)) in hostapd_setup_bss()
1500 os_memcpy(conf->r1_key_holder, hapd->own_addr, ETH_ALEN); in hostapd_setup_bss()
1504 if ((hapd->conf->mesh & MESH_ENABLED) && hapd->iface->mconf == NULL) in hostapd_setup_bss()
1515 if (hostapd_setup_encryption(conf->iface, hapd)) in hostapd_setup_bss()
1516 return -1; in hostapd_setup_bss()
1527 return -1; in hostapd_setup_bss()
1529 if (conf->ssid.ssid_set) { in hostapd_setup_bss()
1535 set_ssid = (conf->ssid.ssid_len != (size_t) ssid_len || in hostapd_setup_bss()
1536 os_memcmp(conf->ssid.ssid, ssid, ssid_len) != 0); in hostapd_setup_bss()
1543 conf->ssid.ssid_len = ssid_len; in hostapd_setup_bss()
1544 os_memcpy(conf->ssid.ssid, ssid, conf->ssid.ssid_len); in hostapd_setup_bss()
1549 * IEEE P802.11-REVmd/D3.0, 9.4.2.170.3 (Calculating the Short-SSID). in hostapd_setup_bss()
1551 conf->ssid.short_ssid = ieee80211_crc32(conf->ssid.ssid, in hostapd_setup_bss()
1552 conf->ssid.ssid_len); in hostapd_setup_bss()
1557 conf->iface, MAC2STR(hapd->own_addr), in hostapd_setup_bss()
1558 wpa_ssid_txt(conf->ssid.ssid, conf->ssid.ssid_len)); in hostapd_setup_bss()
1562 wpa_printf(MSG_ERROR, "WPA-PSK setup failed."); in hostapd_setup_bss()
1563 return -1; in hostapd_setup_bss()
1568 if (set_ssid && hostapd_set_ssid(hapd, conf->ssid.ssid, in hostapd_setup_bss()
1569 conf->ssid.ssid_len)) { in hostapd_setup_bss()
1571 return -1; in hostapd_setup_bss()
1575 conf->radius->msg_dumps = 1; in hostapd_setup_bss()
1579 if (conf->radius_req_attr_sqlite) { in hostapd_setup_bss()
1580 if (sqlite3_open(conf->radius_req_attr_sqlite, in hostapd_setup_bss()
1581 &hapd->rad_attr_db)) { in hostapd_setup_bss()
1583 conf->radius_req_attr_sqlite); in hostapd_setup_bss()
1584 return -1; in hostapd_setup_bss()
1588 conf->radius_req_attr_sqlite); in hostapd_setup_bss()
1589 if (!db_table_exists(hapd->rad_attr_db, "radius_attributes") && in hostapd_setup_bss()
1590 db_table_create_radius_attributes(hapd->rad_attr_db) < 0) in hostapd_setup_bss()
1591 return -1; in hostapd_setup_bss()
1597 return -1; in hostapd_setup_bss()
1604 return -1; in hostapd_setup_bss()
1606 if (!f_bss->radius) { in hostapd_setup_bss()
1611 return -1; in hostapd_setup_bss()
1616 hapd->radius = f_bss->radius; in hostapd_setup_bss()
1617 hapd->radius_das = f_bss->radius_das; in hostapd_setup_bss()
1624 return -1; in hostapd_setup_bss()
1627 return -1; in hostapd_setup_bss()
1630 hapd->gas = gas_query_ap_init(hapd, hapd->msg_ctx); in hostapd_setup_bss()
1631 if (!hapd->gas) in hostapd_setup_bss()
1632 return -1; in hostapd_setup_bss()
1634 return -1; in hostapd_setup_bss()
1639 return -1; in hostapd_setup_bss()
1643 return -1; in hostapd_setup_bss()
1647 return -1; in hostapd_setup_bss()
1650 if ((conf->wpa || conf->osen) && hostapd_setup_wpa(hapd)) in hostapd_setup_bss()
1651 return -1; in hostapd_setup_bss()
1655 return -1; in hostapd_setup_bss()
1661 return -1; in hostapd_setup_bss()
1665 if (conf->qos_map_set_len && in hostapd_setup_bss()
1666 hostapd_drv_set_qos_map(hapd, conf->qos_map_set, in hostapd_setup_bss()
1667 conf->qos_map_set_len)) { in hostapd_setup_bss()
1669 return -1; in hostapd_setup_bss()
1672 if (conf->bss_load_update_period && bss_load_update_init(hapd)) { in hostapd_setup_bss()
1674 return -1; in hostapd_setup_bss()
1677 if (conf->bridge[0]) { in hostapd_setup_bss()
1683 if (conf->bridge_multicast_to_unicast) in hostapd_setup_bss()
1688 if (conf->bridge_hairpin) in hostapd_setup_bss()
1693 if (conf->proxy_arp) { in hostapd_setup_bss()
1697 return -1; in hostapd_setup_bss()
1703 return -1; in hostapd_setup_bss()
1709 return -1; in hostapd_setup_bss()
1715 return -1; in hostapd_setup_bss()
1719 return -1; in hostapd_setup_bss()
1721 if (hapd->wpa_auth && wpa_init_keys(hapd->wpa_auth) < 0) in hostapd_setup_bss()
1722 return -1; in hostapd_setup_bss()
1730 struct hostapd_data *hapd = iface->bss[0]; in hostapd_tx_queue_params()
1735 if ((hapd->conf->mesh & MESH_ENABLED) && iface->mconf == NULL) in hostapd_tx_queue_params()
1740 p = &iface->conf->tx_queue[i]; in hostapd_tx_queue_params()
1742 if (hostapd_set_tx_queue_params(hapd, i, p->aifs, p->cwmin, in hostapd_tx_queue_params()
1743 p->cwmax, p->burst)) { in hostapd_tx_queue_params()
1760 (n_entries * sizeof(acl_params->mac_acl[0]))); in hostapd_set_acl_list()
1762 return -ENOMEM; in hostapd_set_acl_list()
1765 os_memcpy(acl_params->mac_acl[i].addr, mac_acl[i].addr, in hostapd_set_acl_list()
1768 acl_params->acl_policy = accept_acl; in hostapd_set_acl_list()
1769 acl_params->num_mac_acl = n_entries; in hostapd_set_acl_list()
1781 struct hostapd_config *conf = hapd->iconf; in hostapd_set_acl()
1785 if (hapd->iface->drv_max_acl_mac_addrs == 0) in hostapd_set_acl()
1788 if (conf->bss[0]->macaddr_acl == DENY_UNLESS_ACCEPTED) { in hostapd_set_acl()
1790 err = hostapd_set_acl_list(hapd, conf->bss[0]->accept_mac, in hostapd_set_acl()
1791 conf->bss[0]->num_accept_mac, in hostapd_set_acl()
1795 return -1; in hostapd_set_acl()
1797 } else if (conf->bss[0]->macaddr_acl == ACCEPT_UNLESS_DENIED) { in hostapd_set_acl()
1799 err = hostapd_set_acl_list(hapd, conf->bss[0]->deny_mac, in hostapd_set_acl()
1800 conf->bss[0]->num_deny_mac, in hostapd_set_acl()
1804 return -1; in hostapd_set_acl()
1813 if (!hapd->iface->interfaces || in start_ctrl_iface_bss()
1814 !hapd->iface->interfaces->ctrl_iface_init) in start_ctrl_iface_bss()
1817 if (hapd->iface->interfaces->ctrl_iface_init(hapd)) { in start_ctrl_iface_bss()
1820 hapd->conf->iface); in start_ctrl_iface_bss()
1821 return -1; in start_ctrl_iface_bss()
1832 if (!iface->interfaces || !iface->interfaces->ctrl_iface_init) in start_ctrl_iface()
1835 for (i = 0; i < iface->num_bss; i++) { in start_ctrl_iface()
1836 struct hostapd_data *hapd = iface->bss[i]; in start_ctrl_iface()
1837 if (iface->interfaces->ctrl_iface_init(hapd)) { in start_ctrl_iface()
1840 hapd->conf->iface); in start_ctrl_iface()
1841 return -1; in start_ctrl_iface()
1858 hostapd_cleanup_iface_partial(bss->iface); in hostapd_no_ir_cleanup()
1875 for (i = 0; i < iface->num_hw_features; i++) { in hostapd_no_ir_channel_list_updated()
1876 mode = &iface->hw_features[i]; in hostapd_no_ir_channel_list_updated()
1878 if (mode->mode == iface->conf->hw_mode) { in hostapd_no_ir_channel_list_updated()
1879 if (iface->freq > 0 && in hostapd_no_ir_channel_list_updated()
1880 !hw_mode_get_channel(mode, iface->freq, NULL)) { in hostapd_no_ir_channel_list_updated()
1885 for (j = 0; j < mode->num_channels; j++) { in hostapd_no_ir_channel_list_updated()
1886 if (!(mode->channels[j].flag & in hostapd_no_ir_channel_list_updated()
1890 if (is_6ghz_freq(mode->channels[j].freq)) in hostapd_no_ir_channel_list_updated()
1899 iface->current_mode = mode; in hostapd_no_ir_channel_list_updated()
1901 if (iface->state == HAPD_IFACE_ENABLED) { in hostapd_no_ir_channel_list_updated()
1905 chan = hw_get_channel_freq(iface->current_mode->mode, in hostapd_no_ir_channel_list_updated()
1906 iface->freq, NULL, in hostapd_no_ir_channel_list_updated()
1907 iface->hw_features, in hostapd_no_ir_channel_list_updated()
1908 iface->num_hw_features); in hostapd_no_ir_channel_list_updated()
1916 if (!(chan->flag & HOSTAPD_CHAN_NO_IR)) in hostapd_no_ir_channel_list_updated()
1926 iface->is_no_ir = true; in hostapd_no_ir_channel_list_updated()
1927 hostapd_drv_stop_ap(iface->bss[0]); in hostapd_no_ir_channel_list_updated()
1928 hostapd_no_ir_cleanup(iface->bss[0]); in hostapd_no_ir_channel_list_updated()
1929 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_NO_IR); in hostapd_no_ir_channel_list_updated()
1930 } else if (iface->state == HAPD_IFACE_NO_IR) { in hostapd_no_ir_channel_list_updated()
1937 if (!iface->conf->acs) { in hostapd_no_ir_channel_list_updated()
1940 chan = hw_get_channel_freq(iface->current_mode->mode, in hostapd_no_ir_channel_list_updated()
1941 iface->freq, NULL, in hostapd_no_ir_channel_list_updated()
1942 iface->hw_features, in hostapd_no_ir_channel_list_updated()
1943 iface->num_hw_features); in hostapd_no_ir_channel_list_updated()
1952 if (chan->flag & HOSTAPD_CHAN_NO_IR) { in hostapd_no_ir_channel_list_updated()
1953 iface->freq = 0; in hostapd_no_ir_channel_list_updated()
1954 iface->conf->channel = 0; in hostapd_no_ir_channel_list_updated()
1973 if (!iface->wait_channel_update) { in channel_list_update_timeout()
1982 wpa_printf(MSG_DEBUG, "Channel list update timeout - try to continue anyway"); in channel_list_update_timeout()
1990 hostapd_for_each_interface(iface->interfaces, in hostapd_channel_list_updated()
1996 if (!iface->wait_channel_update || initiator != REGDOM_SET_BY_USER) in hostapd_channel_list_updated()
1999 wpa_printf(MSG_DEBUG, "Channel list updated - continue setup"); in hostapd_channel_list_updated()
2007 struct hostapd_data *hapd = iface->bss[0]; in setup_interface()
2017 iface->driver_ap_teardown = 0; in setup_interface()
2019 if (!iface->phy[0]) { in setup_interface()
2023 os_strlcpy(iface->phy, phy, sizeof(iface->phy)); in setup_interface()
2031 for (i = 1; i < iface->num_bss; i++) { in setup_interface()
2032 iface->bss[i]->driver = hapd->driver; in setup_interface()
2033 iface->bss[i]->drv_priv = hapd->drv_priv; in setup_interface()
2037 return -1; in setup_interface()
2045 return -1; in setup_interface()
2047 if (hapd->iconf->country[0] && hapd->iconf->country[1]) { in setup_interface()
2054 os_memcpy(country, hapd->iconf->country, 3); in setup_interface()
2058 return -1; in setup_interface()
2066 iface->wait_channel_update = 1; in setup_interface()
2082 if (!iface->conf->channel) in configured_fixed_chan_to_freq()
2084 if (iface->conf->op_class) { in configured_fixed_chan_to_freq()
2085 freq = ieee80211_chan_to_freq(NULL, iface->conf->op_class, in configured_fixed_chan_to_freq()
2086 iface->conf->channel); in configured_fixed_chan_to_freq()
2090 iface->conf->op_class, iface->conf->channel); in configured_fixed_chan_to_freq()
2091 return -1; in configured_fixed_chan_to_freq()
2093 iface->freq = freq; in configured_fixed_chan_to_freq()
2101 for (j = 0; j < iface->num_hw_features; j++) { in configured_fixed_chan_to_freq()
2102 struct hostapd_hw_modes *mode = &iface->hw_features[j]; in configured_fixed_chan_to_freq()
2104 if (iface->conf->hw_mode != HOSTAPD_MODE_IEEE80211ANY && in configured_fixed_chan_to_freq()
2105 iface->conf->hw_mode != mode->mode) in configured_fixed_chan_to_freq()
2107 for (i = 0; i < mode->num_channels; i++) { in configured_fixed_chan_to_freq()
2108 struct hostapd_channel_data *chan = &mode->channels[i]; in configured_fixed_chan_to_freq()
2110 if (chan->chan == iface->conf->channel && in configured_fixed_chan_to_freq()
2111 !is_6ghz_freq(chan->freq)) { in configured_fixed_chan_to_freq()
2112 iface->freq = chan->freq; in configured_fixed_chan_to_freq()
2119 return -1; in configured_fixed_chan_to_freq()
2127 if (!is_6ghz_op_class(iface->conf->op_class)) in hostapd_set_6ghz_sec_chan()
2130 bw = op_class_to_bandwidth(iface->conf->op_class); in hostapd_set_6ghz_sec_chan()
2133 if (bw >= 40 && !iface->conf->secondary_channel) { in hostapd_set_6ghz_sec_chan()
2134 if (((iface->conf->channel - 1) / 4) % 2) in hostapd_set_6ghz_sec_chan()
2135 iface->conf->secondary_channel = -1; in hostapd_set_6ghz_sec_chan()
2137 iface->conf->secondary_channel = 1; in hostapd_set_6ghz_sec_chan()
2144 iface->wait_channel_update = 0; in setup_interface2()
2145 iface->is_no_ir = false; in setup_interface2()
2148 /* XXX hostapd_get_hw_features() is an inline that always returns -1 in setup_interface2()
2159 iface->freq = iface->conf->channel; in setup_interface2()
2167 if (iface->conf->acs && !iface->is_ch_switch_dfs) { in setup_interface2()
2168 iface->freq = 0; in setup_interface2()
2169 iface->conf->channel = 0; in setup_interface2()
2171 iface->is_ch_switch_dfs = false; in setup_interface2()
2177 if (iface->conf->op_class) { in setup_interface2()
2180 ch_width = op_class_to_ch_width(iface->conf->op_class); in setup_interface2()
2181 hostapd_set_oper_chwidth(iface->conf, ch_width); in setup_interface2()
2210 if (iface->conf->ieee80211h) in setup_interface2()
2217 if (iface->is_no_ir) { in setup_interface2()
2221 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_NO_IR); in setup_interface2()
2226 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); in setup_interface2()
2227 if (iface->interfaces && iface->interfaces->terminate_on_error) in setup_interface2()
2229 return -1; in setup_interface2()
2239 return hapd->own_addr; in fst_hostapd_get_bssid_cb()
2249 *hw_mode = ieee80211_freq_to_chan(hapd->iface->freq, channel); in fst_hostapd_get_channel_info_cb()
2258 *modes = hapd->iface->hw_features; in fst_hostapd_get_hw_modes_cb()
2259 return hapd->iface->num_hw_features; in fst_hostapd_get_hw_modes_cb()
2267 if (hapd->iface->fst_ies != fst_ies) { in fst_hostapd_set_ies_cb()
2268 hapd->iface->fst_ies = fst_ies; in fst_hostapd_set_ies_cb()
2280 return hostapd_drv_send_action(hapd, hapd->iface->freq, 0, da, in fst_hostapd_send_action_cb()
2290 return sta ? sta->mb_ies : NULL; in fst_hostapd_get_mb_ie_cb()
2304 wpabuf_free(sta->mb_ies); in fst_hostapd_update_mb_ie_cb()
2305 sta->mb_ies = mb_ies_by_info(&info); in fst_hostapd_update_mb_ie_cb()
2317 for (; s && !s->mb_ies; s = s->next) in fst_hostapd_get_sta()
2322 *get_ctx = (struct fst_get_peer_ctx *) s->next; in fst_hostapd_get_sta()
2324 return s->addr; in fst_hostapd_get_sta()
2338 *get_ctx = (struct fst_get_peer_ctx *) hapd->sta_list; in fst_hostapd_get_peer_first()
2356 iface_obj->ctx = hapd; in fst_hostapd_fill_iface_obj()
2357 iface_obj->get_bssid = fst_hostapd_get_bssid_cb; in fst_hostapd_fill_iface_obj()
2358 iface_obj->get_channel_info = fst_hostapd_get_channel_info_cb; in fst_hostapd_fill_iface_obj()
2359 iface_obj->get_hw_modes = fst_hostapd_get_hw_modes_cb; in fst_hostapd_fill_iface_obj()
2360 iface_obj->set_ies = fst_hostapd_set_ies_cb; in fst_hostapd_fill_iface_obj()
2361 iface_obj->send_action = fst_hostapd_send_action_cb; in fst_hostapd_fill_iface_obj()
2362 iface_obj->get_mb_ie = fst_hostapd_get_mb_ie_cb; in fst_hostapd_fill_iface_obj()
2363 iface_obj->update_mb_ie = fst_hostapd_update_mb_ie_cb; in fst_hostapd_fill_iface_obj()
2364 iface_obj->get_peer_first = fst_hostapd_get_peer_first; in fst_hostapd_fill_iface_obj()
2365 iface_obj->get_peer_next = fst_hostapd_get_peer_next; in fst_hostapd_fill_iface_obj()
2377 for (i = 0; i < iface->num_bss; i++) { in hostapd_owe_iface_iter()
2378 struct hostapd_data *bss = iface->bss[i]; in hostapd_owe_iface_iter()
2380 if (os_strcmp(hapd->conf->owe_transition_ifname, in hostapd_owe_iface_iter()
2381 bss->conf->iface) != 0) in hostapd_owe_iface_iter()
2387 hapd->conf->iface, bss->conf->iface, in hostapd_owe_iface_iter()
2388 MAC2STR(bss->own_addr), in hostapd_owe_iface_iter()
2389 wpa_ssid_txt(bss->conf->ssid.ssid, in hostapd_owe_iface_iter()
2390 bss->conf->ssid.ssid_len)); in hostapd_owe_iface_iter()
2391 if (!bss->conf->ssid.ssid_set || !bss->conf->ssid.ssid_len || in hostapd_owe_iface_iter()
2392 is_zero_ether_addr(bss->own_addr)) in hostapd_owe_iface_iter()
2395 os_memcpy(hapd->conf->owe_transition_bssid, bss->own_addr, in hostapd_owe_iface_iter()
2397 os_memcpy(hapd->conf->owe_transition_ssid, in hostapd_owe_iface_iter()
2398 bss->conf->ssid.ssid, bss->conf->ssid.ssid_len); in hostapd_owe_iface_iter()
2399 hapd->conf->owe_transition_ssid_len = bss->conf->ssid.ssid_len; in hostapd_owe_iface_iter()
2411 if (hapd->conf->owe_transition_ssid_len > 0 && in hostapd_owe_trans_get_info()
2412 !is_zero_ether_addr(hapd->conf->owe_transition_bssid)) in hostapd_owe_trans_get_info()
2417 if (!hapd->iface->interfaces || in hostapd_owe_trans_get_info()
2418 !hapd->iface->interfaces->for_each_interface) in hostapd_owe_trans_get_info()
2419 return hostapd_owe_iface_iter(hapd->iface, hapd); in hostapd_owe_trans_get_info()
2421 return hapd->iface->interfaces->for_each_interface( in hostapd_owe_trans_get_info()
2422 hapd->iface->interfaces, hostapd_owe_iface_iter, hapd); in hostapd_owe_trans_get_info()
2430 for (i = 0; i < iface->num_bss; i++) { in hostapd_owe_iface_iter2()
2431 struct hostapd_data *bss = iface->bss[i]; in hostapd_owe_iface_iter2()
2434 if (!bss->conf->owe_transition_ifname[0]) in hostapd_owe_iface_iter2()
2436 if (bss->iface->state != HAPD_IFACE_ENABLED) { in hostapd_owe_iface_iter2()
2438 "OWE: Interface %s state %s - defer beacon update", in hostapd_owe_iface_iter2()
2439 bss->conf->iface, in hostapd_owe_iface_iter2()
2440 hostapd_state_text(bss->iface->state)); in hostapd_owe_iface_iter2()
2447 "OWE: Matching transition mode interface enabled - update beacon data for %s", in hostapd_owe_iface_iter2()
2448 bss->conf->iface); in hostapd_owe_iface_iter2()
2463 if (!iface->interfaces || in hostapd_owe_update_trans()
2464 !iface->interfaces->for_each_interface) in hostapd_owe_update_trans()
2467 iface->interfaces->for_each_interface( in hostapd_owe_update_trans()
2468 iface->interfaces, hostapd_owe_iface_iter2, NULL); in hostapd_owe_update_trans()
2479 if (iface->num_bss < 1 || !iface->bss || !iface->bss[0]) in hostapd_interface_setup_failure_handler()
2481 hapd = iface->bss[0]; in hostapd_interface_setup_failure_handler()
2482 if (hapd->setup_complete_cb) in hostapd_interface_setup_failure_handler()
2483 hapd->setup_complete_cb(hapd->setup_complete_cb_ctx); in hostapd_interface_setup_failure_handler()
2490 struct hostapd_data *hapd = iface->bss[0]; in hostapd_setup_interface_complete_sync()
2500 if (iface->freq) { in hostapd_setup_interface_complete_sync()
2507 hostapd_hw_mode_txt(iface->conf->hw_mode), in hostapd_setup_interface_complete_sync()
2508 iface->conf->channel, iface->freq); in hostapd_setup_interface_complete_sync()
2512 if (!(iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)) { in hostapd_setup_interface_complete_sync()
2541 if (iface->mconf != NULL) { in hostapd_setup_interface_complete_sync()
2544 iface->bss[0]->conf->iface); in hostapd_setup_interface_complete_sync()
2550 hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq, in hostapd_setup_interface_complete_sync()
2551 hapd->iconf->channel, in hostapd_setup_interface_complete_sync()
2552 hapd->iconf->enable_edmg, in hostapd_setup_interface_complete_sync()
2553 hapd->iconf->edmg_channel, in hostapd_setup_interface_complete_sync()
2554 hapd->iconf->ieee80211n, in hostapd_setup_interface_complete_sync()
2555 hapd->iconf->ieee80211ac, in hostapd_setup_interface_complete_sync()
2556 hapd->iconf->ieee80211ax, in hostapd_setup_interface_complete_sync()
2557 hapd->iconf->ieee80211be, in hostapd_setup_interface_complete_sync()
2558 hapd->iconf->secondary_channel, in hostapd_setup_interface_complete_sync()
2559 hostapd_get_oper_chwidth(hapd->iconf), in hostapd_setup_interface_complete_sync()
2561 hapd->iconf), in hostapd_setup_interface_complete_sync()
2563 hapd->iconf))) { in hostapd_setup_interface_complete_sync()
2570 if (iface->current_mode) { in hostapd_setup_interface_complete_sync()
2571 if (hostapd_prepare_rates(iface, iface->current_mode)) { in hostapd_setup_interface_complete_sync()
2581 if (hapd->iconf->rts_threshold >= -1 && in hostapd_setup_interface_complete_sync()
2582 hostapd_set_rts(hapd, hapd->iconf->rts_threshold) && in hostapd_setup_interface_complete_sync()
2583 hapd->iconf->rts_threshold >= -1) { in hostapd_setup_interface_complete_sync()
2589 if (hapd->iconf->fragm_threshold >= -1 && in hostapd_setup_interface_complete_sync()
2590 hostapd_set_frag(hapd, hapd->iconf->fragm_threshold) && in hostapd_setup_interface_complete_sync()
2591 hapd->iconf->fragm_threshold != -1) { in hostapd_setup_interface_complete_sync()
2597 prev_addr = hapd->own_addr; in hostapd_setup_interface_complete_sync()
2599 for (j = 0; j < iface->num_bss; j++) { in hostapd_setup_interface_complete_sync()
2600 hapd = iface->bss[j]; in hostapd_setup_interface_complete_sync()
2602 os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN); in hostapd_setup_interface_complete_sync()
2603 if (hostapd_setup_bss(hapd, j == 0, !iface->conf->mbssid)) { in hostapd_setup_interface_complete_sync()
2605 hapd = iface->bss[j]; in hostapd_setup_interface_complete_sync()
2610 j--; in hostapd_setup_interface_complete_sync()
2614 if (is_zero_ether_addr(hapd->conf->bssid)) in hostapd_setup_interface_complete_sync()
2615 prev_addr = hapd->own_addr; in hostapd_setup_interface_complete_sync()
2618 if (hapd->iconf->mbssid) { in hostapd_setup_interface_complete_sync()
2619 for (j = 0; hapd->iconf->mbssid && j < iface->num_bss; j++) { in hostapd_setup_interface_complete_sync()
2620 hapd = iface->bss[j]; in hostapd_setup_interface_complete_sync()
2623 hapd = iface->bss[j]; in hostapd_setup_interface_complete_sync()
2628 j--; in hostapd_setup_interface_complete_sync()
2635 hapd = iface->bss[0]; in hostapd_setup_interface_complete_sync()
2651 * If "interface" and "upnp_iface" are the same (e.g., non-bridge in hostapd_setup_interface_complete_sync()
2655 for (j = 0; j < iface->num_bss; j++) { in hostapd_setup_interface_complete_sync()
2656 if (hostapd_init_wps_complete(iface->bss[j])) in hostapd_setup_interface_complete_sync()
2660 if ((iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) && in hostapd_setup_interface_complete_sync()
2675 if (hapd->iconf->fst_cfg.group_id[0]) { in hostapd_setup_interface_complete_sync()
2679 iface->fst = fst_attach(hapd->conf->iface, hapd->own_addr, in hostapd_setup_interface_complete_sync()
2680 &iface_obj, &hapd->iconf->fst_cfg); in hostapd_setup_interface_complete_sync()
2681 if (!iface->fst) { in hostapd_setup_interface_complete_sync()
2683 hapd->iconf->fst_cfg.group_id); in hostapd_setup_interface_complete_sync()
2692 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_ENABLED); in hostapd_setup_interface_complete_sync()
2693 if (hapd->setup_complete_cb) in hostapd_setup_interface_complete_sync()
2694 hapd->setup_complete_cb(hapd->setup_complete_cb_ctx); in hostapd_setup_interface_complete_sync()
2697 if (delay_apply_cfg && !iface->mconf) { in hostapd_setup_interface_complete_sync()
2704 iface->bss[0]->conf->iface); in hostapd_setup_interface_complete_sync()
2705 if (iface->interfaces && iface->interfaces->terminate_on_error > 0) in hostapd_setup_interface_complete_sync()
2706 iface->interfaces->terminate_on_error--; in hostapd_setup_interface_complete_sync()
2708 for (j = 0; j < iface->num_bss; j++) in hostapd_setup_interface_complete_sync()
2709 hostapd_neighbor_set_own_report(iface->bss[j]); in hostapd_setup_interface_complete_sync()
2711 if (iface->interfaces && iface->interfaces->count > 1) in hostapd_setup_interface_complete_sync()
2719 if (iface->is_no_ir) { in hostapd_setup_interface_complete_sync()
2721 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_NO_IR); in hostapd_setup_interface_complete_sync()
2726 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); in hostapd_setup_interface_complete_sync()
2728 if (iface->fst) { in hostapd_setup_interface_complete_sync()
2729 fst_detach(iface->fst); in hostapd_setup_interface_complete_sync()
2730 iface->fst = NULL; in hostapd_setup_interface_complete_sync()
2734 if (iface->interfaces && iface->interfaces->terminate_on_error) { in hostapd_setup_interface_complete_sync()
2736 } else if (hapd->setup_complete_cb) { in hostapd_setup_interface_complete_sync()
2738 * Calling hapd->setup_complete_cb directly may cause iface in hostapd_setup_interface_complete_sync()
2746 return -1; in hostapd_setup_interface_complete_sync()
2751 * hostapd_setup_interface_complete - Complete interface setup
2760 struct hapd_interfaces *interfaces = iface->interfaces; in hostapd_setup_interface_complete()
2761 struct hostapd_data *hapd = iface->bss[0]; in hostapd_setup_interface_complete()
2765 if (!iface->need_to_start_in_sync) in hostapd_setup_interface_complete()
2770 iface->need_to_start_in_sync = 0; in hostapd_setup_interface_complete()
2772 if (iface->is_no_ir) { in hostapd_setup_interface_complete()
2774 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_NO_IR); in hostapd_setup_interface_complete()
2779 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); in hostapd_setup_interface_complete()
2780 if (interfaces && interfaces->terminate_on_error) in hostapd_setup_interface_complete()
2782 return -1; in hostapd_setup_interface_complete()
2785 if (iface->ready_to_start_in_sync) { in hostapd_setup_interface_complete()
2790 for (i = 0; i < interfaces->count; i++) { in hostapd_setup_interface_complete()
2791 if (interfaces->iface[i]->need_to_start_in_sync && in hostapd_setup_interface_complete()
2792 !interfaces->iface[i]->ready_to_start_in_sync) in hostapd_setup_interface_complete()
2800 if (not_ready_in_sync_ifaces > 1 && iface->state == HAPD_IFACE_DFS) { in hostapd_setup_interface_complete()
2805 iface->need_to_start_in_sync = 0; in hostapd_setup_interface_complete()
2807 "%s: Finished CAC - bypass sync and start interface", in hostapd_setup_interface_complete()
2808 iface->bss[0]->conf->iface); in hostapd_setup_interface_complete()
2814 iface->ready_to_start_in_sync = 1; in hostapd_setup_interface_complete()
2817 iface->bss[0]->conf->iface); in hostapd_setup_interface_complete()
2822 "%s: Last interface to sync - starting all interfaces", in hostapd_setup_interface_complete()
2823 iface->bss[0]->conf->iface); in hostapd_setup_interface_complete()
2824 iface->need_to_start_in_sync = 0; in hostapd_setup_interface_complete()
2826 for (i = 0; i < interfaces->count; i++) { in hostapd_setup_interface_complete()
2827 if (interfaces->iface[i]->need_to_start_in_sync && in hostapd_setup_interface_complete()
2828 interfaces->iface[i]->ready_to_start_in_sync) { in hostapd_setup_interface_complete()
2830 interfaces->iface[i], 0); in hostapd_setup_interface_complete()
2832 interfaces->iface[i]->need_to_start_in_sync = 0; in hostapd_setup_interface_complete()
2841 * hostapd_setup_interface - Setup of an interface
2843 * Returns: 0 on success, -1 on failure
2850 * If interface setup requires more time, e.g., to perform HT co-ex scans, ACS,
2860 if (!iface->conf) in hostapd_setup_interface()
2861 return -1; in hostapd_setup_interface()
2865 iface->conf->bss[0]->iface); in hostapd_setup_interface()
2866 return -1; in hostapd_setup_interface()
2874 * hostapd_alloc_bss_data - Allocate and initialize per-BSS data
2876 * @conf: Pointer to per-interface configuration
2877 * @bss: Pointer to per-BSS configuration for this BSS
2880 * This function is used to allocate per-BSS data structure. This data will be
2895 hapd->new_assoc_sta_cb = hostapd_new_assoc_sta; in hostapd_alloc_bss_data()
2896 hapd->iconf = conf; in hostapd_alloc_bss_data()
2897 hapd->conf = bss; in hostapd_alloc_bss_data()
2898 hapd->iface = hapd_iface; in hostapd_alloc_bss_data()
2900 hapd->driver = conf->driver; in hostapd_alloc_bss_data()
2901 hapd->ctrl_sock = -1; in hostapd_alloc_bss_data()
2902 dl_list_init(&hapd->ctrl_dst); in hostapd_alloc_bss_data()
2903 dl_list_init(&hapd->nr_db); in hostapd_alloc_bss_data()
2904 hapd->dhcp_sock = -1; in hostapd_alloc_bss_data()
2906 dl_list_init(&hapd->l2_queue); in hostapd_alloc_bss_data()
2907 dl_list_init(&hapd->l2_oui_queue); in hostapd_alloc_bss_data()
2910 dl_list_init(&hapd->sae_commit_queue); in hostapd_alloc_bss_data()
2922 hapd->conf ? hapd->conf->iface : "N/A"); in hostapd_bss_deinit()
2924 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); in hostapd_bss_deinit()
2926 if (hapd->rad_attr_db) { in hostapd_bss_deinit()
2927 sqlite3_close(hapd->rad_attr_db); in hostapd_bss_deinit()
2928 hapd->rad_attr_db = NULL; in hostapd_bss_deinit()
2948 iface->wait_channel_update = 0; in hostapd_interface_deinit()
2949 iface->is_no_ir = false; in hostapd_interface_deinit()
2952 if (iface->fst) { in hostapd_interface_deinit()
2953 fst_detach(iface->fst); in hostapd_interface_deinit()
2954 iface->fst = NULL; in hostapd_interface_deinit()
2958 for (j = (int) iface->num_bss - 1; j >= 0; j--) { in hostapd_interface_deinit()
2959 if (!iface->bss) in hostapd_interface_deinit()
2961 hostapd_bss_deinit(iface->bss[j]); in hostapd_interface_deinit()
2978 if (mld->refcount == HOSTAPD_MLD_MAX_REF_COUNT) { in hostapd_mld_ref_inc()
2980 mld->name); in hostapd_mld_ref_inc()
2984 mld->refcount++; in hostapd_mld_ref_inc()
2993 if (!mld->refcount) { in hostapd_mld_ref_dec()
2995 mld->name); in hostapd_mld_ref_dec()
2999 mld->refcount--; in hostapd_mld_ref_dec()
3009 for (j = 0; j < iface->num_bss; j++) { in hostapd_interface_free()
3010 if (!iface->bss) in hostapd_interface_free()
3013 if (iface->bss[j]) in hostapd_interface_free()
3014 hostapd_mld_ref_dec(iface->bss[j]->mld); in hostapd_interface_free()
3017 __func__, iface->bss[j]); in hostapd_interface_free()
3018 os_free(iface->bss[j]); in hostapd_interface_free()
3032 dl_list_init(&hapd_iface->sta_seen); in hostapd_alloc_iface()
3041 hapd->mld_link_id = hapd->mld->next_link_id++; in hostapd_bss_alloc_link_id()
3043 hapd->mld->name, hapd->mld_link_id); in hostapd_bss_alloc_link_id()
3056 conf = hapd->conf; in hostapd_bss_setup_multi_link()
3058 if (!hapd->iconf || !hapd->iconf->ieee80211be || !conf->mld_ap || in hostapd_bss_setup_multi_link()
3059 conf->disable_11be) in hostapd_bss_setup_multi_link()
3062 for (i = 0; i < interfaces->mld_count; i++) { in hostapd_bss_setup_multi_link()
3063 mld = interfaces->mld[i]; in hostapd_bss_setup_multi_link()
3065 if (!mld || os_strcmp(conf->iface, mld->name) != 0) in hostapd_bss_setup_multi_link()
3068 hapd->mld = mld; in hostapd_bss_setup_multi_link()
3074 if (hapd->mld) in hostapd_bss_setup_multi_link()
3081 os_strlcpy(mld->name, conf->iface, sizeof(conf->iface)); in hostapd_bss_setup_multi_link()
3082 dl_list_init(&mld->links); in hostapd_bss_setup_multi_link()
3084 wpa_printf(MSG_DEBUG, "AP MLD %s created", mld->name); in hostapd_bss_setup_multi_link()
3086 hapd->mld = mld; in hostapd_bss_setup_multi_link()
3090 all_mld = os_realloc_array(interfaces->mld, interfaces->mld_count + 1, in hostapd_bss_setup_multi_link()
3095 interfaces->mld = all_mld; in hostapd_bss_setup_multi_link()
3096 interfaces->mld[interfaces->mld_count] = mld; in hostapd_bss_setup_multi_link()
3097 interfaces->mld_count++; in hostapd_bss_setup_multi_link()
3104 wpa_printf(MSG_DEBUG, "AP MLD %s: free mld %p", mld->name, mld); in hostapd_bss_setup_multi_link()
3106 hapd->mld = NULL; in hostapd_bss_setup_multi_link()
3118 if (!interfaces->mld) in hostapd_cleanup_unused_mlds()
3121 num_mlds = interfaces->mld_count; in hostapd_cleanup_unused_mlds()
3123 for (i = 0; i < interfaces->mld_count; i++) { in hostapd_cleanup_unused_mlds()
3124 mld = interfaces->mld[i]; in hostapd_cleanup_unused_mlds()
3131 if (!mld->refcount) in hostapd_cleanup_unused_mlds()
3139 if (!remove && !interfaces->count) in hostapd_cleanup_unused_mlds()
3145 wpa_printf(MSG_DEBUG, "AP MLD %s: Freed%s", mld->name, in hostapd_cleanup_unused_mlds()
3148 interfaces->mld[i] = NULL; in hostapd_cleanup_unused_mlds()
3149 num_mlds--; in hostapd_cleanup_unused_mlds()
3153 interfaces->mld_count = 0; in hostapd_cleanup_unused_mlds()
3154 os_free(interfaces->mld); in hostapd_cleanup_unused_mlds()
3155 interfaces->mld = NULL; in hostapd_cleanup_unused_mlds()
3162 "AP MLD: Failed to re-allocate the MLDs. Expect issues"); in hostapd_cleanup_unused_mlds()
3166 for (i = 0, j = 0; i < interfaces->mld_count; i++) { in hostapd_cleanup_unused_mlds()
3167 mld = interfaces->mld[i]; in hostapd_cleanup_unused_mlds()
3182 os_free(interfaces->mld); in hostapd_cleanup_unused_mlds()
3183 interfaces->mld = all_mld; in hostapd_cleanup_unused_mlds()
3184 interfaces->mld_count = num_mlds; in hostapd_cleanup_unused_mlds()
3190 * hostapd_init - Allocate and initialize per-interface data
3194 * This function is used to allocate main data structures for per-interface
3210 hapd_iface->config_fname = os_strdup(config_file); in hostapd_init()
3211 if (hapd_iface->config_fname == NULL) in hostapd_init()
3214 conf = interfaces->config_read_cb(hapd_iface->config_fname); in hostapd_init()
3217 hapd_iface->conf = conf; in hostapd_init()
3219 hapd_iface->num_bss = conf->num_bss; in hostapd_init()
3220 hapd_iface->bss = os_calloc(conf->num_bss, in hostapd_init()
3222 if (hapd_iface->bss == NULL) in hostapd_init()
3225 for (i = 0; i < conf->num_bss; i++) { in hostapd_init()
3226 hapd = hapd_iface->bss[i] = in hostapd_init()
3228 conf->bss[i]); in hostapd_init()
3231 hapd->msg_ctx = hapd; in hostapd_init()
3235 hapd_iface->is_ch_switch_dfs = false; in hostapd_init()
3244 os_free(hapd_iface->config_fname); in hostapd_init()
3245 os_free(hapd_iface->bss); in hostapd_init()
3258 for (i = 0; i < interfaces->count; i++) { in ifname_in_use()
3259 struct hostapd_iface *iface = interfaces->iface[i]; in ifname_in_use()
3260 for (j = 0; j < iface->num_bss; j++) { in ifname_in_use()
3261 struct hostapd_data *hapd = iface->bss[j]; in ifname_in_use()
3262 if (os_strcmp(ifname, hapd->conf->iface) == 0) in ifname_in_use()
3272 * hostapd_interface_init_bss - Read configuration file and init BSS data
3294 for (i = 0; i < interfaces->count; i++) { in hostapd_interface_init_bss()
3295 if (os_strcmp(interfaces->iface[i]->phy, phy) == 0) { in hostapd_interface_init_bss()
3296 iface = interfaces->iface[i]; in hostapd_interface_init_bss()
3302 config_fname, phy, iface ? "" : " --> new PHY"); in hostapd_interface_init_bss()
3311 conf = interfaces->config_read_cb(config_fname); in hostapd_interface_init_bss()
3314 if (conf->num_bss > 1) { in hostapd_interface_init_bss()
3315 wpa_printf(MSG_ERROR, "Multiple BSSes specified in BSS-config"); in hostapd_interface_init_bss()
3320 ifname = conf->bss[0]->iface; in hostapd_interface_init_bss()
3329 iface->conf->bss, iface->conf->num_bss + 1, in hostapd_interface_init_bss()
3331 tmp_bss = os_realloc_array(iface->bss, iface->num_bss + 1, in hostapd_interface_init_bss()
3334 iface->bss = tmp_bss; in hostapd_interface_init_bss()
3336 iface->conf->bss = tmp_conf; in hostapd_interface_init_bss()
3337 iface->conf->last_bss = tmp_conf[0]; in hostapd_interface_init_bss()
3343 bss = iface->conf->bss[iface->conf->num_bss] = conf->bss[0]; in hostapd_interface_init_bss()
3344 iface->conf->num_bss++; in hostapd_interface_init_bss()
3346 hapd = hostapd_alloc_bss_data(iface, iface->conf, bss); in hostapd_interface_init_bss()
3348 iface->conf->num_bss--; in hostapd_interface_init_bss()
3352 iface->conf->last_bss = bss; in hostapd_interface_init_bss()
3353 iface->bss[iface->num_bss] = hapd; in hostapd_interface_init_bss()
3354 hapd->msg_ctx = hapd; in hostapd_interface_init_bss()
3358 bss_idx = iface->num_bss++; in hostapd_interface_init_bss()
3359 conf->num_bss--; in hostapd_interface_init_bss()
3360 conf->bss[0] = NULL; in hostapd_interface_init_bss()
3367 os_strlcpy(iface->phy, phy, sizeof(iface->phy)); in hostapd_interface_init_bss()
3368 iface->interfaces = interfaces; in hostapd_interface_init_bss()
3373 if (iface->bss[bss_idx]->conf->logger_stdout_level > 0) in hostapd_interface_init_bss()
3374 iface->bss[bss_idx]->conf->logger_stdout_level--; in hostapd_interface_init_bss()
3377 if (iface->conf->bss[bss_idx]->iface[0] == '\0' && in hostapd_interface_init_bss()
3378 !hostapd_drv_none(iface->bss[bss_idx])) { in hostapd_interface_init_bss()
3393 if (!driver || !driver->hapd_deinit || !drv_priv) in hostapd_cleanup_driver()
3397 /* In case of non-ML operation, de-init. But if ML operation exist, in hostapd_cleanup_driver()
3400 * still being used by some other BSS before de-initiallizing. */ in hostapd_cleanup_driver()
3401 if (!iface->bss[0]->conf->mld_ap) { in hostapd_cleanup_driver()
3402 driver->hapd_deinit(drv_priv); in hostapd_cleanup_driver()
3403 } else if (hostapd_mld_is_first_bss(iface->bss[0]) && in hostapd_cleanup_driver()
3404 driver->is_drv_shared && in hostapd_cleanup_driver()
3405 !driver->is_drv_shared(drv_priv, iface->bss[0])) { in hostapd_cleanup_driver()
3406 driver->hapd_deinit(drv_priv); in hostapd_cleanup_driver()
3407 } else if (hostapd_if_link_remove(iface->bss[0], in hostapd_cleanup_driver()
3409 iface->bss[0]->conf->iface, in hostapd_cleanup_driver()
3410 iface->bss[0]->mld_link_id)) { in hostapd_cleanup_driver()
3412 iface->bss[0]->conf->iface); in hostapd_cleanup_driver()
3415 driver->hapd_deinit(drv_priv); in hostapd_cleanup_driver()
3417 iface->bss[0]->drv_priv = NULL; in hostapd_cleanup_driver()
3429 wpa_printf(MSG_DEBUG, "%s: num_bss=%u conf->num_bss=%u", in hostapd_interface_deinit_free()
3430 __func__, (unsigned int) iface->num_bss, in hostapd_interface_deinit_free()
3431 (unsigned int) iface->conf->num_bss); in hostapd_interface_deinit_free()
3432 driver = iface->bss[0]->driver; in hostapd_interface_deinit_free()
3433 drv_priv = iface->bss[0]->drv_priv; in hostapd_interface_deinit_free()
3435 wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit", in hostapd_interface_deinit_free()
3448 wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit", in hostapd_deinit_driver()
3453 if (driver && driver->hapd_deinit && drv_priv) { in hostapd_deinit_driver()
3454 for (j = 0; j < hapd_iface->num_bss; j++) { in hostapd_deinit_driver()
3455 wpa_printf(MSG_DEBUG, "%s:bss[%d]->drv_priv=%p", in hostapd_deinit_driver()
3457 hapd_iface->bss[j]->drv_priv); in hostapd_deinit_driver()
3458 if (hapd_iface->bss[j]->drv_priv == drv_priv) { in hostapd_deinit_driver()
3459 hapd_iface->bss[j]->drv_priv = NULL; in hostapd_deinit_driver()
3460 hapd_iface->extended_capa = NULL; in hostapd_deinit_driver()
3461 hapd_iface->extended_capa_mask = NULL; in hostapd_deinit_driver()
3462 hapd_iface->extended_capa_len = 0; in hostapd_deinit_driver()
3473 if (!hapd_iface->interfaces || hapd_iface->interfaces->count <= 1) in hostapd_refresh_all_iface_beacons()
3476 for (j = 0; j < hapd_iface->interfaces->count; j++) { in hostapd_refresh_all_iface_beacons()
3477 if (hapd_iface->interfaces->iface[j] == hapd_iface) in hostapd_refresh_all_iface_beacons()
3480 ieee802_11_update_beacons(hapd_iface->interfaces->iface[j]); in hostapd_refresh_all_iface_beacons()
3490 return -1; in hostapd_enable_iface()
3492 if (hapd_iface->enable_iface_cb) in hostapd_enable_iface()
3493 return hapd_iface->enable_iface_cb(hapd_iface); in hostapd_enable_iface()
3495 if (hapd_iface->bss[0]->drv_priv != NULL) { in hostapd_enable_iface()
3497 hapd_iface->conf->bss[0]->iface); in hostapd_enable_iface()
3498 return -1; in hostapd_enable_iface()
3502 hapd_iface->conf->bss[0]->iface); in hostapd_enable_iface()
3504 for (j = 0; j < hapd_iface->num_bss; j++) in hostapd_enable_iface()
3505 hostapd_set_security_params(hapd_iface->conf->bss[j], 1); in hostapd_enable_iface()
3506 if (hostapd_config_check(hapd_iface->conf, 1) < 0) { in hostapd_enable_iface()
3507 wpa_printf(MSG_INFO, "Invalid configuration - cannot enable"); in hostapd_enable_iface()
3508 return -1; in hostapd_enable_iface()
3511 if (hapd_iface->interfaces == NULL || in hostapd_enable_iface()
3512 hapd_iface->interfaces->driver_init == NULL || in hostapd_enable_iface()
3513 hapd_iface->interfaces->driver_init(hapd_iface)) in hostapd_enable_iface()
3514 return -1; in hostapd_enable_iface()
3517 hostapd_deinit_driver(hapd_iface->bss[0]->driver, in hostapd_enable_iface()
3518 hapd_iface->bss[0]->drv_priv, in hostapd_enable_iface()
3520 return -1; in hostapd_enable_iface()
3534 hapd_iface->conf->bss[0]->iface); in hostapd_reload_iface()
3535 for (j = 0; j < hapd_iface->num_bss; j++) in hostapd_reload_iface()
3536 hostapd_set_security_params(hapd_iface->conf->bss[j], 1); in hostapd_reload_iface()
3537 if (hostapd_config_check(hapd_iface->conf, 1) < 0) { in hostapd_reload_iface()
3539 return -1; in hostapd_reload_iface()
3542 for (j = 0; j < hapd_iface->num_bss; j++) in hostapd_reload_iface()
3543 hostapd_reload_bss(hapd_iface->bss[j]); in hostapd_reload_iface()
3552 wpa_printf(MSG_DEBUG, "Reload BSS %s", bss->conf->iface); in hostapd_reload_bss_only()
3553 hostapd_set_security_params(bss->conf, 1); in hostapd_reload_bss_only()
3554 if (hostapd_config_check(bss->iconf, 1) < 0) { in hostapd_reload_bss_only()
3556 return -1; in hostapd_reload_bss_only()
3571 return -1; in hostapd_disable_iface()
3573 if (hapd_iface->disable_iface_cb) in hostapd_disable_iface()
3574 return hapd_iface->disable_iface_cb(hapd_iface); in hostapd_disable_iface()
3576 if (hapd_iface->bss[0]->drv_priv == NULL) { in hostapd_disable_iface()
3578 hapd_iface->conf->bss[0]->iface); in hostapd_disable_iface()
3579 return -1; in hostapd_disable_iface()
3582 wpa_msg(hapd_iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); in hostapd_disable_iface()
3583 driver = hapd_iface->bss[0]->driver; in hostapd_disable_iface()
3584 drv_priv = hapd_iface->bss[0]->drv_priv; in hostapd_disable_iface()
3586 hapd_iface->driver_ap_teardown = in hostapd_disable_iface()
3587 !!(hapd_iface->drv_flags & in hostapd_disable_iface()
3591 for (j = 0; j < hapd_iface->num_bss; j++) in hostapd_disable_iface()
3592 hostapd_cleanup_cs_params(hapd_iface->bss[j]); in hostapd_disable_iface()
3595 /* same as hostapd_interface_deinit without deinitializing ctrl-iface */ in hostapd_disable_iface()
3596 for (j = 0; j < hapd_iface->num_bss; j++) { in hostapd_disable_iface()
3597 struct hostapd_data *hapd = hapd_iface->bss[j]; in hostapd_disable_iface()
3611 hapd_iface->bss[0]->conf->iface); in hostapd_disable_iface()
3623 iface = os_realloc_array(interfaces->iface, interfaces->count + 1, in hostapd_iface_alloc()
3627 interfaces->iface = iface; in hostapd_iface_alloc()
3628 hapd_iface = interfaces->iface[interfaces->count] = in hostapd_iface_alloc()
3635 interfaces->count++; in hostapd_iface_alloc()
3636 hapd_iface->interfaces = interfaces; in hostapd_iface_alloc()
3661 if (os_strcmp(driver, wpa_drivers[j]->name) == 0) { in hostapd_config_alloc()
3662 conf->driver = wpa_drivers[j]; in hostapd_config_alloc()
3668 "Invalid/unknown driver '%s' - registering the default driver", in hostapd_config_alloc()
3672 conf->driver = wpa_drivers[0]; in hostapd_config_alloc()
3673 if (conf->driver == NULL) { in hostapd_config_alloc()
3680 bss = conf->last_bss = conf->bss[0]; in hostapd_config_alloc()
3682 os_strlcpy(bss->iface, ifname, sizeof(bss->iface)); in hostapd_config_alloc()
3683 bss->ctrl_interface = os_strdup(ctrl_iface); in hostapd_config_alloc()
3684 if (bss->ctrl_interface == NULL) { in hostapd_config_alloc()
3703 hapd_iface->bss = os_calloc(conf->num_bss, in hostapd_data_alloc()
3705 if (hapd_iface->bss == NULL) in hostapd_data_alloc()
3706 return -1; in hostapd_data_alloc()
3708 for (i = 0; i < conf->num_bss; i++) { in hostapd_data_alloc()
3709 hapd = hapd_iface->bss[i] = in hostapd_data_alloc()
3710 hostapd_alloc_bss_data(hapd_iface, conf, conf->bss[i]); in hostapd_data_alloc()
3713 i--; in hostapd_data_alloc()
3714 os_free(hapd_iface->bss[i]); in hostapd_data_alloc()
3715 hapd_iface->bss[i] = NULL; in hostapd_data_alloc()
3717 os_free(hapd_iface->bss); in hostapd_data_alloc()
3718 hapd_iface->bss = NULL; in hostapd_data_alloc()
3719 return -1; in hostapd_data_alloc()
3721 hapd->msg_ctx = hapd; in hostapd_data_alloc()
3722 hostapd_bss_setup_multi_link(hapd, hapd_iface->interfaces); in hostapd_data_alloc()
3725 hapd_iface->conf = conf; in hostapd_data_alloc()
3726 hapd_iface->num_bss = conf->num_bss; in hostapd_data_alloc()
3746 return -1; in hostapd_add_iface()
3750 return -1; in hostapd_add_iface()
3755 return -1; in hostapd_add_iface()
3756 for (j = 0; j < interfaces->count; j++) { in hostapd_add_iface()
3757 if (interfaces->iface[j] == hapd_iface) in hostapd_add_iface()
3760 if (j == interfaces->count) { in hostapd_add_iface()
3762 tmp = os_realloc_array(interfaces->iface, in hostapd_add_iface()
3763 interfaces->count + 1, in hostapd_add_iface()
3767 return -1; in hostapd_add_iface()
3769 interfaces->iface = tmp; in hostapd_add_iface()
3770 interfaces->iface[interfaces->count++] = hapd_iface; in hostapd_add_iface()
3775 if (interfaces->driver_init(hapd_iface)) in hostapd_add_iface()
3780 hapd_iface->bss[0]->driver, in hostapd_add_iface()
3781 hapd_iface->bss[0]->drv_priv, in hostapd_add_iface()
3787 hapd = hapd_iface->bss[hapd_iface->num_bss - 1]; in hostapd_add_iface()
3788 hapd->driver = hapd_iface->bss[0]->driver; in hostapd_add_iface()
3789 hapd->drv_priv = hapd_iface->bss[0]->drv_priv; in hostapd_add_iface()
3790 os_memcpy(hapd->own_addr, hapd_iface->bss[0]->own_addr, in hostapd_add_iface()
3794 (hapd_iface->state == HAPD_IFACE_ENABLED && in hostapd_add_iface()
3795 hostapd_setup_bss(hapd, -1, true))) { in hostapd_add_iface()
3798 hapd_iface->bss[hapd_iface->num_bss - 1] = NULL; in hostapd_add_iface()
3799 hapd_iface->conf->num_bss--; in hostapd_add_iface()
3800 hapd_iface->num_bss--; in hostapd_add_iface()
3802 __func__, hapd, hapd->conf->iface); in hostapd_add_iface()
3803 hostapd_config_free_bss(hapd->conf); in hostapd_add_iface()
3804 hapd->conf = NULL; in hostapd_add_iface()
3806 hostapd_mld_ref_dec(hapd->mld); in hostapd_add_iface()
3809 return -1; in hostapd_add_iface()
3818 return -1; in hostapd_add_iface()
3824 for (i = 0; i < interfaces->count; i++) { in hostapd_add_iface()
3828 mld_ap = interfaces->iface[i]->conf->bss[0]->mld_ap; in hostapd_add_iface()
3831 if (!os_strcmp(interfaces->iface[i]->conf->bss[0]->iface, in hostapd_add_iface()
3833 wpa_printf(MSG_INFO, "Cannot add interface - it " in hostapd_add_iface()
3835 return -1; in hostapd_add_iface()
3847 if (conf_file && interfaces->config_read_cb) { in hostapd_add_iface()
3848 conf = interfaces->config_read_cb(conf_file); in hostapd_add_iface()
3849 if (conf && conf->bss) in hostapd_add_iface()
3850 os_strlcpy(conf->bss[0]->iface, buf, in hostapd_add_iface()
3851 sizeof(conf->bss[0]->iface)); in hostapd_add_iface()
3860 if (conf == NULL || conf->bss == NULL) { in hostapd_add_iface()
3877 hapd_iface->conf->bss[0]->iface); in hostapd_add_iface()
3885 if (hapd_iface->bss) { in hostapd_add_iface()
3886 for (i = 0; i < hapd_iface->num_bss; i++) { in hostapd_add_iface()
3887 hapd = hapd_iface->bss[i]; in hostapd_add_iface()
3890 if (hapd_iface->interfaces && in hostapd_add_iface()
3891 hapd_iface->interfaces->ctrl_iface_deinit) in hostapd_add_iface()
3892 hapd_iface->interfaces-> in hostapd_add_iface()
3895 __func__, hapd_iface->bss[i], in hostapd_add_iface()
3896 hapd->conf->iface); in hostapd_add_iface()
3900 hostapd_mld_ref_dec(hapd->mld); in hostapd_add_iface()
3903 hapd_iface->bss[i] = NULL; in hostapd_add_iface()
3905 os_free(hapd_iface->bss); in hostapd_add_iface()
3906 hapd_iface->bss = NULL; in hostapd_add_iface()
3909 interfaces->count--; in hostapd_add_iface()
3910 interfaces->iface[interfaces->count] = NULL; in hostapd_add_iface()
3915 return -1; in hostapd_add_iface()
3923 wpa_printf(MSG_INFO, "Remove BSS '%s'", iface->conf->bss[idx]->iface); in hostapd_remove_bss()
3926 if (idx < iface->num_bss) { in hostapd_remove_bss()
3927 struct hostapd_data *hapd = iface->bss[idx]; in hostapd_remove_bss()
3931 __func__, hapd, hapd->conf->iface); in hostapd_remove_bss()
3932 hostapd_config_free_bss(hapd->conf); in hostapd_remove_bss()
3933 hapd->conf = NULL; in hostapd_remove_bss()
3935 hostapd_mld_ref_dec(hapd->mld); in hostapd_remove_bss()
3939 iface->num_bss--; in hostapd_remove_bss()
3941 for (i = idx; i < iface->num_bss; i++) in hostapd_remove_bss()
3942 iface->bss[i] = iface->bss[i + 1]; in hostapd_remove_bss()
3944 hostapd_config_free_bss(iface->conf->bss[idx]); in hostapd_remove_bss()
3945 iface->conf->bss[idx] = NULL; in hostapd_remove_bss()
3948 iface->conf->num_bss--; in hostapd_remove_bss()
3949 for (i = idx; i < iface->conf->num_bss; i++) in hostapd_remove_bss()
3950 iface->conf->bss[i] = iface->conf->bss[i + 1]; in hostapd_remove_bss()
3961 for (i = 0; i < interfaces->count; i++) { in hostapd_remove_iface()
3962 hapd_iface = interfaces->iface[i]; in hostapd_remove_iface()
3964 return -1; in hostapd_remove_iface()
3965 if (!os_strcmp(hapd_iface->conf->bss[0]->iface, buf)) { in hostapd_remove_iface()
3967 hapd_iface->driver_ap_teardown = in hostapd_remove_iface()
3968 !!(hapd_iface->drv_flags & in hostapd_remove_iface()
3973 while (k < (interfaces->count - 1)) { in hostapd_remove_iface()
3974 interfaces->iface[k] = in hostapd_remove_iface()
3975 interfaces->iface[k + 1]; in hostapd_remove_iface()
3978 interfaces->count--; in hostapd_remove_iface()
3984 for (j = 0; j < hapd_iface->conf->num_bss; j++) { in hostapd_remove_iface()
3985 if (!os_strcmp(hapd_iface->conf->bss[j]->iface, buf)) { in hostapd_remove_iface()
3986 hapd_iface->driver_ap_teardown = in hostapd_remove_iface()
3987 !(hapd_iface->drv_flags & in hostapd_remove_iface()
3993 return -1; in hostapd_remove_iface()
3998 * hostapd_new_assoc_sta - Notify that a new station associated with the AP
4001 * @reassoc: 1 to indicate this was a re-association; 0 = first association
4011 if (hapd->tkip_countermeasures) { in hostapd_new_assoc_sta()
4012 hostapd_drv_sta_deauth(hapd, sta->addr, in hostapd_new_assoc_sta()
4019 sta->mld_assoc_link_id != hapd->mld_link_id) in hostapd_new_assoc_sta()
4024 sta->post_csa_sa_query = 0; in hostapd_new_assoc_sta()
4027 if (sta->p2p_ie == NULL && !sta->no_p2p_set) { in hostapd_new_assoc_sta()
4028 sta->no_p2p_set = 1; in hostapd_new_assoc_sta()
4029 hapd->num_sta_no_p2p++; in hostapd_new_assoc_sta()
4030 if (hapd->num_sta_no_p2p == 1) in hostapd_new_assoc_sta()
4040 if (!hapd->conf->ieee802_1x && !hapd->conf->wpa && !hapd->conf->osen) { in hostapd_new_assoc_sta()
4042 os_get_reltime(&sta->connected_time); in hostapd_new_assoc_sta()
4049 if (sta->auth_alg != WLAN_AUTH_FT && in hostapd_new_assoc_sta()
4050 sta->auth_alg != WLAN_AUTH_FILS_SK && in hostapd_new_assoc_sta()
4051 sta->auth_alg != WLAN_AUTH_FILS_SK_PFS && in hostapd_new_assoc_sta()
4052 sta->auth_alg != WLAN_AUTH_FILS_PK && in hostapd_new_assoc_sta()
4053 !(sta->flags & (WLAN_STA_WPS | WLAN_STA_MAYBE_WPS))) in hostapd_new_assoc_sta()
4054 wpa_auth_sm_event(sta->wpa_sm, WPA_REAUTH); in hostapd_new_assoc_sta()
4055 } else if (!(hapd->iface->drv_flags2 & in hostapd_new_assoc_sta()
4057 /* The 4-way handshake offloaded case will have this handled in hostapd_new_assoc_sta()
4059 wpa_auth_sta_associated(hapd->wpa_auth, sta->wpa_sm); in hostapd_new_assoc_sta()
4062 if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_WIRED) { in hostapd_new_assoc_sta()
4067 hapd->conf->iface, __func__, in hostapd_new_assoc_sta()
4068 MAC2STR(sta->addr)); in hostapd_new_assoc_sta()
4070 } else if (!(hapd->iface->drv_flags & in hostapd_new_assoc_sta()
4074 MACSTR " (%d seconds - ap_max_inactivity)", in hostapd_new_assoc_sta()
4075 hapd->conf->iface, __func__, MAC2STR(sta->addr), in hostapd_new_assoc_sta()
4076 hapd->conf->ap_max_inactivity); in hostapd_new_assoc_sta()
4078 eloop_register_timeout(hapd->conf->ap_max_inactivity, 0, in hostapd_new_assoc_sta()
4083 if (hapd->conf->wpa_key_mgmt == WPA_KEY_MGMT_NONE && in hostapd_new_assoc_sta()
4084 hapd->conf->mka_psk_set) in hostapd_new_assoc_sta()
4119 wpa_printf(MSG_INFO, "%s: interface state %s->%s", in hostapd_set_state()
4120 iface->conf ? iface->conf->bss[0]->iface : "N/A", in hostapd_set_state()
4121 hostapd_state_text(iface->state), hostapd_state_text(s)); in hostapd_set_state()
4122 iface->state = s; in hostapd_set_state()
4130 for (i = 0; i < iface->num_bss; i++) in hostapd_csa_in_progress()
4131 if (iface->bss[i]->csa_in_progress) in hostapd_csa_in_progress()
4141 os_free(beacon->head); in free_beacon_data()
4142 beacon->head = NULL; in free_beacon_data()
4143 os_free(beacon->tail); in free_beacon_data()
4144 beacon->tail = NULL; in free_beacon_data()
4145 os_free(beacon->probe_resp); in free_beacon_data()
4146 beacon->probe_resp = NULL; in free_beacon_data()
4147 os_free(beacon->beacon_ies); in free_beacon_data()
4148 beacon->beacon_ies = NULL; in free_beacon_data()
4149 os_free(beacon->proberesp_ies); in free_beacon_data()
4150 beacon->proberesp_ies = NULL; in free_beacon_data()
4151 os_free(beacon->assocresp_ies); in free_beacon_data()
4152 beacon->assocresp_ies = NULL; in free_beacon_data()
4174 ret = -1; in hostapd_build_beacon_data()
4175 beacon->head = os_memdup(params.head, params.head_len); in hostapd_build_beacon_data()
4176 if (!beacon->head) in hostapd_build_beacon_data()
4179 beacon->head_len = params.head_len; in hostapd_build_beacon_data()
4181 beacon->tail = os_memdup(params.tail, params.tail_len); in hostapd_build_beacon_data()
4182 if (!beacon->tail) in hostapd_build_beacon_data()
4185 beacon->tail_len = params.tail_len; in hostapd_build_beacon_data()
4188 beacon->probe_resp = os_memdup(params.proberesp, in hostapd_build_beacon_data()
4190 if (!beacon->probe_resp) in hostapd_build_beacon_data()
4193 beacon->probe_resp_len = params.proberesp_len; in hostapd_build_beacon_data()
4198 beacon->beacon_ies = os_memdup(beacon_extra->buf, in hostapd_build_beacon_data()
4200 if (!beacon->beacon_ies) in hostapd_build_beacon_data()
4203 beacon->beacon_ies_len = wpabuf_len(beacon_extra); in hostapd_build_beacon_data()
4207 beacon->proberesp_ies = os_memdup(proberesp_extra->buf, in hostapd_build_beacon_data()
4209 if (!beacon->proberesp_ies) in hostapd_build_beacon_data()
4212 beacon->proberesp_ies_len = wpabuf_len(proberesp_extra); in hostapd_build_beacon_data()
4216 beacon->assocresp_ies = os_memdup(assocresp_extra->buf, in hostapd_build_beacon_data()
4218 if (!beacon->assocresp_ies) in hostapd_build_beacon_data()
4221 beacon->assocresp_ies_len = wpabuf_len(assocresp_extra); in hostapd_build_beacon_data()
4253 if (!params->channel) { in hostapd_change_config_freq()
4255 params->channel = hostapd_hw_get_channel(hapd, params->freq); in hostapd_change_config_freq()
4258 channel = params->channel; in hostapd_change_config_freq()
4260 return -1; in hostapd_change_config_freq()
4262 hostapd_determine_mode(hapd->iface); in hostapd_change_config_freq()
4263 mode = hapd->iface->current_mode; in hostapd_change_config_freq()
4267 hostapd_set_freq_params(old_params, conf->hw_mode, in hostapd_change_config_freq()
4268 hostapd_hw_get_freq(hapd, conf->channel), in hostapd_change_config_freq()
4269 conf->channel, conf->enable_edmg, in hostapd_change_config_freq()
4270 conf->edmg_channel, conf->ieee80211n, in hostapd_change_config_freq()
4271 conf->ieee80211ac, conf->ieee80211ax, in hostapd_change_config_freq()
4272 conf->ieee80211be, conf->secondary_channel, in hostapd_change_config_freq()
4276 conf->vht_capab, in hostapd_change_config_freq()
4277 mode ? &mode->he_capab[IEEE80211_MODE_AP] : in hostapd_change_config_freq()
4279 mode ? &mode->eht_capab[IEEE80211_MODE_AP] : in hostapd_change_config_freq()
4282 return -1; in hostapd_change_config_freq()
4284 switch (params->bandwidth) { in hostapd_change_config_freq()
4287 conf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; in hostapd_change_config_freq()
4293 conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; in hostapd_change_config_freq()
4296 return -1; in hostapd_change_config_freq()
4299 switch (params->bandwidth) { in hostapd_change_config_freq()
4306 if (params->center_freq2) in hostapd_change_config_freq()
4320 return -1; in hostapd_change_config_freq()
4323 conf->channel = channel; in hostapd_change_config_freq()
4324 conf->ieee80211n = params->ht_enabled; in hostapd_change_config_freq()
4325 conf->ieee80211ac = params->vht_enabled; in hostapd_change_config_freq()
4326 conf->secondary_channel = params->sec_channel_offset; in hostapd_change_config_freq()
4327 if (params->center_freq1 && in hostapd_change_config_freq()
4328 ieee80211_freq_to_chan(params->center_freq1, &seg0) == in hostapd_change_config_freq()
4330 return -1; in hostapd_change_config_freq()
4331 if (params->center_freq2 && in hostapd_change_config_freq()
4332 ieee80211_freq_to_chan(params->center_freq2, in hostapd_change_config_freq()
4334 return -1; in hostapd_change_config_freq()
4347 struct hostapd_iface *iface = hapd->iface; in hostapd_fill_csa_settings()
4356 if (!iface || !iface->freq || hapd->csa_in_progress) in hostapd_fill_csa_settings()
4357 return -1; in hostapd_fill_csa_settings()
4359 switch (settings->freq_params.bandwidth) { in hostapd_fill_csa_settings()
4361 if (settings->freq_params.center_freq2) in hostapd_fill_csa_settings()
4378 settings->freq_params.freq, in hostapd_fill_csa_settings()
4379 settings->freq_params.sec_channel_offset, in hostapd_fill_csa_settings()
4381 &hapd->iface->cs_oper_class, in hostapd_fill_csa_settings()
4385 settings->freq_params.freq, in hostapd_fill_csa_settings()
4386 settings->freq_params.sec_channel_offset, in hostapd_fill_csa_settings()
4387 settings->freq_params.vht_enabled, in hostapd_fill_csa_settings()
4388 settings->freq_params.he_enabled, in hostapd_fill_csa_settings()
4389 settings->freq_params.eht_enabled); in hostapd_fill_csa_settings()
4390 return -1; in hostapd_fill_csa_settings()
4393 settings->freq_params.channel = chan; in hostapd_fill_csa_settings()
4395 ret = hostapd_change_config_freq(iface->bss[0], iface->conf, in hostapd_fill_csa_settings()
4396 &settings->freq_params, in hostapd_fill_csa_settings()
4402 old_punct_bitmap = iface->conf->punct_bitmap; in hostapd_fill_csa_settings()
4403 iface->conf->punct_bitmap = settings->punct_bitmap; in hostapd_fill_csa_settings()
4405 ret = hostapd_build_beacon_data(hapd, &settings->beacon_after); in hostapd_fill_csa_settings()
4409 iface->conf->punct_bitmap = old_punct_bitmap; in hostapd_fill_csa_settings()
4411 hostapd_change_config_freq(iface->bss[0], iface->conf, in hostapd_fill_csa_settings()
4418 hapd->cs_freq_params = settings->freq_params; in hostapd_fill_csa_settings()
4419 hapd->cs_count = settings->cs_count; in hostapd_fill_csa_settings()
4420 hapd->cs_block_tx = settings->block_tx; in hostapd_fill_csa_settings()
4422 ret = hostapd_build_beacon_data(hapd, &settings->beacon_csa); in hostapd_fill_csa_settings()
4424 free_beacon_data(&settings->beacon_after); in hostapd_fill_csa_settings()
4428 settings->counter_offset_beacon[0] = hapd->cs_c_off_beacon; in hostapd_fill_csa_settings()
4429 settings->counter_offset_presp[0] = hapd->cs_c_off_proberesp; in hostapd_fill_csa_settings()
4430 settings->counter_offset_beacon[1] = hapd->cs_c_off_ecsa_beacon; in hostapd_fill_csa_settings()
4431 settings->counter_offset_presp[1] = hapd->cs_c_off_ecsa_proberesp; in hostapd_fill_csa_settings()
4432 settings->link_id = -1; in hostapd_fill_csa_settings()
4434 if (hapd->conf->mld_ap) in hostapd_fill_csa_settings()
4435 settings->link_id = hapd->mld_link_id; in hostapd_fill_csa_settings()
4439 settings->ubpr.unsol_bcast_probe_resp_tmpl = in hostapd_fill_csa_settings()
4440 hostapd_unsol_bcast_probe_resp(hapd, &settings->ubpr); in hostapd_fill_csa_settings()
4449 os_memset(&hapd->cs_freq_params, 0, sizeof(hapd->cs_freq_params)); in hostapd_cleanup_cs_params()
4450 hapd->cs_count = 0; in hostapd_cleanup_cs_params()
4451 hapd->cs_block_tx = 0; in hostapd_cleanup_cs_params()
4452 hapd->cs_c_off_beacon = 0; in hostapd_cleanup_cs_params()
4453 hapd->cs_c_off_proberesp = 0; in hostapd_cleanup_cs_params()
4454 hapd->csa_in_progress = 0; in hostapd_cleanup_cs_params()
4455 hapd->cs_c_off_ecsa_beacon = 0; in hostapd_cleanup_cs_params()
4456 hapd->cs_c_off_ecsa_proberesp = 0; in hostapd_cleanup_cs_params()
4463 if (freq_params->eht_enabled) in hostapd_chan_switch_config()
4464 hapd->iconf->ch_switch_eht_config |= CH_SWITCH_EHT_ENABLED; in hostapd_chan_switch_config()
4466 hapd->iconf->ch_switch_eht_config |= CH_SWITCH_EHT_DISABLED; in hostapd_chan_switch_config()
4468 if (freq_params->he_enabled) in hostapd_chan_switch_config()
4469 hapd->iconf->ch_switch_he_config |= CH_SWITCH_HE_ENABLED; in hostapd_chan_switch_config()
4471 hapd->iconf->ch_switch_he_config |= CH_SWITCH_HE_DISABLED; in hostapd_chan_switch_config()
4473 if (freq_params->vht_enabled) in hostapd_chan_switch_config()
4474 hapd->iconf->ch_switch_vht_config |= CH_SWITCH_VHT_ENABLED; in hostapd_chan_switch_config()
4476 hapd->iconf->ch_switch_vht_config |= CH_SWITCH_VHT_DISABLED; in hostapd_chan_switch_config()
4481 hapd->iconf->ch_switch_eht_config, in hostapd_chan_switch_config()
4482 hapd->iconf->ch_switch_he_config, in hostapd_chan_switch_config()
4483 hapd->iconf->ch_switch_vht_config); in hostapd_chan_switch_config()
4492 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) { in hostapd_switch_channel()
4494 return -1; in hostapd_switch_channel()
4502 free_beacon_data(&settings->beacon_csa); in hostapd_switch_channel()
4503 free_beacon_data(&settings->beacon_after); in hostapd_switch_channel()
4505 os_free(settings->ubpr.unsol_bcast_probe_resp_tmpl); in hostapd_switch_channel()
4514 hapd->csa_in_progress = 1; in hostapd_switch_channel()
4527 wpa_printf(MSG_DEBUG, "Restarting all CSA-related BSSes"); in hostapd_switch_channel_fallback()
4529 if (freq_params->center_freq1) in hostapd_switch_channel_fallback()
4530 ieee80211_freq_to_chan(freq_params->center_freq1, &seg0_idx); in hostapd_switch_channel_fallback()
4531 if (freq_params->center_freq2) in hostapd_switch_channel_fallback()
4532 ieee80211_freq_to_chan(freq_params->center_freq2, &seg1_idx); in hostapd_switch_channel_fallback()
4534 switch (freq_params->bandwidth) { in hostapd_switch_channel_fallback()
4541 if (freq_params->center_freq2) { in hostapd_switch_channel_fallback()
4543 iface->conf->vht_capab |= in hostapd_switch_channel_fallback()
4551 iface->conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; in hostapd_switch_channel_fallback()
4558 freq_params->bandwidth); in hostapd_switch_channel_fallback()
4562 iface->freq = freq_params->freq; in hostapd_switch_channel_fallback()
4563 iface->conf->channel = freq_params->channel; in hostapd_switch_channel_fallback()
4564 iface->conf->secondary_channel = freq_params->sec_channel_offset; in hostapd_switch_channel_fallback()
4565 if (ieee80211_freq_to_channel_ext(freq_params->freq, in hostapd_switch_channel_fallback()
4566 freq_params->sec_channel_offset, bw, in hostapd_switch_channel_fallback()
4569 chan != freq_params->channel) in hostapd_switch_channel_fallback()
4570 wpa_printf(MSG_INFO, "CSA: Channel mismatch: %d -> %d", in hostapd_switch_channel_fallback()
4571 freq_params->channel, chan); in hostapd_switch_channel_fallback()
4573 iface->conf->op_class = op_class; in hostapd_switch_channel_fallback()
4574 hostapd_set_oper_centr_freq_seg0_idx(iface->conf, seg0_idx); in hostapd_switch_channel_fallback()
4575 hostapd_set_oper_centr_freq_seg1_idx(iface->conf, seg1_idx); in hostapd_switch_channel_fallback()
4576 hostapd_set_oper_chwidth(iface->conf, bw); in hostapd_switch_channel_fallback()
4577 iface->conf->ieee80211n = freq_params->ht_enabled; in hostapd_switch_channel_fallback()
4578 iface->conf->ieee80211ac = freq_params->vht_enabled; in hostapd_switch_channel_fallback()
4579 iface->conf->ieee80211ax = freq_params->he_enabled; in hostapd_switch_channel_fallback()
4580 iface->conf->ieee80211be = freq_params->eht_enabled; in hostapd_switch_channel_fallback()
4596 hapd->cca_count = 0; in hostapd_cleanup_cca_params()
4597 hapd->cca_color = 0; in hostapd_cleanup_cca_params()
4598 hapd->cca_c_off_beacon = 0; in hostapd_cleanup_cca_params()
4599 hapd->cca_c_off_proberesp = 0; in hostapd_cleanup_cca_params()
4600 hapd->cca_in_progress = false; in hostapd_cleanup_cca_params()
4607 struct hostapd_iface *iface = hapd->iface; in hostapd_fill_cca_settings()
4611 if (!iface || iface->conf->he_op.he_bss_color_disabled) in hostapd_fill_cca_settings()
4612 return -1; in hostapd_fill_cca_settings()
4614 settings->link_id = -1; in hostapd_fill_cca_settings()
4616 if (hapd->conf->mld_ap) in hostapd_fill_cca_settings()
4617 settings->link_id = hapd->mld_link_id; in hostapd_fill_cca_settings()
4620 old_color = iface->conf->he_op.he_bss_color; in hostapd_fill_cca_settings()
4621 iface->conf->he_op.he_bss_color = hapd->cca_color; in hostapd_fill_cca_settings()
4622 ret = hostapd_build_beacon_data(hapd, &settings->beacon_after); in hostapd_fill_cca_settings()
4626 iface->conf->he_op.he_bss_color = old_color; in hostapd_fill_cca_settings()
4628 settings->cca_count = hapd->cca_count; in hostapd_fill_cca_settings()
4629 settings->cca_color = hapd->cca_color, in hostapd_fill_cca_settings()
4630 hapd->cca_in_progress = true; in hostapd_fill_cca_settings()
4632 ret = hostapd_build_beacon_data(hapd, &settings->beacon_cca); in hostapd_fill_cca_settings()
4634 free_beacon_data(&settings->beacon_after); in hostapd_fill_cca_settings()
4638 settings->ubpr.unsol_bcast_probe_resp_tmpl = in hostapd_fill_cca_settings()
4639 hostapd_unsol_bcast_probe_resp(hapd, &settings->ubpr); in hostapd_fill_cca_settings()
4641 settings->counter_offset_beacon = hapd->cca_c_off_beacon; in hostapd_fill_cca_settings()
4642 settings->counter_offset_presp = hapd->cca_c_off_proberesp; in hostapd_fill_cca_settings()
4659 delta_t = hapd->last_color_collision.sec - in hostapd_switch_color_timeout_handler()
4660 hapd->first_color_collision.sec; in hostapd_switch_color_timeout_handler()
4666 if (r && !(hapd->color_collision_bitmap & (1ULL << r))) in hostapd_switch_color_timeout_handler()
4676 hapd->iface->conf->he_op.he_bss_color_disabled = 1; in hostapd_switch_color_timeout_handler()
4677 hapd->iface->conf->he_op.he_bss_color = os_random() % 63 + 1; in hostapd_switch_color_timeout_handler()
4678 for (b = 0; b < hapd->iface->num_bss; b++) in hostapd_switch_color_timeout_handler()
4679 ieee802_11_set_beacon(hapd->iface->bss[b]); in hostapd_switch_color_timeout_handler()
4683 for (b = 0; b < hapd->iface->num_bss; b++) { in hostapd_switch_color_timeout_handler()
4684 struct hostapd_data *bss = hapd->iface->bss[b]; in hostapd_switch_color_timeout_handler()
4689 bss->cca_color = r; in hostapd_switch_color_timeout_handler()
4690 bss->cca_count = 10; in hostapd_switch_color_timeout_handler()
4712 if (hapd->cca_in_progress) in hostapd_switch_color()
4718 hapd->color_collision_bitmap = bitmap; in hostapd_switch_color()
4719 hapd->last_color_collision = now; in hostapd_switch_color()
4725 hapd->first_color_collision = now; in hostapd_switch_color()
4742 for (i = 0; i < interfaces->count; i++) { in hostapd_get_iface()
4743 struct hostapd_iface *iface = interfaces->iface[i]; in hostapd_get_iface()
4745 for (j = 0; j < iface->num_bss; j++) { in hostapd_get_iface()
4746 struct hostapd_data *hapd = iface->bss[j]; in hostapd_get_iface()
4748 if (os_strcmp(ifname, hapd->conf->iface) == 0) in hostapd_get_iface()
4763 for (i = 0; i < iface->num_bss; i++) { in hostapd_periodic_iface()
4764 struct hostapd_data *hapd = iface->bss[i]; in hostapd_periodic_iface()
4766 if (!hapd->started) in hostapd_periodic_iface()
4782 wpa_printf(MSG_DEBUG, "OCV: Post-CSA SA Query initiation check"); in hostapd_ocv_check_csa_sa_query()
4784 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_ocv_check_csa_sa_query()
4785 if (!sta->post_csa_sa_query) in hostapd_ocv_check_csa_sa_query()
4789 " did not start SA Query after CSA - disconnect", in hostapd_ocv_check_csa_sa_query()
4790 MAC2STR(sta->addr)); in hostapd_ocv_check_csa_sa_query()
4791 ap_sta_disconnect(hapd, sta, sta->addr, in hostapd_ocv_check_csa_sa_query()
4807 for (i = 0; i < hapd->iface->interfaces->count; i++) { in hostapd_mld_get_link_bss()
4808 iface = hapd->iface->interfaces->iface[i]; in hostapd_mld_get_link_bss()
4812 for (j = 0; j < iface->num_bss; j++) { in hostapd_mld_get_link_bss()
4813 bss = iface->bss[j]; in hostapd_mld_get_link_bss()
4815 if (!bss->conf->mld_ap || in hostapd_mld_get_link_bss()
4819 if (!bss->drv_priv) in hostapd_mld_get_link_bss()
4822 if (bss->mld_link_id == link_id) in hostapd_mld_get_link_bss()
4834 if (!hapd1->conf->mld_ap || !hapd2->conf->mld_ap) in hostapd_is_ml_partner()
4837 return !os_strcmp(hapd1->conf->iface, hapd2->conf->iface); in hostapd_is_ml_partner()
4843 if (!hapd->conf->mld_ap) in hostapd_get_mld_id()
4855 struct hostapd_mld *mld = hapd->mld; in hostapd_mld_add_link()
4857 if (!hapd->conf->mld_ap) in hostapd_mld_add_link()
4862 return -1; in hostapd_mld_add_link()
4864 dl_list_add_tail(&mld->links, &hapd->link); in hostapd_mld_add_link()
4865 mld->num_links++; in hostapd_mld_add_link()
4868 mld->name, hapd->mld_link_id, mld->num_links); in hostapd_mld_add_link()
4870 if (mld->fbss) in hostapd_mld_add_link()
4873 mld->fbss = hapd; in hostapd_mld_add_link()
4875 mld->name, mld->fbss); in hostapd_mld_add_link()
4882 struct hostapd_mld *mld = hapd->mld; in hostapd_mld_remove_link()
4885 if (!hapd->conf->mld_ap) in hostapd_mld_remove_link()
4890 return -1; in hostapd_mld_remove_link()
4892 dl_list_del(&hapd->link); in hostapd_mld_remove_link()
4893 mld->num_links--; in hostapd_mld_remove_link()
4896 mld->name, hapd->mld_link_id, mld->num_links); in hostapd_mld_remove_link()
4898 if (mld->fbss != hapd) in hostapd_mld_remove_link()
4902 if (dl_list_empty(&mld->links)) { in hostapd_mld_remove_link()
4903 mld->fbss = NULL; in hostapd_mld_remove_link()
4905 next_fbss = dl_list_entry(mld->links.next, struct hostapd_data, in hostapd_mld_remove_link()
4907 mld->fbss = next_fbss; in hostapd_mld_remove_link()
4911 mld->name, mld->fbss); in hostapd_mld_remove_link()
4918 struct hostapd_mld *mld = hapd->mld; in hostapd_mld_is_first_bss()
4920 if (!hapd->conf->mld_ap) in hostapd_mld_is_first_bss()
4929 if (!mld->fbss) in hostapd_mld_is_first_bss()
4932 return hapd == mld->fbss; in hostapd_mld_is_first_bss()
4938 struct hostapd_mld *mld = hapd->mld; in hostapd_mld_get_first_bss()
4940 if (!hapd->conf->mld_ap) in hostapd_mld_get_first_bss()
4947 return mld->fbss; in hostapd_mld_get_first_bss()
4958 punct_bitmap = hapd->iconf->punct_bitmap; in hostapd_get_punct_bitmap()
4961 punct_bitmap = hapd->conf->eht_oper_puncturing_override; in hostapd_get_punct_bitmap()