3 * Copyright (c) 2002-2017, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
10 #ifndef CONFIG_NATIVE_WINDOWS
13 #endif /* CONFIG_NATIVE_WINDOWS */
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"
28 #include "config_file.h"
29 #include "eap_register.h"
30 #include "ctrl_iface.h"
38 static struct hapd_global global
;
41 #ifndef CONFIG_NO_HOSTAPD_LOGGER
42 static void hostapd_logger_cb(void *ctx
, const u8
*addr
, unsigned int module
,
43 int level
, const char *txt
, size_t len
)
45 struct hostapd_data
*hapd
= ctx
;
46 char *format
, *module_str
;
48 int conf_syslog_level
, conf_stdout_level
;
49 unsigned int conf_syslog
, conf_stdout
;
52 format
= os_malloc(maxlen
);
56 if (hapd
&& hapd
->conf
) {
57 conf_syslog_level
= hapd
->conf
->logger_syslog_level
;
58 conf_stdout_level
= hapd
->conf
->logger_stdout_level
;
59 conf_syslog
= hapd
->conf
->logger_syslog
;
60 conf_stdout
= hapd
->conf
->logger_stdout
;
62 conf_syslog_level
= conf_stdout_level
= 0;
63 conf_syslog
= conf_stdout
= (unsigned int) -1;
67 case HOSTAPD_MODULE_IEEE80211
:
68 module_str
= "IEEE 802.11";
70 case HOSTAPD_MODULE_IEEE8021X
:
71 module_str
= "IEEE 802.1X";
73 case HOSTAPD_MODULE_RADIUS
:
74 module_str
= "RADIUS";
76 case HOSTAPD_MODULE_WPA
:
79 case HOSTAPD_MODULE_DRIVER
:
80 module_str
= "DRIVER";
82 case HOSTAPD_MODULE_IAPP
:
85 case HOSTAPD_MODULE_MLME
:
93 if (hapd
&& hapd
->conf
&& addr
)
94 os_snprintf(format
, maxlen
, "%s: STA " MACSTR
"%s%s: %s",
95 hapd
->conf
->iface
, MAC2STR(addr
),
96 module_str
? " " : "", module_str
? module_str
: "",
98 else if (hapd
&& hapd
->conf
)
99 os_snprintf(format
, maxlen
, "%s:%s%s %s",
100 hapd
->conf
->iface
, module_str
? " " : "",
101 module_str
? module_str
: "", txt
);
103 os_snprintf(format
, maxlen
, "STA " MACSTR
"%s%s: %s",
104 MAC2STR(addr
), module_str
? " " : "",
105 module_str
? module_str
: "", txt
);
107 os_snprintf(format
, maxlen
, "%s%s%s",
108 module_str
? module_str
: "",
109 module_str
? ": " : "", txt
);
111 #ifdef CONFIG_DEBUG_SYSLOG
112 if (wpa_debug_syslog
)
114 #endif /* CONFIG_DEBUG_SYSLOG */
115 if ((conf_stdout
& module
) && level
>= conf_stdout_level
) {
116 wpa_debug_print_timestamp();
117 wpa_printf(MSG_INFO
, "%s", format
);
120 #ifndef CONFIG_NATIVE_WINDOWS
121 if ((conf_syslog
& module
) && level
>= conf_syslog_level
) {
124 case HOSTAPD_LEVEL_DEBUG_VERBOSE
:
125 case HOSTAPD_LEVEL_DEBUG
:
126 priority
= LOG_DEBUG
;
128 case HOSTAPD_LEVEL_INFO
:
131 case HOSTAPD_LEVEL_NOTICE
:
132 priority
= LOG_NOTICE
;
134 case HOSTAPD_LEVEL_WARNING
:
135 priority
= LOG_WARNING
;
141 syslog(priority
, "%s", format
);
143 #endif /* CONFIG_NATIVE_WINDOWS */
147 #endif /* CONFIG_NO_HOSTAPD_LOGGER */
151 * hostapd_driver_init - Preparate driver interface
153 static int hostapd_driver_init(struct hostapd_iface
*iface
)
155 struct wpa_init_params params
;
157 struct hostapd_data
*hapd
= iface
->bss
[0];
158 struct hostapd_bss_config
*conf
= hapd
->conf
;
160 struct wpa_driver_capa capa
;
162 if (hapd
->driver
== NULL
|| hapd
->driver
->hapd_init
== NULL
) {
163 wpa_printf(MSG_ERROR
, "No hostapd driver wrapper available");
167 /* Initialize the driver interface */
168 if (!(b
[0] | b
[1] | b
[2] | b
[3] | b
[4] | b
[5]))
171 os_memset(¶ms
, 0, sizeof(params
));
172 for (i
= 0; wpa_drivers
[i
]; i
++) {
173 if (wpa_drivers
[i
] != hapd
->driver
)
176 if (global
.drv_priv
[i
] == NULL
&&
177 wpa_drivers
[i
]->global_init
) {
179 wpa_drivers
[i
]->global_init(iface
->interfaces
);
180 if (global
.drv_priv
[i
] == NULL
) {
181 wpa_printf(MSG_ERROR
, "Failed to initialize "
183 wpa_drivers
[i
]->name
);
188 params
.global_priv
= global
.drv_priv
[i
];
192 params
.ifname
= hapd
->conf
->iface
;
193 params
.driver_params
= hapd
->iconf
->driver_params
;
194 params
.use_pae_group_addr
= hapd
->conf
->use_pae_group_addr
;
196 params
.num_bridge
= hapd
->iface
->num_bss
;
197 params
.bridge
= os_calloc(hapd
->iface
->num_bss
, sizeof(char *));
198 if (params
.bridge
== NULL
)
200 for (i
= 0; i
< hapd
->iface
->num_bss
; i
++) {
201 struct hostapd_data
*bss
= hapd
->iface
->bss
[i
];
202 if (bss
->conf
->bridge
[0])
203 params
.bridge
[i
] = bss
->conf
->bridge
;
206 params
.own_addr
= hapd
->own_addr
;
208 hapd
->drv_priv
= hapd
->driver
->hapd_init(hapd
, ¶ms
);
209 os_free(params
.bridge
);
210 if (hapd
->drv_priv
== NULL
) {
211 wpa_printf(MSG_ERROR
, "%s driver initialization failed.",
217 if (hapd
->driver
->get_capa
&&
218 hapd
->driver
->get_capa(hapd
->drv_priv
, &capa
) == 0) {
219 struct wowlan_triggers
*triggs
;
221 iface
->drv_flags
= capa
.flags
;
222 iface
->smps_modes
= capa
.smps_modes
;
223 iface
->probe_resp_offloads
= capa
.probe_resp_offloads
;
225 * Use default extended capa values from per-radio information
227 iface
->extended_capa
= capa
.extended_capa
;
228 iface
->extended_capa_mask
= capa
.extended_capa_mask
;
229 iface
->extended_capa_len
= capa
.extended_capa_len
;
230 iface
->drv_max_acl_mac_addrs
= capa
.max_acl_mac_addrs
;
233 * Override extended capa with per-interface type (AP), if
234 * available from the driver.
236 hostapd_get_ext_capa(iface
);
238 triggs
= wpa_get_wowlan_triggers(conf
->wowlan_triggers
, &capa
);
239 if (triggs
&& hapd
->driver
->set_wowlan
) {
240 if (hapd
->driver
->set_wowlan(hapd
->drv_priv
, triggs
))
241 wpa_printf(MSG_ERROR
, "set_wowlan failed");
251 * hostapd_interface_init - Read configuration file and init BSS data
253 * This function is used to parse configuration file for a full interface (one
254 * or more BSSes sharing the same radio) and allocate memory for the BSS
255 * interfaces. No actiual driver operations are started.
257 static struct hostapd_iface
*
258 hostapd_interface_init(struct hapd_interfaces
*interfaces
, const char *if_name
,
259 const char *config_fname
, int debug
)
261 struct hostapd_iface
*iface
;
264 wpa_printf(MSG_ERROR
, "Configuration file: %s", config_fname
);
265 iface
= hostapd_init(interfaces
, config_fname
);
270 os_strlcpy(iface
->conf
->bss
[0]->iface
, if_name
,
271 sizeof(iface
->conf
->bss
[0]->iface
));
274 iface
->interfaces
= interfaces
;
276 for (k
= 0; k
< debug
; k
++) {
277 if (iface
->bss
[0]->conf
->logger_stdout_level
> 0)
278 iface
->bss
[0]->conf
->logger_stdout_level
--;
281 if (iface
->conf
->bss
[0]->iface
[0] == '\0' &&
282 !hostapd_drv_none(iface
->bss
[0])) {
283 wpa_printf(MSG_ERROR
,
284 "Interface name not specified in %s, nor by '-i' parameter",
286 hostapd_interface_deinit_free(iface
);
295 * handle_term - SIGINT and SIGTERM handler to terminate hostapd process
297 static void handle_term(int sig
, void *signal_ctx
)
299 wpa_printf(MSG_DEBUG
, "Signal %d received - terminating", sig
);
304 #ifndef CONFIG_NATIVE_WINDOWS
306 static int handle_reload_iface(struct hostapd_iface
*iface
, void *ctx
)
308 if (hostapd_reload_config(iface
) < 0) {
309 wpa_printf(MSG_WARNING
, "Failed to read new configuration "
310 "file - continuing with old.");
317 * handle_reload - SIGHUP handler to reload configuration
319 static void handle_reload(int sig
, void *signal_ctx
)
321 struct hapd_interfaces
*interfaces
= signal_ctx
;
322 wpa_printf(MSG_DEBUG
, "Signal %d received - reloading configuration",
324 hostapd_for_each_interface(interfaces
, handle_reload_iface
, NULL
);
328 static void handle_dump_state(int sig
, void *signal_ctx
)
330 /* Not used anymore - ignore signal */
332 #endif /* CONFIG_NATIVE_WINDOWS */
335 static int hostapd_global_init(struct hapd_interfaces
*interfaces
,
336 const char *entropy_file
)
340 os_memset(&global
, 0, sizeof(global
));
342 hostapd_logger_register_cb(hostapd_logger_cb
);
344 if (eap_server_register_methods()) {
345 wpa_printf(MSG_ERROR
, "Failed to register EAP methods");
350 wpa_printf(MSG_ERROR
, "Failed to initialize event loop");
353 interfaces
->eloop_initialized
= 1;
355 random_init(entropy_file
);
357 #ifndef CONFIG_NATIVE_WINDOWS
358 eloop_register_signal(SIGHUP
, handle_reload
, interfaces
);
359 eloop_register_signal(SIGUSR1
, handle_dump_state
, interfaces
);
360 #endif /* CONFIG_NATIVE_WINDOWS */
361 eloop_register_signal_terminate(handle_term
, interfaces
);
363 #ifndef CONFIG_NATIVE_WINDOWS
364 openlog("hostapd", 0, LOG_DAEMON
);
365 #endif /* CONFIG_NATIVE_WINDOWS */
367 for (i
= 0; wpa_drivers
[i
]; i
++)
369 if (global
.drv_count
== 0) {
370 wpa_printf(MSG_ERROR
, "No drivers enabled");
373 global
.drv_priv
= os_calloc(global
.drv_count
, sizeof(void *));
374 if (global
.drv_priv
== NULL
)
381 static void hostapd_global_deinit(const char *pid_file
, int eloop_initialized
)
385 for (i
= 0; wpa_drivers
[i
] && global
.drv_priv
; i
++) {
386 if (!global
.drv_priv
[i
])
388 wpa_drivers
[i
]->global_deinit(global
.drv_priv
[i
]);
390 os_free(global
.drv_priv
);
391 global
.drv_priv
= NULL
;
393 #ifdef EAP_SERVER_TNC
394 tncs_global_deinit();
395 #endif /* EAP_SERVER_TNC */
399 if (eloop_initialized
)
402 #ifndef CONFIG_NATIVE_WINDOWS
404 #endif /* CONFIG_NATIVE_WINDOWS */
406 eap_server_unregister_methods();
408 os_daemonize_terminate(pid_file
);
412 static int hostapd_global_run(struct hapd_interfaces
*ifaces
, int daemonize
,
413 const char *pid_file
)
415 #ifdef EAP_SERVER_TNC
419 for (i
= 0; !tnc
&& i
< ifaces
->count
; i
++) {
420 for (k
= 0; k
< ifaces
->iface
[i
]->num_bss
; k
++) {
421 if (ifaces
->iface
[i
]->bss
[0]->conf
->tnc
) {
428 if (tnc
&& tncs_global_init() < 0) {
429 wpa_printf(MSG_ERROR
, "Failed to initialize TNCS");
432 #endif /* EAP_SERVER_TNC */
435 if (os_daemonize(pid_file
)) {
436 wpa_printf(MSG_ERROR
, "daemon: %s", strerror(errno
));
439 if (eloop_sock_requeue()) {
440 wpa_printf(MSG_ERROR
, "eloop_sock_requeue: %s",
452 static void show_version(void)
455 "hostapd v" VERSION_STR
"\n"
456 "User space daemon for IEEE 802.11 AP management,\n"
457 "IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator\n"
458 "Copyright (c) 2002-2017, Jouni Malinen <j@w1.fi> "
459 "and contributors\n");
463 static void usage(void)
468 "usage: hostapd [-hdBKtv] [-P <PID file>] [-e <entropy file>] "
470 " [-g <global ctrl_iface>] [-G <group>]\\\n"
471 " [-i <comma-separated list of interface names>]\\\n"
472 " <configuration file(s)>\n"
475 " -h show this usage\n"
476 " -d show more debug messages (-dd for even more)\n"
477 " -B run daemon in the background\n"
479 " -g global control interface path\n"
480 " -G group for control interfaces\n"
482 " -K include key data in debug messages\n"
483 #ifdef CONFIG_DEBUG_FILE
484 " -f log output to debug file instead of stdout\n"
485 #endif /* CONFIG_DEBUG_FILE */
486 #ifdef CONFIG_DEBUG_LINUX_TRACING
487 " -T record to Linux tracing in addition to logging\n"
488 " (records all messages regardless of debug verbosity)\n"
489 #endif /* CONFIG_DEBUG_LINUX_TRACING */
490 " -i list of interface names to use\n"
491 #ifdef CONFIG_DEBUG_SYSLOG
492 " -s log output to syslog instead of stdout\n"
493 #endif /* CONFIG_DEBUG_SYSLOG */
494 " -S start all the interfaces synchronously\n"
495 " -t include timestamps in some debug messages\n"
496 " -v show hostapd version\n");
502 static const char * hostapd_msg_ifname_cb(void *ctx
)
504 struct hostapd_data
*hapd
= ctx
;
505 if (hapd
&& hapd
->conf
)
506 return hapd
->conf
->iface
;
511 static int hostapd_get_global_ctrl_iface(struct hapd_interfaces
*interfaces
,
514 #ifndef CONFIG_CTRL_IFACE_UDP
516 #endif /* !CONFIG_CTRL_IFACE_UDP */
518 os_free(interfaces
->global_iface_path
);
519 interfaces
->global_iface_path
= os_strdup(path
);
520 if (interfaces
->global_iface_path
== NULL
)
523 #ifndef CONFIG_CTRL_IFACE_UDP
524 pos
= os_strrchr(interfaces
->global_iface_path
, '/');
526 wpa_printf(MSG_ERROR
, "No '/' in the global control interface "
528 os_free(interfaces
->global_iface_path
);
529 interfaces
->global_iface_path
= NULL
;
534 interfaces
->global_iface_name
= pos
+ 1;
535 #endif /* !CONFIG_CTRL_IFACE_UDP */
541 static int hostapd_get_ctrl_iface_group(struct hapd_interfaces
*interfaces
,
544 #ifndef CONFIG_NATIVE_WINDOWS
546 grp
= getgrnam(group
);
548 wpa_printf(MSG_ERROR
, "Unknown group '%s'", group
);
551 interfaces
->ctrl_iface_group
= grp
->gr_gid
;
552 #endif /* CONFIG_NATIVE_WINDOWS */
557 static int hostapd_get_interface_names(char ***if_names
,
558 size_t *if_names_size
,
561 char *if_name
, *tmp
, **nnames
;
566 if_name
= strtok_r(arg
, ",", &tmp
);
569 nnames
= os_realloc_array(*if_names
, 1 + *if_names_size
,
575 (*if_names
)[*if_names_size
] = os_strdup(if_name
);
576 if (!(*if_names
)[*if_names_size
])
579 if_name
= strtok_r(NULL
, ",", &tmp
);
585 for (i
= 0; i
< *if_names_size
; i
++)
586 os_free((*if_names
)[i
]);
595 static int gen_uuid(const char *txt_addr
)
601 if (hwaddr_aton(txt_addr
, addr
) < 0)
604 uuid_gen_mac_addr(addr
, uuid
);
605 if (uuid_bin2str(uuid
, buf
, sizeof(buf
)) < 0)
612 #endif /* CONFIG_WPS */
615 #ifndef HOSTAPD_CLEANUP_INTERVAL
616 #define HOSTAPD_CLEANUP_INTERVAL 10
617 #endif /* HOSTAPD_CLEANUP_INTERVAL */
619 static int hostapd_periodic_call(struct hostapd_iface
*iface
, void *ctx
)
621 hostapd_periodic_iface(iface
);
626 /* Periodic cleanup tasks */
627 static void hostapd_periodic(void *eloop_ctx
, void *timeout_ctx
)
629 struct hapd_interfaces
*interfaces
= eloop_ctx
;
631 eloop_register_timeout(HOSTAPD_CLEANUP_INTERVAL
, 0,
632 hostapd_periodic
, interfaces
, NULL
);
633 hostapd_for_each_interface(interfaces
, hostapd_periodic_call
, NULL
);
637 int main(int argc
, char *argv
[])
639 struct hapd_interfaces interfaces
;
642 int c
, debug
= 0, daemonize
= 0;
643 char *pid_file
= NULL
;
644 const char *log_file
= NULL
;
645 const char *entropy_file
= NULL
;
646 char **bss_config
= NULL
, **tmp_bss
;
647 size_t num_bss_configs
= 0;
648 #ifdef CONFIG_DEBUG_LINUX_TRACING
649 int enable_trace_dbg
= 0;
650 #endif /* CONFIG_DEBUG_LINUX_TRACING */
651 int start_ifaces_in_sync
= 0;
652 char **if_names
= NULL
;
653 size_t if_names_size
= 0;
655 if (os_program_init())
658 os_memset(&interfaces
, 0, sizeof(interfaces
));
659 interfaces
.reload_config
= hostapd_reload_config
;
660 interfaces
.config_read_cb
= hostapd_config_read
;
661 interfaces
.for_each_interface
= hostapd_for_each_interface
;
662 interfaces
.ctrl_iface_init
= hostapd_ctrl_iface_init
;
663 interfaces
.ctrl_iface_deinit
= hostapd_ctrl_iface_deinit
;
664 interfaces
.driver_init
= hostapd_driver_init
;
665 interfaces
.global_iface_path
= NULL
;
666 interfaces
.global_iface_name
= NULL
;
667 interfaces
.global_ctrl_sock
= -1;
668 dl_list_init(&interfaces
.global_ctrl_dst
);
671 c
= getopt(argc
, argv
, "b:Bde:f:hi:KP:sSTtu:vg:G:");
680 if (wpa_debug_level
> 0)
687 entropy_file
= optarg
;
693 wpa_debug_show_keys
++;
697 pid_file
= os_rel2abs_path(optarg
);
700 wpa_debug_timestamp
++;
702 #ifdef CONFIG_DEBUG_LINUX_TRACING
704 enable_trace_dbg
= 1;
706 #endif /* CONFIG_DEBUG_LINUX_TRACING */
712 if (hostapd_get_global_ctrl_iface(&interfaces
, optarg
))
716 if (hostapd_get_ctrl_iface_group(&interfaces
, optarg
))
720 tmp_bss
= os_realloc_array(bss_config
,
725 bss_config
= tmp_bss
;
726 bss_config
[num_bss_configs
++] = optarg
;
728 #ifdef CONFIG_DEBUG_SYSLOG
730 wpa_debug_syslog
= 1;
732 #endif /* CONFIG_DEBUG_SYSLOG */
734 start_ifaces_in_sync
= 1;
738 return gen_uuid(optarg
);
739 #endif /* CONFIG_WPS */
741 if (hostapd_get_interface_names(&if_names
,
742 &if_names_size
, optarg
))
751 if (optind
== argc
&& interfaces
.global_iface_path
== NULL
&&
752 num_bss_configs
== 0)
755 wpa_msg_register_ifname_cb(hostapd_msg_ifname_cb
);
758 wpa_debug_open_file(log_file
);
760 wpa_debug_setup_stdout();
761 #ifdef CONFIG_DEBUG_SYSLOG
762 if (wpa_debug_syslog
)
763 wpa_debug_open_syslog();
764 #endif /* CONFIG_DEBUG_SYSLOG */
765 #ifdef CONFIG_DEBUG_LINUX_TRACING
766 if (enable_trace_dbg
) {
767 int tret
= wpa_debug_open_linux_tracing();
769 wpa_printf(MSG_ERROR
, "Failed to enable trace logging");
773 #endif /* CONFIG_DEBUG_LINUX_TRACING */
775 interfaces
.count
= argc
- optind
;
776 if (interfaces
.count
|| num_bss_configs
) {
777 interfaces
.iface
= os_calloc(interfaces
.count
+ num_bss_configs
,
778 sizeof(struct hostapd_iface
*));
779 if (interfaces
.iface
== NULL
) {
780 wpa_printf(MSG_ERROR
, "malloc failed");
785 if (hostapd_global_init(&interfaces
, entropy_file
)) {
786 wpa_printf(MSG_ERROR
, "Failed to initialize global context");
790 eloop_register_timeout(HOSTAPD_CLEANUP_INTERVAL
, 0,
791 hostapd_periodic
, &interfaces
, NULL
);
793 if (fst_global_init()) {
794 wpa_printf(MSG_ERROR
,
795 "Failed to initialize global FST context");
799 #if defined(CONFIG_FST) && defined(CONFIG_CTRL_IFACE)
800 if (!fst_global_add_ctrl(fst_ctrl_cli
))
801 wpa_printf(MSG_WARNING
, "Failed to add CLI FST ctrl");
802 #endif /* CONFIG_FST && CONFIG_CTRL_IFACE */
804 /* Allocate and parse configuration for full interface files */
805 for (i
= 0; i
< interfaces
.count
; i
++) {
806 char *if_name
= NULL
;
808 if (i
< if_names_size
)
809 if_name
= if_names
[i
];
811 interfaces
.iface
[i
] = hostapd_interface_init(&interfaces
,
815 if (!interfaces
.iface
[i
]) {
816 wpa_printf(MSG_ERROR
, "Failed to initialize interface");
819 if (start_ifaces_in_sync
)
820 interfaces
.iface
[i
]->need_to_start_in_sync
= 1;
823 /* Allocate and parse configuration for per-BSS files */
824 for (i
= 0; i
< num_bss_configs
; i
++) {
825 struct hostapd_iface
*iface
;
828 wpa_printf(MSG_INFO
, "BSS config: %s", bss_config
[i
]);
829 fname
= os_strchr(bss_config
[i
], ':');
831 wpa_printf(MSG_ERROR
,
832 "Invalid BSS config identifier '%s'",
837 iface
= hostapd_interface_init_bss(&interfaces
, bss_config
[i
],
841 for (j
= 0; j
< interfaces
.count
; j
++) {
842 if (interfaces
.iface
[j
] == iface
)
845 if (j
== interfaces
.count
) {
846 struct hostapd_iface
**tmp
;
847 tmp
= os_realloc_array(interfaces
.iface
,
848 interfaces
.count
+ 1,
849 sizeof(struct hostapd_iface
*));
851 hostapd_interface_deinit_free(iface
);
854 interfaces
.iface
= tmp
;
855 interfaces
.iface
[interfaces
.count
++] = iface
;
860 * Enable configured interfaces. Depending on channel configuration,
861 * this may complete full initialization before returning or use a
862 * callback mechanism to complete setup in case of operations like HT
863 * co-ex scans, ACS, or DFS are needed to determine channel parameters.
864 * In such case, the interface will be enabled from eloop context within
865 * hostapd_global_run().
867 interfaces
.terminate_on_error
= interfaces
.count
;
868 for (i
= 0; i
< interfaces
.count
; i
++) {
869 if (hostapd_driver_init(interfaces
.iface
[i
]) ||
870 hostapd_setup_interface(interfaces
.iface
[i
]))
874 hostapd_global_ctrl_iface_init(&interfaces
);
876 if (hostapd_global_run(&interfaces
, daemonize
, pid_file
)) {
877 wpa_printf(MSG_ERROR
, "Failed to start eloop");
884 hostapd_global_ctrl_iface_deinit(&interfaces
);
885 /* Deinitialize all interfaces */
886 for (i
= 0; i
< interfaces
.count
; i
++) {
887 if (!interfaces
.iface
[i
])
889 interfaces
.iface
[i
]->driver_ap_teardown
=
890 !!(interfaces
.iface
[i
]->drv_flags
&
891 WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT
);
892 hostapd_interface_deinit_free(interfaces
.iface
[i
]);
894 os_free(interfaces
.iface
);
896 if (interfaces
.eloop_initialized
)
897 eloop_cancel_timeout(hostapd_periodic
, &interfaces
, NULL
);
898 hostapd_global_deinit(pid_file
, interfaces
.eloop_initialized
);
901 wpa_debug_close_syslog();
903 wpa_debug_close_file();
904 wpa_debug_close_linux_tracing();
908 for (i
= 0; i
< if_names_size
; i
++)
909 os_free(if_names
[i
]);