aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2009-05-27 17:55:15 (GMT)
committerJouni Malinen <j@w1.fi>2009-11-22 09:42:29 (GMT)
commit8f0836f0d925733de91944e19a5757e61da40b30 (patch)
tree521c474663d7600a5bdb28ca0dba6640beefc485
parente2dac5e98b6045154cc116925e505fa62b199c00 (diff)
downloadhostap-06-8f0836f0d925733de91944e19a5757e61da40b30.zip
hostap-06-8f0836f0d925733de91944e19a5757e61da40b30.tar.gz
hostap-06-8f0836f0d925733de91944e19a5757e61da40b30.tar.bz2
wext: don't force-disconnect in ad-hoc mode
Otherwise the driver might interpret the request as a request to create/join a new adhoc network with the bogus SSID. Signed-off-by: Dan Williams <dcbw@redhat.com> (cherry picked from commit 64a04447c3d2248ab1aac7f6c220346dad0e1921)
-rw-r--r--src/drivers/driver_wext.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/drivers/driver_wext.c b/src/drivers/driver_wext.c
index e7c53ba..4e47287 100644
--- a/src/drivers/driver_wext.c
+++ b/src/drivers/driver_wext.c
@@ -1901,21 +1901,36 @@ 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;
/*
- * Clear the BSSID selection and set a random SSID to make sure the
- * driver will not be trying to associate with something even if it
- * does not understand SIOCSIWMLME commands (or tries to associate
- * automatically after deauth/disassoc).
+ * Only force-disconnect when the card is in infrastructure mode,
+ * otherwise the driver might interpret the cleared BSSID and random
+ * SSID as an attempt to create a new ad-hoc network.
*/
- wpa_driver_wext_set_bssid(drv, null_bssid);
+ os_memset(&iwr, 0, sizeof(iwr));
+ os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+ if (ioctl(drv->ioctl_sock, SIOCGIWMODE, &iwr) < 0) {
+ perror("ioctl[SIOCGIWMODE]");
+ iwr.u.mode = IW_MODE_INFRA;
+ }
- for (i = 0; i < 32; i++)
- ssid[i] = rand() & 0xFF;
- wpa_driver_wext_set_ssid(drv, ssid, 32);
+ if (iwr.u.mode == IW_MODE_INFRA) {
+ /*
+ * Clear the BSSID selection and set a random SSID to make sure
+ * the driver will not be trying to associate with something
+ * even if it does not understand SIOCSIWMLME commands (or
+ * tries to associate automatically after deauth/disassoc).
+ */
+ wpa_driver_wext_set_bssid(drv, null_bssid);
+
+ for (i = 0; i < 32; i++)
+ ssid[i] = rand() & 0xFF;
+ wpa_driver_wext_set_ssid(drv, ssid, 32);
+ }
}