wlan: Check sequence number before discarding auth frame.

Currently if a auth frame has retry bit set and its preauth context
exists, it is discarded. So even when a new auth frame is received
with retry bit set it is always discarded, resultig in connection
failure. As a part of fix, make sure that new auth frames(with
different sequence no.) are not discarded.

Change-Id: Iad862b0086b87e2fc113d6d9aae5b88a50d22d0f
CRs-Fixed: 787197
diff --git a/CORE/MAC/src/pe/include/limGlobal.h b/CORE/MAC/src/pe/include/limGlobal.h
index 8be34bb..8f8b913 100644
--- a/CORE/MAC/src/pe/include/limGlobal.h
+++ b/CORE/MAC/src/pe/include/limGlobal.h
@@ -357,6 +357,7 @@
     tANI_U8             fFree:1;
     tANI_U8             rsvd:5;
     TX_TIMER            timer;
+    tANI_U16            seqNo;
 }tLimPreAuthNode, *tpLimPreAuthNode;
 
 // Pre-authentication table definition
diff --git a/CORE/MAC/src/pe/lim/limProcessAuthFrame.c b/CORE/MAC/src/pe/lim/limProcessAuthFrame.c
index abdaddc..2247313 100644
--- a/CORE/MAC/src/pe/lim/limProcessAuthFrame.c
+++ b/CORE/MAC/src/pe/lim/limProcessAuthFrame.c
@@ -156,6 +156,7 @@
     tANI_U8                 challengeTextArray[SIR_MAC_AUTH_CHALLENGE_LENGTH];
     tpDphHashNode           pStaDs = NULL;
     tANI_U16                assocId = 0;
+    tANI_U16                currSeqNo = 0;
     /* Added For BT -AMP support */
     // Get pointer to Authentication frame header and body
  
@@ -184,6 +185,7 @@
 
         return;
     }
+    currSeqNo = (pHdr->seqControl.seqNumHi << 4) | (pHdr->seqControl.seqNumLo);
     limLog(pMac, LOG1,
                FL("Sessionid: %d System role : %d limMlmState: %d :Auth "
                "Frame Received: BSSID: "MAC_ADDRESS_STR " (RSSI %d)"),
@@ -642,7 +644,7 @@
             if (pAuthNode)
             {
                 /// Pre-auth context exists for the STA
-                if (pHdr->fc.retry == 0)
+                if (pHdr->fc.retry == 0 || pAuthNode->seqNo != currSeqNo)
                 {
                     /**
                      * STA is initiating brand-new Authentication
@@ -779,6 +781,8 @@
                                               pRxAuthFrameBody->authAlgoNumber;
                         pAuthNode->fSeen = 0;
                         pAuthNode->fTimerStarted = 0;
+                        pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
+                                            (pHdr->seqControl.seqNumLo));
                         limAddPreAuthNode(pMac, pAuthNode);
 
                         /**
@@ -884,6 +888,8 @@
                             pRxAuthFrameBody->authAlgoNumber;
                             pAuthNode->fSeen = 0;
                             pAuthNode->fTimerStarted = 0;
+                            pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
+                                                (pHdr->seqControl.seqNumLo));
                             limAddPreAuthNode(pMac, pAuthNode);
 
                             limLog(pMac, LOG1,
@@ -1125,6 +1131,8 @@
                                  sizeof(tSirMacAddr));
                     pAuthNode->fTimerStarted = 0;
                     pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
+                    pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
+                                        (pHdr->seqControl.seqNumLo));
                     limAddPreAuthNode(pMac, pAuthNode);
 
                     limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
@@ -1670,6 +1678,8 @@
                              sizeof(tSirMacAddr));
                 pAuthNode->fTimerStarted = 0;
                 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
+                pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
+                                    (pHdr->seqControl.seqNumLo));
                 limAddPreAuthNode(pMac, pAuthNode);
 
                 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,