]> git.ipfire.org Git - thirdparty/hostap.git/blob - hostapd/main.c
d1a54ce54da0fde81ba6ec55dcb743f8879b8e13
[thirdparty/hostap.git] / hostapd / main.c
1 /*
2 * hostapd / main()
3 * Copyright (c) 2002-2011, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9 #include "utils/includes.h"
10 #ifndef CONFIG_NATIVE_WINDOWS
11 #include <syslog.h>
12 #include <grp.h>
13 #endif /* CONFIG_NATIVE_WINDOWS */
14
15 #include "utils/common.h"
16 #include "utils/eloop.h"
17 #include "utils/uuid.h"
18 #include "crypto/random.h"
19 #include "crypto/tls.h"
20 #include "common/version.h"
21 #include "drivers/driver.h"
22 #include "eap_server/eap.h"
23 #include "eap_server/tncs.h"
24 #include "ap/hostapd.h"
25 #include "ap/ap_config.h"
26 #include "ap/ap_drv_ops.h"
27 #include "config_file.h"
28 #include "eap_register.h"
29 #include "ctrl_iface.h"
30
31
32 struct hapd_global {
33 void **drv_priv;
34 size_t drv_count;
35 };
36
37 static struct hapd_global global;
38
39
40 #ifndef CONFIG_NO_HOSTAPD_LOGGER
41 static void hostapd_logger_cb(void *ctx, const u8 *addr, unsigned int module,
42 int level, const char *txt, size_t len)
43 {
44 struct hostapd_data *hapd = ctx;
45 char *format, *module_str;
46 int maxlen;
47 int conf_syslog_level, conf_stdout_level;
48 unsigned int conf_syslog, conf_stdout;
49
50 maxlen = len + 100;
51 format = os_malloc(maxlen);
52 if (!format)
53 return;
54
55 if (hapd && hapd->conf) {
56 conf_syslog_level = hapd->conf->logger_syslog_level;
57 conf_stdout_level = hapd->conf->logger_stdout_level;
58 conf_syslog = hapd->conf->logger_syslog;
59 conf_stdout = hapd->conf->logger_stdout;
60 } else {
61 conf_syslog_level = conf_stdout_level = 0;
62 conf_syslog = conf_stdout = (unsigned int) -1;
63 }
64
65 switch (module) {
66 case HOSTAPD_MODULE_IEEE80211:
67 module_str = "IEEE 802.11";
68 break;
69 case HOSTAPD_MODULE_IEEE8021X:
70 module_str = "IEEE 802.1X";
71 break;
72 case HOSTAPD_MODULE_RADIUS:
73 module_str = "RADIUS";
74 break;
75 case HOSTAPD_MODULE_WPA:
76 module_str = "WPA";
77 break;
78 case HOSTAPD_MODULE_DRIVER:
79 module_str = "DRIVER";
80 break;
81 case HOSTAPD_MODULE_IAPP:
82 module_str = "IAPP";
83 break;
84 case HOSTAPD_MODULE_MLME:
85 module_str = "MLME";
86 break;
87 default:
88 module_str = NULL;
89 break;
90 }
91
92 if (hapd && hapd->conf && addr)
93 os_snprintf(format, maxlen, "%s: STA " MACSTR "%s%s: %s",
94 hapd->conf->iface, MAC2STR(addr),
95 module_str ? " " : "", module_str ? module_str : "",
96 txt);
97 else if (hapd && hapd->conf)
98 os_snprintf(format, maxlen, "%s:%s%s %s",
99 hapd->conf->iface, module_str ? " " : "",
100 module_str ? module_str : "", txt);
101 else if (addr)
102 os_snprintf(format, maxlen, "STA " MACSTR "%s%s: %s",
103 MAC2STR(addr), module_str ? " " : "",
104 module_str ? module_str : "", txt);
105 else
106 os_snprintf(format, maxlen, "%s%s%s",
107 module_str ? module_str : "",
108 module_str ? ": " : "", txt);
109
110 if ((conf_stdout & module) && level >= conf_stdout_level) {
111 wpa_debug_print_timestamp();
112 wpa_printf(MSG_INFO, "%s", format);
113 }
114
115 #ifndef CONFIG_NATIVE_WINDOWS
116 if ((conf_syslog & module) && level >= conf_syslog_level) {
117 int priority;
118 switch (level) {
119 case HOSTAPD_LEVEL_DEBUG_VERBOSE:
120 case HOSTAPD_LEVEL_DEBUG:
121 priority = LOG_DEBUG;
122 break;
123 case HOSTAPD_LEVEL_INFO:
124 priority = LOG_INFO;
125 break;
126 case HOSTAPD_LEVEL_NOTICE:
127 priority = LOG_NOTICE;
128 break;
129 case HOSTAPD_LEVEL_WARNING:
130 priority = LOG_WARNING;
131 break;
132 default:
133 priority = LOG_INFO;
134 break;
135 }
136 syslog(priority, "%s", format);
137 }
138 #endif /* CONFIG_NATIVE_WINDOWS */
139
140 os_free(format);
141 }
142 #endif /* CONFIG_NO_HOSTAPD_LOGGER */
143
144
145 /**
146 * hostapd_driver_init - Preparate driver interface
147 */
148 static int hostapd_driver_init(struct hostapd_iface *iface)
149 {
150 struct wpa_init_params params;
151 size_t i;
152 struct hostapd_data *hapd = iface->bss[0];
153 struct hostapd_bss_config *conf = hapd->conf;
154 u8 *b = conf->bssid;
155 struct wpa_driver_capa capa;
156
157 if (hapd->driver == NULL || hapd->driver->hapd_init == NULL) {
158 wpa_printf(MSG_ERROR, "No hostapd driver wrapper available");
159 return -1;
160 }
161
162 /* Initialize the driver interface */
163 if (!(b[0] | b[1] | b[2] | b[3] | b[4] | b[5]))
164 b = NULL;
165
166 os_memset(&params, 0, sizeof(params));
167 for (i = 0; wpa_drivers[i]; i++) {
168 if (wpa_drivers[i] != hapd->driver)
169 continue;
170
171 if (global.drv_priv[i] == NULL &&
172 wpa_drivers[i]->global_init) {
173 global.drv_priv[i] = wpa_drivers[i]->global_init();
174 if (global.drv_priv[i] == NULL) {
175 wpa_printf(MSG_ERROR, "Failed to initialize "
176 "driver '%s'",
177 wpa_drivers[i]->name);
178 return -1;
179 }
180 }
181
182 params.global_priv = global.drv_priv[i];
183 break;
184 }
185 params.bssid = b;
186 params.ifname = hapd->conf->iface;
187 params.use_pae_group_addr = hapd->conf->use_pae_group_addr;
188
189 params.num_bridge = hapd->iface->num_bss;
190 params.bridge = os_calloc(hapd->iface->num_bss, sizeof(char *));
191 if (params.bridge == NULL)
192 return -1;
193 for (i = 0; i < hapd->iface->num_bss; i++) {
194 struct hostapd_data *bss = hapd->iface->bss[i];
195 if (bss->conf->bridge[0])
196 params.bridge[i] = bss->conf->bridge;
197 }
198
199 params.own_addr = hapd->own_addr;
200
201 hapd->drv_priv = hapd->driver->hapd_init(hapd, &params);
202 os_free(params.bridge);
203 if (hapd->drv_priv == NULL) {
204 wpa_printf(MSG_ERROR, "%s driver initialization failed.",
205 hapd->driver->name);
206 hapd->driver = NULL;
207 return -1;
208 }
209
210 if (hapd->driver->get_capa &&
211 hapd->driver->get_capa(hapd->drv_priv, &capa) == 0) {
212 struct wowlan_triggers *triggs;
213
214 iface->drv_flags = capa.flags;
215 iface->smps_modes = capa.smps_modes;
216 iface->probe_resp_offloads = capa.probe_resp_offloads;
217 iface->extended_capa = capa.extended_capa;
218 iface->extended_capa_mask = capa.extended_capa_mask;
219 iface->extended_capa_len = capa.extended_capa_len;
220 iface->drv_max_acl_mac_addrs = capa.max_acl_mac_addrs;
221
222 triggs = wpa_get_wowlan_triggers(conf->wowlan_triggers, &capa);
223 if (triggs && hapd->driver->set_wowlan) {
224 if (hapd->driver->set_wowlan(hapd->drv_priv, triggs))
225 wpa_printf(MSG_ERROR, "set_wowlan failed");
226 }
227 os_free(triggs);
228 }
229
230 return 0;
231 }
232
233
234 /**
235 * hostapd_interface_init - Read configuration file and init BSS data
236 *
237 * This function is used to parse configuration file for a full interface (one
238 * or more BSSes sharing the same radio) and allocate memory for the BSS
239 * interfaces. No actiual driver operations are started.
240 */
241 static struct hostapd_iface *
242 hostapd_interface_init(struct hapd_interfaces *interfaces,
243 const char *config_fname, int debug)
244 {
245 struct hostapd_iface *iface;
246 int k;
247
248 wpa_printf(MSG_ERROR, "Configuration file: %s", config_fname);
249 iface = hostapd_init(interfaces, config_fname);
250 if (!iface)
251 return NULL;
252 iface->interfaces = interfaces;
253
254 for (k = 0; k < debug; k++) {
255 if (iface->bss[0]->conf->logger_stdout_level > 0)
256 iface->bss[0]->conf->logger_stdout_level--;
257 }
258
259 if (iface->conf->bss[0]->iface[0] == '\0' &&
260 !hostapd_drv_none(iface->bss[0])) {
261 wpa_printf(MSG_ERROR, "Interface name not specified in %s",
262 config_fname);
263 hostapd_interface_deinit_free(iface);
264 return NULL;
265 }
266
267 return iface;
268 }
269
270
271 /**
272 * handle_term - SIGINT and SIGTERM handler to terminate hostapd process
273 */
274 static void handle_term(int sig, void *signal_ctx)
275 {
276 wpa_printf(MSG_DEBUG, "Signal %d received - terminating", sig);
277 eloop_terminate();
278 }
279
280
281 #ifndef CONFIG_NATIVE_WINDOWS
282
283 static int handle_reload_iface(struct hostapd_iface *iface, void *ctx)
284 {
285 if (hostapd_reload_config(iface) < 0) {
286 wpa_printf(MSG_WARNING, "Failed to read new configuration "
287 "file - continuing with old.");
288 }
289 return 0;
290 }
291
292
293 /**
294 * handle_reload - SIGHUP handler to reload configuration
295 */
296 static void handle_reload(int sig, void *signal_ctx)
297 {
298 struct hapd_interfaces *interfaces = signal_ctx;
299 wpa_printf(MSG_DEBUG, "Signal %d received - reloading configuration",
300 sig);
301 hostapd_for_each_interface(interfaces, handle_reload_iface, NULL);
302 }
303
304
305 static void handle_dump_state(int sig, void *signal_ctx)
306 {
307 /* Not used anymore - ignore signal */
308 }
309 #endif /* CONFIG_NATIVE_WINDOWS */
310
311
312 static int hostapd_global_init(struct hapd_interfaces *interfaces,
313 const char *entropy_file)
314 {
315 int i;
316
317 os_memset(&global, 0, sizeof(global));
318
319 hostapd_logger_register_cb(hostapd_logger_cb);
320
321 if (eap_server_register_methods()) {
322 wpa_printf(MSG_ERROR, "Failed to register EAP methods");
323 return -1;
324 }
325
326 if (eloop_init()) {
327 wpa_printf(MSG_ERROR, "Failed to initialize event loop");
328 return -1;
329 }
330
331 random_init(entropy_file);
332
333 #ifndef CONFIG_NATIVE_WINDOWS
334 eloop_register_signal(SIGHUP, handle_reload, interfaces);
335 eloop_register_signal(SIGUSR1, handle_dump_state, interfaces);
336 #endif /* CONFIG_NATIVE_WINDOWS */
337 eloop_register_signal_terminate(handle_term, interfaces);
338
339 #ifndef CONFIG_NATIVE_WINDOWS
340 openlog("hostapd", 0, LOG_DAEMON);
341 #endif /* CONFIG_NATIVE_WINDOWS */
342
343 for (i = 0; wpa_drivers[i]; i++)
344 global.drv_count++;
345 if (global.drv_count == 0) {
346 wpa_printf(MSG_ERROR, "No drivers enabled");
347 return -1;
348 }
349 global.drv_priv = os_calloc(global.drv_count, sizeof(void *));
350 if (global.drv_priv == NULL)
351 return -1;
352
353 return 0;
354 }
355
356
357 static void hostapd_global_deinit(const char *pid_file)
358 {
359 int i;
360
361 for (i = 0; wpa_drivers[i] && global.drv_priv; i++) {
362 if (!global.drv_priv[i])
363 continue;
364 wpa_drivers[i]->global_deinit(global.drv_priv[i]);
365 }
366 os_free(global.drv_priv);
367 global.drv_priv = NULL;
368
369 #ifdef EAP_SERVER_TNC
370 tncs_global_deinit();
371 #endif /* EAP_SERVER_TNC */
372
373 random_deinit();
374
375 eloop_destroy();
376
377 #ifndef CONFIG_NATIVE_WINDOWS
378 closelog();
379 #endif /* CONFIG_NATIVE_WINDOWS */
380
381 eap_server_unregister_methods();
382
383 os_daemonize_terminate(pid_file);
384 }
385
386
387 static int hostapd_global_run(struct hapd_interfaces *ifaces, int daemonize,
388 const char *pid_file)
389 {
390 #ifdef EAP_SERVER_TNC
391 int tnc = 0;
392 size_t i, k;
393
394 for (i = 0; !tnc && i < ifaces->count; i++) {
395 for (k = 0; k < ifaces->iface[i]->num_bss; k++) {
396 if (ifaces->iface[i]->bss[0]->conf->tnc) {
397 tnc++;
398 break;
399 }
400 }
401 }
402
403 if (tnc && tncs_global_init() < 0) {
404 wpa_printf(MSG_ERROR, "Failed to initialize TNCS");
405 return -1;
406 }
407 #endif /* EAP_SERVER_TNC */
408
409 if (daemonize && os_daemonize(pid_file)) {
410 perror("daemon");
411 return -1;
412 }
413
414 eloop_run();
415
416 return 0;
417 }
418
419
420 static void show_version(void)
421 {
422 fprintf(stderr,
423 "hostapd v" VERSION_STR "\n"
424 "User space daemon for IEEE 802.11 AP management,\n"
425 "IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator\n"
426 "Copyright (c) 2002-2014, Jouni Malinen <j@w1.fi> "
427 "and contributors\n");
428 }
429
430
431 static void usage(void)
432 {
433 show_version();
434 fprintf(stderr,
435 "\n"
436 "usage: hostapd [-hdBKtv] [-P <PID file>] [-e <entropy file>] "
437 "\\\n"
438 " [-g <global ctrl_iface>] [-G <group>] \\\n"
439 " <configuration file(s)>\n"
440 "\n"
441 "options:\n"
442 " -h show this usage\n"
443 " -d show more debug messages (-dd for even more)\n"
444 " -B run daemon in the background\n"
445 " -e entropy file\n"
446 " -g global control interface path\n"
447 " -G group for control interfaces\n"
448 " -P PID file\n"
449 " -K include key data in debug messages\n"
450 #ifdef CONFIG_DEBUG_FILE
451 " -f log output to debug file instead of stdout\n"
452 #endif /* CONFIG_DEBUG_FILE */
453 #ifdef CONFIG_DEBUG_LINUX_TRACING
454 " -T = record to Linux tracing in addition to logging\n"
455 " (records all messages regardless of debug verbosity)\n"
456 #endif /* CONFIG_DEBUG_LINUX_TRACING */
457 " -t include timestamps in some debug messages\n"
458 " -v show hostapd version\n");
459
460 exit(1);
461 }
462
463
464 static const char * hostapd_msg_ifname_cb(void *ctx)
465 {
466 struct hostapd_data *hapd = ctx;
467 if (hapd && hapd->iconf && hapd->iconf->bss &&
468 hapd->iconf->num_bss > 0 && hapd->iconf->bss[0])
469 return hapd->iconf->bss[0]->iface;
470 return NULL;
471 }
472
473
474 static int hostapd_get_global_ctrl_iface(struct hapd_interfaces *interfaces,
475 const char *path)
476 {
477 char *pos;
478 os_free(interfaces->global_iface_path);
479 interfaces->global_iface_path = os_strdup(path);
480 if (interfaces->global_iface_path == NULL)
481 return -1;
482 pos = os_strrchr(interfaces->global_iface_path, '/');
483 if (pos == NULL) {
484 wpa_printf(MSG_ERROR, "No '/' in the global control interface "
485 "file");
486 os_free(interfaces->global_iface_path);
487 interfaces->global_iface_path = NULL;
488 return -1;
489 }
490
491 *pos = '\0';
492 interfaces->global_iface_name = pos + 1;
493
494 return 0;
495 }
496
497
498 static int hostapd_get_ctrl_iface_group(struct hapd_interfaces *interfaces,
499 const char *group)
500 {
501 #ifndef CONFIG_NATIVE_WINDOWS
502 struct group *grp;
503 grp = getgrnam(group);
504 if (grp == NULL) {
505 wpa_printf(MSG_ERROR, "Unknown group '%s'", group);
506 return -1;
507 }
508 interfaces->ctrl_iface_group = grp->gr_gid;
509 #endif /* CONFIG_NATIVE_WINDOWS */
510 return 0;
511 }
512
513
514 #ifdef CONFIG_WPS
515 static int gen_uuid(const char *txt_addr)
516 {
517 u8 addr[ETH_ALEN];
518 u8 uuid[UUID_LEN];
519 char buf[100];
520
521 if (hwaddr_aton(txt_addr, addr) < 0)
522 return -1;
523
524 uuid_gen_mac_addr(addr, uuid);
525 if (uuid_bin2str(uuid, buf, sizeof(buf)) < 0)
526 return -1;
527
528 printf("%s\n", buf);
529
530 return 0;
531 }
532 #endif /* CONFIG_WPS */
533
534
535 int main(int argc, char *argv[])
536 {
537 struct hapd_interfaces interfaces;
538 int ret = 1;
539 size_t i, j;
540 int c, debug = 0, daemonize = 0;
541 char *pid_file = NULL;
542 const char *log_file = NULL;
543 const char *entropy_file = NULL;
544 char **bss_config = NULL, **tmp_bss;
545 size_t num_bss_configs = 0;
546 #ifdef CONFIG_DEBUG_LINUX_TRACING
547 int enable_trace_dbg = 0;
548 #endif /* CONFIG_DEBUG_LINUX_TRACING */
549
550 if (os_program_init())
551 return -1;
552
553 os_memset(&interfaces, 0, sizeof(interfaces));
554 interfaces.reload_config = hostapd_reload_config;
555 interfaces.config_read_cb = hostapd_config_read;
556 interfaces.for_each_interface = hostapd_for_each_interface;
557 interfaces.ctrl_iface_init = hostapd_ctrl_iface_init;
558 interfaces.ctrl_iface_deinit = hostapd_ctrl_iface_deinit;
559 interfaces.driver_init = hostapd_driver_init;
560 interfaces.global_iface_path = NULL;
561 interfaces.global_iface_name = NULL;
562 interfaces.global_ctrl_sock = -1;
563
564 for (;;) {
565 c = getopt(argc, argv, "b:Bde:f:hKP:Ttu:vg:G:");
566 if (c < 0)
567 break;
568 switch (c) {
569 case 'h':
570 usage();
571 break;
572 case 'd':
573 debug++;
574 if (wpa_debug_level > 0)
575 wpa_debug_level--;
576 break;
577 case 'B':
578 daemonize++;
579 break;
580 case 'e':
581 entropy_file = optarg;
582 break;
583 case 'f':
584 log_file = optarg;
585 break;
586 case 'K':
587 wpa_debug_show_keys++;
588 break;
589 case 'P':
590 os_free(pid_file);
591 pid_file = os_rel2abs_path(optarg);
592 break;
593 case 't':
594 wpa_debug_timestamp++;
595 break;
596 #ifdef CONFIG_DEBUG_LINUX_TRACING
597 case 'T':
598 enable_trace_dbg = 1;
599 break;
600 #endif /* CONFIG_DEBUG_LINUX_TRACING */
601 case 'v':
602 show_version();
603 exit(1);
604 break;
605 case 'g':
606 if (hostapd_get_global_ctrl_iface(&interfaces, optarg))
607 return -1;
608 break;
609 case 'G':
610 if (hostapd_get_ctrl_iface_group(&interfaces, optarg))
611 return -1;
612 break;
613 case 'b':
614 tmp_bss = os_realloc_array(bss_config,
615 num_bss_configs + 1,
616 sizeof(char *));
617 if (tmp_bss == NULL)
618 goto out;
619 bss_config = tmp_bss;
620 bss_config[num_bss_configs++] = optarg;
621 break;
622 #ifdef CONFIG_WPS
623 case 'u':
624 return gen_uuid(optarg);
625 #endif /* CONFIG_WPS */
626 default:
627 usage();
628 break;
629 }
630 }
631
632 if (optind == argc && interfaces.global_iface_path == NULL &&
633 num_bss_configs == 0)
634 usage();
635
636 wpa_msg_register_ifname_cb(hostapd_msg_ifname_cb);
637
638 if (log_file)
639 wpa_debug_open_file(log_file);
640 #ifdef CONFIG_DEBUG_LINUX_TRACING
641 if (enable_trace_dbg) {
642 int tret = wpa_debug_open_linux_tracing();
643 if (tret) {
644 wpa_printf(MSG_ERROR, "Failed to enable trace logging");
645 return -1;
646 }
647 }
648 #endif /* CONFIG_DEBUG_LINUX_TRACING */
649
650 interfaces.count = argc - optind;
651 if (interfaces.count || num_bss_configs) {
652 interfaces.iface = os_calloc(interfaces.count + num_bss_configs,
653 sizeof(struct hostapd_iface *));
654 if (interfaces.iface == NULL) {
655 wpa_printf(MSG_ERROR, "malloc failed");
656 return -1;
657 }
658 }
659
660 if (hostapd_global_init(&interfaces, entropy_file)) {
661 wpa_printf(MSG_ERROR, "Failed to initilize global context");
662 return -1;
663 }
664
665 /* Allocate and parse configuration for full interface files */
666 for (i = 0; i < interfaces.count; i++) {
667 interfaces.iface[i] = hostapd_interface_init(&interfaces,
668 argv[optind + i],
669 debug);
670 if (!interfaces.iface[i]) {
671 wpa_printf(MSG_ERROR, "Failed to initialize interface");
672 goto out;
673 }
674 }
675
676 /* Allocate and parse configuration for per-BSS files */
677 for (i = 0; i < num_bss_configs; i++) {
678 struct hostapd_iface *iface;
679 char *fname;
680
681 wpa_printf(MSG_INFO, "BSS config: %s", bss_config[i]);
682 fname = os_strchr(bss_config[i], ':');
683 if (fname == NULL) {
684 wpa_printf(MSG_ERROR,
685 "Invalid BSS config identifier '%s'",
686 bss_config[i]);
687 goto out;
688 }
689 *fname++ = '\0';
690 iface = hostapd_interface_init_bss(&interfaces, bss_config[i],
691 fname, debug);
692 if (iface == NULL)
693 goto out;
694 for (j = 0; j < interfaces.count; j++) {
695 if (interfaces.iface[j] == iface)
696 break;
697 }
698 if (j == interfaces.count) {
699 struct hostapd_iface **tmp;
700 tmp = os_realloc_array(interfaces.iface,
701 interfaces.count + 1,
702 sizeof(struct hostapd_iface *));
703 if (tmp == NULL) {
704 hostapd_interface_deinit_free(iface);
705 goto out;
706 }
707 interfaces.iface = tmp;
708 interfaces.iface[interfaces.count++] = iface;
709 }
710 }
711
712 /*
713 * Enable configured interfaces. Depending on channel configuration,
714 * this may complete full initialization before returning or use a
715 * callback mechanism to complete setup in case of operations like HT
716 * co-ex scans, ACS, or DFS are needed to determine channel parameters.
717 * In such case, the interface will be enabled from eloop context within
718 * hostapd_global_run().
719 */
720 interfaces.terminate_on_error = interfaces.count;
721 for (i = 0; i < interfaces.count; i++) {
722 if (hostapd_driver_init(interfaces.iface[i]) ||
723 hostapd_setup_interface(interfaces.iface[i]))
724 goto out;
725 }
726
727 hostapd_global_ctrl_iface_init(&interfaces);
728
729 if (hostapd_global_run(&interfaces, daemonize, pid_file)) {
730 wpa_printf(MSG_ERROR, "Failed to start eloop");
731 goto out;
732 }
733
734 ret = 0;
735
736 out:
737 hostapd_global_ctrl_iface_deinit(&interfaces);
738 /* Deinitialize all interfaces */
739 for (i = 0; i < interfaces.count; i++) {
740 if (!interfaces.iface[i])
741 continue;
742 interfaces.iface[i]->driver_ap_teardown =
743 !!(interfaces.iface[i]->drv_flags &
744 WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT);
745 hostapd_interface_deinit_free(interfaces.iface[i]);
746 }
747 os_free(interfaces.iface);
748
749 hostapd_global_deinit(pid_file);
750 os_free(pid_file);
751
752 if (log_file)
753 wpa_debug_close_file();
754 wpa_debug_close_linux_tracing();
755
756 os_free(bss_config);
757
758 os_program_deinit();
759
760 return ret;
761 }