Share common code in wpa_supplicant_{disassociate,deauthenticate}()

This commit is contained in:
Jouni Malinen 2010-08-26 13:43:38 +03:00
parent eb0a3c7f96
commit 09f58c0984

View file

@ -1296,6 +1296,24 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
} }
static void wpa_supplicant_clear_connection(struct wpa_supplicant *wpa_s,
const u8 *addr)
{
struct wpa_ssid *old_ssid;
wpa_clear_keys(wpa_s, addr);
wpa_supplicant_mark_disassoc(wpa_s);
old_ssid = wpa_s->current_ssid;
wpa_s->current_ssid = NULL;
wpa_s->current_bss = NULL;
wpa_sm_set_config(wpa_s->wpa, NULL);
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
if (old_ssid != wpa_s->current_ssid)
wpas_notify_network_changed(wpa_s);
eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
}
/** /**
* wpa_supplicant_disassociate - Disassociate the current connection * wpa_supplicant_disassociate - Disassociate the current connection
* @wpa_s: Pointer to wpa_supplicant data * @wpa_s: Pointer to wpa_supplicant data
@ -1307,7 +1325,6 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s, void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
int reason_code) int reason_code)
{ {
struct wpa_ssid *old_ssid;
u8 *addr = NULL; u8 *addr = NULL;
if (!is_zero_ether_addr(wpa_s->bssid)) { if (!is_zero_ether_addr(wpa_s->bssid)) {
@ -1317,16 +1334,8 @@ void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
wpa_drv_disassociate(wpa_s, wpa_s->bssid, reason_code); wpa_drv_disassociate(wpa_s, wpa_s->bssid, reason_code);
addr = wpa_s->bssid; addr = wpa_s->bssid;
} }
wpa_clear_keys(wpa_s, addr);
wpa_supplicant_mark_disassoc(wpa_s); wpa_supplicant_clear_connection(wpa_s, addr);
old_ssid = wpa_s->current_ssid;
wpa_s->current_ssid = NULL;
wpa_s->current_bss = NULL;
wpa_sm_set_config(wpa_s->wpa, NULL);
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
if (old_ssid != wpa_s->current_ssid)
wpas_notify_network_changed(wpa_s);
eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
} }
@ -1341,7 +1350,6 @@ void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s, void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
int reason_code) int reason_code)
{ {
struct wpa_ssid *old_ssid;
u8 *addr = NULL; u8 *addr = NULL;
if (!is_zero_ether_addr(wpa_s->bssid)) { if (!is_zero_ether_addr(wpa_s->bssid)) {
@ -1352,16 +1360,8 @@ void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
reason_code); reason_code);
addr = wpa_s->bssid; addr = wpa_s->bssid;
} }
wpa_clear_keys(wpa_s, addr);
wpa_supplicant_mark_disassoc(wpa_s); wpa_supplicant_clear_connection(wpa_s, addr);
old_ssid = wpa_s->current_ssid;
wpa_s->current_ssid = NULL;
wpa_s->current_bss = NULL;
wpa_sm_set_config(wpa_s->wpa, NULL);
eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
if (old_ssid != wpa_s->current_ssid)
wpas_notify_network_changed(wpa_s);
eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
} }