]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS UPnP: Fix UPnP initialization for non-bridge case with some drivers
authorVinay Adella <vinay.adella@atheros.com>
Thu, 19 May 2011 09:55:47 +0000 (12:55 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 19 May 2011 09:55:47 +0000 (12:55 +0300)
If the driver wrapper is setting up the interface up only at commit(),
UPnP initialization fails. Fix that by moving UPnP setup to happen after
the driver commit() call.

src/ap/hostapd.c
src/ap/wps_hostapd.c
src/ap/wps_hostapd.h

index 4e5eb01996ad33a940ea7f31d935f45cf0022369..32db66872227fc5aba37a9da755ec469d9e508a2 100644 (file)
@@ -784,6 +784,17 @@ int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err)
                return -1;
        }
 
+       /*
+        * WPS UPnP module can be initialized only when the "upnp_iface" is up.
+        * If "interface" and "upnp_iface" are the same (e.g., non-bridge
+        * mode), the interface is up only after driver_commit, so initialize
+        * WPS after driver_commit.
+        */
+       for (j = 0; j < iface->num_bss; j++) {
+               if (hostapd_init_wps_complete(iface->bss[j]))
+                       return -1;
+       }
+
        if (hapd->setup_complete_cb)
                hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
 
index fcbd89b9cff54ad33c28c19120caa51c1b1e65c2..fc927f98f3dca1ad12a333f4b157b6163194cb58 100644 (file)
@@ -876,20 +876,34 @@ int hostapd_init_wps(struct hostapd_data *hapd,
        wps->model_description = hapd->conf->model_description;
        wps->model_url = hapd->conf->model_url;
        wps->upc = hapd->conf->upc;
+#endif /* CONFIG_WPS_UPNP */
+
+       hostapd_register_probereq_cb(hapd, hostapd_wps_probe_req_rx, hapd);
+
+       hapd->wps = wps;
+
+       return 0;
+}
+
+
+int hostapd_init_wps_complete(struct hostapd_data *hapd)
+{
+       struct wps_context *wps = hapd->wps;
+
+       if (hapd->wps == NULL)
+               return 0;
 
+#ifdef CONFIG_WPS_UPNP
        if (hostapd_wps_upnp_init(hapd, wps) < 0) {
                wpa_printf(MSG_ERROR, "Failed to initialize WPS UPnP");
                wps_registrar_deinit(wps->registrar);
                os_free(wps->network_key);
                os_free(wps);
+               hapd->wps = NULL;
                return -1;
        }
 #endif /* CONFIG_WPS_UPNP */
 
-       hostapd_register_probereq_cb(hapd, hostapd_wps_probe_req_rx, hapd);
-
-       hapd->wps = wps;
-
        return 0;
 }
 
index 338a2208850078a1a9be37bd05e27915a833bbad..6b28c13a11b2707459a8c1019c80600bdf8f4df6 100644 (file)
@@ -19,6 +19,7 @@
 
 int hostapd_init_wps(struct hostapd_data *hapd,
                     struct hostapd_bss_config *conf);
+int hostapd_init_wps_complete(struct hostapd_data *hapd);
 void hostapd_deinit_wps(struct hostapd_data *hapd);
 void hostapd_update_wps(struct hostapd_data *hapd);
 int hostapd_wps_add_pin(struct hostapd_data *hapd, const u8 *addr,
@@ -50,6 +51,11 @@ static inline void hostapd_deinit_wps(struct hostapd_data *hapd)
 {
 }
 
+static inline int hostapd_init_wps_complete(struct hostapd_data *hapd)
+{
+    return 0;
+}
+
 static inline void hostapd_update_wps(struct hostapd_data *hapd)
 {
 }