blob: 741a078b48f3a95ee4df26609be2435124f28c7d [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,
Yeshwanth Sriram Guntukab74fadf2019-08-21 21:09:57 +0530729 FL("Auth frame received in mlm state: %d(staId: %d, assocId: %d)"),
730 pStaDs->mlmStaContext.mlmState,
Abhishek Singh0496a522015-12-14 23:39:23 -0800731 pStaDs->staIndex, assocId);
Yeshwanth Sriram Guntukab74fadf2019-08-21 21:09:57 +0530732 if (pStaDs->mlmStaContext.mlmState ==
733 eLIM_MLM_LINK_ESTABLISHED_STATE) {
734 limLog(pMac, LOGE,
735 FL("STA is already connected but received auth frame"
736 "Send the Deauth and lim Delete Station Context"
737 "(staId: %d, assocId: %d) "),
738 pStaDs->staIndex, assocId);
739 limSendDeauthMgmtFrame(pMac,
740 eSIR_MAC_UNSPEC_FAILURE_REASON,
741 (tANI_U8 *) pHdr->sa,
742 psessionEntry, FALSE);
743 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
744 }
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530745 goto free;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800746 }
747 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700748
749 /// Check if there exists pre-auth context for this STA
750 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
751 if (pAuthNode)
752 {
753 /// Pre-auth context exists for the STA
gaurank kathpalia66414892018-03-21 20:24:39 +0530754 if (pAuthNode->seqNo != currSeqNo)
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 {
756 /**
757 * STA is initiating brand-new Authentication
758 * sequence after local Auth Response timeout.
759 * Or STA retrying to transmit First Auth frame due to packet drop OTA
760 * Delete Pre-auth node and fall through.
761 */
762 if(pAuthNode->fTimerStarted)
763 {
764 limDeactivateAndChangePerStaIdTimer(pMac,
765 eLIM_AUTH_RSP_TIMER,
766 pAuthNode->authNodeIdx);
767 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530768 PELOGE(limLog(pMac, LOGE, FL("STA is initiating brand-new "
769 "Authentication ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 limDeletePreAuthNode(pMac,
771 pHdr->sa);
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 /**
773 * SAP Mode:Disassociate the station and
774 * delete its entry if we have its entry
775 * already and received "auth" from the
776 * same station.
777 */
778
779 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
780 {
781 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
782
783 if (NULL == pStaDs)
784 continue;
785
786 if (pStaDs->valid)
787 {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530788 if (vos_mem_compare((tANI_U8 *) &pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 (tANI_U8 *) &(pHdr->sa), (tANI_U8) (sizeof(tSirMacAddr))) )
790 break;
791 }
Edhar, Mahesh Kumar29013e82014-02-05 10:38:08 +0530792
793 pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 }
795
Abhishek Singhe9417492014-09-25 15:55:36 +0530796 if (NULL != pStaDs
797#ifdef WLAN_FEATURE_11W
798 && !pStaDs->rmfEnabled
799#endif
800 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 {
Abhishek Singh0496a522015-12-14 23:39:23 -0800802 PELOGE(limLog(pMac, LOGE, FL("lim Delete Station "
803 "Context (staId: %d, assocId: %d) "),pStaDs->staIndex,
804 assocId);)
805 limSendDeauthMgmtFrame(pMac,
806 eSIR_MAC_UNSPEC_FAILURE_REASON, (tANI_U8 *) pAuthNode->peerMacAddr, psessionEntry, FALSE);
807 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530808 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 }
811 else
812 {
813 /*
814 * This can happen when first authentication frame is received
815 * but ACK lost at STA side, in this case 2nd auth frame is already
816 * in transmission queue
817 * */
Abhishek Singh208848c2013-12-18 19:02:52 +0530818 PELOGE(limLog(pMac, LOGE, FL("STA is initiating "
819 "Authentication after ACK lost..."));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530820 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 }
822 }
823 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
824 (tANI_U32 *) &maxNumPreAuth) != eSIR_SUCCESS)
825 {
826 /**
827 * Could not get MaxNumPreAuth
828 * from CFG. Log error.
829 */
830 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700831 FL("could not retrieve MaxNumPreAuth"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 }
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530833
834 if (pMac->lim.gLimNumPreAuthContexts == maxNumPreAuth &&
835 !limDeleteOpenAuthPreAuthNode(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530837 PELOGE(limLog(pMac, LOGE, FL("Max number of "
838 "preauth context reached"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 /**
840 * Maximum number of pre-auth contexts
841 * reached. Send Authentication frame
842 * with unspecified failure
843 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530844 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530846 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530848 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 eSIR_MAC_UNSPEC_FAILURE_STATUS;
850
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530851 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530853 LIM_NO_WEP_IN_FC,
854 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700855
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530856 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 }
858 /// No Pre-auth context exists for the STA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 if (limIsAuthAlgoSupported(
860 pMac,
861 (tAniAuthType)
862 pRxAuthFrameBody->authAlgoNumber, psessionEntry))
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 {
864 switch (pRxAuthFrameBody->authAlgoNumber)
865 {
866 case eSIR_OPEN_SYSTEM:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700867 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_OPEN_SYSTEM ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 /// Create entry for this STA in pre-auth list
869 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
870 if (pAuthNode == NULL)
871 {
872 // Log error
873 limLog(pMac, LOGW,
874 FL("Max pre-auth nodes reached "));
875 limPrintMacAddr(pMac, pHdr->sa, LOGW);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530876 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 }
878
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530879 limLog(pMac, LOG1,
880 FL("Alloc new data: peer "MAC_ADDRESS_STR),
881 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700882
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530883 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
884 pHdr->sa,
885 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700886
887 pAuthNode->mlmState =
888 eLIM_MLM_AUTHENTICATED_STATE;
889 pAuthNode->authType = (tAniAuthType)
890 pRxAuthFrameBody->authAlgoNumber;
891 pAuthNode->fSeen = 0;
892 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530893 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
894 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530895 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 limAddPreAuthNode(pMac, pAuthNode);
897
898 /**
899 * Send Authenticaton frame with Success
900 * status code.
901 */
902
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530903 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530905 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530907 authFrame->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530909 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530911 LIM_NO_WEP_IN_FC,
912 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700913
914 /// Send Auth indication to SME
915
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530916 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700917 (tANI_U8 *) pHdr->sa,
918 sizeof(tSirMacAddr));
919 mlmAuthInd.authType = (tAniAuthType)
920 pRxAuthFrameBody->authAlgoNumber;
921 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
922
923 limPostSmeMessage(pMac,
924 LIM_MLM_AUTH_IND,
925 (tANI_U32 *) &mlmAuthInd);
926 break;
927
928 case eSIR_SHARED_KEY:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700929 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_SHARED_KEY ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
931 {
932 val = psessionEntry->privacy;
933 }
934 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
936 &val) != eSIR_SUCCESS)
937 {
938 /**
939 * Could not get Privacy option
940 * from CFG. Log error.
941 */
942 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700943 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 }
945 cfgPrivacyOptImp = (tANI_U8)val;
946 if (!cfgPrivacyOptImp)
947 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530948 // Log error
949 PELOGE(limLog(pMac, LOGE,
950 FL("received Auth frame for unsupported auth algorithm %d "
951 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
952 MAC_ADDR_ARRAY(pHdr->sa));)
953
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 /**
955 * Authenticator does not have WEP
956 * implemented.
957 * Reject by sending Authentication frame
958 * with Auth algorithm not supported status
959 * code.
960 */
961
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530962 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530964 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530966 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
968
969 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530970 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530972 LIM_NO_WEP_IN_FC,
973 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700974
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530975 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700976 }
977 else
978 {
979 // Create entry for this STA
980 //in pre-auth list
981 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
982 if (pAuthNode == NULL)
983 {
984 // Log error
985 limLog(pMac, LOGW,
986 FL("Max pre-auth nodes reached "));
987 limPrintMacAddr(pMac, pHdr->sa, LOGW);
988
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530989 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 }
991
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530992 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
993 pHdr->sa,
994 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700995
996 pAuthNode->mlmState =
997 eLIM_MLM_WT_AUTH_FRAME3_STATE;
998 pAuthNode->authType =
999 (tAniAuthType)
1000 pRxAuthFrameBody->authAlgoNumber;
1001 pAuthNode->fSeen = 0;
1002 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301003 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1004 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301005 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 limAddPreAuthNode(pMac, pAuthNode);
1007
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301008 limLog(pMac, LOG1,
1009 FL("Alloc new data: id %d peer "MAC_ADDRESS_STR),
1010 pAuthNode->authNodeIdx, MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001011
1012 /// Create and activate Auth Response timer
1013 if (tx_timer_change_context(&pAuthNode->timer, pAuthNode->authNodeIdx) != TX_SUCCESS)
1014 {
1015 /// Could not start Auth response timer.
1016 // Log error
1017 limLog(pMac, LOGP,
1018 FL("Unable to chg context auth response timer for peer "));
1019 limPrintMacAddr(pMac, pHdr->sa, LOGP);
1020
1021 /**
1022 * Send Authenticaton frame with
1023 * unspecified failure status code.
1024 */
1025
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301026 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301028 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301030 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 eSIR_MAC_UNSPEC_FAILURE_STATUS;
1032
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301033 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301035 LIM_NO_WEP_IN_FC,
1036 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001037
1038 limDeletePreAuthNode(pMac, pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301039 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 }
1041
1042 limActivateAuthRspTimer(pMac, pAuthNode);
1043
1044 pAuthNode->fTimerStarted = 1;
1045
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301046 /*
1047 * get random bytes and use as challenge text
1048 */
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301049 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 -07001050 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301051 limLog(pMac, LOGE,FL("Challenge text "
1052 "preparation failed in limProcessAuthFrame"));
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301053 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 }
1055
1056 pChallenge = pAuthNode->challengeText;
1057
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301058 vos_mem_copy(pChallenge,
1059 (tANI_U8 *) challengeTextArray,
1060 sizeof(challengeTextArray));
Jeff Johnson295189b2012-06-20 16:38:30 -07001061
1062 /**
1063 * Sending Authenticaton frame with challenge.
1064 */
1065
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301066 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301068 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301070 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 eSIR_MAC_SUCCESS_STATUS;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301072 authFrame->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301073 authFrame->length = SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301074 vos_mem_copy(authFrame->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 pAuthNode->challengeText,
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301076 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -07001077
1078 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301079 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301081 LIM_NO_WEP_IN_FC,
1082 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 } // if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1084
1085 break;
1086
1087 default:
Abhishek Singh208848c2013-12-18 19:02:52 +05301088 // Log error
1089 PELOGE( limLog(pMac, LOGE,
1090 FL("received Auth frame for unsupported auth "
1091 "algorithm %d "MAC_ADDRESS_STR),
1092 pRxAuthFrameBody->authAlgoNumber,
1093 MAC_ADDR_ARRAY(pHdr->sa));)
1094
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 /**
1096 * Responding party does not support the
1097 * authentication algorithm requested by
1098 * sending party.
1099 * Reject by sending Authentication frame
1100 * with auth algorithm not supported status code
1101 */
1102
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301103 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301105 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001106 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301107 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1109
1110 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301111 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301113 LIM_NO_WEP_IN_FC,
1114 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001115
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301116 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001117 } // end switch(pRxAuthFrameBody->authAlgoNumber)
1118 } // if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1119 else
1120 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301121 // Log error
1122 PELOGE(limLog(pMac, LOGE,
1123 FL("received Authentication frame for unsupported auth "
1124 "algorithm %d "MAC_ADDRESS_STR),
1125 pRxAuthFrameBody->authAlgoNumber,
1126 MAC_ADDR_ARRAY(pHdr->sa));)
1127
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 /**
1129 * Responding party does not support the
1130 * authentication algorithm requested by sending party.
1131 * Reject Authentication with StatusCode=13.
1132 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301133 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301135 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301137 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1139
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301140 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001141 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301142 LIM_NO_WEP_IN_FC,
1143 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001144
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301145 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 } //end if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1147 break;
1148
1149 case SIR_MAC_AUTH_FRAME_2:
1150 // AuthFrame 2
1151
1152 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME2_STATE)
1153 {
1154 /**
1155 * Received Authentication frame2 in an unexpected state.
1156 * Log error and ignore the frame.
1157 */
1158
1159 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301160 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001161 FL("received Auth frame2 from peer in state %d, addr "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301162 psessionEntry->limMlmState);
1163 limPrintMacAddr(pMac, pHdr->sa, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001164
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301165 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 }
1167
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301168 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1169 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1170 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001171 {
1172 /**
1173 * Received Authentication frame from an entity
1174 * other than one request was initiated.
1175 * Wait until Authentication Failure Timeout.
1176 */
1177
1178 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001179 PELOGW(limLog(pMac, LOGW,
Abhishek Singh208848c2013-12-18 19:02:52 +05301180 FL("received Auth frame2 from unexpected peer "
1181 MAC_ADDRESS_STR),
Mohit Khanna23863762012-09-11 17:40:09 -07001182 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001183
1184 break;
1185 }
1186
1187 if (pRxAuthFrameBody->authStatusCode ==
1188 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS)
1189 {
1190 /**
1191 * Interoperability workaround: Linksys WAP4400N is returning
1192 * wrong authType in OpenAuth response in case of
1193 * SharedKey AP configuration. Pretend we don't see that,
1194 * so upper layer can fallback to SharedKey authType,
1195 * and successfully connect to the AP.
1196 */
1197 if (pRxAuthFrameBody->authAlgoNumber !=
1198 pMac->lim.gpLimMlmAuthReq->authType)
1199 {
1200 pRxAuthFrameBody->authAlgoNumber =
1201 pMac->lim.gpLimMlmAuthReq->authType;
1202 }
1203 }
1204
1205 if (pRxAuthFrameBody->authAlgoNumber !=
1206 pMac->lim.gpLimMlmAuthReq->authType)
1207 {
1208 /**
1209 * Received Authentication frame with an auth
1210 * algorithm other than one requested.
1211 * Wait until Authentication Failure Timeout.
1212 */
1213
1214 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001215 PELOGW(limLog(pMac, LOGW,
1216 FL("received Auth frame2 for unexpected auth algo number %d "
Abhishek Singh208848c2013-12-18 19:02:52 +05301217 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001218 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001219
1220 break;
1221 }
1222
1223 if (pRxAuthFrameBody->authStatusCode ==
1224 eSIR_MAC_SUCCESS_STATUS)
1225 {
1226 if (pRxAuthFrameBody->authAlgoNumber ==
1227 eSIR_OPEN_SYSTEM)
1228 {
1229 psessionEntry->limCurrentAuthType = eSIR_OPEN_SYSTEM;
1230
1231 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1232
1233 if (pAuthNode == NULL)
1234 {
1235 // Log error
1236 limLog(pMac, LOGW,
1237 FL("Max pre-auth nodes reached "));
1238 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1239
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301240 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 }
1242
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301243 limLog(pMac, LOG1,
1244 FL("Alloc new data: peer "MAC_ADDRESS_STR),
1245 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001246
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301247 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1249 sizeof(tSirMacAddr));
1250 pAuthNode->fTimerStarted = 0;
1251 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301252 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1253 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301254 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 limAddPreAuthNode(pMac, pAuthNode);
1256
1257 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1258 pRxAuthFrameBody->authStatusCode,psessionEntry);
1259 } // if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1260 else
1261 {
1262 // Shared key authentication
1263
Jeff Johnson295189b2012-06-20 16:38:30 -07001264 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1265 {
1266 val = psessionEntry->privacy;
1267 }
1268 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1270 &val) != eSIR_SUCCESS)
1271 {
1272 /**
1273 * Could not get Privacy option
1274 * from CFG. Log error.
1275 */
1276 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001277 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 }
1279 cfgPrivacyOptImp = (tANI_U8)val;
1280 if (!cfgPrivacyOptImp)
1281 {
1282 /**
1283 * Requesting STA does not have WEP implemented.
1284 * Reject with unsupported authentication algorithm
1285 * Status code and wait until auth failure timeout
1286 */
1287
1288 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001289 PELOGE( limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301290 FL("received Auth frame from peer for "
1291 "unsupported auth algo %d "
1292 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001293 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001294
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301295 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301297 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301299 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1301
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301302 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301304 LIM_NO_WEP_IN_FC,
1305 psessionEntry, eSIR_FALSE);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301306 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 }
1308 else
1309 {
1310
1311 if (pRxAuthFrameBody->type !=
1312 SIR_MAC_CHALLENGE_TEXT_EID)
1313 {
1314 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001315 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301316 FL("received Auth frame with invalid "
1317 "challenge text IE"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001318
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301319 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 }
1321
1322 /**
1323 * Check if there exists a key mappping key
1324 * for the STA that sent Authentication frame
1325 */
1326 pKeyMapEntry = limLookUpKeyMappings(
1327 pHdr->sa);
1328
1329 if (pKeyMapEntry)
1330 {
1331 if (pKeyMapEntry->key == NULL)
1332 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301333 // Log error
1334 PELOGE(limLog(pMac, LOGE,
1335 FL("received Auth frame from peer when "
1336 "key mapping key is NULL"MAC_ADDRESS_STR),
1337 MAC_ADDR_ARRAY(pHdr->sa));)
1338
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 /**
1340 * Key Mapping entry has null key.
1341 * Send Auth frame with
1342 * challenge failure status code
1343 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301344 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301346 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301348 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1350
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301351 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301353 LIM_NO_WEP_IN_FC,
1354 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001355
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 limRestoreFromAuthState(pMac, eSIR_SME_NO_KEY_MAPPING_KEY_FOR_PEER,
1357 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1358
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301359 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 } // if (pKeyMapEntry->key == NULL)
1361 else
1362 {
1363 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1364 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1365 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1366 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1367 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1368 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301369 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301370 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301372 pRxAuthFrameBody->length);
1373
1374 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1375 LIM_ENCR_AUTH_INFO_LEN);
1376 if (!encrAuthFrame) {
1377 limLog(pMac, LOGE, FL("failed to allocate memory"));
1378 goto free;
1379 }
1380 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1381 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001382
1383 limEncryptAuthFrame(pMac, 0,
1384 pKeyMapEntry->key,
1385 plainBody,
1386 encrAuthFrame,key_length);
1387
1388 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001389 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001390
1391 limSendAuthMgmtFrame(pMac,
1392 (tpSirMacAuthFrameBody) encrAuthFrame,
1393 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301394 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301395 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001396
1397 break;
1398 } // end if (pKeyMapEntry->key == NULL)
1399 } // if (pKeyMapEntry)
1400 else
1401 {
1402 if (wlan_cfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID,
1403 &val) != eSIR_SUCCESS)
1404 {
1405 /**
1406 * Could not get Default keyId
1407 * from CFG. Log error.
1408 */
1409 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001410 FL("could not retrieve Default keyId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 }
1412 keyId = (tANI_U8)val;
1413
1414 val = SIR_MAC_KEY_LENGTH;
1415
Jeff Johnson295189b2012-06-20 16:38:30 -07001416 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1417 {
1418 tpSirKeys pKey;
1419 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301420 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 }
1422 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
1424 defaultKey,
1425 &val)
1426 != eSIR_SUCCESS)
1427 {
1428 /// Could not get Default key from CFG.
1429 //Log error.
1430 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001431 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001432
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301433 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001434 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301435 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301437 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001438 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1439
1440 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301441 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301443 LIM_NO_WEP_IN_FC,
1444 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001445
1446 limRestoreFromAuthState(pMac, eSIR_SME_INVALID_WEP_DEFAULT_KEY,
1447 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1448
1449 break;
1450 }
1451 key_length=val;
1452 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1453 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1454 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1455 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1456 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1457 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301458 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301459 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301461 pRxAuthFrameBody->length);
1462
1463 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1464 LIM_ENCR_AUTH_INFO_LEN);
1465 if (!encrAuthFrame) {
1466 limLog(pMac, LOGE, FL("failed to allocate memory"));
1467 goto free;
1468 }
1469 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1470 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001471
1472 limEncryptAuthFrame(pMac, keyId,
1473 defaultKey,
1474 plainBody,
1475 encrAuthFrame,key_length);
1476
1477 psessionEntry->limMlmState =
1478 eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001479 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001480
1481 limSendAuthMgmtFrame(pMac,
1482 (tpSirMacAuthFrameBody) encrAuthFrame,
1483 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301484 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301485 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001486
1487 break;
1488 } // end if (pKeyMapEntry)
1489 } // end if (!wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1490 } // end if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1491 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1492 else
1493 {
1494 /**
1495 * Authentication failure.
1496 * Return Auth confirm with received failure code to SME
1497 */
1498
1499 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001500 PELOGE(limLog(pMac, LOGE,
1501 FL("received Auth frame from peer with failure code %d "
1502 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1503 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001504
1505 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1506 pRxAuthFrameBody->authStatusCode,psessionEntry);
1507 } // end if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1508
1509 break;
1510
1511 case SIR_MAC_AUTH_FRAME_3:
1512 // AuthFrame 3
1513
1514 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1515 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301516 // Log error
1517 PELOGE(limLog(pMac, LOGE,
1518 FL("received Auth frame3 from peer with auth algo "
1519 "number %d "MAC_ADDRESS_STR),
1520 pRxAuthFrameBody->authAlgoNumber,
1521 MAC_ADDR_ARRAY(pHdr->sa));)
1522
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 /**
1524 * Received Authentication frame3 with algorithm other than
1525 * Shared Key authentication type. Reject with Auth frame4
1526 * with 'out of sequence' status code.
1527 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301528 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1529 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301531 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1533
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301534 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301536 LIM_NO_WEP_IN_FC,
1537 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001538
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301539 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 }
1541
1542 if (psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE ||
1543 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
1544 {
1545 /**
1546 * Check if wep bit was set in FC. If not set,
1547 * reject with Authentication frame4 with
1548 * 'challenge failure' status code.
1549 */
1550 if (!pHdr->fc.wep)
1551 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301552 // Log error
1553 PELOGE(limLog(pMac, LOGE,
1554 FL("received Auth frame3 from peer with no WEP bit "
1555 "set "MAC_ADDRESS_STR),
1556 MAC_ADDR_ARRAY(pHdr->sa));)
1557
Jeff Johnson295189b2012-06-20 16:38:30 -07001558 /// WEP bit is not set in FC of Auth Frame3
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301559 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1560 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001561 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301562 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1564
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301565 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301567 LIM_NO_WEP_IN_FC,
1568 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001569
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301570 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 }
1572
1573 pAuthNode = limSearchPreAuthList(pMac,
1574 pHdr->sa);
1575 if (pAuthNode == NULL)
1576 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301577 // Log error
1578 PELOGE(limLog(pMac, LOGW,
1579 FL("received AuthFrame3 from peer that has no "
1580 "preauth context "MAC_ADDRESS_STR),
1581 MAC_ADDR_ARRAY(pHdr->sa));)
1582
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 /**
1584 * No 'pre-auth' context exists for
1585 * this STA that sent an Authentication
1586 * frame3.
1587 * Send Auth frame4 with 'out of sequence'
1588 * status code.
1589 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301590 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1591 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301593 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1595
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301596 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301598 LIM_NO_WEP_IN_FC,
1599 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001600
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301601 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 }
1603
1604 if (pAuthNode->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)
1605 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301606 // Log error
1607 limLog(pMac, LOGW,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301608 FL("auth response timer timedout for peer "
1609 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 /**
1611 * Received Auth Frame3 after Auth Response timeout.
1612 * Reject by sending Auth Frame4 with
1613 * Auth respone timeout Status Code.
1614 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301615 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1616 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301618 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001619 eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS;
1620
1621 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301622 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301624 LIM_NO_WEP_IN_FC,
1625 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001626
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 /// Delete pre-auth context of STA
1628 limDeletePreAuthNode(pMac,
1629 pHdr->sa);
1630
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301631 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 } // end switch (pAuthNode->mlmState)
1633
1634 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1635 {
1636 /**
1637 * Received Authenetication Frame 3 with status code
1638 * other than success. Wait until Auth response timeout
1639 * to delete STA context.
1640 */
1641
1642 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001643 PELOGE(limLog(pMac, LOGE,
1644 FL("received Auth frame3 from peer with status code %d "
1645 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1646 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001647
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301648 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 }
1650
1651 /**
1652 * Check if received challenge text is same as one sent in
1653 * Authentication frame3
1654 */
1655
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301656 if (vos_mem_compare(pRxAuthFrameBody->challengeText,
1657 pAuthNode->challengeText,
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301658 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH))
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 {
1660 /// Challenge match. STA is autheticated !
1661
1662 /// Delete Authentication response timer if running
1663 limDeactivateAndChangePerStaIdTimer(pMac,
1664 eLIM_AUTH_RSP_TIMER,
1665 pAuthNode->authNodeIdx);
1666
1667 pAuthNode->fTimerStarted = 0;
1668 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1669
1670 /**
1671 * Send Authentication Frame4 with 'success' Status Code.
1672 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301673 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1674 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001675 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301676 authFrame->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001677
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301678 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301680 LIM_NO_WEP_IN_FC,
1681 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001682
1683 /// Send Auth indication to SME
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301684 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 (tANI_U8 *) pHdr->sa,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301686 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001687 mlmAuthInd.authType = (tAniAuthType)
1688 pRxAuthFrameBody->authAlgoNumber;
1689 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
1690
1691 limPostSmeMessage(pMac,
1692 LIM_MLM_AUTH_IND,
1693 (tANI_U32 *) &mlmAuthInd);
1694
1695 break;
1696 }
1697 else
1698 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301699 // Log error
1700 PELOGE( limLog(pMac, LOGW,
1701 FL("Challenge failure for peer "
1702 MAC_ADDRESS_STR),
1703 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 /**
1705 * Challenge Failure.
1706 * Send Authentication frame4 with 'challenge failure'
1707 * status code and wait until Auth response timeout to
1708 * delete STA context.
1709 */
1710
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301711 authFrame->authAlgoNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001712 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301713 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001714 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301715 authFrame->authStatusCode =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001716 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001717
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301718 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301720 LIM_NO_WEP_IN_FC,
1721 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001722
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301723 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 }
1725 } // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE || ...
1726
1727 break;
1728
1729 case SIR_MAC_AUTH_FRAME_4:
1730 // AuthFrame 4
1731 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE)
1732 {
1733 /**
1734 * Received Authentication frame4 in an unexpected state.
1735 * Log error and ignore the frame.
1736 */
1737
1738 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301739 limLog(pMac, LOG1,
Abhishek Singh208848c2013-12-18 19:02:52 +05301740 FL("received unexpected Auth frame4 from peer in state "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301741 "%d, addr "MAC_ADDRESS_STR), psessionEntry->limMlmState,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301742 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001743
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301744 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001745 }
1746
1747 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1748 {
1749 /**
1750 * Received Authentication frame4 with algorithm other than
1751 * Shared Key authentication type.
1752 * Wait until Auth failure timeout to report authentication
1753 * failure to SME.
1754 */
1755
1756 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001757 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301758 FL("received Auth frame4 from peer with invalid auth "
1759 "algo %d "MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001760 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001761
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301762 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 }
1764
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301765 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1766 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1767 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 {
1769 /**
1770 * Received Authentication frame from an entity
1771 * other than one to which request was initiated.
1772 * Wait until Authentication Failure Timeout.
1773 */
1774
1775 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001776 PELOGE(limLog(pMac, LOGW,
1777 FL("received Auth frame4 from unexpected peer "
1778 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001779
1780 break;
1781 }
1782
1783 if (pRxAuthFrameBody->authAlgoNumber !=
1784 pMac->lim.gpLimMlmAuthReq->authType)
1785 {
1786 /**
1787 * Received Authentication frame with an auth algorithm
1788 * other than one requested.
1789 * Wait until Authentication Failure Timeout.
1790 */
1791
Mohit Khanna23863762012-09-11 17:40:09 -07001792 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301793 FL("received Authentication frame from peer with "
1794 "invalid auth seq number %d "
1795 MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001796 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001797
1798 break;
1799 }
1800
1801 if (pRxAuthFrameBody->authStatusCode ==
1802 eSIR_MAC_SUCCESS_STATUS)
1803 {
1804 /**
1805 * Authentication Success !
1806 * Inform SME of same.
1807 */
1808 psessionEntry->limCurrentAuthType = eSIR_SHARED_KEY;
1809
1810 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1811 if (pAuthNode == NULL)
1812 {
1813 // Log error
1814 limLog(pMac, LOGW,
1815 FL("Max pre-auth nodes reached "));
1816 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1817
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301818 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301820 limLog(pMac, LOG1,
1821 FL("Alloc new data: peer " MAC_ADDRESS_STR),
1822 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001823
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301824 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1826 sizeof(tSirMacAddr));
1827 pAuthNode->fTimerStarted = 0;
1828 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301829 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1830 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301831 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 limAddPreAuthNode(pMac, pAuthNode);
1833
1834 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1835 pRxAuthFrameBody->authStatusCode,psessionEntry);
1836
1837 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1838 else
1839 {
1840 /**
1841 * Authentication failure.
1842 * Return Auth confirm with received failure code to SME
1843 */
1844
1845 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001846 PELOGE(limLog(pMac, LOGE, FL("Authentication failure from peer "
1847 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001848
1849 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1850 pRxAuthFrameBody->authStatusCode,psessionEntry);
1851 } // end if (pRxAuthFrameBody->Status == 0)
1852
1853 break;
1854
1855 default:
1856 /// Invalid Authentication Frame received. Ignore it.
1857
1858 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001859 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301860 FL("received Auth frame from peer with invalid auth seq "
1861 "number %d " MAC_ADDRESS_STR),
1862 pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001863 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001864
1865 break;
1866 } // end switch (pRxAuthFrameBody->authTransactionSeqNumber)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301867
1868free:
1869 if (authFrame)
1870 vos_mem_free(authFrame);
1871 if (rxAuthFrame)
1872 vos_mem_free(rxAuthFrame);
1873 if (encrAuthFrame)
1874 vos_mem_free(encrAuthFrame);
1875 if (plainBody)
1876 vos_mem_free(plainBody);
1877 if (challengeTextArray)
1878 vos_mem_free(challengeTextArray);
1879
Jeff Johnson295189b2012-06-20 16:38:30 -07001880} /*** end limProcessAuthFrame() ***/
1881
1882
1883
1884
1885
1886#ifdef WLAN_FEATURE_VOWIFI_11R
1887
1888/*----------------------------------------------------------------------
1889 *
1890 * Pass the received Auth frame. This is possibly the pre-auth from the
1891 * neighbor AP, in the same mobility domain.
1892 * This will be used in case of 11r FT.
1893 *
1894 * !!!! This is going to be renoved for the next checkin. We will be creating
1895 * the session before sending out the Auth. Thus when auth response
1896 * is received we will have a session in progress. !!!!!
1897 *----------------------------------------------------------------------
1898 */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001899tSirRetStatus limProcessAuthFrameNoSession(tpAniSirGlobal pMac, tANI_U8 *pBd, void *body)
Jeff Johnson295189b2012-06-20 16:38:30 -07001900{
1901 tpSirMacMgmtHdr pHdr;
1902 tpPESession psessionEntry = NULL;
1903 tANI_U8 *pBody;
1904 tANI_U16 frameLen;
1905 tSirMacAuthFrameBody rxAuthFrame;
1906 tSirMacAuthFrameBody *pRxAuthFrameBody = NULL;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001907 tSirRetStatus ret_status = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001908
1909 pHdr = WDA_GET_RX_MAC_HEADER(pBd);
1910 pBody = WDA_GET_RX_MPDU_DATA(pBd);
1911 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd);
1912
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05301913 /*
1914 * since, roaming is not supported in sta + mon scc, ignore
1915 * pre-auth when capture on monitor mode is started
1916 */
1917 if (vos_check_monitor_state())
1918 {
1919 limLog(pMac, LOG1, FL("Ignore pre-auth frame in monitor mode"));
1920 return eSIR_FAILURE;
1921 }
1922
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301923 limLog(pMac, LOG1, FL("Auth Frame Received: BSSID " MAC_ADDRESS_STR
1924 " (RSSI %d)"),MAC_ADDR_ARRAY(pHdr->bssId),
1925 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 // Check for the operating channel and see what needs to be done next.
1927 psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
1928 if (psessionEntry == NULL)
1929 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301930 limLog(pMac, LOGE, FL("Error: Unable to find session id while in "
1931 "pre-auth phase for FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001932 return eSIR_FAILURE;
1933 }
1934
1935 if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL)
1936 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301937 limLog(pMac, LOGE, FL("Error: No FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001938 // No FT in progress.
1939 return eSIR_FAILURE;
1940 }
1941
1942 if (frameLen == 0)
1943 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301944 limLog(pMac, LOGE, FL("Error: Frame len = 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 return eSIR_FAILURE;
1946 }
1947#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001948 limPrintMacAddr(pMac, pHdr->bssId, LOG2);
1949 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOG2);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001950 limLog(pMac,LOG2,FL("seqControl 0x%X"),
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001951 ((pHdr->seqControl.seqNumHi << 8) |
1952 (pHdr->seqControl.seqNumLo << 4) |
1953 (pHdr->seqControl.fragNum)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001954#endif
1955
1956 // Check that its the same bssId we have for preAuth
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301957 if (!vos_mem_compare(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1958 pHdr->bssId, sizeof( tSirMacAddr )))
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301960 limLog(pMac, LOGE, FL("Error: NOT same bssid as preauth BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 // In this case SME if indeed has triggered a
1962 // pre auth it will time out.
1963 return eSIR_FAILURE;
1964 }
1965
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001966 if (eANI_BOOLEAN_TRUE ==
1967 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed)
1968 {
1969 /*
1970 * This is likely a duplicate for the same pre-auth request.
1971 * PE/LIM already posted a response to SME. Hence, drop it.
1972 * TBD:
1973 * 1) How did we even receive multiple auth responses?
1974 * 2) Do we need to delete pre-auth session? Suppose we
1975 * previously received an auth resp with failure which
1976 * would not have created the session and forwarded to SME.
1977 * And, we subsequently received an auth resp with success
1978 * which would have created the session. This will now be
1979 * dropped without being forwarded to SME! However, it is
1980 * very unlikely to receive auth responses from the same
1981 * AP with different reason codes.
1982 * NOTE: return eSIR_SUCCESS so that the packet is dropped
1983 * as this was indeed a response from the BSSID we tried to
1984 * pre-auth.
1985 */
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001986 PELOGE(limLog(pMac,LOG1,"Auth rsp already posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001987 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001988 pMac->ft.ftPEContext.pftSessionEntry););
1989 return eSIR_SUCCESS;
1990 }
1991 else
1992 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001993 PELOGE(limLog(pMac,LOGW,"Auth rsp not yet posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001994 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001995 pMac->ft.ftPEContext.pftSessionEntry););
1996 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
1997 eANI_BOOLEAN_TRUE;
1998 }
1999
Jeff Johnson295189b2012-06-20 16:38:30 -07002000#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002001 limLog(pMac, LOG1, FL("Pre-Auth response received from neighbor"));
2002 limLog(pMac, LOG1, FL("Pre-Auth done state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002003#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302004
2005 limLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
2006 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
2007
Jeff Johnson295189b2012-06-20 16:38:30 -07002008 // Stopping timer now, that we have our unicast from the AP
2009 // of our choice.
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302010 if (!pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
2011 limDeactivateAndChangeTimer(pMac, eLIM_FT_PREAUTH_RSP_TIMER);
2012
2013#ifdef WLAN_FEATURE_LFR_MBB
2014 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
2015 limDeactivateAndChangeTimer(pMac, eLIM_PREAUTH_MBB_RSP_TIMER);
2016#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002017
2018
2019 // Save off the auth resp.
2020 if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame) != eSIR_SUCCESS))
2021 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05302022 limLog(pMac, LOGE, FL("failed to convert Auth frame to struct"));
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302023
2024#ifdef WLAN_FEATURE_LFR_MBB
2025 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
2026 lim_handle_pre_auth_mbb_rsp(pMac, eSIR_FAILURE, psessionEntry);
2027 return eSIR_FAILURE;
2028 }
2029#endif
2030
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
2032 return eSIR_FAILURE;
2033 }
2034 pRxAuthFrameBody = &rxAuthFrame;
2035
2036#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002037 PELOGE(limLog(pMac, LOG1,
2038 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
2040 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
2041 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
2042#endif
2043
2044 switch (pRxAuthFrameBody->authTransactionSeqNumber)
2045 {
2046 case SIR_MAC_AUTH_FRAME_2:
2047 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
2048 {
2049#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08002050 PELOGE(limLog( pMac, LOGE, "Auth status code received is %d",
2051 (tANI_U32) pRxAuthFrameBody->authStatusCode););
Jeff Johnson295189b2012-06-20 16:38:30 -07002052#endif
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08002053 if (eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS == pRxAuthFrameBody->authStatusCode)
2054 ret_status = eSIR_LIM_MAX_STA_REACHED_ERROR;
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 }
2056 else
2057 {
2058 ret_status = eSIR_SUCCESS;
2059 }
2060 break;
2061
2062 default:
2063#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002064 PELOGE(limLog( pMac, LOGE, "Seq. no incorrect expected 2 received %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber);)
2066#endif
2067 break;
2068 }
2069
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302070#ifdef WLAN_FEATURE_LFR_MBB
2071 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
2072 lim_handle_pre_auth_mbb_rsp(pMac, ret_status, psessionEntry);
2073 return ret_status;
2074 }
2075#endif
2076
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 // Send the Auth response to SME
2078 limHandleFTPreAuthRsp(pMac, ret_status, pBody, frameLen, psessionEntry);
2079
2080 return ret_status;
2081}
2082
2083#endif /* WLAN_FEATURE_VOWIFI_11R */
2084