Lines Matching refs:hapd
62 static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason);
64 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd);
65 static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd);
96 struct hostapd_data * hostapd_mbssid_get_tx_bss(struct hostapd_data *hapd) in hostapd_mbssid_get_tx_bss() argument
98 if (hapd->iconf->mbssid) in hostapd_mbssid_get_tx_bss()
99 return hapd->iface->bss[0]; in hostapd_mbssid_get_tx_bss()
101 return hapd; in hostapd_mbssid_get_tx_bss()
105 int hostapd_mbssid_get_bss_index(struct hostapd_data *hapd) in hostapd_mbssid_get_bss_index() argument
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()
119 void hostapd_reconfig_encryption(struct hostapd_data *hapd) in hostapd_reconfig_encryption() argument
121 if (hapd->wpa_auth) in hostapd_reconfig_encryption()
124 hostapd_set_privacy(hapd, 0); in hostapd_reconfig_encryption()
126 hostapd_setup_encryption(hapd->conf->iface, hapd); in hostapd_reconfig_encryption()
131 static void hostapd_reload_bss(struct hostapd_data *hapd) in hostapd_reload_bss() argument
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()
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()
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()
166 hostapd_setup_wpa(hapd); 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()
172 hostapd_reconfig_wpa(hapd); in hostapd_reload_bss()
173 wpa_ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &wpa_ie_len); in hostapd_reload_bss()
174 if (hostapd_set_generic_elem(hapd, wpa_ie, 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()
180 hostapd_set_privacy(hapd, 0); in hostapd_reload_bss()
182 hostapd_setup_encryption(hapd->conf->iface, hapd); in hostapd_reload_bss()
184 hostapd_set_generic_elem(hapd, (u8 *) "", 0); in hostapd_reload_bss()
187 hostapd_neighbor_sync_own_report(hapd); in hostapd_reload_bss()
189 ieee802_11_set_beacon(hapd); in hostapd_reload_bss()
190 hostapd_update_wps(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()
254 struct hostapd_data *hapd = iface->bss[0]; in hostapd_reload_config() local
273 oldconf = hapd->iconf; in hostapd_reload_config()
287 hostapd_remove_iface(interfaces, hapd->conf->iface); 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()
312 hostapd_clear_old_bss(hapd); 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()
330 hostapd_reload_bss(hapd); in hostapd_reload_config()
342 static void hostapd_broadcast_key_clear_iface(struct hostapd_data *hapd, in hostapd_broadcast_key_clear_iface() argument
347 if (!ifname || !hapd->drv_priv) in hostapd_broadcast_key_clear_iface()
350 if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i, 0, in hostapd_broadcast_key_clear_iface()
357 if (hapd->conf->ieee80211w) { in hostapd_broadcast_key_clear_iface()
359 if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, in hostapd_broadcast_key_clear_iface()
371 static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd) in hostapd_broadcast_wep_clear() argument
373 hostapd_broadcast_key_clear_iface(hapd, hapd->conf->iface); in hostapd_broadcast_wep_clear()
378 static int hostapd_broadcast_wep_set(struct hostapd_data *hapd) in hostapd_broadcast_wep_set() argument
381 struct hostapd_ssid *ssid = &hapd->conf->ssid; in hostapd_broadcast_wep_set()
385 hostapd_drv_set_key(hapd->conf->iface, in hostapd_broadcast_wep_set()
386 hapd, WPA_ALG_WEP, broadcast_ether_addr, idx, 0, in hostapd_broadcast_wep_set()
408 struct hostapd_data *hapd = (struct hostapd_data *) eloop_data; in hostapd_link_remove_timeout_handler() local
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()
418 ieee802_11_set_beacon(hapd); in hostapd_link_remove_timeout_handler()
420 if (!hapd->eht_mld_link_removal_count) { in hostapd_link_remove_timeout_handler()
421 hostapd_free_link_stas(hapd); 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()
428 hapd, NULL); in hostapd_link_remove_timeout_handler()
432 int hostapd_link_remove(struct hostapd_data *hapd, u32 count) in hostapd_link_remove() argument
434 if (!hapd->conf->mld_ap) 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()
446 hapd, NULL); in hostapd_link_remove()
448 ieee802_11_set_beacon(hapd); in hostapd_link_remove()
456 void hostapd_free_hapd_data(struct hostapd_data *hapd) in hostapd_free_hapd_data() argument
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()
478 accounting_deinit(hapd); in hostapd_free_hapd_data()
479 hostapd_deinit_wpa(hapd); in hostapd_free_hapd_data()
480 vlan_deinit(hapd); in hostapd_free_hapd_data()
481 hostapd_acl_deinit(hapd); in hostapd_free_hapd_data()
483 if (hostapd_mld_is_first_bss(hapd)) { in hostapd_free_hapd_data()
485 struct hapd_interfaces *ifaces = hapd->iface->interfaces; in hostapd_free_hapd_data()
495 if (hapd == h) in hostapd_free_hapd_data()
497 if (h->radius == hapd->radius) in hostapd_free_hapd_data()
499 if (h->radius_das == hapd->radius_das) 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()
511 hostapd_deinit_wps(hapd); in hostapd_free_hapd_data()
512 ieee802_1x_dealloc_kay_sm_hapd(hapd); in hostapd_free_hapd_data()
514 hostapd_dpp_deinit(hapd); 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()
519 hostapd_nan_usd_deinit(hapd); in hostapd_free_hapd_data()
522 authsrv_deinit(hapd); 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()
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()
555 gas_serv_deinit(hapd); in hostapd_free_hapd_data()
558 bss_load_update_deinit(hapd); in hostapd_free_hapd_data()
559 ndisc_snoop_deinit(hapd); in hostapd_free_hapd_data()
560 dhcp_snoop_deinit(hapd); in hostapd_free_hapd_data()
561 x_snoop_deinit(hapd); 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()
579 hostapd_clean_rrm(hapd); in hostapd_free_hapd_data()
581 fils_hlp_deinit(hapd); in hostapd_free_hapd_data()
584 eloop_cancel_timeout(hostapd_ocv_check_csa_sa_query, hapd, NULL); in hostapd_free_hapd_data()
591 while ((q = dl_list_first(&hapd->sae_commit_queue, in hostapd_free_hapd_data()
598 eloop_cancel_timeout(auth_sae_process_commit, hapd, NULL); in hostapd_free_hapd_data()
602 eloop_cancel_timeout(hostapd_switch_color_timeout_handler, hapd, NULL); in hostapd_free_hapd_data()
605 eloop_cancel_timeout(hostapd_link_remove_timeout_handler, hapd, NULL); in hostapd_free_hapd_data()
620 static void hostapd_bss_link_deinit(struct hostapd_data *hapd) in hostapd_bss_link_deinit() argument
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()
643 hostapd_mld_remove_link(hapd); in hostapd_bss_link_deinit()
656 static void hostapd_cleanup(struct hostapd_data *hapd) in hostapd_cleanup() argument
658 wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s))", __func__, hapd, in hostapd_cleanup()
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()
665 hostapd_free_hapd_data(hapd); in hostapd_cleanup()
734 static void hostapd_clear_wep(struct hostapd_data *hapd) in hostapd_clear_wep() argument
736 if (hapd->drv_priv && !hapd->iface->driver_ap_teardown && hapd->conf) { in hostapd_clear_wep()
737 hostapd_set_privacy(hapd, 0); in hostapd_clear_wep()
738 hostapd_broadcast_wep_clear(hapd); in hostapd_clear_wep()
743 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd) in hostapd_setup_encryption() argument
747 hostapd_broadcast_wep_set(hapd); in hostapd_setup_encryption()
749 if (hapd->conf->ssid.wep.default_len) { in hostapd_setup_encryption()
750 hostapd_set_privacy(hapd, 1); 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()
762 hostapd_drv_set_key(iface, hapd, WPA_ALG_WEP, NULL, i, 0, 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()
773 if (hapd->conf->ssid.wep.key[i] && in hostapd_setup_encryption()
774 i == hapd->conf->ssid.wep.idx) in hostapd_setup_encryption()
775 hostapd_set_privacy(hapd, 1); in hostapd_setup_encryption()
784 static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason) in hostapd_flush_old_stations() argument
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()
796 if (hostapd_flush(hapd)) { in hostapd_flush_old_stations()
797 wpa_msg(hapd->msg_ctx, MSG_WARNING, 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()
806 hostapd_drv_sta_deauth(hapd, addr, reason); in hostapd_flush_old_stations()
808 hostapd_free_stas(hapd); in hostapd_flush_old_stations()
814 void hostapd_bss_deinit_no_free(struct hostapd_data *hapd) in hostapd_bss_deinit_no_free() argument
816 hostapd_free_stas(hapd); in hostapd_bss_deinit_no_free()
817 hostapd_flush_old_stations(hapd, WLAN_REASON_DEAUTH_LEAVING); in hostapd_bss_deinit_no_free()
819 hostapd_clear_wep(hapd); in hostapd_bss_deinit_no_free()
834 struct hostapd_data *hapd = iface->bss[0]; in hostapd_validate_bssid_configuration() local
838 if (hostapd_drv_none(hapd)) in hostapd_validate_bssid_configuration()
862 hapd->own_addr[i]; 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()
939 static int hostapd_das_nas_mismatch(struct hostapd_data *hapd, in hostapd_das_nas_mismatch() argument
943 (!hapd->conf->nas_identifier || in hostapd_das_nas_mismatch()
944 os_strlen(hapd->conf->nas_identifier) != in hostapd_das_nas_mismatch()
946 os_memcmp(hapd->conf->nas_identifier, attr->nas_identifier, 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()
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()
974 static struct sta_info * hostapd_das_find_sta(struct hostapd_data *hapd, in hostapd_das_find_sta() argument
985 for (sta = hapd->sta_list; sta; sta = sta->next) in hostapd_das_find_sta()
990 sta = ap_get_sta(hapd, attr->sta_addr); in hostapd_das_find_sta()
998 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1014 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1042 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1073 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1100 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1138 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1152 static int hostapd_das_disconnect_pmksa(struct hostapd_data *hapd, in hostapd_das_disconnect_pmksa() argument
1155 if (!hapd->wpa_auth) in hostapd_das_disconnect_pmksa()
1157 return wpa_auth_radius_das_disconnect_pmksa(hapd->wpa_auth, attr); in hostapd_das_disconnect_pmksa()
1164 struct hostapd_data *hapd = ctx; 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()
1178 if (hostapd_das_disconnect_pmksa(hapd, attr) == 0) { 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()
1193 ap_sta_deauthenticate(hapd, sta, WLAN_REASON_PREV_AUTH_NOT_VALID); in hostapd_das_disconnect()
1203 struct hostapd_data *hapd = ctx; 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()
1231 hs20_t_c_filtering(hapd, sta, 0); in hostapd_das_coa()
1280 static int hostapd_start_beacon(struct hostapd_data *hapd, in hostapd_start_beacon() argument
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()
1296 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, in hostapd_start_beacon()
1299 hostapd_drv_sta_deauth(hapd, addr, 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()
1311 static int hostapd_bss_radius_init(struct hostapd_data *hapd) in hostapd_bss_radius_init() argument
1315 if (!hapd) 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()
1347 das_conf.ctx = hapd; 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()
1380 static int hostapd_setup_bss(struct hostapd_data *hapd, int first, in hostapd_setup_bss() argument
1383 struct hostapd_bss_config *conf = hapd->conf; in hostapd_setup_bss()
1390 if (!hostapd_mld_is_first_bss(hapd)) in hostapd_setup_bss()
1395 __func__, hapd, conf->iface, first); in hostapd_setup_bss()
1404 if (hapd->started) { in hostapd_setup_bss()
1409 hapd->started = 1; in hostapd_setup_bss()
1412 u8 *addr = hapd->own_addr; 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()
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()
1439 h_hapd = hostapd_mld_get_first_bss(hapd); 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()
1443 hostapd_mld_add_link(hapd); 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()
1459 MACSTR ")", MAC2STR(hapd->own_addr)); in hostapd_setup_bss()
1460 hapd->interface_added = 0; 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()
1474 hostapd_mld_add_link(hapd); 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()
1495 conf->wmm_enabled = hapd->iconf->ieee80211n | in hostapd_setup_bss()
1496 hapd->iconf->ieee80211ax; 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()
1509 hostapd_flush(hapd); in hostapd_setup_bss()
1510 hostapd_set_privacy(hapd, 0); in hostapd_setup_bss()
1513 if (!hostapd_drv_nl80211(hapd)) in hostapd_setup_bss()
1514 hostapd_broadcast_wep_clear(hapd); in hostapd_setup_bss()
1515 if (hostapd_setup_encryption(conf->iface, hapd)) in hostapd_setup_bss()
1524 ssid_len = hostapd_get_ssid(hapd, ssid, sizeof(ssid)); in hostapd_setup_bss()
1554 if (!hostapd_drv_none(hapd)) { in hostapd_setup_bss()
1557 conf->iface, MAC2STR(hapd->own_addr), in hostapd_setup_bss()
1568 if (set_ssid && hostapd_set_ssid(hapd, conf->ssid.ssid, in hostapd_setup_bss()
1581 &hapd->rad_attr_db)) { 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()
1595 if (hostapd_mld_is_first_bss(hapd)) { in hostapd_setup_bss()
1596 if (hostapd_bss_radius_init(hapd)) in hostapd_setup_bss()
1602 f_bss = hostapd_mld_get_first_bss(hapd); 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()
1622 if (hostapd_acl_init(hapd)) { in hostapd_setup_bss()
1626 if (hostapd_init_wps(hapd, conf)) 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()
1633 if (hostapd_dpp_init(hapd)) in hostapd_setup_bss()
1638 if (hostapd_nan_usd_init(hapd) < 0) in hostapd_setup_bss()
1642 if (authsrv_init(hapd) < 0) in hostapd_setup_bss()
1645 if (ieee802_1x_init(hapd)) { in hostapd_setup_bss()
1650 if ((conf->wpa || conf->osen) && hostapd_setup_wpa(hapd)) in hostapd_setup_bss()
1653 if (accounting_init(hapd)) { in hostapd_setup_bss()
1659 if (gas_serv_init(hapd)) { in hostapd_setup_bss()
1666 hostapd_drv_set_qos_map(hapd, conf->qos_map_set, in hostapd_setup_bss()
1672 if (conf->bss_load_update_period && bss_load_update_init(hapd)) { in hostapd_setup_bss()
1685 hapd, DRV_BR_PORT_ATTR_MCAST2UCAST, 1); in hostapd_setup_bss()
1690 hapd, DRV_BR_PORT_ATTR_HAIRPIN_MODE, 1); in hostapd_setup_bss()
1694 if (x_snoop_init(hapd)) { in hostapd_setup_bss()
1700 if (dhcp_snoop_init(hapd)) { in hostapd_setup_bss()
1706 if (ndisc_snoop_init(hapd)) { in hostapd_setup_bss()
1713 if (!hostapd_drv_none(hapd) && vlan_init(hapd)) { in hostapd_setup_bss()
1718 if (start_beacon && hostapd_start_beacon(hapd, flush_old_stations) < 0) in hostapd_setup_bss()
1721 if (hapd->wpa_auth && wpa_init_keys(hapd->wpa_auth) < 0) in hostapd_setup_bss()
1730 struct hostapd_data *hapd = iface->bss[0]; in hostapd_tx_queue_params() local
1735 if ((hapd->conf->mesh & MESH_ENABLED) && iface->mconf == NULL) in hostapd_tx_queue_params()
1742 if (hostapd_set_tx_queue_params(hapd, i, p->aifs, p->cwmin, in hostapd_tx_queue_params()
1752 static int hostapd_set_acl_list(struct hostapd_data *hapd, in hostapd_set_acl_list() argument
1771 err = hostapd_drv_set_acl(hapd, acl_params); in hostapd_set_acl_list()
1779 int hostapd_set_acl(struct hostapd_data *hapd) in hostapd_set_acl() argument
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()
1790 err = hostapd_set_acl_list(hapd, conf->bss[0]->accept_mac, in hostapd_set_acl()
1799 err = hostapd_set_acl_list(hapd, conf->bss[0]->deny_mac, in hostapd_set_acl()
1811 static int start_ctrl_iface_bss(struct hostapd_data *hapd) in start_ctrl_iface_bss() argument
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()
1836 struct hostapd_data *hapd = iface->bss[i]; in start_ctrl_iface() local
1837 if (iface->interfaces->ctrl_iface_init(hapd)) { in start_ctrl_iface()
1840 hapd->conf->iface); in start_ctrl_iface()
2007 struct hostapd_data *hapd = iface->bss[0]; in setup_interface() local
2020 const char *phy = hostapd_drv_get_radio_name(hapd); 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()
2047 if (hapd->iconf->country[0] && hapd->iconf->country[1]) { in setup_interface()
2051 if (hostapd_get_country(hapd, previous_country) < 0) in setup_interface()
2054 os_memcpy(country, hapd->iconf->country, 3); in setup_interface()
2056 if (hostapd_set_country(hapd, country) < 0) { in setup_interface()
2237 struct hostapd_data *hapd = ctx; in fst_hostapd_get_bssid_cb() local
2239 return hapd->own_addr; in fst_hostapd_get_bssid_cb()
2247 struct hostapd_data *hapd = ctx; in fst_hostapd_get_channel_info_cb() local
2249 *hw_mode = ieee80211_freq_to_chan(hapd->iface->freq, channel); in fst_hostapd_get_channel_info_cb()
2256 struct hostapd_data *hapd = ctx; in fst_hostapd_get_hw_modes_cb() local
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()
2265 struct hostapd_data *hapd = ctx; in fst_hostapd_set_ies_cb() local
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()
2269 if (ieee802_11_set_beacon(hapd)) in fst_hostapd_set_ies_cb()
2278 struct hostapd_data *hapd = ctx; in fst_hostapd_send_action_cb() local
2280 return hostapd_drv_send_action(hapd, hapd->iface->freq, 0, da, in fst_hostapd_send_action_cb()
2287 struct hostapd_data *hapd = ctx; in fst_hostapd_get_mb_ie_cb() local
2288 struct sta_info *sta = ap_get_sta(hapd, addr); in fst_hostapd_get_mb_ie_cb()
2297 struct hostapd_data *hapd = ctx; in fst_hostapd_update_mb_ie_cb() local
2298 struct sta_info *sta = ap_get_sta(hapd, addr); in fst_hostapd_update_mb_ie_cb()
2336 struct hostapd_data *hapd = ctx; in fst_hostapd_get_peer_first() local
2338 *get_ctx = (struct fst_get_peer_ctx *) hapd->sta_list; in fst_hostapd_get_peer_first()
2352 void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd, in fst_hostapd_fill_iface_obj() argument
2356 iface_obj->ctx = hapd; in fst_hostapd_fill_iface_obj()
2374 struct hostapd_data *hapd = ctx; in hostapd_owe_iface_iter() local
2380 if (os_strcmp(hapd->conf->owe_transition_ifname, in hostapd_owe_iface_iter()
2387 hapd->conf->iface, bss->conf->iface, 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()
2399 hapd->conf->owe_transition_ssid_len = bss->conf->ssid.ssid_len; in hostapd_owe_iface_iter()
2409 int hostapd_owe_trans_get_info(struct hostapd_data *hapd) in hostapd_owe_trans_get_info() argument
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()
2477 struct hostapd_data *hapd; in hostapd_interface_setup_failure_handler() local
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() local
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()
2574 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, 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()
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()
2606 hostapd_bss_deinit_no_free(hapd); in hostapd_setup_interface_complete_sync()
2607 hostapd_free_hapd_data(hapd); 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()
2621 if (hostapd_start_beacon(hapd, true)) { in hostapd_setup_interface_complete_sync()
2623 hapd = iface->bss[j]; in hostapd_setup_interface_complete_sync()
2624 hostapd_bss_deinit_no_free(hapd); in hostapd_setup_interface_complete_sync()
2625 hostapd_free_hapd_data(hapd); in hostapd_setup_interface_complete_sync()
2635 hapd = iface->bss[0]; in hostapd_setup_interface_complete_sync()
2641 hostapd_set_acl(hapd); in hostapd_setup_interface_complete_sync()
2643 if (hostapd_driver_commit(hapd) < 0) { in hostapd_setup_interface_complete_sync()
2675 if (hapd->iconf->fst_cfg.group_id[0]) { in hostapd_setup_interface_complete_sync()
2678 fst_hostapd_fill_iface_obj(hapd, &iface_obj); 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()
2683 hapd->iconf->fst_cfg.group_id); 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()
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()
2736 } else if (hapd->setup_complete_cb) { in hostapd_setup_interface_complete_sync()
2761 struct hostapd_data *hapd = iface->bss[0]; in hostapd_setup_interface_complete() local
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()
2889 struct hostapd_data *hapd; in hostapd_alloc_bss_data() local
2891 hapd = os_zalloc(sizeof(*hapd)); in hostapd_alloc_bss_data()
2892 if (hapd == NULL) in hostapd_alloc_bss_data()
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()
2913 return hapd; in hostapd_alloc_bss_data()
2917 static void hostapd_bss_deinit(struct hostapd_data *hapd) in hostapd_bss_deinit() argument
2919 if (!hapd) in hostapd_bss_deinit()
2922 hapd->conf ? hapd->conf->iface : "N/A"); in hostapd_bss_deinit()
2923 hostapd_bss_deinit_no_free(hapd); 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()
2932 hostapd_bss_link_deinit(hapd); in hostapd_bss_deinit()
2933 hostapd_cleanup(hapd); in hostapd_bss_deinit()
3039 static void hostapd_bss_alloc_link_id(struct hostapd_data *hapd) in hostapd_bss_alloc_link_id() argument
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()
3048 static void hostapd_bss_setup_multi_link(struct hostapd_data *hapd, in hostapd_bss_setup_multi_link() argument
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()
3068 hapd->mld = mld; in hostapd_bss_setup_multi_link()
3070 hostapd_bss_alloc_link_id(hapd); in hostapd_bss_setup_multi_link()
3074 if (hapd->mld) in hostapd_bss_setup_multi_link()
3086 hapd->mld = mld; in hostapd_bss_setup_multi_link()
3088 hostapd_bss_alloc_link_id(hapd); in hostapd_bss_setup_multi_link()
3106 hapd->mld = NULL; in hostapd_bss_setup_multi_link()
3203 struct hostapd_data *hapd; in hostapd_init() local
3226 hapd = hapd_iface->bss[i] = in hostapd_init()
3229 if (hapd == NULL) in hostapd_init()
3231 hapd->msg_ctx = hapd; in hostapd_init()
3232 hostapd_bss_setup_multi_link(hapd, interfaces); in hostapd_init()
3261 struct hostapd_data *hapd = iface->bss[j]; in ifname_in_use() local
3262 if (os_strcmp(ifname, hapd->conf->iface) == 0) in ifname_in_use()
3287 struct hostapd_data *hapd; in hostapd_interface_init_bss() local
3346 hapd = hostapd_alloc_bss_data(iface, iface->conf, bss); in hostapd_interface_init_bss()
3347 if (hapd == NULL) { 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()
3355 hostapd_bss_setup_multi_link(hapd, interfaces); in hostapd_interface_init_bss()
3597 struct hostapd_data *hapd = hapd_iface->bss[j]; in hostapd_disable_iface() local
3598 hostapd_bss_deinit_no_free(hapd); in hostapd_disable_iface()
3599 hostapd_bss_link_deinit(hapd); in hostapd_disable_iface()
3600 hostapd_free_hapd_data(hapd); in hostapd_disable_iface()
3701 struct hostapd_data *hapd; in hostapd_data_alloc() local
3709 hapd = hapd_iface->bss[i] = in hostapd_data_alloc()
3711 if (hapd == NULL) { 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()
3736 struct hostapd_data *hapd; in hostapd_add_iface() local
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()
3793 if (start_ctrl_iface_bss(hapd) < 0 || in hostapd_add_iface()
3795 hostapd_setup_bss(hapd, -1, true))) { in hostapd_add_iface()
3796 hostapd_bss_link_deinit(hapd); in hostapd_add_iface()
3797 hostapd_cleanup(hapd); 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()
3808 os_free(hapd); in hostapd_add_iface()
3887 hapd = hapd_iface->bss[i]; in hostapd_add_iface()
3888 if (!hapd) in hostapd_add_iface()
3893 ctrl_iface_deinit(hapd); in hostapd_add_iface()
3896 hapd->conf->iface); in hostapd_add_iface()
3897 hostapd_bss_link_deinit(hapd); in hostapd_add_iface()
3898 hostapd_cleanup(hapd); in hostapd_add_iface()
3900 hostapd_mld_ref_dec(hapd->mld); in hostapd_add_iface()
3902 os_free(hapd); in hostapd_add_iface()
3927 struct hostapd_data *hapd = iface->bss[idx]; in hostapd_remove_bss() local
3929 hostapd_bss_deinit(hapd); 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()
3937 os_free(hapd); in hostapd_remove_bss()
4008 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, in hostapd_new_assoc_sta() argument
4011 if (hapd->tkip_countermeasures) { in hostapd_new_assoc_sta()
4012 hostapd_drv_sta_deauth(hapd, sta->addr, in hostapd_new_assoc_sta()
4018 if (ap_sta_is_mld(hapd, sta) && in hostapd_new_assoc_sta()
4019 sta->mld_assoc_link_id != hapd->mld_link_id) in hostapd_new_assoc_sta()
4023 ap_sta_clear_disconnect_timeouts(hapd, sta); 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()
4031 hostapd_p2p_non_p2p_sta_connected(hapd); in hostapd_new_assoc_sta()
4035 airtime_policy_new_sta(hapd, sta); in hostapd_new_assoc_sta()
4040 if (!hapd->conf->ieee802_1x && !hapd->conf->wpa && !hapd->conf->osen) { in hostapd_new_assoc_sta()
4041 ap_sta_set_authorized(hapd, sta, 1); in hostapd_new_assoc_sta()
4043 accounting_sta_start(hapd, sta); in hostapd_new_assoc_sta()
4047 ieee802_1x_new_station(hapd, sta); in hostapd_new_assoc_sta()
4055 } else if (!(hapd->iface->drv_flags2 & 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()
4063 if (eloop_cancel_timeout(ap_handle_timer, hapd, sta) > 0) { in hostapd_new_assoc_sta()
4067 hapd->conf->iface, __func__, in hostapd_new_assoc_sta()
4070 } else if (!(hapd->iface->drv_flags & 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()
4077 eloop_cancel_timeout(ap_handle_timer, hapd, sta); in hostapd_new_assoc_sta()
4078 eloop_register_timeout(hapd->conf->ap_max_inactivity, 0, in hostapd_new_assoc_sta()
4079 ap_handle_timer, hapd, sta); 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()
4085 ieee802_1x_create_preshared_mka_hapd(hapd, sta); in hostapd_new_assoc_sta()
4087 ieee802_1x_alloc_kay_sm_hapd(hapd, sta); in hostapd_new_assoc_sta()
4156 static int hostapd_build_beacon_data(struct hostapd_data *hapd, in hostapd_build_beacon_data() argument
4164 ret = ieee802_11_build_ap_params(hapd, ¶ms); in hostapd_build_beacon_data()
4168 ret = hostapd_build_ap_extra_ies(hapd, &beacon_extra, in hostapd_build_beacon_data()
4231 hostapd_free_ap_extra_ies(hapd, beacon_extra, proberesp_extra, in hostapd_build_beacon_data()
4244 static int hostapd_change_config_freq(struct hostapd_data *hapd, in hostapd_change_config_freq() argument
4255 params->channel = hostapd_hw_get_channel(hapd, params->freq); 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()
4268 hostapd_hw_get_freq(hapd, conf->channel), in hostapd_change_config_freq()
4281 hostapd_get_punct_bitmap(hapd))) in hostapd_change_config_freq()
4344 static int hostapd_fill_csa_settings(struct hostapd_data *hapd, in hostapd_fill_csa_settings() argument
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()
4381 &hapd->iface->cs_oper_class, in hostapd_fill_csa_settings()
4405 ret = hostapd_build_beacon_data(hapd, &settings->beacon_after); 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()
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()
4434 if (hapd->conf->mld_ap) in hostapd_fill_csa_settings()
4435 settings->link_id = hapd->mld_link_id; in hostapd_fill_csa_settings()
4440 hostapd_unsol_bcast_probe_resp(hapd, &settings->ubpr); in hostapd_fill_csa_settings()
4447 void hostapd_cleanup_cs_params(struct hostapd_data *hapd) in hostapd_cleanup_cs_params() argument
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()
4460 void hostapd_chan_switch_config(struct hostapd_data *hapd, in hostapd_chan_switch_config() argument
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()
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()
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()
4478 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, 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()
4487 int hostapd_switch_channel(struct hostapd_data *hapd, in hostapd_switch_channel() argument
4492 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) { in hostapd_switch_channel()
4497 ret = hostapd_fill_csa_settings(hapd, settings); in hostapd_switch_channel()
4501 ret = hostapd_drv_switch_channel(hapd, settings); in hostapd_switch_channel()
4510 hostapd_cleanup_cs_params(hapd); in hostapd_switch_channel()
4514 hapd->csa_in_progress = 1; in hostapd_switch_channel()
4594 void hostapd_cleanup_cca_params(struct hostapd_data *hapd) in hostapd_cleanup_cca_params() argument
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()
4604 int hostapd_fill_cca_settings(struct hostapd_data *hapd, in hostapd_fill_cca_settings() argument
4607 struct hostapd_iface *iface = hapd->iface; 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()
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()
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()
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()
4651 struct hostapd_data *hapd = (struct hostapd_data *) eloop_data; in hostapd_switch_color_timeout_handler() local
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()
4708 void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap) in hostapd_switch_color() argument
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()
4722 hapd, NULL)) in hostapd_switch_color()
4725 hapd->first_color_collision = now; in hostapd_switch_color()
4729 hapd, NULL); in hostapd_switch_color()
4746 struct hostapd_data *hapd = iface->bss[j]; in hostapd_get_iface() local
4748 if (os_strcmp(ifname, hapd->conf->iface) == 0) in hostapd_get_iface()
4749 return hapd; in hostapd_get_iface()
4764 struct hostapd_data *hapd = iface->bss[i]; in hostapd_periodic_iface() local
4766 if (!hapd->started) in hostapd_periodic_iface()
4770 hostapd_acl_expire(hapd); in hostapd_periodic_iface()
4779 struct hostapd_data *hapd = eloop_ctx; in hostapd_ocv_check_csa_sa_query() local
4784 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_ocv_check_csa_sa_query()
4791 ap_sta_disconnect(hapd, sta, sta->addr, in hostapd_ocv_check_csa_sa_query()
4800 struct hostapd_data * hostapd_mld_get_link_bss(struct hostapd_data *hapd, in hostapd_mld_get_link_bss() argument
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()
4816 !hostapd_is_ml_partner(hapd, bss)) in hostapd_mld_get_link_bss()
4841 u8 hostapd_get_mld_id(struct hostapd_data *hapd) in hostapd_get_mld_id() argument
4843 if (!hapd->conf->mld_ap) in hostapd_get_mld_id()
4853 int hostapd_mld_add_link(struct hostapd_data *hapd) in hostapd_mld_add_link() argument
4855 struct hostapd_mld *mld = hapd->mld; in hostapd_mld_add_link()
4857 if (!hapd->conf->mld_ap) in hostapd_mld_add_link()
4864 dl_list_add_tail(&mld->links, &hapd->link); in hostapd_mld_add_link()
4868 mld->name, hapd->mld_link_id, mld->num_links); in hostapd_mld_add_link()
4873 mld->fbss = hapd; in hostapd_mld_add_link()
4880 int hostapd_mld_remove_link(struct hostapd_data *hapd) in hostapd_mld_remove_link() argument
4882 struct hostapd_mld *mld = hapd->mld; in hostapd_mld_remove_link()
4885 if (!hapd->conf->mld_ap) in hostapd_mld_remove_link()
4892 dl_list_del(&hapd->link); 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()
4916 bool hostapd_mld_is_first_bss(struct hostapd_data *hapd) in hostapd_mld_is_first_bss() argument
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()
4932 return hapd == mld->fbss; in hostapd_mld_is_first_bss()
4936 struct hostapd_data * hostapd_mld_get_first_bss(struct hostapd_data *hapd) in hostapd_mld_get_first_bss() argument
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()
4953 u16 hostapd_get_punct_bitmap(struct hostapd_data *hapd) in hostapd_get_punct_bitmap() argument
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()