Lines Matching defs:hapd

60 static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason);
61 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd);
62 static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd);
86 void hostapd_reconfig_encryption(struct hostapd_data *hapd)
88 if (hapd->wpa_auth)
91 hostapd_set_privacy(hapd, 0);
92 hostapd_setup_encryption(hapd->conf->iface, hapd);
96 static void hostapd_reload_bss(struct hostapd_data *hapd)
100 if (!hapd->started)
103 if (hapd->conf->wmm_enabled < 0)
104 hapd->conf->wmm_enabled = hapd->iconf->ieee80211n;
107 radius_client_reconfig(hapd->radius, hapd->conf->radius);
110 ssid = &hapd->conf->ssid;
117 hostapd_config_clear_wpa_psk(&hapd->conf->ssid.wpa_psk);
119 if (hostapd_setup_wpa_psk(hapd->conf)) {
124 if (hapd->conf->ieee802_1x || hapd->conf->wpa)
125 hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 1);
127 hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 0);
129 if ((hapd->conf->wpa || hapd->conf->osen) && hapd->wpa_auth == NULL) {
130 hostapd_setup_wpa(hapd);
131 if (hapd->wpa_auth)
132 wpa_init_keys(hapd->wpa_auth);
133 } else if (hapd->conf->wpa) {
136 hostapd_reconfig_wpa(hapd);
137 wpa_ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &wpa_ie_len);
138 if (hostapd_set_generic_elem(hapd, wpa_ie, wpa_ie_len))
141 } else if (hapd->wpa_auth) {
142 wpa_deinit(hapd->wpa_auth);
143 hapd->wpa_auth = NULL;
144 hostapd_set_privacy(hapd, 0);
145 hostapd_setup_encryption(hapd->conf->iface, hapd);
146 hostapd_set_generic_elem(hapd, (u8 *) "", 0);
149 ieee802_11_set_beacon(hapd);
150 hostapd_update_wps(hapd);
152 if (hapd->conf->ssid.ssid_set &&
153 hostapd_set_ssid(hapd, hapd->conf->ssid.ssid,
154 hapd->conf->ssid.ssid_len)) {
158 wpa_printf(MSG_DEBUG, "Reconfigured interface %s", hapd->conf->iface);
205 struct hostapd_data *hapd = iface->bss[0];
226 oldconf = hapd->iconf;
238 hostapd_remove_iface(interfaces, hapd->conf->iface);
259 hapd = iface->bss[j];
260 hapd->iconf = newconf;
261 hapd->iconf->channel = oldconf->channel;
262 hapd->iconf->acs = oldconf->acs;
263 hapd->iconf->secondary_channel = oldconf->secondary_channel;
264 hapd->iconf->ieee80211n = oldconf->ieee80211n;
265 hapd->iconf->ieee80211ac = oldconf->ieee80211ac;
266 hapd->iconf->ht_capab = oldconf->ht_capab;
267 hapd->iconf->vht_capab = oldconf->vht_capab;
268 hostapd_set_oper_chwidth(hapd->iconf,
271 hapd->iconf,
274 hapd->iconf,
276 hapd->conf = newconf->bss[j];
277 hostapd_reload_bss(hapd);
287 static void hostapd_broadcast_key_clear_iface(struct hostapd_data *hapd,
292 if (!ifname || !hapd->drv_priv)
295 if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i,
303 if (hapd->conf->ieee80211w) {
305 if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE,
318 static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd)
320 hostapd_broadcast_key_clear_iface(hapd, hapd->conf->iface);
325 static int hostapd_broadcast_wep_set(struct hostapd_data *hapd)
328 struct hostapd_ssid *ssid = &hapd->conf->ssid;
332 hostapd_drv_set_key(hapd->conf->iface,
333 hapd, WPA_ALG_WEP, broadcast_ether_addr, idx,
344 static void hostapd_free_hapd_data(struct hostapd_data *hapd)
346 os_free(hapd->probereq_cb);
347 hapd->probereq_cb = NULL;
348 hapd->num_probereq_cb = 0;
351 wpabuf_free(hapd->p2p_beacon_ie);
352 hapd->p2p_beacon_ie = NULL;
353 wpabuf_free(hapd->p2p_probe_resp_ie);
354 hapd->p2p_probe_resp_ie = NULL;
357 if (!hapd->started) {
359 __func__, hapd->conf ? hapd->conf->iface : "N/A");
362 hapd->started = 0;
363 hapd->beacon_set_done = 0;
365 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
366 iapp_deinit(hapd->iapp);
367 hapd->iapp = NULL;
368 accounting_deinit(hapd);
369 hostapd_deinit_wpa(hapd);
370 vlan_deinit(hapd);
371 hostapd_acl_deinit(hapd);
373 radius_client_deinit(hapd->radius);
374 hapd->radius = NULL;
375 radius_das_deinit(hapd->radius_das);
376 hapd->radius_das = NULL;
379 hostapd_deinit_wps(hapd);
380 ieee802_1x_dealloc_kay_sm_hapd(hapd);
382 hostapd_dpp_deinit(hapd);
383 gas_query_ap_deinit(hapd->gas);
386 authsrv_deinit(hapd);
388 if (hapd->interface_added) {
389 hapd->interface_added = 0;
390 if (hostapd_if_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface)) {
393 hapd->conf->iface);
394 hapd->interface_added = 1;
399 * and hapd->drv_priv is not valid anymore.
401 hapd->drv_priv = NULL;
405 wpabuf_free(hapd->time_adv);
408 gas_serv_deinit(hapd);
411 bss_load_update_deinit(hapd);
412 ndisc_snoop_deinit(hapd);
413 dhcp_snoop_deinit(hapd);
414 x_snoop_deinit(hapd);
417 bin_clear_free(hapd->tmp_eap_user.identity,
418 hapd->tmp_eap_user.identity_len);
419 bin_clear_free(hapd->tmp_eap_user.password,
420 hapd->tmp_eap_user.password_len);
424 wpabuf_free(hapd->mesh_pending_auth);
425 hapd->mesh_pending_auth = NULL;
428 hostapd_clean_rrm(hapd);
429 fils_hlp_deinit(hapd);
435 while ((q = dl_list_first(&hapd->sae_commit_queue,
442 eloop_cancel_timeout(auth_sae_process_commit, hapd, NULL);
449 * @hapd: Pointer to BSS data
455 static void hostapd_cleanup(struct hostapd_data *hapd)
457 wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s))", __func__, hapd,
458 hapd->conf ? hapd->conf->iface : "N/A");
459 if (hapd->iface->interfaces &&
460 hapd->iface->interfaces->ctrl_iface_deinit) {
461 wpa_msg(hapd->msg_ctx, MSG_INFO, WPA_EVENT_TERMINATING);
462 hapd->iface->interfaces->ctrl_iface_deinit(hapd);
464 hostapd_free_hapd_data(hapd);
532 static void hostapd_clear_wep(struct hostapd_data *hapd)
534 if (hapd->drv_priv && !hapd->iface->driver_ap_teardown && hapd->conf) {
535 hostapd_set_privacy(hapd, 0);
536 hostapd_broadcast_wep_clear(hapd);
541 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd)
545 hostapd_broadcast_wep_set(hapd);
547 if (hapd->conf->ssid.wep.default_len) {
548 hostapd_set_privacy(hapd, 1);
556 hostapd_drv_set_authmode(hapd, hapd->conf->auth_algs);
559 if (hapd->conf->ssid.wep.key[i] &&
560 hostapd_drv_set_key(iface, hapd, WPA_ALG_WEP, NULL, i,
561 i == hapd->conf->ssid.wep.idx, NULL, 0,
562 hapd->conf->ssid.wep.key[i],
563 hapd->conf->ssid.wep.len[i])) {
568 if (hapd->conf->ssid.wep.key[i] &&
569 i == hapd->conf->ssid.wep.idx)
570 hostapd_set_privacy(hapd, 1);
577 static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason)
582 if (hostapd_drv_none(hapd) || hapd->drv_priv == NULL)
585 if (!hapd->iface->driver_ap_teardown) {
586 wpa_dbg(hapd->msg_ctx, MSG_DEBUG,
589 if (hostapd_flush(hapd)) {
590 wpa_msg(hapd->msg_ctx, MSG_WARNING,
595 if (hapd->conf && hapd->conf->broadcast_deauth) {
596 wpa_dbg(hapd->msg_ctx, MSG_DEBUG,
599 hostapd_drv_sta_deauth(hapd, addr, reason);
601 hostapd_free_stas(hapd);
607 static void hostapd_bss_deinit_no_free(struct hostapd_data *hapd)
609 hostapd_free_stas(hapd);
610 hostapd_flush_old_stations(hapd, WLAN_REASON_DEAUTH_LEAVING);
611 hostapd_clear_wep(hapd);
625 struct hostapd_data *hapd = iface->bss[0];
629 if (hostapd_drv_none(hapd))
653 hapd->own_addr[i];
699 if ((hapd->own_addr[i] & mask[i]) != hapd->own_addr[i]) {
702 MAC2STR(mask), MAC2STR(hapd->own_addr));
730 static int hostapd_das_nas_mismatch(struct hostapd_data *hapd,
734 (!hapd->conf->nas_identifier ||
735 os_strlen(hapd->conf->nas_identifier) !=
737 os_memcmp(hapd->conf->nas_identifier, attr->nas_identifier,
744 (hapd->conf->own_ip_addr.af != AF_INET ||
745 os_memcmp(&hapd->conf->own_ip_addr.u.v4, attr->nas_ip_addr, 4) !=
753 (hapd->conf->own_ip_addr.af != AF_INET6 ||
754 os_memcmp(&hapd->conf->own_ip_addr.u.v6, attr->nas_ipv6_addr, 16)
765 static struct sta_info * hostapd_das_find_sta(struct hostapd_data *hapd,
776 for (sta = hapd->sta_list; sta; sta = sta->next)
781 sta = ap_get_sta(hapd, attr->sta_addr);
789 for (sta = hapd->sta_list; sta; sta = sta->next) {
805 for (sta = hapd->sta_list; sta; sta = sta->next) {
833 for (sta = hapd->sta_list; sta; sta = sta->next) {
864 for (sta = hapd->sta_list; sta; sta = sta->next) {
891 for (sta = hapd->sta_list; sta; sta = sta->next) {
929 for (sta = hapd->sta_list; sta; sta = sta->next) {
943 static int hostapd_das_disconnect_pmksa(struct hostapd_data *hapd,
946 if (!hapd->wpa_auth)
948 return wpa_auth_radius_das_disconnect_pmksa(hapd->wpa_auth, attr);
955 struct hostapd_data *hapd = ctx;
959 if (hostapd_das_nas_mismatch(hapd, attr))
962 sta = hostapd_das_find_sta(hapd, attr, &multi);
969 if (hostapd_das_disconnect_pmksa(hapd, attr) == 0) {
980 wpa_auth_pmksa_remove(hapd->wpa_auth, sta->addr);
982 hostapd_drv_sta_deauth(hapd, sta->addr,
984 ap_sta_deauthenticate(hapd, sta, WLAN_REASON_PREV_AUTH_NOT_VALID);
994 struct hostapd_data *hapd = ctx;
998 if (hostapd_das_nas_mismatch(hapd, attr))
1001 sta = hostapd_das_find_sta(hapd, attr, &multi);
1022 hs20_t_c_filtering(hapd, sta, 0);
1073 * @hapd: Pointer to BSS data
1082 static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
1084 struct hostapd_bss_config *conf = hapd->conf;
1091 wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s), first=%d)",
1092 __func__, hapd, conf->iface, first);
1101 if (hapd->started) {
1106 hapd->started = 1;
1109 u8 *addr = hapd->own_addr;
1113 os_memcpy(hapd->own_addr, conf->bssid, ETH_ALEN);
1115 if (hostapd_mac_comp(hapd->own_addr,
1116 hapd->iface->bss[0]->own_addr) ==
1123 } else if (hapd->iconf->use_driver_iface_addr) {
1128 inc_byte_array(hapd->own_addr, ETH_ALEN);
1129 } while (mac_in_conf(hapd->iconf, hapd->own_addr));
1132 hapd->interface_added = 1;
1133 if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS,
1134 conf->iface, addr, hapd,
1135 &hapd->drv_priv, force_ifname, if_addr,
1139 MACSTR ")", MAC2STR(hapd->own_addr));
1140 hapd->interface_added = 0;
1145 os_memcpy(hapd->own_addr, if_addr, ETH_ALEN);
1149 conf->wmm_enabled = hapd->iconf->ieee80211n;
1153 os_memcpy(conf->r1_key_holder, hapd->own_addr, ETH_ALEN);
1157 if ((hapd->conf->mesh & MESH_ENABLED) && hapd->iface->mconf == NULL)
1162 hostapd_flush_old_stations(hapd,
1164 hostapd_set_privacy(hapd, 0);
1166 hostapd_broadcast_wep_clear(hapd);
1167 if (hostapd_setup_encryption(conf->iface, hapd))
1175 ssid_len = hostapd_get_ssid(hapd, ssid, sizeof(ssid));
1198 if (!hostapd_drv_none(hapd)) {
1201 conf->iface, MAC2DBGSTR(hapd->own_addr),
1212 if (set_ssid && hostapd_set_ssid(hapd, conf->ssid.ssid,
1225 &hapd->rad_attr_db)) {
1233 if (!db_table_exists(hapd->rad_attr_db, "radius_attributes") &&
1234 db_table_create_radius_attributes(hapd->rad_attr_db) < 0)
1239 hapd->radius = radius_client_init(hapd, conf->radius);
1240 if (hapd->radius == NULL) {
1258 das_conf.ctx = hapd;
1261 hapd->radius_das = radius_das_init(&das_conf);
1262 if (hapd->radius_das == NULL) {
1270 if (hostapd_acl_init(hapd)) {
1274 if (hostapd_init_wps(hapd, conf))
1278 hapd->gas = gas_query_ap_init(hapd, hapd->msg_ctx);
1279 if (!hapd->gas)
1281 if (hostapd_dpp_init(hapd))
1285 if (authsrv_init(hapd) < 0)
1288 if (ieee802_1x_init(hapd)) {
1293 if ((conf->wpa || conf->osen) && hostapd_setup_wpa(hapd))
1296 if (accounting_init(hapd)) {
1302 (hapd->iapp = iapp_init(hapd, conf->iapp_iface)) == NULL) {
1309 if (gas_serv_init(hapd)) {
1315 hostapd_drv_set_qos_map(hapd, conf->qos_map_set,
1322 if (conf->bss_load_update_period && bss_load_update_init(hapd)) {
1328 if (x_snoop_init(hapd)) {
1334 if (dhcp_snoop_init(hapd)) {
1340 if (ndisc_snoop_init(hapd)) {
1347 if (!hostapd_drv_none(hapd) && vlan_init(hapd)) {
1352 if (!conf->start_disabled && ieee802_11_set_beacon(hapd) < 0)
1355 if (hapd->wpa_auth && wpa_init_keys(hapd->wpa_auth) < 0)
1358 if (hapd->driver && hapd->driver->set_operstate)
1359 hapd->driver->set_operstate(hapd->drv_priv, 1);
1367 struct hostapd_data *hapd = iface->bss[0];
1372 if ((hapd->conf->mesh & MESH_ENABLED) && iface->mconf == NULL)
1379 if (hostapd_set_tx_queue_params(hapd, i, p->aifs, p->cwmin,
1389 static int hostapd_set_acl_list(struct hostapd_data *hapd,
1408 err = hostapd_drv_set_acl(hapd, acl_params);
1416 static void hostapd_set_acl(struct hostapd_data *hapd)
1418 struct hostapd_config *conf = hapd->iconf;
1422 if (hapd->iface->drv_max_acl_mac_addrs == 0)
1427 err = hostapd_set_acl_list(hapd, conf->bss[0]->accept_mac,
1436 err = hostapd_set_acl_list(hapd, conf->bss[0]->deny_mac,
1447 static int start_ctrl_iface_bss(struct hostapd_data *hapd)
1449 if (!hapd->iface->interfaces ||
1450 !hapd->iface->interfaces->ctrl_iface_init)
1453 if (hapd->iface->interfaces->ctrl_iface_init(hapd)) {
1456 hapd->conf->iface);
1472 struct hostapd_data *hapd = iface->bss[i];
1473 if (iface->interfaces->ctrl_iface_init(hapd)) {
1476 hapd->conf->iface);
1516 struct hostapd_data *hapd = iface->bss[0];
1529 const char *phy = hostapd_drv_get_radio_name(hapd);
1541 iface->bss[i]->driver = hapd->driver;
1542 iface->bss[i]->drv_priv = hapd->drv_priv;
1556 if (hapd->iconf->country[0] && hapd->iconf->country[1]) {
1560 if (hostapd_get_country(hapd, previous_country) < 0)
1563 os_memcpy(country, hapd->iconf->country, 3);
1565 if (hostapd_set_country(hapd, country) < 0) {
1632 struct hostapd_data *hapd = ctx;
1634 return hapd->own_addr;
1642 struct hostapd_data *hapd = ctx;
1644 *hw_mode = ieee80211_freq_to_chan(hapd->iface->freq, channel);
1650 struct hostapd_data *hapd = ctx;
1652 if (hapd->iface->fst_ies != fst_ies) {
1653 hapd->iface->fst_ies = fst_ies;
1654 if (ieee802_11_set_beacon(hapd))
1663 struct hostapd_data *hapd = ctx;
1665 return hostapd_drv_send_action(hapd, hapd->iface->freq, 0, da,
1672 struct hostapd_data *hapd = ctx;
1673 struct sta_info *sta = ap_get_sta(hapd, addr);
1682 struct hostapd_data *hapd = ctx;
1683 struct sta_info *sta = ap_get_sta(hapd, addr);
1721 struct hostapd_data *hapd = ctx;
1723 *get_ctx = (struct fst_get_peer_ctx *) hapd->sta_list;
1737 void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd,
1740 iface_obj->ctx = hapd;
1757 struct hostapd_data *hapd = ctx;
1763 if (os_strcmp(hapd->conf->owe_transition_ifname,
1770 hapd->conf->iface, bss->conf->iface,
1778 os_memcpy(hapd->conf->owe_transition_bssid, bss->own_addr,
1780 os_memcpy(hapd->conf->owe_transition_ssid,
1782 hapd->conf->owe_transition_ssid_len = bss->conf->ssid.ssid_len;
1792 int hostapd_owe_trans_get_info(struct hostapd_data *hapd)
1794 if (hapd->conf->owe_transition_ssid_len > 0 &&
1795 !is_zero_ether_addr(hapd->conf->owe_transition_bssid))
1800 if (!hapd->iface->interfaces ||
1801 !hapd->iface->interfaces->for_each_interface)
1802 return hostapd_owe_iface_iter(hapd->iface, hapd);
1804 return hapd->iface->interfaces->for_each_interface(
1805 hapd->iface->interfaces, hostapd_owe_iface_iter, hapd);
1853 struct hostapd_data *hapd;
1857 hapd = iface->bss[0];
1858 if (hapd->setup_complete_cb)
1859 hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
1866 struct hostapd_data *hapd = iface->bss[0];
1881 iface->freq = hostapd_hw_get_freq(hapd, iface->conf->channel);
1927 hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq,
1928 hapd->iconf->channel,
1929 hapd->iconf->ieee80211n,
1930 hapd->iconf->ieee80211ac,
1931 hapd->iconf->ieee80211ax,
1932 hapd->iconf->secondary_channel,
1933 hostapd_get_oper_chwidth(hapd->iconf),
1935 hapd->iconf),
1937 hapd->iconf))) {
1948 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
1955 if (hapd->iconf->rts_threshold >= -1 &&
1956 hostapd_set_rts(hapd, hapd->iconf->rts_threshold) &&
1957 hapd->iconf->rts_threshold >= -1) {
1963 if (hapd->iconf->fragm_threshold >= -1 &&
1964 hostapd_set_frag(hapd, hapd->iconf->fragm_threshold) &&
1965 hapd->iconf->fragm_threshold != -1) {
1971 prev_addr = hapd->own_addr;
1974 hapd = iface->bss[j];
1976 os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
1977 if (hostapd_setup_bss(hapd, j == 0)) {
1979 hapd = iface->bss[j];
1980 hostapd_bss_deinit_no_free(hapd);
1981 hostapd_free_hapd_data(hapd);
1988 if (is_zero_ether_addr(hapd->conf->bssid))
1989 prev_addr = hapd->own_addr;
1991 hapd = iface->bss[0];
1997 hostapd_set_acl(hapd);
1999 if (hostapd_driver_commit(hapd) < 0) {
2031 if (hapd->iconf->fst_cfg.group_id[0]) {
2034 fst_hostapd_fill_iface_obj(hapd, &iface_obj);
2035 iface->fst = fst_attach(hapd->conf->iface, hapd->own_addr,
2036 &iface_obj, &hapd->iconf->fst_cfg);
2039 hapd->iconf->fst_cfg.group_id);
2049 if (hapd->setup_complete_cb)
2050 hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
2065 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
2075 } else if (hapd->setup_complete_cb) {
2077 * Calling hapd->setup_complete_cb directly may cause iface
2100 struct hostapd_data *hapd = iface->bss[0];
2111 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
2219 struct hostapd_data *hapd;
2221 hapd = os_zalloc(sizeof(*hapd));
2222 if (hapd == NULL)
2225 hapd->new_assoc_sta_cb = hostapd_new_assoc_sta;
2226 hapd->iconf = conf;
2227 hapd->conf = bss;
2228 hapd->iface = hapd_iface;
2230 hapd->driver = conf->driver;
2231 hapd->ctrl_sock = -1;
2232 dl_list_init(&hapd->ctrl_dst);
2233 dl_list_init(&hapd->nr_db);
2234 hapd->dhcp_sock = -1;
2236 dl_list_init(&hapd->l2_queue);
2237 dl_list_init(&hapd->l2_oui_queue);
2240 dl_list_init(&hapd->sae_commit_queue);
2243 return hapd;
2247 static void hostapd_bss_deinit(struct hostapd_data *hapd)
2249 if (!hapd)
2252 hapd->conf ? hapd->conf->iface : "N/A");
2253 hostapd_bss_deinit_no_free(hapd);
2254 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED);
2256 if (hapd->rad_attr_db) {
2257 sqlite3_close(hapd->rad_attr_db);
2258 hapd->rad_attr_db = NULL;
2261 hostapd_cleanup(hapd);
2307 wpa_printf(MSG_DEBUG, "%s: free hapd %p",
2343 struct hostapd_data *hapd;
2366 hapd = hapd_iface->bss[i] =
2369 if (hapd == NULL)
2371 hapd->msg_ctx = hapd;
2399 struct hostapd_data *hapd = iface->bss[j];
2400 if (os_strcmp(ifname, hapd->conf->iface) == 0)
2425 struct hostapd_data *hapd;
2484 hapd = hostapd_alloc_bss_data(iface, iface->conf, bss);
2485 if (hapd == NULL) {
2491 iface->bss[iface->num_bss] = hapd;
2492 hapd->msg_ctx = hapd;
2661 struct hostapd_data *hapd = hapd_iface->bss[j];
2662 hostapd_bss_deinit_no_free(hapd);
2663 hostapd_free_hapd_data(hapd);
2763 struct hostapd_data *hapd;
2771 hapd = hapd_iface->bss[i] =
2773 if (hapd == NULL) {
2783 hapd->msg_ctx = hapd;
2797 struct hostapd_data *hapd;
2848 hapd = hapd_iface->bss[hapd_iface->num_bss - 1];
2849 hapd->driver = hapd_iface->bss[0]->driver;
2850 hapd->drv_priv = hapd_iface->bss[0]->drv_priv;
2851 os_memcpy(hapd->own_addr, hapd_iface->bss[0]->own_addr,
2854 if (start_ctrl_iface_bss(hapd) < 0 ||
2856 hostapd_setup_bss(hapd, -1))) {
2857 hostapd_cleanup(hapd);
2861 wpa_printf(MSG_DEBUG, "%s: free hapd %p %s",
2862 __func__, hapd, hapd->conf->iface);
2863 hostapd_config_free_bss(hapd->conf);
2864 hapd->conf = NULL;
2865 os_free(hapd);
2938 hapd = hapd_iface->bss[i];
2939 if (!hapd)
2944 ctrl_iface_deinit(hapd);
2945 wpa_printf(MSG_DEBUG, "%s: free hapd %p (%s)",
2947 hapd->conf->iface);
2948 hostapd_cleanup(hapd);
2949 os_free(hapd);
2973 struct hostapd_data *hapd = iface->bss[idx];
2975 hostapd_bss_deinit(hapd);
2976 wpa_printf(MSG_DEBUG, "%s: free hapd %p (%s)",
2977 __func__, hapd, hapd->conf->iface);
2978 hostapd_config_free_bss(hapd->conf);
2979 hapd->conf = NULL;
2980 os_free(hapd);
3040 * @hapd: Pointer to BSS data
3049 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
3052 if (hapd->tkip_countermeasures) {
3053 hostapd_drv_sta_deauth(hapd, sta->addr,
3058 hostapd_prune_associations(hapd, sta->addr);
3059 ap_sta_clear_disconnect_timeouts(hapd, sta);
3062 if (hapd->conf->ieee802_11f)
3063 iapp_new_station(hapd->iapp, sta);
3068 hapd->num_sta_no_p2p++;
3069 if (hapd->num_sta_no_p2p == 1)
3070 hostapd_p2p_non_p2p_sta_connected(hapd);
3074 airtime_policy_new_sta(hapd, sta);
3079 if (!hapd->conf->ieee802_1x && !hapd->conf->wpa && !hapd->conf->osen) {
3080 ap_sta_set_authorized(hapd, sta, 1);
3082 accounting_sta_start(hapd, sta);
3086 ieee802_1x_new_station(hapd, sta);
3095 wpa_auth_sta_associated(hapd->wpa_auth, sta->wpa_sm);
3097 if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_WIRED) {
3098 if (eloop_cancel_timeout(ap_handle_timer, hapd, sta) > 0) {
3102 hapd->conf->iface, __func__,
3105 } else if (!(hapd->iface->drv_flags &
3110 hapd->conf->iface, __func__, MAC2STR(sta->addr),
3111 hapd->conf->ap_max_inactivity);
3112 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
3113 eloop_register_timeout(hapd->conf->ap_max_inactivity, 0,
3114 ap_handle_timer, hapd, sta);
3118 if (hapd->conf->wpa_key_mgmt == WPA_KEY_MGMT_NONE &&
3119 hapd->conf->mka_psk_set)
3120 ieee802_1x_create_preshared_mka_hapd(hapd, sta);
3122 ieee802_1x_alloc_kay_sm_hapd(hapd, sta);
3189 static int hostapd_build_beacon_data(struct hostapd_data *hapd,
3197 ret = ieee802_11_build_ap_params(hapd, &params);
3201 ret = hostapd_build_ap_extra_ies(hapd, &beacon_extra,
3264 hostapd_free_ap_extra_ies(hapd, beacon_extra, proberesp_extra,
3277 static int hostapd_change_config_freq(struct hostapd_data *hapd,
3288 params->channel = hostapd_hw_get_channel(hapd, params->freq);
3295 mode = hapd->iface->current_mode;
3300 hostapd_hw_get_freq(hapd, conf->channel),
3347 static int hostapd_fill_csa_settings(struct hostapd_data *hapd,
3350 struct hostapd_iface *iface = hapd->iface;
3356 if (!iface || !iface->freq || hapd->csa_in_progress)
3378 &hapd->iface->cs_oper_class,
3397 ret = hostapd_build_beacon_data(hapd, &settings->beacon_after);
3407 hapd->cs_freq_params = settings->freq_params;
3408 hapd->cs_count = settings->cs_count;
3409 hapd->cs_block_tx = settings->block_tx;
3411 ret = hostapd_build_beacon_data(hapd, &settings->beacon_csa);
3417 settings->counter_offset_beacon[0] = hapd->cs_c_off_beacon;
3418 settings->counter_offset_presp[0] = hapd->cs_c_off_proberesp;
3419 settings->counter_offset_beacon[1] = hapd->cs_c_off_ecsa_beacon;
3420 settings->counter_offset_presp[1] = hapd->cs_c_off_ecsa_proberesp;
3426 void hostapd_cleanup_cs_params(struct hostapd_data *hapd)
3428 os_memset(&hapd->cs_freq_params, 0, sizeof(hapd->cs_freq_params));
3429 hapd->cs_count = 0;
3430 hapd->cs_block_tx = 0;
3431 hapd->cs_c_off_beacon = 0;
3432 hapd->cs_c_off_proberesp = 0;
3433 hapd->csa_in_progress = 0;
3434 hapd->cs_c_off_ecsa_beacon = 0;
3435 hapd->cs_c_off_ecsa_proberesp = 0;
3439 void hostapd_chan_switch_vht_config(struct hostapd_data *hapd, int vht_enabled)
3442 hapd->iconf->ch_switch_vht_config |= CH_SWITCH_VHT_ENABLED;
3444 hapd->iconf->ch_switch_vht_config |= CH_SWITCH_VHT_DISABLED;
3446 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
3448 hapd->iconf->ch_switch_vht_config);
3452 int hostapd_switch_channel(struct hostapd_data *hapd,
3457 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) {
3462 ret = hostapd_fill_csa_settings(hapd, settings);
3466 ret = hostapd_drv_switch_channel(hapd, settings);
3472 hostapd_cleanup_cs_params(hapd);
3476 hapd->csa_in_progress = 1;
3546 struct hostapd_data *hapd = iface->bss[j];
3548 if (os_strcmp(ifname, hapd->conf->iface) == 0)
3549 return hapd;
3564 struct hostapd_data *hapd = iface->bss[i];
3566 if (!hapd->started)
3570 hostapd_acl_expire(hapd);