From: Vinay Adella Date: Thu, 19 May 2011 09:55:47 +0000 (+0300) Subject: WPS UPnP: Fix UPnP initialization for non-bridge case with some drivers X-Git-Tag: hostap-1-bp~385 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86795546f7bf06a306ee288a7c8e7aad6d6a58f3;p=thirdparty%2Fhostap.git WPS UPnP: Fix UPnP initialization for non-bridge case with some drivers 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. --- diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 4e5eb0199..32db66872 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -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); diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c index fcbd89b9c..fc927f98f 100644 --- a/src/ap/wps_hostapd.c +++ b/src/ap/wps_hostapd.c @@ -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; } diff --git a/src/ap/wps_hostapd.h b/src/ap/wps_hostapd.h index 338a22088..6b28c13a1 100644 --- a/src/ap/wps_hostapd.h +++ b/src/ap/wps_hostapd.h @@ -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) { }