wlan: Adding HS2.0 IEs in the Re-Assoc Requset

DUT fails to send re-assoc

Change-Id: Ibf293d952875bf91b09b9838eb4b076a1e333221
CR-Fixed: 407823
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index e8bb5f5..2d4fdfa 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -259,6 +259,9 @@
 
 #define WLAN_PRIV_SET_MCBC_FILTER    (SIOCIWFIRSTPRIV + 26)
 #define WLAN_PRIV_CLEAR_MCBC_FILTER  (SIOCIWFIRSTPRIV + 27)
+/* Private ioctl to trigger reassociation */
+#define WLAN_SET_REASSOC_TRIGGER     (SIOCIWFIRSTPRIV + 28)
+
 #define WLAN_SET_POWER_PARAMS        (SIOCIWFIRSTPRIV + 29)
 #define WLAN_GET_LINK_SPEED          (SIOCIWFIRSTPRIV + 31)
 
@@ -2145,6 +2148,28 @@
    return 0;
 }
 
+/*
+ * Support for the reassoc trigger private command
+ */
+static int iw_set_reassoc_trigger(struct net_device *dev,
+                            struct iw_request_info *info,
+                            union iwreq_data *wrqu, char *extra)
+{
+   hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
+   tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
+   v_U32_t roamId = 0;
+   tCsrRoamModifyProfileFields modProfileFields;
+   tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pAdapter->sessionId );
+   /* to force the AP initiate fresh 802.1x authentication need to clear 
+    * the PMKID cache for that set the following boolean. this is needed 
+    * by the HS 2.0 passpoint certification 5.2.a and b testcases */ 
+   pSession->fIgnorePMKIDCache = TRUE;
+   sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
+   sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
+   return 0;
+   
+}
+
 
 /*
  * Support for the RSSI & RSSI-APPROX private commands
@@ -5893,7 +5918,8 @@
    [WLAN_PRIV_SET_MCBC_FILTER           - SIOCIWFIRSTPRIV]   = iw_set_dynamic_mcbc_filter,
    [WLAN_PRIV_CLEAR_MCBC_FILTER         - SIOCIWFIRSTPRIV]   = iw_clear_dynamic_mcbc_filter,
    [WLAN_SET_POWER_PARAMS               - SIOCIWFIRSTPRIV]   = iw_set_power_params_priv,
-   [WLAN_GET_LINK_SPEED                 - SIOCIWFIRSTPRIV]   = iw_get_linkspeed
+   [WLAN_GET_LINK_SPEED                 - SIOCIWFIRSTPRIV]   = iw_get_linkspeed,
+   [WLAN_SET_REASSOC_TRIGGER            - SIOCIWFIRSTPRIV]   = iw_set_reassoc_trigger
 };
 
 /*Maximum command length can be only 15 */
@@ -6277,6 +6303,11 @@
         WLAN_GET_LINK_SPEED,
         IW_PRIV_TYPE_CHAR | 18,
         IW_PRIV_TYPE_CHAR | 3, "getLinkSpeed" },
+    {
+        WLAN_SET_REASSOC_TRIGGER,
+        0,
+        0,
+        "reassoc" },
 };
 
 
diff --git a/CORE/SME/inc/csrApi.h b/CORE/SME/inc/csrApi.h
index b76079c..01e6faf 100644
--- a/CORE/SME/inc/csrApi.h
+++ b/CORE/SME/inc/csrApi.h
@@ -854,6 +854,9 @@
     // (Bit0:VO; Bit1:VI; Bit2:BK; Bit3:BE all other bits are ignored)
     tANI_U8  acm_mask;
     tCsrRoamModifyProfileFields modifyProfileFields;
+    tANI_U32 nAddIEAssocLength;   //The byte count in the pAddIE for assoc
+    tANI_U8 *pAddIEAssoc;       //If not null, it has the IE byte stream for additional IE, which can be WSC IE and/or P2P IE
+    
     tSirBssDescription *pBssDesc;   
     tANI_BOOLEAN   qap; //AP supports QoS
     tANI_BOOLEAN   qosConnection; //A connection is QoS enabled
diff --git a/CORE/SME/inc/csrInternal.h b/CORE/SME/inc/csrInternal.h
index 2708398..b70be01 100644
--- a/CORE/SME/inc/csrInternal.h
+++ b/CORE/SME/inc/csrInternal.h
@@ -836,6 +836,10 @@
     tANI_U32 roamTS1;
 #endif
     tANI_U8 bRefAssocStartCnt;   //Tracking assoc start indication
+   /* to force the AP initiate fresh 802.1x authentication after re-association need to clear 
+    * the PMKID cache. To clear the cache in this particular case this is added
+    * it is needed by the HS 2.0 passpoint certification 5.2.a and b testcases */ 
+    tANI_BOOLEAN fIgnorePMKIDCache;
 } tCsrRoamSession;
 
 typedef struct tagCsrRoamStruct
diff --git a/CORE/SME/inc/sme_Api.h b/CORE/SME/inc/sme_Api.h
index 68ee249..4ccd8b5 100644
--- a/CORE/SME/inc/sme_Api.h
+++ b/CORE/SME/inc/sme_Api.h
@@ -525,7 +525,7 @@
   -------------------------------------------------------------------------------*/
 eHalStatus sme_RoamReassoc(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
                           tCsrRoamModifyProfileFields modProfileFields,
-                          tANI_U32 *pRoamId);
+                          tANI_U32 *pRoamId, v_BOOL_t fForce);
 
 /* ---------------------------------------------------------------------------
     \fn sme_RoamConnectToLastProfile
diff --git a/CORE/SME/src/csr/csrApiRoam.c b/CORE/SME/src/csr/csrApiRoam.c
index b3e20fe..d333b98 100644
--- a/CORE/SME/src/csr/csrApiRoam.c
+++ b/CORE/SME/src/csr/csrApiRoam.c
@@ -713,6 +713,10 @@
     {
         palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
     }
+    if(pProfile->pAddIEAssoc)
+    {
+        palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
+    }
     palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
     pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
     return (status);
@@ -5358,6 +5362,18 @@
             pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
             palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
         }
+        if(pSrcProfile->nAddIEAssocLength)
+        {
+            status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
+            if(!HAL_STATUS_SUCCESS(status))
+            {
+                smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs \n") );
+                break;
+            }
+            pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
+            palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
+                pSrcProfile->nAddIEAssocLength);
+        }
         status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
         if(!HAL_STATUS_SUCCESS(status))
         {
@@ -6207,6 +6223,21 @@
     pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
 
     palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
+    /* saving the addional IE`s like Hot spot indication element and extended capabilities */
+    if(pProfile->nAddIEAssocLength)
+    {
+        status = palAllocateMemory(pMac->hHdd,
+                 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
+        if(!HAL_STATUS_SUCCESS(status))
+        {
+            smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
+            return eHAL_STATUS_FAILURE;
+        }
+        pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
+        palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
+                pProfile->nAddIEAssocLength);
+    }
+    
     //Save bssid
     csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
 #ifdef WLAN_FEATURE_VOWIFI_11R
diff --git a/CORE/SME/src/csr/csrUtil.c b/CORE/SME/src/csr/csrUtil.c
index 69faeb2..70f0456 100644
--- a/CORE/SME/src/csr/csrUtil.c
+++ b/CORE/SME/src/csr/csrUtil.c
@@ -3513,7 +3513,16 @@
         smsLog(pMac, LOGE, FL("  session %d not found "), sessionId);
         return FALSE;
     }
-
+   /* to force the AP initiate fresh 802.1x authentication after re-association should not 
+    * fill the PMKID from cache  this is needed 
+    * by the HS 2.0 passpoint certification 5.2.a and b testcases */ 
+    
+    if(pSession->fIgnorePMKIDCache)
+    {
+        pSession->fIgnorePMKIDCache = FALSE;
+        return fRC;
+    }
+    
     do
     {
         for( Index=0; Index < pSession->NumPmkidCache; Index++ )
diff --git a/CORE/SME/src/sme_common/sme_Api.c b/CORE/SME/src/sme_common/sme_Api.c
index c2b541b..fa95d9a 100644
--- a/CORE/SME/src/sme_common/sme_Api.c
+++ b/CORE/SME/src/sme_common/sme_Api.c
@@ -2236,7 +2236,7 @@
   -------------------------------------------------------------------------------*/
 eHalStatus sme_RoamReassoc(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
                           tCsrRoamModifyProfileFields modProfileFields,
-                          tANI_U32 *pRoamId)
+                          tANI_U32 *pRoamId, v_BOOL_t fForce)
 {
     eHalStatus status = eHAL_STATUS_FAILURE;
     tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
@@ -2247,7 +2247,14 @@
     {
         if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
         {
-            status = csrRoamReassoc( pMac, sessionId, pProfile, modProfileFields, pRoamId );
+            if(NULL == pProfile)
+            {        
+                status = csrReassoc( pMac, sessionId, &modProfileFields, pRoamId , fForce);
+            }
+            else
+            {
+                status = csrRoamReassoc( pMac, sessionId, pProfile, modProfileFields, pRoamId );
+            }        
         }
         else
         {