Browse Source

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

Jouni Malinen 14 years ago
parent
commit
09f58c0984
1 changed files with 22 additions and 22 deletions
  1. 22 22
      wpa_supplicant/wpa_supplicant.c

+ 22 - 22
wpa_supplicant/wpa_supplicant.c

@@ -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_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,
 				 int reason_code)
 {
-	struct wpa_ssid *old_ssid;
 	u8 *addr = NULL;
 
 	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);
 		addr = wpa_s->bssid;
 	}
-	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_clear_connection(wpa_s, addr);
 }
 
 
@@ -1341,7 +1350,6 @@ void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
 				   int reason_code)
 {
-	struct wpa_ssid *old_ssid;
 	u8 *addr = NULL;
 
 	if (!is_zero_ether_addr(wpa_s->bssid)) {
@@ -1352,16 +1360,8 @@ void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
 					       reason_code);
 		addr = wpa_s->bssid;
 	}
-	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_clear_connection(wpa_s, addr);
 }