From 07783eaaa05c07e2c0071780ed3ebf7d0abfe4b5 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 5 Nov 2012 16:55:30 +0200 Subject: [PATCH] Use deauthentication instead of disassociation if not associated cfg80211/mac80211 may reject disassociation command if association has not yet been formed. Use deauthentication in cases where it is possible that we are associating at the moment the command is issued. Signed-hostap: Jouni Malinen --- wpa_supplicant/ctrl_iface.c | 7 ++++--- wpa_supplicant/dbus/dbus_new_handlers.c | 3 ++- wpa_supplicant/events.c | 4 ++-- wpa_supplicant/wpa_supplicant.c | 8 ++++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index a037cca4c..345e026da 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2124,8 +2124,8 @@ static int wpa_supplicant_ctrl_iface_remove_network( #endif /* CONFIG_SME */ wpa_sm_set_config(wpa_s->wpa, NULL); eapol_sm_notify_config(wpa_s->eapol, NULL, NULL); - wpa_supplicant_disassociate(wpa_s, - WLAN_REASON_DEAUTH_LEAVING); + wpa_supplicant_deauthenticate( + wpa_s, WLAN_REASON_DEAUTH_LEAVING); } return 0; } @@ -2157,7 +2157,8 @@ static int wpa_supplicant_ctrl_iface_remove_network( wpa_sm_set_config(wpa_s->wpa, NULL); eapol_sm_notify_config(wpa_s->eapol, NULL, NULL); - wpa_supplicant_disassociate(wpa_s, WLAN_REASON_DEAUTH_LEAVING); + wpa_supplicant_deauthenticate(wpa_s, + WLAN_REASON_DEAUTH_LEAVING); } if (wpa_config_remove_network(wpa_s->conf, id) < 0) { diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 062024fbb..e100df24f 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -1547,7 +1547,8 @@ static void remove_network(void *arg, struct wpa_ssid *ssid) } if (ssid == wpa_s->current_ssid) - wpa_supplicant_disassociate(wpa_s, WLAN_REASON_DEAUTH_LEAVING); + wpa_supplicant_deauthenticate(wpa_s, + WLAN_REASON_DEAUTH_LEAVING); } diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 1aa9c2109..42c4deaaa 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1609,7 +1609,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s, if (wpa_drv_get_bssid(wpa_s, bssid) < 0) { wpa_dbg(wpa_s, MSG_ERROR, "Failed to get BSSID"); - wpa_supplicant_disassociate( + wpa_supplicant_deauthenticate( wpa_s, WLAN_REASON_DEAUTH_LEAVING); return; } @@ -1627,7 +1627,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s, wpa_clear_keys(wpa_s, bssid); } if (wpa_supplicant_select_config(wpa_s) < 0) { - wpa_supplicant_disassociate( + wpa_supplicant_deauthenticate( wpa_s, WLAN_REASON_DEAUTH_LEAVING); return; } diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 076d31301..82edae205 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -190,7 +190,7 @@ static void wpa_supplicant_timeout(void *eloop_ctx, void *timeout_ctx) MAC2STR(bssid)); wpa_blacklist_add(wpa_s, bssid); wpa_sm_notify_disassoc(wpa_s->wpa); - wpa_supplicant_disassociate(wpa_s, WLAN_REASON_DEAUTH_LEAVING); + wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING); wpa_s->reassociate = 1; /* @@ -1867,11 +1867,11 @@ void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s, wpa_s, other_ssid); } if (wpa_s->current_ssid) - wpa_supplicant_disassociate( + wpa_supplicant_deauthenticate( wpa_s, WLAN_REASON_DEAUTH_LEAVING); } else if (ssid->disabled != 2) { if (ssid == wpa_s->current_ssid) - wpa_supplicant_disassociate( + wpa_supplicant_deauthenticate( wpa_s, WLAN_REASON_DEAUTH_LEAVING); was_disabled = ssid->disabled; @@ -1897,7 +1897,7 @@ void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s, int disconnected = 0; if (ssid && ssid != wpa_s->current_ssid && wpa_s->current_ssid) { - wpa_supplicant_disassociate( + wpa_supplicant_deauthenticate( wpa_s, WLAN_REASON_DEAUTH_LEAVING); disconnected = 1; }