WLAN: Handle De-auth Frame After Pre-Authentication

Fix to handle a de-authentication frame from AP2 while roaming from AP1 to AP2

CRs-Fixed: 438700
Change-Id: I20fbf8eada2f0cfb514fb2ce99cb6afd7a3ea7af
diff --git a/CORE/MAC/src/pe/lim/limFT.c b/CORE/MAC/src/pe/lim/limFT.c
index 0498efb..c7cfeb3 100644
--- a/CORE/MAC/src/pe/lim/limFT.c
+++ b/CORE/MAC/src/pe/lim/limFT.c
@@ -601,7 +601,6 @@
 {
     tpPESession      pftSessionEntry;
     tANI_U8          currentBssUapsd;
-    tANI_U8          sessionId;
     tPowerdBm        localPowerConstraint;
     tPowerdBm        regMax;
     tSchBeaconStruct *pBeaconStruct;
@@ -614,21 +613,13 @@
     }
 
 
-    if((pftSessionEntry = peCreateSession(pMac, pbssDescription->bssId,
-        &sessionId, pMac->lim.maxStation)) == NULL)
-    {
-        limLog(pMac, LOGE, FL("Session Can not be created for pre-auth 11R AP\n"));
-        palFreeMemory(pMac->hHdd, pBeaconStruct);
-        return NULL;
-    }
-        
+       
+    /* Retrieve the session that has already been created and update the entry */
+    pftSessionEntry = pMac->ft.ftPEContext.pftSessionEntry;
 #if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
     limPrintMacAddr(pMac, pbssDescription->bssId, LOGE);
 #endif
 
-    /* Store PE session Id in session Table */
-    pftSessionEntry->peSessionId = sessionId;
-
     pftSessionEntry->dot11mode = psessionEntry->dot11mode;
     pftSessionEntry->htCapability = psessionEntry->htCapability;
 
@@ -729,11 +720,6 @@
 
     pftSessionEntry->encryptType = psessionEntry->encryptType;
 
-#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
-    PELOGE(limLog(pMac,LOGE,"%s:created session (%p) with id = %d\n", 
-       __func__, pftSessionEntry, pftSessionEntry->peSessionId);)
-#endif
-
     palFreeMemory(pMac->hHdd, pBeaconStruct);
     return pftSessionEntry;
 }
@@ -983,6 +969,10 @@
     tpPESession psessionEntry)
 {
 
+    tpPESession      pftSessionEntry;
+    tANI_U8 sessionId;
+    tpSirBssDescription  pbssDescription;
+
     // Save the status of pre-auth
     pMac->ft.ftPEContext.ftPreAuthStatus = status; 
 
@@ -996,6 +986,44 @@
         pMac->ft.ftPEContext.saved_auth_rsp_length = auth_rsp_length;
     }
 
+    /* Create FT session for the re-association at this point */
+    if (pMac->ft.ftPEContext.ftPreAuthStatus == eSIR_SUCCESS)
+    {
+        pbssDescription = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription;
+        if((pftSessionEntry = peCreateSession(pMac, pbssDescription->bssId,
+                                              &sessionId, pMac->lim.maxStation)) == NULL)
+        {
+            limLog(pMac, LOGE, FL("Session Can not be created for pre-auth 11R AP\n"));
+            return;
+        }
+        pftSessionEntry->peSessionId = sessionId;
+        sirCopyMacAddr(pftSessionEntry->selfMacAddr, psessionEntry->selfMacAddr);
+        sirCopyMacAddr(pftSessionEntry->limReAssocbssId, pbssDescription->bssId);
+        pftSessionEntry->bssType = psessionEntry->bssType;
+
+        if (pftSessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
+        {
+            pftSessionEntry->limSystemRole = eLIM_STA_ROLE;
+        }
+        else if(pftSessionEntry->bssType == eSIR_BTAMP_AP_MODE)
+        {
+            pftSessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
+        }
+        else
+        {
+            limLog(pMac, LOGE, FL("Invalid bss type\n"));
+        }
+        pftSessionEntry->limPrevSmeState = pftSessionEntry->limSmeState;
+        pftSessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
+        pMac->ft.ftPEContext.pftSessionEntry = pftSessionEntry;
+        PELOGE(limLog(pMac,LOGE,"%s:created session (%p) with id = %d\n",
+                      __func__, pftSessionEntry, pftSessionEntry->peSessionId);)
+
+        /* Update the ReAssoc BSSID of the current session */
+        sirCopyMacAddr(psessionEntry->limReAssocbssId, pbssDescription->bssId);
+        limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOGE);
+    }
+
     if (psessionEntry->currentOperChannel != 
         pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum) 
     {