Lines Matching defs: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)
98 if (hapd->iconf->mbssid)
99 return hapd->iface->bss[0];
101 return hapd;
105 int hostapd_mbssid_get_bss_index(struct hostapd_data *hapd)
107 if (hapd->iconf->mbssid) {
110 for (i = 1; i < hapd->iface->num_bss; i++)
111 if (hapd->iface->bss[i] == hapd)
119 void hostapd_reconfig_encryption(struct hostapd_data *hapd)
121 if (hapd->wpa_auth)
124 hostapd_set_privacy(hapd, 0);
126 hostapd_setup_encryption(hapd->conf->iface, hapd);
131 static void hostapd_reload_bss(struct hostapd_data *hapd)
135 if (!hapd->started)
138 if (hapd->conf->wmm_enabled < 0)
139 hapd->conf->wmm_enabled = hapd->iconf->ieee80211n |
140 hapd->iconf->ieee80211ax;
143 radius_client_reconfig(hapd->radius, hapd->conf->radius);
146 ssid = &hapd->conf->ssid;
153 hostapd_config_clear_wpa_psk(&hapd->conf->ssid.wpa_psk);
155 if (hostapd_setup_wpa_psk(hapd->conf)) {
160 if (hapd->conf->ieee802_1x || hapd->conf->wpa)
161 hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 1);
163 hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 0);
165 if ((hapd->conf->wpa || hapd->conf->osen) && hapd->wpa_auth == NULL) {
166 hostapd_setup_wpa(hapd);
167 if (hapd->wpa_auth)
168 wpa_init_keys(hapd->wpa_auth);
169 } else if (hapd->conf->wpa) {
172 hostapd_reconfig_wpa(hapd);
173 wpa_ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &wpa_ie_len);
174 if (hostapd_set_generic_elem(hapd, wpa_ie, wpa_ie_len))
177 } else if (hapd->wpa_auth) {
178 wpa_deinit(hapd->wpa_auth);
179 hapd->wpa_auth = NULL;
180 hostapd_set_privacy(hapd, 0);
182 hostapd_setup_encryption(hapd->conf->iface, hapd);
184 hostapd_set_generic_elem(hapd, (u8 *) "", 0);
187 hostapd_neighbor_sync_own_report(hapd);
189 ieee802_11_set_beacon(hapd);
190 hostapd_update_wps(hapd);
192 if (hapd->conf->ssid.ssid_set &&
193 hostapd_set_ssid(hapd, hapd->conf->ssid.ssid,
194 hapd->conf->ssid.ssid_len)) {
198 wpa_printf(MSG_DEBUG, "Reconfigured interface %s", hapd->conf->iface);
254 struct hostapd_data *hapd = iface->bss[0];
273 oldconf = hapd->iconf;
287 hostapd_remove_iface(interfaces, hapd->conf->iface);
308 hapd = iface->bss[j];
309 if (!hapd->conf->config_id || !newconf->bss[j]->config_id ||
310 os_strcmp(hapd->conf->config_id,
312 hostapd_clear_old_bss(hapd);
313 hapd->iconf = newconf;
314 hapd->iconf->channel = oldconf->channel;
315 hapd->iconf->acs = oldconf->acs;
316 hapd->iconf->secondary_channel = oldconf->secondary_channel;
317 hapd->iconf->ieee80211n = oldconf->ieee80211n;
318 hapd->iconf->ieee80211ac = oldconf->ieee80211ac;
319 hapd->iconf->ht_capab = oldconf->ht_capab;
320 hapd->iconf->vht_capab = oldconf->vht_capab;
321 hostapd_set_oper_chwidth(hapd->iconf,
324 hapd->iconf,
327 hapd->iconf,
329 hapd->conf = newconf->bss[j];
330 hostapd_reload_bss(hapd);
342 static void hostapd_broadcast_key_clear_iface(struct hostapd_data *hapd,
347 if (!ifname || !hapd->drv_priv)
350 if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i, 0,
357 if (hapd->conf->ieee80211w) {
359 if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE,
371 static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd)
373 hostapd_broadcast_key_clear_iface(hapd, hapd->conf->iface);
378 static int hostapd_broadcast_wep_set(struct hostapd_data *hapd)
381 struct hostapd_ssid *ssid = &hapd->conf->ssid;
385 hostapd_drv_set_key(hapd->conf->iface,
386 hapd, WPA_ALG_WEP, broadcast_ether_addr, idx, 0,
408 struct hostapd_data *hapd = (struct hostapd_data *) eloop_data;
410 if (hapd->eht_mld_link_removal_count == 0)
412 hapd->eht_mld_link_removal_count--;
415 hapd->mld_link_id,
416 hapd->eht_mld_link_removal_count);
418 ieee802_11_set_beacon(hapd);
420 if (!hapd->eht_mld_link_removal_count) {
421 hostapd_free_link_stas(hapd);
422 hostapd_disable_iface(hapd->iface);
426 eloop_register_timeout(0, TU_TO_USEC(hapd->iconf->beacon_int),
428 hapd, NULL);
432 int hostapd_link_remove(struct hostapd_data *hapd, u32 count)
434 if (!hapd->conf->mld_ap)
439 hapd->mld_link_id, count);
441 hapd->eht_mld_link_removal_count = count;
442 hapd->eht_mld_bss_param_change++;
444 eloop_register_timeout(0, TU_TO_USEC(hapd->iconf->beacon_int),
446 hapd, NULL);
448 ieee802_11_set_beacon(hapd);
456 void hostapd_free_hapd_data(struct hostapd_data *hapd)
458 os_free(hapd->probereq_cb);
459 hapd->probereq_cb = NULL;
460 hapd->num_probereq_cb = 0;
463 wpabuf_free(hapd->p2p_beacon_ie);
464 hapd->p2p_beacon_ie = NULL;
465 wpabuf_free(hapd->p2p_probe_resp_ie);
466 hapd->p2p_probe_resp_ie = NULL;
469 if (!hapd->started) {
471 __func__, hapd->conf ? hapd->conf->iface : "N/A");
474 hapd->started = 0;
475 hapd->beacon_set_done = 0;
477 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
478 accounting_deinit(hapd);
479 hostapd_deinit_wpa(hapd);
480 vlan_deinit(hapd);
481 hostapd_acl_deinit(hapd);
483 if (hostapd_mld_is_first_bss(hapd)) {
485 struct hapd_interfaces *ifaces = hapd->iface->interfaces;
495 if (hapd == h)
497 if (h->radius == hapd->radius)
499 if (h->radius_das == hapd->radius_das)
504 radius_client_deinit(hapd->radius);
505 radius_das_deinit(hapd->radius_das);
507 hapd->radius = NULL;
508 hapd->radius_das = NULL;
511 hostapd_deinit_wps(hapd);
512 ieee802_1x_dealloc_kay_sm_hapd(hapd);
514 hostapd_dpp_deinit(hapd);
515 gas_query_ap_deinit(hapd->gas);
516 hapd->gas = NULL;
519 hostapd_nan_usd_deinit(hapd);
522 authsrv_deinit(hapd);
524 if (hapd->interface_added) {
525 hapd->interface_added = 0;
526 if (hostapd_if_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface)) {
529 hapd->conf->iface);
530 hapd->interface_added = 1;
535 * and hapd->drv_priv is not valid anymore.
537 hapd->drv_priv = NULL;
545 if (hapd->conf->mld_ap && !hapd->interface_added &&
546 hapd->iface->bss[0] != hapd)
547 hostapd_if_link_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface,
548 hapd->mld_link_id);
551 wpabuf_free(hapd->time_adv);
552 hapd->time_adv = NULL;
555 gas_serv_deinit(hapd);
558 bss_load_update_deinit(hapd);
559 ndisc_snoop_deinit(hapd);
560 dhcp_snoop_deinit(hapd);
561 x_snoop_deinit(hapd);
564 bin_clear_free(hapd->tmp_eap_user.identity,
565 hapd->tmp_eap_user.identity_len);
566 bin_clear_free(hapd->tmp_eap_user.password,
567 hapd->tmp_eap_user.password_len);
568 os_memset(&hapd->tmp_eap_user, 0, sizeof(hapd->tmp_eap_user));
572 wpabuf_free(hapd->mesh_pending_auth);
573 hapd->mesh_pending_auth = NULL;
575 hapd->setup_complete_cb = NULL;
579 hostapd_clean_rrm(hapd);
581 fils_hlp_deinit(hapd);
584 eloop_cancel_timeout(hostapd_ocv_check_csa_sa_query, hapd, NULL);
591 while ((q = dl_list_first(&hapd->sae_commit_queue,
598 eloop_cancel_timeout(auth_sae_process_commit, hapd, NULL);
602 eloop_cancel_timeout(hostapd_switch_color_timeout_handler, hapd, NULL);
605 eloop_cancel_timeout(hostapd_link_remove_timeout_handler, hapd, NULL);
614 * @hapd: Pointer to BSS data
620 static void hostapd_bss_link_deinit(struct hostapd_data *hapd)
623 if (!hapd->conf || !hapd->conf->mld_ap)
626 if (!hapd->mld->num_links)
633 if (!hapd->started && hapd->iface->bss[0] != hapd)
640 if (hapd->iface->bss[0] == hapd && !hapd->drv_priv)
643 hostapd_mld_remove_link(hapd);
650 * @hapd: Pointer to BSS data
656 static void hostapd_cleanup(struct hostapd_data *hapd)
658 wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s))", __func__, hapd,
659 hapd->conf ? hapd->conf->iface : "N/A");
660 if (hapd->iface->interfaces &&
661 hapd->iface->interfaces->ctrl_iface_deinit) {
662 wpa_msg(hapd->msg_ctx, MSG_INFO, WPA_EVENT_TERMINATING);
663 hapd->iface->interfaces->ctrl_iface_deinit(hapd);
665 hostapd_free_hapd_data(hapd);
734 static void hostapd_clear_wep(struct hostapd_data *hapd)
736 if (hapd->drv_priv && !hapd->iface->driver_ap_teardown && hapd->conf) {
737 hostapd_set_privacy(hapd, 0);
738 hostapd_broadcast_wep_clear(hapd);
743 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd)
747 hostapd_broadcast_wep_set(hapd);
749 if (hapd->conf->ssid.wep.default_len) {
750 hostapd_set_privacy(hapd, 1);
758 hostapd_drv_set_authmode(hapd, hapd->conf->auth_algs);
761 if (hapd->conf->ssid.wep.key[i] &&
762 hostapd_drv_set_key(iface, hapd, WPA_ALG_WEP, NULL, i, 0,
763 i == hapd->conf->ssid.wep.idx, NULL, 0,
764 hapd->conf->ssid.wep.key[i],
765 hapd->conf->ssid.wep.len[i],
766 i == hapd->conf->ssid.wep.idx ?
773 if (hapd->conf->ssid.wep.key[i] &&
774 i == hapd->conf->ssid.wep.idx)
775 hostapd_set_privacy(hapd, 1);
784 static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason)
789 if (hostapd_drv_none(hapd) || hapd->drv_priv == NULL)
792 if (!hapd->iface->driver_ap_teardown) {
793 wpa_dbg(hapd->msg_ctx, MSG_DEBUG,
796 if (hostapd_flush(hapd)) {
797 wpa_msg(hapd->msg_ctx, MSG_WARNING,
802 if (hapd->conf && hapd->conf->broadcast_deauth) {
803 wpa_dbg(hapd->msg_ctx, MSG_DEBUG,
806 hostapd_drv_sta_deauth(hapd, addr, reason);
808 hostapd_free_stas(hapd);
814 void hostapd_bss_deinit_no_free(struct hostapd_data *hapd)
816 hostapd_free_stas(hapd);
817 hostapd_flush_old_stations(hapd, WLAN_REASON_DEAUTH_LEAVING);
819 hostapd_clear_wep(hapd);
834 struct hostapd_data *hapd = iface->bss[0];
838 if (hostapd_drv_none(hapd))
862 hapd->own_addr[i];
908 if ((hapd->own_addr[i] & mask[i]) != hapd->own_addr[i]) {
911 MAC2STR(mask), MAC2STR(hapd->own_addr));
939 static int hostapd_das_nas_mismatch(struct hostapd_data *hapd,
943 (!hapd->conf->nas_identifier ||
944 os_strlen(hapd->conf->nas_identifier) !=
946 os_memcmp(hapd->conf->nas_identifier, attr->nas_identifier,
953 (hapd->conf->own_ip_addr.af != AF_INET ||
954 os_memcmp(&hapd->conf->own_ip_addr.u.v4, attr->nas_ip_addr, 4) !=
962 (hapd->conf->own_ip_addr.af != AF_INET6 ||
963 os_memcmp(&hapd->conf->own_ip_addr.u.v6, attr->nas_ipv6_addr, 16)
974 static struct sta_info * hostapd_das_find_sta(struct hostapd_data *hapd,
985 for (sta = hapd->sta_list; sta; sta = sta->next)
990 sta = ap_get_sta(hapd, attr->sta_addr);
998 for (sta = hapd->sta_list; sta; sta = sta->next) {
1014 for (sta = hapd->sta_list; sta; sta = sta->next) {
1042 for (sta = hapd->sta_list; sta; sta = sta->next) {
1073 for (sta = hapd->sta_list; sta; sta = sta->next) {
1100 for (sta = hapd->sta_list; sta; sta = sta->next) {
1138 for (sta = hapd->sta_list; sta; sta = sta->next) {
1152 static int hostapd_das_disconnect_pmksa(struct hostapd_data *hapd,
1155 if (!hapd->wpa_auth)
1157 return wpa_auth_radius_das_disconnect_pmksa(hapd->wpa_auth, attr);
1164 struct hostapd_data *hapd = ctx;
1168 if (hostapd_das_nas_mismatch(hapd, attr))
1171 sta = hostapd_das_find_sta(hapd, attr, &multi);
1178 if (hostapd_das_disconnect_pmksa(hapd, attr) == 0) {
1189 wpa_auth_pmksa_remove(hapd->wpa_auth, sta->addr);
1191 hostapd_drv_sta_deauth(hapd, sta->addr,
1193 ap_sta_deauthenticate(hapd, sta, WLAN_REASON_PREV_AUTH_NOT_VALID);
1203 struct hostapd_data *hapd = ctx;
1207 if (hostapd_das_nas_mismatch(hapd, attr))
1210 sta = hostapd_das_find_sta(hapd, attr, &multi);
1231 hs20_t_c_filtering(hapd, sta, 0);
1280 static int hostapd_start_beacon(struct hostapd_data *hapd,
1283 struct hostapd_bss_config *conf = hapd->conf;
1285 if (!conf->start_disabled && ieee802_11_set_beacon(hapd) < 0)
1296 wpa_dbg(hapd->msg_ctx, MSG_DEBUG,
1299 hostapd_drv_sta_deauth(hapd, addr,
1303 if (hapd->driver && hapd->driver->set_operstate)
1304 hapd->driver->set_operstate(hapd->drv_priv, 1);
1311 static int hostapd_bss_radius_init(struct hostapd_data *hapd)
1315 if (!hapd)
1318 conf = hapd->conf;
1320 if (hapd->radius) {
1326 hapd->radius = radius_client_init(hapd, conf->radius);
1327 if (!hapd->radius) {
1347 das_conf.ctx = hapd;
1350 hapd->radius_das = radius_das_init(&das_conf);
1351 if (!hapd->radius_das) {
1365 * @hapd: Pointer to BSS data
1380 static int hostapd_setup_bss(struct hostapd_data *hapd, int first,
1383 struct hostapd_bss_config *conf = hapd->conf;
1390 if (!hostapd_mld_is_first_bss(hapd))
1394 wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s), first=%d)",
1395 __func__, hapd, conf->iface, first);
1404 if (hapd->started) {
1409 hapd->started = 1;
1412 u8 *addr = hapd->own_addr;
1416 os_memcpy(hapd->own_addr, conf->bssid, ETH_ALEN);
1418 if (hostapd_mac_comp(hapd->own_addr,
1419 hapd->iface->bss[0]->own_addr) ==
1426 } else if (hapd->iconf->use_driver_iface_addr) {
1431 inc_byte_array(hapd->own_addr, ETH_ALEN);
1432 } while (mac_in_conf(hapd->iconf, hapd->own_addr));
1439 h_hapd = hostapd_mld_get_first_bss(hapd);
1441 hapd->drv_priv = h_hapd->drv_priv;
1442 hapd->interface_added = h_hapd->interface_added;
1443 hostapd_mld_add_link(hapd);
1446 hapd->mld_link_id, hapd->conf->iface);
1452 hapd->interface_added = 1;
1453 if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS,
1454 conf->iface, addr, hapd,
1455 &hapd->drv_priv, force_ifname, if_addr,
1459 MACSTR ")", MAC2STR(hapd->own_addr));
1460 hapd->interface_added = 0;
1465 os_memcpy(hapd->own_addr, if_addr, ETH_ALEN);
1468 if (hapd->conf->mld_ap) {
1471 hapd->mld_link_id, hapd->conf->iface);
1472 os_memcpy(hapd->mld->mld_addr, hapd->own_addr,
1474 hostapd_mld_add_link(hapd);
1481 if (hapd->conf->mld_ap && !first) {
1485 hapd->mld_link_id, MAC2STR(hapd->mld->mld_addr),
1486 MAC2STR(hapd->own_addr));
1488 if (hostapd_drv_link_add(hapd, hapd->mld_link_id,
1489 hapd->own_addr))
1495 conf->wmm_enabled = hapd->iconf->ieee80211n |
1496 hapd->iconf->ieee80211ax;
1500 os_memcpy(conf->r1_key_holder, hapd->own_addr, ETH_ALEN);
1504 if ((hapd->conf->mesh & MESH_ENABLED) && hapd->iface->mconf == NULL)
1509 hostapd_flush(hapd);
1510 hostapd_set_privacy(hapd, 0);
1513 if (!hostapd_drv_nl80211(hapd))
1514 hostapd_broadcast_wep_clear(hapd);
1515 if (hostapd_setup_encryption(conf->iface, hapd))
1524 ssid_len = hostapd_get_ssid(hapd, ssid, sizeof(ssid));
1554 if (!hostapd_drv_none(hapd)) {
1557 conf->iface, MAC2STR(hapd->own_addr),
1568 if (set_ssid && hostapd_set_ssid(hapd, conf->ssid.ssid,
1581 &hapd->rad_attr_db)) {
1589 if (!db_table_exists(hapd->rad_attr_db, "radius_attributes") &&
1590 db_table_create_radius_attributes(hapd->rad_attr_db) < 0)
1595 if (hostapd_mld_is_first_bss(hapd)) {
1596 if (hostapd_bss_radius_init(hapd))
1602 f_bss = hostapd_mld_get_first_bss(hapd);
1616 hapd->radius = f_bss->radius;
1617 hapd->radius_das = f_bss->radius_das;
1622 if (hostapd_acl_init(hapd)) {
1626 if (hostapd_init_wps(hapd, conf))
1630 hapd->gas = gas_query_ap_init(hapd, hapd->msg_ctx);
1631 if (!hapd->gas)
1633 if (hostapd_dpp_init(hapd))
1638 if (hostapd_nan_usd_init(hapd) < 0)
1642 if (authsrv_init(hapd) < 0)
1645 if (ieee802_1x_init(hapd)) {
1650 if ((conf->wpa || conf->osen) && hostapd_setup_wpa(hapd))
1653 if (accounting_init(hapd)) {
1659 if (gas_serv_init(hapd)) {
1666 hostapd_drv_set_qos_map(hapd, conf->qos_map_set,
1672 if (conf->bss_load_update_period && bss_load_update_init(hapd)) {
1685 hapd, DRV_BR_PORT_ATTR_MCAST2UCAST, 1);
1690 hapd, DRV_BR_PORT_ATTR_HAIRPIN_MODE, 1);
1694 if (x_snoop_init(hapd)) {
1700 if (dhcp_snoop_init(hapd)) {
1706 if (ndisc_snoop_init(hapd)) {
1713 if (!hostapd_drv_none(hapd) && vlan_init(hapd)) {
1718 if (start_beacon && hostapd_start_beacon(hapd, flush_old_stations) < 0)
1721 if (hapd->wpa_auth && wpa_init_keys(hapd->wpa_auth) < 0)
1730 struct hostapd_data *hapd = iface->bss[0];
1735 if ((hapd->conf->mesh & MESH_ENABLED) && iface->mconf == NULL)
1742 if (hostapd_set_tx_queue_params(hapd, i, p->aifs, p->cwmin,
1752 static int hostapd_set_acl_list(struct hostapd_data *hapd,
1771 err = hostapd_drv_set_acl(hapd, acl_params);
1779 int hostapd_set_acl(struct hostapd_data *hapd)
1781 struct hostapd_config *conf = hapd->iconf;
1785 if (hapd->iface->drv_max_acl_mac_addrs == 0)
1790 err = hostapd_set_acl_list(hapd, conf->bss[0]->accept_mac,
1799 err = hostapd_set_acl_list(hapd, conf->bss[0]->deny_mac,
1811 static int start_ctrl_iface_bss(struct hostapd_data *hapd)
1813 if (!hapd->iface->interfaces ||
1814 !hapd->iface->interfaces->ctrl_iface_init)
1817 if (hapd->iface->interfaces->ctrl_iface_init(hapd)) {
1820 hapd->conf->iface);
1836 struct hostapd_data *hapd = iface->bss[i];
1837 if (iface->interfaces->ctrl_iface_init(hapd)) {
1840 hapd->conf->iface);
2007 struct hostapd_data *hapd = iface->bss[0];
2020 const char *phy = hostapd_drv_get_radio_name(hapd);
2032 iface->bss[i]->driver = hapd->driver;
2033 iface->bss[i]->drv_priv = hapd->drv_priv;
2047 if (hapd->iconf->country[0] && hapd->iconf->country[1]) {
2051 if (hostapd_get_country(hapd, previous_country) < 0)
2054 os_memcpy(country, hapd->iconf->country, 3);
2056 if (hostapd_set_country(hapd, country) < 0) {
2237 struct hostapd_data *hapd = ctx;
2239 return hapd->own_addr;
2247 struct hostapd_data *hapd = ctx;
2249 *hw_mode = ieee80211_freq_to_chan(hapd->iface->freq, channel);
2256 struct hostapd_data *hapd = ctx;
2258 *modes = hapd->iface->hw_features;
2259 return hapd->iface->num_hw_features;
2265 struct hostapd_data *hapd = ctx;
2267 if (hapd->iface->fst_ies != fst_ies) {
2268 hapd->iface->fst_ies = fst_ies;
2269 if (ieee802_11_set_beacon(hapd))
2278 struct hostapd_data *hapd = ctx;
2280 return hostapd_drv_send_action(hapd, hapd->iface->freq, 0, da,
2287 struct hostapd_data *hapd = ctx;
2288 struct sta_info *sta = ap_get_sta(hapd, addr);
2297 struct hostapd_data *hapd = ctx;
2298 struct sta_info *sta = ap_get_sta(hapd, addr);
2336 struct hostapd_data *hapd = ctx;
2338 *get_ctx = (struct fst_get_peer_ctx *) hapd->sta_list;
2352 void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd,
2356 iface_obj->ctx = hapd;
2374 struct hostapd_data *hapd = ctx;
2380 if (os_strcmp(hapd->conf->owe_transition_ifname,
2387 hapd->conf->iface, bss->conf->iface,
2395 os_memcpy(hapd->conf->owe_transition_bssid, bss->own_addr,
2397 os_memcpy(hapd->conf->owe_transition_ssid,
2399 hapd->conf->owe_transition_ssid_len = bss->conf->ssid.ssid_len;
2409 int hostapd_owe_trans_get_info(struct hostapd_data *hapd)
2411 if (hapd->conf->owe_transition_ssid_len > 0 &&
2412 !is_zero_ether_addr(hapd->conf->owe_transition_bssid))
2417 if (!hapd->iface->interfaces ||
2418 !hapd->iface->interfaces->for_each_interface)
2419 return hostapd_owe_iface_iter(hapd->iface, hapd);
2421 return hapd->iface->interfaces->for_each_interface(
2422 hapd->iface->interfaces, hostapd_owe_iface_iter, hapd);
2477 struct hostapd_data *hapd;
2481 hapd = iface->bss[0];
2482 if (hapd->setup_complete_cb)
2483 hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
2490 struct hostapd_data *hapd = iface->bss[0];
2550 hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq,
2551 hapd->iconf->channel,
2552 hapd->iconf->enable_edmg,
2553 hapd->iconf->edmg_channel,
2554 hapd->iconf->ieee80211n,
2555 hapd->iconf->ieee80211ac,
2556 hapd->iconf->ieee80211ax,
2557 hapd->iconf->ieee80211be,
2558 hapd->iconf->secondary_channel,
2559 hostapd_get_oper_chwidth(hapd->iconf),
2561 hapd->iconf),
2563 hapd->iconf))) {
2574 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
2581 if (hapd->iconf->rts_threshold >= -1 &&
2582 hostapd_set_rts(hapd, hapd->iconf->rts_threshold) &&
2583 hapd->iconf->rts_threshold >= -1) {
2589 if (hapd->iconf->fragm_threshold >= -1 &&
2590 hostapd_set_frag(hapd, hapd->iconf->fragm_threshold) &&
2591 hapd->iconf->fragm_threshold != -1) {
2597 prev_addr = hapd->own_addr;
2600 hapd = iface->bss[j];
2602 os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
2603 if (hostapd_setup_bss(hapd, j == 0, !iface->conf->mbssid)) {
2605 hapd = iface->bss[j];
2606 hostapd_bss_deinit_no_free(hapd);
2607 hostapd_free_hapd_data(hapd);
2614 if (is_zero_ether_addr(hapd->conf->bssid))
2615 prev_addr = hapd->own_addr;
2618 if (hapd->iconf->mbssid) {
2619 for (j = 0; hapd->iconf->mbssid && j < iface->num_bss; j++) {
2620 hapd = iface->bss[j];
2621 if (hostapd_start_beacon(hapd, true)) {
2623 hapd = iface->bss[j];
2624 hostapd_bss_deinit_no_free(hapd);
2625 hostapd_free_hapd_data(hapd);
2635 hapd = iface->bss[0];
2641 hostapd_set_acl(hapd);
2643 if (hostapd_driver_commit(hapd) < 0) {
2675 if (hapd->iconf->fst_cfg.group_id[0]) {
2678 fst_hostapd_fill_iface_obj(hapd, &iface_obj);
2679 iface->fst = fst_attach(hapd->conf->iface, hapd->own_addr,
2680 &iface_obj, &hapd->iconf->fst_cfg);
2683 hapd->iconf->fst_cfg.group_id);
2693 if (hapd->setup_complete_cb)
2694 hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
2721 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_NO_IR);
2726 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
2736 } else if (hapd->setup_complete_cb) {
2738 * Calling hapd->setup_complete_cb directly may cause iface
2761 struct hostapd_data *hapd = iface->bss[0];
2774 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_NO_IR);
2779 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
2889 struct hostapd_data *hapd;
2891 hapd = os_zalloc(sizeof(*hapd));
2892 if (hapd == NULL)
2895 hapd->new_assoc_sta_cb = hostapd_new_assoc_sta;
2896 hapd->iconf = conf;
2897 hapd->conf = bss;
2898 hapd->iface = hapd_iface;
2900 hapd->driver = conf->driver;
2901 hapd->ctrl_sock = -1;
2902 dl_list_init(&hapd->ctrl_dst);
2903 dl_list_init(&hapd->nr_db);
2904 hapd->dhcp_sock = -1;
2906 dl_list_init(&hapd->l2_queue);
2907 dl_list_init(&hapd->l2_oui_queue);
2910 dl_list_init(&hapd->sae_commit_queue);
2913 return hapd;
2917 static void hostapd_bss_deinit(struct hostapd_data *hapd)
2919 if (!hapd)
2922 hapd->conf ? hapd->conf->iface : "N/A");
2923 hostapd_bss_deinit_no_free(hapd);
2924 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
2926 if (hapd->rad_attr_db) {
2927 sqlite3_close(hapd->rad_attr_db);
2928 hapd->rad_attr_db = NULL;
2932 hostapd_bss_link_deinit(hapd);
2933 hostapd_cleanup(hapd);
3016 wpa_printf(MSG_DEBUG, "%s: free hapd %p",
3039 static void hostapd_bss_alloc_link_id(struct hostapd_data *hapd)
3041 hapd->mld_link_id = hapd->mld->next_link_id++;
3043 hapd->mld->name, hapd->mld_link_id);
3048 static void hostapd_bss_setup_multi_link(struct hostapd_data *hapd,
3056 conf = hapd->conf;
3058 if (!hapd->iconf || !hapd->iconf->ieee80211be || !conf->mld_ap ||
3068 hapd->mld = mld;
3070 hostapd_bss_alloc_link_id(hapd);
3074 if (hapd->mld)
3086 hapd->mld = mld;
3088 hostapd_bss_alloc_link_id(hapd);
3106 hapd->mld = NULL;
3203 struct hostapd_data *hapd;
3226 hapd = hapd_iface->bss[i] =
3229 if (hapd == NULL)
3231 hapd->msg_ctx = hapd;
3232 hostapd_bss_setup_multi_link(hapd, interfaces);
3261 struct hostapd_data *hapd = iface->bss[j];
3262 if (os_strcmp(ifname, hapd->conf->iface) == 0)
3287 struct hostapd_data *hapd;
3346 hapd = hostapd_alloc_bss_data(iface, iface->conf, bss);
3347 if (hapd == NULL) {
3353 iface->bss[iface->num_bss] = hapd;
3354 hapd->msg_ctx = hapd;
3355 hostapd_bss_setup_multi_link(hapd, interfaces);
3597 struct hostapd_data *hapd = hapd_iface->bss[j];
3598 hostapd_bss_deinit_no_free(hapd);
3599 hostapd_bss_link_deinit(hapd);
3600 hostapd_free_hapd_data(hapd);
3701 struct hostapd_data *hapd;
3709 hapd = hapd_iface->bss[i] =
3711 if (hapd == NULL) {
3721 hapd->msg_ctx = hapd;
3722 hostapd_bss_setup_multi_link(hapd, hapd_iface->interfaces);
3736 struct hostapd_data *hapd;
3787 hapd = hapd_iface->bss[hapd_iface->num_bss - 1];
3788 hapd->driver = hapd_iface->bss[0]->driver;
3789 hapd->drv_priv = hapd_iface->bss[0]->drv_priv;
3790 os_memcpy(hapd->own_addr, hapd_iface->bss[0]->own_addr,
3793 if (start_ctrl_iface_bss(hapd) < 0 ||
3795 hostapd_setup_bss(hapd, -1, true))) {
3796 hostapd_bss_link_deinit(hapd);
3797 hostapd_cleanup(hapd);
3801 wpa_printf(MSG_DEBUG, "%s: free hapd %p %s",
3802 __func__, hapd, hapd->conf->iface);
3803 hostapd_config_free_bss(hapd->conf);
3804 hapd->conf = NULL;
3806 hostapd_mld_ref_dec(hapd->mld);
3808 os_free(hapd);
3887 hapd = hapd_iface->bss[i];
3888 if (!hapd)
3893 ctrl_iface_deinit(hapd);
3894 wpa_printf(MSG_DEBUG, "%s: free hapd %p (%s)",
3896 hapd->conf->iface);
3897 hostapd_bss_link_deinit(hapd);
3898 hostapd_cleanup(hapd);
3900 hostapd_mld_ref_dec(hapd->mld);
3902 os_free(hapd);
3927 struct hostapd_data *hapd = iface->bss[idx];
3929 hostapd_bss_deinit(hapd);
3930 wpa_printf(MSG_DEBUG, "%s: free hapd %p (%s)",
3931 __func__, hapd, hapd->conf->iface);
3932 hostapd_config_free_bss(hapd->conf);
3933 hapd->conf = NULL;
3935 hostapd_mld_ref_dec(hapd->mld);
3937 os_free(hapd);
3999 * @hapd: Pointer to BSS data
4008 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
4011 if (hapd->tkip_countermeasures) {
4012 hostapd_drv_sta_deauth(hapd, sta->addr,
4018 if (ap_sta_is_mld(hapd, sta) &&
4019 sta->mld_assoc_link_id != hapd->mld_link_id)
4023 ap_sta_clear_disconnect_timeouts(hapd, sta);
4029 hapd->num_sta_no_p2p++;
4030 if (hapd->num_sta_no_p2p == 1)
4031 hostapd_p2p_non_p2p_sta_connected(hapd);
4035 airtime_policy_new_sta(hapd, sta);
4040 if (!hapd->conf->ieee802_1x && !hapd->conf->wpa && !hapd->conf->osen) {
4041 ap_sta_set_authorized(hapd, sta, 1);
4043 accounting_sta_start(hapd, sta);
4047 ieee802_1x_new_station(hapd, sta);
4055 } else if (!(hapd->iface->drv_flags2 &
4059 wpa_auth_sta_associated(hapd->wpa_auth, sta->wpa_sm);
4062 if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_WIRED) {
4063 if (eloop_cancel_timeout(ap_handle_timer, hapd, sta) > 0) {
4067 hapd->conf->iface, __func__,
4070 } else if (!(hapd->iface->drv_flags &
4075 hapd->conf->iface, __func__, MAC2STR(sta->addr),
4076 hapd->conf->ap_max_inactivity);
4077 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
4078 eloop_register_timeout(hapd->conf->ap_max_inactivity, 0,
4079 ap_handle_timer, hapd, sta);
4083 if (hapd->conf->wpa_key_mgmt == WPA_KEY_MGMT_NONE &&
4084 hapd->conf->mka_psk_set)
4085 ieee802_1x_create_preshared_mka_hapd(hapd, sta);
4087 ieee802_1x_alloc_kay_sm_hapd(hapd, sta);
4156 static int hostapd_build_beacon_data(struct hostapd_data *hapd,
4164 ret = ieee802_11_build_ap_params(hapd, ¶ms);
4168 ret = hostapd_build_ap_extra_ies(hapd, &beacon_extra,
4231 hostapd_free_ap_extra_ies(hapd, beacon_extra, proberesp_extra,
4244 static int hostapd_change_config_freq(struct hostapd_data *hapd,
4255 params->channel = hostapd_hw_get_channel(hapd, params->freq);
4262 hostapd_determine_mode(hapd->iface);
4263 mode = hapd->iface->current_mode;
4268 hostapd_hw_get_freq(hapd, conf->channel),
4281 hostapd_get_punct_bitmap(hapd)))
4344 static int hostapd_fill_csa_settings(struct hostapd_data *hapd,
4347 struct hostapd_iface *iface = hapd->iface;
4356 if (!iface || !iface->freq || hapd->csa_in_progress)
4381 &hapd->iface->cs_oper_class,
4405 ret = hostapd_build_beacon_data(hapd, &settings->beacon_after);
4418 hapd->cs_freq_params = settings->freq_params;
4419 hapd->cs_count = settings->cs_count;
4420 hapd->cs_block_tx = settings->block_tx;
4422 ret = hostapd_build_beacon_data(hapd, &settings->beacon_csa);
4428 settings->counter_offset_beacon[0] = hapd->cs_c_off_beacon;
4429 settings->counter_offset_presp[0] = hapd->cs_c_off_proberesp;
4430 settings->counter_offset_beacon[1] = hapd->cs_c_off_ecsa_beacon;
4431 settings->counter_offset_presp[1] = hapd->cs_c_off_ecsa_proberesp;
4434 if (hapd->conf->mld_ap)
4435 settings->link_id = hapd->mld_link_id;
4440 hostapd_unsol_bcast_probe_resp(hapd, &settings->ubpr);
4447 void hostapd_cleanup_cs_params(struct hostapd_data *hapd)
4449 os_memset(&hapd->cs_freq_params, 0, sizeof(hapd->cs_freq_params));
4450 hapd->cs_count = 0;
4451 hapd->cs_block_tx = 0;
4452 hapd->cs_c_off_beacon = 0;
4453 hapd->cs_c_off_proberesp = 0;
4454 hapd->csa_in_progress = 0;
4455 hapd->cs_c_off_ecsa_beacon = 0;
4456 hapd->cs_c_off_ecsa_proberesp = 0;
4460 void hostapd_chan_switch_config(struct hostapd_data *hapd,
4464 hapd->iconf->ch_switch_eht_config |= CH_SWITCH_EHT_ENABLED;
4466 hapd->iconf->ch_switch_eht_config |= CH_SWITCH_EHT_DISABLED;
4469 hapd->iconf->ch_switch_he_config |= CH_SWITCH_HE_ENABLED;
4471 hapd->iconf->ch_switch_he_config |= CH_SWITCH_HE_DISABLED;
4474 hapd->iconf->ch_switch_vht_config |= CH_SWITCH_VHT_ENABLED;
4476 hapd->iconf->ch_switch_vht_config |= CH_SWITCH_VHT_DISABLED;
4478 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
4481 hapd->iconf->ch_switch_eht_config,
4482 hapd->iconf->ch_switch_he_config,
4483 hapd->iconf->ch_switch_vht_config);
4487 int hostapd_switch_channel(struct hostapd_data *hapd,
4492 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) {
4497 ret = hostapd_fill_csa_settings(hapd, settings);
4501 ret = hostapd_drv_switch_channel(hapd, settings);
4510 hostapd_cleanup_cs_params(hapd);
4514 hapd->csa_in_progress = 1;
4594 void hostapd_cleanup_cca_params(struct hostapd_data *hapd)
4596 hapd->cca_count = 0;
4597 hapd->cca_color = 0;
4598 hapd->cca_c_off_beacon = 0;
4599 hapd->cca_c_off_proberesp = 0;
4600 hapd->cca_in_progress = false;
4604 int hostapd_fill_cca_settings(struct hostapd_data *hapd,
4607 struct hostapd_iface *iface = hapd->iface;
4616 if (hapd->conf->mld_ap)
4617 settings->link_id = hapd->mld_link_id;
4621 iface->conf->he_op.he_bss_color = hapd->cca_color;
4622 ret = hostapd_build_beacon_data(hapd, &settings->beacon_after);
4628 settings->cca_count = hapd->cca_count;
4629 settings->cca_color = hapd->cca_color,
4630 hapd->cca_in_progress = true;
4632 ret = hostapd_build_beacon_data(hapd, &settings->beacon_cca);
4639 hostapd_unsol_bcast_probe_resp(hapd, &settings->ubpr);
4641 settings->counter_offset_beacon = hapd->cca_c_off_beacon;
4642 settings->counter_offset_presp = hapd->cca_c_off_proberesp;
4651 struct hostapd_data *hapd = (struct hostapd_data *) eloop_data;
4659 delta_t = hapd->last_color_collision.sec -
4660 hapd->first_color_collision.sec;
4666 if (r && !(hapd->color_collision_bitmap & (1ULL << r)))
4676 hapd->iface->conf->he_op.he_bss_color_disabled = 1;
4677 hapd->iface->conf->he_op.he_bss_color = os_random() % 63 + 1;
4678 for (b = 0; b < hapd->iface->num_bss; b++)
4679 ieee802_11_set_beacon(hapd->iface->bss[b]);
4683 for (b = 0; b < hapd->iface->num_bss; b++) {
4684 struct hostapd_data *bss = hapd->iface->bss[b];
4708 void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap)
4712 if (hapd->cca_in_progress)
4718 hapd->color_collision_bitmap = bitmap;
4719 hapd->last_color_collision = now;
4722 hapd, NULL))
4725 hapd->first_color_collision = now;
4729 hapd, NULL);
4746 struct hostapd_data *hapd = iface->bss[j];
4748 if (os_strcmp(ifname, hapd->conf->iface) == 0)
4749 return hapd;
4764 struct hostapd_data *hapd = iface->bss[i];
4766 if (!hapd->started)
4770 hostapd_acl_expire(hapd);
4779 struct hostapd_data *hapd = eloop_ctx;
4784 for (sta = hapd->sta_list; sta; sta = sta->next) {
4791 ap_sta_disconnect(hapd, sta, sta->addr,
4800 struct hostapd_data * hostapd_mld_get_link_bss(struct hostapd_data *hapd,
4807 for (i = 0; i < hapd->iface->interfaces->count; i++) {
4808 iface = hapd->iface->interfaces->iface[i];
4816 !hostapd_is_ml_partner(hapd, bss))
4841 u8 hostapd_get_mld_id(struct hostapd_data *hapd)
4843 if (!hapd->conf->mld_ap)
4853 int hostapd_mld_add_link(struct hostapd_data *hapd)
4855 struct hostapd_mld *mld = hapd->mld;
4857 if (!hapd->conf->mld_ap)
4864 dl_list_add_tail(&mld->links, &hapd->link);
4868 mld->name, hapd->mld_link_id, mld->num_links);
4873 mld->fbss = hapd;
4880 int hostapd_mld_remove_link(struct hostapd_data *hapd)
4882 struct hostapd_mld *mld = hapd->mld;
4885 if (!hapd->conf->mld_ap)
4892 dl_list_del(&hapd->link);
4896 mld->name, hapd->mld_link_id, mld->num_links);
4898 if (mld->fbss != hapd)
4916 bool hostapd_mld_is_first_bss(struct hostapd_data *hapd)
4918 struct hostapd_mld *mld = hapd->mld;
4920 if (!hapd->conf->mld_ap)
4932 return hapd == mld->fbss;
4936 struct hostapd_data * hostapd_mld_get_first_bss(struct hostapd_data *hapd)
4938 struct hostapd_mld *mld = hapd->mld;
4940 if (!hapd->conf->mld_ap)
4953 u16 hostapd_get_punct_bitmap(struct hostapd_data *hapd)
4958 punct_bitmap = hapd->iconf->punct_bitmap;
4961 punct_bitmap = hapd->conf->eht_oper_puncturing_override;