]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AOSP: Customized STA reconnection behavior
authorJouni Malinen <j@w1.fi>
Fri, 1 Nov 2013 10:31:26 +0000 (12:31 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 1 Nov 2013 14:36:04 +0000 (16:36 +0200)
This is rebased version of this AOSP commit:

commit 7db4ef75f0190d98dbc84f8968ede3ac0ae29571
Author: Irfan Sheriff <isheriff@google.com>
Date:   Mon Jun 18 09:39:07 2012 -0700

    Restore STA reconnection behavior

    Have the customized retry behavior only for P2P & do group failure indicatio
    beyond 5 retries

    Bug: 6674338
    Change-Id: I58cba356ebdb7fc4eaa9bedfa417b7d5d35bb306

wpa_supplicant/config_ssid.h
wpa_supplicant/events.c
wpa_supplicant/wpa_supplicant.c

index 3a4427239902fd115bf7ead2e43cfa2950b4cf88..c6ea9630c97fe596fd7b7783fc53f1b057640ce5 100644 (file)
@@ -491,6 +491,13 @@ struct wpa_ssid {
         */
        int export_keys;
 
+#ifdef ANDROID_P2P
+       /**
+        * assoc_retry - Number of times association should be retried.
+        */
+       int assoc_retry;
+#endif
+
 #ifdef CONFIG_HT_OVERRIDES
        /**
         * disable_ht - Disable HT (IEEE 802.11n) for this network
index 69e40302cd41a555e1aa95a1d869f7da28dfbe42..624ed25456be6412c6a32bf056269f22428e1f55 100644 (file)
@@ -2683,11 +2683,52 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
                        sme_event_assoc_reject(wpa_s, data);
                else {
+#ifdef ANDROID_P2P
+                       if(!wpa_s->current_ssid) {
+                               wpa_printf(MSG_ERROR, "current_ssid == NULL");
+                               break;
+                       }
+                       /* If assoc reject is reported by the driver, then avoid
+                        * waiting for  the authentication timeout. Cancel the
+                        * authentication timeout and retry the assoc.
+                        */
+                       if(wpa_s->current_ssid->assoc_retry++ < 10) {
+                               wpa_printf(MSG_ERROR, "Retrying assoc: %d ",
+                                                               wpa_s->current_ssid->assoc_retry);
+
+                               wpa_supplicant_cancel_auth_timeout(wpa_s);
+
+                               /* Clear the states */
+                               wpa_sm_notify_disassoc(wpa_s->wpa);
+                               wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
+
+                               wpa_s->reassociate = 1;
+                               if (wpa_s->p2p_group_interface == NOT_P2P_GROUP_INTERFACE) {
+                                       const u8 *bl_bssid = data->assoc_reject.bssid;
+                                       if (!bl_bssid || is_zero_ether_addr(bl_bssid))
+                                               bl_bssid = wpa_s->pending_bssid;
+                                       wpa_blacklist_add(wpa_s, bl_bssid);
+                                       wpa_supplicant_req_scan(wpa_s, 0, 0);
+                               } else {
+                                       wpa_supplicant_req_scan(wpa_s, 1, 0);
+                               }
+                       } else if (wpa_s->p2p_group_interface != NOT_P2P_GROUP_INTERFACE) {
+                               /* If we ASSOC_REJECT's hits threshold, disable the 
+                                * network
+                                */
+                               wpa_printf(MSG_ERROR, "Assoc retry threshold reached. "
+                               "Disabling the network");
+                               wpa_s->current_ssid->assoc_retry = 0;
+                               wpa_supplicant_disable_network(wpa_s, wpa_s->current_ssid);
+                               wpas_p2p_group_remove(wpa_s, wpa_s->ifname);
+                       }
+#else
                        const u8 *bssid = data->assoc_reject.bssid;
                        if (bssid == NULL || is_zero_ether_addr(bssid))
                                bssid = wpa_s->pending_bssid;
                        wpas_connection_failed(wpa_s, bssid);
                        wpa_supplicant_mark_disassoc(wpa_s);
+#endif /* ANDROID_P2P */
                }
                break;
        case EVENT_AUTH_TIMED_OUT:
index 8a1574efa5e1c2784b24e2f037efe9b9eb2c7a88..4e012979502b62d9249cd611b45f930fd46ba424 100644 (file)
@@ -651,6 +651,12 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
                wpa_supplicant_state_txt(wpa_s->wpa_state),
                wpa_supplicant_state_txt(state));
 
+#ifdef ANDROID_P2P
+       if(state == WPA_ASSOCIATED && wpa_s->current_ssid) {
+               wpa_s->current_ssid->assoc_retry = 0;
+       }
+#endif /* ANDROID_P2P */
+
        if (state != WPA_SCANNING)
                wpa_supplicant_notify_scanning(wpa_s, 0);