blob: 08cc2c63d6e2213268f5afa8b209640562bf4d8f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
gaurank kathpalia66414892018-03-21 20:24:39 +05302 * Copyright (c) 2011-2015, 2017-2018 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
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530104#ifdef WLAN_FEATURE_SAE
105/**
106 * lim_process_sae_auth_frame()-Process SAE authentication frame
107 * @mac_ctx: MAC context
108 * @rx_pkt_info: Rx packet
109 * @pe_session: PE session
110 *
111 * Return: None
112 */
113static void lim_process_sae_auth_frame(tpAniSirGlobal mac_ctx,
114 uint8_t *rx_pkt_info,
115 tpPESession pe_session)
116{
117 tpSirMacMgmtHdr mac_hdr;
118
119 mac_hdr = WDA_GET_RX_MAC_HEADER(rx_pkt_info);
120
121 limLog(mac_ctx, LOG1, FL("Received SAE Auth frame type %d subtype %d"),
122 mac_hdr->fc.type, mac_hdr->fc.subType);
123
124 if (pe_session->limMlmState != eLIM_MLM_WT_SAE_AUTH_STATE)
125 limLog(mac_ctx, LOGE,
126 FL("received SAE auth response in unexpected state %x"),
127 pe_session->limMlmState);
128
129 limSendSmeMgmtFrameInd(mac_ctx, pe_session->peSessionId,
130 rx_pkt_info, pe_session,
131 WDA_GET_RX_RSSI_DB(rx_pkt_info));
132}
133#else
134static void lim_process_sae_auth_frame(tpAniSirGlobal mac_ctx,
135 uint8_t *rx_pkt_info,
136 tpPESession pe_session)
137{}
138#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700139
140/**
141 * limProcessAuthFrame
142 *
143 *FUNCTION:
144 * This function is called by limProcessMessageQueue() upon Authentication
145 * frame reception.
146 *
147 *LOGIC:
148 * This function processes received Authentication frame and responds
149 * with either next Authentication frame in sequence to peer MAC entity
150 * or LIM_MLM_AUTH_IND on AP or LIM_MLM_AUTH_CNF on STA.
151 *
152 *ASSUMPTIONS:
153 *
154 *NOTE:
155 * 1. Authentication failures are reported to SME with same status code
156 * received from the peer MAC entity.
157 * 2. Authentication frame2/4 received with alogirthm number other than
158 * one requested in frame1/3 are logged with an error and auth confirm
159 * will be sent to SME only after auth failure timeout.
160 * 3. Inconsistency in the spec:
161 * On receiving Auth frame2, specs says that if WEP key mapping key
162 * or default key is NULL, Auth frame3 with a status code 15 (challenge
163 * failure to be returned to peer entity. However, section 7.2.3.10,
164 * table 14 says that status code field is 'reserved' for frame3 !
165 * In the current implementation, Auth frame3 is returned with status
166 * code 15 overriding section 7.2.3.10.
167 * 4. If number pre-authentications reach configrable max limit,
168 * Authentication frame with 'unspecified failure' status code is
169 * returned to requesting entity.
170 *
171 * @param pMac - Pointer to Global MAC structure
172 * @param *pRxPacketInfo - A pointer to Rx packet info structure
173 * @return None
174 */
175
176void
177limProcessAuthFrame(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tpPESession psessionEntry)
178{
179 tANI_U8 *pBody, keyId, cfgPrivacyOptImp,
180 defaultKey[SIR_MAC_KEY_LENGTH],
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530181 *encrAuthFrame = NULL,
182 *plainBody = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700183 tANI_U16 frameLen;
184 //tANI_U32 authRspTimeout, maxNumPreAuth, val;
185 tANI_U32 maxNumPreAuth, val;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530186 tSirMacAuthFrameBody *pRxAuthFrameBody,
187 *rxAuthFrame = NULL,
188 *authFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 tpSirMacMgmtHdr pHdr;
190 tCfgWepKeyEntry *pKeyMapEntry = NULL;
191 struct tLimPreAuthNode *pAuthNode;
192 tLimMlmAuthInd mlmAuthInd;
193 tANI_U8 decryptResult;
194 tANI_U8 *pChallenge;
195 tANI_U32 key_length=8;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530196 tANI_U8 *challengeTextArray = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 tpDphHashNode pStaDs = NULL;
198 tANI_U16 assocId = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530199 tANI_U16 currSeqNo = 0;
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530200 tANI_U16 auth_alg = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 /* Added For BT -AMP support */
202 // Get pointer to Authentication frame header and body
203
204
205 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
206 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700207
208 if (!frameLen)
209 {
210 // Log error
211 limLog(pMac, LOGE,
212 FL("received Authentication frame with no body from "));
213 limPrintMacAddr(pMac, pHdr->sa, LOGE);
214
215 return;
216 }
217
218 if (limIsGroupAddr(pHdr->sa))
219 {
220 // Received Auth frame from a BC/MC address
221 // Log error and ignore it
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530222 limLog(pMac, LOGE,
223 FL("received Auth frame from a BC/MC address - "));
224 limPrintMacAddr(pMac, pHdr->sa, LOGE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700225
226 return;
227 }
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530228 currSeqNo = (pHdr->seqControl.seqNumHi << 4) | (pHdr->seqControl.seqNumLo);
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530229 limLog(pMac, LOG1,
230 FL("Sessionid: %d System role : %d limMlmState: %d :Auth "
231 "Frame Received: BSSID: "MAC_ADDRESS_STR " (RSSI %d)"),
232 psessionEntry->peSessionId, psessionEntry->limSystemRole,
233 psessionEntry->limMlmState, MAC_ADDR_ARRAY(pHdr->bssId),
234 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo)));
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800235
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
237
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530238 auth_alg = *(uint16_t *)pBody;
239 limLog(pMac, LOG1, FL("auth_alg %d "), auth_alg);
240
Jeff Johnsone7245742012-09-05 17:12:55 -0700241 //PELOG3(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG3, (tANI_U8*)pBd, ((tpHalBufDesc) pBd)->mpduDataOffset + frameLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700242
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800243 //Restore default failure timeout
244 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
245 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530246 limLog(pMac, LOG1, FL("Restore default failure timeout"));
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800247 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
248 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
249 }
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530250
251 rxAuthFrame = vos_mem_malloc(sizeof(tSirMacAuthFrameBody));
252 if (!rxAuthFrame) {
253 limLog(pMac, LOGE, FL("Failed to allocate memory"));
254 return;
255 }
256
257 authFrame = vos_mem_malloc(sizeof(tSirMacAuthFrameBody));
258 if (!authFrame) {
259 limLog(pMac, LOGE, FL("failed to allocate memory"));
260 goto free;
261 }
262
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530263 plainBody = vos_mem_malloc(LIM_ENCR_AUTH_BODY_LEN);
264 if (!plainBody) {
265 limLog(pMac, LOGE, FL("failed to allocate memory"));
266 goto free;
267 }
268
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +0530269 challengeTextArray = vos_mem_malloc(SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530270 if(!challengeTextArray) {
271 limLog(pMac, LOGE, FL("failed to allocate memory"));
272 goto free;
273 }
274
275 vos_mem_set(rxAuthFrame, sizeof(tSirMacAuthFrameBody), 0);
276 vos_mem_set(authFrame, sizeof(tSirMacAuthFrameBody), 0);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530277 vos_mem_set(plainBody, LIM_ENCR_AUTH_BODY_LEN, 0);
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +0530278 vos_mem_set(challengeTextArray, SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280 /// Determine if WEP bit is set in the FC or received MAC header
281 if (pHdr->fc.wep)
282 {
283 /**
284 * WEP bit is set in FC of MAC header.
285 */
286
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 // If TKIP counter measures enabled issue Deauth frame to station
288 if ((psessionEntry->bTkipCntrMeasActive) && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
289 {
290 PELOGE( limLog(pMac, LOGE,
291 FL("Tkip counter measures Enabled, sending Deauth frame to")); )
292 limPrintMacAddr(pMac, pHdr->sa, LOGE);
293
294 limSendDeauthMgmtFrame( pMac, eSIR_MAC_MIC_FAILURE_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800295 pHdr->sa, psessionEntry, FALSE );
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530296 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700298
299 // Extract key ID from IV (most 2 bits of 4th byte of IV)
300
301 keyId = (*(pBody + 3)) >> 6;
302
303 /**
304 * On STA in infrastructure BSS, Authentication frames received
305 * with WEP bit set in the FC must be rejected with challenge
306 * failure status code (wierd thing in the spec - this should have
307 * been rejected with unspecified failure or unexpected assertion
308 * of wep bit (this status code does not exist though) or
309 * Out-of-sequence-Authentication-Frame status code.
310 */
311
312 if (psessionEntry->limSystemRole == eLIM_STA_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)
313 {
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530314 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
315 authFrame->authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
316 authFrame->authStatusCode = eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Abhishek Singh208848c2013-12-18 19:02:52 +0530317 // Log error
318 PELOGE(limLog(pMac, LOGE,
319 FL("received Authentication frame with wep bit set on "
320 "role=%d "MAC_ADDRESS_STR),
321 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pHdr->sa) );)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530322 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530324 LIM_NO_WEP_IN_FC,
325 psessionEntry, eSIR_FALSE);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530326 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 }
328
Vignesh Viswanathan5ab5cde2017-11-21 16:21:34 +0530329 if ((frameLen < LIM_ENCR_AUTH_BODY_LEN_SAP) ||
330 (frameLen > LIM_ENCR_AUTH_BODY_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 {
332 // Log error
333 limLog(pMac, LOGE,
334 FL("Not enough size [%d] to decrypt received Auth frame"),
335 frameLen);
336 limPrintMacAddr(pMac, pHdr->sa, LOGE);
337
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530338 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
341 {
342 val = psessionEntry->privacy;
343 }
344 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 // Accept Authentication frame only if Privacy is implemented
346 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
347 &val) != eSIR_SUCCESS)
348 {
349 /**
350 * Could not get Privacy option
351 * from CFG. Log error.
352 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700353 limLog(pMac, LOGP, FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 }
355
356 cfgPrivacyOptImp = (tANI_U8)val;
357 if (cfgPrivacyOptImp)
358 {
359 /**
360 * Privacy option is implemented.
361 * Check if the received frame is Authentication
362 * frame3 and there is a context for requesting STA.
363 * If not, reject with unspecified failure status code
364 */
365 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
366
367 if (pAuthNode == NULL)
368 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530369 // Log error
370 PELOGE(limLog(pMac, LOGE,
371 FL("received Authentication frame from peer that has "
372 "no preauth context with WEP bit set "MAC_ADDRESS_STR),
373 MAC_ADDR_ARRAY(pHdr->sa));)
374
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 /**
376 * No 'pre-auth' context exists for this STA that sent
377 * an Authentication frame with FC bit set.
378 * Send Auth frame4 with 'out of sequence' status code.
379 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530380 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
381 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530383 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
385
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530386 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530388 LIM_NO_WEP_IN_FC,
389 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700390
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530391 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 }
393 else
394 {
395 /// Change the auth-response timeout
396 limDeactivateAndChangePerStaIdTimer(pMac,
397 eLIM_AUTH_RSP_TIMER,
398 pAuthNode->authNodeIdx);
399
400 /// 'Pre-auth' status exists for STA
401 if ((pAuthNode->mlmState !=
402 eLIM_MLM_WT_AUTH_FRAME3_STATE) &&
403 (pAuthNode->mlmState !=
404 eLIM_MLM_AUTH_RSP_TIMEOUT_STATE))
405 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530406 // Log error
407 PELOGE(limLog(pMac, LOGE,
408 FL("received Authentication frame from peer that is "
409 "in state %d "MAC_ADDRESS_STR),
410 pAuthNode->mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
411
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 /**
413 * Should not have received Authentication frame
414 * with WEP bit set in FC in other states.
415 * Reject by sending Authenticaton frame with
416 * out of sequence Auth frame status code.
417 */
418
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530419 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
420 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530422 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700423 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
424
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530425 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700426 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530427 LIM_NO_WEP_IN_FC,
428 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700429
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530430 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700431 }
432 }
433
434 /**
435 * Check if there exists a key mappping key
436 * for the STA that sent Authentication frame
437 */
438 pKeyMapEntry = limLookUpKeyMappings(pHdr->sa);
439
440 if (pKeyMapEntry)
441 {
442 if (!pKeyMapEntry->wepOn)
443 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530444 // Log error
445 PELOGE(limLog(pMac, LOGE,
446 FL("received Auth frame3 from peer that has NULL "
447 "key map entry "
448 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));)
449
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 /**
451 * Key Mapping entry has null key.
452 * Send Authentication frame
453 * with challenge failure status code
454 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530455 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
456 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700457 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530458 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
460
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530461 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530463 LIM_NO_WEP_IN_FC,
464 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700465
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530466 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 } // if (!pKeyMapEntry->wepOn)
468 else
469 {
470 decryptResult = limDecryptAuthFrame(pMac, pKeyMapEntry->key,
471 pBody,
472 plainBody,
473 key_length,
474 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
475 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
476 {
477 /// ICV failure
Abhishek Singh208848c2013-12-18 19:02:52 +0530478 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
479 "LIM_DECRYPT_ICV_FAIL ..."));)
480 // Log error
481 PELOGE(limLog(pMac, LOGE,
482 FL("received Authentication frame from peer "
483 "that failed decryption, Addr "
484 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
485
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 limDeletePreAuthNode(pMac,
487 pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530488 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
489 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530491 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
493
494 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530495 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530497 LIM_NO_WEP_IN_FC,
498 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700499
Jeff Johnson295189b2012-06-20 16:38:30 -0700500
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530501 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 }
503
Abhishek Singh208848c2013-12-18 19:02:52 +0530504 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530505 rxAuthFrame)!=eSIR_SUCCESS ) ||
506 ( !isAuthValid(pMac, rxAuthFrame,psessionEntry) ) )
Abhishek Singh208848c2013-12-18 19:02:52 +0530507 {
508 PELOGE(limLog(pMac, LOGE,
509 FL("failed to convert Auth Frame to structure "
510 "or Auth is not valid "));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530511 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530512 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700513
514
515 } // end if (pKeyMapEntry->key == NULL)
516 } // if keyMappings has entry
517 else
518 {
519
520 val = SIR_MAC_KEY_LENGTH;
521
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
523 {
524 tpSirKeys pKey;
525 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530526 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 val = pKey->keyLength;
528 }
529 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
531 defaultKey, &val) != eSIR_SUCCESS)
532 {
533 /// Could not get Default key from CFG.
534 //Log error.
535 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700536 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700537
538 /**
539 * Send Authentication frame
540 * with challenge failure status code
541 */
542
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530543 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
544 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530546 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
548
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530549 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530551 LIM_NO_WEP_IN_FC,
552 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700553
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530554 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 }
556
557 key_length=val;
558
559 decryptResult = limDecryptAuthFrame(pMac, defaultKey,
560 pBody,
561 plainBody,
562 key_length,
563 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
564 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
565 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530566 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
567 "LIM_DECRYPT_ICV_FAIL ..."));)
568 // Log error
569 PELOGE(limLog(pMac, LOGE,
570 FL("received Authentication frame from peer that "
571 "failed decryption: "
572 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 /// ICV failure
574 limDeletePreAuthNode(pMac,
575 pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530576 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
577 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700578 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530579 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
581
582 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530583 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 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530590 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530591 rxAuthFrame)!=eSIR_SUCCESS ) ||
592 ( !isAuthValid(pMac, rxAuthFrame, psessionEntry) ) )
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530593 {
594 limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +0530595 FL("failed to convert Auth Frame to structure "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530596 "or Auth is not valid "));
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530597 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530598 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 } // End of check for Key Mapping/Default key presence
600 }
601 else
602 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530603 // Log error
604 PELOGE(limLog(pMac, LOGE,
605 FL("received Authentication frame3 from peer that while "
606 "privacy option is turned OFF "
607 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 /**
609 * Privacy option is not implemented.
610 * So reject Authentication frame received with
611 * WEP bit set by sending Authentication frame
612 * with 'challenge failure' status code. This is
613 * another strange thing in the spec. Status code
614 * should have been 'unsupported algorithm' status code.
615 */
616
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530617 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
618 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530620 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700621 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
622
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530623 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700624 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530625 LIM_NO_WEP_IN_FC,
626 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700627
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530628 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 } // else if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530630 } else if ((auth_alg ==
631 eSIR_AUTH_TYPE_SAE) && (LIM_IS_STA_ROLE(psessionEntry))) {
632 lim_process_sae_auth_frame(pMac, pRxPacketInfo, psessionEntry);
633 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 } // if (fc.wep)
635 else
636 {
637
638
Abhishek Singh208848c2013-12-18 19:02:52 +0530639 if ( ( sirConvertAuthFrame2Struct(pMac, pBody,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530640 frameLen, rxAuthFrame)!=eSIR_SUCCESS ) ||
641 ( !isAuthValid(pMac, rxAuthFrame,psessionEntry) ) )
Abhishek Singh208848c2013-12-18 19:02:52 +0530642 {
643 PELOGE(limLog(pMac, LOGE,
644 FL("failed to convert Auth Frame to structure or Auth is "
645 "not valid "));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530646 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530647 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700648 }
649
650
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530651 pRxAuthFrameBody = rxAuthFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -0700652
Mohit Khanna23863762012-09-11 17:40:09 -0700653 PELOGW(limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700654 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700655 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
656 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
657 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
658
Wang Hu4506bae2015-12-07 14:15:19 +0800659 // IOT Workaround: with invalid WEP password, some APs reply AUTH frame 4
660 // with invalid seqNumber. This AUTH frame will be dropped by driver,
661 // thus driver sends the generic status code instead of protocol status code.
662 // As a workaround, assign the correct seqNumber for the AUTH frame 4.
663 if (psessionEntry->limMlmState == eLIM_MLM_WT_AUTH_FRAME4_STATE &&
664 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_1 &&
665 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_2 &&
666 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_3) {
667 PELOGE(limLog(pMac, LOGE, FL("Workaround: Assign a correct seqNumber=4 "
668 "for AUTH frame 4"));)
669 pRxAuthFrameBody->authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
670 }
671
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 switch (pRxAuthFrameBody->authTransactionSeqNumber)
673 {
674 case SIR_MAC_AUTH_FRAME_1:
675 // AuthFrame 1
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800676
677 pStaDs = dphLookupHashEntry(pMac, pHdr->sa,
678 &assocId, &psessionEntry->dph.dphHashTable);
679 if (pStaDs)
680 {
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530681 tLimMlmDisassocReq *pMlmDisassocReq = NULL;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800682 tLimMlmDeauthReq *pMlmDeauthReq = NULL;
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530683 tAniBool isConnected = eSIR_TRUE;
684
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800685 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
686 if (pMlmDisassocReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530687 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800688 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530689 sizeof(tSirMacAddr))))
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800690 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800691 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for disassoc "
692 "frame is pending Issue delsta for "
693 MAC_ADDRESS_STR),
694 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700695 limProcessDisassocAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530696 isConnected = eSIR_FALSE;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800697 }
698 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
699 if (pMlmDeauthReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530700 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800701 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
702 sizeof(tSirMacAddr))))
703 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800704 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for deauth frame "
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700705 "is pending Issue delsta for "
Arif Hussain24bafea2013-11-15 15:10:03 -0800706 MAC_ADDRESS_STR),
707 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700708 limProcessDeauthAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530709 isConnected = eSIR_FALSE;
710 }
711
712 /* pStaDS != NULL and isConnected = 1 means the STA is already
713 * connected, But SAP received the Auth from that station.
Abhishek Singh0496a522015-12-14 23:39:23 -0800714 * For non PMF connection send Deauth frame as STA will retry
715 * to connect back.
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530716 *
717 * For PMF connection the AP should not tear down or otherwise
718 * modify the state of the existing association until the
719 * SA-Query procedure determines that the original SA is
720 * invalid.
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530721 */
gaurank kathpalia66414892018-03-21 20:24:39 +0530722 if (isConnected && pStaDs->PrevAuthSeqno != currSeqNo
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530723#ifdef WLAN_FEATURE_11W
724 && !pStaDs->rmfEnabled
725#endif
gaurank kathpalia66414892018-03-21 20:24:39 +0530726 )
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530727 {
Abhishek Singh0496a522015-12-14 23:39:23 -0800728 limLog(pMac, LOGE,
729 FL("STA is already connected but received auth frame"
730 "Send the Deauth and lim Delete Station Context"
731 "(staId: %d, assocId: %d) "),
732 pStaDs->staIndex, assocId);
733 limSendDeauthMgmtFrame(pMac, eSIR_MAC_UNSPEC_FAILURE_REASON,
734 (tANI_U8 *) pHdr->sa, psessionEntry, FALSE);
735 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530736 goto free;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800737 }
738 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700739
740 /// Check if there exists pre-auth context for this STA
741 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
742 if (pAuthNode)
743 {
744 /// Pre-auth context exists for the STA
gaurank kathpalia66414892018-03-21 20:24:39 +0530745 if (pAuthNode->seqNo != currSeqNo)
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 {
747 /**
748 * STA is initiating brand-new Authentication
749 * sequence after local Auth Response timeout.
750 * Or STA retrying to transmit First Auth frame due to packet drop OTA
751 * Delete Pre-auth node and fall through.
752 */
753 if(pAuthNode->fTimerStarted)
754 {
755 limDeactivateAndChangePerStaIdTimer(pMac,
756 eLIM_AUTH_RSP_TIMER,
757 pAuthNode->authNodeIdx);
758 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530759 PELOGE(limLog(pMac, LOGE, FL("STA is initiating brand-new "
760 "Authentication ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 limDeletePreAuthNode(pMac,
762 pHdr->sa);
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 /**
764 * SAP Mode:Disassociate the station and
765 * delete its entry if we have its entry
766 * already and received "auth" from the
767 * same station.
768 */
769
770 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
771 {
772 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
773
774 if (NULL == pStaDs)
775 continue;
776
777 if (pStaDs->valid)
778 {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530779 if (vos_mem_compare((tANI_U8 *) &pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 (tANI_U8 *) &(pHdr->sa), (tANI_U8) (sizeof(tSirMacAddr))) )
781 break;
782 }
Edhar, Mahesh Kumar29013e82014-02-05 10:38:08 +0530783
784 pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700785 }
786
Abhishek Singhe9417492014-09-25 15:55:36 +0530787 if (NULL != pStaDs
788#ifdef WLAN_FEATURE_11W
789 && !pStaDs->rmfEnabled
790#endif
791 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 {
Abhishek Singh0496a522015-12-14 23:39:23 -0800793 PELOGE(limLog(pMac, LOGE, FL("lim Delete Station "
794 "Context (staId: %d, assocId: %d) "),pStaDs->staIndex,
795 assocId);)
796 limSendDeauthMgmtFrame(pMac,
797 eSIR_MAC_UNSPEC_FAILURE_REASON, (tANI_U8 *) pAuthNode->peerMacAddr, psessionEntry, FALSE);
798 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530799 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700800 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 }
802 else
803 {
804 /*
805 * This can happen when first authentication frame is received
806 * but ACK lost at STA side, in this case 2nd auth frame is already
807 * in transmission queue
808 * */
Abhishek Singh208848c2013-12-18 19:02:52 +0530809 PELOGE(limLog(pMac, LOGE, FL("STA is initiating "
810 "Authentication after ACK lost..."));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530811 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 }
813 }
814 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
815 (tANI_U32 *) &maxNumPreAuth) != eSIR_SUCCESS)
816 {
817 /**
818 * Could not get MaxNumPreAuth
819 * from CFG. Log error.
820 */
821 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700822 FL("could not retrieve MaxNumPreAuth"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700823 }
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530824
825 if (pMac->lim.gLimNumPreAuthContexts == maxNumPreAuth &&
826 !limDeleteOpenAuthPreAuthNode(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530828 PELOGE(limLog(pMac, LOGE, FL("Max number of "
829 "preauth context reached"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 /**
831 * Maximum number of pre-auth contexts
832 * reached. Send Authentication frame
833 * with unspecified failure
834 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530835 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530837 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530839 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 eSIR_MAC_UNSPEC_FAILURE_STATUS;
841
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530842 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530844 LIM_NO_WEP_IN_FC,
845 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700846
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530847 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 }
849 /// No Pre-auth context exists for the STA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700850 if (limIsAuthAlgoSupported(
851 pMac,
852 (tAniAuthType)
853 pRxAuthFrameBody->authAlgoNumber, psessionEntry))
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 {
855 switch (pRxAuthFrameBody->authAlgoNumber)
856 {
857 case eSIR_OPEN_SYSTEM:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700858 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_OPEN_SYSTEM ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 /// Create entry for this STA in pre-auth list
860 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
861 if (pAuthNode == NULL)
862 {
863 // Log error
864 limLog(pMac, LOGW,
865 FL("Max pre-auth nodes reached "));
866 limPrintMacAddr(pMac, pHdr->sa, LOGW);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530867 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 }
869
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530870 limLog(pMac, LOG1,
871 FL("Alloc new data: peer "MAC_ADDRESS_STR),
872 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700873
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530874 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
875 pHdr->sa,
876 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700877
878 pAuthNode->mlmState =
879 eLIM_MLM_AUTHENTICATED_STATE;
880 pAuthNode->authType = (tAniAuthType)
881 pRxAuthFrameBody->authAlgoNumber;
882 pAuthNode->fSeen = 0;
883 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530884 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
885 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530886 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 limAddPreAuthNode(pMac, pAuthNode);
888
889 /**
890 * Send Authenticaton frame with Success
891 * status code.
892 */
893
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530894 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530896 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530898 authFrame->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530900 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530902 LIM_NO_WEP_IN_FC,
903 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700904
905 /// Send Auth indication to SME
906
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530907 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 (tANI_U8 *) pHdr->sa,
909 sizeof(tSirMacAddr));
910 mlmAuthInd.authType = (tAniAuthType)
911 pRxAuthFrameBody->authAlgoNumber;
912 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
913
914 limPostSmeMessage(pMac,
915 LIM_MLM_AUTH_IND,
916 (tANI_U32 *) &mlmAuthInd);
917 break;
918
919 case eSIR_SHARED_KEY:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700920 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_SHARED_KEY ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
922 {
923 val = psessionEntry->privacy;
924 }
925 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
927 &val) != eSIR_SUCCESS)
928 {
929 /**
930 * Could not get Privacy option
931 * from CFG. Log error.
932 */
933 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700934 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 }
936 cfgPrivacyOptImp = (tANI_U8)val;
937 if (!cfgPrivacyOptImp)
938 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530939 // Log error
940 PELOGE(limLog(pMac, LOGE,
941 FL("received Auth frame for unsupported auth algorithm %d "
942 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
943 MAC_ADDR_ARRAY(pHdr->sa));)
944
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 /**
946 * Authenticator does not have WEP
947 * implemented.
948 * Reject by sending Authentication frame
949 * with Auth algorithm not supported status
950 * code.
951 */
952
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530953 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530955 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530957 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
959
960 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530961 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530963 LIM_NO_WEP_IN_FC,
964 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700965
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530966 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 }
968 else
969 {
970 // Create entry for this STA
971 //in pre-auth list
972 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
973 if (pAuthNode == NULL)
974 {
975 // Log error
976 limLog(pMac, LOGW,
977 FL("Max pre-auth nodes reached "));
978 limPrintMacAddr(pMac, pHdr->sa, LOGW);
979
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530980 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 }
982
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530983 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
984 pHdr->sa,
985 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700986
987 pAuthNode->mlmState =
988 eLIM_MLM_WT_AUTH_FRAME3_STATE;
989 pAuthNode->authType =
990 (tAniAuthType)
991 pRxAuthFrameBody->authAlgoNumber;
992 pAuthNode->fSeen = 0;
993 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530994 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
995 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530996 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -0700997 limAddPreAuthNode(pMac, pAuthNode);
998
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530999 limLog(pMac, LOG1,
1000 FL("Alloc new data: id %d peer "MAC_ADDRESS_STR),
1001 pAuthNode->authNodeIdx, MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001002
1003 /// Create and activate Auth Response timer
1004 if (tx_timer_change_context(&pAuthNode->timer, pAuthNode->authNodeIdx) != TX_SUCCESS)
1005 {
1006 /// Could not start Auth response timer.
1007 // Log error
1008 limLog(pMac, LOGP,
1009 FL("Unable to chg context auth response timer for peer "));
1010 limPrintMacAddr(pMac, pHdr->sa, LOGP);
1011
1012 /**
1013 * Send Authenticaton frame with
1014 * unspecified failure status code.
1015 */
1016
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301017 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301019 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301021 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 eSIR_MAC_UNSPEC_FAILURE_STATUS;
1023
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301024 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301026 LIM_NO_WEP_IN_FC,
1027 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001028
1029 limDeletePreAuthNode(pMac, pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301030 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 }
1032
1033 limActivateAuthRspTimer(pMac, pAuthNode);
1034
1035 pAuthNode->fTimerStarted = 1;
1036
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301037 /*
1038 * get random bytes and use as challenge text
1039 */
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301040 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 -07001041 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301042 limLog(pMac, LOGE,FL("Challenge text "
1043 "preparation failed in limProcessAuthFrame"));
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301044 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 }
1046
1047 pChallenge = pAuthNode->challengeText;
1048
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301049 vos_mem_copy(pChallenge,
1050 (tANI_U8 *) challengeTextArray,
1051 sizeof(challengeTextArray));
Jeff Johnson295189b2012-06-20 16:38:30 -07001052
1053 /**
1054 * Sending Authenticaton frame with challenge.
1055 */
1056
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301057 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301059 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301061 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 eSIR_MAC_SUCCESS_STATUS;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301063 authFrame->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301064 authFrame->length = SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301065 vos_mem_copy(authFrame->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 pAuthNode->challengeText,
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301067 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -07001068
1069 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301070 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301072 LIM_NO_WEP_IN_FC,
1073 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001074 } // if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1075
1076 break;
1077
1078 default:
Abhishek Singh208848c2013-12-18 19:02:52 +05301079 // Log error
1080 PELOGE( limLog(pMac, LOGE,
1081 FL("received Auth frame for unsupported auth "
1082 "algorithm %d "MAC_ADDRESS_STR),
1083 pRxAuthFrameBody->authAlgoNumber,
1084 MAC_ADDR_ARRAY(pHdr->sa));)
1085
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 /**
1087 * Responding party does not support the
1088 * authentication algorithm requested by
1089 * sending party.
1090 * Reject by sending Authentication frame
1091 * with auth algorithm not supported status code
1092 */
1093
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301094 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301096 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301098 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1100
1101 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301102 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301104 LIM_NO_WEP_IN_FC,
1105 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001106
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301107 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 } // end switch(pRxAuthFrameBody->authAlgoNumber)
1109 } // if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1110 else
1111 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301112 // Log error
1113 PELOGE(limLog(pMac, LOGE,
1114 FL("received Authentication frame for unsupported auth "
1115 "algorithm %d "MAC_ADDRESS_STR),
1116 pRxAuthFrameBody->authAlgoNumber,
1117 MAC_ADDR_ARRAY(pHdr->sa));)
1118
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 /**
1120 * Responding party does not support the
1121 * authentication algorithm requested by sending party.
1122 * Reject Authentication with StatusCode=13.
1123 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301124 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301126 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301128 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001129 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1130
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301131 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301133 LIM_NO_WEP_IN_FC,
1134 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001135
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301136 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 } //end if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1138 break;
1139
1140 case SIR_MAC_AUTH_FRAME_2:
1141 // AuthFrame 2
1142
1143 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME2_STATE)
1144 {
1145 /**
1146 * Received Authentication frame2 in an unexpected state.
1147 * Log error and ignore the frame.
1148 */
1149
1150 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301151 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 FL("received Auth frame2 from peer in state %d, addr "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301153 psessionEntry->limMlmState);
1154 limPrintMacAddr(pMac, pHdr->sa, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001155
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301156 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 }
1158
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301159 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1160 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1161 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001162 {
1163 /**
1164 * Received Authentication frame from an entity
1165 * other than one request was initiated.
1166 * Wait until Authentication Failure Timeout.
1167 */
1168
1169 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001170 PELOGW(limLog(pMac, LOGW,
Abhishek Singh208848c2013-12-18 19:02:52 +05301171 FL("received Auth frame2 from unexpected peer "
1172 MAC_ADDRESS_STR),
Mohit Khanna23863762012-09-11 17:40:09 -07001173 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001174
1175 break;
1176 }
1177
1178 if (pRxAuthFrameBody->authStatusCode ==
1179 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS)
1180 {
1181 /**
1182 * Interoperability workaround: Linksys WAP4400N is returning
1183 * wrong authType in OpenAuth response in case of
1184 * SharedKey AP configuration. Pretend we don't see that,
1185 * so upper layer can fallback to SharedKey authType,
1186 * and successfully connect to the AP.
1187 */
1188 if (pRxAuthFrameBody->authAlgoNumber !=
1189 pMac->lim.gpLimMlmAuthReq->authType)
1190 {
1191 pRxAuthFrameBody->authAlgoNumber =
1192 pMac->lim.gpLimMlmAuthReq->authType;
1193 }
1194 }
1195
1196 if (pRxAuthFrameBody->authAlgoNumber !=
1197 pMac->lim.gpLimMlmAuthReq->authType)
1198 {
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05301199 /*
1200 * Auth algo is open in rx auth frame when auth type is SAE and
1201 * PMK is cached as driver sent auth algo as open in tx frame
1202 * as well.
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 */
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05301204 if ((pMac->lim.gpLimMlmAuthReq->authType ==
1205 eSIR_AUTH_TYPE_SAE) && psessionEntry->sae_pmk_cached) {
1206 limLog(pMac, LOGW,
1207 FL("rx Auth frame2 auth algo %d in SAE PMK case"),
1208 pRxAuthFrameBody->authAlgoNumber);
1209 } else {
1210 /**
1211 * Received Authentication frame with an auth
1212 * algorithm other than one requested.
1213 * Wait until Authentication Failure Timeout.
1214 */
1215 // Log error
1216 PELOGW(limLog(pMac, LOGW,
1217 FL("received Auth frame2 for unexpected auth algo num %d "
1218 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
1219 MAC_ADDR_ARRAY(pHdr->sa));)
1220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 break;
1222 }
1223
1224 if (pRxAuthFrameBody->authStatusCode ==
1225 eSIR_MAC_SUCCESS_STATUS)
1226 {
1227 if (pRxAuthFrameBody->authAlgoNumber ==
1228 eSIR_OPEN_SYSTEM)
1229 {
1230 psessionEntry->limCurrentAuthType = eSIR_OPEN_SYSTEM;
1231
1232 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1233
1234 if (pAuthNode == NULL)
1235 {
1236 // Log error
1237 limLog(pMac, LOGW,
1238 FL("Max pre-auth nodes reached "));
1239 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1240
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301241 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 }
1243
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301244 limLog(pMac, LOG1,
1245 FL("Alloc new data: peer "MAC_ADDRESS_STR),
1246 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001247
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301248 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1250 sizeof(tSirMacAddr));
1251 pAuthNode->fTimerStarted = 0;
1252 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301253 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1254 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301255 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 limAddPreAuthNode(pMac, pAuthNode);
1257
1258 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1259 pRxAuthFrameBody->authStatusCode,psessionEntry);
1260 } // if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1261 else
1262 {
1263 // Shared key authentication
1264
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1266 {
1267 val = psessionEntry->privacy;
1268 }
1269 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1271 &val) != eSIR_SUCCESS)
1272 {
1273 /**
1274 * Could not get Privacy option
1275 * from CFG. Log error.
1276 */
1277 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001278 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 }
1280 cfgPrivacyOptImp = (tANI_U8)val;
1281 if (!cfgPrivacyOptImp)
1282 {
1283 /**
1284 * Requesting STA does not have WEP implemented.
1285 * Reject with unsupported authentication algorithm
1286 * Status code and wait until auth failure timeout
1287 */
1288
1289 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001290 PELOGE( limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301291 FL("received Auth frame from peer for "
1292 "unsupported auth algo %d "
1293 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001294 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001295
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301296 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301298 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301300 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001301 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1302
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301303 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301305 LIM_NO_WEP_IN_FC,
1306 psessionEntry, eSIR_FALSE);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301307 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 }
1309 else
1310 {
1311
1312 if (pRxAuthFrameBody->type !=
1313 SIR_MAC_CHALLENGE_TEXT_EID)
1314 {
1315 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001316 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301317 FL("received Auth frame with invalid "
1318 "challenge text IE"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001319
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301320 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 }
1322
1323 /**
1324 * Check if there exists a key mappping key
1325 * for the STA that sent Authentication frame
1326 */
1327 pKeyMapEntry = limLookUpKeyMappings(
1328 pHdr->sa);
1329
1330 if (pKeyMapEntry)
1331 {
1332 if (pKeyMapEntry->key == NULL)
1333 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301334 // Log error
1335 PELOGE(limLog(pMac, LOGE,
1336 FL("received Auth frame from peer when "
1337 "key mapping key is NULL"MAC_ADDRESS_STR),
1338 MAC_ADDR_ARRAY(pHdr->sa));)
1339
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 /**
1341 * Key Mapping entry has null key.
1342 * Send Auth frame with
1343 * challenge failure status code
1344 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301345 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301347 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301349 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001350 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1351
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301352 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001353 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301354 LIM_NO_WEP_IN_FC,
1355 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001356
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 limRestoreFromAuthState(pMac, eSIR_SME_NO_KEY_MAPPING_KEY_FOR_PEER,
1358 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1359
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301360 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 } // if (pKeyMapEntry->key == NULL)
1362 else
1363 {
1364 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1365 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1366 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1367 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1368 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1369 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301370 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301371 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301373 pRxAuthFrameBody->length);
1374
1375 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1376 LIM_ENCR_AUTH_INFO_LEN);
1377 if (!encrAuthFrame) {
1378 limLog(pMac, LOGE, FL("failed to allocate memory"));
1379 goto free;
1380 }
1381 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1382 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001383
1384 limEncryptAuthFrame(pMac, 0,
1385 pKeyMapEntry->key,
1386 plainBody,
1387 encrAuthFrame,key_length);
1388
1389 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001390 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001391
1392 limSendAuthMgmtFrame(pMac,
1393 (tpSirMacAuthFrameBody) encrAuthFrame,
1394 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301395 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301396 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001397
1398 break;
1399 } // end if (pKeyMapEntry->key == NULL)
1400 } // if (pKeyMapEntry)
1401 else
1402 {
1403 if (wlan_cfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID,
1404 &val) != eSIR_SUCCESS)
1405 {
1406 /**
1407 * Could not get Default keyId
1408 * from CFG. Log error.
1409 */
1410 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001411 FL("could not retrieve Default keyId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 }
1413 keyId = (tANI_U8)val;
1414
1415 val = SIR_MAC_KEY_LENGTH;
1416
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1418 {
1419 tpSirKeys pKey;
1420 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301421 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 }
1423 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
1425 defaultKey,
1426 &val)
1427 != eSIR_SUCCESS)
1428 {
1429 /// Could not get Default key from CFG.
1430 //Log error.
1431 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001432 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001433
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301434 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301436 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301438 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1440
1441 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301442 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301444 LIM_NO_WEP_IN_FC,
1445 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001446
1447 limRestoreFromAuthState(pMac, eSIR_SME_INVALID_WEP_DEFAULT_KEY,
1448 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1449
1450 break;
1451 }
1452 key_length=val;
1453 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1454 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1455 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1456 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1457 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1458 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301459 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301460 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301462 pRxAuthFrameBody->length);
1463
1464 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1465 LIM_ENCR_AUTH_INFO_LEN);
1466 if (!encrAuthFrame) {
1467 limLog(pMac, LOGE, FL("failed to allocate memory"));
1468 goto free;
1469 }
1470 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1471 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001472
1473 limEncryptAuthFrame(pMac, keyId,
1474 defaultKey,
1475 plainBody,
1476 encrAuthFrame,key_length);
1477
1478 psessionEntry->limMlmState =
1479 eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001480 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001481
1482 limSendAuthMgmtFrame(pMac,
1483 (tpSirMacAuthFrameBody) encrAuthFrame,
1484 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301485 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301486 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001487
1488 break;
1489 } // end if (pKeyMapEntry)
1490 } // end if (!wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1491 } // end if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1492 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1493 else
1494 {
1495 /**
1496 * Authentication failure.
1497 * Return Auth confirm with received failure code to SME
1498 */
1499
1500 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001501 PELOGE(limLog(pMac, LOGE,
1502 FL("received Auth frame from peer with failure code %d "
1503 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1504 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001505
1506 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1507 pRxAuthFrameBody->authStatusCode,psessionEntry);
1508 } // end if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1509
1510 break;
1511
1512 case SIR_MAC_AUTH_FRAME_3:
1513 // AuthFrame 3
1514
1515 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1516 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301517 // Log error
1518 PELOGE(limLog(pMac, LOGE,
1519 FL("received Auth frame3 from peer with auth algo "
1520 "number %d "MAC_ADDRESS_STR),
1521 pRxAuthFrameBody->authAlgoNumber,
1522 MAC_ADDR_ARRAY(pHdr->sa));)
1523
Jeff Johnson295189b2012-06-20 16:38:30 -07001524 /**
1525 * Received Authentication frame3 with algorithm other than
1526 * Shared Key authentication type. Reject with Auth frame4
1527 * with 'out of sequence' status code.
1528 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301529 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1530 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301532 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1534
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301535 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301537 LIM_NO_WEP_IN_FC,
1538 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001539
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301540 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 }
1542
1543 if (psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE ||
1544 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
1545 {
1546 /**
1547 * Check if wep bit was set in FC. If not set,
1548 * reject with Authentication frame4 with
1549 * 'challenge failure' status code.
1550 */
1551 if (!pHdr->fc.wep)
1552 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301553 // Log error
1554 PELOGE(limLog(pMac, LOGE,
1555 FL("received Auth frame3 from peer with no WEP bit "
1556 "set "MAC_ADDRESS_STR),
1557 MAC_ADDR_ARRAY(pHdr->sa));)
1558
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 /// WEP bit is not set in FC of Auth Frame3
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301560 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1561 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301563 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1565
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301566 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001567 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301568 LIM_NO_WEP_IN_FC,
1569 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001570
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301571 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 }
1573
1574 pAuthNode = limSearchPreAuthList(pMac,
1575 pHdr->sa);
1576 if (pAuthNode == NULL)
1577 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301578 // Log error
1579 PELOGE(limLog(pMac, LOGW,
1580 FL("received AuthFrame3 from peer that has no "
1581 "preauth context "MAC_ADDRESS_STR),
1582 MAC_ADDR_ARRAY(pHdr->sa));)
1583
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 /**
1585 * No 'pre-auth' context exists for
1586 * this STA that sent an Authentication
1587 * frame3.
1588 * Send Auth frame4 with 'out of sequence'
1589 * status code.
1590 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301591 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1592 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301594 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1596
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301597 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301599 LIM_NO_WEP_IN_FC,
1600 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001601
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301602 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 }
1604
1605 if (pAuthNode->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)
1606 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301607 // Log error
1608 limLog(pMac, LOGW,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301609 FL("auth response timer timedout for peer "
1610 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 /**
1612 * Received Auth Frame3 after Auth Response timeout.
1613 * Reject by sending Auth Frame4 with
1614 * Auth respone timeout Status Code.
1615 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301616 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1617 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301619 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS;
1621
1622 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301623 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301625 LIM_NO_WEP_IN_FC,
1626 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001627
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 /// Delete pre-auth context of STA
1629 limDeletePreAuthNode(pMac,
1630 pHdr->sa);
1631
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301632 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 } // end switch (pAuthNode->mlmState)
1634
1635 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1636 {
1637 /**
1638 * Received Authenetication Frame 3 with status code
1639 * other than success. Wait until Auth response timeout
1640 * to delete STA context.
1641 */
1642
1643 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001644 PELOGE(limLog(pMac, LOGE,
1645 FL("received Auth frame3 from peer with status code %d "
1646 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1647 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001648
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301649 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 }
1651
1652 /**
1653 * Check if received challenge text is same as one sent in
1654 * Authentication frame3
1655 */
1656
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301657 if (vos_mem_compare(pRxAuthFrameBody->challengeText,
1658 pAuthNode->challengeText,
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301659 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH))
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 {
1661 /// Challenge match. STA is autheticated !
1662
1663 /// Delete Authentication response timer if running
1664 limDeactivateAndChangePerStaIdTimer(pMac,
1665 eLIM_AUTH_RSP_TIMER,
1666 pAuthNode->authNodeIdx);
1667
1668 pAuthNode->fTimerStarted = 0;
1669 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1670
1671 /**
1672 * Send Authentication Frame4 with 'success' Status Code.
1673 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301674 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1675 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001676 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301677 authFrame->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001678
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301679 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301681 LIM_NO_WEP_IN_FC,
1682 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001683
1684 /// Send Auth indication to SME
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301685 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 (tANI_U8 *) pHdr->sa,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301687 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 mlmAuthInd.authType = (tAniAuthType)
1689 pRxAuthFrameBody->authAlgoNumber;
1690 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
1691
1692 limPostSmeMessage(pMac,
1693 LIM_MLM_AUTH_IND,
1694 (tANI_U32 *) &mlmAuthInd);
1695
1696 break;
1697 }
1698 else
1699 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301700 // Log error
1701 PELOGE( limLog(pMac, LOGW,
1702 FL("Challenge failure for peer "
1703 MAC_ADDRESS_STR),
1704 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 /**
1706 * Challenge Failure.
1707 * Send Authentication frame4 with 'challenge failure'
1708 * status code and wait until Auth response timeout to
1709 * delete STA context.
1710 */
1711
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301712 authFrame->authAlgoNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001713 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301714 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001715 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301716 authFrame->authStatusCode =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001717 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001718
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301719 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301721 LIM_NO_WEP_IN_FC,
1722 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001723
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301724 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 }
1726 } // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE || ...
1727
1728 break;
1729
1730 case SIR_MAC_AUTH_FRAME_4:
1731 // AuthFrame 4
1732 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE)
1733 {
1734 /**
1735 * Received Authentication frame4 in an unexpected state.
1736 * Log error and ignore the frame.
1737 */
1738
1739 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301740 limLog(pMac, LOG1,
Abhishek Singh208848c2013-12-18 19:02:52 +05301741 FL("received unexpected Auth frame4 from peer in state "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301742 "%d, addr "MAC_ADDRESS_STR), psessionEntry->limMlmState,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301743 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001744
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301745 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 }
1747
1748 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1749 {
1750 /**
1751 * Received Authentication frame4 with algorithm other than
1752 * Shared Key authentication type.
1753 * Wait until Auth failure timeout to report authentication
1754 * failure to SME.
1755 */
1756
1757 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001758 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301759 FL("received Auth frame4 from peer with invalid auth "
1760 "algo %d "MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001761 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001762
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301763 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 }
1765
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301766 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1767 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1768 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 {
1770 /**
1771 * Received Authentication frame from an entity
1772 * other than one to which request was initiated.
1773 * Wait until Authentication Failure Timeout.
1774 */
1775
1776 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001777 PELOGE(limLog(pMac, LOGW,
1778 FL("received Auth frame4 from unexpected peer "
1779 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001780
1781 break;
1782 }
1783
1784 if (pRxAuthFrameBody->authAlgoNumber !=
1785 pMac->lim.gpLimMlmAuthReq->authType)
1786 {
1787 /**
1788 * Received Authentication frame with an auth algorithm
1789 * other than one requested.
1790 * Wait until Authentication Failure Timeout.
1791 */
1792
Mohit Khanna23863762012-09-11 17:40:09 -07001793 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301794 FL("received Authentication frame from peer with "
1795 "invalid auth seq number %d "
1796 MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001797 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001798
1799 break;
1800 }
1801
1802 if (pRxAuthFrameBody->authStatusCode ==
1803 eSIR_MAC_SUCCESS_STATUS)
1804 {
1805 /**
1806 * Authentication Success !
1807 * Inform SME of same.
1808 */
1809 psessionEntry->limCurrentAuthType = eSIR_SHARED_KEY;
1810
1811 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1812 if (pAuthNode == NULL)
1813 {
1814 // Log error
1815 limLog(pMac, LOGW,
1816 FL("Max pre-auth nodes reached "));
1817 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1818
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301819 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301821 limLog(pMac, LOG1,
1822 FL("Alloc new data: peer " MAC_ADDRESS_STR),
1823 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001824
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301825 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1827 sizeof(tSirMacAddr));
1828 pAuthNode->fTimerStarted = 0;
1829 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301830 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1831 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301832 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 limAddPreAuthNode(pMac, pAuthNode);
1834
1835 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1836 pRxAuthFrameBody->authStatusCode,psessionEntry);
1837
1838 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1839 else
1840 {
1841 /**
1842 * Authentication failure.
1843 * Return Auth confirm with received failure code to SME
1844 */
1845
1846 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001847 PELOGE(limLog(pMac, LOGE, FL("Authentication failure from peer "
1848 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001849
1850 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1851 pRxAuthFrameBody->authStatusCode,psessionEntry);
1852 } // end if (pRxAuthFrameBody->Status == 0)
1853
1854 break;
1855
1856 default:
1857 /// Invalid Authentication Frame received. Ignore it.
1858
1859 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001860 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301861 FL("received Auth frame from peer with invalid auth seq "
1862 "number %d " MAC_ADDRESS_STR),
1863 pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001864 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001865
1866 break;
1867 } // end switch (pRxAuthFrameBody->authTransactionSeqNumber)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301868
1869free:
1870 if (authFrame)
1871 vos_mem_free(authFrame);
1872 if (rxAuthFrame)
1873 vos_mem_free(rxAuthFrame);
1874 if (encrAuthFrame)
1875 vos_mem_free(encrAuthFrame);
1876 if (plainBody)
1877 vos_mem_free(plainBody);
1878 if (challengeTextArray)
1879 vos_mem_free(challengeTextArray);
1880
Jeff Johnson295189b2012-06-20 16:38:30 -07001881} /*** end limProcessAuthFrame() ***/
1882
1883
1884
1885
1886
1887#ifdef WLAN_FEATURE_VOWIFI_11R
1888
1889/*----------------------------------------------------------------------
1890 *
1891 * Pass the received Auth frame. This is possibly the pre-auth from the
1892 * neighbor AP, in the same mobility domain.
1893 * This will be used in case of 11r FT.
1894 *
1895 * !!!! This is going to be renoved for the next checkin. We will be creating
1896 * the session before sending out the Auth. Thus when auth response
1897 * is received we will have a session in progress. !!!!!
1898 *----------------------------------------------------------------------
1899 */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001900tSirRetStatus limProcessAuthFrameNoSession(tpAniSirGlobal pMac, tANI_U8 *pBd, void *body)
Jeff Johnson295189b2012-06-20 16:38:30 -07001901{
1902 tpSirMacMgmtHdr pHdr;
1903 tpPESession psessionEntry = NULL;
1904 tANI_U8 *pBody;
1905 tANI_U16 frameLen;
1906 tSirMacAuthFrameBody rxAuthFrame;
1907 tSirMacAuthFrameBody *pRxAuthFrameBody = NULL;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001908 tSirRetStatus ret_status = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001909
1910 pHdr = WDA_GET_RX_MAC_HEADER(pBd);
1911 pBody = WDA_GET_RX_MPDU_DATA(pBd);
1912 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd);
1913
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05301914 /*
1915 * since, roaming is not supported in sta + mon scc, ignore
1916 * pre-auth when capture on monitor mode is started
1917 */
1918 if (vos_check_monitor_state())
1919 {
1920 limLog(pMac, LOG1, FL("Ignore pre-auth frame in monitor mode"));
1921 return eSIR_FAILURE;
1922 }
1923
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301924 limLog(pMac, LOG1, FL("Auth Frame Received: BSSID " MAC_ADDRESS_STR
1925 " (RSSI %d)"),MAC_ADDR_ARRAY(pHdr->bssId),
1926 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 // Check for the operating channel and see what needs to be done next.
1928 psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
1929 if (psessionEntry == NULL)
1930 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301931 limLog(pMac, LOGE, FL("Error: Unable to find session id while in "
1932 "pre-auth phase for FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 return eSIR_FAILURE;
1934 }
1935
1936 if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL)
1937 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301938 limLog(pMac, LOGE, FL("Error: No FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 // No FT in progress.
1940 return eSIR_FAILURE;
1941 }
1942
1943 if (frameLen == 0)
1944 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301945 limLog(pMac, LOGE, FL("Error: Frame len = 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 return eSIR_FAILURE;
1947 }
1948#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001949 limPrintMacAddr(pMac, pHdr->bssId, LOG2);
1950 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOG2);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001951 limLog(pMac,LOG2,FL("seqControl 0x%X"),
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001952 ((pHdr->seqControl.seqNumHi << 8) |
1953 (pHdr->seqControl.seqNumLo << 4) |
1954 (pHdr->seqControl.fragNum)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001955#endif
1956
1957 // Check that its the same bssId we have for preAuth
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301958 if (!vos_mem_compare(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1959 pHdr->bssId, sizeof( tSirMacAddr )))
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301961 limLog(pMac, LOGE, FL("Error: NOT same bssid as preauth BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 // In this case SME if indeed has triggered a
1963 // pre auth it will time out.
1964 return eSIR_FAILURE;
1965 }
1966
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001967 if (eANI_BOOLEAN_TRUE ==
1968 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed)
1969 {
1970 /*
1971 * This is likely a duplicate for the same pre-auth request.
1972 * PE/LIM already posted a response to SME. Hence, drop it.
1973 * TBD:
1974 * 1) How did we even receive multiple auth responses?
1975 * 2) Do we need to delete pre-auth session? Suppose we
1976 * previously received an auth resp with failure which
1977 * would not have created the session and forwarded to SME.
1978 * And, we subsequently received an auth resp with success
1979 * which would have created the session. This will now be
1980 * dropped without being forwarded to SME! However, it is
1981 * very unlikely to receive auth responses from the same
1982 * AP with different reason codes.
1983 * NOTE: return eSIR_SUCCESS so that the packet is dropped
1984 * as this was indeed a response from the BSSID we tried to
1985 * pre-auth.
1986 */
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001987 PELOGE(limLog(pMac,LOG1,"Auth rsp already posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001988 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001989 pMac->ft.ftPEContext.pftSessionEntry););
1990 return eSIR_SUCCESS;
1991 }
1992 else
1993 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001994 PELOGE(limLog(pMac,LOGW,"Auth rsp not yet posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001995 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001996 pMac->ft.ftPEContext.pftSessionEntry););
1997 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
1998 eANI_BOOLEAN_TRUE;
1999 }
2000
Jeff Johnson295189b2012-06-20 16:38:30 -07002001#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002002 limLog(pMac, LOG1, FL("Pre-Auth response received from neighbor"));
2003 limLog(pMac, LOG1, FL("Pre-Auth done state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002004#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302005
2006 limLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
2007 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
2008
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 // Stopping timer now, that we have our unicast from the AP
2010 // of our choice.
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302011 if (!pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
2012 limDeactivateAndChangeTimer(pMac, eLIM_FT_PREAUTH_RSP_TIMER);
2013
2014#ifdef WLAN_FEATURE_LFR_MBB
2015 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
2016 limDeactivateAndChangeTimer(pMac, eLIM_PREAUTH_MBB_RSP_TIMER);
2017#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002018
2019
2020 // Save off the auth resp.
2021 if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame) != eSIR_SUCCESS))
2022 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05302023 limLog(pMac, LOGE, FL("failed to convert Auth frame to struct"));
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302024
2025#ifdef WLAN_FEATURE_LFR_MBB
2026 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
2027 lim_handle_pre_auth_mbb_rsp(pMac, eSIR_FAILURE, psessionEntry);
2028 return eSIR_FAILURE;
2029 }
2030#endif
2031
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
2033 return eSIR_FAILURE;
2034 }
2035 pRxAuthFrameBody = &rxAuthFrame;
2036
2037#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002038 PELOGE(limLog(pMac, LOG1,
2039 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002040 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
2041 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
2042 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
2043#endif
2044
2045 switch (pRxAuthFrameBody->authTransactionSeqNumber)
2046 {
2047 case SIR_MAC_AUTH_FRAME_2:
2048 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
2049 {
2050#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08002051 PELOGE(limLog( pMac, LOGE, "Auth status code received is %d",
2052 (tANI_U32) pRxAuthFrameBody->authStatusCode););
Jeff Johnson295189b2012-06-20 16:38:30 -07002053#endif
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08002054 if (eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS == pRxAuthFrameBody->authStatusCode)
2055 ret_status = eSIR_LIM_MAX_STA_REACHED_ERROR;
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 }
2057 else
2058 {
2059 ret_status = eSIR_SUCCESS;
2060 }
2061 break;
2062
2063 default:
2064#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002065 PELOGE(limLog( pMac, LOGE, "Seq. no incorrect expected 2 received %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber);)
2067#endif
2068 break;
2069 }
2070
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302071#ifdef WLAN_FEATURE_LFR_MBB
2072 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
2073 lim_handle_pre_auth_mbb_rsp(pMac, ret_status, psessionEntry);
2074 return ret_status;
2075 }
2076#endif
2077
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 // Send the Auth response to SME
2079 limHandleFTPreAuthRsp(pMac, ret_status, pBody, frameLen, psessionEntry);
2080
2081 return ret_status;
2082}
2083
2084#endif /* WLAN_FEATURE_VOWIFI_11R */
2085