blob: 0abfed6285c3b863209b571401bca53eca6eb81b [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 {
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05301208 /*
1209 * Auth algo is open in rx auth frame when auth type is SAE and
1210 * PMK is cached as driver sent auth algo as open in tx frame
1211 * as well.
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 */
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05301213 if ((pMac->lim.gpLimMlmAuthReq->authType ==
1214 eSIR_AUTH_TYPE_SAE) && psessionEntry->sae_pmk_cached) {
1215 limLog(pMac, LOGW,
1216 FL("rx Auth frame2 auth algo %d in SAE PMK case"),
1217 pRxAuthFrameBody->authAlgoNumber);
1218 } else {
1219 /**
1220 * Received Authentication frame with an auth
1221 * algorithm other than one requested.
1222 * Wait until Authentication Failure Timeout.
1223 */
1224 // Log error
1225 PELOGW(limLog(pMac, LOGW,
1226 FL("received Auth frame2 for unexpected auth algo num %d "
1227 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
1228 MAC_ADDR_ARRAY(pHdr->sa));)
Abhinav Kumar0ee145b2019-09-12 20:13:58 +05301229 break;
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05301230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 }
1232
1233 if (pRxAuthFrameBody->authStatusCode ==
1234 eSIR_MAC_SUCCESS_STATUS)
1235 {
1236 if (pRxAuthFrameBody->authAlgoNumber ==
1237 eSIR_OPEN_SYSTEM)
1238 {
1239 psessionEntry->limCurrentAuthType = eSIR_OPEN_SYSTEM;
1240
1241 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1242
1243 if (pAuthNode == NULL)
1244 {
1245 // Log error
1246 limLog(pMac, LOGW,
1247 FL("Max pre-auth nodes reached "));
1248 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1249
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301250 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001251 }
1252
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301253 limLog(pMac, LOG1,
1254 FL("Alloc new data: peer "MAC_ADDRESS_STR),
1255 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001256
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301257 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1259 sizeof(tSirMacAddr));
1260 pAuthNode->fTimerStarted = 0;
1261 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301262 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1263 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301264 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 limAddPreAuthNode(pMac, pAuthNode);
1266
1267 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1268 pRxAuthFrameBody->authStatusCode,psessionEntry);
1269 } // if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1270 else
1271 {
1272 // Shared key authentication
1273
Jeff Johnson295189b2012-06-20 16:38:30 -07001274 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1275 {
1276 val = psessionEntry->privacy;
1277 }
1278 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1280 &val) != eSIR_SUCCESS)
1281 {
1282 /**
1283 * Could not get Privacy option
1284 * from CFG. Log error.
1285 */
1286 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001287 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 }
1289 cfgPrivacyOptImp = (tANI_U8)val;
1290 if (!cfgPrivacyOptImp)
1291 {
1292 /**
1293 * Requesting STA does not have WEP implemented.
1294 * Reject with unsupported authentication algorithm
1295 * Status code and wait until auth failure timeout
1296 */
1297
1298 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001299 PELOGE( limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301300 FL("received Auth frame from peer for "
1301 "unsupported auth algo %d "
1302 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001303 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001304
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301305 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001306 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301307 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301309 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1311
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301312 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301314 LIM_NO_WEP_IN_FC,
1315 psessionEntry, eSIR_FALSE);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301316 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 }
1318 else
1319 {
1320
1321 if (pRxAuthFrameBody->type !=
1322 SIR_MAC_CHALLENGE_TEXT_EID)
1323 {
1324 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001325 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301326 FL("received Auth frame with invalid "
1327 "challenge text IE"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001328
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301329 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 }
1331
1332 /**
1333 * Check if there exists a key mappping key
1334 * for the STA that sent Authentication frame
1335 */
1336 pKeyMapEntry = limLookUpKeyMappings(
1337 pHdr->sa);
1338
1339 if (pKeyMapEntry)
1340 {
1341 if (pKeyMapEntry->key == NULL)
1342 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301343 // Log error
1344 PELOGE(limLog(pMac, LOGE,
1345 FL("received Auth frame from peer when "
1346 "key mapping key is NULL"MAC_ADDRESS_STR),
1347 MAC_ADDR_ARRAY(pHdr->sa));)
1348
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 /**
1350 * Key Mapping entry has null key.
1351 * Send Auth frame with
1352 * challenge failure status code
1353 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301354 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301356 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301358 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1360
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301361 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001362 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301363 LIM_NO_WEP_IN_FC,
1364 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 limRestoreFromAuthState(pMac, eSIR_SME_NO_KEY_MAPPING_KEY_FOR_PEER,
1367 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1368
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301369 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 } // if (pKeyMapEntry->key == NULL)
1371 else
1372 {
1373 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1374 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1375 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1376 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1377 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1378 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301379 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301380 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301382 pRxAuthFrameBody->length);
1383
1384 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1385 LIM_ENCR_AUTH_INFO_LEN);
1386 if (!encrAuthFrame) {
1387 limLog(pMac, LOGE, FL("failed to allocate memory"));
1388 goto free;
1389 }
1390 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1391 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001392
1393 limEncryptAuthFrame(pMac, 0,
1394 pKeyMapEntry->key,
1395 plainBody,
1396 encrAuthFrame,key_length);
1397
1398 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001399 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001400
1401 limSendAuthMgmtFrame(pMac,
1402 (tpSirMacAuthFrameBody) encrAuthFrame,
1403 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301404 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301405 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001406
1407 break;
1408 } // end if (pKeyMapEntry->key == NULL)
1409 } // if (pKeyMapEntry)
1410 else
1411 {
1412 if (wlan_cfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID,
1413 &val) != eSIR_SUCCESS)
1414 {
1415 /**
1416 * Could not get Default keyId
1417 * from CFG. Log error.
1418 */
1419 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001420 FL("could not retrieve Default keyId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 }
1422 keyId = (tANI_U8)val;
1423
1424 val = SIR_MAC_KEY_LENGTH;
1425
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1427 {
1428 tpSirKeys pKey;
1429 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301430 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 }
1432 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
1434 defaultKey,
1435 &val)
1436 != eSIR_SUCCESS)
1437 {
1438 /// Could not get Default key from CFG.
1439 //Log error.
1440 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001441 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001442
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301443 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301445 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301447 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1449
1450 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301451 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301453 LIM_NO_WEP_IN_FC,
1454 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001455
1456 limRestoreFromAuthState(pMac, eSIR_SME_INVALID_WEP_DEFAULT_KEY,
1457 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1458
1459 break;
1460 }
1461 key_length=val;
1462 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1463 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1464 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1465 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1466 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1467 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301468 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301469 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301471 pRxAuthFrameBody->length);
1472
1473 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1474 LIM_ENCR_AUTH_INFO_LEN);
1475 if (!encrAuthFrame) {
1476 limLog(pMac, LOGE, FL("failed to allocate memory"));
1477 goto free;
1478 }
1479 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1480 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001481
1482 limEncryptAuthFrame(pMac, keyId,
1483 defaultKey,
1484 plainBody,
1485 encrAuthFrame,key_length);
1486
1487 psessionEntry->limMlmState =
1488 eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001489 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001490
1491 limSendAuthMgmtFrame(pMac,
1492 (tpSirMacAuthFrameBody) encrAuthFrame,
1493 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301494 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301495 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001496
1497 break;
1498 } // end if (pKeyMapEntry)
1499 } // end if (!wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1500 } // end if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1501 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1502 else
1503 {
1504 /**
1505 * Authentication failure.
1506 * Return Auth confirm with received failure code to SME
1507 */
1508
1509 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001510 PELOGE(limLog(pMac, LOGE,
1511 FL("received Auth frame from peer with failure code %d "
1512 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1513 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001514
1515 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1516 pRxAuthFrameBody->authStatusCode,psessionEntry);
1517 } // end if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1518
1519 break;
1520
1521 case SIR_MAC_AUTH_FRAME_3:
1522 // AuthFrame 3
1523
1524 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1525 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301526 // Log error
1527 PELOGE(limLog(pMac, LOGE,
1528 FL("received Auth frame3 from peer with auth algo "
1529 "number %d "MAC_ADDRESS_STR),
1530 pRxAuthFrameBody->authAlgoNumber,
1531 MAC_ADDR_ARRAY(pHdr->sa));)
1532
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 /**
1534 * Received Authentication frame3 with algorithm other than
1535 * Shared Key authentication type. Reject with Auth frame4
1536 * with 'out of sequence' status code.
1537 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301538 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1539 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301541 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1543
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301544 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301546 LIM_NO_WEP_IN_FC,
1547 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001548
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301549 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 }
1551
1552 if (psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE ||
1553 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
1554 {
1555 /**
1556 * Check if wep bit was set in FC. If not set,
1557 * reject with Authentication frame4 with
1558 * 'challenge failure' status code.
1559 */
1560 if (!pHdr->fc.wep)
1561 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301562 // Log error
1563 PELOGE(limLog(pMac, LOGE,
1564 FL("received Auth frame3 from peer with no WEP bit "
1565 "set "MAC_ADDRESS_STR),
1566 MAC_ADDR_ARRAY(pHdr->sa));)
1567
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 /// WEP bit is not set in FC of Auth Frame3
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301569 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1570 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301572 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001573 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1574
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301575 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301577 LIM_NO_WEP_IN_FC,
1578 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001579
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301580 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 }
1582
1583 pAuthNode = limSearchPreAuthList(pMac,
1584 pHdr->sa);
1585 if (pAuthNode == NULL)
1586 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301587 // Log error
1588 PELOGE(limLog(pMac, LOGW,
1589 FL("received AuthFrame3 from peer that has no "
1590 "preauth context "MAC_ADDRESS_STR),
1591 MAC_ADDR_ARRAY(pHdr->sa));)
1592
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 /**
1594 * No 'pre-auth' context exists for
1595 * this STA that sent an Authentication
1596 * frame3.
1597 * Send Auth frame4 with 'out of sequence'
1598 * status code.
1599 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301600 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1601 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301603 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1605
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301606 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301608 LIM_NO_WEP_IN_FC,
1609 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001610
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301611 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 }
1613
1614 if (pAuthNode->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)
1615 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301616 // Log error
1617 limLog(pMac, LOGW,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301618 FL("auth response timer timedout for peer "
1619 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 /**
1621 * Received Auth Frame3 after Auth Response timeout.
1622 * Reject by sending Auth Frame4 with
1623 * Auth respone timeout Status Code.
1624 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301625 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1626 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301628 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS;
1630
1631 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301632 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301634 LIM_NO_WEP_IN_FC,
1635 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001636
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 /// Delete pre-auth context of STA
1638 limDeletePreAuthNode(pMac,
1639 pHdr->sa);
1640
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301641 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 } // end switch (pAuthNode->mlmState)
1643
1644 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1645 {
1646 /**
1647 * Received Authenetication Frame 3 with status code
1648 * other than success. Wait until Auth response timeout
1649 * to delete STA context.
1650 */
1651
1652 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001653 PELOGE(limLog(pMac, LOGE,
1654 FL("received Auth frame3 from peer with status code %d "
1655 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1656 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001657
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301658 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 }
1660
1661 /**
1662 * Check if received challenge text is same as one sent in
1663 * Authentication frame3
1664 */
1665
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301666 if (vos_mem_compare(pRxAuthFrameBody->challengeText,
1667 pAuthNode->challengeText,
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301668 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH))
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 {
1670 /// Challenge match. STA is autheticated !
1671
1672 /// Delete Authentication response timer if running
1673 limDeactivateAndChangePerStaIdTimer(pMac,
1674 eLIM_AUTH_RSP_TIMER,
1675 pAuthNode->authNodeIdx);
1676
1677 pAuthNode->fTimerStarted = 0;
1678 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1679
1680 /**
1681 * Send Authentication Frame4 with 'success' Status Code.
1682 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301683 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1684 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001685 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301686 authFrame->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001687
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301688 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301690 LIM_NO_WEP_IN_FC,
1691 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001692
1693 /// Send Auth indication to SME
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301694 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 (tANI_U8 *) pHdr->sa,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301696 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 mlmAuthInd.authType = (tAniAuthType)
1698 pRxAuthFrameBody->authAlgoNumber;
1699 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
1700
1701 limPostSmeMessage(pMac,
1702 LIM_MLM_AUTH_IND,
1703 (tANI_U32 *) &mlmAuthInd);
1704
1705 break;
1706 }
1707 else
1708 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301709 // Log error
1710 PELOGE( limLog(pMac, LOGW,
1711 FL("Challenge failure for peer "
1712 MAC_ADDRESS_STR),
1713 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 /**
1715 * Challenge Failure.
1716 * Send Authentication frame4 with 'challenge failure'
1717 * status code and wait until Auth response timeout to
1718 * delete STA context.
1719 */
1720
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301721 authFrame->authAlgoNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001722 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301723 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001724 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301725 authFrame->authStatusCode =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001726 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001727
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301728 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301730 LIM_NO_WEP_IN_FC,
1731 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001732
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301733 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 }
1735 } // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE || ...
1736
1737 break;
1738
1739 case SIR_MAC_AUTH_FRAME_4:
1740 // AuthFrame 4
1741 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE)
1742 {
1743 /**
1744 * Received Authentication frame4 in an unexpected state.
1745 * Log error and ignore the frame.
1746 */
1747
1748 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301749 limLog(pMac, LOG1,
Abhishek Singh208848c2013-12-18 19:02:52 +05301750 FL("received unexpected Auth frame4 from peer in state "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301751 "%d, addr "MAC_ADDRESS_STR), psessionEntry->limMlmState,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301752 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001753
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301754 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 }
1756
1757 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1758 {
1759 /**
1760 * Received Authentication frame4 with algorithm other than
1761 * Shared Key authentication type.
1762 * Wait until Auth failure timeout to report authentication
1763 * failure to SME.
1764 */
1765
1766 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001767 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301768 FL("received Auth frame4 from peer with invalid auth "
1769 "algo %d "MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001770 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001771
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301772 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 }
1774
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301775 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1776 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1777 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 {
1779 /**
1780 * Received Authentication frame from an entity
1781 * other than one to which request was initiated.
1782 * Wait until Authentication Failure Timeout.
1783 */
1784
1785 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001786 PELOGE(limLog(pMac, LOGW,
1787 FL("received Auth frame4 from unexpected peer "
1788 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001789
1790 break;
1791 }
1792
1793 if (pRxAuthFrameBody->authAlgoNumber !=
1794 pMac->lim.gpLimMlmAuthReq->authType)
1795 {
1796 /**
1797 * Received Authentication frame with an auth algorithm
1798 * other than one requested.
1799 * Wait until Authentication Failure Timeout.
1800 */
1801
Mohit Khanna23863762012-09-11 17:40:09 -07001802 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301803 FL("received Authentication frame from peer with "
1804 "invalid auth seq number %d "
1805 MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001806 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001807
1808 break;
1809 }
1810
1811 if (pRxAuthFrameBody->authStatusCode ==
1812 eSIR_MAC_SUCCESS_STATUS)
1813 {
1814 /**
1815 * Authentication Success !
1816 * Inform SME of same.
1817 */
1818 psessionEntry->limCurrentAuthType = eSIR_SHARED_KEY;
1819
1820 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1821 if (pAuthNode == NULL)
1822 {
1823 // Log error
1824 limLog(pMac, LOGW,
1825 FL("Max pre-auth nodes reached "));
1826 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1827
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301828 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301830 limLog(pMac, LOG1,
1831 FL("Alloc new data: peer " MAC_ADDRESS_STR),
1832 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001833
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301834 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1836 sizeof(tSirMacAddr));
1837 pAuthNode->fTimerStarted = 0;
1838 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301839 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1840 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301841 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 limAddPreAuthNode(pMac, pAuthNode);
1843
1844 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1845 pRxAuthFrameBody->authStatusCode,psessionEntry);
1846
1847 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1848 else
1849 {
1850 /**
1851 * Authentication failure.
1852 * Return Auth confirm with received failure code to SME
1853 */
1854
1855 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001856 PELOGE(limLog(pMac, LOGE, FL("Authentication failure from peer "
1857 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001858
1859 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1860 pRxAuthFrameBody->authStatusCode,psessionEntry);
1861 } // end if (pRxAuthFrameBody->Status == 0)
1862
1863 break;
1864
1865 default:
1866 /// Invalid Authentication Frame received. Ignore it.
1867
1868 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001869 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301870 FL("received Auth frame from peer with invalid auth seq "
1871 "number %d " MAC_ADDRESS_STR),
1872 pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001873 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001874
1875 break;
1876 } // end switch (pRxAuthFrameBody->authTransactionSeqNumber)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301877
1878free:
1879 if (authFrame)
1880 vos_mem_free(authFrame);
1881 if (rxAuthFrame)
1882 vos_mem_free(rxAuthFrame);
1883 if (encrAuthFrame)
1884 vos_mem_free(encrAuthFrame);
1885 if (plainBody)
1886 vos_mem_free(plainBody);
1887 if (challengeTextArray)
1888 vos_mem_free(challengeTextArray);
1889
Jeff Johnson295189b2012-06-20 16:38:30 -07001890} /*** end limProcessAuthFrame() ***/
1891
1892
1893
1894
1895
1896#ifdef WLAN_FEATURE_VOWIFI_11R
1897
1898/*----------------------------------------------------------------------
1899 *
1900 * Pass the received Auth frame. This is possibly the pre-auth from the
1901 * neighbor AP, in the same mobility domain.
1902 * This will be used in case of 11r FT.
1903 *
1904 * !!!! This is going to be renoved for the next checkin. We will be creating
1905 * the session before sending out the Auth. Thus when auth response
1906 * is received we will have a session in progress. !!!!!
1907 *----------------------------------------------------------------------
1908 */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001909tSirRetStatus limProcessAuthFrameNoSession(tpAniSirGlobal pMac, tANI_U8 *pBd, void *body)
Jeff Johnson295189b2012-06-20 16:38:30 -07001910{
1911 tpSirMacMgmtHdr pHdr;
1912 tpPESession psessionEntry = NULL;
1913 tANI_U8 *pBody;
1914 tANI_U16 frameLen;
1915 tSirMacAuthFrameBody rxAuthFrame;
1916 tSirMacAuthFrameBody *pRxAuthFrameBody = NULL;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001917 tSirRetStatus ret_status = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001918
1919 pHdr = WDA_GET_RX_MAC_HEADER(pBd);
1920 pBody = WDA_GET_RX_MPDU_DATA(pBd);
1921 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd);
1922
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05301923 /*
1924 * since, roaming is not supported in sta + mon scc, ignore
1925 * pre-auth when capture on monitor mode is started
1926 */
1927 if (vos_check_monitor_state())
1928 {
1929 limLog(pMac, LOG1, FL("Ignore pre-auth frame in monitor mode"));
1930 return eSIR_FAILURE;
1931 }
1932
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301933 limLog(pMac, LOG1, FL("Auth Frame Received: BSSID " MAC_ADDRESS_STR
1934 " (RSSI %d)"),MAC_ADDR_ARRAY(pHdr->bssId),
1935 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001936 // Check for the operating channel and see what needs to be done next.
1937 psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
1938 if (psessionEntry == NULL)
1939 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301940 limLog(pMac, LOGE, FL("Error: Unable to find session id while in "
1941 "pre-auth phase for FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 return eSIR_FAILURE;
1943 }
1944
1945 if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL)
1946 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301947 limLog(pMac, LOGE, FL("Error: No FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 // No FT in progress.
1949 return eSIR_FAILURE;
1950 }
1951
1952 if (frameLen == 0)
1953 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301954 limLog(pMac, LOGE, FL("Error: Frame len = 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 return eSIR_FAILURE;
1956 }
1957#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001958 limPrintMacAddr(pMac, pHdr->bssId, LOG2);
1959 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOG2);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001960 limLog(pMac,LOG2,FL("seqControl 0x%X"),
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001961 ((pHdr->seqControl.seqNumHi << 8) |
1962 (pHdr->seqControl.seqNumLo << 4) |
1963 (pHdr->seqControl.fragNum)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001964#endif
1965
1966 // Check that its the same bssId we have for preAuth
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301967 if (!vos_mem_compare(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1968 pHdr->bssId, sizeof( tSirMacAddr )))
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301970 limLog(pMac, LOGE, FL("Error: NOT same bssid as preauth BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 // In this case SME if indeed has triggered a
1972 // pre auth it will time out.
1973 return eSIR_FAILURE;
1974 }
1975
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001976 if (eANI_BOOLEAN_TRUE ==
1977 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed)
1978 {
1979 /*
1980 * This is likely a duplicate for the same pre-auth request.
1981 * PE/LIM already posted a response to SME. Hence, drop it.
1982 * TBD:
1983 * 1) How did we even receive multiple auth responses?
1984 * 2) Do we need to delete pre-auth session? Suppose we
1985 * previously received an auth resp with failure which
1986 * would not have created the session and forwarded to SME.
1987 * And, we subsequently received an auth resp with success
1988 * which would have created the session. This will now be
1989 * dropped without being forwarded to SME! However, it is
1990 * very unlikely to receive auth responses from the same
1991 * AP with different reason codes.
1992 * NOTE: return eSIR_SUCCESS so that the packet is dropped
1993 * as this was indeed a response from the BSSID we tried to
1994 * pre-auth.
1995 */
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001996 PELOGE(limLog(pMac,LOG1,"Auth rsp already posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001997 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001998 pMac->ft.ftPEContext.pftSessionEntry););
1999 return eSIR_SUCCESS;
2000 }
2001 else
2002 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002003 PELOGE(limLog(pMac,LOGW,"Auth rsp not yet posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07002004 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002005 pMac->ft.ftPEContext.pftSessionEntry););
2006 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
2007 eANI_BOOLEAN_TRUE;
2008 }
2009
Jeff Johnson295189b2012-06-20 16:38:30 -07002010#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002011 limLog(pMac, LOG1, FL("Pre-Auth response received from neighbor"));
2012 limLog(pMac, LOG1, FL("Pre-Auth done state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002013#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302014
2015 limLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
2016 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
2017
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 // Stopping timer now, that we have our unicast from the AP
2019 // of our choice.
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302020 if (!pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
2021 limDeactivateAndChangeTimer(pMac, eLIM_FT_PREAUTH_RSP_TIMER);
2022
2023#ifdef WLAN_FEATURE_LFR_MBB
2024 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
2025 limDeactivateAndChangeTimer(pMac, eLIM_PREAUTH_MBB_RSP_TIMER);
2026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002027
2028
2029 // Save off the auth resp.
2030 if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame) != eSIR_SUCCESS))
2031 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05302032 limLog(pMac, LOGE, FL("failed to convert Auth frame to struct"));
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302033
2034#ifdef WLAN_FEATURE_LFR_MBB
2035 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
2036 lim_handle_pre_auth_mbb_rsp(pMac, eSIR_FAILURE, psessionEntry);
2037 return eSIR_FAILURE;
2038 }
2039#endif
2040
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
2042 return eSIR_FAILURE;
2043 }
2044 pRxAuthFrameBody = &rxAuthFrame;
2045
2046#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002047 PELOGE(limLog(pMac, LOG1,
2048 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
2050 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
2051 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
2052#endif
2053
2054 switch (pRxAuthFrameBody->authTransactionSeqNumber)
2055 {
2056 case SIR_MAC_AUTH_FRAME_2:
2057 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
2058 {
2059#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08002060 PELOGE(limLog( pMac, LOGE, "Auth status code received is %d",
2061 (tANI_U32) pRxAuthFrameBody->authStatusCode););
Jeff Johnson295189b2012-06-20 16:38:30 -07002062#endif
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08002063 if (eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS == pRxAuthFrameBody->authStatusCode)
2064 ret_status = eSIR_LIM_MAX_STA_REACHED_ERROR;
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 }
2066 else
2067 {
2068 ret_status = eSIR_SUCCESS;
2069 }
2070 break;
2071
2072 default:
2073#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002074 PELOGE(limLog( pMac, LOGE, "Seq. no incorrect expected 2 received %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber);)
2076#endif
2077 break;
2078 }
2079
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302080#ifdef WLAN_FEATURE_LFR_MBB
2081 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
2082 lim_handle_pre_auth_mbb_rsp(pMac, ret_status, psessionEntry);
2083 return ret_status;
2084 }
2085#endif
2086
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 // Send the Auth response to SME
2088 limHandleFTPreAuthRsp(pMac, ret_status, pBody, frameLen, psessionEntry);
2089
2090 return ret_status;
2091}
2092
2093#endif /* WLAN_FEATURE_VOWIFI_11R */
2094