2 * hostapd / Initialization and configuration
3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
19 #include "ieee802_1x.h"
21 #include "hw_features.h"
22 #include "accounting.h"
25 #include "ieee802_11_defs.h"
26 #include "ieee802_11_auth.h"
30 #include "radius/radius_client.h"
31 #include "radius/radius_server.h"
34 #include "vlan_init.h"
35 #include "ctrl_iface.h"
37 #include "eap_server/eap_sim_db.h"
38 #include "eap_server/eap.h"
39 #include "eap_server/tncs.h"
41 #include "l2_packet/l2_packet.h"
42 #include "wps_hostapd.h"
43 #include "tkip_countermeasures.h"
46 static int hostapd_radius_get_eap_user(void *ctx, const u8 *identity,
47 size_t identity_len, int phase2,
48 struct eap_user *user);
49 static int hostapd_flush_old_stations(struct hostapd_data *hapd);
50 static int hostapd_setup_wpa(struct hostapd_data *hapd);
51 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd);
53 extern int wpa_debug_level;
57 static int hostapd_sim_db_cb_sta(struct hostapd_data *hapd,
58 struct sta_info *sta, void *ctx)
60 if (eapol_auth_eap_pending_cb(sta->eapol_sm, ctx) == 0)
66 static void hostapd_sim_db_cb(void *ctx, void *session_ctx)
68 struct hostapd_data *hapd = ctx;
69 if (ap_for_each_sta(hapd, hostapd_sim_db_cb_sta, session_ctx) == 0)
70 radius_server_eap_pending_cb(hapd->radius_srv, session_ctx);
72 #endif /* EAP_SERVER */
75 static void hostapd_wpa_auth_conf(struct hostapd_bss_config *conf,
76 struct wpa_auth_config *wconf)
78 wconf->wpa = conf->wpa;
79 wconf->wpa_key_mgmt = conf->wpa_key_mgmt;
80 wconf->wpa_pairwise = conf->wpa_pairwise;
81 wconf->wpa_group = conf->wpa_group;
82 wconf->wpa_group_rekey = conf->wpa_group_rekey;
83 wconf->wpa_strict_rekey = conf->wpa_strict_rekey;
84 wconf->wpa_gmk_rekey = conf->wpa_gmk_rekey;
85 wconf->wpa_ptk_rekey = conf->wpa_ptk_rekey;
86 wconf->rsn_pairwise = conf->rsn_pairwise;
87 wconf->rsn_preauth = conf->rsn_preauth;
88 wconf->eapol_version = conf->eapol_version;
89 wconf->peerkey = conf->peerkey;
90 wconf->wmm_enabled = conf->wmm_enabled;
91 wconf->okc = conf->okc;
92 #ifdef CONFIG_IEEE80211W
93 wconf->ieee80211w = conf->ieee80211w;
94 #endif /* CONFIG_IEEE80211W */
95 #ifdef CONFIG_IEEE80211R
96 wconf->ssid_len = conf->ssid.ssid_len;
97 if (wconf->ssid_len > SSID_LEN)
98 wconf->ssid_len = SSID_LEN;
99 os_memcpy(wconf->ssid, conf->ssid.ssid, wconf->ssid_len);
100 os_memcpy(wconf->mobility_domain, conf->mobility_domain,
101 MOBILITY_DOMAIN_ID_LEN);
102 if (conf->nas_identifier &&
103 os_strlen(conf->nas_identifier) <= FT_R0KH_ID_MAX_LEN) {
104 wconf->r0_key_holder_len = os_strlen(conf->nas_identifier);
105 os_memcpy(wconf->r0_key_holder, conf->nas_identifier,
106 wconf->r0_key_holder_len);
108 os_memcpy(wconf->r1_key_holder, conf->r1_key_holder, FT_R1KH_ID_LEN);
109 wconf->r0_key_lifetime = conf->r0_key_lifetime;
110 wconf->reassociation_deadline = conf->reassociation_deadline;
111 wconf->r0kh_list = conf->r0kh_list;
112 wconf->r1kh_list = conf->r1kh_list;
113 wconf->pmk_r1_push = conf->pmk_r1_push;
114 #endif /* CONFIG_IEEE80211R */
118 int hostapd_reload_config(struct hostapd_iface *iface)
120 struct hostapd_data *hapd = iface->bss[0];
121 struct hostapd_config *newconf, *oldconf;
122 struct wpa_auth_config wpa_auth_conf;
124 newconf = hostapd_config_read(iface->config_fname);
129 * Deauthenticate all stations since the new configuration may not
130 * allow them to use the BSS anymore.
132 hostapd_flush_old_stations(hapd);
134 /* TODO: update dynamic data based on changed configuration
135 * items (e.g., open/close sockets, etc.) */
136 radius_client_flush(hapd->radius, 0);
138 oldconf = hapd->iconf;
139 hapd->iconf = newconf;
140 hapd->conf = &newconf->bss[0];
141 iface->conf = newconf;
143 if (hostapd_setup_wpa_psk(hapd->conf)) {
144 wpa_printf(MSG_ERROR, "Failed to re-configure WPA PSK "
145 "after reloading configuration");
148 if (hapd->conf->wpa && hapd->wpa_auth == NULL)
149 hostapd_setup_wpa(hapd);
150 else if (hapd->conf->wpa) {
151 hostapd_wpa_auth_conf(&newconf->bss[0], &wpa_auth_conf);
152 wpa_reconfig(hapd->wpa_auth, &wpa_auth_conf);
153 } else if (hapd->wpa_auth) {
154 wpa_deinit(hapd->wpa_auth);
155 hapd->wpa_auth = NULL;
156 hostapd_set_privacy(hapd, 0);
157 hostapd_setup_encryption(hapd->conf->iface, hapd);
160 ieee802_11_set_beacon(hapd);
162 if (hapd->conf->ssid.ssid_set &&
163 hostapd_set_ssid(hapd, (u8 *) hapd->conf->ssid.ssid,
164 hapd->conf->ssid.ssid_len)) {
165 wpa_printf(MSG_ERROR, "Could not set SSID for kernel driver");
166 /* try to continue */
169 if (hapd->conf->ieee802_1x || hapd->conf->wpa)
170 hostapd_set_ieee8021x(hapd->conf->iface, hapd, 1);
172 hostapd_config_free(oldconf);
174 wpa_printf(MSG_DEBUG, "Reconfigured interface %s", hapd->conf->iface);
180 int handle_reload_iface(struct hostapd_iface *iface, void *ctx)
182 if (hostapd_reload_config(iface) < 0) {
183 wpa_printf(MSG_WARNING, "Failed to read new configuration "
184 "file - continuing with old.");
190 #ifdef HOSTAPD_DUMP_STATE
192 * hostapd_dump_state - SIGUSR1 handler to dump hostapd state to a text file
194 static void hostapd_dump_state(struct hostapd_data *hapd)
198 struct sta_info *sta;
202 if (!hapd->conf->dump_log_name) {
203 wpa_printf(MSG_DEBUG, "Dump file not defined - ignoring dump "
208 wpa_printf(MSG_DEBUG, "Dumping hostapd state to '%s'",
209 hapd->conf->dump_log_name);
210 f = fopen(hapd->conf->dump_log_name, "w");
212 wpa_printf(MSG_WARNING, "Could not open dump file '%s' for "
213 "writing.", hapd->conf->dump_log_name);
218 fprintf(f, "hostapd state dump - %s", ctime(&now));
219 fprintf(f, "num_sta=%d num_sta_non_erp=%d "
220 "num_sta_no_short_slot_time=%d\n"
221 "num_sta_no_short_preamble=%d\n",
222 hapd->num_sta, hapd->iface->num_sta_non_erp,
223 hapd->iface->num_sta_no_short_slot_time,
224 hapd->iface->num_sta_no_short_preamble);
226 for (sta = hapd->sta_list; sta != NULL; sta = sta->next) {
227 fprintf(f, "\nSTA=" MACSTR "\n", MAC2STR(sta->addr));
230 " AID=%d flags=0x%x %s%s%s%s%s%s%s%s%s%s%s%s%s%s\n"
231 " capability=0x%x listen_interval=%d\n",
234 (sta->flags & WLAN_STA_AUTH ? "[AUTH]" : ""),
235 (sta->flags & WLAN_STA_ASSOC ? "[ASSOC]" : ""),
236 (sta->flags & WLAN_STA_PS ? "[PS]" : ""),
237 (sta->flags & WLAN_STA_TIM ? "[TIM]" : ""),
238 (sta->flags & WLAN_STA_PERM ? "[PERM]" : ""),
239 (sta->flags & WLAN_STA_AUTHORIZED ? "[AUTHORIZED]" :
241 (sta->flags & WLAN_STA_PENDING_POLL ? "[PENDING_POLL" :
243 (sta->flags & WLAN_STA_SHORT_PREAMBLE ?
244 "[SHORT_PREAMBLE]" : ""),
245 (sta->flags & WLAN_STA_PREAUTH ? "[PREAUTH]" : ""),
246 (sta->flags & WLAN_STA_WMM ? "[WMM]" : ""),
247 (sta->flags & WLAN_STA_MFP ? "[MFP]" : ""),
248 (sta->flags & WLAN_STA_WPS ? "[WPS]" : ""),
249 (sta->flags & WLAN_STA_MAYBE_WPS ? "[MAYBE_WPS]" : ""),
250 (sta->flags & WLAN_STA_NONERP ? "[NonERP]" : ""),
252 sta->listen_interval);
254 fprintf(f, " supported_rates=");
255 for (i = 0; i < sta->supported_rates_len; i++)
256 fprintf(f, "%02x ", sta->supported_rates[i]);
260 " timeout_next=%s\n",
261 (sta->timeout_next == STA_NULLFUNC ? "NULLFUNC POLL" :
262 (sta->timeout_next == STA_DISASSOC ? "DISASSOC" :
265 ieee802_1x_dump_state(f, " ", sta);
268 buf = os_malloc(4096);
270 int count = radius_client_get_mib(hapd->radius, buf, 4096);
273 else if (count > 4095)
276 fprintf(f, "%s", buf);
278 count = radius_server_get_mib(hapd->radius_srv, buf, 4096);
281 else if (count > 4095)
284 fprintf(f, "%s", buf);
291 int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx)
295 for (i = 0; i < iface->num_bss; i++)
296 hostapd_dump_state(iface->bss[i]);
300 #endif /* HOSTAPD_DUMP_STATE */
303 static void hostapd_broadcast_key_clear_iface(struct hostapd_data *hapd,
308 for (i = 0; i < NUM_WEP_KEYS; i++) {
309 if (hostapd_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i,
310 i == 0 ? 1 : 0, NULL, 0, NULL, 0)) {
311 wpa_printf(MSG_DEBUG, "Failed to clear default "
312 "encryption keys (ifname=%s keyidx=%d)",
316 #ifdef CONFIG_IEEE80211W
317 if (hapd->conf->ieee80211w) {
318 for (i = NUM_WEP_KEYS; i < NUM_WEP_KEYS + 2; i++) {
319 if (hostapd_set_key(ifname, hapd, WPA_ALG_NONE, NULL,
320 i, i == 0 ? 1 : 0, NULL, 0,
322 wpa_printf(MSG_DEBUG, "Failed to clear "
323 "default mgmt encryption keys "
324 "(ifname=%s keyidx=%d)", ifname, i);
328 #endif /* CONFIG_IEEE80211W */
332 static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd)
334 hostapd_broadcast_key_clear_iface(hapd, hapd->conf->iface);
339 static int hostapd_broadcast_wep_set(struct hostapd_data *hapd)
342 struct hostapd_ssid *ssid = &hapd->conf->ssid;
345 if (ssid->wep.default_len &&
346 hostapd_set_key(hapd->conf->iface,
347 hapd, WPA_ALG_WEP, NULL, idx, idx == ssid->wep.idx,
348 NULL, 0, ssid->wep.key[idx], ssid->wep.len[idx])) {
349 wpa_printf(MSG_WARNING, "Could not set WEP encryption.");
353 if (ssid->dyn_vlan_keys) {
355 for (i = 0; i <= ssid->max_dyn_vlan_keys; i++) {
357 struct hostapd_wep_keys *key = ssid->dyn_vlan_keys[i];
360 ifname = hostapd_get_vlan_id_ifname(hapd->conf->vlan,
366 if (hostapd_set_key(ifname, hapd, WPA_ALG_WEP, NULL,
367 idx, idx == key->idx, NULL, 0,
368 key->key[idx], key->len[idx])) {
369 wpa_printf(MSG_WARNING, "Could not set "
370 "dynamic VLAN WEP encryption.");
380 * hostapd_cleanup - Per-BSS cleanup (deinitialization)
381 * @hapd: Pointer to BSS data
383 * This function is used to free all per-BSS data structures and resources.
384 * This gets called in a loop for each BSS between calls to
385 * hostapd_cleanup_iface_pre() and hostapd_cleanup_iface() when an interface
386 * is deinitialized. Most of the modules that are initialized in
387 * hostapd_setup_bss() are deinitialized here.
389 static void hostapd_cleanup(struct hostapd_data *hapd)
391 hostapd_ctrl_iface_deinit(hapd);
393 os_free(hapd->default_wep_key);
394 hapd->default_wep_key = NULL;
395 iapp_deinit(hapd->iapp);
397 accounting_deinit(hapd);
398 rsn_preauth_iface_deinit(hapd);
399 if (hapd->wpa_auth) {
400 wpa_deinit(hapd->wpa_auth);
401 hapd->wpa_auth = NULL;
403 if (hostapd_set_privacy(hapd, 0)) {
404 wpa_printf(MSG_DEBUG, "Could not disable "
405 "PrivacyInvoked for interface %s",
409 if (hostapd_set_generic_elem(hapd, (u8 *) "", 0)) {
410 wpa_printf(MSG_DEBUG, "Could not remove generic "
411 "information element from interface %s",
415 ieee802_1x_deinit(hapd);
417 hostapd_acl_deinit(hapd);
418 radius_client_deinit(hapd->radius);
420 radius_server_deinit(hapd->radius_srv);
421 hapd->radius_srv = NULL;
423 #ifdef CONFIG_IEEE80211R
424 l2_packet_deinit(hapd->l2);
425 #endif /* CONFIG_IEEE80211R */
427 hostapd_deinit_wps(hapd);
429 hostapd_wireless_event_deinit(hapd);
433 tls_deinit(hapd->ssl_ctx);
434 hapd->ssl_ctx = NULL;
436 #endif /* EAP_TLS_FUNCS */
439 if (hapd->eap_sim_db_priv) {
440 eap_sim_db_deinit(hapd->eap_sim_db_priv);
441 hapd->eap_sim_db_priv = NULL;
443 #endif /* EAP_SERVER */
445 if (hapd->interface_added &&
446 hostapd_bss_remove(hapd, hapd->conf->iface)) {
447 wpa_printf(MSG_WARNING, "Failed to remove BSS interface %s",
454 * hostapd_cleanup_iface_pre - Preliminary per-interface cleanup
455 * @iface: Pointer to interface data
457 * This function is called before per-BSS data structures are deinitialized
458 * with hostapd_cleanup().
460 static void hostapd_cleanup_iface_pre(struct hostapd_iface *iface)
466 * hostapd_cleanup_iface - Complete per-interface cleanup
467 * @iface: Pointer to interface data
469 * This function is called after per-BSS data structures are deinitialized
470 * with hostapd_cleanup().
472 static void hostapd_cleanup_iface(struct hostapd_iface *iface)
474 hostapd_free_hw_features(iface->hw_features, iface->num_hw_features);
475 iface->hw_features = NULL;
476 os_free(iface->current_rates);
477 iface->current_rates = NULL;
478 ap_list_deinit(iface);
479 hostapd_config_free(iface->conf);
482 os_free(iface->config_fname);
488 static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd)
492 hostapd_broadcast_wep_set(hapd);
494 if (hapd->conf->ssid.wep.default_len)
497 for (i = 0; i < 4; i++) {
498 if (hapd->conf->ssid.wep.key[i] &&
499 hostapd_set_key(iface, hapd, WPA_ALG_WEP, NULL, i,
500 i == hapd->conf->ssid.wep.idx, NULL, 0,
501 hapd->conf->ssid.wep.key[i],
502 hapd->conf->ssid.wep.len[i])) {
503 wpa_printf(MSG_WARNING, "Could not set WEP "
507 if (hapd->conf->ssid.wep.key[i] &&
508 i == hapd->conf->ssid.wep.idx)
509 hostapd_set_privacy(hapd, 1);
516 static int hostapd_flush_old_stations(struct hostapd_data *hapd)
520 if (hostapd_drv_none(hapd))
523 wpa_printf(MSG_DEBUG, "Flushing old station entries");
524 if (hostapd_flush(hapd)) {
525 wpa_printf(MSG_WARNING, "Could not connect to kernel driver.");
528 wpa_printf(MSG_DEBUG, "Deauthenticate all stations");
530 /* New Prism2.5/3 STA firmware versions seem to have issues with this
531 * broadcast deauth frame. This gets the firmware in odd state where
532 * nothing works correctly, so let's skip sending this for the hostap
534 if (hapd->driver && os_strcmp(hapd->driver->name, "hostap") != 0) {
536 os_memset(addr, 0xff, ETH_ALEN);
537 hostapd_sta_deauth(hapd, addr,
538 WLAN_REASON_PREV_AUTH_NOT_VALID);
545 static void hostapd_wpa_auth_logger(void *ctx, const u8 *addr,
546 logger_level level, const char *txt)
548 #ifndef CONFIG_NO_HOSTAPD_LOGGER
549 struct hostapd_data *hapd = ctx;
554 hlevel = HOSTAPD_LEVEL_WARNING;
557 hlevel = HOSTAPD_LEVEL_INFO;
561 hlevel = HOSTAPD_LEVEL_DEBUG;
565 hostapd_logger(hapd, addr, HOSTAPD_MODULE_WPA, hlevel, "%s", txt);
566 #endif /* CONFIG_NO_HOSTAPD_LOGGER */
570 static void hostapd_wpa_auth_disconnect(void *ctx, const u8 *addr,
573 struct hostapd_data *hapd = ctx;
574 struct sta_info *sta;
576 wpa_printf(MSG_DEBUG, "%s: WPA authenticator requests disconnect: "
577 "STA " MACSTR " reason %d",
578 __func__, MAC2STR(addr), reason);
580 sta = ap_get_sta(hapd, addr);
581 hostapd_sta_deauth(hapd, addr, reason);
584 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_AUTHORIZED);
585 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
586 eloop_register_timeout(0, 0, ap_handle_timer, hapd, sta);
587 sta->timeout_next = STA_REMOVE;
591 static void hostapd_wpa_auth_mic_failure_report(void *ctx, const u8 *addr)
593 struct hostapd_data *hapd = ctx;
594 michael_mic_failure(hapd, addr, 0);
598 static void hostapd_wpa_auth_set_eapol(void *ctx, const u8 *addr,
599 wpa_eapol_variable var, int value)
601 struct hostapd_data *hapd = ctx;
602 struct sta_info *sta = ap_get_sta(hapd, addr);
606 case WPA_EAPOL_portEnabled:
607 ieee802_1x_notify_port_enabled(sta->eapol_sm, value);
609 case WPA_EAPOL_portValid:
610 ieee802_1x_notify_port_valid(sta->eapol_sm, value);
612 case WPA_EAPOL_authorized:
613 ieee802_1x_set_sta_authorized(hapd, sta, value);
615 case WPA_EAPOL_portControl_Auto:
617 sta->eapol_sm->portControl = Auto;
619 case WPA_EAPOL_keyRun:
621 sta->eapol_sm->keyRun = value ? TRUE : FALSE;
623 case WPA_EAPOL_keyAvailable:
625 sta->eapol_sm->eap_if->eapKeyAvailable =
626 value ? TRUE : FALSE;
628 case WPA_EAPOL_keyDone:
630 sta->eapol_sm->keyDone = value ? TRUE : FALSE;
632 case WPA_EAPOL_inc_EapolFramesTx:
634 sta->eapol_sm->dot1xAuthEapolFramesTx++;
640 static int hostapd_wpa_auth_get_eapol(void *ctx, const u8 *addr,
641 wpa_eapol_variable var)
643 struct hostapd_data *hapd = ctx;
644 struct sta_info *sta = ap_get_sta(hapd, addr);
645 if (sta == NULL || sta->eapol_sm == NULL)
648 case WPA_EAPOL_keyRun:
649 return sta->eapol_sm->keyRun;
650 case WPA_EAPOL_keyAvailable:
651 return sta->eapol_sm->eap_if->eapKeyAvailable;
658 static const u8 * hostapd_wpa_auth_get_psk(void *ctx, const u8 *addr,
661 struct hostapd_data *hapd = ctx;
662 return hostapd_get_psk(hapd->conf, addr, prev_psk);
666 static int hostapd_wpa_auth_get_msk(void *ctx, const u8 *addr, u8 *msk,
669 struct hostapd_data *hapd = ctx;
672 struct sta_info *sta;
674 sta = ap_get_sta(hapd, addr);
678 key = ieee802_1x_get_key(sta->eapol_sm, &keylen);
684 os_memcpy(msk, key, keylen);
691 static int hostapd_wpa_auth_set_key(void *ctx, int vlan_id, wpa_alg alg,
692 const u8 *addr, int idx, u8 *key,
695 struct hostapd_data *hapd = ctx;
696 const char *ifname = hapd->conf->iface;
699 ifname = hostapd_get_vlan_id_ifname(hapd->conf->vlan, vlan_id);
704 return hostapd_set_key(ifname, hapd, alg, addr, idx, 1, NULL, 0,
709 static int hostapd_wpa_auth_get_seqnum(void *ctx, const u8 *addr, int idx,
712 struct hostapd_data *hapd = ctx;
713 return hostapd_get_seqnum(hapd->conf->iface, hapd, addr, idx, seq);
717 static int hostapd_wpa_auth_get_seqnum_igtk(void *ctx, const u8 *addr, int idx,
720 struct hostapd_data *hapd = ctx;
721 return hostapd_get_seqnum_igtk(hapd->conf->iface, hapd, addr, idx,
726 static int hostapd_wpa_auth_send_eapol(void *ctx, const u8 *addr,
727 const u8 *data, size_t data_len,
730 struct hostapd_data *hapd = ctx;
731 return hostapd_send_eapol(hapd, addr, data, data_len, encrypt);
735 static int hostapd_wpa_auth_for_each_sta(
736 void *ctx, int (*cb)(struct wpa_state_machine *sm, void *ctx),
739 struct hostapd_data *hapd = ctx;
740 struct sta_info *sta;
742 for (sta = hapd->sta_list; sta; sta = sta->next) {
743 if (sta->wpa_sm && cb(sta->wpa_sm, cb_ctx))
750 struct wpa_auth_iface_iter_data {
751 int (*cb)(struct wpa_authenticator *sm, void *ctx);
755 static int wpa_auth_iface_iter(struct hostapd_iface *iface, void *ctx)
757 struct wpa_auth_iface_iter_data *data = ctx;
759 for (i = 0; i < iface->num_bss; i++) {
760 if (data->cb(iface->bss[i]->wpa_auth, data->cb_ctx))
767 static int hostapd_wpa_auth_for_each_auth(
768 void *ctx, int (*cb)(struct wpa_authenticator *sm, void *ctx),
771 struct wpa_auth_iface_iter_data data;
773 data.cb_ctx = cb_ctx;
774 return hostapd_for_each_interface(wpa_auth_iface_iter, &data);
778 static int hostapd_wpa_auth_send_ether(void *ctx, const u8 *dst, u16 proto,
779 const u8 *data, size_t data_len)
781 struct hostapd_data *hapd = ctx;
783 if (hapd->driver && hapd->driver->send_ether)
784 return hapd->driver->send_ether(hapd->drv_priv, dst,
785 hapd->own_addr, proto,
787 if (hapd->l2 == NULL)
789 return l2_packet_send(hapd->l2, dst, proto, data, data_len);
793 #ifdef CONFIG_IEEE80211R
795 static int hostapd_wpa_auth_send_ft_action(void *ctx, const u8 *dst,
796 const u8 *data, size_t data_len)
798 struct hostapd_data *hapd = ctx;
800 struct ieee80211_mgmt *m;
802 struct sta_info *sta;
804 sta = ap_get_sta(hapd, dst);
805 if (sta == NULL || sta->wpa_sm == NULL)
808 m = os_zalloc(sizeof(*m) + data_len);
811 mlen = ((u8 *) &m->u - (u8 *) m) + data_len;
812 m->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
813 WLAN_FC_STYPE_ACTION);
814 os_memcpy(m->da, dst, ETH_ALEN);
815 os_memcpy(m->sa, hapd->own_addr, ETH_ALEN);
816 os_memcpy(m->bssid, hapd->own_addr, ETH_ALEN);
817 os_memcpy(&m->u, data, data_len);
819 res = hostapd_send_mgmt_frame(hapd, (u8 *) m, mlen, 0);
825 static struct wpa_state_machine *
826 hostapd_wpa_auth_add_sta(void *ctx, const u8 *sta_addr)
828 struct hostapd_data *hapd = ctx;
829 struct sta_info *sta;
831 sta = ap_sta_add(hapd, sta_addr);
837 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, sta->addr);
838 if (sta->wpa_sm == NULL) {
839 ap_free_sta(hapd, sta);
842 sta->auth_alg = WLAN_AUTH_FT;
848 static void hostapd_rrb_receive(void *ctx, const u8 *src_addr, const u8 *buf,
851 struct hostapd_data *hapd = ctx;
852 wpa_ft_rrb_rx(hapd->wpa_auth, src_addr, buf, len);
855 #endif /* CONFIG_IEEE80211R */
859 * hostapd_validate_bssid_configuration - Validate BSSID configuration
860 * @iface: Pointer to interface data
861 * Returns: 0 on success, -1 on failure
863 * This function is used to validate that the configured BSSIDs are valid.
865 static int hostapd_validate_bssid_configuration(struct hostapd_iface *iface)
867 u8 mask[ETH_ALEN] = { 0 };
868 struct hostapd_data *hapd = iface->bss[0];
869 unsigned int i = iface->conf->num_bss, bits = 0, j;
873 if (hostapd_drv_none(hapd))
876 /* Generate BSSID mask that is large enough to cover the BSSIDs. */
878 /* Determine the bits necessary to cover the number of BSSIDs. */
879 for (i--; i; i >>= 1)
882 /* Determine the bits necessary to any configured BSSIDs,
883 if they are higher than the number of BSSIDs. */
884 for (j = 0; j < iface->conf->num_bss; j++) {
885 if (hostapd_mac_comp_empty(iface->conf->bss[j].bssid) == 0) {
891 for (i = 0; i < ETH_ALEN; i++) {
893 iface->conf->bss[j].bssid[i] ^
901 for (i = 0; i < ETH_ALEN && mask[i] == 0; i++)
907 while (mask[i] != 0) {
917 wpa_printf(MSG_ERROR, "Too many bits in the BSSID mask (%u)",
922 os_memset(mask, 0xff, ETH_ALEN);
924 for (i = 5; i > 5 - j; i--)
931 wpa_printf(MSG_DEBUG, "BSS count %lu, BSSID mask " MACSTR " (%d bits)",
932 (unsigned long) iface->conf->num_bss, MAC2STR(mask), bits);
934 res = hostapd_valid_bss_mask(hapd, hapd->own_addr, mask);
939 wpa_printf(MSG_ERROR, "Driver did not accept BSSID mask "
940 MACSTR " for start address " MACSTR ".",
941 MAC2STR(mask), MAC2STR(hapd->own_addr));
948 for (i = 0; i < ETH_ALEN; i++) {
949 if ((hapd->own_addr[i] & mask[i]) != hapd->own_addr[i]) {
950 wpa_printf(MSG_ERROR, "Invalid BSSID mask " MACSTR
951 " for start address " MACSTR ".",
952 MAC2STR(mask), MAC2STR(hapd->own_addr));
953 wpa_printf(MSG_ERROR, "Start address must be the "
954 "first address in the block (i.e., addr "
955 "AND mask == addr).");
964 static int mac_in_conf(struct hostapd_config *conf, const void *a)
968 for (i = 0; i < conf->num_bss; i++) {
969 if (hostapd_mac_comp(conf->bss[i].bssid, a) == 0) {
978 static int hostapd_setup_wpa(struct hostapd_data *hapd)
980 struct wpa_auth_config _conf;
981 struct wpa_auth_callbacks cb;
985 hostapd_wpa_auth_conf(hapd->conf, &_conf);
986 os_memset(&cb, 0, sizeof(cb));
988 cb.logger = hostapd_wpa_auth_logger;
989 cb.disconnect = hostapd_wpa_auth_disconnect;
990 cb.mic_failure_report = hostapd_wpa_auth_mic_failure_report;
991 cb.set_eapol = hostapd_wpa_auth_set_eapol;
992 cb.get_eapol = hostapd_wpa_auth_get_eapol;
993 cb.get_psk = hostapd_wpa_auth_get_psk;
994 cb.get_msk = hostapd_wpa_auth_get_msk;
995 cb.set_key = hostapd_wpa_auth_set_key;
996 cb.get_seqnum = hostapd_wpa_auth_get_seqnum;
997 cb.get_seqnum_igtk = hostapd_wpa_auth_get_seqnum_igtk;
998 cb.send_eapol = hostapd_wpa_auth_send_eapol;
999 cb.for_each_sta = hostapd_wpa_auth_for_each_sta;
1000 cb.for_each_auth = hostapd_wpa_auth_for_each_auth;
1001 cb.send_ether = hostapd_wpa_auth_send_ether;
1002 #ifdef CONFIG_IEEE80211R
1003 cb.send_ft_action = hostapd_wpa_auth_send_ft_action;
1004 cb.add_sta = hostapd_wpa_auth_add_sta;
1005 #endif /* CONFIG_IEEE80211R */
1006 hapd->wpa_auth = wpa_init(hapd->own_addr, &_conf, &cb);
1007 if (hapd->wpa_auth == NULL) {
1008 wpa_printf(MSG_ERROR, "WPA initialization failed.");
1012 if (hostapd_set_privacy(hapd, 1)) {
1013 wpa_printf(MSG_ERROR, "Could not set PrivacyInvoked "
1014 "for interface %s", hapd->conf->iface);
1018 wpa_ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &wpa_ie_len);
1019 if (hostapd_set_generic_elem(hapd, wpa_ie, wpa_ie_len)) {
1020 wpa_printf(MSG_ERROR, "Failed to configure WPA IE for "
1021 "the kernel driver.");
1025 if (rsn_preauth_iface_init(hapd)) {
1026 wpa_printf(MSG_ERROR, "Initialization of RSN "
1027 "pre-authentication failed.");
1036 static int hostapd_setup_radius_srv(struct hostapd_data *hapd,
1037 struct hostapd_bss_config *conf)
1039 struct radius_server_conf srv;
1040 os_memset(&srv, 0, sizeof(srv));
1041 srv.client_file = conf->radius_server_clients;
1042 srv.auth_port = conf->radius_server_auth_port;
1043 srv.conf_ctx = conf;
1044 srv.eap_sim_db_priv = hapd->eap_sim_db_priv;
1045 srv.ssl_ctx = hapd->ssl_ctx;
1046 srv.pac_opaque_encr_key = conf->pac_opaque_encr_key;
1047 srv.eap_fast_a_id = conf->eap_fast_a_id;
1048 srv.eap_fast_a_id_len = conf->eap_fast_a_id_len;
1049 srv.eap_fast_a_id_info = conf->eap_fast_a_id_info;
1050 srv.eap_fast_prov = conf->eap_fast_prov;
1051 srv.pac_key_lifetime = conf->pac_key_lifetime;
1052 srv.pac_key_refresh_time = conf->pac_key_refresh_time;
1053 srv.eap_sim_aka_result_ind = conf->eap_sim_aka_result_ind;
1054 srv.tnc = conf->tnc;
1055 srv.wps = hapd->wps;
1056 srv.ipv6 = conf->radius_server_ipv6;
1057 srv.get_eap_user = hostapd_radius_get_eap_user;
1058 srv.eap_req_id_text = conf->eap_req_id_text;
1059 srv.eap_req_id_text_len = conf->eap_req_id_text_len;
1061 hapd->radius_srv = radius_server_init(&srv);
1062 if (hapd->radius_srv == NULL) {
1063 wpa_printf(MSG_ERROR, "RADIUS server initialization failed.");
1072 * hostapd_setup_bss - Per-BSS setup (initialization)
1073 * @hapd: Pointer to BSS data
1074 * @first: Whether this BSS is the first BSS of an interface
1076 * This function is used to initialize all per-BSS data structures and
1077 * resources. This gets called in a loop for each BSS when an interface is
1078 * initialized. Most of the modules that are initialized here will be
1079 * deinitialized in hostapd_cleanup().
1081 static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
1083 struct hostapd_bss_config *conf = hapd->conf;
1084 u8 ssid[HOSTAPD_MAX_SSID_LEN + 1];
1085 int ssid_len, set_ssid;
1088 if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0) {
1089 /* Allocate the next available BSSID. */
1091 inc_byte_array(hapd->own_addr, ETH_ALEN);
1092 } while (mac_in_conf(hapd->iconf, hapd->own_addr));
1094 /* Allocate the configured BSSID. */
1095 os_memcpy(hapd->own_addr, hapd->conf->bssid, ETH_ALEN);
1097 if (hostapd_mac_comp(hapd->own_addr,
1098 hapd->iface->bss[0]->own_addr) ==
1100 wpa_printf(MSG_ERROR, "BSS '%s' may not have "
1101 "BSSID set to the MAC address of "
1102 "the radio", hapd->conf->iface);
1107 hapd->interface_added = 1;
1108 if (hostapd_bss_add(hapd->iface->bss[0], hapd->conf->iface,
1110 wpa_printf(MSG_ERROR, "Failed to add BSS (BSSID="
1111 MACSTR ")", MAC2STR(hapd->own_addr));
1117 * Fetch the SSID from the system and use it or,
1118 * if one was specified in the config file, verify they
1121 ssid_len = hostapd_get_ssid(hapd, ssid, sizeof(ssid));
1123 wpa_printf(MSG_ERROR, "Could not read SSID from system");
1126 if (conf->ssid.ssid_set) {
1128 * If SSID is specified in the config file and it differs
1129 * from what is being used then force installation of the
1132 set_ssid = (conf->ssid.ssid_len != (size_t) ssid_len ||
1133 os_memcmp(conf->ssid.ssid, ssid, ssid_len) != 0);
1136 * No SSID in the config file; just use the one we got
1140 conf->ssid.ssid_len = ssid_len;
1141 os_memcpy(conf->ssid.ssid, ssid, conf->ssid.ssid_len);
1142 conf->ssid.ssid[conf->ssid.ssid_len] = '\0';
1145 if (!hostapd_drv_none(hapd)) {
1146 wpa_printf(MSG_ERROR, "Using interface %s with hwaddr " MACSTR
1148 hapd->conf->iface, MAC2STR(hapd->own_addr),
1149 hapd->conf->ssid.ssid);
1152 if (hostapd_setup_wpa_psk(conf)) {
1153 wpa_printf(MSG_ERROR, "WPA-PSK setup failed.");
1157 /* Set flag for whether SSID is broadcast in beacons */
1158 if (hostapd_set_broadcast_ssid(hapd,
1159 !!hapd->conf->ignore_broadcast_ssid)) {
1160 wpa_printf(MSG_ERROR, "Could not set broadcast SSID flag for "
1165 /* Set SSID for the kernel driver (to be used in beacon and probe
1166 * response frames) */
1167 if (set_ssid && hostapd_set_ssid(hapd, (u8 *) conf->ssid.ssid,
1168 conf->ssid.ssid_len)) {
1169 wpa_printf(MSG_ERROR, "Could not set SSID for kernel driver");
1173 if (wpa_debug_level == MSG_MSGDUMP)
1174 conf->radius->msg_dumps = 1;
1175 hapd->radius = radius_client_init(hapd, conf->radius);
1176 if (hapd->radius == NULL) {
1177 wpa_printf(MSG_ERROR, "RADIUS client initialization failed.");
1181 if (hostapd_acl_init(hapd)) {
1182 wpa_printf(MSG_ERROR, "ACL initialization failed.");
1185 if (hostapd_init_wps(hapd, conf))
1188 if (ieee802_1x_init(hapd)) {
1189 wpa_printf(MSG_ERROR, "IEEE 802.1X initialization failed.");
1193 if (hapd->conf->wpa && hostapd_setup_wpa(hapd))
1196 if (accounting_init(hapd)) {
1197 wpa_printf(MSG_ERROR, "Accounting initialization failed.");
1201 if (hapd->conf->ieee802_11f &&
1202 (hapd->iapp = iapp_init(hapd, hapd->conf->iapp_iface)) == NULL) {
1203 wpa_printf(MSG_ERROR, "IEEE 802.11F (IAPP) initialization "
1208 if (hostapd_ctrl_iface_init(hapd)) {
1209 wpa_printf(MSG_ERROR, "Failed to setup control interface");
1213 if (!hostapd_drv_none(hapd) && vlan_init(hapd)) {
1214 wpa_printf(MSG_ERROR, "VLAN initialization failed.");
1218 #ifdef CONFIG_IEEE80211R
1219 if (!hostapd_drv_none(hapd)) {
1220 hapd->l2 = l2_packet_init(hapd->conf->iface, NULL, ETH_P_RRB,
1221 hostapd_rrb_receive, hapd, 0);
1222 if (hapd->l2 == NULL &&
1223 (hapd->driver == NULL ||
1224 hapd->driver->send_ether == NULL)) {
1225 wpa_printf(MSG_ERROR, "Failed to open l2_packet "
1230 #endif /* CONFIG_IEEE80211R */
1232 ieee802_11_set_beacon(hapd);
1234 if (conf->radius_server_clients &&
1235 hostapd_setup_radius_srv(hapd, conf))
1242 static void hostapd_tx_queue_params(struct hostapd_iface *iface)
1244 struct hostapd_data *hapd = iface->bss[0];
1246 struct hostapd_tx_queue_params *p;
1248 for (i = 0; i < NUM_TX_QUEUES; i++) {
1249 p = &iface->conf->tx_queue[i];
1254 if (hostapd_set_tx_queue_params(hapd, i, p->aifs, p->cwmin,
1255 p->cwmax, p->burst)) {
1256 wpa_printf(MSG_DEBUG, "Failed to set TX queue "
1257 "parameters for queue %d.", i);
1258 /* Continue anyway */
1264 static int hostapd_radius_get_eap_user(void *ctx, const u8 *identity,
1265 size_t identity_len, int phase2,
1266 struct eap_user *user)
1268 const struct hostapd_eap_user *eap_user;
1271 eap_user = hostapd_get_eap_user(ctx, identity, identity_len, phase2);
1272 if (eap_user == NULL)
1278 os_memset(user, 0, sizeof(*user));
1279 count = EAP_USER_MAX_METHODS;
1280 if (count > EAP_MAX_METHODS)
1281 count = EAP_MAX_METHODS;
1282 for (i = 0; i < count; i++) {
1283 user->methods[i].vendor = eap_user->methods[i].vendor;
1284 user->methods[i].method = eap_user->methods[i].method;
1287 if (eap_user->password) {
1288 user->password = os_malloc(eap_user->password_len);
1289 if (user->password == NULL)
1291 os_memcpy(user->password, eap_user->password,
1292 eap_user->password_len);
1293 user->password_len = eap_user->password_len;
1294 user->password_hash = eap_user->password_hash;
1296 user->force_version = eap_user->force_version;
1297 user->ttls_auth = eap_user->ttls_auth;
1303 static int setup_interface(struct hostapd_iface *iface)
1305 struct hostapd_data *hapd = iface->bss[0];
1306 struct hostapd_bss_config *conf = hapd->conf;
1309 u8 *b = conf->bssid;
1315 * Initialize the driver interface and make sure that all BSSes get
1316 * configured with a pointer to this driver interface.
1318 if (b[0] | b[1] | b[2] | b[3] | b[4] | b[5]) {
1319 hapd->drv_priv = hostapd_driver_init_bssid(hapd, b);
1321 hapd->drv_priv = hostapd_driver_init(hapd);
1324 if (hapd->drv_priv == NULL) {
1325 wpa_printf(MSG_ERROR, "%s driver initialization failed.",
1326 hapd->driver ? hapd->driver->name : "Unknown");
1327 hapd->driver = NULL;
1330 for (i = 0; i < iface->num_bss; i++) {
1331 iface->bss[i]->driver = hapd->driver;
1332 iface->bss[i]->drv_priv = hapd->drv_priv;
1335 if (hostapd_validate_bssid_configuration(iface))
1338 #ifdef CONFIG_IEEE80211N
1339 SET_2BIT_LE16(&iface->ht_op_mode,
1340 HT_INFO_OPERATION_MODE_OP_MODE_OFFSET,
1342 #endif /* CONFIG_IEEE80211N */
1344 if (hapd->iconf->country[0] && hapd->iconf->country[1]) {
1345 os_memcpy(country, hapd->iconf->country, 3);
1347 if (hostapd_set_country(hapd, country) < 0) {
1348 wpa_printf(MSG_ERROR, "Failed to set country code");
1353 if (hapd->iconf->ieee80211d &&
1354 hostapd_set_ieee80211d(hapd, 1) < 0) {
1355 wpa_printf(MSG_ERROR, "Failed to set ieee80211d (%d)",
1356 hapd->iconf->ieee80211d);
1360 if (hapd->iconf->bridge_packets != INTERNAL_BRIDGE_DO_NOT_CONTROL &&
1361 hostapd_set_internal_bridge(hapd, hapd->iconf->bridge_packets)) {
1362 wpa_printf(MSG_ERROR, "Failed to set bridge_packets for "
1367 /* TODO: merge with hostapd_driver_init() ? */
1368 if (hostapd_wireless_event_init(hapd) < 0)
1371 if (hostapd_get_hw_features(iface)) {
1372 /* Not all drivers support this yet, so continue without hw
1375 int ret = hostapd_select_hw_mode(iface);
1377 wpa_printf(MSG_ERROR, "Could not select hw_mode and "
1378 "channel. (%d)", ret);
1383 hostapd_flush_old_stations(hapd);
1384 hostapd_set_privacy(hapd, 0);
1386 if (hapd->iconf->channel) {
1387 freq = hostapd_hw_get_freq(hapd, hapd->iconf->channel);
1388 wpa_printf(MSG_DEBUG, "Mode: %s Channel: %d "
1389 "Frequency: %d MHz",
1390 hostapd_hw_mode_txt(hapd->iconf->hw_mode),
1391 hapd->iconf->channel, freq);
1393 if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, freq,
1394 hapd->iconf->channel,
1395 hapd->iconf->ieee80211n,
1396 hapd->iconf->secondary_channel)) {
1397 wpa_printf(MSG_ERROR, "Could not set channel for "
1403 hostapd_broadcast_wep_clear(hapd);
1404 if (hostapd_setup_encryption(hapd->conf->iface, hapd))
1407 hostapd_set_beacon_int(hapd, hapd->iconf->beacon_int);
1408 ieee802_11_set_beacon(hapd);
1410 if (hapd->iconf->rts_threshold > -1 &&
1411 hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
1412 wpa_printf(MSG_ERROR, "Could not set RTS threshold for "
1417 if (hapd->iconf->fragm_threshold > -1 &&
1418 hostapd_set_frag(hapd, hapd->iconf->fragm_threshold)) {
1419 wpa_printf(MSG_ERROR, "Could not set fragmentation threshold "
1420 "for kernel driver");
1424 prev_addr = hapd->own_addr;
1426 for (j = 0; j < iface->num_bss; j++) {
1427 hapd = iface->bss[j];
1429 os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
1430 if (hostapd_setup_bss(hapd, j == 0))
1432 if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
1433 prev_addr = hapd->own_addr;
1436 hostapd_tx_queue_params(iface);
1438 ap_list_init(iface);
1440 if (hostapd_driver_commit(hapd) < 0) {
1441 wpa_printf(MSG_ERROR, "%s: Failed to commit driver "
1442 "configuration", __func__);
1451 * hostapd_setup_interface - Setup of an interface
1452 * @iface: Pointer to interface data.
1453 * Returns: 0 on success, -1 on failure
1455 * Initializes the driver interface, validates the configuration,
1456 * and sets driver parameters based on the configuration.
1457 * Flushes old stations, sets the channel, encryption,
1458 * beacons, and WDS links based on the configuration.
1460 int hostapd_setup_interface(struct hostapd_iface *iface)
1464 ret = setup_interface(iface);
1466 wpa_printf(MSG_DEBUG, "%s: Unable to setup interface.",
1467 iface->bss[0]->conf->iface);
1470 } else if (!hostapd_drv_none(iface->bss[0])) {
1471 wpa_printf(MSG_DEBUG, "%s: Setup of interface done.",
1472 iface->bss[0]->conf->iface);
1480 * hostapd_alloc_bss_data - Allocate and initialize per-BSS data
1481 * @hapd_iface: Pointer to interface data
1482 * @conf: Pointer to per-interface configuration
1483 * @bss: Pointer to per-BSS configuration for this BSS
1484 * Returns: Pointer to allocated BSS data
1486 * This function is used to allocate per-BSS data structure. This data will be
1487 * freed after hostapd_cleanup() is called for it during interface
1490 struct hostapd_data *
1491 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
1492 struct hostapd_config *conf,
1493 struct hostapd_bss_config *bss)
1495 struct hostapd_data *hapd;
1497 hapd = os_zalloc(sizeof(*hapd));
1503 hapd->iface = hapd_iface;
1505 if (hapd->conf->individual_wep_key_len > 0) {
1506 /* use key0 in individual key and key1 in broadcast key */
1507 hapd->default_wep_key_idx = 1;
1510 #ifdef EAP_TLS_FUNCS
1511 if (hapd->conf->eap_server &&
1512 (hapd->conf->ca_cert || hapd->conf->server_cert ||
1513 hapd->conf->dh_file)) {
1514 struct tls_connection_params params;
1516 hapd->ssl_ctx = tls_init(NULL);
1517 if (hapd->ssl_ctx == NULL) {
1518 wpa_printf(MSG_ERROR, "Failed to initialize TLS");
1522 os_memset(¶ms, 0, sizeof(params));
1523 params.ca_cert = hapd->conf->ca_cert;
1524 params.client_cert = hapd->conf->server_cert;
1525 params.private_key = hapd->conf->private_key;
1526 params.private_key_passwd = hapd->conf->private_key_passwd;
1527 params.dh_file = hapd->conf->dh_file;
1529 if (tls_global_set_params(hapd->ssl_ctx, ¶ms)) {
1530 wpa_printf(MSG_ERROR, "Failed to set TLS parameters");
1534 if (tls_global_set_verify(hapd->ssl_ctx,
1535 hapd->conf->check_crl)) {
1536 wpa_printf(MSG_ERROR, "Failed to enable check_crl");
1540 #endif /* EAP_TLS_FUNCS */
1543 if (hapd->conf->eap_sim_db) {
1544 hapd->eap_sim_db_priv =
1545 eap_sim_db_init(hapd->conf->eap_sim_db,
1546 hostapd_sim_db_cb, hapd);
1547 if (hapd->eap_sim_db_priv == NULL) {
1548 wpa_printf(MSG_ERROR, "Failed to initialize EAP-SIM "
1549 "database interface");
1553 #endif /* EAP_SERVER */
1555 hapd->driver = hapd->iconf->driver;
1559 #if defined(EAP_TLS_FUNCS) || defined(EAP_SERVER)
1562 /* TODO: cleanup allocated resources(?) */
1568 void hostapd_interface_deinit(struct hostapd_iface *iface)
1575 hostapd_cleanup_iface_pre(iface);
1576 for (j = 0; j < iface->num_bss; j++) {
1577 struct hostapd_data *hapd = iface->bss[j];
1578 hostapd_free_stas(hapd);
1579 hostapd_flush_old_stations(hapd);
1580 hostapd_cleanup(hapd);
1581 if (j == iface->num_bss - 1 && hapd->driver)
1582 hostapd_driver_deinit(hapd);
1584 for (j = 0; j < iface->num_bss; j++)
1585 os_free(iface->bss[j]);
1586 hostapd_cleanup_iface(iface);