wlan: Handle change in AP capabilities properly

In limDetectChangeInApCapabilities if Beacon capabilities
are not matching with the psessionEntry capabilities,
instead of sending eSIR_SME_AP_CAPS_CHANGED event, send a
probe req to AP.

This logic is already present for mismatch in Qos,
Short preamble, privacy bit and NULL ssid. Extending it
for remaining params.

When we recieve probe response check the session
capabilities against probe response and take the action
based on it.

CRs-Fixed: 589742
Change-Id: I658cfb2974e57aff0339ad0ab4d9b2ad419cf98c
diff --git a/CORE/MAC/src/pe/lim/limApi.c b/CORE/MAC/src/pe/lim/limApi.c
index fa58a2c..660a3e4 100644
--- a/CORE/MAC/src/pe/lim/limApi.c
+++ b/CORE/MAC/src/pe/lim/limApi.c
@@ -1736,79 +1736,45 @@
     apNewCaps.capabilityInfo = limGetU16((tANI_U8 *) &pBeacon->capabilityInfo);
     newChannel = (tANI_U8) pBeacon->channelNumber;
 
-    /* Some APs are not setting privacy bit when hidden ssid enabled.
-     * So LIM was keep on sending eSIR_SME_AP_CAPS_CHANGED event to SME */
-    if ((limIsNullSsid(&pBeacon->ssId) &&
-            (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
-             SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps))) ||
-            (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) !=
-             SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
-            (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) !=
-             SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps))
-       )
+    if ( ( false == psessionEntry->limSentCapsChangeNtf ) &&
+        ( ( ( limIsNullSsid(&pBeacon->ssId) ) ||
+          ( ( !limIsNullSsid(&pBeacon->ssId) ) &&
+             ( false == limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) ) ) ) ||
+          ( (SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) !=
+             SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps) ) ||
+          ( SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=
+            SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps) ) ||
+          ( SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) !=
+            SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps) ) ||
+          ( SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) !=
+            SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps) ) ||
+          ( newChannel !=  psessionEntry->currentOperChannel )
+          ) ) )
     {
-        /* If Hidden SSID and privacy bit is not matching with the current capability,
-         * then send unicast probe request to AP and take decision after
-         * receiving probe response */
-        if (psessionEntry->fIgnoreCapsChange == true)
+        if( false == psessionEntry->fWaitForProbeRsp )
         {
-            limLog(pMac, LOGW, FL("Ignoring the Capability change as it is false alarm"));
+            /* If Beacon capabilities is not matching with the current capability,
+             * then send unicast probe request to AP and take decision after
+             * receiving probe response */
+            if ( true == psessionEntry->fIgnoreCapsChange )
+            {
+                limLog(pMac, LOGW, FL("Ignoring the Capability change as it is false alarm"));
+                return;
+            }
+            psessionEntry->fWaitForProbeRsp = true;
+            limLog(pMac, LOGW, FL("AP capabilities are not matching,"
+                   "sending directed probe request.. "));
+            status = limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId,
+                    psessionEntry->currentOperChannel,psessionEntry->selfMacAddr,
+                    psessionEntry->dot11mode, 0, NULL);
+
+            if ( eSIR_SUCCESS != status )
+            {
+               limLog(pMac, LOGE, FL("send ProbeReq failed"));
+               psessionEntry->fWaitForProbeRsp = false;
+            }
             return;
         }
-        psessionEntry->fWaitForProbeRsp = true;
-        limLog(pMac, LOGW, FL("Hidden SSID and privacy bit is not matching,"
-                    " Or Short preamble bit is not matching ,"
-                    "sending directed probe request.. "));
-        status = limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId,
-                psessionEntry->currentOperChannel,psessionEntry->selfMacAddr,
-                psessionEntry->dot11mode, 0, NULL);
-
-        if ( status != eSIR_SUCCESS)
-        {
-            limLog(pMac, LOGE, FL("send ProbeReq failed"));
-        }
-
-        return;
-    }
-    else
-    {
-        /* The control will come here if the frame is beacon with broadcast ssid
-         * or probe response frame */
-        if (psessionEntry->fWaitForProbeRsp == true)
-        {
-            if ((((!limIsNullSsid(&pBeacon->ssId)) &&
-                        (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == true)) &&
-                    (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) ==
-                     SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps))) &&
-                    (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) ==
-                     SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) &&
-                    (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) ==
-                     SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps))
-               )
-            {
-                /* Only for probe response frames the control will come here */
-                /* If beacon with broadcast ssid then fWaitForProbeRsp will be false,
-                   the control wll not come here*/
-                limLog(pMac, LOGW, FL("Privacy bit in probe response is"
-                            "matching with the current setting,"
-                            "Ignoring subsequent privacy bit capability"
-                            "mismatch"));
-                psessionEntry->fIgnoreCapsChange = true;
-                psessionEntry->fWaitForProbeRsp = false;
-            }
-        }
-    }
-
-    if ((psessionEntry->limSentCapsChangeNtf == false) &&
-        (((!limIsNullSsid(&pBeacon->ssId)) && (limCmpSSid(pMac, &pBeacon->ssId, psessionEntry) == false)) ||
-        ((SIR_MAC_GET_ESS(apNewCaps.capabilityInfo) != SIR_MAC_GET_ESS(psessionEntry->limCurrentBssCaps)) ||
-         (SIR_MAC_GET_PRIVACY(apNewCaps.capabilityInfo) !=   SIR_MAC_GET_PRIVACY(psessionEntry->limCurrentBssCaps)) ||
-         (SIR_MAC_GET_SHORT_PREAMBLE(apNewCaps.capabilityInfo) !=  SIR_MAC_GET_SHORT_PREAMBLE(psessionEntry->limCurrentBssCaps)) ||
-         (SIR_MAC_GET_QOS(apNewCaps.capabilityInfo) !=   SIR_MAC_GET_QOS(psessionEntry->limCurrentBssCaps)) ||
-         (newChannel !=  psessionEntry->currentOperChannel)
-         )))
-    {
-
         /**
          * BSS capabilities have changed.
          * Inform Roaming.
@@ -1859,6 +1825,20 @@
                                     (tANI_U32 *) &apNewCaps,
                                     len, psessionEntry->smeSessionId);
     }
+    else if ( true == psessionEntry->fWaitForProbeRsp )
+    {
+        /* Only for probe response frames and matching capabilities the control
+         * will come here. If beacon is with broadcast ssid then fWaitForProbeRsp
+         * will be false, the control will not come here*/
+
+        limLog(pMac, LOG1, FL("capabilities in probe response are"
+                    "matching with the current setting,"
+                    "Ignoring subsequent capability"
+                    "mismatch"));
+        psessionEntry->fIgnoreCapsChange = true;
+        psessionEntry->fWaitForProbeRsp = false;
+     }
+
 } /*** limDetectChangeInApCapabilities() ***/