vlan: Clean up netlink vs. ioctl API implementation
[mech_eap.git] / hostapd / main.c
index 4913cbd..1d9e63e 100644 (file)
@@ -171,7 +171,8 @@ static int hostapd_driver_init(struct hostapd_iface *iface)
 
                if (global.drv_priv[i] == NULL &&
                    wpa_drivers[i]->global_init) {
-                       global.drv_priv[i] = wpa_drivers[i]->global_init();
+                       global.drv_priv[i] =
+                               wpa_drivers[i]->global_init(iface->interfaces);
                        if (global.drv_priv[i] == NULL) {
                                wpa_printf(MSG_ERROR, "Failed to initialize "
                                           "driver '%s'",
@@ -408,9 +409,16 @@ static int hostapd_global_run(struct hapd_interfaces *ifaces, int daemonize,
        }
 #endif /* EAP_SERVER_TNC */
 
-       if (daemonize && os_daemonize(pid_file)) {
-               wpa_printf(MSG_ERROR, "daemon: %s", strerror(errno));
-               return -1;
+       if (daemonize) {
+               if (os_daemonize(pid_file)) {
+                       wpa_printf(MSG_ERROR, "daemon: %s", strerror(errno));
+                       return -1;
+               }
+               if (eloop_sock_requeue()) {
+                       wpa_printf(MSG_ERROR, "eloop_sock_requeue: %s",
+                                  strerror(errno));
+                       return -1;
+               }
        }
 
        eloop_run();
@@ -467,9 +475,8 @@ static void usage(void)
 static const char * hostapd_msg_ifname_cb(void *ctx)
 {
        struct hostapd_data *hapd = ctx;
-       if (hapd && hapd->iconf && hapd->iconf->bss &&
-           hapd->iconf->num_bss > 0 && hapd->iconf->bss[0])
-               return hapd->iconf->bss[0]->iface;
+       if (hapd && hapd->conf)
+               return hapd->conf->iface;
        return NULL;
 }
 
@@ -477,11 +484,16 @@ static const char * hostapd_msg_ifname_cb(void *ctx)
 static int hostapd_get_global_ctrl_iface(struct hapd_interfaces *interfaces,
                                         const char *path)
 {
+#ifndef CONFIG_CTRL_IFACE_UDP
        char *pos;
+#endif /* !CONFIG_CTRL_IFACE_UDP */
+
        os_free(interfaces->global_iface_path);
        interfaces->global_iface_path = os_strdup(path);
        if (interfaces->global_iface_path == NULL)
                return -1;
+
+#ifndef CONFIG_CTRL_IFACE_UDP
        pos = os_strrchr(interfaces->global_iface_path, '/');
        if (pos == NULL) {
                wpa_printf(MSG_ERROR, "No '/' in the global control interface "
@@ -493,6 +505,7 @@ static int hostapd_get_global_ctrl_iface(struct hapd_interfaces *interfaces,
 
        *pos = '\0';
        interfaces->global_iface_name = pos + 1;
+#endif /* !CONFIG_CTRL_IFACE_UDP */
 
        return 0;
 }
@@ -586,7 +599,7 @@ int main(int argc, char *argv[])
        interfaces.global_iface_path = NULL;
        interfaces.global_iface_name = NULL;
        interfaces.global_ctrl_sock = -1;
-       interfaces.global_ctrl_dst = NULL;
+       dl_list_init(&interfaces.global_ctrl_dst);
 
        for (;;) {
                c = getopt(argc, argv, "b:Bde:f:hKP:STtu:vg:G:");