@@ -2238,6 +2238,25 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
data->assoc_reject.status_code);
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
sme_event_assoc_reject(wpa_s, data);
+
+ /* 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->assoc_retries++ < 3) {
+ wpa_printf(MSG_ERROR, "Retrying assoc "
+ "Iteration:%d", wpa_s->assoc_retries);
+ wpa_supplicant_cancel_auth_timeout(wpa_s);
+
+ /* Clear the states */
+ wpa_sm_notify_disassoc(wpa_s->wpa);
+ wpa_supplicant_disassociate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
+
+ wpa_s->reassociate = 1;
+ wpa_supplicant_req_scan(wpa_s, 1, 0);
+ } else {
+ wpa_s->assoc_retries = 0;
+ }
break;
case EVENT_AUTH_TIMED_OUT:
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
@@ -585,6 +585,9 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
wpa_supplicant_state_txt(wpa_s->wpa_state),
wpa_supplicant_state_txt(state));
+ if(state == WPA_ASSOCIATED || (state <= WPA_INACTIVE))
+ wpa_s->assoc_retries = 0;
+
if (state != WPA_SCANNING)
wpa_supplicant_notify_scanning(wpa_s, 0);
@@ -286,6 +286,7 @@ struct wpa_supplicant {
struct wpa_bss *current_bss;
int ap_ies_from_associnfo;
unsigned int assoc_freq;
+ unsigned int assoc_retries;
/* Selected configuration (based on Beacon/ProbeResp WPA IE) */
int pairwise_cipher;