data->assoc_reject.status_code);
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
sme_event_assoc_reject(wpa_s, data);
+#ifdef ANDROID_P2P
+ /* 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++ < 5) {
+ 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;
+#endif /* ANDROID_P2P */
break;
case EVENT_AUTH_TIMED_OUT:
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
wpa_supplicant_state_txt(wpa_s->wpa_state),
wpa_supplicant_state_txt(state));
+#ifdef ANDROID_P2P
+ if(state == WPA_ASSOCIATED || (state <= WPA_INACTIVE))
+ wpa_s->assoc_retries = 0;
+#endif /* ANDROID_P2P */
+
if (state != WPA_SCANNING)
wpa_supplicant_notify_scanning(wpa_s, 0);
struct wpa_bss *current_bss;
int ap_ies_from_associnfo;
unsigned int assoc_freq;
+#ifdef ANDROID_P2P
+ unsigned int assoc_retries;
+#endif
/* Selected configuration (based on Beacon/ProbeResp WPA IE) */
int pairwise_cipher;