blob: 83dd9170f34fd410dd23bcd7e9bdf00e8f86c5c3 [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],
146 encrAuthFrame[LIM_ENCR_AUTH_BODY_LEN],
147 plainBody[256];
148 tANI_U16 frameLen;
149 //tANI_U32 authRspTimeout, maxNumPreAuth, val;
150 tANI_U32 maxNumPreAuth, val;
151 tSirMacAuthFrameBody *pRxAuthFrameBody, rxAuthFrame, authFrame;
152 tpSirMacMgmtHdr pHdr;
153 tCfgWepKeyEntry *pKeyMapEntry = NULL;
154 struct tLimPreAuthNode *pAuthNode;
155 tLimMlmAuthInd mlmAuthInd;
156 tANI_U8 decryptResult;
157 tANI_U8 *pChallenge;
158 tANI_U32 key_length=8;
159 tANI_U8 challengeTextArray[SIR_MAC_AUTH_CHALLENGE_LENGTH];
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 tpDphHashNode pStaDs = NULL;
161 tANI_U16 assocId = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530162 tANI_U16 currSeqNo = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 /* Added For BT -AMP support */
164 // Get pointer to Authentication frame header and body
165
166
167 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
168 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700169
170 if (!frameLen)
171 {
172 // Log error
173 limLog(pMac, LOGE,
174 FL("received Authentication frame with no body from "));
175 limPrintMacAddr(pMac, pHdr->sa, LOGE);
176
177 return;
178 }
179
180 if (limIsGroupAddr(pHdr->sa))
181 {
182 // Received Auth frame from a BC/MC address
183 // Log error and ignore it
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530184 limLog(pMac, LOGE,
185 FL("received Auth frame from a BC/MC address - "));
186 limPrintMacAddr(pMac, pHdr->sa, LOGE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700187
188 return;
189 }
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530190 currSeqNo = (pHdr->seqControl.seqNumHi << 4) | (pHdr->seqControl.seqNumLo);
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530191 limLog(pMac, LOG1,
192 FL("Sessionid: %d System role : %d limMlmState: %d :Auth "
193 "Frame Received: BSSID: "MAC_ADDRESS_STR " (RSSI %d)"),
194 psessionEntry->peSessionId, psessionEntry->limSystemRole,
195 psessionEntry->limMlmState, MAC_ADDR_ARRAY(pHdr->bssId),
196 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo)));
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800197
Jeff Johnson295189b2012-06-20 16:38:30 -0700198 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
199
Jeff Johnsone7245742012-09-05 17:12:55 -0700200 //PELOG3(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG3, (tANI_U8*)pBd, ((tpHalBufDesc) pBd)->mpduDataOffset + frameLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700201
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800202 //Restore default failure timeout
203 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
204 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530205 limLog(pMac, LOG1, FL("Restore default failure timeout"));
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800206 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
207 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
208 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700209
210 /// Determine if WEP bit is set in the FC or received MAC header
211 if (pHdr->fc.wep)
212 {
213 /**
214 * WEP bit is set in FC of MAC header.
215 */
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 // If TKIP counter measures enabled issue Deauth frame to station
218 if ((psessionEntry->bTkipCntrMeasActive) && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
219 {
220 PELOGE( limLog(pMac, LOGE,
221 FL("Tkip counter measures Enabled, sending Deauth frame to")); )
222 limPrintMacAddr(pMac, pHdr->sa, LOGE);
223
224 limSendDeauthMgmtFrame( pMac, eSIR_MAC_MIC_FAILURE_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800225 pHdr->sa, psessionEntry, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700226 return;
227 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700228
229 // Extract key ID from IV (most 2 bits of 4th byte of IV)
230
231 keyId = (*(pBody + 3)) >> 6;
232
233 /**
234 * On STA in infrastructure BSS, Authentication frames received
235 * with WEP bit set in the FC must be rejected with challenge
236 * failure status code (wierd thing in the spec - this should have
237 * been rejected with unspecified failure or unexpected assertion
238 * of wep bit (this status code does not exist though) or
239 * Out-of-sequence-Authentication-Frame status code.
240 */
241
242 if (psessionEntry->limSystemRole == eLIM_STA_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)
243 {
244 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
245 authFrame.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
246 authFrame.authStatusCode = eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Abhishek Singh208848c2013-12-18 19:02:52 +0530247 // Log error
248 PELOGE(limLog(pMac, LOGE,
249 FL("received Authentication frame with wep bit set on "
250 "role=%d "MAC_ADDRESS_STR),
251 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pHdr->sa) );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700252 limSendAuthMgmtFrame(pMac, &authFrame,
253 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530254 LIM_NO_WEP_IN_FC,
255 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 return;
257 }
258
259 if (frameLen < LIM_ENCR_AUTH_BODY_LEN)
260 {
261 // Log error
262 limLog(pMac, LOGE,
263 FL("Not enough size [%d] to decrypt received Auth frame"),
264 frameLen);
265 limPrintMacAddr(pMac, pHdr->sa, LOGE);
266
267 return;
268 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
270 {
271 val = psessionEntry->privacy;
272 }
273 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 // Accept Authentication frame only if Privacy is implemented
275 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
276 &val) != eSIR_SUCCESS)
277 {
278 /**
279 * Could not get Privacy option
280 * from CFG. Log error.
281 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700282 limLog(pMac, LOGP, FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700283 }
284
285 cfgPrivacyOptImp = (tANI_U8)val;
286 if (cfgPrivacyOptImp)
287 {
288 /**
289 * Privacy option is implemented.
290 * Check if the received frame is Authentication
291 * frame3 and there is a context for requesting STA.
292 * If not, reject with unspecified failure status code
293 */
294 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
295
296 if (pAuthNode == NULL)
297 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530298 // Log error
299 PELOGE(limLog(pMac, LOGE,
300 FL("received Authentication frame from peer that has "
301 "no preauth context with WEP bit set "MAC_ADDRESS_STR),
302 MAC_ADDR_ARRAY(pHdr->sa));)
303
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 /**
305 * No 'pre-auth' context exists for this STA that sent
306 * an Authentication frame with FC bit set.
307 * Send Auth frame4 with 'out of sequence' status code.
308 */
309 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
310 authFrame.authTransactionSeqNumber =
311 SIR_MAC_AUTH_FRAME_4;
312 authFrame.authStatusCode =
313 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
314
315 limSendAuthMgmtFrame(pMac, &authFrame,
316 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530317 LIM_NO_WEP_IN_FC,
318 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700319
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 return;
321 }
322 else
323 {
324 /// Change the auth-response timeout
325 limDeactivateAndChangePerStaIdTimer(pMac,
326 eLIM_AUTH_RSP_TIMER,
327 pAuthNode->authNodeIdx);
328
329 /// 'Pre-auth' status exists for STA
330 if ((pAuthNode->mlmState !=
331 eLIM_MLM_WT_AUTH_FRAME3_STATE) &&
332 (pAuthNode->mlmState !=
333 eLIM_MLM_AUTH_RSP_TIMEOUT_STATE))
334 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530335 // Log error
336 PELOGE(limLog(pMac, LOGE,
337 FL("received Authentication frame from peer that is "
338 "in state %d "MAC_ADDRESS_STR),
339 pAuthNode->mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
340
Jeff Johnson295189b2012-06-20 16:38:30 -0700341 /**
342 * Should not have received Authentication frame
343 * with WEP bit set in FC in other states.
344 * Reject by sending Authenticaton frame with
345 * out of sequence Auth frame status code.
346 */
347
348 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
349 authFrame.authTransactionSeqNumber =
350 SIR_MAC_AUTH_FRAME_4;
351 authFrame.authStatusCode =
352 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
353
354 limSendAuthMgmtFrame(pMac, &authFrame,
355 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530356 LIM_NO_WEP_IN_FC,
357 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 return;
360 }
361 }
362
363 /**
364 * Check if there exists a key mappping key
365 * for the STA that sent Authentication frame
366 */
367 pKeyMapEntry = limLookUpKeyMappings(pHdr->sa);
368
369 if (pKeyMapEntry)
370 {
371 if (!pKeyMapEntry->wepOn)
372 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530373 // Log error
374 PELOGE(limLog(pMac, LOGE,
375 FL("received Auth frame3 from peer that has NULL "
376 "key map entry "
377 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));)
378
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 /**
380 * Key Mapping entry has null key.
381 * Send Authentication frame
382 * with challenge failure status code
383 */
384 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
385 authFrame.authTransactionSeqNumber =
386 SIR_MAC_AUTH_FRAME_4;
387 authFrame.authStatusCode =
388 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
389
390 limSendAuthMgmtFrame(pMac, &authFrame,
391 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530392 LIM_NO_WEP_IN_FC,
393 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700394
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 return;
396 } // if (!pKeyMapEntry->wepOn)
397 else
398 {
399 decryptResult = limDecryptAuthFrame(pMac, pKeyMapEntry->key,
400 pBody,
401 plainBody,
402 key_length,
403 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
404 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
405 {
406 /// ICV failure
Abhishek Singh208848c2013-12-18 19:02:52 +0530407 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
408 "LIM_DECRYPT_ICV_FAIL ..."));)
409 // Log error
410 PELOGE(limLog(pMac, LOGE,
411 FL("received Authentication frame from peer "
412 "that failed decryption, Addr "
413 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
414
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 limDeletePreAuthNode(pMac,
416 pHdr->sa);
417 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
418 authFrame.authTransactionSeqNumber =
419 SIR_MAC_AUTH_FRAME_4;
420 authFrame.authStatusCode =
421 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
422
423 limSendAuthMgmtFrame(
424 pMac, &authFrame,
425 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530426 LIM_NO_WEP_IN_FC,
427 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700428
Jeff Johnson295189b2012-06-20 16:38:30 -0700429
430 return;
431 }
432
Abhishek Singh208848c2013-12-18 19:02:52 +0530433 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
434 &rxAuthFrame)!=eSIR_SUCCESS ) ||
435 ( !isAuthValid(pMac, &rxAuthFrame,psessionEntry) ) )
436 {
437 PELOGE(limLog(pMac, LOGE,
438 FL("failed to convert Auth Frame to structure "
439 "or Auth is not valid "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 return;
Abhishek Singh208848c2013-12-18 19:02:52 +0530441 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700442
443
444 } // end if (pKeyMapEntry->key == NULL)
445 } // if keyMappings has entry
446 else
447 {
448
449 val = SIR_MAC_KEY_LENGTH;
450
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
452 {
453 tpSirKeys pKey;
454 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530455 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 val = pKey->keyLength;
457 }
458 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
460 defaultKey, &val) != eSIR_SUCCESS)
461 {
462 /// Could not get Default key from CFG.
463 //Log error.
464 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700465 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700466
467 /**
468 * Send Authentication frame
469 * with challenge failure status code
470 */
471
472 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
473 authFrame.authTransactionSeqNumber =
474 SIR_MAC_AUTH_FRAME_4;
475 authFrame.authStatusCode =
476 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
477
478 limSendAuthMgmtFrame(pMac, &authFrame,
479 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530480 LIM_NO_WEP_IN_FC,
481 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700482
483 return;
484 }
485
486 key_length=val;
487
488 decryptResult = limDecryptAuthFrame(pMac, defaultKey,
489 pBody,
490 plainBody,
491 key_length,
492 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
493 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
494 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530495 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
496 "LIM_DECRYPT_ICV_FAIL ..."));)
497 // Log error
498 PELOGE(limLog(pMac, LOGE,
499 FL("received Authentication frame from peer that "
500 "failed decryption: "
501 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 /// ICV failure
503 limDeletePreAuthNode(pMac,
504 pHdr->sa);
505 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
506 authFrame.authTransactionSeqNumber =
507 SIR_MAC_AUTH_FRAME_4;
508 authFrame.authStatusCode =
509 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
510
511 limSendAuthMgmtFrame(
512 pMac, &authFrame,
513 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530514 LIM_NO_WEP_IN_FC,
515 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700516
Jeff Johnson295189b2012-06-20 16:38:30 -0700517 return;
518 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530519 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530520 &rxAuthFrame)!=eSIR_SUCCESS ) ||
Abhishek Singh208848c2013-12-18 19:02:52 +0530521 ( !isAuthValid(pMac, &rxAuthFrame, psessionEntry) ) )
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530522 {
523 limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +0530524 FL("failed to convert Auth Frame to structure "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530525 "or Auth is not valid "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 return;
Abhishek Singh208848c2013-12-18 19:02:52 +0530527 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700528 } // End of check for Key Mapping/Default key presence
529 }
530 else
531 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530532 // Log error
533 PELOGE(limLog(pMac, LOGE,
534 FL("received Authentication frame3 from peer that while "
535 "privacy option is turned OFF "
536 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 /**
538 * Privacy option is not implemented.
539 * So reject Authentication frame received with
540 * WEP bit set by sending Authentication frame
541 * with 'challenge failure' status code. This is
542 * another strange thing in the spec. Status code
543 * should have been 'unsupported algorithm' status code.
544 */
545
546 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
547 authFrame.authTransactionSeqNumber =
548 SIR_MAC_AUTH_FRAME_4;
549 authFrame.authStatusCode =
550 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
551
552 limSendAuthMgmtFrame(pMac, &authFrame,
553 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530554 LIM_NO_WEP_IN_FC,
555 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700556
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 return;
558 } // else if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
559 } // if (fc.wep)
560 else
561 {
562
563
Abhishek Singh208848c2013-12-18 19:02:52 +0530564 if ( ( sirConvertAuthFrame2Struct(pMac, pBody,
565 frameLen, &rxAuthFrame)!=eSIR_SUCCESS ) ||
566 ( !isAuthValid(pMac, &rxAuthFrame,psessionEntry) ) )
567 {
568 PELOGE(limLog(pMac, LOGE,
569 FL("failed to convert Auth Frame to structure or Auth is "
570 "not valid "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 return;
Abhishek Singh208848c2013-12-18 19:02:52 +0530572 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 }
574
575
576 pRxAuthFrameBody = &rxAuthFrame;
577
Mohit Khanna23863762012-09-11 17:40:09 -0700578 PELOGW(limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700579 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
581 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
582 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
583
Wang Hu4506bae2015-12-07 14:15:19 +0800584 // IOT Workaround: with invalid WEP password, some APs reply AUTH frame 4
585 // with invalid seqNumber. This AUTH frame will be dropped by driver,
586 // thus driver sends the generic status code instead of protocol status code.
587 // As a workaround, assign the correct seqNumber for the AUTH frame 4.
588 if (psessionEntry->limMlmState == eLIM_MLM_WT_AUTH_FRAME4_STATE &&
589 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_1 &&
590 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_2 &&
591 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_3) {
592 PELOGE(limLog(pMac, LOGE, FL("Workaround: Assign a correct seqNumber=4 "
593 "for AUTH frame 4"));)
594 pRxAuthFrameBody->authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
595 }
596
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 switch (pRxAuthFrameBody->authTransactionSeqNumber)
598 {
599 case SIR_MAC_AUTH_FRAME_1:
600 // AuthFrame 1
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800601
602 pStaDs = dphLookupHashEntry(pMac, pHdr->sa,
603 &assocId, &psessionEntry->dph.dphHashTable);
604 if (pStaDs)
605 {
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530606 tLimMlmDisassocReq *pMlmDisassocReq = NULL;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800607 tLimMlmDeauthReq *pMlmDeauthReq = NULL;
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530608 tAniBool isConnected = eSIR_TRUE;
609
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800610 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
611 if (pMlmDisassocReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530612 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800613 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530614 sizeof(tSirMacAddr))))
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800615 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800616 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for disassoc "
617 "frame is pending Issue delsta for "
618 MAC_ADDRESS_STR),
619 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700620 limProcessDisassocAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530621 isConnected = eSIR_FALSE;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800622 }
623 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
624 if (pMlmDeauthReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530625 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800626 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
627 sizeof(tSirMacAddr))))
628 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800629 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for deauth frame "
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700630 "is pending Issue delsta for "
Arif Hussain24bafea2013-11-15 15:10:03 -0800631 MAC_ADDRESS_STR),
632 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700633 limProcessDeauthAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530634 isConnected = eSIR_FALSE;
635 }
636
637 /* pStaDS != NULL and isConnected = 1 means the STA is already
638 * connected, But SAP received the Auth from that station.
Abhishek Singh0496a522015-12-14 23:39:23 -0800639 * For non PMF connection send Deauth frame as STA will retry
640 * to connect back.
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530641 *
642 * For PMF connection the AP should not tear down or otherwise
643 * modify the state of the existing association until the
644 * SA-Query procedure determines that the original SA is
645 * invalid.
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530646 */
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530647 if (isConnected
648#ifdef WLAN_FEATURE_11W
649 && !pStaDs->rmfEnabled
650#endif
651 )
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530652 {
Abhishek Singh0496a522015-12-14 23:39:23 -0800653 limLog(pMac, LOGE,
654 FL("STA is already connected but received auth frame"
655 "Send the Deauth and lim Delete Station Context"
656 "(staId: %d, assocId: %d) "),
657 pStaDs->staIndex, assocId);
658 limSendDeauthMgmtFrame(pMac, eSIR_MAC_UNSPEC_FAILURE_REASON,
659 (tANI_U8 *) pHdr->sa, psessionEntry, FALSE);
660 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530661 return;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800662 }
663 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700664
665 /// Check if there exists pre-auth context for this STA
666 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
667 if (pAuthNode)
668 {
669 /// Pre-auth context exists for the STA
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530670 if (pHdr->fc.retry == 0 || pAuthNode->seqNo != currSeqNo)
Jeff Johnson295189b2012-06-20 16:38:30 -0700671 {
672 /**
673 * STA is initiating brand-new Authentication
674 * sequence after local Auth Response timeout.
675 * Or STA retrying to transmit First Auth frame due to packet drop OTA
676 * Delete Pre-auth node and fall through.
677 */
678 if(pAuthNode->fTimerStarted)
679 {
680 limDeactivateAndChangePerStaIdTimer(pMac,
681 eLIM_AUTH_RSP_TIMER,
682 pAuthNode->authNodeIdx);
683 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530684 PELOGE(limLog(pMac, LOGE, FL("STA is initiating brand-new "
685 "Authentication ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700686 limDeletePreAuthNode(pMac,
687 pHdr->sa);
Jeff Johnson295189b2012-06-20 16:38:30 -0700688 /**
689 * SAP Mode:Disassociate the station and
690 * delete its entry if we have its entry
691 * already and received "auth" from the
692 * same station.
693 */
694
695 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
696 {
697 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
698
699 if (NULL == pStaDs)
700 continue;
701
702 if (pStaDs->valid)
703 {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530704 if (vos_mem_compare((tANI_U8 *) &pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700705 (tANI_U8 *) &(pHdr->sa), (tANI_U8) (sizeof(tSirMacAddr))) )
706 break;
707 }
Edhar, Mahesh Kumar29013e82014-02-05 10:38:08 +0530708
709 pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 }
711
Abhishek Singhe9417492014-09-25 15:55:36 +0530712 if (NULL != pStaDs
713#ifdef WLAN_FEATURE_11W
714 && !pStaDs->rmfEnabled
715#endif
716 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 {
Abhishek Singh0496a522015-12-14 23:39:23 -0800718 PELOGE(limLog(pMac, LOGE, FL("lim Delete Station "
719 "Context (staId: %d, assocId: %d) "),pStaDs->staIndex,
720 assocId);)
721 limSendDeauthMgmtFrame(pMac,
722 eSIR_MAC_UNSPEC_FAILURE_REASON, (tANI_U8 *) pAuthNode->peerMacAddr, psessionEntry, FALSE);
723 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 return;
725 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 }
727 else
728 {
729 /*
730 * This can happen when first authentication frame is received
731 * but ACK lost at STA side, in this case 2nd auth frame is already
732 * in transmission queue
733 * */
Abhishek Singh208848c2013-12-18 19:02:52 +0530734 PELOGE(limLog(pMac, LOGE, FL("STA is initiating "
735 "Authentication after ACK lost..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 return;
737 }
738 }
739 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
740 (tANI_U32 *) &maxNumPreAuth) != eSIR_SUCCESS)
741 {
742 /**
743 * Could not get MaxNumPreAuth
744 * from CFG. Log error.
745 */
746 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700747 FL("could not retrieve MaxNumPreAuth"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 }
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530749
750 if (pMac->lim.gLimNumPreAuthContexts == maxNumPreAuth &&
751 !limDeleteOpenAuthPreAuthNode(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -0700752 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530753 PELOGE(limLog(pMac, LOGE, FL("Max number of "
754 "preauth context reached"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 /**
756 * Maximum number of pre-auth contexts
757 * reached. Send Authentication frame
758 * with unspecified failure
759 */
760 authFrame.authAlgoNumber =
761 pRxAuthFrameBody->authAlgoNumber;
762 authFrame.authTransactionSeqNumber =
763 pRxAuthFrameBody->authTransactionSeqNumber + 1;
764 authFrame.authStatusCode =
765 eSIR_MAC_UNSPEC_FAILURE_STATUS;
766
767 limSendAuthMgmtFrame(pMac, &authFrame,
768 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530769 LIM_NO_WEP_IN_FC,
770 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700771
772 return;
773 }
774 /// No Pre-auth context exists for the STA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 if (limIsAuthAlgoSupported(
776 pMac,
777 (tAniAuthType)
778 pRxAuthFrameBody->authAlgoNumber, psessionEntry))
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 {
780 switch (pRxAuthFrameBody->authAlgoNumber)
781 {
782 case eSIR_OPEN_SYSTEM:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700783 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_OPEN_SYSTEM ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 /// Create entry for this STA in pre-auth list
785 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
786 if (pAuthNode == NULL)
787 {
788 // Log error
789 limLog(pMac, LOGW,
790 FL("Max pre-auth nodes reached "));
791 limPrintMacAddr(pMac, pHdr->sa, LOGW);
792
793 return;
794 }
795
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530796 limLog(pMac, LOG1,
797 FL("Alloc new data: peer "MAC_ADDRESS_STR),
798 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700799
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530800 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
801 pHdr->sa,
802 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700803
804 pAuthNode->mlmState =
805 eLIM_MLM_AUTHENTICATED_STATE;
806 pAuthNode->authType = (tAniAuthType)
807 pRxAuthFrameBody->authAlgoNumber;
808 pAuthNode->fSeen = 0;
809 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530810 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
811 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530812 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 limAddPreAuthNode(pMac, pAuthNode);
814
815 /**
816 * Send Authenticaton frame with Success
817 * status code.
818 */
819
820 authFrame.authAlgoNumber =
821 pRxAuthFrameBody->authAlgoNumber;
822 authFrame.authTransactionSeqNumber =
823 pRxAuthFrameBody->authTransactionSeqNumber + 1;
824 authFrame.authStatusCode = eSIR_MAC_SUCCESS_STATUS;
825 limSendAuthMgmtFrame(
826 pMac, &authFrame,
827 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530828 LIM_NO_WEP_IN_FC,
829 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700830
831 /// Send Auth indication to SME
832
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530833 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 (tANI_U8 *) pHdr->sa,
835 sizeof(tSirMacAddr));
836 mlmAuthInd.authType = (tAniAuthType)
837 pRxAuthFrameBody->authAlgoNumber;
838 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
839
840 limPostSmeMessage(pMac,
841 LIM_MLM_AUTH_IND,
842 (tANI_U32 *) &mlmAuthInd);
843 break;
844
845 case eSIR_SHARED_KEY:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700846 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_SHARED_KEY ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
848 {
849 val = psessionEntry->privacy;
850 }
851 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
853 &val) != eSIR_SUCCESS)
854 {
855 /**
856 * Could not get Privacy option
857 * from CFG. Log error.
858 */
859 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700860 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700861 }
862 cfgPrivacyOptImp = (tANI_U8)val;
863 if (!cfgPrivacyOptImp)
864 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530865 // Log error
866 PELOGE(limLog(pMac, LOGE,
867 FL("received Auth frame for unsupported auth algorithm %d "
868 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
869 MAC_ADDR_ARRAY(pHdr->sa));)
870
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 /**
872 * Authenticator does not have WEP
873 * implemented.
874 * Reject by sending Authentication frame
875 * with Auth algorithm not supported status
876 * code.
877 */
878
879 authFrame.authAlgoNumber =
880 pRxAuthFrameBody->authAlgoNumber;
881 authFrame.authTransactionSeqNumber =
882 pRxAuthFrameBody->authTransactionSeqNumber + 1;
883 authFrame.authStatusCode =
884 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
885
886 limSendAuthMgmtFrame(
887 pMac, &authFrame,
888 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530889 LIM_NO_WEP_IN_FC,
890 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 return;
893 }
894 else
895 {
896 // Create entry for this STA
897 //in pre-auth list
898 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
899 if (pAuthNode == NULL)
900 {
901 // Log error
902 limLog(pMac, LOGW,
903 FL("Max pre-auth nodes reached "));
904 limPrintMacAddr(pMac, pHdr->sa, LOGW);
905
906 return;
907 }
908
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530909 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
910 pHdr->sa,
911 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700912
913 pAuthNode->mlmState =
914 eLIM_MLM_WT_AUTH_FRAME3_STATE;
915 pAuthNode->authType =
916 (tAniAuthType)
917 pRxAuthFrameBody->authAlgoNumber;
918 pAuthNode->fSeen = 0;
919 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530920 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
921 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530922 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 limAddPreAuthNode(pMac, pAuthNode);
924
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530925 limLog(pMac, LOG1,
926 FL("Alloc new data: id %d peer "MAC_ADDRESS_STR),
927 pAuthNode->authNodeIdx, MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700928
929 /// Create and activate Auth Response timer
930 if (tx_timer_change_context(&pAuthNode->timer, pAuthNode->authNodeIdx) != TX_SUCCESS)
931 {
932 /// Could not start Auth response timer.
933 // Log error
934 limLog(pMac, LOGP,
935 FL("Unable to chg context auth response timer for peer "));
936 limPrintMacAddr(pMac, pHdr->sa, LOGP);
937
938 /**
939 * Send Authenticaton frame with
940 * unspecified failure status code.
941 */
942
943 authFrame.authAlgoNumber =
944 pRxAuthFrameBody->authAlgoNumber;
945 authFrame.authTransactionSeqNumber =
946 pRxAuthFrameBody->authTransactionSeqNumber + 1;
947 authFrame.authStatusCode =
948 eSIR_MAC_UNSPEC_FAILURE_STATUS;
949
950 limSendAuthMgmtFrame(pMac, &authFrame,
951 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530952 LIM_NO_WEP_IN_FC,
953 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700954
955 limDeletePreAuthNode(pMac, pHdr->sa);
956 return;
957 }
958
959 limActivateAuthRspTimer(pMac, pAuthNode);
960
961 pAuthNode->fTimerStarted = 1;
962
963 // get random bytes and use as
964 // challenge text
965 // TODO
966 //if( !VOS_IS_STATUS_SUCCESS( vos_rand_get_bytes( 0, (tANI_U8 *)challengeTextArray, SIR_MAC_AUTH_CHALLENGE_LENGTH ) ) )
967 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530968 limLog(pMac, LOGE,FL("Challenge text "
969 "preparation failed in limProcessAuthFrame"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 }
971
972 pChallenge = pAuthNode->challengeText;
973
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530974 vos_mem_copy(pChallenge,
975 (tANI_U8 *) challengeTextArray,
976 sizeof(challengeTextArray));
Jeff Johnson295189b2012-06-20 16:38:30 -0700977
978 /**
979 * Sending Authenticaton frame with challenge.
980 */
981
982 authFrame.authAlgoNumber =
983 pRxAuthFrameBody->authAlgoNumber;
984 authFrame.authTransactionSeqNumber =
985 pRxAuthFrameBody->authTransactionSeqNumber + 1;
986 authFrame.authStatusCode =
987 eSIR_MAC_SUCCESS_STATUS;
988 authFrame.type = SIR_MAC_CHALLENGE_TEXT_EID;
989 authFrame.length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530990 vos_mem_copy(authFrame.challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 pAuthNode->challengeText,
992 SIR_MAC_AUTH_CHALLENGE_LENGTH);
993
994 limSendAuthMgmtFrame(
995 pMac, &authFrame,
996 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530997 LIM_NO_WEP_IN_FC,
998 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 } // if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1000
1001 break;
1002
1003 default:
Abhishek Singh208848c2013-12-18 19:02:52 +05301004 // Log error
1005 PELOGE( limLog(pMac, LOGE,
1006 FL("received Auth frame for unsupported auth "
1007 "algorithm %d "MAC_ADDRESS_STR),
1008 pRxAuthFrameBody->authAlgoNumber,
1009 MAC_ADDR_ARRAY(pHdr->sa));)
1010
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 /**
1012 * Responding party does not support the
1013 * authentication algorithm requested by
1014 * sending party.
1015 * Reject by sending Authentication frame
1016 * with auth algorithm not supported status code
1017 */
1018
1019 authFrame.authAlgoNumber =
1020 pRxAuthFrameBody->authAlgoNumber;
1021 authFrame.authTransactionSeqNumber =
1022 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1023 authFrame.authStatusCode =
1024 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1025
1026 limSendAuthMgmtFrame(
1027 pMac, &authFrame,
1028 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301029 LIM_NO_WEP_IN_FC,
1030 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001031
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 return;
1033 } // end switch(pRxAuthFrameBody->authAlgoNumber)
1034 } // if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1035 else
1036 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301037 // Log error
1038 PELOGE(limLog(pMac, LOGE,
1039 FL("received Authentication frame for unsupported auth "
1040 "algorithm %d "MAC_ADDRESS_STR),
1041 pRxAuthFrameBody->authAlgoNumber,
1042 MAC_ADDR_ARRAY(pHdr->sa));)
1043
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 /**
1045 * Responding party does not support the
1046 * authentication algorithm requested by sending party.
1047 * Reject Authentication with StatusCode=13.
1048 */
1049 authFrame.authAlgoNumber =
1050 pRxAuthFrameBody->authAlgoNumber;
1051 authFrame.authTransactionSeqNumber =
1052 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1053 authFrame.authStatusCode =
1054 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1055
1056 limSendAuthMgmtFrame(pMac, &authFrame,
1057 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301058 LIM_NO_WEP_IN_FC,
1059 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001060
Jeff Johnson295189b2012-06-20 16:38:30 -07001061 return;
1062 } //end if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1063 break;
1064
1065 case SIR_MAC_AUTH_FRAME_2:
1066 // AuthFrame 2
1067
1068 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME2_STATE)
1069 {
1070 /**
1071 * Received Authentication frame2 in an unexpected state.
1072 * Log error and ignore the frame.
1073 */
1074
1075 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301076 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 FL("received Auth frame2 from peer in state %d, addr "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301078 psessionEntry->limMlmState);
1079 limPrintMacAddr(pMac, pHdr->sa, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001080
1081 return;
1082 }
1083
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301084 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1085 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1086 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 {
1088 /**
1089 * Received Authentication frame from an entity
1090 * other than one request was initiated.
1091 * Wait until Authentication Failure Timeout.
1092 */
1093
1094 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001095 PELOGW(limLog(pMac, LOGW,
Abhishek Singh208848c2013-12-18 19:02:52 +05301096 FL("received Auth frame2 from unexpected peer "
1097 MAC_ADDRESS_STR),
Mohit Khanna23863762012-09-11 17:40:09 -07001098 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001099
1100 break;
1101 }
1102
1103 if (pRxAuthFrameBody->authStatusCode ==
1104 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS)
1105 {
1106 /**
1107 * Interoperability workaround: Linksys WAP4400N is returning
1108 * wrong authType in OpenAuth response in case of
1109 * SharedKey AP configuration. Pretend we don't see that,
1110 * so upper layer can fallback to SharedKey authType,
1111 * and successfully connect to the AP.
1112 */
1113 if (pRxAuthFrameBody->authAlgoNumber !=
1114 pMac->lim.gpLimMlmAuthReq->authType)
1115 {
1116 pRxAuthFrameBody->authAlgoNumber =
1117 pMac->lim.gpLimMlmAuthReq->authType;
1118 }
1119 }
1120
1121 if (pRxAuthFrameBody->authAlgoNumber !=
1122 pMac->lim.gpLimMlmAuthReq->authType)
1123 {
1124 /**
1125 * Received Authentication frame with an auth
1126 * algorithm other than one requested.
1127 * Wait until Authentication Failure Timeout.
1128 */
1129
1130 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001131 PELOGW(limLog(pMac, LOGW,
1132 FL("received Auth frame2 for unexpected auth algo number %d "
Abhishek Singh208848c2013-12-18 19:02:52 +05301133 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001134 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001135
1136 break;
1137 }
1138
1139 if (pRxAuthFrameBody->authStatusCode ==
1140 eSIR_MAC_SUCCESS_STATUS)
1141 {
1142 if (pRxAuthFrameBody->authAlgoNumber ==
1143 eSIR_OPEN_SYSTEM)
1144 {
1145 psessionEntry->limCurrentAuthType = eSIR_OPEN_SYSTEM;
1146
1147 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1148
1149 if (pAuthNode == NULL)
1150 {
1151 // Log error
1152 limLog(pMac, LOGW,
1153 FL("Max pre-auth nodes reached "));
1154 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1155
1156 return;
1157 }
1158
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301159 limLog(pMac, LOG1,
1160 FL("Alloc new data: peer "MAC_ADDRESS_STR),
1161 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001162
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301163 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001164 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1165 sizeof(tSirMacAddr));
1166 pAuthNode->fTimerStarted = 0;
1167 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301168 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1169 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301170 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001171 limAddPreAuthNode(pMac, pAuthNode);
1172
1173 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1174 pRxAuthFrameBody->authStatusCode,psessionEntry);
1175 } // if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1176 else
1177 {
1178 // Shared key authentication
1179
Jeff Johnson295189b2012-06-20 16:38:30 -07001180 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1181 {
1182 val = psessionEntry->privacy;
1183 }
1184 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001185 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1186 &val) != eSIR_SUCCESS)
1187 {
1188 /**
1189 * Could not get Privacy option
1190 * from CFG. Log error.
1191 */
1192 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001193 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001194 }
1195 cfgPrivacyOptImp = (tANI_U8)val;
1196 if (!cfgPrivacyOptImp)
1197 {
1198 /**
1199 * Requesting STA does not have WEP implemented.
1200 * Reject with unsupported authentication algorithm
1201 * Status code and wait until auth failure timeout
1202 */
1203
1204 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001205 PELOGE( limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301206 FL("received Auth frame from peer for "
1207 "unsupported auth algo %d "
1208 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001209 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001210
1211 authFrame.authAlgoNumber =
1212 pRxAuthFrameBody->authAlgoNumber;
1213 authFrame.authTransactionSeqNumber =
1214 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1215 authFrame.authStatusCode =
1216 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1217
1218 limSendAuthMgmtFrame(pMac, &authFrame,
1219 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301220 LIM_NO_WEP_IN_FC,
1221 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 return;
1223 }
1224 else
1225 {
1226
1227 if (pRxAuthFrameBody->type !=
1228 SIR_MAC_CHALLENGE_TEXT_EID)
1229 {
1230 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001231 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301232 FL("received Auth frame with invalid "
1233 "challenge text IE"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001234
1235 return;
1236 }
1237
1238 /**
1239 * Check if there exists a key mappping key
1240 * for the STA that sent Authentication frame
1241 */
1242 pKeyMapEntry = limLookUpKeyMappings(
1243 pHdr->sa);
1244
1245 if (pKeyMapEntry)
1246 {
1247 if (pKeyMapEntry->key == NULL)
1248 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301249 // Log error
1250 PELOGE(limLog(pMac, LOGE,
1251 FL("received Auth frame from peer when "
1252 "key mapping key is NULL"MAC_ADDRESS_STR),
1253 MAC_ADDR_ARRAY(pHdr->sa));)
1254
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 /**
1256 * Key Mapping entry has null key.
1257 * Send Auth frame with
1258 * challenge failure status code
1259 */
1260 authFrame.authAlgoNumber =
1261 pRxAuthFrameBody->authAlgoNumber;
1262 authFrame.authTransactionSeqNumber =
1263 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1264 authFrame.authStatusCode =
1265 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1266
1267 limSendAuthMgmtFrame(pMac, &authFrame,
1268 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301269 LIM_NO_WEP_IN_FC,
1270 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001271
Jeff Johnson295189b2012-06-20 16:38:30 -07001272 limRestoreFromAuthState(pMac, eSIR_SME_NO_KEY_MAPPING_KEY_FOR_PEER,
1273 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1274
1275 return;
1276 } // if (pKeyMapEntry->key == NULL)
1277 else
1278 {
1279 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1280 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1281 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1282 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1283 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1284 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
1285 ((tpSirMacAuthFrameBody) plainBody)->length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301286 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001287 pRxAuthFrameBody->challengeText,
1288 SIR_MAC_AUTH_CHALLENGE_LENGTH);
1289
1290 limEncryptAuthFrame(pMac, 0,
1291 pKeyMapEntry->key,
1292 plainBody,
1293 encrAuthFrame,key_length);
1294
1295 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001296 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001297
1298 limSendAuthMgmtFrame(pMac,
1299 (tpSirMacAuthFrameBody) encrAuthFrame,
1300 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301301 LIM_WEP_IN_FC,
1302 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001303
1304 break;
1305 } // end if (pKeyMapEntry->key == NULL)
1306 } // if (pKeyMapEntry)
1307 else
1308 {
1309 if (wlan_cfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID,
1310 &val) != eSIR_SUCCESS)
1311 {
1312 /**
1313 * Could not get Default keyId
1314 * from CFG. Log error.
1315 */
1316 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001317 FL("could not retrieve Default keyId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 }
1319 keyId = (tANI_U8)val;
1320
1321 val = SIR_MAC_KEY_LENGTH;
1322
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1324 {
1325 tpSirKeys pKey;
1326 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301327 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 }
1329 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
1331 defaultKey,
1332 &val)
1333 != eSIR_SUCCESS)
1334 {
1335 /// Could not get Default key from CFG.
1336 //Log error.
1337 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001338 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001339
1340 authFrame.authAlgoNumber =
1341 pRxAuthFrameBody->authAlgoNumber;
1342 authFrame.authTransactionSeqNumber =
1343 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1344 authFrame.authStatusCode =
1345 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1346
1347 limSendAuthMgmtFrame(
1348 pMac, &authFrame,
1349 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301350 LIM_NO_WEP_IN_FC,
1351 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001352
1353 limRestoreFromAuthState(pMac, eSIR_SME_INVALID_WEP_DEFAULT_KEY,
1354 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1355
1356 break;
1357 }
1358 key_length=val;
1359 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1360 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1361 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1362 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1363 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1364 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
1365 ((tpSirMacAuthFrameBody) plainBody)->length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301366 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 pRxAuthFrameBody->challengeText,
1368 SIR_MAC_AUTH_CHALLENGE_LENGTH);
1369
1370 limEncryptAuthFrame(pMac, keyId,
1371 defaultKey,
1372 plainBody,
1373 encrAuthFrame,key_length);
1374
1375 psessionEntry->limMlmState =
1376 eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001377 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001378
1379 limSendAuthMgmtFrame(pMac,
1380 (tpSirMacAuthFrameBody) encrAuthFrame,
1381 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301382 LIM_WEP_IN_FC,
1383 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001384
1385 break;
1386 } // end if (pKeyMapEntry)
1387 } // end if (!wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1388 } // end if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1389 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1390 else
1391 {
1392 /**
1393 * Authentication failure.
1394 * Return Auth confirm with received failure code to SME
1395 */
1396
1397 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001398 PELOGE(limLog(pMac, LOGE,
1399 FL("received Auth frame from peer with failure code %d "
1400 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1401 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001402
1403 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1404 pRxAuthFrameBody->authStatusCode,psessionEntry);
1405 } // end if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1406
1407 break;
1408
1409 case SIR_MAC_AUTH_FRAME_3:
1410 // AuthFrame 3
1411
1412 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1413 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301414 // Log error
1415 PELOGE(limLog(pMac, LOGE,
1416 FL("received Auth frame3 from peer with auth algo "
1417 "number %d "MAC_ADDRESS_STR),
1418 pRxAuthFrameBody->authAlgoNumber,
1419 MAC_ADDR_ARRAY(pHdr->sa));)
1420
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 /**
1422 * Received Authentication frame3 with algorithm other than
1423 * Shared Key authentication type. Reject with Auth frame4
1424 * with 'out of sequence' status code.
1425 */
1426 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1427 authFrame.authTransactionSeqNumber =
1428 SIR_MAC_AUTH_FRAME_4;
1429 authFrame.authStatusCode =
1430 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1431
1432 limSendAuthMgmtFrame(pMac, &authFrame,
1433 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301434 LIM_NO_WEP_IN_FC,
1435 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001436
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 return;
1438 }
1439
1440 if (psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE ||
1441 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
1442 {
1443 /**
1444 * Check if wep bit was set in FC. If not set,
1445 * reject with Authentication frame4 with
1446 * 'challenge failure' status code.
1447 */
1448 if (!pHdr->fc.wep)
1449 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301450 // Log error
1451 PELOGE(limLog(pMac, LOGE,
1452 FL("received Auth frame3 from peer with no WEP bit "
1453 "set "MAC_ADDRESS_STR),
1454 MAC_ADDR_ARRAY(pHdr->sa));)
1455
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 /// WEP bit is not set in FC of Auth Frame3
1457 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1458 authFrame.authTransactionSeqNumber =
1459 SIR_MAC_AUTH_FRAME_4;
1460 authFrame.authStatusCode =
1461 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1462
1463 limSendAuthMgmtFrame(pMac, &authFrame,
1464 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301465 LIM_NO_WEP_IN_FC,
1466 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001467
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 return;
1469 }
1470
1471 pAuthNode = limSearchPreAuthList(pMac,
1472 pHdr->sa);
1473 if (pAuthNode == NULL)
1474 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301475 // Log error
1476 PELOGE(limLog(pMac, LOGW,
1477 FL("received AuthFrame3 from peer that has no "
1478 "preauth context "MAC_ADDRESS_STR),
1479 MAC_ADDR_ARRAY(pHdr->sa));)
1480
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 /**
1482 * No 'pre-auth' context exists for
1483 * this STA that sent an Authentication
1484 * frame3.
1485 * Send Auth frame4 with 'out of sequence'
1486 * status code.
1487 */
1488 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1489 authFrame.authTransactionSeqNumber =
1490 SIR_MAC_AUTH_FRAME_4;
1491 authFrame.authStatusCode =
1492 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1493
1494 limSendAuthMgmtFrame(pMac, &authFrame,
1495 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301496 LIM_NO_WEP_IN_FC,
1497 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001498
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 return;
1500 }
1501
1502 if (pAuthNode->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)
1503 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301504 // Log error
1505 limLog(pMac, LOGW,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301506 FL("auth response timer timedout for peer "
1507 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 /**
1509 * Received Auth Frame3 after Auth Response timeout.
1510 * Reject by sending Auth Frame4 with
1511 * Auth respone timeout Status Code.
1512 */
1513 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1514 authFrame.authTransactionSeqNumber =
1515 SIR_MAC_AUTH_FRAME_4;
1516 authFrame.authStatusCode =
1517 eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS;
1518
1519 limSendAuthMgmtFrame(
1520 pMac, &authFrame,
1521 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301522 LIM_NO_WEP_IN_FC,
1523 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001524
Jeff Johnson295189b2012-06-20 16:38:30 -07001525 /// Delete pre-auth context of STA
1526 limDeletePreAuthNode(pMac,
1527 pHdr->sa);
1528
1529 return;
1530 } // end switch (pAuthNode->mlmState)
1531
1532 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1533 {
1534 /**
1535 * Received Authenetication Frame 3 with status code
1536 * other than success. Wait until Auth response timeout
1537 * to delete STA context.
1538 */
1539
1540 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001541 PELOGE(limLog(pMac, LOGE,
1542 FL("received Auth frame3 from peer with status code %d "
1543 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1544 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001545
1546 return;
1547 }
1548
1549 /**
1550 * Check if received challenge text is same as one sent in
1551 * Authentication frame3
1552 */
1553
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301554 if (vos_mem_compare(pRxAuthFrameBody->challengeText,
1555 pAuthNode->challengeText,
1556 SIR_MAC_AUTH_CHALLENGE_LENGTH))
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 {
1558 /// Challenge match. STA is autheticated !
1559
1560 /// Delete Authentication response timer if running
1561 limDeactivateAndChangePerStaIdTimer(pMac,
1562 eLIM_AUTH_RSP_TIMER,
1563 pAuthNode->authNodeIdx);
1564
1565 pAuthNode->fTimerStarted = 0;
1566 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1567
1568 /**
1569 * Send Authentication Frame4 with 'success' Status Code.
1570 */
1571 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1572 authFrame.authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001573 SIR_MAC_AUTH_FRAME_4;
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 authFrame.authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1575
1576 limSendAuthMgmtFrame(pMac, &authFrame,
1577 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301578 LIM_NO_WEP_IN_FC,
1579 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001580
1581 /// Send Auth indication to SME
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301582 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 (tANI_U8 *) pHdr->sa,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301584 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 mlmAuthInd.authType = (tAniAuthType)
1586 pRxAuthFrameBody->authAlgoNumber;
1587 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
1588
1589 limPostSmeMessage(pMac,
1590 LIM_MLM_AUTH_IND,
1591 (tANI_U32 *) &mlmAuthInd);
1592
1593 break;
1594 }
1595 else
1596 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301597 // Log error
1598 PELOGE( limLog(pMac, LOGW,
1599 FL("Challenge failure for peer "
1600 MAC_ADDRESS_STR),
1601 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 /**
1603 * Challenge Failure.
1604 * Send Authentication frame4 with 'challenge failure'
1605 * status code and wait until Auth response timeout to
1606 * delete STA context.
1607 */
1608
1609 authFrame.authAlgoNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001610 pRxAuthFrameBody->authAlgoNumber;
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 authFrame.authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001612 SIR_MAC_AUTH_FRAME_4;
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 authFrame.authStatusCode =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001614 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001615
1616 limSendAuthMgmtFrame(pMac, &authFrame,
1617 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301618 LIM_NO_WEP_IN_FC,
1619 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001620
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 return;
1622 }
1623 } // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE || ...
1624
1625 break;
1626
1627 case SIR_MAC_AUTH_FRAME_4:
1628 // AuthFrame 4
1629 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE)
1630 {
1631 /**
1632 * Received Authentication frame4 in an unexpected state.
1633 * Log error and ignore the frame.
1634 */
1635
1636 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301637 limLog(pMac, LOG1,
Abhishek Singh208848c2013-12-18 19:02:52 +05301638 FL("received unexpected Auth frame4 from peer in state "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301639 "%d, addr "MAC_ADDRESS_STR), psessionEntry->limMlmState,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301640 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001641
1642 return;
1643 }
1644
1645 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1646 {
1647 /**
1648 * Received Authentication frame4 with algorithm other than
1649 * Shared Key authentication type.
1650 * Wait until Auth failure timeout to report authentication
1651 * failure to SME.
1652 */
1653
1654 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001655 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301656 FL("received Auth frame4 from peer with invalid auth "
1657 "algo %d "MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001658 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001659
1660 return;
1661 }
1662
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301663 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1664 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1665 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 {
1667 /**
1668 * Received Authentication frame from an entity
1669 * other than one to which request was initiated.
1670 * Wait until Authentication Failure Timeout.
1671 */
1672
1673 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001674 PELOGE(limLog(pMac, LOGW,
1675 FL("received Auth frame4 from unexpected peer "
1676 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001677
1678 break;
1679 }
1680
1681 if (pRxAuthFrameBody->authAlgoNumber !=
1682 pMac->lim.gpLimMlmAuthReq->authType)
1683 {
1684 /**
1685 * Received Authentication frame with an auth algorithm
1686 * other than one requested.
1687 * Wait until Authentication Failure Timeout.
1688 */
1689
Mohit Khanna23863762012-09-11 17:40:09 -07001690 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301691 FL("received Authentication frame from peer with "
1692 "invalid auth seq number %d "
1693 MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001694 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001695
1696 break;
1697 }
1698
1699 if (pRxAuthFrameBody->authStatusCode ==
1700 eSIR_MAC_SUCCESS_STATUS)
1701 {
1702 /**
1703 * Authentication Success !
1704 * Inform SME of same.
1705 */
1706 psessionEntry->limCurrentAuthType = eSIR_SHARED_KEY;
1707
1708 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1709 if (pAuthNode == NULL)
1710 {
1711 // Log error
1712 limLog(pMac, LOGW,
1713 FL("Max pre-auth nodes reached "));
1714 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1715
1716 return;
1717 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301718 limLog(pMac, LOG1,
1719 FL("Alloc new data: peer " MAC_ADDRESS_STR),
1720 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001721
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301722 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1724 sizeof(tSirMacAddr));
1725 pAuthNode->fTimerStarted = 0;
1726 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301727 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1728 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301729 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 limAddPreAuthNode(pMac, pAuthNode);
1731
1732 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1733 pRxAuthFrameBody->authStatusCode,psessionEntry);
1734
1735 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1736 else
1737 {
1738 /**
1739 * Authentication failure.
1740 * Return Auth confirm with received failure code to SME
1741 */
1742
1743 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001744 PELOGE(limLog(pMac, LOGE, FL("Authentication failure from peer "
1745 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001746
1747 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1748 pRxAuthFrameBody->authStatusCode,psessionEntry);
1749 } // end if (pRxAuthFrameBody->Status == 0)
1750
1751 break;
1752
1753 default:
1754 /// Invalid Authentication Frame received. Ignore it.
1755
1756 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001757 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301758 FL("received Auth frame from peer with invalid auth seq "
1759 "number %d " MAC_ADDRESS_STR),
1760 pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001761 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001762
1763 break;
1764 } // end switch (pRxAuthFrameBody->authTransactionSeqNumber)
1765} /*** end limProcessAuthFrame() ***/
1766
1767
1768
1769
1770
1771#ifdef WLAN_FEATURE_VOWIFI_11R
1772
1773/*----------------------------------------------------------------------
1774 *
1775 * Pass the received Auth frame. This is possibly the pre-auth from the
1776 * neighbor AP, in the same mobility domain.
1777 * This will be used in case of 11r FT.
1778 *
1779 * !!!! This is going to be renoved for the next checkin. We will be creating
1780 * the session before sending out the Auth. Thus when auth response
1781 * is received we will have a session in progress. !!!!!
1782 *----------------------------------------------------------------------
1783 */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001784tSirRetStatus limProcessAuthFrameNoSession(tpAniSirGlobal pMac, tANI_U8 *pBd, void *body)
Jeff Johnson295189b2012-06-20 16:38:30 -07001785{
1786 tpSirMacMgmtHdr pHdr;
1787 tpPESession psessionEntry = NULL;
1788 tANI_U8 *pBody;
1789 tANI_U16 frameLen;
1790 tSirMacAuthFrameBody rxAuthFrame;
1791 tSirMacAuthFrameBody *pRxAuthFrameBody = NULL;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001792 tSirRetStatus ret_status = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001793
1794 pHdr = WDA_GET_RX_MAC_HEADER(pBd);
1795 pBody = WDA_GET_RX_MPDU_DATA(pBd);
1796 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd);
1797
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301798 limLog(pMac, LOG1, FL("Auth Frame Received: BSSID " MAC_ADDRESS_STR
1799 " (RSSI %d)"),MAC_ADDR_ARRAY(pHdr->bssId),
1800 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001801 // Check for the operating channel and see what needs to be done next.
1802 psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
1803 if (psessionEntry == NULL)
1804 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301805 limLog(pMac, LOGE, FL("Error: Unable to find session id while in "
1806 "pre-auth phase for FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 return eSIR_FAILURE;
1808 }
1809
1810 if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL)
1811 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301812 limLog(pMac, LOGE, FL("Error: No FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 // No FT in progress.
1814 return eSIR_FAILURE;
1815 }
1816
1817 if (frameLen == 0)
1818 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301819 limLog(pMac, LOGE, FL("Error: Frame len = 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 return eSIR_FAILURE;
1821 }
1822#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001823 limPrintMacAddr(pMac, pHdr->bssId, LOG2);
1824 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOG2);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001825 limLog(pMac,LOG2,FL("seqControl 0x%X"),
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001826 ((pHdr->seqControl.seqNumHi << 8) |
1827 (pHdr->seqControl.seqNumLo << 4) |
1828 (pHdr->seqControl.fragNum)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001829#endif
1830
1831 // Check that its the same bssId we have for preAuth
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301832 if (!vos_mem_compare(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1833 pHdr->bssId, sizeof( tSirMacAddr )))
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301835 limLog(pMac, LOGE, FL("Error: NOT same bssid as preauth BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 // In this case SME if indeed has triggered a
1837 // pre auth it will time out.
1838 return eSIR_FAILURE;
1839 }
1840
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001841 if (eANI_BOOLEAN_TRUE ==
1842 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed)
1843 {
1844 /*
1845 * This is likely a duplicate for the same pre-auth request.
1846 * PE/LIM already posted a response to SME. Hence, drop it.
1847 * TBD:
1848 * 1) How did we even receive multiple auth responses?
1849 * 2) Do we need to delete pre-auth session? Suppose we
1850 * previously received an auth resp with failure which
1851 * would not have created the session and forwarded to SME.
1852 * And, we subsequently received an auth resp with success
1853 * which would have created the session. This will now be
1854 * dropped without being forwarded to SME! However, it is
1855 * very unlikely to receive auth responses from the same
1856 * AP with different reason codes.
1857 * NOTE: return eSIR_SUCCESS so that the packet is dropped
1858 * as this was indeed a response from the BSSID we tried to
1859 * pre-auth.
1860 */
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001861 PELOGE(limLog(pMac,LOG1,"Auth rsp already posted to SME"
1862 " (session %p, FT session %p)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001863 pMac->ft.ftPEContext.pftSessionEntry););
1864 return eSIR_SUCCESS;
1865 }
1866 else
1867 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001868 PELOGE(limLog(pMac,LOGW,"Auth rsp not yet posted to SME"
1869 " (session %p, FT session %p)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001870 pMac->ft.ftPEContext.pftSessionEntry););
1871 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
1872 eANI_BOOLEAN_TRUE;
1873 }
1874
Jeff Johnson295189b2012-06-20 16:38:30 -07001875#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001876 limLog(pMac, LOG1, FL("Pre-Auth response received from neighbor"));
1877 limLog(pMac, LOG1, FL("Pre-Auth done state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001878#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301879
1880 limLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
1881 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
1882
Jeff Johnson295189b2012-06-20 16:38:30 -07001883 // Stopping timer now, that we have our unicast from the AP
1884 // of our choice.
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301885 if (!pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
1886 limDeactivateAndChangeTimer(pMac, eLIM_FT_PREAUTH_RSP_TIMER);
1887
1888#ifdef WLAN_FEATURE_LFR_MBB
1889 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
1890 limDeactivateAndChangeTimer(pMac, eLIM_PREAUTH_MBB_RSP_TIMER);
1891#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001892
1893
1894 // Save off the auth resp.
1895 if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame) != eSIR_SUCCESS))
1896 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301897 limLog(pMac, LOGE, FL("failed to convert Auth frame to struct"));
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301898
1899#ifdef WLAN_FEATURE_LFR_MBB
1900 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
1901 lim_handle_pre_auth_mbb_rsp(pMac, eSIR_FAILURE, psessionEntry);
1902 return eSIR_FAILURE;
1903 }
1904#endif
1905
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
1907 return eSIR_FAILURE;
1908 }
1909 pRxAuthFrameBody = &rxAuthFrame;
1910
1911#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001912 PELOGE(limLog(pMac, LOG1,
1913 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
1915 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
1916 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
1917#endif
1918
1919 switch (pRxAuthFrameBody->authTransactionSeqNumber)
1920 {
1921 case SIR_MAC_AUTH_FRAME_2:
1922 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1923 {
1924#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001925 PELOGE(limLog( pMac, LOGE, "Auth status code received is %d",
1926 (tANI_U32) pRxAuthFrameBody->authStatusCode););
Jeff Johnson295189b2012-06-20 16:38:30 -07001927#endif
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001928 if (eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS == pRxAuthFrameBody->authStatusCode)
1929 ret_status = eSIR_LIM_MAX_STA_REACHED_ERROR;
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 }
1931 else
1932 {
1933 ret_status = eSIR_SUCCESS;
1934 }
1935 break;
1936
1937 default:
1938#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001939 PELOGE(limLog( pMac, LOGE, "Seq. no incorrect expected 2 received %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber);)
1941#endif
1942 break;
1943 }
1944
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301945#ifdef WLAN_FEATURE_LFR_MBB
1946 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
1947 lim_handle_pre_auth_mbb_rsp(pMac, ret_status, psessionEntry);
1948 return ret_status;
1949 }
1950#endif
1951
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 // Send the Auth response to SME
1953 limHandleFTPreAuthRsp(pMac, ret_status, pBody, frameLen, psessionEntry);
1954
1955 return ret_status;
1956}
1957
1958#endif /* WLAN_FEATURE_VOWIFI_11R */
1959