blob: e59308a5ede3fa91e5fd0ea9ab239f178a0c98d3 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * hostapd / main()
Hai Shalom74f70d42019-02-11 14:42:39 -08003 * Copyright (c) 2002-2019, Jouni Malinen <j@w1.fi>
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07004 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#include "utils/includes.h"
10#ifndef CONFIG_NATIVE_WINDOWS
11#include <syslog.h>
Dmitry Shmidt0ccb66e2013-03-29 16:41:28 -070012#include <grp.h>
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070013#endif /* CONFIG_NATIVE_WINDOWS */
14
15#include "utils/common.h"
16#include "utils/eloop.h"
Dmitry Shmidt96be6222014-02-13 10:16:51 -080017#include "utils/uuid.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070018#include "crypto/random.h"
19#include "crypto/tls.h"
20#include "common/version.h"
Hai Shalom021b0b52019-04-10 11:17:58 -070021#include "common/dpp.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070022#include "drivers/driver.h"
23#include "eap_server/eap.h"
24#include "eap_server/tncs.h"
25#include "ap/hostapd.h"
26#include "ap/ap_config.h"
Dmitry Shmidt04949592012-07-19 12:16:46 -070027#include "ap/ap_drv_ops.h"
Roshan Pius3a1667e2018-07-03 15:17:14 -070028#include "ap/dpp_hostapd.h"
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080029#include "fst/fst.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070030#include "config_file.h"
31#include "eap_register.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070032#include "ctrl_iface.h"
Gabriel Biren72cf9a52021-06-25 23:29:26 +000033#ifdef CONFIG_CTRL_IFACE_AIDL
34#include "aidl.h"
35#endif /* CONFIG_CTRL_IFACE_AIDL */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070036
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080037struct hapd_global {
38 void **drv_priv;
39 size_t drv_count;
40};
41
42static struct hapd_global global;
43
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070044
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070045#ifndef CONFIG_NO_HOSTAPD_LOGGER
46static void hostapd_logger_cb(void *ctx, const u8 *addr, unsigned int module,
47 int level, const char *txt, size_t len)
48{
49 struct hostapd_data *hapd = ctx;
50 char *format, *module_str;
51 int maxlen;
52 int conf_syslog_level, conf_stdout_level;
53 unsigned int conf_syslog, conf_stdout;
54
55 maxlen = len + 100;
56 format = os_malloc(maxlen);
57 if (!format)
58 return;
59
60 if (hapd && hapd->conf) {
61 conf_syslog_level = hapd->conf->logger_syslog_level;
62 conf_stdout_level = hapd->conf->logger_stdout_level;
63 conf_syslog = hapd->conf->logger_syslog;
64 conf_stdout = hapd->conf->logger_stdout;
65 } else {
66 conf_syslog_level = conf_stdout_level = 0;
67 conf_syslog = conf_stdout = (unsigned int) -1;
68 }
69
70 switch (module) {
71 case HOSTAPD_MODULE_IEEE80211:
72 module_str = "IEEE 802.11";
73 break;
74 case HOSTAPD_MODULE_IEEE8021X:
75 module_str = "IEEE 802.1X";
76 break;
77 case HOSTAPD_MODULE_RADIUS:
78 module_str = "RADIUS";
79 break;
80 case HOSTAPD_MODULE_WPA:
81 module_str = "WPA";
82 break;
83 case HOSTAPD_MODULE_DRIVER:
84 module_str = "DRIVER";
85 break;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070086 case HOSTAPD_MODULE_MLME:
87 module_str = "MLME";
88 break;
89 default:
90 module_str = NULL;
91 break;
92 }
93
94 if (hapd && hapd->conf && addr)
95 os_snprintf(format, maxlen, "%s: STA " MACSTR "%s%s: %s",
96 hapd->conf->iface, MAC2STR(addr),
Dmitry Shmidt96be6222014-02-13 10:16:51 -080097 module_str ? " " : "", module_str ? module_str : "",
98 txt);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070099 else if (hapd && hapd->conf)
100 os_snprintf(format, maxlen, "%s:%s%s %s",
101 hapd->conf->iface, module_str ? " " : "",
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700102 module_str ? module_str : "", txt);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700103 else if (addr)
104 os_snprintf(format, maxlen, "STA " MACSTR "%s%s: %s",
105 MAC2STR(addr), module_str ? " " : "",
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700106 module_str ? module_str : "", txt);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700107 else
108 os_snprintf(format, maxlen, "%s%s%s",
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700109 module_str ? module_str : "",
110 module_str ? ": " : "", txt);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700111
Paul Stewart092955c2017-02-06 09:13:09 -0800112#ifdef CONFIG_DEBUG_SYSLOG
113 if (wpa_debug_syslog)
114 conf_stdout = 0;
115#endif /* CONFIG_DEBUG_SYSLOG */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700116 if ((conf_stdout & module) && level >= conf_stdout_level) {
117 wpa_debug_print_timestamp();
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800118 wpa_printf(MSG_INFO, "%s", format);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700119 }
120
121#ifndef CONFIG_NATIVE_WINDOWS
122 if ((conf_syslog & module) && level >= conf_syslog_level) {
123 int priority;
124 switch (level) {
125 case HOSTAPD_LEVEL_DEBUG_VERBOSE:
126 case HOSTAPD_LEVEL_DEBUG:
127 priority = LOG_DEBUG;
128 break;
129 case HOSTAPD_LEVEL_INFO:
130 priority = LOG_INFO;
131 break;
132 case HOSTAPD_LEVEL_NOTICE:
133 priority = LOG_NOTICE;
134 break;
135 case HOSTAPD_LEVEL_WARNING:
136 priority = LOG_WARNING;
137 break;
138 default:
139 priority = LOG_INFO;
140 break;
141 }
142 syslog(priority, "%s", format);
143 }
144#endif /* CONFIG_NATIVE_WINDOWS */
145
146 os_free(format);
147}
148#endif /* CONFIG_NO_HOSTAPD_LOGGER */
149
150
151/**
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800152 * hostapd_driver_init - Preparate driver interface
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700153 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700154static int hostapd_driver_init(struct hostapd_iface *iface)
155{
156 struct wpa_init_params params;
157 size_t i;
158 struct hostapd_data *hapd = iface->bss[0];
159 struct hostapd_bss_config *conf = hapd->conf;
160 u8 *b = conf->bssid;
161 struct wpa_driver_capa capa;
162
163 if (hapd->driver == NULL || hapd->driver->hapd_init == NULL) {
164 wpa_printf(MSG_ERROR, "No hostapd driver wrapper available");
165 return -1;
166 }
167
168 /* Initialize the driver interface */
169 if (!(b[0] | b[1] | b[2] | b[3] | b[4] | b[5]))
170 b = NULL;
171
172 os_memset(&params, 0, sizeof(params));
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800173 for (i = 0; wpa_drivers[i]; i++) {
174 if (wpa_drivers[i] != hapd->driver)
175 continue;
176
177 if (global.drv_priv[i] == NULL &&
178 wpa_drivers[i]->global_init) {
Dmitry Shmidte4663042016-04-04 10:07:49 -0700179 global.drv_priv[i] =
180 wpa_drivers[i]->global_init(iface->interfaces);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800181 if (global.drv_priv[i] == NULL) {
182 wpa_printf(MSG_ERROR, "Failed to initialize "
183 "driver '%s'",
184 wpa_drivers[i]->name);
185 return -1;
186 }
187 }
188
189 params.global_priv = global.drv_priv[i];
190 break;
191 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700192 params.bssid = b;
193 params.ifname = hapd->conf->iface;
Dmitry Shmidtfb45fd52015-01-05 13:08:17 -0800194 params.driver_params = hapd->iconf->driver_params;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700195 params.use_pae_group_addr = hapd->conf->use_pae_group_addr;
196
197 params.num_bridge = hapd->iface->num_bss;
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700198 params.bridge = os_calloc(hapd->iface->num_bss, sizeof(char *));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700199 if (params.bridge == NULL)
200 return -1;
201 for (i = 0; i < hapd->iface->num_bss; i++) {
202 struct hostapd_data *bss = hapd->iface->bss[i];
203 if (bss->conf->bridge[0])
204 params.bridge[i] = bss->conf->bridge;
205 }
206
207 params.own_addr = hapd->own_addr;
208
209 hapd->drv_priv = hapd->driver->hapd_init(hapd, &params);
210 os_free(params.bridge);
211 if (hapd->drv_priv == NULL) {
212 wpa_printf(MSG_ERROR, "%s driver initialization failed.",
213 hapd->driver->name);
214 hapd->driver = NULL;
215 return -1;
216 }
217
218 if (hapd->driver->get_capa &&
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800219 hapd->driver->get_capa(hapd->drv_priv, &capa) == 0) {
Dmitry Shmidt0207e232014-09-03 14:58:37 -0700220 struct wowlan_triggers *triggs;
221
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700222 iface->drv_flags = capa.flags;
Hai Shalomb755a2a2020-04-23 21:49:02 -0700223 iface->drv_flags2 = capa.flags2;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800224 iface->probe_resp_offloads = capa.probe_resp_offloads;
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700225 /*
226 * Use default extended capa values from per-radio information
227 */
Dmitry Shmidt444d5672013-04-01 13:08:44 -0700228 iface->extended_capa = capa.extended_capa;
229 iface->extended_capa_mask = capa.extended_capa_mask;
230 iface->extended_capa_len = capa.extended_capa_len;
Dmitry Shmidt8bae4132013-06-06 11:25:10 -0700231 iface->drv_max_acl_mac_addrs = capa.max_acl_mac_addrs;
Dmitry Shmidt0207e232014-09-03 14:58:37 -0700232
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700233 /*
234 * Override extended capa with per-interface type (AP), if
235 * available from the driver.
236 */
237 hostapd_get_ext_capa(iface);
238
Dmitry Shmidt0207e232014-09-03 14:58:37 -0700239 triggs = wpa_get_wowlan_triggers(conf->wowlan_triggers, &capa);
240 if (triggs && hapd->driver->set_wowlan) {
241 if (hapd->driver->set_wowlan(hapd->drv_priv, triggs))
242 wpa_printf(MSG_ERROR, "set_wowlan failed");
243 }
244 os_free(triggs);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800245 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700246
247 return 0;
248}
249
250
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800251/**
252 * hostapd_interface_init - Read configuration file and init BSS data
253 *
254 * This function is used to parse configuration file for a full interface (one
255 * or more BSSes sharing the same radio) and allocate memory for the BSS
Hai Shalom74f70d42019-02-11 14:42:39 -0800256 * interfaces. No actual driver operations are started.
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800257 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700258static struct hostapd_iface *
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700259hostapd_interface_init(struct hapd_interfaces *interfaces, const char *if_name,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700260 const char *config_fname, int debug)
261{
262 struct hostapd_iface *iface;
263 int k;
264
Hai Shalomfdcde762020-04-02 11:19:20 -0700265 wpa_printf(MSG_DEBUG, "Configuration file: %s", config_fname);
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800266 iface = hostapd_init(interfaces, config_fname);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700267 if (!iface)
268 return NULL;
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700269
270 if (if_name) {
271 os_strlcpy(iface->conf->bss[0]->iface, if_name,
272 sizeof(iface->conf->bss[0]->iface));
273 }
274
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700275 iface->interfaces = interfaces;
276
277 for (k = 0; k < debug; k++) {
278 if (iface->bss[0]->conf->logger_stdout_level > 0)
279 iface->bss[0]->conf->logger_stdout_level--;
280 }
281
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800282 if (iface->conf->bss[0]->iface[0] == '\0' &&
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700283 !hostapd_drv_none(iface->bss[0])) {
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700284 wpa_printf(MSG_ERROR,
285 "Interface name not specified in %s, nor by '-i' parameter",
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700286 config_fname);
287 hostapd_interface_deinit_free(iface);
288 return NULL;
289 }
290
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700291 return iface;
292}
293
294
295/**
296 * handle_term - SIGINT and SIGTERM handler to terminate hostapd process
297 */
298static void handle_term(int sig, void *signal_ctx)
299{
300 wpa_printf(MSG_DEBUG, "Signal %d received - terminating", sig);
301 eloop_terminate();
302}
303
304
305#ifndef CONFIG_NATIVE_WINDOWS
306
307static int handle_reload_iface(struct hostapd_iface *iface, void *ctx)
308{
309 if (hostapd_reload_config(iface) < 0) {
310 wpa_printf(MSG_WARNING, "Failed to read new configuration "
311 "file - continuing with old.");
312 }
313 return 0;
314}
315
316
317/**
318 * handle_reload - SIGHUP handler to reload configuration
319 */
320static void handle_reload(int sig, void *signal_ctx)
321{
322 struct hapd_interfaces *interfaces = signal_ctx;
323 wpa_printf(MSG_DEBUG, "Signal %d received - reloading configuration",
324 sig);
325 hostapd_for_each_interface(interfaces, handle_reload_iface, NULL);
326}
327
328
329static void handle_dump_state(int sig, void *signal_ctx)
330{
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800331 /* Not used anymore - ignore signal */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700332}
333#endif /* CONFIG_NATIVE_WINDOWS */
334
335
Jouni Malinen75ecf522011-06-27 15:19:46 -0700336static int hostapd_global_init(struct hapd_interfaces *interfaces,
337 const char *entropy_file)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700338{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800339 int i;
340
341 os_memset(&global, 0, sizeof(global));
342
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700343 hostapd_logger_register_cb(hostapd_logger_cb);
344
345 if (eap_server_register_methods()) {
346 wpa_printf(MSG_ERROR, "Failed to register EAP methods");
347 return -1;
348 }
349
350 if (eloop_init()) {
351 wpa_printf(MSG_ERROR, "Failed to initialize event loop");
352 return -1;
353 }
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700354 interfaces->eloop_initialized = 1;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700355
Jouni Malinen75ecf522011-06-27 15:19:46 -0700356 random_init(entropy_file);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700357
358#ifndef CONFIG_NATIVE_WINDOWS
359 eloop_register_signal(SIGHUP, handle_reload, interfaces);
360 eloop_register_signal(SIGUSR1, handle_dump_state, interfaces);
361#endif /* CONFIG_NATIVE_WINDOWS */
362 eloop_register_signal_terminate(handle_term, interfaces);
363
364#ifndef CONFIG_NATIVE_WINDOWS
365 openlog("hostapd", 0, LOG_DAEMON);
366#endif /* CONFIG_NATIVE_WINDOWS */
367
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800368 for (i = 0; wpa_drivers[i]; i++)
369 global.drv_count++;
370 if (global.drv_count == 0) {
371 wpa_printf(MSG_ERROR, "No drivers enabled");
372 return -1;
373 }
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700374 global.drv_priv = os_calloc(global.drv_count, sizeof(void *));
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800375 if (global.drv_priv == NULL)
376 return -1;
377
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700378 return 0;
379}
380
381
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700382static void hostapd_global_deinit(const char *pid_file, int eloop_initialized)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700383{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800384 int i;
385
386 for (i = 0; wpa_drivers[i] && global.drv_priv; i++) {
387 if (!global.drv_priv[i])
388 continue;
389 wpa_drivers[i]->global_deinit(global.drv_priv[i]);
390 }
391 os_free(global.drv_priv);
392 global.drv_priv = NULL;
393
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700394#ifdef EAP_SERVER_TNC
395 tncs_global_deinit();
396#endif /* EAP_SERVER_TNC */
397
398 random_deinit();
399
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700400 if (eloop_initialized)
401 eloop_destroy();
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700402
403#ifndef CONFIG_NATIVE_WINDOWS
404 closelog();
405#endif /* CONFIG_NATIVE_WINDOWS */
406
407 eap_server_unregister_methods();
408
409 os_daemonize_terminate(pid_file);
410}
411
412
413static int hostapd_global_run(struct hapd_interfaces *ifaces, int daemonize,
414 const char *pid_file)
415{
416#ifdef EAP_SERVER_TNC
417 int tnc = 0;
418 size_t i, k;
419
420 for (i = 0; !tnc && i < ifaces->count; i++) {
421 for (k = 0; k < ifaces->iface[i]->num_bss; k++) {
422 if (ifaces->iface[i]->bss[0]->conf->tnc) {
423 tnc++;
424 break;
425 }
426 }
427 }
428
429 if (tnc && tncs_global_init() < 0) {
430 wpa_printf(MSG_ERROR, "Failed to initialize TNCS");
431 return -1;
432 }
433#endif /* EAP_SERVER_TNC */
434
Dmitry Shmidtb97e4282016-02-08 10:16:07 -0800435 if (daemonize) {
436 if (os_daemonize(pid_file)) {
437 wpa_printf(MSG_ERROR, "daemon: %s", strerror(errno));
438 return -1;
439 }
440 if (eloop_sock_requeue()) {
441 wpa_printf(MSG_ERROR, "eloop_sock_requeue: %s",
442 strerror(errno));
443 return -1;
444 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700445 }
446
447 eloop_run();
448
449 return 0;
450}
451
452
453static void show_version(void)
454{
455 fprintf(stderr,
Hai Shalomfdcde762020-04-02 11:19:20 -0700456 "hostapd v%s\n"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700457 "User space daemon for IEEE 802.11 AP management,\n"
458 "IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator\n"
Hai Shalom74f70d42019-02-11 14:42:39 -0800459 "Copyright (c) 2002-2019, Jouni Malinen <j@w1.fi> "
Hai Shalomfdcde762020-04-02 11:19:20 -0700460 "and contributors\n",
461 VERSION_STR);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700462}
463
464
465static void usage(void)
466{
467 show_version();
468 fprintf(stderr,
469 "\n"
Jouni Malinen75ecf522011-06-27 15:19:46 -0700470 "usage: hostapd [-hdBKtv] [-P <PID file>] [-e <entropy file>] "
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700471 "\\\n"
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700472 " [-g <global ctrl_iface>] [-G <group>]\\\n"
473 " [-i <comma-separated list of interface names>]\\\n"
Dmitry Shmidt0ccb66e2013-03-29 16:41:28 -0700474 " <configuration file(s)>\n"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700475 "\n"
476 "options:\n"
477 " -h show this usage\n"
478 " -d show more debug messages (-dd for even more)\n"
479 " -B run daemon in the background\n"
Jouni Malinen75ecf522011-06-27 15:19:46 -0700480 " -e entropy file\n"
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700481 " -g global control interface path\n"
Dmitry Shmidt0ccb66e2013-03-29 16:41:28 -0700482 " -G group for control interfaces\n"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700483 " -P PID file\n"
484 " -K include key data in debug messages\n"
485#ifdef CONFIG_DEBUG_FILE
486 " -f log output to debug file instead of stdout\n"
487#endif /* CONFIG_DEBUG_FILE */
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800488#ifdef CONFIG_DEBUG_LINUX_TRACING
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800489 " -T record to Linux tracing in addition to logging\n"
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800490 " (records all messages regardless of debug verbosity)\n"
491#endif /* CONFIG_DEBUG_LINUX_TRACING */
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700492 " -i list of interface names to use\n"
Paul Stewart092955c2017-02-06 09:13:09 -0800493#ifdef CONFIG_DEBUG_SYSLOG
494 " -s log output to syslog instead of stdout\n"
495#endif /* CONFIG_DEBUG_SYSLOG */
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800496 " -S start all the interfaces synchronously\n"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700497 " -t include timestamps in some debug messages\n"
498 " -v show hostapd version\n");
499
500 exit(1);
501}
502
503
504static const char * hostapd_msg_ifname_cb(void *ctx)
505{
506 struct hostapd_data *hapd = ctx;
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800507 if (hapd && hapd->conf)
508 return hapd->conf->iface;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700509 return NULL;
510}
511
512
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700513static int hostapd_get_global_ctrl_iface(struct hapd_interfaces *interfaces,
514 const char *path)
515{
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800516#ifndef CONFIG_CTRL_IFACE_UDP
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700517 char *pos;
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800518#endif /* !CONFIG_CTRL_IFACE_UDP */
519
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700520 os_free(interfaces->global_iface_path);
521 interfaces->global_iface_path = os_strdup(path);
522 if (interfaces->global_iface_path == NULL)
523 return -1;
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800524
525#ifndef CONFIG_CTRL_IFACE_UDP
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700526 pos = os_strrchr(interfaces->global_iface_path, '/');
527 if (pos == NULL) {
Dmitry Shmidt1e78e762013-04-02 11:05:36 -0700528 wpa_printf(MSG_ERROR, "No '/' in the global control interface "
529 "file");
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700530 os_free(interfaces->global_iface_path);
531 interfaces->global_iface_path = NULL;
532 return -1;
533 }
534
535 *pos = '\0';
536 interfaces->global_iface_name = pos + 1;
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800537#endif /* !CONFIG_CTRL_IFACE_UDP */
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700538
539 return 0;
540}
541
542
Dmitry Shmidt0ccb66e2013-03-29 16:41:28 -0700543static int hostapd_get_ctrl_iface_group(struct hapd_interfaces *interfaces,
544 const char *group)
545{
546#ifndef CONFIG_NATIVE_WINDOWS
547 struct group *grp;
548 grp = getgrnam(group);
549 if (grp == NULL) {
550 wpa_printf(MSG_ERROR, "Unknown group '%s'", group);
551 return -1;
552 }
553 interfaces->ctrl_iface_group = grp->gr_gid;
554#endif /* CONFIG_NATIVE_WINDOWS */
555 return 0;
556}
557
558
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700559static int hostapd_get_interface_names(char ***if_names,
560 size_t *if_names_size,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800561 char *arg)
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700562{
563 char *if_name, *tmp, **nnames;
564 size_t i;
565
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800566 if (!arg)
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700567 return -1;
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800568 if_name = strtok_r(arg, ",", &tmp);
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700569
570 while (if_name) {
571 nnames = os_realloc_array(*if_names, 1 + *if_names_size,
572 sizeof(char *));
573 if (!nnames)
574 goto fail;
575 *if_names = nnames;
576
577 (*if_names)[*if_names_size] = os_strdup(if_name);
578 if (!(*if_names)[*if_names_size])
579 goto fail;
580 (*if_names_size)++;
581 if_name = strtok_r(NULL, ",", &tmp);
582 }
583
584 return 0;
585
586fail:
587 for (i = 0; i < *if_names_size; i++)
588 os_free((*if_names)[i]);
589 os_free(*if_names);
590 *if_names = NULL;
591 *if_names_size = 0;
592 return -1;
593}
594
595
Dmitry Shmidt96be6222014-02-13 10:16:51 -0800596#ifdef CONFIG_WPS
597static int gen_uuid(const char *txt_addr)
598{
599 u8 addr[ETH_ALEN];
600 u8 uuid[UUID_LEN];
601 char buf[100];
602
603 if (hwaddr_aton(txt_addr, addr) < 0)
604 return -1;
605
606 uuid_gen_mac_addr(addr, uuid);
607 if (uuid_bin2str(uuid, buf, sizeof(buf)) < 0)
608 return -1;
609
610 printf("%s\n", buf);
611
612 return 0;
613}
614#endif /* CONFIG_WPS */
615
616
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800617#ifndef HOSTAPD_CLEANUP_INTERVAL
618#define HOSTAPD_CLEANUP_INTERVAL 10
619#endif /* HOSTAPD_CLEANUP_INTERVAL */
620
621static int hostapd_periodic_call(struct hostapd_iface *iface, void *ctx)
622{
623 hostapd_periodic_iface(iface);
624 return 0;
625}
626
627
628/* Periodic cleanup tasks */
629static void hostapd_periodic(void *eloop_ctx, void *timeout_ctx)
630{
631 struct hapd_interfaces *interfaces = eloop_ctx;
632
633 eloop_register_timeout(HOSTAPD_CLEANUP_INTERVAL, 0,
634 hostapd_periodic, interfaces, NULL);
635 hostapd_for_each_interface(interfaces, hostapd_periodic_call, NULL);
636}
637
638
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700639int main(int argc, char *argv[])
640{
641 struct hapd_interfaces interfaces;
642 int ret = 1;
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800643 size_t i, j;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700644 int c, debug = 0, daemonize = 0;
645 char *pid_file = NULL;
646 const char *log_file = NULL;
Jouni Malinen75ecf522011-06-27 15:19:46 -0700647 const char *entropy_file = NULL;
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800648 char **bss_config = NULL, **tmp_bss;
649 size_t num_bss_configs = 0;
650#ifdef CONFIG_DEBUG_LINUX_TRACING
651 int enable_trace_dbg = 0;
652#endif /* CONFIG_DEBUG_LINUX_TRACING */
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800653 int start_ifaces_in_sync = 0;
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700654 char **if_names = NULL;
655 size_t if_names_size = 0;
Hai Shalom81f62d82019-07-22 12:10:00 -0700656#ifdef CONFIG_DPP
657 struct dpp_global_config dpp_conf;
658#endif /* CONFIG_DPP */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700659
660 if (os_program_init())
661 return -1;
662
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700663 os_memset(&interfaces, 0, sizeof(interfaces));
664 interfaces.reload_config = hostapd_reload_config;
665 interfaces.config_read_cb = hostapd_config_read;
666 interfaces.for_each_interface = hostapd_for_each_interface;
667 interfaces.ctrl_iface_init = hostapd_ctrl_iface_init;
668 interfaces.ctrl_iface_deinit = hostapd_ctrl_iface_deinit;
669 interfaces.driver_init = hostapd_driver_init;
670 interfaces.global_iface_path = NULL;
671 interfaces.global_iface_name = NULL;
672 interfaces.global_ctrl_sock = -1;
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800673 dl_list_init(&interfaces.global_ctrl_dst);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700674#ifdef CONFIG_ETH_P_OUI
675 dl_list_init(&interfaces.eth_p_oui);
676#endif /* CONFIG_ETH_P_OUI */
Roshan Pius3a1667e2018-07-03 15:17:14 -0700677#ifdef CONFIG_DPP
Hai Shalom81f62d82019-07-22 12:10:00 -0700678 os_memset(&dpp_conf, 0, sizeof(dpp_conf));
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700679 dpp_conf.cb_ctx = &interfaces;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700680#ifdef CONFIG_DPP2
681 dpp_conf.remove_bi = hostapd_dpp_remove_bi;
682#endif /* CONFIG_DPP2 */
Hai Shalom81f62d82019-07-22 12:10:00 -0700683 interfaces.dpp = dpp_global_init(&dpp_conf);
Hai Shalom021b0b52019-04-10 11:17:58 -0700684 if (!interfaces.dpp)
685 return -1;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700686#endif /* CONFIG_DPP */
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700687
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700688 for (;;) {
Paul Stewart092955c2017-02-06 09:13:09 -0800689 c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:vg:G:");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700690 if (c < 0)
691 break;
692 switch (c) {
693 case 'h':
694 usage();
695 break;
696 case 'd':
697 debug++;
698 if (wpa_debug_level > 0)
699 wpa_debug_level--;
700 break;
701 case 'B':
702 daemonize++;
703 break;
Jouni Malinen75ecf522011-06-27 15:19:46 -0700704 case 'e':
705 entropy_file = optarg;
706 break;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700707 case 'f':
708 log_file = optarg;
709 break;
710 case 'K':
711 wpa_debug_show_keys++;
712 break;
713 case 'P':
714 os_free(pid_file);
715 pid_file = os_rel2abs_path(optarg);
716 break;
717 case 't':
718 wpa_debug_timestamp++;
719 break;
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800720#ifdef CONFIG_DEBUG_LINUX_TRACING
721 case 'T':
722 enable_trace_dbg = 1;
723 break;
724#endif /* CONFIG_DEBUG_LINUX_TRACING */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700725 case 'v':
726 show_version();
727 exit(1);
728 break;
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700729 case 'g':
Dmitry Shmidt1e78e762013-04-02 11:05:36 -0700730 if (hostapd_get_global_ctrl_iface(&interfaces, optarg))
731 return -1;
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700732 break;
Dmitry Shmidt0ccb66e2013-03-29 16:41:28 -0700733 case 'G':
Dmitry Shmidt1e78e762013-04-02 11:05:36 -0700734 if (hostapd_get_ctrl_iface_group(&interfaces, optarg))
735 return -1;
Dmitry Shmidt0ccb66e2013-03-29 16:41:28 -0700736 break;
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800737 case 'b':
738 tmp_bss = os_realloc_array(bss_config,
739 num_bss_configs + 1,
740 sizeof(char *));
741 if (tmp_bss == NULL)
742 goto out;
743 bss_config = tmp_bss;
744 bss_config[num_bss_configs++] = optarg;
745 break;
Paul Stewart092955c2017-02-06 09:13:09 -0800746#ifdef CONFIG_DEBUG_SYSLOG
747 case 's':
748 wpa_debug_syslog = 1;
749 break;
750#endif /* CONFIG_DEBUG_SYSLOG */
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800751 case 'S':
752 start_ifaces_in_sync = 1;
753 break;
Dmitry Shmidt96be6222014-02-13 10:16:51 -0800754#ifdef CONFIG_WPS
755 case 'u':
756 return gen_uuid(optarg);
757#endif /* CONFIG_WPS */
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700758 case 'i':
759 if (hostapd_get_interface_names(&if_names,
760 &if_names_size, optarg))
761 goto out;
762 break;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700763 default:
764 usage();
765 break;
766 }
767 }
768
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000769#ifndef CONFIG_CTRL_IFACE_AIDL
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800770 if (optind == argc && interfaces.global_iface_path == NULL &&
771 num_bss_configs == 0)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700772 usage();
Roshan Piuscc817562017-12-22 14:45:05 -0800773#endif
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700774
775 wpa_msg_register_ifname_cb(hostapd_msg_ifname_cb);
776
777 if (log_file)
778 wpa_debug_open_file(log_file);
Hai Shalomfdcde762020-04-02 11:19:20 -0700779 if (!log_file && !wpa_debug_syslog)
Dmitry Shmidtfb45fd52015-01-05 13:08:17 -0800780 wpa_debug_setup_stdout();
Paul Stewart092955c2017-02-06 09:13:09 -0800781#ifdef CONFIG_DEBUG_SYSLOG
782 if (wpa_debug_syslog)
783 wpa_debug_open_syslog();
784#endif /* CONFIG_DEBUG_SYSLOG */
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800785#ifdef CONFIG_DEBUG_LINUX_TRACING
786 if (enable_trace_dbg) {
787 int tret = wpa_debug_open_linux_tracing();
788 if (tret) {
789 wpa_printf(MSG_ERROR, "Failed to enable trace logging");
790 return -1;
791 }
792 }
793#endif /* CONFIG_DEBUG_LINUX_TRACING */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700794
795 interfaces.count = argc - optind;
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800796 if (interfaces.count || num_bss_configs) {
797 interfaces.iface = os_calloc(interfaces.count + num_bss_configs,
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700798 sizeof(struct hostapd_iface *));
799 if (interfaces.iface == NULL) {
800 wpa_printf(MSG_ERROR, "malloc failed");
801 return -1;
802 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700803 }
804
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700805 if (hostapd_global_init(&interfaces, entropy_file)) {
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700806 wpa_printf(MSG_ERROR, "Failed to initialize global context");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700807 return -1;
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700808 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700809
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800810 eloop_register_timeout(HOSTAPD_CLEANUP_INTERVAL, 0,
811 hostapd_periodic, &interfaces, NULL);
812
813 if (fst_global_init()) {
814 wpa_printf(MSG_ERROR,
815 "Failed to initialize global FST context");
816 goto out;
817 }
818
819#if defined(CONFIG_FST) && defined(CONFIG_CTRL_IFACE)
820 if (!fst_global_add_ctrl(fst_ctrl_cli))
821 wpa_printf(MSG_WARNING, "Failed to add CLI FST ctrl");
822#endif /* CONFIG_FST && CONFIG_CTRL_IFACE */
823
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800824 /* Allocate and parse configuration for full interface files */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700825 for (i = 0; i < interfaces.count; i++) {
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700826 char *if_name = NULL;
827
828 if (i < if_names_size)
829 if_name = if_names[i];
830
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700831 interfaces.iface[i] = hostapd_interface_init(&interfaces,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700832 if_name,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700833 argv[optind + i],
834 debug);
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700835 if (!interfaces.iface[i]) {
836 wpa_printf(MSG_ERROR, "Failed to initialize interface");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700837 goto out;
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700838 }
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800839 if (start_ifaces_in_sync)
840 interfaces.iface[i]->need_to_start_in_sync = 1;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700841 }
842
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800843 /* Allocate and parse configuration for per-BSS files */
844 for (i = 0; i < num_bss_configs; i++) {
845 struct hostapd_iface *iface;
846 char *fname;
847
848 wpa_printf(MSG_INFO, "BSS config: %s", bss_config[i]);
849 fname = os_strchr(bss_config[i], ':');
850 if (fname == NULL) {
851 wpa_printf(MSG_ERROR,
852 "Invalid BSS config identifier '%s'",
853 bss_config[i]);
854 goto out;
855 }
856 *fname++ = '\0';
857 iface = hostapd_interface_init_bss(&interfaces, bss_config[i],
858 fname, debug);
859 if (iface == NULL)
860 goto out;
861 for (j = 0; j < interfaces.count; j++) {
862 if (interfaces.iface[j] == iface)
863 break;
864 }
865 if (j == interfaces.count) {
866 struct hostapd_iface **tmp;
867 tmp = os_realloc_array(interfaces.iface,
868 interfaces.count + 1,
869 sizeof(struct hostapd_iface *));
870 if (tmp == NULL) {
871 hostapd_interface_deinit_free(iface);
872 goto out;
873 }
874 interfaces.iface = tmp;
875 interfaces.iface[interfaces.count++] = iface;
876 }
877 }
878
879 /*
880 * Enable configured interfaces. Depending on channel configuration,
881 * this may complete full initialization before returning or use a
882 * callback mechanism to complete setup in case of operations like HT
883 * co-ex scans, ACS, or DFS are needed to determine channel parameters.
884 * In such case, the interface will be enabled from eloop context within
885 * hostapd_global_run().
886 */
Dmitry Shmidtb96dad42013-11-05 10:07:29 -0800887 interfaces.terminate_on_error = interfaces.count;
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800888 for (i = 0; i < interfaces.count; i++) {
Hai Shalom74f70d42019-02-11 14:42:39 -0800889 if (hostapd_driver_init(interfaces.iface[i]) ||
890 hostapd_setup_interface(interfaces.iface[i]))
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800891 goto out;
892 }
893
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000894#ifdef CONFIG_CTRL_IFACE_AIDL
895 if (hostapd_aidl_init(&interfaces)) {
896 wpa_printf(MSG_ERROR, "Failed to initialize AIDL interface");
Roshan Piuscc817562017-12-22 14:45:05 -0800897 goto out;
898 }
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000899#endif /* CONFIG_CTRL_IFACE_AIDL */
Daichi Ueuracaa74a82018-02-14 22:25:39 +0900900 hostapd_global_ctrl_iface_init(&interfaces);
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700901
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700902 if (hostapd_global_run(&interfaces, daemonize, pid_file)) {
903 wpa_printf(MSG_ERROR, "Failed to start eloop");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700904 goto out;
Dmitry Shmidt4b060592013-04-29 16:42:49 -0700905 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700906
907 ret = 0;
908
909 out:
Gabriel Biren72cf9a52021-06-25 23:29:26 +0000910#ifdef CONFIG_CTRL_IFACE_AIDL
911 hostapd_aidl_deinit(&interfaces);
912#endif /* CONFIG_CTRL_IFACE_AIDL */
Daichi Ueuracaa74a82018-02-14 22:25:39 +0900913 hostapd_global_ctrl_iface_deinit(&interfaces);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700914 /* Deinitialize all interfaces */
Dmitry Shmidta38abf92014-03-06 13:38:44 -0800915 for (i = 0; i < interfaces.count; i++) {
Dmitry Shmidt818ea482014-03-10 13:15:21 -0700916 if (!interfaces.iface[i])
917 continue;
Dmitry Shmidta38abf92014-03-06 13:38:44 -0800918 interfaces.iface[i]->driver_ap_teardown =
919 !!(interfaces.iface[i]->drv_flags &
920 WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700921 hostapd_interface_deinit_free(interfaces.iface[i]);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700922 interfaces.iface[i] = NULL;
Dmitry Shmidta38abf92014-03-06 13:38:44 -0800923 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700924 os_free(interfaces.iface);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700925 interfaces.iface = NULL;
926 interfaces.count = 0;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700927
Roshan Pius3a1667e2018-07-03 15:17:14 -0700928#ifdef CONFIG_DPP
Hai Shalom021b0b52019-04-10 11:17:58 -0700929 dpp_global_deinit(interfaces.dpp);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700930#endif /* CONFIG_DPP */
931
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700932 if (interfaces.eloop_initialized)
933 eloop_cancel_timeout(hostapd_periodic, &interfaces, NULL);
934 hostapd_global_deinit(pid_file, interfaces.eloop_initialized);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700935 os_free(pid_file);
936
Paul Stewart092955c2017-02-06 09:13:09 -0800937 wpa_debug_close_syslog();
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700938 if (log_file)
939 wpa_debug_close_file();
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800940 wpa_debug_close_linux_tracing();
941
942 os_free(bss_config);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700943
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700944 for (i = 0; i < if_names_size; i++)
945 os_free(if_names[i]);
946 os_free(if_names);
947
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800948 fst_global_deinit();
949
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700950 os_program_deinit();
951
952 return ret;
953}