wlan: Use intersection of AP's and user's RSN cap in assoc req

While preparing the RSNIE caps only AP capability are considered.
The capability should be intersection of user provided capability
and AP's capability.

So use intersection of AP's and user's RSN cap in assoc request.

Change-Id: I585d84953767c217239eedc284d6b413cf7af5e4
CRs-Fixed: 2263151
diff --git a/CORE/SME/src/csr/csrUtil.c b/CORE/SME/src/csr/csrUtil.c
index 4f4d524..7f63987 100644
--- a/CORE/SME/src/csr/csrUtil.c
+++ b/CORE/SME/src/csr/csrUtil.c
@@ -4019,11 +4019,13 @@
     tCsrRSNCapabilities RSNCapabilities;
     tCsrRSNPMKIe        *pPMK;
     tANI_U8 PMKId[CSR_RSN_PMKID_SIZE];
+    uint32_t ret;
 #ifdef WLAN_FEATURE_11W
     tANI_U8 *pGroupMgmtCipherSuite;
 #endif
     tDot11fBeaconIEs *pIesLocal = pIes;
     eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
+    tDot11fIERSN rsn_ie;
 
     smsLog(pMac, LOGW, "%s called...", __func__);
 
@@ -4036,7 +4038,21 @@
             break;
         }
 
-        // See if the cyphers in the Bss description match with the settings in the profile.
+         /* Use intersection of the RSN cap sent by user space and
+          * the AP, so that only common capability are enabled.
+          */
+         if (pProfile->pRSNReqIE && pProfile->nRSNReqIELength) {
+             ret = dot11fUnpackIeRSN(pMac, pProfile->pRSNReqIE + 2,
+                                     pProfile->nRSNReqIELength -2, &rsn_ie);
+             if (DOT11F_SUCCEEDED(ret)) {
+                 pIesLocal->RSN.RSN_Cap[0] = pIesLocal->RSN.RSN_Cap[0] &
+                                             rsn_ie.RSN_Cap[0];
+                 pIesLocal->RSN.RSN_Cap[1] = pIesLocal->RSN.RSN_Cap[1] &
+                                             rsn_ie.RSN_Cap[1];
+             }
+         }
+
+        /* See if the cyphers in the Bss description match with the settings in the profile */
         fRSNMatch = csrGetRSNInformation( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType, 
                                             &pProfile->mcEncryptionType, &pIesLocal->RSN,
                                             UnicastCypher, MulticastCypher, AuthSuite, &RSNCapabilities, &negAuthType, NULL );
@@ -4057,12 +4073,12 @@
         pAuthSuite->cAuthenticationSuites = 1;
         vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
 
-        // RSN capabilities follows the Auth Suite (two octects)
-        // !!REVIEW - What should STA put in RSN capabilities, currently
-        // just putting back APs capabilities
-        // For one, we shouldn't EVER be sending out "pre-auth supported".  It is an AP only capability
-        // For another, we should use the Management Frame Protection values given by the supplicant
+        /* PreAuthSupported is an AP only capability */
         RSNCapabilities.PreAuthSupported = 0;
+
+        /* Use the Management Frame Protection values given by the supplicant,
+         * if AP and STA both are MFP capable.
+         */
 #ifdef WLAN_FEATURE_11W
         RSNCapabilities.MFPRequired = pProfile->MFPRequired;
         RSNCapabilities.MFPCapable = pProfile->MFPCapable;