#endif /* CONFIG_NATIVE_WINDOWS */
#include "common.h"
-#include "hostapd.h"
#include "eloop.h"
+#include "crypto/tls.h"
#include "common/version.h"
-#include "config.h"
-#include "tls.h"
#include "eap_server/eap.h"
#include "eap_server/tncs.h"
+#include "hostapd.h"
+#include "config.h"
extern int wpa_debug_level;
};
-int hostapd_for_each_interface(int (*cb)(struct hostapd_iface *iface,
+int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
+ int (*cb)(struct hostapd_iface *iface,
void *ctx), void *ctx)
{
- struct hapd_interfaces *interfaces = eloop_get_user_data();
size_t i;
int ret;
}
-static struct hostapd_iface * hostapd_interface_init(const char *config_fname,
- int debug)
+static struct hostapd_iface *
+hostapd_interface_init(struct hapd_interfaces *interfaces,
+ const char *config_fname, int debug)
{
struct hostapd_iface *iface;
int k;
iface = hostapd_init(config_fname);
if (!iface)
return NULL;
+ iface->interfaces = interfaces;
for (k = 0; k < debug; k++) {
if (iface->bss[0]->conf->logger_stdout_level > 0)
/**
* handle_term - SIGINT and SIGTERM handler to terminate hostapd process
*/
-static void handle_term(int sig, void *eloop_ctx, void *signal_ctx)
+static void handle_term(int sig, void *signal_ctx)
{
wpa_printf(MSG_DEBUG, "Signal %d received - terminating", sig);
eloop_terminate();
/**
* handle_reload - SIGHUP handler to reload configuration
*/
-static void handle_reload(int sig, void *eloop_ctx, void *signal_ctx)
+static void handle_reload(int sig, void *signal_ctx)
{
+ struct hapd_interfaces *interfaces = signal_ctx;
wpa_printf(MSG_DEBUG, "Signal %d received - reloading configuration",
sig);
- hostapd_for_each_interface(handle_reload_iface, NULL);
+ hostapd_for_each_interface(interfaces, handle_reload_iface, NULL);
}
-static void handle_dump_state(int sig, void *eloop_ctx, void *signal_ctx)
+static void handle_dump_state(int sig, void *signal_ctx)
{
#ifdef HOSTAPD_DUMP_STATE
- hostapd_for_each_interface(handle_dump_state_iface, NULL);
+ struct hapd_interfaces *interfaces = signal_ctx;
+ hostapd_for_each_interface(interfaces, handle_dump_state_iface, NULL);
#endif /* HOSTAPD_DUMP_STATE */
}
#endif /* CONFIG_NATIVE_WINDOWS */
return -1;
}
- if (eloop_init(interfaces)) {
+ if (eloop_init()) {
wpa_printf(MSG_ERROR, "Failed to initialize event loop");
return -1;
}
#ifndef CONFIG_NATIVE_WINDOWS
- eloop_register_signal(SIGHUP, handle_reload, NULL);
- eloop_register_signal(SIGUSR1, handle_dump_state, NULL);
+ eloop_register_signal(SIGHUP, handle_reload, interfaces);
+ eloop_register_signal(SIGUSR1, handle_dump_state, interfaces);
#endif /* CONFIG_NATIVE_WINDOWS */
- eloop_register_signal_terminate(handle_term, NULL);
+ eloop_register_signal_terminate(handle_term, interfaces);
#ifndef CONFIG_NATIVE_WINDOWS
openlog("hostapd", 0, LOG_DAEMON);
int c, debug = 0, daemonize = 0;
char *pid_file = NULL;
+ if (os_program_init())
+ return -1;
+
for (;;) {
c = getopt(argc, argv, "BdhKP:tv");
if (c < 0)
/* Initialize interfaces */
for (i = 0; i < interfaces.count; i++) {
- interfaces.iface[i] = hostapd_interface_init(argv[optind + i],
+ interfaces.iface[i] = hostapd_interface_init(&interfaces,
+ argv[optind + i],
debug);
if (!interfaces.iface[i])
goto out;
hostapd_global_deinit(pid_file);
os_free(pid_file);
+ os_program_deinit();
+
return ret;
}