automake build system
[libeap.git] / hostapd / main.c
index d69e1e6..9c532d4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * hostapd / main()
- * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2002-2010, Jouni Malinen <j@w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * See README and COPYING for more details.
  */
 
-#include "includes.h"
+#include "utils/includes.h"
 #ifndef CONFIG_NATIVE_WINDOWS
 #include <syslog.h>
 #endif /* CONFIG_NATIVE_WINDOWS */
 
-#include "common.h"
-#include "eloop.h"
+#include "utils/common.h"
+#include "utils/eloop.h"
 #include "crypto/tls.h"
 #include "common/version.h"
 #include "drivers/driver.h"
 #include "eap_server/eap.h"
 #include "eap_server/tncs.h"
 #include "ap/hostapd.h"
-#include "ap/config.h"
+#include "ap/ap_config.h"
 #include "config_file.h"
 #include "eap_register.h"
 #include "dump_state.h"
@@ -209,6 +209,7 @@ static struct hostapd_iface * hostapd_init(const char *config_file)
                                               &conf->bss[i]);
                if (hapd == NULL)
                        goto fail;
+               hapd->msg_ctx = hapd;
        }
 
        return hapd_iface;
@@ -275,6 +276,21 @@ static int hostapd_driver_init(struct hostapd_iface *iface)
 }
 
 
+static void hostapd_interface_deinit_free(struct hostapd_iface *iface)
+{
+       const struct wpa_driver_ops *driver;
+       void *drv_priv;
+       if (iface == NULL)
+               return;
+       driver = iface->bss[0]->driver;
+       drv_priv = iface->bss[0]->drv_priv;
+       hostapd_interface_deinit(iface);
+       if (driver && driver->hapd_deinit)
+               driver->hapd_deinit(drv_priv);
+       hostapd_interface_free(iface);
+}
+
+
 static struct hostapd_iface *
 hostapd_interface_init(struct hapd_interfaces *interfaces,
                       const char *config_fname, int debug)
@@ -295,13 +311,7 @@ hostapd_interface_init(struct hapd_interfaces *interfaces,
 
        if (hostapd_driver_init(iface) ||
            hostapd_setup_interface(iface)) {
-               const struct wpa_driver_ops *driver;
-               void *drv_priv;
-               driver = iface->bss[0]->driver;
-               drv_priv = iface->bss[0]->drv_priv;
-               hostapd_interface_deinit(iface);
-               if (driver && driver->hapd_deinit)
-                       driver->hapd_deinit(drv_priv);
+               hostapd_interface_deinit_free(iface);
                return NULL;
        }
 
@@ -438,7 +448,7 @@ static void show_version(void)
                "hostapd v" VERSION_STR "\n"
                "User space daemon for IEEE 802.11 AP management,\n"
                "IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator\n"
-               "Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi> "
+               "Copyright (c) 2002-2010, Jouni Malinen <j@w1.fi> "
                "and contributors\n");
 }
 
@@ -542,16 +552,8 @@ int main(int argc, char *argv[])
 
  out:
        /* Deinitialize all interfaces */
-       for (i = 0; i < interfaces.count; i++) {
-               struct hostapd_iface *iface = interfaces.iface[i];
-               const struct wpa_driver_ops *driver;
-               void *drv_priv;
-               driver = iface->bss[0]->driver;
-               drv_priv = iface->bss[0]->drv_priv;
-               hostapd_interface_deinit(iface);
-               if (driver && driver->hapd_deinit)
-                       driver->hapd_deinit(drv_priv);
-       }
+       for (i = 0; i < interfaces.count; i++)
+               hostapd_interface_deinit_free(interfaces.iface[i]);
        os_free(interfaces.iface);
 
        hostapd_global_deinit(pid_file);