Lines Matching refs:hapd

65 static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason);
67 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd);
68 static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd);
99 struct hostapd_data * hostapd_mbssid_get_tx_bss(struct hostapd_data *hapd) in hostapd_mbssid_get_tx_bss() argument
101 if (hapd->iconf->mbssid) in hostapd_mbssid_get_tx_bss()
102 return hapd->iface->bss[0]; in hostapd_mbssid_get_tx_bss()
104 return hapd; in hostapd_mbssid_get_tx_bss()
108 int hostapd_mbssid_get_bss_index(struct hostapd_data *hapd) in hostapd_mbssid_get_bss_index() argument
110 if (hapd->iconf->mbssid) { in hostapd_mbssid_get_bss_index()
113 for (i = 1; i < hapd->iface->num_bss; i++) in hostapd_mbssid_get_bss_index()
114 if (hapd->iface->bss[i] == hapd) in hostapd_mbssid_get_bss_index()
122 void hostapd_reconfig_encryption(struct hostapd_data *hapd) in hostapd_reconfig_encryption() argument
124 if (hapd->wpa_auth) in hostapd_reconfig_encryption()
127 hostapd_set_privacy(hapd, 0); in hostapd_reconfig_encryption()
129 hostapd_setup_encryption(hapd->conf->iface, hapd); in hostapd_reconfig_encryption()
134 static void hostapd_reload_bss(struct hostapd_data *hapd) in hostapd_reload_bss() argument
138 if (!hapd->started) in hostapd_reload_bss()
141 if (hapd->conf->wmm_enabled < 0) in hostapd_reload_bss()
142 hapd->conf->wmm_enabled = hapd->iconf->ieee80211n | in hostapd_reload_bss()
143 hapd->iconf->ieee80211ax; in hostapd_reload_bss()
146 radius_client_reconfig(hapd->radius, hapd->conf->radius); in hostapd_reload_bss()
149 ssid = &hapd->conf->ssid; in hostapd_reload_bss()
156 hostapd_config_clear_wpa_psk(&hapd->conf->ssid.wpa_psk); in hostapd_reload_bss()
158 if (hostapd_setup_wpa_psk(hapd->conf)) { in hostapd_reload_bss()
163 if (hapd->conf->ieee802_1x || hapd->conf->wpa) in hostapd_reload_bss()
164 hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 1); in hostapd_reload_bss()
166 hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 0); in hostapd_reload_bss()
168 if ((hapd->conf->wpa || hapd->conf->osen) && hapd->wpa_auth == NULL) { in hostapd_reload_bss()
169 hostapd_setup_wpa(hapd); in hostapd_reload_bss()
170 if (hapd->wpa_auth) in hostapd_reload_bss()
171 wpa_init_keys(hapd->wpa_auth); in hostapd_reload_bss()
172 } else if (hapd->conf->wpa) { in hostapd_reload_bss()
175 hostapd_reconfig_wpa(hapd); in hostapd_reload_bss()
176 wpa_ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &wpa_ie_len); in hostapd_reload_bss()
177 if (hostapd_set_generic_elem(hapd, wpa_ie, wpa_ie_len)) in hostapd_reload_bss()
180 } else if (hapd->wpa_auth) { in hostapd_reload_bss()
181 wpa_deinit(hapd->wpa_auth); in hostapd_reload_bss()
182 hapd->wpa_auth = NULL; in hostapd_reload_bss()
183 hostapd_set_privacy(hapd, 0); in hostapd_reload_bss()
185 hostapd_setup_encryption(hapd->conf->iface, hapd); in hostapd_reload_bss()
187 hostapd_set_generic_elem(hapd, (u8 *) "", 0); in hostapd_reload_bss()
190 hostapd_neighbor_sync_own_report(hapd); in hostapd_reload_bss()
192 ieee802_11_set_beacon(hapd); in hostapd_reload_bss()
193 hostapd_update_wps(hapd); in hostapd_reload_bss()
195 if (hapd->conf->ssid.ssid_set && in hostapd_reload_bss()
196 hostapd_set_ssid(hapd, hapd->conf->ssid.ssid, in hostapd_reload_bss()
197 hapd->conf->ssid.ssid_len)) { in hostapd_reload_bss()
201 wpa_printf(MSG_DEBUG, "Reconfigured interface %s", hapd->conf->iface); in hostapd_reload_bss()
257 struct hostapd_data *hapd = iface->bss[0]; in hostapd_reload_config() local
276 oldconf = hapd->iconf; in hostapd_reload_config()
290 hostapd_remove_iface(interfaces, hapd->conf->iface); in hostapd_reload_config()
311 hapd = iface->bss[j]; in hostapd_reload_config()
312 if (!hapd->conf->config_id || !newconf->bss[j]->config_id || in hostapd_reload_config()
313 os_strcmp(hapd->conf->config_id, in hostapd_reload_config()
315 hostapd_clear_old_bss(hapd); in hostapd_reload_config()
316 hapd->iconf = newconf; in hostapd_reload_config()
317 hapd->iconf->channel = oldconf->channel; in hostapd_reload_config()
318 hapd->iconf->acs = oldconf->acs; in hostapd_reload_config()
319 hapd->iconf->secondary_channel = oldconf->secondary_channel; in hostapd_reload_config()
320 hapd->iconf->ieee80211n = oldconf->ieee80211n; in hostapd_reload_config()
321 hapd->iconf->ieee80211ac = oldconf->ieee80211ac; in hostapd_reload_config()
322 hapd->iconf->ht_capab = oldconf->ht_capab; in hostapd_reload_config()
323 hapd->iconf->vht_capab = oldconf->vht_capab; in hostapd_reload_config()
324 hostapd_set_oper_chwidth(hapd->iconf, in hostapd_reload_config()
327 hapd->iconf, in hostapd_reload_config()
330 hapd->iconf, in hostapd_reload_config()
332 hapd->conf = newconf->bss[j]; in hostapd_reload_config()
333 hostapd_reload_bss(hapd); in hostapd_reload_config()
345 static void hostapd_broadcast_key_clear_iface(struct hostapd_data *hapd, in hostapd_broadcast_key_clear_iface() argument
350 if (!ifname || !hapd->drv_priv) in hostapd_broadcast_key_clear_iface()
353 if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i, 0, in hostapd_broadcast_key_clear_iface()
360 if (hapd->conf->ieee80211w) { in hostapd_broadcast_key_clear_iface()
362 if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, in hostapd_broadcast_key_clear_iface()
374 static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd) in hostapd_broadcast_wep_clear() argument
376 hostapd_broadcast_key_clear_iface(hapd, hapd->conf->iface); in hostapd_broadcast_wep_clear()
381 static int hostapd_broadcast_wep_set(struct hostapd_data *hapd) in hostapd_broadcast_wep_set() argument
384 struct hostapd_ssid *ssid = &hapd->conf->ssid; in hostapd_broadcast_wep_set()
388 hostapd_drv_set_key(hapd->conf->iface, in hostapd_broadcast_wep_set()
389 hapd, WPA_ALG_WEP, broadcast_ether_addr, idx, 0, in hostapd_broadcast_wep_set()
411 struct hostapd_data *hapd = (struct hostapd_data *) eloop_data; in hostapd_link_remove_timeout_handler() local
413 if (hapd->eht_mld_link_removal_count == 0) in hostapd_link_remove_timeout_handler()
415 hapd->eht_mld_link_removal_count--; in hostapd_link_remove_timeout_handler()
418 hapd->mld_link_id, in hostapd_link_remove_timeout_handler()
419 hapd->eht_mld_link_removal_count); in hostapd_link_remove_timeout_handler()
421 ieee802_11_set_beacon(hapd); in hostapd_link_remove_timeout_handler()
423 if (!hapd->eht_mld_link_removal_count) { in hostapd_link_remove_timeout_handler()
424 hostapd_free_link_stas(hapd); in hostapd_link_remove_timeout_handler()
425 hostapd_disable_iface(hapd->iface); in hostapd_link_remove_timeout_handler()
429 eloop_register_timeout(0, TU_TO_USEC(hapd->iconf->beacon_int), in hostapd_link_remove_timeout_handler()
431 hapd, NULL); in hostapd_link_remove_timeout_handler()
435 int hostapd_link_remove(struct hostapd_data *hapd, u32 count) in hostapd_link_remove() argument
437 if (!hapd->conf->mld_ap) in hostapd_link_remove()
442 hapd->mld_link_id, count); in hostapd_link_remove()
444 hapd->eht_mld_link_removal_count = count; in hostapd_link_remove()
445 hapd->eht_mld_bss_param_change++; in hostapd_link_remove()
447 eloop_register_timeout(0, TU_TO_USEC(hapd->iconf->beacon_int), in hostapd_link_remove()
449 hapd, NULL); in hostapd_link_remove()
451 ieee802_11_set_beacon(hapd); in hostapd_link_remove()
459 void hostapd_free_hapd_data(struct hostapd_data *hapd) in hostapd_free_hapd_data() argument
461 os_free(hapd->probereq_cb); in hostapd_free_hapd_data()
462 hapd->probereq_cb = NULL; in hostapd_free_hapd_data()
463 hapd->num_probereq_cb = 0; in hostapd_free_hapd_data()
466 wpabuf_free(hapd->p2p_beacon_ie); in hostapd_free_hapd_data()
467 hapd->p2p_beacon_ie = NULL; in hostapd_free_hapd_data()
468 wpabuf_free(hapd->p2p_probe_resp_ie); in hostapd_free_hapd_data()
469 hapd->p2p_probe_resp_ie = NULL; in hostapd_free_hapd_data()
472 if (!hapd->started) { in hostapd_free_hapd_data()
474 __func__, hapd->conf ? hapd->conf->iface : "N/A"); in hostapd_free_hapd_data()
477 hapd->started = 0; in hostapd_free_hapd_data()
478 hapd->beacon_set_done = 0; in hostapd_free_hapd_data()
480 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface); in hostapd_free_hapd_data()
481 accounting_deinit(hapd); in hostapd_free_hapd_data()
482 hostapd_deinit_wpa(hapd); in hostapd_free_hapd_data()
483 vlan_deinit(hapd); in hostapd_free_hapd_data()
484 hostapd_acl_deinit(hapd); in hostapd_free_hapd_data()
486 if (hostapd_mld_is_first_bss(hapd)) { in hostapd_free_hapd_data()
488 struct hapd_interfaces *ifaces = hapd->iface->interfaces; in hostapd_free_hapd_data()
498 if (hapd == h) in hostapd_free_hapd_data()
500 if (h->radius == hapd->radius) in hostapd_free_hapd_data()
502 if (h->radius_das == hapd->radius_das) in hostapd_free_hapd_data()
507 radius_client_deinit(hapd->radius); in hostapd_free_hapd_data()
508 radius_das_deinit(hapd->radius_das); in hostapd_free_hapd_data()
510 hapd->radius = NULL; in hostapd_free_hapd_data()
511 hapd->radius_das = NULL; in hostapd_free_hapd_data()
514 hostapd_deinit_wps(hapd); in hostapd_free_hapd_data()
515 ieee802_1x_dealloc_kay_sm_hapd(hapd); in hostapd_free_hapd_data()
517 hostapd_dpp_deinit(hapd); in hostapd_free_hapd_data()
518 gas_query_ap_deinit(hapd->gas); in hostapd_free_hapd_data()
519 hapd->gas = NULL; in hostapd_free_hapd_data()
522 hostapd_nan_usd_deinit(hapd); in hostapd_free_hapd_data()
525 authsrv_deinit(hapd); in hostapd_free_hapd_data()
527 if (hapd->interface_added) { in hostapd_free_hapd_data()
528 hapd->interface_added = 0; in hostapd_free_hapd_data()
529 if (hostapd_if_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface)) { in hostapd_free_hapd_data()
532 hapd->conf->iface); in hostapd_free_hapd_data()
533 hapd->interface_added = 1; in hostapd_free_hapd_data()
540 hapd->drv_priv = NULL; in hostapd_free_hapd_data()
548 if (hapd->conf->mld_ap && !hapd->interface_added && in hostapd_free_hapd_data()
549 hapd->iface->bss[0] != hapd) in hostapd_free_hapd_data()
550 hostapd_if_link_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface, in hostapd_free_hapd_data()
551 hapd->mld_link_id); in hostapd_free_hapd_data()
554 wpabuf_free(hapd->time_adv); in hostapd_free_hapd_data()
555 hapd->time_adv = NULL; in hostapd_free_hapd_data()
558 gas_serv_deinit(hapd); in hostapd_free_hapd_data()
561 bss_load_update_deinit(hapd); in hostapd_free_hapd_data()
562 ndisc_snoop_deinit(hapd); in hostapd_free_hapd_data()
563 dhcp_snoop_deinit(hapd); in hostapd_free_hapd_data()
564 x_snoop_deinit(hapd); in hostapd_free_hapd_data()
567 bin_clear_free(hapd->tmp_eap_user.identity, in hostapd_free_hapd_data()
568 hapd->tmp_eap_user.identity_len); in hostapd_free_hapd_data()
569 bin_clear_free(hapd->tmp_eap_user.password, in hostapd_free_hapd_data()
570 hapd->tmp_eap_user.password_len); in hostapd_free_hapd_data()
571 os_memset(&hapd->tmp_eap_user, 0, sizeof(hapd->tmp_eap_user)); in hostapd_free_hapd_data()
575 wpabuf_free(hapd->mesh_pending_auth); in hostapd_free_hapd_data()
576 hapd->mesh_pending_auth = NULL; in hostapd_free_hapd_data()
578 hapd->setup_complete_cb = NULL; in hostapd_free_hapd_data()
582 hostapd_clean_rrm(hapd); in hostapd_free_hapd_data()
584 fils_hlp_deinit(hapd); in hostapd_free_hapd_data()
587 eloop_cancel_timeout(hostapd_ocv_check_csa_sa_query, hapd, NULL); in hostapd_free_hapd_data()
594 while ((q = dl_list_first(&hapd->sae_commit_queue, in hostapd_free_hapd_data()
601 eloop_cancel_timeout(auth_sae_process_commit, hapd, NULL); in hostapd_free_hapd_data()
605 eloop_cancel_timeout(hostapd_switch_color_timeout_handler, hapd, NULL); in hostapd_free_hapd_data()
608 eloop_cancel_timeout(hostapd_link_remove_timeout_handler, hapd, NULL); in hostapd_free_hapd_data()
623 static void hostapd_bss_link_deinit(struct hostapd_data *hapd) in hostapd_bss_link_deinit() argument
626 if (!hapd->conf || !hapd->conf->mld_ap) in hostapd_bss_link_deinit()
629 if (!hapd->mld->num_links) in hostapd_bss_link_deinit()
636 if (!hapd->started && hapd->iface->bss[0] != hapd) in hostapd_bss_link_deinit()
643 if (hapd->iface->bss[0] == hapd && !hapd->drv_priv) in hostapd_bss_link_deinit()
646 hostapd_mld_remove_link(hapd); in hostapd_bss_link_deinit()
659 static void hostapd_cleanup(struct hostapd_data *hapd) in hostapd_cleanup() argument
661 wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s))", __func__, hapd, in hostapd_cleanup()
662 hapd->conf ? hapd->conf->iface : "N/A"); in hostapd_cleanup()
663 if (hapd->iface->interfaces && in hostapd_cleanup()
664 hapd->iface->interfaces->ctrl_iface_deinit) { in hostapd_cleanup()
665 wpa_msg(hapd->msg_ctx, MSG_INFO, WPA_EVENT_TERMINATING); in hostapd_cleanup()
666 hapd->iface->interfaces->ctrl_iface_deinit(hapd); in hostapd_cleanup()
668 hostapd_free_hapd_data(hapd); in hostapd_cleanup()
737 static void hostapd_clear_wep(struct hostapd_data *hapd) in hostapd_clear_wep() argument
739 if (hapd->drv_priv && !hapd->iface->driver_ap_teardown && hapd->conf) { in hostapd_clear_wep()
740 hostapd_set_privacy(hapd, 0); in hostapd_clear_wep()
741 hostapd_broadcast_wep_clear(hapd); in hostapd_clear_wep()
746 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd) in hostapd_setup_encryption() argument
750 hostapd_broadcast_wep_set(hapd); in hostapd_setup_encryption()
752 if (hapd->conf->ssid.wep.default_len) { in hostapd_setup_encryption()
753 hostapd_set_privacy(hapd, 1); in hostapd_setup_encryption()
761 hostapd_drv_set_authmode(hapd, hapd->conf->auth_algs); in hostapd_setup_encryption()
764 if (hapd->conf->ssid.wep.key[i] && in hostapd_setup_encryption()
765 hostapd_drv_set_key(iface, hapd, WPA_ALG_WEP, NULL, i, 0, in hostapd_setup_encryption()
766 i == hapd->conf->ssid.wep.idx, NULL, 0, in hostapd_setup_encryption()
767 hapd->conf->ssid.wep.key[i], in hostapd_setup_encryption()
768 hapd->conf->ssid.wep.len[i], in hostapd_setup_encryption()
769 i == hapd->conf->ssid.wep.idx ? in hostapd_setup_encryption()
776 if (hapd->conf->ssid.wep.key[i] && in hostapd_setup_encryption()
777 i == hapd->conf->ssid.wep.idx) in hostapd_setup_encryption()
778 hostapd_set_privacy(hapd, 1); in hostapd_setup_encryption()
787 static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason) in hostapd_flush_old_stations() argument
792 if (hostapd_drv_none(hapd) || hapd->drv_priv == NULL) in hostapd_flush_old_stations()
795 if (!hapd->iface->driver_ap_teardown) { in hostapd_flush_old_stations()
796 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, in hostapd_flush_old_stations()
799 if (hostapd_flush(hapd)) { in hostapd_flush_old_stations()
800 wpa_msg(hapd->msg_ctx, MSG_WARNING, in hostapd_flush_old_stations()
805 if (hapd->conf && hapd->conf->broadcast_deauth) { in hostapd_flush_old_stations()
806 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, in hostapd_flush_old_stations()
809 hostapd_drv_sta_deauth(hapd, addr, reason); in hostapd_flush_old_stations()
811 hostapd_free_stas(hapd); in hostapd_flush_old_stations()
817 void hostapd_bss_deinit_no_free(struct hostapd_data *hapd) in hostapd_bss_deinit_no_free() argument
819 hostapd_free_stas(hapd); in hostapd_bss_deinit_no_free()
820 hostapd_flush_old_stations(hapd, WLAN_REASON_DEAUTH_LEAVING); in hostapd_bss_deinit_no_free()
822 hostapd_clear_wep(hapd); in hostapd_bss_deinit_no_free()
837 struct hostapd_data *hapd = iface->bss[0]; in hostapd_validate_bssid_configuration() local
841 if (hostapd_drv_none(hapd)) in hostapd_validate_bssid_configuration()
865 hapd->own_addr[i]; in hostapd_validate_bssid_configuration()
911 if ((hapd->own_addr[i] & mask[i]) != hapd->own_addr[i]) { in hostapd_validate_bssid_configuration()
914 MAC2STR(mask), MAC2STR(hapd->own_addr)); in hostapd_validate_bssid_configuration()
942 static int hostapd_das_nas_mismatch(struct hostapd_data *hapd, in hostapd_das_nas_mismatch() argument
946 (!hapd->conf->nas_identifier || in hostapd_das_nas_mismatch()
947 os_strlen(hapd->conf->nas_identifier) != in hostapd_das_nas_mismatch()
949 os_memcmp(hapd->conf->nas_identifier, attr->nas_identifier, in hostapd_das_nas_mismatch()
956 (hapd->conf->own_ip_addr.af != AF_INET || in hostapd_das_nas_mismatch()
957 os_memcmp(&hapd->conf->own_ip_addr.u.v4, attr->nas_ip_addr, 4) != in hostapd_das_nas_mismatch()
965 (hapd->conf->own_ip_addr.af != AF_INET6 || in hostapd_das_nas_mismatch()
966 os_memcmp(&hapd->conf->own_ip_addr.u.v6, attr->nas_ipv6_addr, 16) in hostapd_das_nas_mismatch()
977 static struct sta_info * hostapd_das_find_sta(struct hostapd_data *hapd, in hostapd_das_find_sta() argument
988 for (sta = hapd->sta_list; sta; sta = sta->next) in hostapd_das_find_sta()
993 sta = ap_get_sta(hapd, attr->sta_addr); in hostapd_das_find_sta()
1001 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1017 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1045 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1076 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1103 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1141 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_das_find_sta()
1155 static int hostapd_das_disconnect_pmksa(struct hostapd_data *hapd, in hostapd_das_disconnect_pmksa() argument
1158 if (!hapd->wpa_auth) in hostapd_das_disconnect_pmksa()
1160 return wpa_auth_radius_das_disconnect_pmksa(hapd->wpa_auth, attr); in hostapd_das_disconnect_pmksa()
1167 struct hostapd_data *hapd = ctx; in hostapd_das_disconnect() local
1171 if (hostapd_das_nas_mismatch(hapd, attr)) in hostapd_das_disconnect()
1174 sta = hostapd_das_find_sta(hapd, attr, &multi); in hostapd_das_disconnect()
1181 if (hostapd_das_disconnect_pmksa(hapd, attr) == 0) { in hostapd_das_disconnect()
1192 wpa_auth_pmksa_remove(hapd->wpa_auth, sta->addr); in hostapd_das_disconnect()
1194 hostapd_drv_sta_deauth(hapd, sta->addr, in hostapd_das_disconnect()
1196 ap_sta_deauthenticate(hapd, sta, WLAN_REASON_PREV_AUTH_NOT_VALID); in hostapd_das_disconnect()
1206 struct hostapd_data *hapd = ctx; in hostapd_das_coa() local
1210 if (hostapd_das_nas_mismatch(hapd, attr)) in hostapd_das_coa()
1213 sta = hostapd_das_find_sta(hapd, attr, &multi); in hostapd_das_coa()
1234 hs20_t_c_filtering(hapd, sta, 0); in hostapd_das_coa()
1283 static int hostapd_start_beacon(struct hostapd_data *hapd, in hostapd_start_beacon() argument
1286 struct hostapd_bss_config *conf = hapd->conf; in hostapd_start_beacon()
1288 if (!conf->start_disabled && ieee802_11_set_beacon(hapd) < 0) in hostapd_start_beacon()
1299 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, in hostapd_start_beacon()
1302 hostapd_drv_sta_deauth(hapd, addr, in hostapd_start_beacon()
1306 if (hapd->driver && hapd->driver->set_operstate) in hostapd_start_beacon()
1307 hapd->driver->set_operstate(hapd->drv_priv, 1); in hostapd_start_beacon()
1314 static int hostapd_bss_radius_init(struct hostapd_data *hapd) in hostapd_bss_radius_init() argument
1318 if (!hapd) in hostapd_bss_radius_init()
1321 conf = hapd->conf; in hostapd_bss_radius_init()
1323 if (hapd->radius) { in hostapd_bss_radius_init()
1329 hapd->radius = radius_client_init(hapd, conf->radius); in hostapd_bss_radius_init()
1330 if (!hapd->radius) { in hostapd_bss_radius_init()
1350 das_conf.ctx = hapd; in hostapd_bss_radius_init()
1353 hapd->radius_das = radius_das_init(&das_conf); in hostapd_bss_radius_init()
1354 if (!hapd->radius_das) { in hostapd_bss_radius_init()
1383 static int hostapd_setup_bss(struct hostapd_data *hapd, int first, in hostapd_setup_bss() argument
1386 struct hostapd_bss_config *conf = hapd->conf; in hostapd_setup_bss()
1393 if (!hostapd_mld_is_first_bss(hapd)) in hostapd_setup_bss()
1398 __func__, hapd, conf->iface, first); in hostapd_setup_bss()
1407 if (hapd->started) { in hostapd_setup_bss()
1412 hapd->started = 1; in hostapd_setup_bss()
1415 u8 *addr = hapd->own_addr; in hostapd_setup_bss()
1419 os_memcpy(hapd->own_addr, conf->bssid, ETH_ALEN); in hostapd_setup_bss()
1421 if (hostapd_mac_comp(hapd->own_addr, in hostapd_setup_bss()
1422 hapd->iface->bss[0]->own_addr) == in hostapd_setup_bss()
1429 } else if (hapd->iconf->use_driver_iface_addr) { in hostapd_setup_bss()
1434 inc_byte_array(hapd->own_addr, ETH_ALEN); in hostapd_setup_bss()
1435 } while (mac_in_conf(hapd->iconf, hapd->own_addr)); in hostapd_setup_bss()
1442 h_hapd = hostapd_mld_get_first_bss(hapd); in hostapd_setup_bss()
1444 hapd->drv_priv = h_hapd->drv_priv; in hostapd_setup_bss()
1445 hapd->interface_added = h_hapd->interface_added; in hostapd_setup_bss()
1446 hostapd_mld_add_link(hapd); in hostapd_setup_bss()
1449 hapd->mld_link_id, hapd->conf->iface); in hostapd_setup_bss()
1455 hapd->interface_added = 1; in hostapd_setup_bss()
1456 if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS, in hostapd_setup_bss()
1457 conf->iface, addr, hapd, in hostapd_setup_bss()
1458 &hapd->drv_priv, force_ifname, if_addr, in hostapd_setup_bss()
1462 MACSTR ")", MAC2STR(hapd->own_addr)); in hostapd_setup_bss()
1463 hapd->interface_added = 0; in hostapd_setup_bss()
1468 os_memcpy(hapd->own_addr, if_addr, ETH_ALEN); in hostapd_setup_bss()
1471 if (hapd->conf->mld_ap) { in hostapd_setup_bss()
1474 hapd->mld_link_id, hapd->conf->iface); in hostapd_setup_bss()
1475 os_memcpy(hapd->mld->mld_addr, hapd->own_addr, in hostapd_setup_bss()
1477 hostapd_mld_add_link(hapd); in hostapd_setup_bss()
1484 if (hapd->conf->mld_ap && !first) { in hostapd_setup_bss()
1488 hapd->mld_link_id, MAC2STR(hapd->mld->mld_addr), in hostapd_setup_bss()
1489 MAC2STR(hapd->own_addr)); in hostapd_setup_bss()
1491 if (hostapd_drv_link_add(hapd, hapd->mld_link_id, in hostapd_setup_bss()
1492 hapd->own_addr)) in hostapd_setup_bss()
1498 conf->wmm_enabled = hapd->iconf->ieee80211n | in hostapd_setup_bss()
1499 hapd->iconf->ieee80211ax; in hostapd_setup_bss()
1503 os_memcpy(conf->r1_key_holder, hapd->own_addr, ETH_ALEN); in hostapd_setup_bss()
1507 if ((hapd->conf->mesh & MESH_ENABLED) && hapd->iface->mconf == NULL) in hostapd_setup_bss()
1512 hostapd_flush(hapd); in hostapd_setup_bss()
1513 hostapd_set_privacy(hapd, 0); in hostapd_setup_bss()
1516 if (!hostapd_drv_nl80211(hapd)) in hostapd_setup_bss()
1517 hostapd_broadcast_wep_clear(hapd); in hostapd_setup_bss()
1518 if (hostapd_setup_encryption(conf->iface, hapd)) in hostapd_setup_bss()
1527 ssid_len = hostapd_get_ssid(hapd, ssid, sizeof(ssid)); in hostapd_setup_bss()
1557 if (!hostapd_drv_none(hapd)) { in hostapd_setup_bss()
1560 conf->iface, MAC2STR(hapd->own_addr), in hostapd_setup_bss()
1571 if (set_ssid && hostapd_set_ssid(hapd, conf->ssid.ssid, in hostapd_setup_bss()
1584 &hapd->rad_attr_db)) { in hostapd_setup_bss()
1592 if (!db_table_exists(hapd->rad_attr_db, "radius_attributes") && in hostapd_setup_bss()
1593 db_table_create_radius_attributes(hapd->rad_attr_db) < 0) in hostapd_setup_bss()
1598 if (hostapd_mld_is_first_bss(hapd)) { in hostapd_setup_bss()
1599 if (hostapd_bss_radius_init(hapd)) in hostapd_setup_bss()
1605 f_bss = hostapd_mld_get_first_bss(hapd); in hostapd_setup_bss()
1619 hapd->radius = f_bss->radius; in hostapd_setup_bss()
1620 hapd->radius_das = f_bss->radius_das; in hostapd_setup_bss()
1625 if (hostapd_acl_init(hapd)) { in hostapd_setup_bss()
1629 if (hostapd_init_wps(hapd, conf)) in hostapd_setup_bss()
1633 hapd->gas = gas_query_ap_init(hapd, hapd->msg_ctx); in hostapd_setup_bss()
1634 if (!hapd->gas) in hostapd_setup_bss()
1636 if (hostapd_dpp_init(hapd)) in hostapd_setup_bss()
1641 if (hostapd_nan_usd_init(hapd) < 0) in hostapd_setup_bss()
1645 if (authsrv_init(hapd) < 0) in hostapd_setup_bss()
1648 if (ieee802_1x_init(hapd)) { in hostapd_setup_bss()
1653 if ((conf->wpa || conf->osen) && hostapd_setup_wpa(hapd)) in hostapd_setup_bss()
1656 if (accounting_init(hapd)) { in hostapd_setup_bss()
1662 if (gas_serv_init(hapd)) { in hostapd_setup_bss()
1669 hostapd_drv_set_qos_map(hapd, conf->qos_map_set, in hostapd_setup_bss()
1675 if (conf->bss_load_update_period && bss_load_update_init(hapd)) { in hostapd_setup_bss()
1688 hapd, DRV_BR_PORT_ATTR_MCAST2UCAST, 1); in hostapd_setup_bss()
1693 hapd, DRV_BR_PORT_ATTR_HAIRPIN_MODE, 1); in hostapd_setup_bss()
1697 if (x_snoop_init(hapd)) { in hostapd_setup_bss()
1703 if (dhcp_snoop_init(hapd)) { in hostapd_setup_bss()
1709 if (ndisc_snoop_init(hapd)) { in hostapd_setup_bss()
1716 if (!hostapd_drv_none(hapd) && vlan_init(hapd)) { in hostapd_setup_bss()
1721 if (start_beacon && hostapd_start_beacon(hapd, flush_old_stations) < 0) in hostapd_setup_bss()
1724 if (hapd->wpa_auth && wpa_init_keys(hapd->wpa_auth) < 0) in hostapd_setup_bss()
1733 struct hostapd_data *hapd = iface->bss[0]; in hostapd_tx_queue_params() local
1738 if ((hapd->conf->mesh & MESH_ENABLED) && iface->mconf == NULL) in hostapd_tx_queue_params()
1745 if (hostapd_set_tx_queue_params(hapd, i, p->aifs, p->cwmin, in hostapd_tx_queue_params()
1755 static int hostapd_set_acl_list(struct hostapd_data *hapd, in hostapd_set_acl_list() argument
1774 err = hostapd_drv_set_acl(hapd, acl_params); in hostapd_set_acl_list()
1782 int hostapd_set_acl(struct hostapd_data *hapd) in hostapd_set_acl() argument
1784 struct hostapd_config *conf = hapd->iconf; in hostapd_set_acl()
1788 if (hapd->iface->drv_max_acl_mac_addrs == 0) in hostapd_set_acl()
1793 err = hostapd_set_acl_list(hapd, conf->bss[0]->accept_mac, in hostapd_set_acl()
1802 err = hostapd_set_acl_list(hapd, conf->bss[0]->deny_mac, in hostapd_set_acl()
1814 static int start_ctrl_iface_bss(struct hostapd_data *hapd) in start_ctrl_iface_bss() argument
1816 if (!hapd->iface->interfaces || in start_ctrl_iface_bss()
1817 !hapd->iface->interfaces->ctrl_iface_init) in start_ctrl_iface_bss()
1820 if (hapd->iface->interfaces->ctrl_iface_init(hapd)) { in start_ctrl_iface_bss()
1823 hapd->conf->iface); in start_ctrl_iface_bss()
1839 struct hostapd_data *hapd = iface->bss[i]; in start_ctrl_iface() local
1840 if (iface->interfaces->ctrl_iface_init(hapd)) { in start_ctrl_iface()
1843 hapd->conf->iface); in start_ctrl_iface()
2010 struct hostapd_data *hapd = iface->bss[0]; in setup_interface() local
2023 const char *phy = hostapd_drv_get_radio_name(hapd); in setup_interface()
2035 iface->bss[i]->driver = hapd->driver; in setup_interface()
2036 iface->bss[i]->drv_priv = hapd->drv_priv; in setup_interface()
2050 if (hapd->iconf->country[0] && hapd->iconf->country[1]) { in setup_interface()
2054 if (hostapd_get_country(hapd, previous_country) < 0) in setup_interface()
2057 os_memcpy(country, hapd->iconf->country, 3); in setup_interface()
2059 if (hostapd_set_country(hapd, country) < 0) { in setup_interface()
2225 struct hostapd_data *hapd = ctx; in fst_hostapd_get_bssid_cb() local
2227 return hapd->own_addr; in fst_hostapd_get_bssid_cb()
2235 struct hostapd_data *hapd = ctx; in fst_hostapd_get_channel_info_cb() local
2237 *hw_mode = ieee80211_freq_to_chan(hapd->iface->freq, channel); in fst_hostapd_get_channel_info_cb()
2244 struct hostapd_data *hapd = ctx; in fst_hostapd_get_hw_modes_cb() local
2246 *modes = hapd->iface->hw_features; in fst_hostapd_get_hw_modes_cb()
2247 return hapd->iface->num_hw_features; in fst_hostapd_get_hw_modes_cb()
2253 struct hostapd_data *hapd = ctx; in fst_hostapd_set_ies_cb() local
2255 if (hapd->iface->fst_ies != fst_ies) { in fst_hostapd_set_ies_cb()
2256 hapd->iface->fst_ies = fst_ies; in fst_hostapd_set_ies_cb()
2257 if (ieee802_11_set_beacon(hapd)) in fst_hostapd_set_ies_cb()
2266 struct hostapd_data *hapd = ctx; in fst_hostapd_send_action_cb() local
2268 return hostapd_drv_send_action(hapd, hapd->iface->freq, 0, da, in fst_hostapd_send_action_cb()
2275 struct hostapd_data *hapd = ctx; in fst_hostapd_get_mb_ie_cb() local
2276 struct sta_info *sta = ap_get_sta(hapd, addr); in fst_hostapd_get_mb_ie_cb()
2285 struct hostapd_data *hapd = ctx; in fst_hostapd_update_mb_ie_cb() local
2286 struct sta_info *sta = ap_get_sta(hapd, addr); in fst_hostapd_update_mb_ie_cb()
2324 struct hostapd_data *hapd = ctx; in fst_hostapd_get_peer_first() local
2326 *get_ctx = (struct fst_get_peer_ctx *) hapd->sta_list; in fst_hostapd_get_peer_first()
2340 void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd, in fst_hostapd_fill_iface_obj() argument
2344 iface_obj->ctx = hapd; in fst_hostapd_fill_iface_obj()
2362 struct hostapd_data *hapd = ctx; in hostapd_owe_iface_iter() local
2368 if (os_strcmp(hapd->conf->owe_transition_ifname, in hostapd_owe_iface_iter()
2375 hapd->conf->iface, bss->conf->iface, in hostapd_owe_iface_iter()
2383 os_memcpy(hapd->conf->owe_transition_bssid, bss->own_addr, in hostapd_owe_iface_iter()
2385 os_memcpy(hapd->conf->owe_transition_ssid, in hostapd_owe_iface_iter()
2387 hapd->conf->owe_transition_ssid_len = bss->conf->ssid.ssid_len; in hostapd_owe_iface_iter()
2397 int hostapd_owe_trans_get_info(struct hostapd_data *hapd) in hostapd_owe_trans_get_info() argument
2399 if (hapd->conf->owe_transition_ssid_len > 0 && in hostapd_owe_trans_get_info()
2400 !is_zero_ether_addr(hapd->conf->owe_transition_bssid)) in hostapd_owe_trans_get_info()
2405 if (!hapd->iface->interfaces || in hostapd_owe_trans_get_info()
2406 !hapd->iface->interfaces->for_each_interface) in hostapd_owe_trans_get_info()
2407 return hostapd_owe_iface_iter(hapd->iface, hapd); in hostapd_owe_trans_get_info()
2409 return hapd->iface->interfaces->for_each_interface( in hostapd_owe_trans_get_info()
2410 hapd->iface->interfaces, hostapd_owe_iface_iter, hapd); in hostapd_owe_trans_get_info()
2465 struct hostapd_data *hapd; in hostapd_interface_setup_failure_handler() local
2469 hapd = iface->bss[0]; in hostapd_interface_setup_failure_handler()
2470 if (hapd->setup_complete_cb) in hostapd_interface_setup_failure_handler()
2471 hapd->setup_complete_cb(hapd->setup_complete_cb_ctx); in hostapd_interface_setup_failure_handler()
2478 struct hostapd_data *hapd = iface->bss[0]; in hostapd_setup_interface_complete_sync() local
2538 hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq, in hostapd_setup_interface_complete_sync()
2539 hapd->iconf->channel, in hostapd_setup_interface_complete_sync()
2540 hapd->iconf->enable_edmg, in hostapd_setup_interface_complete_sync()
2541 hapd->iconf->edmg_channel, in hostapd_setup_interface_complete_sync()
2542 hapd->iconf->ieee80211n, in hostapd_setup_interface_complete_sync()
2543 hapd->iconf->ieee80211ac, in hostapd_setup_interface_complete_sync()
2544 hapd->iconf->ieee80211ax, in hostapd_setup_interface_complete_sync()
2545 hapd->iconf->ieee80211be, in hostapd_setup_interface_complete_sync()
2546 hapd->iconf->secondary_channel, in hostapd_setup_interface_complete_sync()
2547 hostapd_get_oper_chwidth(hapd->iconf), in hostapd_setup_interface_complete_sync()
2549 hapd->iconf), in hostapd_setup_interface_complete_sync()
2551 hapd->iconf))) { in hostapd_setup_interface_complete_sync()
2562 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, in hostapd_setup_interface_complete_sync()
2569 if (hapd->iconf->rts_threshold >= -1 && in hostapd_setup_interface_complete_sync()
2570 hostapd_set_rts(hapd, hapd->iconf->rts_threshold) && in hostapd_setup_interface_complete_sync()
2571 hapd->iconf->rts_threshold >= -1) { in hostapd_setup_interface_complete_sync()
2577 if (hapd->iconf->fragm_threshold >= -1 && in hostapd_setup_interface_complete_sync()
2578 hostapd_set_frag(hapd, hapd->iconf->fragm_threshold) && in hostapd_setup_interface_complete_sync()
2579 hapd->iconf->fragm_threshold != -1) { in hostapd_setup_interface_complete_sync()
2585 prev_addr = hapd->own_addr; in hostapd_setup_interface_complete_sync()
2588 hapd = iface->bss[j]; in hostapd_setup_interface_complete_sync()
2590 os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN); in hostapd_setup_interface_complete_sync()
2591 if (hostapd_setup_bss(hapd, j == 0, !iface->conf->mbssid)) { in hostapd_setup_interface_complete_sync()
2593 hapd = iface->bss[j]; in hostapd_setup_interface_complete_sync()
2594 hostapd_bss_deinit_no_free(hapd); in hostapd_setup_interface_complete_sync()
2595 hostapd_free_hapd_data(hapd); in hostapd_setup_interface_complete_sync()
2602 if (is_zero_ether_addr(hapd->conf->bssid)) in hostapd_setup_interface_complete_sync()
2603 prev_addr = hapd->own_addr; in hostapd_setup_interface_complete_sync()
2606 if (hapd->iconf->mbssid) { in hostapd_setup_interface_complete_sync()
2607 for (j = 0; hapd->iconf->mbssid && j < iface->num_bss; j++) { in hostapd_setup_interface_complete_sync()
2608 hapd = iface->bss[j]; in hostapd_setup_interface_complete_sync()
2609 if (hostapd_start_beacon(hapd, true)) { in hostapd_setup_interface_complete_sync()
2611 hapd = iface->bss[j]; in hostapd_setup_interface_complete_sync()
2612 hostapd_bss_deinit_no_free(hapd); in hostapd_setup_interface_complete_sync()
2613 hostapd_free_hapd_data(hapd); in hostapd_setup_interface_complete_sync()
2623 hapd = iface->bss[0]; in hostapd_setup_interface_complete_sync()
2629 hostapd_set_acl(hapd); in hostapd_setup_interface_complete_sync()
2631 if (hostapd_driver_commit(hapd) < 0) { in hostapd_setup_interface_complete_sync()
2663 if (hapd->iconf->fst_cfg.group_id[0]) { in hostapd_setup_interface_complete_sync()
2666 fst_hostapd_fill_iface_obj(hapd, &iface_obj); in hostapd_setup_interface_complete_sync()
2667 iface->fst = fst_attach(hapd->conf->iface, hapd->own_addr, in hostapd_setup_interface_complete_sync()
2668 &iface_obj, &hapd->iconf->fst_cfg); in hostapd_setup_interface_complete_sync()
2671 hapd->iconf->fst_cfg.group_id); in hostapd_setup_interface_complete_sync()
2681 if (hapd->setup_complete_cb) in hostapd_setup_interface_complete_sync()
2682 hapd->setup_complete_cb(hapd->setup_complete_cb_ctx); in hostapd_setup_interface_complete_sync()
2714 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_NO_IR); in hostapd_setup_interface_complete_sync()
2719 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); in hostapd_setup_interface_complete_sync()
2729 } else if (hapd->setup_complete_cb) { in hostapd_setup_interface_complete_sync()
2754 struct hostapd_data *hapd = iface->bss[0]; in hostapd_setup_interface_complete() local
2767 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_NO_IR); in hostapd_setup_interface_complete()
2772 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); in hostapd_setup_interface_complete()
2882 struct hostapd_data *hapd; in hostapd_alloc_bss_data() local
2884 hapd = os_zalloc(sizeof(*hapd)); in hostapd_alloc_bss_data()
2885 if (hapd == NULL) in hostapd_alloc_bss_data()
2888 hapd->new_assoc_sta_cb = hostapd_new_assoc_sta; in hostapd_alloc_bss_data()
2889 hapd->iconf = conf; in hostapd_alloc_bss_data()
2890 hapd->conf = bss; in hostapd_alloc_bss_data()
2891 hapd->iface = hapd_iface; in hostapd_alloc_bss_data()
2893 hapd->driver = conf->driver; in hostapd_alloc_bss_data()
2894 hapd->ctrl_sock = -1; in hostapd_alloc_bss_data()
2895 dl_list_init(&hapd->ctrl_dst); in hostapd_alloc_bss_data()
2896 dl_list_init(&hapd->nr_db); in hostapd_alloc_bss_data()
2897 hapd->dhcp_sock = -1; in hostapd_alloc_bss_data()
2899 dl_list_init(&hapd->l2_queue); in hostapd_alloc_bss_data()
2900 dl_list_init(&hapd->l2_oui_queue); in hostapd_alloc_bss_data()
2903 dl_list_init(&hapd->sae_commit_queue); in hostapd_alloc_bss_data()
2906 return hapd; in hostapd_alloc_bss_data()
2910 static void hostapd_bss_deinit(struct hostapd_data *hapd) in hostapd_bss_deinit() argument
2912 if (!hapd) in hostapd_bss_deinit()
2915 hapd->conf ? hapd->conf->iface : "N/A"); in hostapd_bss_deinit()
2916 hostapd_bss_deinit_no_free(hapd); in hostapd_bss_deinit()
2917 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); in hostapd_bss_deinit()
2919 if (hapd->rad_attr_db) { in hostapd_bss_deinit()
2920 sqlite3_close(hapd->rad_attr_db); in hostapd_bss_deinit()
2921 hapd->rad_attr_db = NULL; in hostapd_bss_deinit()
2925 hostapd_bss_link_deinit(hapd); in hostapd_bss_deinit()
2926 hostapd_cleanup(hapd); in hostapd_bss_deinit()
3032 static void hostapd_bss_alloc_link_id(struct hostapd_data *hapd) in hostapd_bss_alloc_link_id() argument
3034 hapd->mld_link_id = hapd->mld->next_link_id++; in hostapd_bss_alloc_link_id()
3036 hapd->mld->name, hapd->mld_link_id); in hostapd_bss_alloc_link_id()
3041 static void hostapd_bss_setup_multi_link(struct hostapd_data *hapd, in hostapd_bss_setup_multi_link() argument
3049 conf = hapd->conf; in hostapd_bss_setup_multi_link()
3051 if (!hapd->iconf || !hapd->iconf->ieee80211be || !conf->mld_ap || in hostapd_bss_setup_multi_link()
3061 hapd->mld = mld; in hostapd_bss_setup_multi_link()
3063 hostapd_bss_alloc_link_id(hapd); in hostapd_bss_setup_multi_link()
3067 if (hapd->mld) in hostapd_bss_setup_multi_link()
3079 hapd->mld = mld; in hostapd_bss_setup_multi_link()
3081 hostapd_bss_alloc_link_id(hapd); in hostapd_bss_setup_multi_link()
3099 hapd->mld = NULL; in hostapd_bss_setup_multi_link()
3196 struct hostapd_data *hapd; in hostapd_init() local
3219 hapd = hapd_iface->bss[i] = in hostapd_init()
3222 if (hapd == NULL) in hostapd_init()
3224 hapd->msg_ctx = hapd; in hostapd_init()
3225 hostapd_bss_setup_multi_link(hapd, interfaces); in hostapd_init()
3254 struct hostapd_data *hapd = iface->bss[j]; in ifname_in_use() local
3255 if (os_strcmp(ifname, hapd->conf->iface) == 0) in ifname_in_use()
3280 struct hostapd_data *hapd; in hostapd_interface_init_bss() local
3339 hapd = hostapd_alloc_bss_data(iface, iface->conf, bss); in hostapd_interface_init_bss()
3340 if (hapd == NULL) { in hostapd_interface_init_bss()
3346 iface->bss[iface->num_bss] = hapd; in hostapd_interface_init_bss()
3347 hapd->msg_ctx = hapd; in hostapd_interface_init_bss()
3348 hostapd_bss_setup_multi_link(hapd, interfaces); in hostapd_interface_init_bss()
3590 struct hostapd_data *hapd = hapd_iface->bss[j]; in hostapd_disable_iface() local
3591 hostapd_bss_deinit_no_free(hapd); in hostapd_disable_iface()
3592 hostapd_bss_link_deinit(hapd); in hostapd_disable_iface()
3593 hostapd_free_hapd_data(hapd); in hostapd_disable_iface()
3694 struct hostapd_data *hapd; in hostapd_data_alloc() local
3702 hapd = hapd_iface->bss[i] = in hostapd_data_alloc()
3704 if (hapd == NULL) { in hostapd_data_alloc()
3714 hapd->msg_ctx = hapd; in hostapd_data_alloc()
3715 hostapd_bss_setup_multi_link(hapd, hapd_iface->interfaces); in hostapd_data_alloc()
3729 struct hostapd_data *hapd; in hostapd_add_iface() local
3780 hapd = hapd_iface->bss[hapd_iface->num_bss - 1]; in hostapd_add_iface()
3781 hapd->driver = hapd_iface->bss[0]->driver; in hostapd_add_iface()
3782 hapd->drv_priv = hapd_iface->bss[0]->drv_priv; in hostapd_add_iface()
3783 os_memcpy(hapd->own_addr, hapd_iface->bss[0]->own_addr, in hostapd_add_iface()
3786 if (start_ctrl_iface_bss(hapd) < 0 || in hostapd_add_iface()
3788 hostapd_setup_bss(hapd, -1, true))) { in hostapd_add_iface()
3789 hostapd_bss_link_deinit(hapd); in hostapd_add_iface()
3790 hostapd_cleanup(hapd); in hostapd_add_iface()
3795 __func__, hapd, hapd->conf->iface); in hostapd_add_iface()
3796 hostapd_config_free_bss(hapd->conf); in hostapd_add_iface()
3797 hapd->conf = NULL; in hostapd_add_iface()
3799 hostapd_mld_ref_dec(hapd->mld); in hostapd_add_iface()
3801 os_free(hapd); in hostapd_add_iface()
3880 hapd = hapd_iface->bss[i]; in hostapd_add_iface()
3881 if (!hapd) in hostapd_add_iface()
3886 ctrl_iface_deinit(hapd); in hostapd_add_iface()
3889 hapd->conf->iface); in hostapd_add_iface()
3890 hostapd_bss_link_deinit(hapd); in hostapd_add_iface()
3891 hostapd_cleanup(hapd); in hostapd_add_iface()
3893 hostapd_mld_ref_dec(hapd->mld); in hostapd_add_iface()
3895 os_free(hapd); in hostapd_add_iface()
3920 struct hostapd_data *hapd = iface->bss[idx]; in hostapd_remove_bss() local
3922 hostapd_bss_deinit(hapd); in hostapd_remove_bss()
3924 __func__, hapd, hapd->conf->iface); in hostapd_remove_bss()
3925 hostapd_config_free_bss(hapd->conf); in hostapd_remove_bss()
3926 hapd->conf = NULL; in hostapd_remove_bss()
3928 hostapd_mld_ref_dec(hapd->mld); in hostapd_remove_bss()
3930 os_free(hapd); in hostapd_remove_bss()
4001 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, in hostapd_new_assoc_sta() argument
4004 if (hapd->tkip_countermeasures) { in hostapd_new_assoc_sta()
4005 hostapd_drv_sta_deauth(hapd, sta->addr, in hostapd_new_assoc_sta()
4011 if (ap_sta_is_mld(hapd, sta) && in hostapd_new_assoc_sta()
4012 sta->mld_assoc_link_id != hapd->mld_link_id) in hostapd_new_assoc_sta()
4016 ap_sta_clear_disconnect_timeouts(hapd, sta); in hostapd_new_assoc_sta()
4022 hapd->num_sta_no_p2p++; in hostapd_new_assoc_sta()
4023 if (hapd->num_sta_no_p2p == 1) in hostapd_new_assoc_sta()
4024 hostapd_p2p_non_p2p_sta_connected(hapd); in hostapd_new_assoc_sta()
4028 airtime_policy_new_sta(hapd, sta); in hostapd_new_assoc_sta()
4033 if (!hapd->conf->ieee802_1x && !hapd->conf->wpa && !hapd->conf->osen) { in hostapd_new_assoc_sta()
4034 ap_sta_set_authorized(hapd, sta, 1); in hostapd_new_assoc_sta()
4036 accounting_sta_start(hapd, sta); in hostapd_new_assoc_sta()
4040 ieee802_1x_new_station(hapd, sta); in hostapd_new_assoc_sta()
4048 } else if (!(hapd->iface->drv_flags2 & in hostapd_new_assoc_sta()
4052 wpa_auth_sta_associated(hapd->wpa_auth, sta->wpa_sm); in hostapd_new_assoc_sta()
4055 if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_WIRED) { in hostapd_new_assoc_sta()
4056 if (eloop_cancel_timeout(ap_handle_timer, hapd, sta) > 0) { in hostapd_new_assoc_sta()
4060 hapd->conf->iface, __func__, in hostapd_new_assoc_sta()
4063 } else if (!(hapd->iface->drv_flags & in hostapd_new_assoc_sta()
4068 hapd->conf->iface, __func__, MAC2STR(sta->addr), in hostapd_new_assoc_sta()
4069 hapd->conf->ap_max_inactivity); in hostapd_new_assoc_sta()
4070 eloop_cancel_timeout(ap_handle_timer, hapd, sta); in hostapd_new_assoc_sta()
4071 eloop_register_timeout(hapd->conf->ap_max_inactivity, 0, in hostapd_new_assoc_sta()
4072 ap_handle_timer, hapd, sta); in hostapd_new_assoc_sta()
4076 if (hapd->conf->wpa_key_mgmt == WPA_KEY_MGMT_NONE && in hostapd_new_assoc_sta()
4077 hapd->conf->mka_psk_set) in hostapd_new_assoc_sta()
4078 ieee802_1x_create_preshared_mka_hapd(hapd, sta); in hostapd_new_assoc_sta()
4080 ieee802_1x_alloc_kay_sm_hapd(hapd, sta); in hostapd_new_assoc_sta()
4149 static int hostapd_build_beacon_data(struct hostapd_data *hapd, in hostapd_build_beacon_data() argument
4157 ret = ieee802_11_build_ap_params(hapd, &params); in hostapd_build_beacon_data()
4161 ret = hostapd_build_ap_extra_ies(hapd, &beacon_extra, in hostapd_build_beacon_data()
4224 hostapd_free_ap_extra_ies(hapd, beacon_extra, proberesp_extra, in hostapd_build_beacon_data()
4237 static int hostapd_change_config_freq(struct hostapd_data *hapd, in hostapd_change_config_freq() argument
4248 params->channel = hostapd_hw_get_channel(hapd, params->freq); in hostapd_change_config_freq()
4255 hostapd_determine_mode(hapd->iface); in hostapd_change_config_freq()
4256 mode = hapd->iface->current_mode; in hostapd_change_config_freq()
4261 hostapd_hw_get_freq(hapd, conf->channel), in hostapd_change_config_freq()
4274 hostapd_get_punct_bitmap(hapd))) in hostapd_change_config_freq()
4337 static int hostapd_fill_csa_settings(struct hostapd_data *hapd, in hostapd_fill_csa_settings() argument
4340 struct hostapd_iface *iface = hapd->iface; in hostapd_fill_csa_settings()
4349 if (!iface || !iface->freq || hapd->csa_in_progress) in hostapd_fill_csa_settings()
4374 &hapd->iface->cs_oper_class, in hostapd_fill_csa_settings()
4398 ret = hostapd_build_beacon_data(hapd, &settings->beacon_after); in hostapd_fill_csa_settings()
4411 hapd->cs_freq_params = settings->freq_params; in hostapd_fill_csa_settings()
4412 hapd->cs_count = settings->cs_count; in hostapd_fill_csa_settings()
4413 hapd->cs_block_tx = settings->block_tx; in hostapd_fill_csa_settings()
4415 ret = hostapd_build_beacon_data(hapd, &settings->beacon_csa); in hostapd_fill_csa_settings()
4421 settings->counter_offset_beacon[0] = hapd->cs_c_off_beacon; in hostapd_fill_csa_settings()
4422 settings->counter_offset_presp[0] = hapd->cs_c_off_proberesp; in hostapd_fill_csa_settings()
4423 settings->counter_offset_beacon[1] = hapd->cs_c_off_ecsa_beacon; in hostapd_fill_csa_settings()
4424 settings->counter_offset_presp[1] = hapd->cs_c_off_ecsa_proberesp; in hostapd_fill_csa_settings()
4427 if (hapd->conf->mld_ap) in hostapd_fill_csa_settings()
4428 settings->link_id = hapd->mld_link_id; in hostapd_fill_csa_settings()
4433 hostapd_unsol_bcast_probe_resp(hapd, &settings->ubpr); in hostapd_fill_csa_settings()
4440 void hostapd_cleanup_cs_params(struct hostapd_data *hapd) in hostapd_cleanup_cs_params() argument
4442 os_memset(&hapd->cs_freq_params, 0, sizeof(hapd->cs_freq_params)); in hostapd_cleanup_cs_params()
4443 hapd->cs_count = 0; in hostapd_cleanup_cs_params()
4444 hapd->cs_block_tx = 0; in hostapd_cleanup_cs_params()
4445 hapd->cs_c_off_beacon = 0; in hostapd_cleanup_cs_params()
4446 hapd->cs_c_off_proberesp = 0; in hostapd_cleanup_cs_params()
4447 hapd->csa_in_progress = 0; in hostapd_cleanup_cs_params()
4448 hapd->cs_c_off_ecsa_beacon = 0; in hostapd_cleanup_cs_params()
4449 hapd->cs_c_off_ecsa_proberesp = 0; in hostapd_cleanup_cs_params()
4453 void hostapd_chan_switch_config(struct hostapd_data *hapd, in hostapd_chan_switch_config() argument
4457 hapd->iconf->ch_switch_eht_config |= CH_SWITCH_EHT_ENABLED; in hostapd_chan_switch_config()
4459 hapd->iconf->ch_switch_eht_config |= CH_SWITCH_EHT_DISABLED; in hostapd_chan_switch_config()
4462 hapd->iconf->ch_switch_he_config |= CH_SWITCH_HE_ENABLED; in hostapd_chan_switch_config()
4464 hapd->iconf->ch_switch_he_config |= CH_SWITCH_HE_DISABLED; in hostapd_chan_switch_config()
4467 hapd->iconf->ch_switch_vht_config |= CH_SWITCH_VHT_ENABLED; in hostapd_chan_switch_config()
4469 hapd->iconf->ch_switch_vht_config |= CH_SWITCH_VHT_DISABLED; in hostapd_chan_switch_config()
4471 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, in hostapd_chan_switch_config()
4474 hapd->iconf->ch_switch_eht_config, in hostapd_chan_switch_config()
4475 hapd->iconf->ch_switch_he_config, in hostapd_chan_switch_config()
4476 hapd->iconf->ch_switch_vht_config); in hostapd_chan_switch_config()
4480 int hostapd_switch_channel(struct hostapd_data *hapd, in hostapd_switch_channel() argument
4485 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) { in hostapd_switch_channel()
4490 ret = hostapd_fill_csa_settings(hapd, settings); in hostapd_switch_channel()
4494 ret = hostapd_drv_switch_channel(hapd, settings); in hostapd_switch_channel()
4503 hostapd_cleanup_cs_params(hapd); in hostapd_switch_channel()
4507 hapd->csa_in_progress = 1; in hostapd_switch_channel()
4587 void hostapd_cleanup_cca_params(struct hostapd_data *hapd) in hostapd_cleanup_cca_params() argument
4589 hapd->cca_count = 0; in hostapd_cleanup_cca_params()
4590 hapd->cca_color = 0; in hostapd_cleanup_cca_params()
4591 hapd->cca_c_off_beacon = 0; in hostapd_cleanup_cca_params()
4592 hapd->cca_c_off_proberesp = 0; in hostapd_cleanup_cca_params()
4593 hapd->cca_in_progress = false; in hostapd_cleanup_cca_params()
4597 int hostapd_fill_cca_settings(struct hostapd_data *hapd, in hostapd_fill_cca_settings() argument
4600 struct hostapd_iface *iface = hapd->iface; in hostapd_fill_cca_settings()
4609 if (hapd->conf->mld_ap) in hostapd_fill_cca_settings()
4610 settings->link_id = hapd->mld_link_id; in hostapd_fill_cca_settings()
4614 iface->conf->he_op.he_bss_color = hapd->cca_color; in hostapd_fill_cca_settings()
4615 ret = hostapd_build_beacon_data(hapd, &settings->beacon_after); in hostapd_fill_cca_settings()
4621 settings->cca_count = hapd->cca_count; in hostapd_fill_cca_settings()
4622 settings->cca_color = hapd->cca_color, in hostapd_fill_cca_settings()
4623 hapd->cca_in_progress = true; in hostapd_fill_cca_settings()
4625 ret = hostapd_build_beacon_data(hapd, &settings->beacon_cca); in hostapd_fill_cca_settings()
4632 hostapd_unsol_bcast_probe_resp(hapd, &settings->ubpr); in hostapd_fill_cca_settings()
4634 settings->counter_offset_beacon = hapd->cca_c_off_beacon; in hostapd_fill_cca_settings()
4635 settings->counter_offset_presp = hapd->cca_c_off_proberesp; in hostapd_fill_cca_settings()
4644 struct hostapd_data *hapd = (struct hostapd_data *) eloop_data; in hostapd_switch_color_timeout_handler() local
4652 delta_t = hapd->last_color_collision.sec - in hostapd_switch_color_timeout_handler()
4653 hapd->first_color_collision.sec; in hostapd_switch_color_timeout_handler()
4659 if (r && !(hapd->color_collision_bitmap & (1ULL << r))) in hostapd_switch_color_timeout_handler()
4669 hapd->iface->conf->he_op.he_bss_color_disabled = 1; in hostapd_switch_color_timeout_handler()
4670 hapd->iface->conf->he_op.he_bss_color = os_random() % 63 + 1; in hostapd_switch_color_timeout_handler()
4671 for (b = 0; b < hapd->iface->num_bss; b++) in hostapd_switch_color_timeout_handler()
4672 ieee802_11_set_beacon(hapd->iface->bss[b]); in hostapd_switch_color_timeout_handler()
4676 for (b = 0; b < hapd->iface->num_bss; b++) { in hostapd_switch_color_timeout_handler()
4677 struct hostapd_data *bss = hapd->iface->bss[b]; in hostapd_switch_color_timeout_handler()
4701 void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap) in hostapd_switch_color() argument
4705 if (hapd->cca_in_progress) in hostapd_switch_color()
4711 hapd->color_collision_bitmap = bitmap; in hostapd_switch_color()
4712 hapd->last_color_collision = now; in hostapd_switch_color()
4715 hapd, NULL)) in hostapd_switch_color()
4718 hapd->first_color_collision = now; in hostapd_switch_color()
4722 hapd, NULL); in hostapd_switch_color()
4739 struct hostapd_data *hapd = iface->bss[j]; in hostapd_get_iface() local
4741 if (os_strcmp(ifname, hapd->conf->iface) == 0) in hostapd_get_iface()
4742 return hapd; in hostapd_get_iface()
4757 struct hostapd_data *hapd = iface->bss[i]; in hostapd_periodic_iface() local
4759 if (!hapd->started) in hostapd_periodic_iface()
4763 hostapd_acl_expire(hapd); in hostapd_periodic_iface()
4772 struct hostapd_data *hapd = eloop_ctx; in hostapd_ocv_check_csa_sa_query() local
4777 for (sta = hapd->sta_list; sta; sta = sta->next) { in hostapd_ocv_check_csa_sa_query()
4784 ap_sta_disconnect(hapd, sta, sta->addr, in hostapd_ocv_check_csa_sa_query()
4793 struct hostapd_data * hostapd_mld_get_link_bss(struct hostapd_data *hapd, in hostapd_mld_get_link_bss() argument
4800 for (i = 0; i < hapd->iface->interfaces->count; i++) { in hostapd_mld_get_link_bss()
4801 iface = hapd->iface->interfaces->iface[i]; in hostapd_mld_get_link_bss()
4809 !hostapd_is_ml_partner(hapd, bss)) in hostapd_mld_get_link_bss()
4834 u8 hostapd_get_mld_id(struct hostapd_data *hapd) in hostapd_get_mld_id() argument
4836 if (!hapd->conf->mld_ap) in hostapd_get_mld_id()
4846 int hostapd_mld_add_link(struct hostapd_data *hapd) in hostapd_mld_add_link() argument
4848 struct hostapd_mld *mld = hapd->mld; in hostapd_mld_add_link()
4850 if (!hapd->conf->mld_ap) in hostapd_mld_add_link()
4857 dl_list_add_tail(&mld->links, &hapd->link); in hostapd_mld_add_link()
4861 mld->name, hapd->mld_link_id, mld->num_links); in hostapd_mld_add_link()
4866 mld->fbss = hapd; in hostapd_mld_add_link()
4873 int hostapd_mld_remove_link(struct hostapd_data *hapd) in hostapd_mld_remove_link() argument
4875 struct hostapd_mld *mld = hapd->mld; in hostapd_mld_remove_link()
4878 if (!hapd->conf->mld_ap) in hostapd_mld_remove_link()
4885 dl_list_del(&hapd->link); in hostapd_mld_remove_link()
4889 mld->name, hapd->mld_link_id, mld->num_links); in hostapd_mld_remove_link()
4891 if (mld->fbss != hapd) in hostapd_mld_remove_link()
4909 bool hostapd_mld_is_first_bss(struct hostapd_data *hapd) in hostapd_mld_is_first_bss() argument
4911 struct hostapd_mld *mld = hapd->mld; in hostapd_mld_is_first_bss()
4913 if (!hapd->conf->mld_ap) in hostapd_mld_is_first_bss()
4925 return hapd == mld->fbss; in hostapd_mld_is_first_bss()
4929 struct hostapd_data * hostapd_mld_get_first_bss(struct hostapd_data *hapd) in hostapd_mld_get_first_bss() argument
4931 struct hostapd_mld *mld = hapd->mld; in hostapd_mld_get_first_bss()
4933 if (!hapd->conf->mld_ap) in hostapd_mld_get_first_bss()
4946 u16 hostapd_get_punct_bitmap(struct hostapd_data *hapd) in hostapd_get_punct_bitmap() argument
4951 punct_bitmap = hapd->iconf->punct_bitmap; in hostapd_get_punct_bitmap()
4954 punct_bitmap = hapd->conf->eht_oper_puncturing_override; in hostapd_get_punct_bitmap()