blob: 848dbc51cc234c397e1f974cbb4ecdb32b8faf21 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302 * Copyright (c) 2011-2015, 2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080028/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * This file limProcessAuthFrame.cc contains the code
30 * for processing received Authentication Frame.
31 * Author: Chandra Modumudi
32 * Date: 03/11/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 * 05/12/2010 js To support Shared key authentication at AP side
37 *
38 */
39
40#include "wniApi.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053041#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070042#include "aniGlobal.h"
43#include "cfgApi.h"
44
45#include "utilsApi.h"
46#include "limUtils.h"
47#include "limAssocUtils.h"
48#include "limSecurityUtils.h"
49#include "limSerDesUtils.h"
50#ifdef WLAN_FEATURE_VOWIFI_11R
51#include "limFT.h"
52#endif
53#include "vos_utils.h"
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053054#ifdef WLAN_FEATURE_LFR_MBB
55#include "lim_mbb.h"
56#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070057
58
59/**
60 * isAuthValid
61 *
62 *FUNCTION:
63 * This function is called by limProcessAuthFrame() upon Authentication
64 * frame reception.
65 *
66 *LOGIC:
67 * This function is used to test validity of auth frame:
68 * - AUTH1 and AUTH3 must be received in AP mode
69 * - AUTH2 and AUTH4 must be received in STA mode
70 * - AUTH3 and AUTH4 must have challenge text IE, that is,'type' field has been set to
71 * SIR_MAC_CHALLENGE_TEXT_EID by parser
72 * -
73 *
74 *ASSUMPTIONS:
75 *
76 *NOTE:
77 *
78 * @param *auth - Pointer to extracted auth frame body
79 *
80 * @return 0 or 1 (Valid)
81 */
82
83
84static inline unsigned int isAuthValid(tpAniSirGlobal pMac, tpSirMacAuthFrameBody auth,tpPESession sessionEntry) {
85 unsigned int valid;
86 valid=1;
87
88 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_1)||
89 (auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)) &&
90 ((sessionEntry->limSystemRole == eLIM_STA_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)))
91 valid=0;
92
93 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_2)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&&
94 ((sessionEntry->limSystemRole == eLIM_AP_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)))
95 valid=0;
96
97 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&&
98 (auth->type!=SIR_MAC_CHALLENGE_TEXT_EID)&&(auth->authAlgoNumber != eSIR_SHARED_KEY))
99 valid=0;
100
101 return valid;
102}
103
104
105/**
106 * limProcessAuthFrame
107 *
108 *FUNCTION:
109 * This function is called by limProcessMessageQueue() upon Authentication
110 * frame reception.
111 *
112 *LOGIC:
113 * This function processes received Authentication frame and responds
114 * with either next Authentication frame in sequence to peer MAC entity
115 * or LIM_MLM_AUTH_IND on AP or LIM_MLM_AUTH_CNF on STA.
116 *
117 *ASSUMPTIONS:
118 *
119 *NOTE:
120 * 1. Authentication failures are reported to SME with same status code
121 * received from the peer MAC entity.
122 * 2. Authentication frame2/4 received with alogirthm number other than
123 * one requested in frame1/3 are logged with an error and auth confirm
124 * will be sent to SME only after auth failure timeout.
125 * 3. Inconsistency in the spec:
126 * On receiving Auth frame2, specs says that if WEP key mapping key
127 * or default key is NULL, Auth frame3 with a status code 15 (challenge
128 * failure to be returned to peer entity. However, section 7.2.3.10,
129 * table 14 says that status code field is 'reserved' for frame3 !
130 * In the current implementation, Auth frame3 is returned with status
131 * code 15 overriding section 7.2.3.10.
132 * 4. If number pre-authentications reach configrable max limit,
133 * Authentication frame with 'unspecified failure' status code is
134 * returned to requesting entity.
135 *
136 * @param pMac - Pointer to Global MAC structure
137 * @param *pRxPacketInfo - A pointer to Rx packet info structure
138 * @return None
139 */
140
141void
142limProcessAuthFrame(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tpPESession psessionEntry)
143{
144 tANI_U8 *pBody, keyId, cfgPrivacyOptImp,
145 defaultKey[SIR_MAC_KEY_LENGTH],
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530146 *encrAuthFrame = NULL,
147 *plainBody = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 tANI_U16 frameLen;
149 //tANI_U32 authRspTimeout, maxNumPreAuth, val;
150 tANI_U32 maxNumPreAuth, val;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530151 tSirMacAuthFrameBody *pRxAuthFrameBody,
152 *rxAuthFrame = NULL,
153 *authFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 tpSirMacMgmtHdr pHdr;
155 tCfgWepKeyEntry *pKeyMapEntry = NULL;
156 struct tLimPreAuthNode *pAuthNode;
157 tLimMlmAuthInd mlmAuthInd;
158 tANI_U8 decryptResult;
159 tANI_U8 *pChallenge;
160 tANI_U32 key_length=8;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530161 tANI_U8 *challengeTextArray = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 tpDphHashNode pStaDs = NULL;
163 tANI_U16 assocId = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530164 tANI_U16 currSeqNo = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 /* Added For BT -AMP support */
166 // Get pointer to Authentication frame header and body
167
168
169 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
170 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700171
172 if (!frameLen)
173 {
174 // Log error
175 limLog(pMac, LOGE,
176 FL("received Authentication frame with no body from "));
177 limPrintMacAddr(pMac, pHdr->sa, LOGE);
178
179 return;
180 }
181
182 if (limIsGroupAddr(pHdr->sa))
183 {
184 // Received Auth frame from a BC/MC address
185 // Log error and ignore it
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530186 limLog(pMac, LOGE,
187 FL("received Auth frame from a BC/MC address - "));
188 limPrintMacAddr(pMac, pHdr->sa, LOGE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700189
190 return;
191 }
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530192 currSeqNo = (pHdr->seqControl.seqNumHi << 4) | (pHdr->seqControl.seqNumLo);
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530193 limLog(pMac, LOG1,
194 FL("Sessionid: %d System role : %d limMlmState: %d :Auth "
195 "Frame Received: BSSID: "MAC_ADDRESS_STR " (RSSI %d)"),
196 psessionEntry->peSessionId, psessionEntry->limSystemRole,
197 psessionEntry->limMlmState, MAC_ADDR_ARRAY(pHdr->bssId),
198 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo)));
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800199
Jeff Johnson295189b2012-06-20 16:38:30 -0700200 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
201
Jeff Johnsone7245742012-09-05 17:12:55 -0700202 //PELOG3(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG3, (tANI_U8*)pBd, ((tpHalBufDesc) pBd)->mpduDataOffset + frameLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700203
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800204 //Restore default failure timeout
205 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
206 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530207 limLog(pMac, LOG1, FL("Restore default failure timeout"));
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800208 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
209 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
210 }
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530211
212 rxAuthFrame = vos_mem_malloc(sizeof(tSirMacAuthFrameBody));
213 if (!rxAuthFrame) {
214 limLog(pMac, LOGE, FL("Failed to allocate memory"));
215 return;
216 }
217
218 authFrame = vos_mem_malloc(sizeof(tSirMacAuthFrameBody));
219 if (!authFrame) {
220 limLog(pMac, LOGE, FL("failed to allocate memory"));
221 goto free;
222 }
223
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530224 plainBody = vos_mem_malloc(LIM_ENCR_AUTH_BODY_LEN);
225 if (!plainBody) {
226 limLog(pMac, LOGE, FL("failed to allocate memory"));
227 goto free;
228 }
229
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +0530230 challengeTextArray = vos_mem_malloc(SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530231 if(!challengeTextArray) {
232 limLog(pMac, LOGE, FL("failed to allocate memory"));
233 goto free;
234 }
235
236 vos_mem_set(rxAuthFrame, sizeof(tSirMacAuthFrameBody), 0);
237 vos_mem_set(authFrame, sizeof(tSirMacAuthFrameBody), 0);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530238 vos_mem_set(plainBody, LIM_ENCR_AUTH_BODY_LEN, 0);
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +0530239 vos_mem_set(challengeTextArray, SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700240
241 /// Determine if WEP bit is set in the FC or received MAC header
242 if (pHdr->fc.wep)
243 {
244 /**
245 * WEP bit is set in FC of MAC header.
246 */
247
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 // If TKIP counter measures enabled issue Deauth frame to station
249 if ((psessionEntry->bTkipCntrMeasActive) && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
250 {
251 PELOGE( limLog(pMac, LOGE,
252 FL("Tkip counter measures Enabled, sending Deauth frame to")); )
253 limPrintMacAddr(pMac, pHdr->sa, LOGE);
254
255 limSendDeauthMgmtFrame( pMac, eSIR_MAC_MIC_FAILURE_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800256 pHdr->sa, psessionEntry, FALSE );
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530257 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700258 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700259
260 // Extract key ID from IV (most 2 bits of 4th byte of IV)
261
262 keyId = (*(pBody + 3)) >> 6;
263
264 /**
265 * On STA in infrastructure BSS, Authentication frames received
266 * with WEP bit set in the FC must be rejected with challenge
267 * failure status code (wierd thing in the spec - this should have
268 * been rejected with unspecified failure or unexpected assertion
269 * of wep bit (this status code does not exist though) or
270 * Out-of-sequence-Authentication-Frame status code.
271 */
272
273 if (psessionEntry->limSystemRole == eLIM_STA_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)
274 {
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530275 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
276 authFrame->authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
277 authFrame->authStatusCode = eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Abhishek Singh208848c2013-12-18 19:02:52 +0530278 // Log error
279 PELOGE(limLog(pMac, LOGE,
280 FL("received Authentication frame with wep bit set on "
281 "role=%d "MAC_ADDRESS_STR),
282 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pHdr->sa) );)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530283 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530285 LIM_NO_WEP_IN_FC,
286 psessionEntry, eSIR_FALSE);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530287 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700288 }
289
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +0530290 if (frameLen < LIM_ENCR_AUTH_BODY_LEN_SAP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 {
292 // Log error
293 limLog(pMac, LOGE,
294 FL("Not enough size [%d] to decrypt received Auth frame"),
295 frameLen);
296 limPrintMacAddr(pMac, pHdr->sa, LOGE);
297
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530298 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
301 {
302 val = psessionEntry->privacy;
303 }
304 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700305 // Accept Authentication frame only if Privacy is implemented
306 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
307 &val) != eSIR_SUCCESS)
308 {
309 /**
310 * Could not get Privacy option
311 * from CFG. Log error.
312 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700313 limLog(pMac, LOGP, FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700314 }
315
316 cfgPrivacyOptImp = (tANI_U8)val;
317 if (cfgPrivacyOptImp)
318 {
319 /**
320 * Privacy option is implemented.
321 * Check if the received frame is Authentication
322 * frame3 and there is a context for requesting STA.
323 * If not, reject with unspecified failure status code
324 */
325 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
326
327 if (pAuthNode == NULL)
328 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530329 // Log error
330 PELOGE(limLog(pMac, LOGE,
331 FL("received Authentication frame from peer that has "
332 "no preauth context with WEP bit set "MAC_ADDRESS_STR),
333 MAC_ADDR_ARRAY(pHdr->sa));)
334
Jeff Johnson295189b2012-06-20 16:38:30 -0700335 /**
336 * No 'pre-auth' context exists for this STA that sent
337 * an Authentication frame with FC bit set.
338 * Send Auth frame4 with 'out of sequence' status code.
339 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530340 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
341 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700342 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530343 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
345
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530346 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530348 LIM_NO_WEP_IN_FC,
349 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700350
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530351 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 }
353 else
354 {
355 /// Change the auth-response timeout
356 limDeactivateAndChangePerStaIdTimer(pMac,
357 eLIM_AUTH_RSP_TIMER,
358 pAuthNode->authNodeIdx);
359
360 /// 'Pre-auth' status exists for STA
361 if ((pAuthNode->mlmState !=
362 eLIM_MLM_WT_AUTH_FRAME3_STATE) &&
363 (pAuthNode->mlmState !=
364 eLIM_MLM_AUTH_RSP_TIMEOUT_STATE))
365 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530366 // Log error
367 PELOGE(limLog(pMac, LOGE,
368 FL("received Authentication frame from peer that is "
369 "in state %d "MAC_ADDRESS_STR),
370 pAuthNode->mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
371
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 /**
373 * Should not have received Authentication frame
374 * with WEP bit set in FC in other states.
375 * Reject by sending Authenticaton frame with
376 * out of sequence Auth frame status code.
377 */
378
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530379 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
380 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530382 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
384
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530385 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700386 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530387 LIM_NO_WEP_IN_FC,
388 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700389
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530390 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 }
392 }
393
394 /**
395 * Check if there exists a key mappping key
396 * for the STA that sent Authentication frame
397 */
398 pKeyMapEntry = limLookUpKeyMappings(pHdr->sa);
399
400 if (pKeyMapEntry)
401 {
402 if (!pKeyMapEntry->wepOn)
403 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530404 // Log error
405 PELOGE(limLog(pMac, LOGE,
406 FL("received Auth frame3 from peer that has NULL "
407 "key map entry "
408 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));)
409
Jeff Johnson295189b2012-06-20 16:38:30 -0700410 /**
411 * Key Mapping entry has null key.
412 * Send Authentication frame
413 * with challenge failure status code
414 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530415 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
416 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700417 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530418 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700419 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
420
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530421 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700422 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530423 LIM_NO_WEP_IN_FC,
424 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700425
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530426 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700427 } // if (!pKeyMapEntry->wepOn)
428 else
429 {
430 decryptResult = limDecryptAuthFrame(pMac, pKeyMapEntry->key,
431 pBody,
432 plainBody,
433 key_length,
434 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
435 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
436 {
437 /// ICV failure
Abhishek Singh208848c2013-12-18 19:02:52 +0530438 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
439 "LIM_DECRYPT_ICV_FAIL ..."));)
440 // Log error
441 PELOGE(limLog(pMac, LOGE,
442 FL("received Authentication frame from peer "
443 "that failed decryption, Addr "
444 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
445
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 limDeletePreAuthNode(pMac,
447 pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530448 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
449 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530451 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
453
454 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530455 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530457 LIM_NO_WEP_IN_FC,
458 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700459
Jeff Johnson295189b2012-06-20 16:38:30 -0700460
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530461 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 }
463
Abhishek Singh208848c2013-12-18 19:02:52 +0530464 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530465 rxAuthFrame)!=eSIR_SUCCESS ) ||
466 ( !isAuthValid(pMac, rxAuthFrame,psessionEntry) ) )
Abhishek Singh208848c2013-12-18 19:02:52 +0530467 {
468 PELOGE(limLog(pMac, LOGE,
469 FL("failed to convert Auth Frame to structure "
470 "or Auth is not valid "));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530471 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530472 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700473
474
475 } // end if (pKeyMapEntry->key == NULL)
476 } // if keyMappings has entry
477 else
478 {
479
480 val = SIR_MAC_KEY_LENGTH;
481
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
483 {
484 tpSirKeys pKey;
485 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530486 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 val = pKey->keyLength;
488 }
489 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
491 defaultKey, &val) != eSIR_SUCCESS)
492 {
493 /// Could not get Default key from CFG.
494 //Log error.
495 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700496 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700497
498 /**
499 * Send Authentication frame
500 * with challenge failure status code
501 */
502
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530503 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
504 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530506 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
508
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530509 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530511 LIM_NO_WEP_IN_FC,
512 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700513
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530514 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 }
516
517 key_length=val;
518
519 decryptResult = limDecryptAuthFrame(pMac, defaultKey,
520 pBody,
521 plainBody,
522 key_length,
523 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
524 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
525 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530526 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
527 "LIM_DECRYPT_ICV_FAIL ..."));)
528 // Log error
529 PELOGE(limLog(pMac, LOGE,
530 FL("received Authentication frame from peer that "
531 "failed decryption: "
532 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 /// ICV failure
534 limDeletePreAuthNode(pMac,
535 pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530536 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
537 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530539 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
541
542 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530543 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530545 LIM_NO_WEP_IN_FC,
546 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700547
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530548 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530550 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530551 rxAuthFrame)!=eSIR_SUCCESS ) ||
552 ( !isAuthValid(pMac, rxAuthFrame, psessionEntry) ) )
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530553 {
554 limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +0530555 FL("failed to convert Auth Frame to structure "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530556 "or Auth is not valid "));
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530557 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530558 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 } // End of check for Key Mapping/Default key presence
560 }
561 else
562 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530563 // Log error
564 PELOGE(limLog(pMac, LOGE,
565 FL("received Authentication frame3 from peer that while "
566 "privacy option is turned OFF "
567 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700568 /**
569 * Privacy option is not implemented.
570 * So reject Authentication frame received with
571 * WEP bit set by sending Authentication frame
572 * with 'challenge failure' status code. This is
573 * another strange thing in the spec. Status code
574 * should have been 'unsupported algorithm' status code.
575 */
576
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530577 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
578 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530580 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
582
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530583 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530585 LIM_NO_WEP_IN_FC,
586 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530588 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 } // else if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
590 } // if (fc.wep)
591 else
592 {
593
594
Abhishek Singh208848c2013-12-18 19:02:52 +0530595 if ( ( sirConvertAuthFrame2Struct(pMac, pBody,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530596 frameLen, rxAuthFrame)!=eSIR_SUCCESS ) ||
597 ( !isAuthValid(pMac, rxAuthFrame,psessionEntry) ) )
Abhishek Singh208848c2013-12-18 19:02:52 +0530598 {
599 PELOGE(limLog(pMac, LOGE,
600 FL("failed to convert Auth Frame to structure or Auth is "
601 "not valid "));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530602 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530603 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 }
605
606
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530607 pRxAuthFrameBody = rxAuthFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -0700608
Mohit Khanna23863762012-09-11 17:40:09 -0700609 PELOGW(limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700610 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
612 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
613 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
614
Wang Hu4506bae2015-12-07 14:15:19 +0800615 // IOT Workaround: with invalid WEP password, some APs reply AUTH frame 4
616 // with invalid seqNumber. This AUTH frame will be dropped by driver,
617 // thus driver sends the generic status code instead of protocol status code.
618 // As a workaround, assign the correct seqNumber for the AUTH frame 4.
619 if (psessionEntry->limMlmState == eLIM_MLM_WT_AUTH_FRAME4_STATE &&
620 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_1 &&
621 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_2 &&
622 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_3) {
623 PELOGE(limLog(pMac, LOGE, FL("Workaround: Assign a correct seqNumber=4 "
624 "for AUTH frame 4"));)
625 pRxAuthFrameBody->authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
626 }
627
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 switch (pRxAuthFrameBody->authTransactionSeqNumber)
629 {
630 case SIR_MAC_AUTH_FRAME_1:
631 // AuthFrame 1
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800632
633 pStaDs = dphLookupHashEntry(pMac, pHdr->sa,
634 &assocId, &psessionEntry->dph.dphHashTable);
635 if (pStaDs)
636 {
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530637 tLimMlmDisassocReq *pMlmDisassocReq = NULL;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800638 tLimMlmDeauthReq *pMlmDeauthReq = NULL;
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530639 tAniBool isConnected = eSIR_TRUE;
640
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800641 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
642 if (pMlmDisassocReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530643 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800644 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530645 sizeof(tSirMacAddr))))
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800646 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800647 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for disassoc "
648 "frame is pending Issue delsta for "
649 MAC_ADDRESS_STR),
650 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700651 limProcessDisassocAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530652 isConnected = eSIR_FALSE;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800653 }
654 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
655 if (pMlmDeauthReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530656 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800657 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
658 sizeof(tSirMacAddr))))
659 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800660 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for deauth frame "
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700661 "is pending Issue delsta for "
Arif Hussain24bafea2013-11-15 15:10:03 -0800662 MAC_ADDRESS_STR),
663 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700664 limProcessDeauthAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530665 isConnected = eSIR_FALSE;
666 }
667
668 /* pStaDS != NULL and isConnected = 1 means the STA is already
669 * connected, But SAP received the Auth from that station.
Abhishek Singh0496a522015-12-14 23:39:23 -0800670 * For non PMF connection send Deauth frame as STA will retry
671 * to connect back.
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530672 *
673 * For PMF connection the AP should not tear down or otherwise
674 * modify the state of the existing association until the
675 * SA-Query procedure determines that the original SA is
676 * invalid.
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530677 */
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530678 if (isConnected
679#ifdef WLAN_FEATURE_11W
680 && !pStaDs->rmfEnabled
681#endif
682 )
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530683 {
Abhishek Singh0496a522015-12-14 23:39:23 -0800684 limLog(pMac, LOGE,
685 FL("STA is already connected but received auth frame"
686 "Send the Deauth and lim Delete Station Context"
687 "(staId: %d, assocId: %d) "),
688 pStaDs->staIndex, assocId);
689 limSendDeauthMgmtFrame(pMac, eSIR_MAC_UNSPEC_FAILURE_REASON,
690 (tANI_U8 *) pHdr->sa, psessionEntry, FALSE);
691 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530692 goto free;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800693 }
694 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700695
696 /// Check if there exists pre-auth context for this STA
697 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
698 if (pAuthNode)
699 {
700 /// Pre-auth context exists for the STA
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530701 if (pHdr->fc.retry == 0 || pAuthNode->seqNo != currSeqNo)
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 {
703 /**
704 * STA is initiating brand-new Authentication
705 * sequence after local Auth Response timeout.
706 * Or STA retrying to transmit First Auth frame due to packet drop OTA
707 * Delete Pre-auth node and fall through.
708 */
709 if(pAuthNode->fTimerStarted)
710 {
711 limDeactivateAndChangePerStaIdTimer(pMac,
712 eLIM_AUTH_RSP_TIMER,
713 pAuthNode->authNodeIdx);
714 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530715 PELOGE(limLog(pMac, LOGE, FL("STA is initiating brand-new "
716 "Authentication ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 limDeletePreAuthNode(pMac,
718 pHdr->sa);
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 /**
720 * SAP Mode:Disassociate the station and
721 * delete its entry if we have its entry
722 * already and received "auth" from the
723 * same station.
724 */
725
726 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
727 {
728 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
729
730 if (NULL == pStaDs)
731 continue;
732
733 if (pStaDs->valid)
734 {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530735 if (vos_mem_compare((tANI_U8 *) &pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 (tANI_U8 *) &(pHdr->sa), (tANI_U8) (sizeof(tSirMacAddr))) )
737 break;
738 }
Edhar, Mahesh Kumar29013e82014-02-05 10:38:08 +0530739
740 pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 }
742
Abhishek Singhe9417492014-09-25 15:55:36 +0530743 if (NULL != pStaDs
744#ifdef WLAN_FEATURE_11W
745 && !pStaDs->rmfEnabled
746#endif
747 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 {
Abhishek Singh0496a522015-12-14 23:39:23 -0800749 PELOGE(limLog(pMac, LOGE, FL("lim Delete Station "
750 "Context (staId: %d, assocId: %d) "),pStaDs->staIndex,
751 assocId);)
752 limSendDeauthMgmtFrame(pMac,
753 eSIR_MAC_UNSPEC_FAILURE_REASON, (tANI_U8 *) pAuthNode->peerMacAddr, psessionEntry, FALSE);
754 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530755 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 }
758 else
759 {
760 /*
761 * This can happen when first authentication frame is received
762 * but ACK lost at STA side, in this case 2nd auth frame is already
763 * in transmission queue
764 * */
Abhishek Singh208848c2013-12-18 19:02:52 +0530765 PELOGE(limLog(pMac, LOGE, FL("STA is initiating "
766 "Authentication after ACK lost..."));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530767 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 }
769 }
770 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
771 (tANI_U32 *) &maxNumPreAuth) != eSIR_SUCCESS)
772 {
773 /**
774 * Could not get MaxNumPreAuth
775 * from CFG. Log error.
776 */
777 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700778 FL("could not retrieve MaxNumPreAuth"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 }
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530780
781 if (pMac->lim.gLimNumPreAuthContexts == maxNumPreAuth &&
782 !limDeleteOpenAuthPreAuthNode(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530784 PELOGE(limLog(pMac, LOGE, FL("Max number of "
785 "preauth context reached"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 /**
787 * Maximum number of pre-auth contexts
788 * reached. Send Authentication frame
789 * with unspecified failure
790 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530791 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530793 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530795 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 eSIR_MAC_UNSPEC_FAILURE_STATUS;
797
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530798 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700799 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530800 LIM_NO_WEP_IN_FC,
801 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700802
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530803 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 }
805 /// No Pre-auth context exists for the STA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 if (limIsAuthAlgoSupported(
807 pMac,
808 (tAniAuthType)
809 pRxAuthFrameBody->authAlgoNumber, psessionEntry))
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 {
811 switch (pRxAuthFrameBody->authAlgoNumber)
812 {
813 case eSIR_OPEN_SYSTEM:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700814 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_OPEN_SYSTEM ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 /// Create entry for this STA in pre-auth list
816 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
817 if (pAuthNode == NULL)
818 {
819 // Log error
820 limLog(pMac, LOGW,
821 FL("Max pre-auth nodes reached "));
822 limPrintMacAddr(pMac, pHdr->sa, LOGW);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530823 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 }
825
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530826 limLog(pMac, LOG1,
827 FL("Alloc new data: peer "MAC_ADDRESS_STR),
828 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700829
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530830 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
831 pHdr->sa,
832 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700833
834 pAuthNode->mlmState =
835 eLIM_MLM_AUTHENTICATED_STATE;
836 pAuthNode->authType = (tAniAuthType)
837 pRxAuthFrameBody->authAlgoNumber;
838 pAuthNode->fSeen = 0;
839 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530840 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
841 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530842 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 limAddPreAuthNode(pMac, pAuthNode);
844
845 /**
846 * Send Authenticaton frame with Success
847 * status code.
848 */
849
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530850 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530852 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700853 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530854 authFrame->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530856 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530858 LIM_NO_WEP_IN_FC,
859 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700860
861 /// Send Auth indication to SME
862
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530863 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 (tANI_U8 *) pHdr->sa,
865 sizeof(tSirMacAddr));
866 mlmAuthInd.authType = (tAniAuthType)
867 pRxAuthFrameBody->authAlgoNumber;
868 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
869
870 limPostSmeMessage(pMac,
871 LIM_MLM_AUTH_IND,
872 (tANI_U32 *) &mlmAuthInd);
873 break;
874
875 case eSIR_SHARED_KEY:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700876 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_SHARED_KEY ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
878 {
879 val = psessionEntry->privacy;
880 }
881 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
883 &val) != eSIR_SUCCESS)
884 {
885 /**
886 * Could not get Privacy option
887 * from CFG. Log error.
888 */
889 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700890 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 }
892 cfgPrivacyOptImp = (tANI_U8)val;
893 if (!cfgPrivacyOptImp)
894 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530895 // Log error
896 PELOGE(limLog(pMac, LOGE,
897 FL("received Auth frame for unsupported auth algorithm %d "
898 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
899 MAC_ADDR_ARRAY(pHdr->sa));)
900
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 /**
902 * Authenticator does not have WEP
903 * implemented.
904 * Reject by sending Authentication frame
905 * with Auth algorithm not supported status
906 * code.
907 */
908
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530909 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530911 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530913 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
915
916 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530917 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530919 LIM_NO_WEP_IN_FC,
920 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530922 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 }
924 else
925 {
926 // Create entry for this STA
927 //in pre-auth list
928 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
929 if (pAuthNode == NULL)
930 {
931 // Log error
932 limLog(pMac, LOGW,
933 FL("Max pre-auth nodes reached "));
934 limPrintMacAddr(pMac, pHdr->sa, LOGW);
935
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530936 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 }
938
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530939 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
940 pHdr->sa,
941 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700942
943 pAuthNode->mlmState =
944 eLIM_MLM_WT_AUTH_FRAME3_STATE;
945 pAuthNode->authType =
946 (tAniAuthType)
947 pRxAuthFrameBody->authAlgoNumber;
948 pAuthNode->fSeen = 0;
949 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530950 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
951 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530952 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 limAddPreAuthNode(pMac, pAuthNode);
954
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530955 limLog(pMac, LOG1,
956 FL("Alloc new data: id %d peer "MAC_ADDRESS_STR),
957 pAuthNode->authNodeIdx, MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700958
959 /// Create and activate Auth Response timer
960 if (tx_timer_change_context(&pAuthNode->timer, pAuthNode->authNodeIdx) != TX_SUCCESS)
961 {
962 /// Could not start Auth response timer.
963 // Log error
964 limLog(pMac, LOGP,
965 FL("Unable to chg context auth response timer for peer "));
966 limPrintMacAddr(pMac, pHdr->sa, LOGP);
967
968 /**
969 * Send Authenticaton frame with
970 * unspecified failure status code.
971 */
972
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530973 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530975 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700976 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530977 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 eSIR_MAC_UNSPEC_FAILURE_STATUS;
979
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530980 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530982 LIM_NO_WEP_IN_FC,
983 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700984
985 limDeletePreAuthNode(pMac, pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530986 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 }
988
989 limActivateAuthRspTimer(pMac, pAuthNode);
990
991 pAuthNode->fTimerStarted = 1;
992
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530993 /*
994 * get random bytes and use as challenge text
995 */
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +0530996 if( !VOS_IS_STATUS_SUCCESS( vos_rand_get_bytes( 0, (tANI_U8 *)challengeTextArray, SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700997 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530998 limLog(pMac, LOGE,FL("Challenge text "
999 "preparation failed in limProcessAuthFrame"));
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301000 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 }
1002
1003 pChallenge = pAuthNode->challengeText;
1004
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301005 vos_mem_copy(pChallenge,
1006 (tANI_U8 *) challengeTextArray,
1007 sizeof(challengeTextArray));
Jeff Johnson295189b2012-06-20 16:38:30 -07001008
1009 /**
1010 * Sending Authenticaton frame with challenge.
1011 */
1012
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301013 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301015 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301017 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 eSIR_MAC_SUCCESS_STATUS;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301019 authFrame->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301020 authFrame->length = SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301021 vos_mem_copy(authFrame->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 pAuthNode->challengeText,
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301023 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -07001024
1025 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301026 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301028 LIM_NO_WEP_IN_FC,
1029 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 } // if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1031
1032 break;
1033
1034 default:
Abhishek Singh208848c2013-12-18 19:02:52 +05301035 // Log error
1036 PELOGE( limLog(pMac, LOGE,
1037 FL("received Auth frame for unsupported auth "
1038 "algorithm %d "MAC_ADDRESS_STR),
1039 pRxAuthFrameBody->authAlgoNumber,
1040 MAC_ADDR_ARRAY(pHdr->sa));)
1041
Jeff Johnson295189b2012-06-20 16:38:30 -07001042 /**
1043 * Responding party does not support the
1044 * authentication algorithm requested by
1045 * sending party.
1046 * Reject by sending Authentication frame
1047 * with auth algorithm not supported status code
1048 */
1049
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301050 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301052 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301054 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1056
1057 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301058 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301060 LIM_NO_WEP_IN_FC,
1061 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001062
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301063 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 } // end switch(pRxAuthFrameBody->authAlgoNumber)
1065 } // if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1066 else
1067 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301068 // Log error
1069 PELOGE(limLog(pMac, LOGE,
1070 FL("received Authentication frame for unsupported auth "
1071 "algorithm %d "MAC_ADDRESS_STR),
1072 pRxAuthFrameBody->authAlgoNumber,
1073 MAC_ADDR_ARRAY(pHdr->sa));)
1074
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 /**
1076 * Responding party does not support the
1077 * authentication algorithm requested by sending party.
1078 * Reject Authentication with StatusCode=13.
1079 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301080 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301082 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301084 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1086
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301087 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301089 LIM_NO_WEP_IN_FC,
1090 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001091
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301092 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 } //end if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1094 break;
1095
1096 case SIR_MAC_AUTH_FRAME_2:
1097 // AuthFrame 2
1098
1099 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME2_STATE)
1100 {
1101 /**
1102 * Received Authentication frame2 in an unexpected state.
1103 * Log error and ignore the frame.
1104 */
1105
1106 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301107 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 FL("received Auth frame2 from peer in state %d, addr "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301109 psessionEntry->limMlmState);
1110 limPrintMacAddr(pMac, pHdr->sa, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001111
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301112 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 }
1114
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301115 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1116 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1117 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 {
1119 /**
1120 * Received Authentication frame from an entity
1121 * other than one request was initiated.
1122 * Wait until Authentication Failure Timeout.
1123 */
1124
1125 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001126 PELOGW(limLog(pMac, LOGW,
Abhishek Singh208848c2013-12-18 19:02:52 +05301127 FL("received Auth frame2 from unexpected peer "
1128 MAC_ADDRESS_STR),
Mohit Khanna23863762012-09-11 17:40:09 -07001129 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001130
1131 break;
1132 }
1133
1134 if (pRxAuthFrameBody->authStatusCode ==
1135 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS)
1136 {
1137 /**
1138 * Interoperability workaround: Linksys WAP4400N is returning
1139 * wrong authType in OpenAuth response in case of
1140 * SharedKey AP configuration. Pretend we don't see that,
1141 * so upper layer can fallback to SharedKey authType,
1142 * and successfully connect to the AP.
1143 */
1144 if (pRxAuthFrameBody->authAlgoNumber !=
1145 pMac->lim.gpLimMlmAuthReq->authType)
1146 {
1147 pRxAuthFrameBody->authAlgoNumber =
1148 pMac->lim.gpLimMlmAuthReq->authType;
1149 }
1150 }
1151
1152 if (pRxAuthFrameBody->authAlgoNumber !=
1153 pMac->lim.gpLimMlmAuthReq->authType)
1154 {
1155 /**
1156 * Received Authentication frame with an auth
1157 * algorithm other than one requested.
1158 * Wait until Authentication Failure Timeout.
1159 */
1160
1161 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001162 PELOGW(limLog(pMac, LOGW,
1163 FL("received Auth frame2 for unexpected auth algo number %d "
Abhishek Singh208848c2013-12-18 19:02:52 +05301164 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001165 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001166
1167 break;
1168 }
1169
1170 if (pRxAuthFrameBody->authStatusCode ==
1171 eSIR_MAC_SUCCESS_STATUS)
1172 {
1173 if (pRxAuthFrameBody->authAlgoNumber ==
1174 eSIR_OPEN_SYSTEM)
1175 {
1176 psessionEntry->limCurrentAuthType = eSIR_OPEN_SYSTEM;
1177
1178 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1179
1180 if (pAuthNode == NULL)
1181 {
1182 // Log error
1183 limLog(pMac, LOGW,
1184 FL("Max pre-auth nodes reached "));
1185 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1186
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301187 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 }
1189
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301190 limLog(pMac, LOG1,
1191 FL("Alloc new data: peer "MAC_ADDRESS_STR),
1192 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001193
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301194 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1196 sizeof(tSirMacAddr));
1197 pAuthNode->fTimerStarted = 0;
1198 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301199 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1200 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301201 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001202 limAddPreAuthNode(pMac, pAuthNode);
1203
1204 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1205 pRxAuthFrameBody->authStatusCode,psessionEntry);
1206 } // if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1207 else
1208 {
1209 // Shared key authentication
1210
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1212 {
1213 val = psessionEntry->privacy;
1214 }
1215 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001216 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1217 &val) != eSIR_SUCCESS)
1218 {
1219 /**
1220 * Could not get Privacy option
1221 * from CFG. Log error.
1222 */
1223 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001224 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 }
1226 cfgPrivacyOptImp = (tANI_U8)val;
1227 if (!cfgPrivacyOptImp)
1228 {
1229 /**
1230 * Requesting STA does not have WEP implemented.
1231 * Reject with unsupported authentication algorithm
1232 * Status code and wait until auth failure timeout
1233 */
1234
1235 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001236 PELOGE( limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301237 FL("received Auth frame from peer for "
1238 "unsupported auth algo %d "
1239 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001240 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001241
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301242 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001243 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301244 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001245 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301246 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1248
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301249 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001250 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301251 LIM_NO_WEP_IN_FC,
1252 psessionEntry, eSIR_FALSE);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301253 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 }
1255 else
1256 {
1257
1258 if (pRxAuthFrameBody->type !=
1259 SIR_MAC_CHALLENGE_TEXT_EID)
1260 {
1261 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001262 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301263 FL("received Auth frame with invalid "
1264 "challenge text IE"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001265
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301266 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 }
1268
1269 /**
1270 * Check if there exists a key mappping key
1271 * for the STA that sent Authentication frame
1272 */
1273 pKeyMapEntry = limLookUpKeyMappings(
1274 pHdr->sa);
1275
1276 if (pKeyMapEntry)
1277 {
1278 if (pKeyMapEntry->key == NULL)
1279 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301280 // Log error
1281 PELOGE(limLog(pMac, LOGE,
1282 FL("received Auth frame from peer when "
1283 "key mapping key is NULL"MAC_ADDRESS_STR),
1284 MAC_ADDR_ARRAY(pHdr->sa));)
1285
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 /**
1287 * Key Mapping entry has null key.
1288 * Send Auth frame with
1289 * challenge failure status code
1290 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301291 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301293 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301295 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1297
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301298 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301300 LIM_NO_WEP_IN_FC,
1301 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001302
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 limRestoreFromAuthState(pMac, eSIR_SME_NO_KEY_MAPPING_KEY_FOR_PEER,
1304 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1305
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301306 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 } // if (pKeyMapEntry->key == NULL)
1308 else
1309 {
1310 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1311 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1312 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1313 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1314 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1315 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301316 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301317 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301319 pRxAuthFrameBody->length);
1320
1321 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1322 LIM_ENCR_AUTH_INFO_LEN);
1323 if (!encrAuthFrame) {
1324 limLog(pMac, LOGE, FL("failed to allocate memory"));
1325 goto free;
1326 }
1327 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1328 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001329
1330 limEncryptAuthFrame(pMac, 0,
1331 pKeyMapEntry->key,
1332 plainBody,
1333 encrAuthFrame,key_length);
1334
1335 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001336 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001337
1338 limSendAuthMgmtFrame(pMac,
1339 (tpSirMacAuthFrameBody) encrAuthFrame,
1340 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301341 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301342 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001343
1344 break;
1345 } // end if (pKeyMapEntry->key == NULL)
1346 } // if (pKeyMapEntry)
1347 else
1348 {
1349 if (wlan_cfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID,
1350 &val) != eSIR_SUCCESS)
1351 {
1352 /**
1353 * Could not get Default keyId
1354 * from CFG. Log error.
1355 */
1356 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001357 FL("could not retrieve Default keyId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 }
1359 keyId = (tANI_U8)val;
1360
1361 val = SIR_MAC_KEY_LENGTH;
1362
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1364 {
1365 tpSirKeys pKey;
1366 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301367 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 }
1369 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
1371 defaultKey,
1372 &val)
1373 != eSIR_SUCCESS)
1374 {
1375 /// Could not get Default key from CFG.
1376 //Log error.
1377 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001378 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001379
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301380 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301382 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301384 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1386
1387 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301388 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001389 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301390 LIM_NO_WEP_IN_FC,
1391 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001392
1393 limRestoreFromAuthState(pMac, eSIR_SME_INVALID_WEP_DEFAULT_KEY,
1394 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1395
1396 break;
1397 }
1398 key_length=val;
1399 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1400 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1401 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1402 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1403 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1404 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301405 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301406 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301408 pRxAuthFrameBody->length);
1409
1410 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1411 LIM_ENCR_AUTH_INFO_LEN);
1412 if (!encrAuthFrame) {
1413 limLog(pMac, LOGE, FL("failed to allocate memory"));
1414 goto free;
1415 }
1416 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1417 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001418
1419 limEncryptAuthFrame(pMac, keyId,
1420 defaultKey,
1421 plainBody,
1422 encrAuthFrame,key_length);
1423
1424 psessionEntry->limMlmState =
1425 eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001426 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001427
1428 limSendAuthMgmtFrame(pMac,
1429 (tpSirMacAuthFrameBody) encrAuthFrame,
1430 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301431 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301432 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001433
1434 break;
1435 } // end if (pKeyMapEntry)
1436 } // end if (!wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1437 } // end if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1438 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1439 else
1440 {
1441 /**
1442 * Authentication failure.
1443 * Return Auth confirm with received failure code to SME
1444 */
1445
1446 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001447 PELOGE(limLog(pMac, LOGE,
1448 FL("received Auth frame from peer with failure code %d "
1449 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1450 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001451
1452 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1453 pRxAuthFrameBody->authStatusCode,psessionEntry);
1454 } // end if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1455
1456 break;
1457
1458 case SIR_MAC_AUTH_FRAME_3:
1459 // AuthFrame 3
1460
1461 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1462 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301463 // Log error
1464 PELOGE(limLog(pMac, LOGE,
1465 FL("received Auth frame3 from peer with auth algo "
1466 "number %d "MAC_ADDRESS_STR),
1467 pRxAuthFrameBody->authAlgoNumber,
1468 MAC_ADDR_ARRAY(pHdr->sa));)
1469
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 /**
1471 * Received Authentication frame3 with algorithm other than
1472 * Shared Key authentication type. Reject with Auth frame4
1473 * with 'out of sequence' status code.
1474 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301475 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1476 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301478 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1480
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301481 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001482 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301483 LIM_NO_WEP_IN_FC,
1484 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001485
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301486 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 }
1488
1489 if (psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE ||
1490 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
1491 {
1492 /**
1493 * Check if wep bit was set in FC. If not set,
1494 * reject with Authentication frame4 with
1495 * 'challenge failure' status code.
1496 */
1497 if (!pHdr->fc.wep)
1498 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301499 // Log error
1500 PELOGE(limLog(pMac, LOGE,
1501 FL("received Auth frame3 from peer with no WEP bit "
1502 "set "MAC_ADDRESS_STR),
1503 MAC_ADDR_ARRAY(pHdr->sa));)
1504
Jeff Johnson295189b2012-06-20 16:38:30 -07001505 /// WEP bit is not set in FC of Auth Frame3
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301506 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1507 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301509 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1511
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301512 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301514 LIM_NO_WEP_IN_FC,
1515 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001516
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301517 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 }
1519
1520 pAuthNode = limSearchPreAuthList(pMac,
1521 pHdr->sa);
1522 if (pAuthNode == NULL)
1523 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301524 // Log error
1525 PELOGE(limLog(pMac, LOGW,
1526 FL("received AuthFrame3 from peer that has no "
1527 "preauth context "MAC_ADDRESS_STR),
1528 MAC_ADDR_ARRAY(pHdr->sa));)
1529
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 /**
1531 * No 'pre-auth' context exists for
1532 * this STA that sent an Authentication
1533 * frame3.
1534 * Send Auth frame4 with 'out of sequence'
1535 * status code.
1536 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301537 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1538 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001539 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301540 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1542
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301543 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301545 LIM_NO_WEP_IN_FC,
1546 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001547
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301548 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 }
1550
1551 if (pAuthNode->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)
1552 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301553 // Log error
1554 limLog(pMac, LOGW,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301555 FL("auth response timer timedout for peer "
1556 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 /**
1558 * Received Auth Frame3 after Auth Response timeout.
1559 * Reject by sending Auth Frame4 with
1560 * Auth respone timeout Status Code.
1561 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301562 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1563 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301565 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS;
1567
1568 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301569 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301571 LIM_NO_WEP_IN_FC,
1572 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001573
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 /// Delete pre-auth context of STA
1575 limDeletePreAuthNode(pMac,
1576 pHdr->sa);
1577
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301578 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 } // end switch (pAuthNode->mlmState)
1580
1581 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1582 {
1583 /**
1584 * Received Authenetication Frame 3 with status code
1585 * other than success. Wait until Auth response timeout
1586 * to delete STA context.
1587 */
1588
1589 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001590 PELOGE(limLog(pMac, LOGE,
1591 FL("received Auth frame3 from peer with status code %d "
1592 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1593 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001594
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301595 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 }
1597
1598 /**
1599 * Check if received challenge text is same as one sent in
1600 * Authentication frame3
1601 */
1602
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301603 if (vos_mem_compare(pRxAuthFrameBody->challengeText,
1604 pAuthNode->challengeText,
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301605 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH))
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 {
1607 /// Challenge match. STA is autheticated !
1608
1609 /// Delete Authentication response timer if running
1610 limDeactivateAndChangePerStaIdTimer(pMac,
1611 eLIM_AUTH_RSP_TIMER,
1612 pAuthNode->authNodeIdx);
1613
1614 pAuthNode->fTimerStarted = 0;
1615 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1616
1617 /**
1618 * Send Authentication Frame4 with 'success' Status Code.
1619 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301620 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1621 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001622 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301623 authFrame->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001624
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301625 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301627 LIM_NO_WEP_IN_FC,
1628 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001629
1630 /// Send Auth indication to SME
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301631 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 (tANI_U8 *) pHdr->sa,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301633 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 mlmAuthInd.authType = (tAniAuthType)
1635 pRxAuthFrameBody->authAlgoNumber;
1636 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
1637
1638 limPostSmeMessage(pMac,
1639 LIM_MLM_AUTH_IND,
1640 (tANI_U32 *) &mlmAuthInd);
1641
1642 break;
1643 }
1644 else
1645 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301646 // Log error
1647 PELOGE( limLog(pMac, LOGW,
1648 FL("Challenge failure for peer "
1649 MAC_ADDRESS_STR),
1650 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 /**
1652 * Challenge Failure.
1653 * Send Authentication frame4 with 'challenge failure'
1654 * status code and wait until Auth response timeout to
1655 * delete STA context.
1656 */
1657
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301658 authFrame->authAlgoNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001659 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301660 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001661 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301662 authFrame->authStatusCode =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001663 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001664
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301665 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301667 LIM_NO_WEP_IN_FC,
1668 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001669
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301670 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 }
1672 } // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE || ...
1673
1674 break;
1675
1676 case SIR_MAC_AUTH_FRAME_4:
1677 // AuthFrame 4
1678 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE)
1679 {
1680 /**
1681 * Received Authentication frame4 in an unexpected state.
1682 * Log error and ignore the frame.
1683 */
1684
1685 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301686 limLog(pMac, LOG1,
Abhishek Singh208848c2013-12-18 19:02:52 +05301687 FL("received unexpected Auth frame4 from peer in state "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301688 "%d, addr "MAC_ADDRESS_STR), psessionEntry->limMlmState,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301689 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001690
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301691 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 }
1693
1694 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1695 {
1696 /**
1697 * Received Authentication frame4 with algorithm other than
1698 * Shared Key authentication type.
1699 * Wait until Auth failure timeout to report authentication
1700 * failure to SME.
1701 */
1702
1703 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001704 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301705 FL("received Auth frame4 from peer with invalid auth "
1706 "algo %d "MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001707 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001708
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301709 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001710 }
1711
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301712 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1713 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1714 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 {
1716 /**
1717 * Received Authentication frame from an entity
1718 * other than one to which request was initiated.
1719 * Wait until Authentication Failure Timeout.
1720 */
1721
1722 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001723 PELOGE(limLog(pMac, LOGW,
1724 FL("received Auth frame4 from unexpected peer "
1725 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001726
1727 break;
1728 }
1729
1730 if (pRxAuthFrameBody->authAlgoNumber !=
1731 pMac->lim.gpLimMlmAuthReq->authType)
1732 {
1733 /**
1734 * Received Authentication frame with an auth algorithm
1735 * other than one requested.
1736 * Wait until Authentication Failure Timeout.
1737 */
1738
Mohit Khanna23863762012-09-11 17:40:09 -07001739 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301740 FL("received Authentication frame from peer with "
1741 "invalid auth seq number %d "
1742 MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001743 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001744
1745 break;
1746 }
1747
1748 if (pRxAuthFrameBody->authStatusCode ==
1749 eSIR_MAC_SUCCESS_STATUS)
1750 {
1751 /**
1752 * Authentication Success !
1753 * Inform SME of same.
1754 */
1755 psessionEntry->limCurrentAuthType = eSIR_SHARED_KEY;
1756
1757 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1758 if (pAuthNode == NULL)
1759 {
1760 // Log error
1761 limLog(pMac, LOGW,
1762 FL("Max pre-auth nodes reached "));
1763 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1764
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301765 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301767 limLog(pMac, LOG1,
1768 FL("Alloc new data: peer " MAC_ADDRESS_STR),
1769 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001770
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301771 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1773 sizeof(tSirMacAddr));
1774 pAuthNode->fTimerStarted = 0;
1775 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301776 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1777 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301778 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 limAddPreAuthNode(pMac, pAuthNode);
1780
1781 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1782 pRxAuthFrameBody->authStatusCode,psessionEntry);
1783
1784 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1785 else
1786 {
1787 /**
1788 * Authentication failure.
1789 * Return Auth confirm with received failure code to SME
1790 */
1791
1792 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001793 PELOGE(limLog(pMac, LOGE, FL("Authentication failure from peer "
1794 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001795
1796 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1797 pRxAuthFrameBody->authStatusCode,psessionEntry);
1798 } // end if (pRxAuthFrameBody->Status == 0)
1799
1800 break;
1801
1802 default:
1803 /// Invalid Authentication Frame received. Ignore it.
1804
1805 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001806 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301807 FL("received Auth frame from peer with invalid auth seq "
1808 "number %d " MAC_ADDRESS_STR),
1809 pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001810 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001811
1812 break;
1813 } // end switch (pRxAuthFrameBody->authTransactionSeqNumber)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301814
1815free:
1816 if (authFrame)
1817 vos_mem_free(authFrame);
1818 if (rxAuthFrame)
1819 vos_mem_free(rxAuthFrame);
1820 if (encrAuthFrame)
1821 vos_mem_free(encrAuthFrame);
1822 if (plainBody)
1823 vos_mem_free(plainBody);
1824 if (challengeTextArray)
1825 vos_mem_free(challengeTextArray);
1826
Jeff Johnson295189b2012-06-20 16:38:30 -07001827} /*** end limProcessAuthFrame() ***/
1828
1829
1830
1831
1832
1833#ifdef WLAN_FEATURE_VOWIFI_11R
1834
1835/*----------------------------------------------------------------------
1836 *
1837 * Pass the received Auth frame. This is possibly the pre-auth from the
1838 * neighbor AP, in the same mobility domain.
1839 * This will be used in case of 11r FT.
1840 *
1841 * !!!! This is going to be renoved for the next checkin. We will be creating
1842 * the session before sending out the Auth. Thus when auth response
1843 * is received we will have a session in progress. !!!!!
1844 *----------------------------------------------------------------------
1845 */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001846tSirRetStatus limProcessAuthFrameNoSession(tpAniSirGlobal pMac, tANI_U8 *pBd, void *body)
Jeff Johnson295189b2012-06-20 16:38:30 -07001847{
1848 tpSirMacMgmtHdr pHdr;
1849 tpPESession psessionEntry = NULL;
1850 tANI_U8 *pBody;
1851 tANI_U16 frameLen;
1852 tSirMacAuthFrameBody rxAuthFrame;
1853 tSirMacAuthFrameBody *pRxAuthFrameBody = NULL;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001854 tSirRetStatus ret_status = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001855
1856 pHdr = WDA_GET_RX_MAC_HEADER(pBd);
1857 pBody = WDA_GET_RX_MPDU_DATA(pBd);
1858 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd);
1859
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301860 limLog(pMac, LOG1, FL("Auth Frame Received: BSSID " MAC_ADDRESS_STR
1861 " (RSSI %d)"),MAC_ADDR_ARRAY(pHdr->bssId),
1862 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 // Check for the operating channel and see what needs to be done next.
1864 psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
1865 if (psessionEntry == NULL)
1866 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301867 limLog(pMac, LOGE, FL("Error: Unable to find session id while in "
1868 "pre-auth phase for FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 return eSIR_FAILURE;
1870 }
1871
1872 if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL)
1873 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301874 limLog(pMac, LOGE, FL("Error: No FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 // No FT in progress.
1876 return eSIR_FAILURE;
1877 }
1878
1879 if (frameLen == 0)
1880 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301881 limLog(pMac, LOGE, FL("Error: Frame len = 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 return eSIR_FAILURE;
1883 }
1884#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001885 limPrintMacAddr(pMac, pHdr->bssId, LOG2);
1886 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOG2);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001887 limLog(pMac,LOG2,FL("seqControl 0x%X"),
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001888 ((pHdr->seqControl.seqNumHi << 8) |
1889 (pHdr->seqControl.seqNumLo << 4) |
1890 (pHdr->seqControl.fragNum)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001891#endif
1892
1893 // Check that its the same bssId we have for preAuth
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301894 if (!vos_mem_compare(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1895 pHdr->bssId, sizeof( tSirMacAddr )))
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301897 limLog(pMac, LOGE, FL("Error: NOT same bssid as preauth BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 // In this case SME if indeed has triggered a
1899 // pre auth it will time out.
1900 return eSIR_FAILURE;
1901 }
1902
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001903 if (eANI_BOOLEAN_TRUE ==
1904 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed)
1905 {
1906 /*
1907 * This is likely a duplicate for the same pre-auth request.
1908 * PE/LIM already posted a response to SME. Hence, drop it.
1909 * TBD:
1910 * 1) How did we even receive multiple auth responses?
1911 * 2) Do we need to delete pre-auth session? Suppose we
1912 * previously received an auth resp with failure which
1913 * would not have created the session and forwarded to SME.
1914 * And, we subsequently received an auth resp with success
1915 * which would have created the session. This will now be
1916 * dropped without being forwarded to SME! However, it is
1917 * very unlikely to receive auth responses from the same
1918 * AP with different reason codes.
1919 * NOTE: return eSIR_SUCCESS so that the packet is dropped
1920 * as this was indeed a response from the BSSID we tried to
1921 * pre-auth.
1922 */
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001923 PELOGE(limLog(pMac,LOG1,"Auth rsp already posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001924 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001925 pMac->ft.ftPEContext.pftSessionEntry););
1926 return eSIR_SUCCESS;
1927 }
1928 else
1929 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001930 PELOGE(limLog(pMac,LOGW,"Auth rsp not yet posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001931 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001932 pMac->ft.ftPEContext.pftSessionEntry););
1933 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
1934 eANI_BOOLEAN_TRUE;
1935 }
1936
Jeff Johnson295189b2012-06-20 16:38:30 -07001937#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001938 limLog(pMac, LOG1, FL("Pre-Auth response received from neighbor"));
1939 limLog(pMac, LOG1, FL("Pre-Auth done state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001940#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301941
1942 limLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
1943 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
1944
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 // Stopping timer now, that we have our unicast from the AP
1946 // of our choice.
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301947 if (!pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
1948 limDeactivateAndChangeTimer(pMac, eLIM_FT_PREAUTH_RSP_TIMER);
1949
1950#ifdef WLAN_FEATURE_LFR_MBB
1951 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
1952 limDeactivateAndChangeTimer(pMac, eLIM_PREAUTH_MBB_RSP_TIMER);
1953#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001954
1955
1956 // Save off the auth resp.
1957 if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame) != eSIR_SUCCESS))
1958 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301959 limLog(pMac, LOGE, FL("failed to convert Auth frame to struct"));
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301960
1961#ifdef WLAN_FEATURE_LFR_MBB
1962 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
1963 lim_handle_pre_auth_mbb_rsp(pMac, eSIR_FAILURE, psessionEntry);
1964 return eSIR_FAILURE;
1965 }
1966#endif
1967
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
1969 return eSIR_FAILURE;
1970 }
1971 pRxAuthFrameBody = &rxAuthFrame;
1972
1973#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001974 PELOGE(limLog(pMac, LOG1,
1975 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
1977 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
1978 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
1979#endif
1980
1981 switch (pRxAuthFrameBody->authTransactionSeqNumber)
1982 {
1983 case SIR_MAC_AUTH_FRAME_2:
1984 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1985 {
1986#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001987 PELOGE(limLog( pMac, LOGE, "Auth status code received is %d",
1988 (tANI_U32) pRxAuthFrameBody->authStatusCode););
Jeff Johnson295189b2012-06-20 16:38:30 -07001989#endif
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001990 if (eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS == pRxAuthFrameBody->authStatusCode)
1991 ret_status = eSIR_LIM_MAX_STA_REACHED_ERROR;
Jeff Johnson295189b2012-06-20 16:38:30 -07001992 }
1993 else
1994 {
1995 ret_status = eSIR_SUCCESS;
1996 }
1997 break;
1998
1999 default:
2000#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002001 PELOGE(limLog( pMac, LOGE, "Seq. no incorrect expected 2 received %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber);)
2003#endif
2004 break;
2005 }
2006
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302007#ifdef WLAN_FEATURE_LFR_MBB
2008 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
2009 lim_handle_pre_auth_mbb_rsp(pMac, ret_status, psessionEntry);
2010 return ret_status;
2011 }
2012#endif
2013
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 // Send the Auth response to SME
2015 limHandleFTPreAuthRsp(pMac, ret_status, pBody, frameLen, psessionEntry);
2016
2017 return ret_status;
2018}
2019
2020#endif /* WLAN_FEATURE_VOWIFI_11R */
2021