wlan: Dont include ext caps in Assoc request if AP doesn't support

Some AP doesn't announce Extended Capabilities IE in Probe Response.
Device should not send extended Capabilities if AP doesn't support.

Change-Id: I53215b866cb90f4addf45e3b6ed8af435eb57842
CRs-Fixed: 930199
diff --git a/CORE/MAC/src/include/parserApi.h b/CORE/MAC/src/include/parserApi.h
index 18e53a6..0b2192c 100644
--- a/CORE/MAC/src/include/parserApi.h
+++ b/CORE/MAC/src/include/parserApi.h
@@ -141,6 +141,7 @@
     tDot11fIEVHTCaps          VHTCaps;
     tDot11fIEVHTOperation     VHTOperation;
     tDot11fIEVHTExtBssLoad    VHTExtBssLoad;
+    tDot11fIEExtCap           ExtCap;
     tDot11fIEOperatingMode    OperatingMode;
     tANI_U8                   WiderBWChanSwitchAnnPresent;
     tDot11fIEWiderBWChanSwitchAnn WiderBWChanSwitchAnn;
diff --git a/CORE/MAC/src/pe/include/limSession.h b/CORE/MAC/src/pe/include/limSession.h
index 0569f10..223034d 100644
--- a/CORE/MAC/src/pe/include/limSession.h
+++ b/CORE/MAC/src/pe/include/limSession.h
@@ -359,6 +359,7 @@
     tANI_U8  isKeyInstalled;
     tANI_BOOLEAN is11Gonly;
     tANI_BOOLEAN addBssfailed;
+    tANI_BOOLEAN is_ext_caps_present;
 }tPESession, *tpPESession;
 
 #define LIM_MAX_ACTIVE_SESSIONS 4
diff --git a/CORE/MAC/src/pe/lim/limPropExtsUtils.c b/CORE/MAC/src/pe/lim/limPropExtsUtils.c
index ae58a14..1345a11 100644
--- a/CORE/MAC/src/pe/lim/limPropExtsUtils.c
+++ b/CORE/MAC/src/pe/lim/limPropExtsUtils.c
@@ -196,6 +196,12 @@
         {
             psessionEntry->countryInfoPresent = TRUE;
         }
+        /* Check if Extended caps are present in probe resp or not */
+        if (pBeaconStruct->ExtCap.present)
+        {
+            psessionEntry->is_ext_caps_present = TRUE;
+        }
+
     }
     vos_mem_free(pBeaconStruct);
     return;
diff --git a/CORE/MAC/src/pe/lim/limSendManagementFrames.c b/CORE/MAC/src/pe/lim/limSendManagementFrames.c
index 6f36cb9..fcff76b 100644
--- a/CORE/MAC/src/pe/lim/limSendManagementFrames.c
+++ b/CORE/MAC/src/pe/lim/limSendManagementFrames.c
@@ -2249,7 +2249,7 @@
     tDot11fAssocRequest *pFrm;
     tANI_U16            caps;
     tANI_U8            *pFrame;
-    tSirRetStatus       nSirStatus;
+    tSirRetStatus       nSirStatus = eSIR_FAILURE;
     tLimMlmAssocCnf     mlmAssocCnf;
     tANI_U32            nPayload, nStatus;
     tANI_U8             fQosEnabled, fWmeEnabled, fWsmEnabled;
@@ -2293,9 +2293,12 @@
     vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
 
     vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
-    nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
+    if (psessionEntry->is_ext_caps_present)
+    {
+        nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
                                   &nAddIELen,
                                   &extractedExtCap );
+    }
     if(eSIR_SUCCESS != nSirStatus )
     {
         extractedExtCapFlag = eANI_BOOLEAN_FALSE;
@@ -2488,7 +2491,8 @@
 
     }
 #endif
-    PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
+    if (psessionEntry->is_ext_caps_present)
+        PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
 
 #if defined WLAN_FEATURE_VOWIFI_11R
     if (psessionEntry->pLimJoinReq->is11Rconnection)
@@ -2969,7 +2973,8 @@
 
     }
 #endif
-    PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
+    if (psessionEntry->is_ext_caps_present)
+        PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
 
     nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
     if ( DOT11F_FAILED( nStatus ) )
@@ -3441,7 +3446,8 @@
         limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
         PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
                      psessionEntry->currentOperChannel, eSIR_FALSE );
-        PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
+        if (psessionEntry->is_ext_caps_present)
+            PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
     }
 #endif
 
diff --git a/CORE/SYS/legacy/src/utils/src/parserApi.c b/CORE/SYS/legacy/src/utils/src/parserApi.c
index 70f542f..ca09447 100644
--- a/CORE/SYS/legacy/src/utils/src/parserApi.c
+++ b/CORE/SYS/legacy/src/utils/src/parserApi.c
@@ -2349,6 +2349,7 @@
         vos_mem_copy( &pProbeResp->VHTExtBssLoad, &pr->VHTExtBssLoad, sizeof( tDot11fIEVHTExtBssLoad) );
     }
 #endif
+
     vos_mem_vfree(pr);
     return eSIR_SUCCESS;
 
@@ -3443,6 +3444,12 @@
     }
 
 #endif
+    if (pBies->ExtCap.present )
+    {
+        pBeaconStruct->ExtCap.present = 1;
+        vos_mem_copy( &pBeaconStruct->ExtCap, &pBies->ExtCap,
+                        sizeof(tDot11fIEExtCap));
+    }
     vos_mem_free(pBies);
 
 
@@ -3754,6 +3761,7 @@
                      &pBeacon->OBSSScanParameters,
                      sizeof( tDot11fIEOBSSScanParameters));
     }
+
     vos_mem_vfree(pBeacon);
     return eSIR_SUCCESS;