[PATCH] wext: disconnect at init and deinit

Dan Williams dcbw
Tue May 12 11:57:04 PDT 2009


To ensure the supplicant starts and ends with a clean slate (keys are
already cleaned up at init and deinit time), force a null BSSID and
bogus SSID to ensure the driver isn't connected to anything.

Signed-off-by: Dan Williams <dcbw at redhat.com>

diff --git a/src/drivers/driver_wext.c b/src/drivers/driver_wext.c
index 698e4f3..65589b5 100644
--- a/src/drivers/driver_wext.c
+++ b/src/drivers/driver_wext.c
@@ -35,6 +35,7 @@
 static int wpa_driver_wext_flush_pmkid(void *priv);
 static int wpa_driver_wext_get_range(void *priv);
 static int wpa_driver_wext_finish_drv_init(struct wpa_driver_wext_data *drv);
+static void wpa_driver_wext_disconnect(struct wpa_driver_wext_data *drv);
 
 
 static int wpa_driver_wext_send_oper_ifla(struct wpa_driver_wext_data *drv,
@@ -994,6 +995,12 @@ static int wpa_driver_wext_finish_drv_init(struct wpa_driver_wext_data *drv)
 
 	wpa_driver_wext_get_range(drv);
 
+	/* Unlock the driver's BSSID and force to a random SSID so clear any
+	 * previous association the driver might have when the supplicant starts
+	 * up.
+	 */
+	wpa_driver_wext_disconnect(drv);
+
 	drv->ifindex = if_nametoindex(drv->ifname);
 
 	if (os_strncmp(drv->ifname, "wlan", 4) == 0) {
@@ -1035,8 +1042,7 @@ void wpa_driver_wext_deinit(void *priv)
 	 * Clear possibly configured driver parameters in order to make it
 	 * easier to use the driver after wpa_supplicant has been terminated.
 	 */
-	(void) wpa_driver_wext_set_bssid(drv,
-					 (u8 *) "\x00\x00\x00\x00\x00\x00");
+	wpa_driver_wext_disconnect(drv);
 
 	wpa_driver_wext_send_oper_ifla(priv, 0, IF_OPER_UP);
 
@@ -1924,7 +1930,6 @@ static int wpa_driver_wext_mlme(struct wpa_driver_wext_data *drv,
 static void wpa_driver_wext_disconnect(struct wpa_driver_wext_data *drv)
 {
 	struct iwreq iwr;
-	const u8 null_bssid[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
 	u8 ssid[32];
 	int i;
 
@@ -1946,7 +1951,8 @@ static void wpa_driver_wext_disconnect(struct wpa_driver_wext_data *drv)
 		 * even if it does not understand SIOCSIWMLME commands (or tries
 		 * to associate automatically after deauth/disassoc).
 		 */
-		wpa_driver_wext_set_bssid(drv, null_bssid);
+		(void) wpa_driver_wext_set_bssid(drv,
+		                             (u8 *) "\x00\x00\x00\x00\x00\x00");
 
 		for (i = 0; i < 32; i++)
 			ssid[i] = rand() & 0xFF;




More information about the Hostap mailing list