]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
SME: Deauthenticate to clear state after disassociation events
authorJouni Malinen <jouni.malinen@atheros.com>
Wed, 2 Dec 2009 15:26:28 +0000 (17:26 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 2 Dec 2009 15:26:28 +0000 (17:26 +0200)
cfg80211/mac80211 can get into somewhat confused state if the AP only
disassociates us and leaves us in authenticated state. For now, force
the state to be cleared with deauthentication to avoid confusing errors
if we try to associate with the AP again. This gets rid of 30 second
delay (scan timeout) in cases where only a disassociation frame is
received from the AP.

wpa_supplicant/events.c
wpa_supplicant/sme.c
wpa_supplicant/sme.h

index 9548cf58bd599b2451ffde13da0578da5cdf07dd..9f6097ef280bd9d63c095cc4aa0f7794ba36ecf4 100644 (file)
@@ -1383,8 +1383,10 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
        case EVENT_ASSOC:
                wpa_supplicant_event_assoc(wpa_s, data);
                break;
-       case EVENT_DEAUTH:
        case EVENT_DISASSOC:
+               sme_event_disassoc(wpa_s, data);
+               /* fall through */
+       case EVENT_DEAUTH:
                wpa_supplicant_event_disassoc(wpa_s);
                break;
        case EVENT_MICHAEL_MIC_FAILURE:
index 734b2e980127662e2790538f3e4565a78d5ca507..5bb45738bc28e01d1740f0b88bab9c10d3f58a9f 100644 (file)
@@ -427,3 +427,23 @@ void sme_event_assoc_timed_out(struct wpa_supplicant *wpa_s,
        wpa_supplicant_mark_disassoc(wpa_s);
        wpa_supplicant_req_scan(wpa_s, 5, 0);
 }
+
+
+void sme_event_disassoc(struct wpa_supplicant *wpa_s,
+                       union wpa_event_data *data)
+{
+       wpa_printf(MSG_DEBUG, "SME: Disassociation event received");
+       if (!is_zero_ether_addr(wpa_s->bssid) &&
+           !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)) {
+               /*
+                * cfg80211/mac80211 can get into somewhat confused state if
+                * the AP only disassociates us and leaves us in authenticated
+                * state. For now, force the state to be cleared to avoid
+                * confusing errors if we try to associate with the AP again.
+                */
+               wpa_printf(MSG_DEBUG, "SME: Deauthenticate to clear driver "
+                          "state");
+               wpa_drv_deauthenticate(wpa_s, wpa_s->bssid,
+                                      WLAN_REASON_DEAUTH_LEAVING);
+       }
+}
index 27800418505d0f8ab3d970ef2f228a34628e16c5..5e8a8f45a1d968932df71cc4cafb8bf80c518d27 100644 (file)
@@ -28,6 +28,8 @@ void sme_event_auth_timed_out(struct wpa_supplicant *wpa_s,
                              union wpa_event_data *data);
 void sme_event_assoc_timed_out(struct wpa_supplicant *wpa_s,
                               union wpa_event_data *data);
+void sme_event_disassoc(struct wpa_supplicant *wpa_s,
+                       union wpa_event_data *data);
 
 #else /* CONFIG_SME */
 
@@ -64,6 +66,11 @@ static inline void sme_event_assoc_timed_out(struct wpa_supplicant *wpa_s,
 {
 }
 
+static inline void sme_event_disassoc(struct wpa_supplicant *wpa_s,
+                                     union wpa_event_data *data)
+{
+}
+
 #endif /* CONFIG_SME */
 
 #endif /* SME_H */