blob: 15344b232c726337de5da7b42845a4b043a481bd [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Pankaj Singhbe225ca2020-06-04 10:45:24 +05302 * Copyright (c) 2011-2015, 2017-2018, 2020 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/**
Pankaj Singhf9c4ca72020-06-05 01:09:07 +0530106 * lim_external_auth_add_pre_auth_node()- Add preauth node for the peer
107 * performing external authentication
108 * @mac_ctx: MAC context
109 * @mac_hdr: Mac header of the packet
110 * @mlm_state: MLM state to be marked to track SAE authentication
111 *
112 * Return: None
113 */
114static void lim_external_auth_add_pre_auth_node(tpAniSirGlobal mac_ctx,
115 tpSirMacMgmtHdr mac_hdr,
116 tLimMlmStates mlm_state)
117{
118 struct tLimPreAuthNode *auth_node;
119 tpLimPreAuthTable preauth_table = &mac_ctx->lim.gLimPreAuthTimerTable;
120
121 limLog(mac_ctx, LOG1, FL("=======> eSIR_AUTH_TYPE_SAE"));
122 /* Create entry for this STA in pre-auth list */
123 auth_node = limAcquireFreePreAuthNode(mac_ctx, preauth_table);
124 if (!auth_node) {
125 limLog(mac_ctx, LOG1,
126 "Max pre-auth nodes reached " MAC_ADDRESS_STR,
127 MAC_ADDR_ARRAY(mac_hdr->sa));
128 return;
129 }
130 limLog(mac_ctx, LOG1,
131 "Creating preauth node for SAE peer " MAC_ADDRESS_STR,
132 MAC_ADDR_ARRAY(mac_hdr->sa));
133 vos_mem_copy((uint8_t *)auth_node->peerMacAddr,
134 mac_hdr->sa, sizeof(tSirMacAddr));
135 auth_node->mlmState = mlm_state;
136 auth_node->authType = eSIR_AUTH_TYPE_SAE;
137 auth_node->timestamp = vos_timer_get_system_ticks();
138 auth_node->seqNo = ((mac_hdr->seqControl.seqNumHi << 4) |
139 (mac_hdr->seqControl.seqNumLo));
140 auth_node->assoc_req.present = false;
141 limAddPreAuthNode(mac_ctx, auth_node);
142}
143
144
145/**
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530146 * lim_process_sae_auth_frame()-Process SAE authentication frame
147 * @mac_ctx: MAC context
148 * @rx_pkt_info: Rx packet
149 * @pe_session: PE session
150 *
151 * Return: None
152 */
153static void lim_process_sae_auth_frame(tpAniSirGlobal mac_ctx,
154 uint8_t *rx_pkt_info,
155 tpPESession pe_session)
156{
157 tpSirMacMgmtHdr mac_hdr;
Pankaj Singh33205b82020-06-05 00:27:49 +0530158 enum rxmgmt_flags rx_flags = RXMGMT_FLAG_NONE;
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530159
160 mac_hdr = WDA_GET_RX_MAC_HEADER(rx_pkt_info);
161
162 limLog(mac_ctx, LOG1, FL("Received SAE Auth frame type %d subtype %d"),
163 mac_hdr->fc.type, mac_hdr->fc.subType);
164
Pankaj Singh33205b82020-06-05 00:27:49 +0530165 if (LIM_IS_STA_ROLE(pe_session) &&
166 pe_session->limMlmState != eLIM_MLM_WT_SAE_AUTH_STATE)
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530167 limLog(mac_ctx, LOGE,
168 FL("received SAE auth response in unexpected state %x"),
169 pe_session->limMlmState);
170
Pankaj Singhf9c4ca72020-06-05 01:09:07 +0530171 if(LIM_IS_AP_ROLE(pe_session)) {
172 struct tLimPreAuthNode *sta_pre_auth_ctx;
173
174 rx_flags = RXMGMT_FLAG_EXTERNAL_AUTH;
175 /* Add preauth node when the first SAE authentication frame
176 * is received and mark state as authenticating.
177 * It's not good to track SAE authentication frames with
178 * authTransactionSeqNumber as it's subjected to
179 * SAE protocol optimizations.
180 */
181 /* Extract pre-auth context for the STA, if any. */
182 sta_pre_auth_ctx = limSearchPreAuthList(mac_ctx,
183 mac_hdr->sa);
184 if (!sta_pre_auth_ctx ||
185 (sta_pre_auth_ctx->mlmState != eLIM_MLM_WT_SAE_AUTH_STATE &&
186 sta_pre_auth_ctx->mlmState !=
187 eLIM_MLM_AUTHENTICATED_STATE)) {
188 lim_external_auth_add_pre_auth_node(mac_ctx, mac_hdr,
189 eLIM_MLM_WT_SAE_AUTH_STATE);
190 }
191 }
Pankaj Singh33205b82020-06-05 00:27:49 +0530192
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530193 limSendSmeMgmtFrameInd(mac_ctx, pe_session->peSessionId,
194 rx_pkt_info, pe_session,
Pankaj Singh33205b82020-06-05 00:27:49 +0530195 WDA_GET_RX_RSSI_DB(rx_pkt_info), rx_flags);
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530196}
197#else
198static void lim_process_sae_auth_frame(tpAniSirGlobal mac_ctx,
199 uint8_t *rx_pkt_info,
200 tpPESession pe_session)
201{}
202#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700203
204/**
205 * limProcessAuthFrame
206 *
207 *FUNCTION:
208 * This function is called by limProcessMessageQueue() upon Authentication
209 * frame reception.
210 *
211 *LOGIC:
212 * This function processes received Authentication frame and responds
213 * with either next Authentication frame in sequence to peer MAC entity
214 * or LIM_MLM_AUTH_IND on AP or LIM_MLM_AUTH_CNF on STA.
215 *
216 *ASSUMPTIONS:
217 *
218 *NOTE:
219 * 1. Authentication failures are reported to SME with same status code
220 * received from the peer MAC entity.
221 * 2. Authentication frame2/4 received with alogirthm number other than
222 * one requested in frame1/3 are logged with an error and auth confirm
223 * will be sent to SME only after auth failure timeout.
224 * 3. Inconsistency in the spec:
225 * On receiving Auth frame2, specs says that if WEP key mapping key
226 * or default key is NULL, Auth frame3 with a status code 15 (challenge
227 * failure to be returned to peer entity. However, section 7.2.3.10,
228 * table 14 says that status code field is 'reserved' for frame3 !
229 * In the current implementation, Auth frame3 is returned with status
230 * code 15 overriding section 7.2.3.10.
231 * 4. If number pre-authentications reach configrable max limit,
232 * Authentication frame with 'unspecified failure' status code is
233 * returned to requesting entity.
234 *
235 * @param pMac - Pointer to Global MAC structure
236 * @param *pRxPacketInfo - A pointer to Rx packet info structure
237 * @return None
238 */
239
240void
241limProcessAuthFrame(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tpPESession psessionEntry)
242{
243 tANI_U8 *pBody, keyId, cfgPrivacyOptImp,
244 defaultKey[SIR_MAC_KEY_LENGTH],
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530245 *encrAuthFrame = NULL,
246 *plainBody = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700247 tANI_U16 frameLen;
248 //tANI_U32 authRspTimeout, maxNumPreAuth, val;
249 tANI_U32 maxNumPreAuth, val;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530250 tSirMacAuthFrameBody *pRxAuthFrameBody,
251 *rxAuthFrame = NULL,
252 *authFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700253 tpSirMacMgmtHdr pHdr;
254 tCfgWepKeyEntry *pKeyMapEntry = NULL;
255 struct tLimPreAuthNode *pAuthNode;
256 tLimMlmAuthInd mlmAuthInd;
257 tANI_U8 decryptResult;
258 tANI_U8 *pChallenge;
259 tANI_U32 key_length=8;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530260 tANI_U8 *challengeTextArray = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 tpDphHashNode pStaDs = NULL;
262 tANI_U16 assocId = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530263 tANI_U16 currSeqNo = 0;
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530264 tANI_U16 auth_alg = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700265 /* Added For BT -AMP support */
266 // Get pointer to Authentication frame header and body
267
268
269 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
270 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700271
272 if (!frameLen)
273 {
274 // Log error
275 limLog(pMac, LOGE,
276 FL("received Authentication frame with no body from "));
277 limPrintMacAddr(pMac, pHdr->sa, LOGE);
278
279 return;
280 }
281
282 if (limIsGroupAddr(pHdr->sa))
283 {
284 // Received Auth frame from a BC/MC address
285 // Log error and ignore it
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530286 limLog(pMac, LOGE,
287 FL("received Auth frame from a BC/MC address - "));
288 limPrintMacAddr(pMac, pHdr->sa, LOGE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700289
290 return;
291 }
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530292 currSeqNo = (pHdr->seqControl.seqNumHi << 4) | (pHdr->seqControl.seqNumLo);
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530293 limLog(pMac, LOG1,
294 FL("Sessionid: %d System role : %d limMlmState: %d :Auth "
295 "Frame Received: BSSID: "MAC_ADDRESS_STR " (RSSI %d)"),
296 psessionEntry->peSessionId, psessionEntry->limSystemRole,
297 psessionEntry->limMlmState, MAC_ADDR_ARRAY(pHdr->bssId),
298 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo)));
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800299
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
301
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530302 auth_alg = *(uint16_t *)pBody;
303 limLog(pMac, LOG1, FL("auth_alg %d "), auth_alg);
304
Jeff Johnsone7245742012-09-05 17:12:55 -0700305 //PELOG3(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG3, (tANI_U8*)pBd, ((tpHalBufDesc) pBd)->mpduDataOffset + frameLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700306
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800307 //Restore default failure timeout
308 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
309 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530310 limLog(pMac, LOG1, FL("Restore default failure timeout"));
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800311 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
312 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
313 }
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530314
315 rxAuthFrame = vos_mem_malloc(sizeof(tSirMacAuthFrameBody));
316 if (!rxAuthFrame) {
317 limLog(pMac, LOGE, FL("Failed to allocate memory"));
318 return;
319 }
320
321 authFrame = vos_mem_malloc(sizeof(tSirMacAuthFrameBody));
322 if (!authFrame) {
323 limLog(pMac, LOGE, FL("failed to allocate memory"));
324 goto free;
325 }
326
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530327 plainBody = vos_mem_malloc(LIM_ENCR_AUTH_BODY_LEN);
328 if (!plainBody) {
329 limLog(pMac, LOGE, FL("failed to allocate memory"));
330 goto free;
331 }
332
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +0530333 challengeTextArray = vos_mem_malloc(SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530334 if(!challengeTextArray) {
335 limLog(pMac, LOGE, FL("failed to allocate memory"));
336 goto free;
337 }
338
339 vos_mem_set(rxAuthFrame, sizeof(tSirMacAuthFrameBody), 0);
340 vos_mem_set(authFrame, sizeof(tSirMacAuthFrameBody), 0);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530341 vos_mem_set(plainBody, LIM_ENCR_AUTH_BODY_LEN, 0);
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +0530342 vos_mem_set(challengeTextArray, SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700343
344 /// Determine if WEP bit is set in the FC or received MAC header
345 if (pHdr->fc.wep)
346 {
347 /**
348 * WEP bit is set in FC of MAC header.
349 */
350
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 // If TKIP counter measures enabled issue Deauth frame to station
352 if ((psessionEntry->bTkipCntrMeasActive) && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
353 {
354 PELOGE( limLog(pMac, LOGE,
355 FL("Tkip counter measures Enabled, sending Deauth frame to")); )
356 limPrintMacAddr(pMac, pHdr->sa, LOGE);
357
358 limSendDeauthMgmtFrame( pMac, eSIR_MAC_MIC_FAILURE_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800359 pHdr->sa, psessionEntry, FALSE );
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530360 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700362
363 // Extract key ID from IV (most 2 bits of 4th byte of IV)
364
365 keyId = (*(pBody + 3)) >> 6;
366
367 /**
368 * On STA in infrastructure BSS, Authentication frames received
369 * with WEP bit set in the FC must be rejected with challenge
370 * failure status code (wierd thing in the spec - this should have
371 * been rejected with unspecified failure or unexpected assertion
372 * of wep bit (this status code does not exist though) or
373 * Out-of-sequence-Authentication-Frame status code.
374 */
375
376 if (psessionEntry->limSystemRole == eLIM_STA_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)
377 {
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530378 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
379 authFrame->authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
380 authFrame->authStatusCode = eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Abhishek Singh208848c2013-12-18 19:02:52 +0530381 // Log error
382 PELOGE(limLog(pMac, LOGE,
383 FL("received Authentication frame with wep bit set on "
384 "role=%d "MAC_ADDRESS_STR),
385 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pHdr->sa) );)
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);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530390 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 }
392
Vignesh Viswanathan5ab5cde2017-11-21 16:21:34 +0530393 if ((frameLen < LIM_ENCR_AUTH_BODY_LEN_SAP) ||
394 (frameLen > LIM_ENCR_AUTH_BODY_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 {
396 // Log error
397 limLog(pMac, LOGE,
398 FL("Not enough size [%d] to decrypt received Auth frame"),
399 frameLen);
400 limPrintMacAddr(pMac, pHdr->sa, LOGE);
401
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530402 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700403 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
405 {
406 val = psessionEntry->privacy;
407 }
408 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 // Accept Authentication frame only if Privacy is implemented
410 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
411 &val) != eSIR_SUCCESS)
412 {
413 /**
414 * Could not get Privacy option
415 * from CFG. Log error.
416 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700417 limLog(pMac, LOGP, FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 }
419
420 cfgPrivacyOptImp = (tANI_U8)val;
421 if (cfgPrivacyOptImp)
422 {
423 /**
424 * Privacy option is implemented.
425 * Check if the received frame is Authentication
426 * frame3 and there is a context for requesting STA.
427 * If not, reject with unspecified failure status code
428 */
429 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
430
431 if (pAuthNode == NULL)
432 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530433 // Log error
434 PELOGE(limLog(pMac, LOGE,
435 FL("received Authentication frame from peer that has "
436 "no preauth context with WEP bit set "MAC_ADDRESS_STR),
437 MAC_ADDR_ARRAY(pHdr->sa));)
438
Jeff Johnson295189b2012-06-20 16:38:30 -0700439 /**
440 * No 'pre-auth' context exists for this STA that sent
441 * an Authentication frame with FC bit set.
442 * Send Auth frame4 with 'out of sequence' status code.
443 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530444 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
445 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530447 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
449
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530450 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530452 LIM_NO_WEP_IN_FC,
453 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700454
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530455 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 }
457 else
458 {
459 /// Change the auth-response timeout
460 limDeactivateAndChangePerStaIdTimer(pMac,
461 eLIM_AUTH_RSP_TIMER,
462 pAuthNode->authNodeIdx);
463
464 /// 'Pre-auth' status exists for STA
465 if ((pAuthNode->mlmState !=
466 eLIM_MLM_WT_AUTH_FRAME3_STATE) &&
467 (pAuthNode->mlmState !=
468 eLIM_MLM_AUTH_RSP_TIMEOUT_STATE))
469 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530470 // Log error
471 PELOGE(limLog(pMac, LOGE,
472 FL("received Authentication frame from peer that is "
473 "in state %d "MAC_ADDRESS_STR),
474 pAuthNode->mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
475
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 /**
477 * Should not have received Authentication frame
478 * with WEP bit set in FC in other states.
479 * Reject by sending Authenticaton frame with
480 * out of sequence Auth frame status code.
481 */
482
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530483 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
484 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530486 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
488
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530489 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530491 LIM_NO_WEP_IN_FC,
492 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530494 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 }
496 }
497
498 /**
499 * Check if there exists a key mappping key
500 * for the STA that sent Authentication frame
501 */
502 pKeyMapEntry = limLookUpKeyMappings(pHdr->sa);
503
504 if (pKeyMapEntry)
505 {
506 if (!pKeyMapEntry->wepOn)
507 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530508 // Log error
509 PELOGE(limLog(pMac, LOGE,
510 FL("received Auth frame3 from peer that has NULL "
511 "key map entry "
512 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));)
513
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 /**
515 * Key Mapping entry has null key.
516 * Send Authentication frame
517 * with challenge failure status code
518 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530519 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
520 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530522 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
524
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530525 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530527 LIM_NO_WEP_IN_FC,
528 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700529
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530530 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 } // if (!pKeyMapEntry->wepOn)
532 else
533 {
534 decryptResult = limDecryptAuthFrame(pMac, pKeyMapEntry->key,
535 pBody,
536 plainBody,
537 key_length,
538 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
539 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
540 {
541 /// ICV failure
Abhishek Singh208848c2013-12-18 19:02:52 +0530542 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
543 "LIM_DECRYPT_ICV_FAIL ..."));)
544 // Log error
545 PELOGE(limLog(pMac, LOGE,
546 FL("received Authentication frame from peer "
547 "that failed decryption, Addr "
548 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
549
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 limDeletePreAuthNode(pMac,
551 pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530552 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
553 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700554 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530555 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
557
558 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530559 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530561 LIM_NO_WEP_IN_FC,
562 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700563
Jeff Johnson295189b2012-06-20 16:38:30 -0700564
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530565 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 }
567
Abhishek Singh208848c2013-12-18 19:02:52 +0530568 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530569 rxAuthFrame)!=eSIR_SUCCESS ) ||
570 ( !isAuthValid(pMac, rxAuthFrame,psessionEntry) ) )
Abhishek Singh208848c2013-12-18 19:02:52 +0530571 {
572 PELOGE(limLog(pMac, LOGE,
573 FL("failed to convert Auth Frame to structure "
574 "or Auth is not valid "));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530575 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530576 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700577
578
579 } // end if (pKeyMapEntry->key == NULL)
580 } // if keyMappings has entry
581 else
582 {
583
584 val = SIR_MAC_KEY_LENGTH;
585
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
587 {
588 tpSirKeys pKey;
589 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530590 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 val = pKey->keyLength;
592 }
593 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
595 defaultKey, &val) != eSIR_SUCCESS)
596 {
597 /// Could not get Default key from CFG.
598 //Log error.
599 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700600 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700601
602 /**
603 * Send Authentication frame
604 * with challenge failure status code
605 */
606
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530607 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
608 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530610 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
612
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530613 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530615 LIM_NO_WEP_IN_FC,
616 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700617
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530618 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 }
620
621 key_length=val;
622
623 decryptResult = limDecryptAuthFrame(pMac, defaultKey,
624 pBody,
625 plainBody,
626 key_length,
627 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
628 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
629 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530630 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
631 "LIM_DECRYPT_ICV_FAIL ..."));)
632 // Log error
633 PELOGE(limLog(pMac, LOGE,
634 FL("received Authentication frame from peer that "
635 "failed decryption: "
636 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 /// ICV failure
638 limDeletePreAuthNode(pMac,
639 pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530640 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
641 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530643 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
645
646 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530647 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700648 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530649 LIM_NO_WEP_IN_FC,
650 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700651
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530652 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530654 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530655 rxAuthFrame)!=eSIR_SUCCESS ) ||
656 ( !isAuthValid(pMac, rxAuthFrame, psessionEntry) ) )
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530657 {
658 limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +0530659 FL("failed to convert Auth Frame to structure "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530660 "or Auth is not valid "));
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530661 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530662 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 } // End of check for Key Mapping/Default key presence
664 }
665 else
666 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530667 // Log error
668 PELOGE(limLog(pMac, LOGE,
669 FL("received Authentication frame3 from peer that while "
670 "privacy option is turned OFF "
671 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 /**
673 * Privacy option is not implemented.
674 * So reject Authentication frame received with
675 * WEP bit set by sending Authentication frame
676 * with 'challenge failure' status code. This is
677 * another strange thing in the spec. Status code
678 * should have been 'unsupported algorithm' status code.
679 */
680
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530681 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
682 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530684 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
686
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530687 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700688 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530689 LIM_NO_WEP_IN_FC,
690 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700691
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530692 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 } // else if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
Pankaj Singhbe225ca2020-06-04 10:45:24 +0530694 } else if (auth_alg == eSIR_AUTH_TYPE_SAE) {
695 if (LIM_IS_STA_ROLE(psessionEntry) ||
696 LIM_IS_AP_ROLE(psessionEntry))
697 lim_process_sae_auth_frame(pMac, pRxPacketInfo, psessionEntry);
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530698 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 } // if (fc.wep)
700 else
701 {
702
703
Abhishek Singh208848c2013-12-18 19:02:52 +0530704 if ( ( sirConvertAuthFrame2Struct(pMac, pBody,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530705 frameLen, rxAuthFrame)!=eSIR_SUCCESS ) ||
706 ( !isAuthValid(pMac, rxAuthFrame,psessionEntry) ) )
Abhishek Singh208848c2013-12-18 19:02:52 +0530707 {
708 PELOGE(limLog(pMac, LOGE,
709 FL("failed to convert Auth Frame to structure or Auth is "
710 "not valid "));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530711 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530712 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 }
714
715
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530716 pRxAuthFrameBody = rxAuthFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -0700717
Mohit Khanna23863762012-09-11 17:40:09 -0700718 PELOGW(limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700719 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
721 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
722 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
723
Wang Hu4506bae2015-12-07 14:15:19 +0800724 // IOT Workaround: with invalid WEP password, some APs reply AUTH frame 4
725 // with invalid seqNumber. This AUTH frame will be dropped by driver,
726 // thus driver sends the generic status code instead of protocol status code.
727 // As a workaround, assign the correct seqNumber for the AUTH frame 4.
728 if (psessionEntry->limMlmState == eLIM_MLM_WT_AUTH_FRAME4_STATE &&
729 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_1 &&
730 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_2 &&
731 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_3) {
732 PELOGE(limLog(pMac, LOGE, FL("Workaround: Assign a correct seqNumber=4 "
733 "for AUTH frame 4"));)
734 pRxAuthFrameBody->authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
735 }
736
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 switch (pRxAuthFrameBody->authTransactionSeqNumber)
738 {
739 case SIR_MAC_AUTH_FRAME_1:
740 // AuthFrame 1
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800741
742 pStaDs = dphLookupHashEntry(pMac, pHdr->sa,
743 &assocId, &psessionEntry->dph.dphHashTable);
744 if (pStaDs)
745 {
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530746 tLimMlmDisassocReq *pMlmDisassocReq = NULL;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800747 tLimMlmDeauthReq *pMlmDeauthReq = NULL;
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530748 tAniBool isConnected = eSIR_TRUE;
749
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800750 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
751 if (pMlmDisassocReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530752 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800753 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530754 sizeof(tSirMacAddr))))
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800755 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800756 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for disassoc "
757 "frame is pending Issue delsta for "
758 MAC_ADDRESS_STR),
759 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700760 limProcessDisassocAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530761 isConnected = eSIR_FALSE;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800762 }
763 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
764 if (pMlmDeauthReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530765 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800766 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
767 sizeof(tSirMacAddr))))
768 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800769 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for deauth frame "
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700770 "is pending Issue delsta for "
Arif Hussain24bafea2013-11-15 15:10:03 -0800771 MAC_ADDRESS_STR),
772 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700773 limProcessDeauthAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530774 isConnected = eSIR_FALSE;
775 }
776
777 /* pStaDS != NULL and isConnected = 1 means the STA is already
778 * connected, But SAP received the Auth from that station.
Abhishek Singh0496a522015-12-14 23:39:23 -0800779 * For non PMF connection send Deauth frame as STA will retry
780 * to connect back.
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530781 *
782 * For PMF connection the AP should not tear down or otherwise
783 * modify the state of the existing association until the
784 * SA-Query procedure determines that the original SA is
785 * invalid.
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530786 */
gaurank kathpalia66414892018-03-21 20:24:39 +0530787 if (isConnected && pStaDs->PrevAuthSeqno != currSeqNo
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530788#ifdef WLAN_FEATURE_11W
789 && !pStaDs->rmfEnabled
790#endif
gaurank kathpalia66414892018-03-21 20:24:39 +0530791 )
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530792 {
Abhishek Singh0496a522015-12-14 23:39:23 -0800793 limLog(pMac, LOGE,
Yeshwanth Sriram Guntukab74fadf2019-08-21 21:09:57 +0530794 FL("Auth frame received in mlm state: %d(staId: %d, assocId: %d)"),
795 pStaDs->mlmStaContext.mlmState,
Abhishek Singh0496a522015-12-14 23:39:23 -0800796 pStaDs->staIndex, assocId);
Yeshwanth Sriram Guntukab74fadf2019-08-21 21:09:57 +0530797 if (pStaDs->mlmStaContext.mlmState ==
798 eLIM_MLM_LINK_ESTABLISHED_STATE) {
799 limLog(pMac, LOGE,
800 FL("STA is already connected but received auth frame"
801 "Send the Deauth and lim Delete Station Context"
802 "(staId: %d, assocId: %d) "),
803 pStaDs->staIndex, assocId);
804 limSendDeauthMgmtFrame(pMac,
805 eSIR_MAC_UNSPEC_FAILURE_REASON,
806 (tANI_U8 *) pHdr->sa,
807 psessionEntry, FALSE);
808 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
809 }
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530810 goto free;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800811 }
812 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700813
814 /// Check if there exists pre-auth context for this STA
815 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
816 if (pAuthNode)
817 {
818 /// Pre-auth context exists for the STA
gaurank kathpalia66414892018-03-21 20:24:39 +0530819 if (pAuthNode->seqNo != currSeqNo)
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 {
821 /**
822 * STA is initiating brand-new Authentication
823 * sequence after local Auth Response timeout.
824 * Or STA retrying to transmit First Auth frame due to packet drop OTA
825 * Delete Pre-auth node and fall through.
826 */
827 if(pAuthNode->fTimerStarted)
828 {
829 limDeactivateAndChangePerStaIdTimer(pMac,
830 eLIM_AUTH_RSP_TIMER,
831 pAuthNode->authNodeIdx);
832 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530833 PELOGE(limLog(pMac, LOGE, FL("STA is initiating brand-new "
834 "Authentication ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 limDeletePreAuthNode(pMac,
836 pHdr->sa);
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 /**
838 * SAP Mode:Disassociate the station and
839 * delete its entry if we have its entry
840 * already and received "auth" from the
841 * same station.
842 */
843
844 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
845 {
846 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
847
848 if (NULL == pStaDs)
849 continue;
850
851 if (pStaDs->valid)
852 {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530853 if (vos_mem_compare((tANI_U8 *) &pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 (tANI_U8 *) &(pHdr->sa), (tANI_U8) (sizeof(tSirMacAddr))) )
855 break;
856 }
Edhar, Mahesh Kumar29013e82014-02-05 10:38:08 +0530857
858 pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 }
860
Abhishek Singhe9417492014-09-25 15:55:36 +0530861 if (NULL != pStaDs
862#ifdef WLAN_FEATURE_11W
863 && !pStaDs->rmfEnabled
864#endif
865 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 {
Abhishek Singh0496a522015-12-14 23:39:23 -0800867 PELOGE(limLog(pMac, LOGE, FL("lim Delete Station "
868 "Context (staId: %d, assocId: %d) "),pStaDs->staIndex,
869 assocId);)
870 limSendDeauthMgmtFrame(pMac,
871 eSIR_MAC_UNSPEC_FAILURE_REASON, (tANI_U8 *) pAuthNode->peerMacAddr, psessionEntry, FALSE);
872 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530873 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 }
876 else
877 {
878 /*
879 * This can happen when first authentication frame is received
880 * but ACK lost at STA side, in this case 2nd auth frame is already
881 * in transmission queue
882 * */
Abhishek Singh208848c2013-12-18 19:02:52 +0530883 PELOGE(limLog(pMac, LOGE, FL("STA is initiating "
884 "Authentication after ACK lost..."));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530885 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 }
887 }
888 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
889 (tANI_U32 *) &maxNumPreAuth) != eSIR_SUCCESS)
890 {
891 /**
892 * Could not get MaxNumPreAuth
893 * from CFG. Log error.
894 */
895 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700896 FL("could not retrieve MaxNumPreAuth"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 }
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530898
899 if (pMac->lim.gLimNumPreAuthContexts == maxNumPreAuth &&
900 !limDeleteOpenAuthPreAuthNode(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530902 PELOGE(limLog(pMac, LOGE, FL("Max number of "
903 "preauth context reached"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 /**
905 * Maximum number of pre-auth contexts
906 * reached. Send Authentication frame
907 * with unspecified failure
908 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530909 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530911 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530913 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 eSIR_MAC_UNSPEC_FAILURE_STATUS;
915
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530916 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700917 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530918 LIM_NO_WEP_IN_FC,
919 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700920
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530921 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 }
923 /// No Pre-auth context exists for the STA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 if (limIsAuthAlgoSupported(
925 pMac,
926 (tAniAuthType)
927 pRxAuthFrameBody->authAlgoNumber, psessionEntry))
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 {
929 switch (pRxAuthFrameBody->authAlgoNumber)
930 {
931 case eSIR_OPEN_SYSTEM:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700932 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_OPEN_SYSTEM ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 /// Create entry for this STA in pre-auth list
934 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
935 if (pAuthNode == NULL)
936 {
937 // Log error
938 limLog(pMac, LOGW,
939 FL("Max pre-auth nodes reached "));
940 limPrintMacAddr(pMac, pHdr->sa, LOGW);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530941 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 }
943
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530944 limLog(pMac, LOG1,
945 FL("Alloc new data: peer "MAC_ADDRESS_STR),
946 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700947
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530948 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
949 pHdr->sa,
950 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700951
952 pAuthNode->mlmState =
953 eLIM_MLM_AUTHENTICATED_STATE;
954 pAuthNode->authType = (tAniAuthType)
955 pRxAuthFrameBody->authAlgoNumber;
956 pAuthNode->fSeen = 0;
957 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530958 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
959 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530960 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 limAddPreAuthNode(pMac, pAuthNode);
962
963 /**
964 * Send Authenticaton frame with Success
965 * status code.
966 */
967
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530968 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530970 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530972 authFrame->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530974 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530976 LIM_NO_WEP_IN_FC,
977 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978
979 /// Send Auth indication to SME
980
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530981 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 (tANI_U8 *) pHdr->sa,
983 sizeof(tSirMacAddr));
984 mlmAuthInd.authType = (tAniAuthType)
985 pRxAuthFrameBody->authAlgoNumber;
986 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
987
988 limPostSmeMessage(pMac,
989 LIM_MLM_AUTH_IND,
990 (tANI_U32 *) &mlmAuthInd);
991 break;
992
993 case eSIR_SHARED_KEY:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700994 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_SHARED_KEY ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
996 {
997 val = psessionEntry->privacy;
998 }
999 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1001 &val) != eSIR_SUCCESS)
1002 {
1003 /**
1004 * Could not get Privacy option
1005 * from CFG. Log error.
1006 */
1007 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001008 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 }
1010 cfgPrivacyOptImp = (tANI_U8)val;
1011 if (!cfgPrivacyOptImp)
1012 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301013 // Log error
1014 PELOGE(limLog(pMac, LOGE,
1015 FL("received Auth frame for unsupported auth algorithm %d "
1016 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
1017 MAC_ADDR_ARRAY(pHdr->sa));)
1018
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 /**
1020 * Authenticator does not have WEP
1021 * implemented.
1022 * Reject by sending Authentication frame
1023 * with Auth algorithm not supported status
1024 * code.
1025 */
1026
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301027 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001028 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301029 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301031 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1033
1034 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301035 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301037 LIM_NO_WEP_IN_FC,
1038 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001039
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301040 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 }
1042 else
1043 {
1044 // Create entry for this STA
1045 //in pre-auth list
1046 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1047 if (pAuthNode == NULL)
1048 {
1049 // Log error
1050 limLog(pMac, LOGW,
1051 FL("Max pre-auth nodes reached "));
1052 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1053
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301054 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 }
1056
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301057 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
1058 pHdr->sa,
1059 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001060
1061 pAuthNode->mlmState =
1062 eLIM_MLM_WT_AUTH_FRAME3_STATE;
1063 pAuthNode->authType =
1064 (tAniAuthType)
1065 pRxAuthFrameBody->authAlgoNumber;
1066 pAuthNode->fSeen = 0;
1067 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301068 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1069 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301070 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 limAddPreAuthNode(pMac, pAuthNode);
1072
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301073 limLog(pMac, LOG1,
1074 FL("Alloc new data: id %d peer "MAC_ADDRESS_STR),
1075 pAuthNode->authNodeIdx, MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001076
1077 /// Create and activate Auth Response timer
1078 if (tx_timer_change_context(&pAuthNode->timer, pAuthNode->authNodeIdx) != TX_SUCCESS)
1079 {
1080 /// Could not start Auth response timer.
1081 // Log error
1082 limLog(pMac, LOGP,
1083 FL("Unable to chg context auth response timer for peer "));
1084 limPrintMacAddr(pMac, pHdr->sa, LOGP);
1085
1086 /**
1087 * Send Authenticaton frame with
1088 * unspecified failure status code.
1089 */
1090
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301091 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301093 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301095 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 eSIR_MAC_UNSPEC_FAILURE_STATUS;
1097
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301098 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301100 LIM_NO_WEP_IN_FC,
1101 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001102
1103 limDeletePreAuthNode(pMac, pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301104 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 }
1106
1107 limActivateAuthRspTimer(pMac, pAuthNode);
1108
1109 pAuthNode->fTimerStarted = 1;
1110
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301111 /*
1112 * get random bytes and use as challenge text
1113 */
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301114 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 -07001115 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301116 limLog(pMac, LOGE,FL("Challenge text "
1117 "preparation failed in limProcessAuthFrame"));
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301118 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 }
1120
1121 pChallenge = pAuthNode->challengeText;
1122
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301123 vos_mem_copy(pChallenge,
1124 (tANI_U8 *) challengeTextArray,
1125 sizeof(challengeTextArray));
Jeff Johnson295189b2012-06-20 16:38:30 -07001126
1127 /**
1128 * Sending Authenticaton frame with challenge.
1129 */
1130
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301131 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301133 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301135 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 eSIR_MAC_SUCCESS_STATUS;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301137 authFrame->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301138 authFrame->length = SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301139 vos_mem_copy(authFrame->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 pAuthNode->challengeText,
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301141 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -07001142
1143 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301144 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301146 LIM_NO_WEP_IN_FC,
1147 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 } // if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1149
1150 break;
1151
1152 default:
Abhishek Singh208848c2013-12-18 19:02:52 +05301153 // Log error
1154 PELOGE( limLog(pMac, LOGE,
1155 FL("received Auth frame for unsupported auth "
1156 "algorithm %d "MAC_ADDRESS_STR),
1157 pRxAuthFrameBody->authAlgoNumber,
1158 MAC_ADDR_ARRAY(pHdr->sa));)
1159
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 /**
1161 * Responding party does not support the
1162 * authentication algorithm requested by
1163 * sending party.
1164 * Reject by sending Authentication frame
1165 * with auth algorithm not supported status code
1166 */
1167
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301168 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301170 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001171 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301172 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1174
1175 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301176 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301178 LIM_NO_WEP_IN_FC,
1179 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001180
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301181 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 } // end switch(pRxAuthFrameBody->authAlgoNumber)
1183 } // if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1184 else
1185 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301186 // Log error
1187 PELOGE(limLog(pMac, LOGE,
1188 FL("received Authentication frame for unsupported auth "
1189 "algorithm %d "MAC_ADDRESS_STR),
1190 pRxAuthFrameBody->authAlgoNumber,
1191 MAC_ADDR_ARRAY(pHdr->sa));)
1192
Jeff Johnson295189b2012-06-20 16:38:30 -07001193 /**
1194 * Responding party does not support the
1195 * authentication algorithm requested by sending party.
1196 * Reject Authentication with StatusCode=13.
1197 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301198 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301200 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301202 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1204
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301205 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001206 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301207 LIM_NO_WEP_IN_FC,
1208 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001209
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301210 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 } //end if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1212 break;
1213
1214 case SIR_MAC_AUTH_FRAME_2:
1215 // AuthFrame 2
1216
1217 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME2_STATE)
1218 {
1219 /**
1220 * Received Authentication frame2 in an unexpected state.
1221 * Log error and ignore the frame.
1222 */
1223
1224 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301225 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 FL("received Auth frame2 from peer in state %d, addr "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301227 psessionEntry->limMlmState);
1228 limPrintMacAddr(pMac, pHdr->sa, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001229
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301230 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 }
1232
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301233 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1234 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1235 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001236 {
1237 /**
1238 * Received Authentication frame from an entity
1239 * other than one request was initiated.
1240 * Wait until Authentication Failure Timeout.
1241 */
1242
1243 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001244 PELOGW(limLog(pMac, LOGW,
Abhishek Singh208848c2013-12-18 19:02:52 +05301245 FL("received Auth frame2 from unexpected peer "
1246 MAC_ADDRESS_STR),
Mohit Khanna23863762012-09-11 17:40:09 -07001247 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001248
1249 break;
1250 }
1251
1252 if (pRxAuthFrameBody->authStatusCode ==
1253 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS)
1254 {
1255 /**
1256 * Interoperability workaround: Linksys WAP4400N is returning
1257 * wrong authType in OpenAuth response in case of
1258 * SharedKey AP configuration. Pretend we don't see that,
1259 * so upper layer can fallback to SharedKey authType,
1260 * and successfully connect to the AP.
1261 */
1262 if (pRxAuthFrameBody->authAlgoNumber !=
1263 pMac->lim.gpLimMlmAuthReq->authType)
1264 {
1265 pRxAuthFrameBody->authAlgoNumber =
1266 pMac->lim.gpLimMlmAuthReq->authType;
1267 }
1268 }
1269
1270 if (pRxAuthFrameBody->authAlgoNumber !=
1271 pMac->lim.gpLimMlmAuthReq->authType)
1272 {
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05301273 /*
1274 * Auth algo is open in rx auth frame when auth type is SAE and
1275 * PMK is cached as driver sent auth algo as open in tx frame
1276 * as well.
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 */
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05301278 if ((pMac->lim.gpLimMlmAuthReq->authType ==
1279 eSIR_AUTH_TYPE_SAE) && psessionEntry->sae_pmk_cached) {
1280 limLog(pMac, LOGW,
1281 FL("rx Auth frame2 auth algo %d in SAE PMK case"),
1282 pRxAuthFrameBody->authAlgoNumber);
1283 } else {
1284 /**
1285 * Received Authentication frame with an auth
1286 * algorithm other than one requested.
1287 * Wait until Authentication Failure Timeout.
1288 */
1289 // Log error
1290 PELOGW(limLog(pMac, LOGW,
1291 FL("received Auth frame2 for unexpected auth algo num %d "
1292 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
1293 MAC_ADDR_ARRAY(pHdr->sa));)
Abhinav Kumar0ee145b2019-09-12 20:13:58 +05301294 break;
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05301295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 }
1297
1298 if (pRxAuthFrameBody->authStatusCode ==
1299 eSIR_MAC_SUCCESS_STATUS)
1300 {
1301 if (pRxAuthFrameBody->authAlgoNumber ==
1302 eSIR_OPEN_SYSTEM)
1303 {
1304 psessionEntry->limCurrentAuthType = eSIR_OPEN_SYSTEM;
1305
1306 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1307
1308 if (pAuthNode == NULL)
1309 {
1310 // Log error
1311 limLog(pMac, LOGW,
1312 FL("Max pre-auth nodes reached "));
1313 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1314
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301315 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 }
1317
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301318 limLog(pMac, LOG1,
1319 FL("Alloc new data: peer "MAC_ADDRESS_STR),
1320 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001321
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301322 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1324 sizeof(tSirMacAddr));
1325 pAuthNode->fTimerStarted = 0;
1326 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301327 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1328 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301329 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 limAddPreAuthNode(pMac, pAuthNode);
1331
1332 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1333 pRxAuthFrameBody->authStatusCode,psessionEntry);
1334 } // if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1335 else
1336 {
1337 // Shared key authentication
1338
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1340 {
1341 val = psessionEntry->privacy;
1342 }
1343 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001344 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1345 &val) != eSIR_SUCCESS)
1346 {
1347 /**
1348 * Could not get Privacy option
1349 * from CFG. Log error.
1350 */
1351 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001352 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001353 }
1354 cfgPrivacyOptImp = (tANI_U8)val;
1355 if (!cfgPrivacyOptImp)
1356 {
1357 /**
1358 * Requesting STA does not have WEP implemented.
1359 * Reject with unsupported authentication algorithm
1360 * Status code and wait until auth failure timeout
1361 */
1362
1363 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001364 PELOGE( limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301365 FL("received Auth frame from peer for "
1366 "unsupported auth algo %d "
1367 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001368 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001369
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301370 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301372 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301374 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1376
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301377 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301379 LIM_NO_WEP_IN_FC,
1380 psessionEntry, eSIR_FALSE);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301381 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 }
1383 else
1384 {
1385
1386 if (pRxAuthFrameBody->type !=
1387 SIR_MAC_CHALLENGE_TEXT_EID)
1388 {
1389 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001390 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301391 FL("received Auth frame with invalid "
1392 "challenge text IE"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301394 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 }
1396
1397 /**
1398 * Check if there exists a key mappping key
1399 * for the STA that sent Authentication frame
1400 */
1401 pKeyMapEntry = limLookUpKeyMappings(
1402 pHdr->sa);
1403
1404 if (pKeyMapEntry)
1405 {
1406 if (pKeyMapEntry->key == NULL)
1407 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301408 // Log error
1409 PELOGE(limLog(pMac, LOGE,
1410 FL("received Auth frame from peer when "
1411 "key mapping key is NULL"MAC_ADDRESS_STR),
1412 MAC_ADDR_ARRAY(pHdr->sa));)
1413
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 /**
1415 * Key Mapping entry has null key.
1416 * Send Auth frame with
1417 * challenge failure status code
1418 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301419 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301421 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301423 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1425
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301426 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301428 LIM_NO_WEP_IN_FC,
1429 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001430
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 limRestoreFromAuthState(pMac, eSIR_SME_NO_KEY_MAPPING_KEY_FOR_PEER,
1432 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1433
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301434 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 } // if (pKeyMapEntry->key == NULL)
1436 else
1437 {
1438 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1439 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1440 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1441 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1442 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1443 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301444 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301445 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301447 pRxAuthFrameBody->length);
1448
1449 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1450 LIM_ENCR_AUTH_INFO_LEN);
1451 if (!encrAuthFrame) {
1452 limLog(pMac, LOGE, FL("failed to allocate memory"));
1453 goto free;
1454 }
1455 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1456 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001457
1458 limEncryptAuthFrame(pMac, 0,
1459 pKeyMapEntry->key,
1460 plainBody,
1461 encrAuthFrame,key_length);
1462
1463 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001464 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001465
1466 limSendAuthMgmtFrame(pMac,
1467 (tpSirMacAuthFrameBody) encrAuthFrame,
1468 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301469 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301470 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001471
1472 break;
1473 } // end if (pKeyMapEntry->key == NULL)
1474 } // if (pKeyMapEntry)
1475 else
1476 {
1477 if (wlan_cfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID,
1478 &val) != eSIR_SUCCESS)
1479 {
1480 /**
1481 * Could not get Default keyId
1482 * from CFG. Log error.
1483 */
1484 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001485 FL("could not retrieve Default keyId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 }
1487 keyId = (tANI_U8)val;
1488
1489 val = SIR_MAC_KEY_LENGTH;
1490
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1492 {
1493 tpSirKeys pKey;
1494 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301495 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 }
1497 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
1499 defaultKey,
1500 &val)
1501 != eSIR_SUCCESS)
1502 {
1503 /// Could not get Default key from CFG.
1504 //Log error.
1505 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001506 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001507
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301508 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301510 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301512 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1514
1515 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301516 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301518 LIM_NO_WEP_IN_FC,
1519 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001520
1521 limRestoreFromAuthState(pMac, eSIR_SME_INVALID_WEP_DEFAULT_KEY,
1522 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1523
1524 break;
1525 }
1526 key_length=val;
1527 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1528 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1529 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1530 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1531 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1532 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301533 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301534 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301536 pRxAuthFrameBody->length);
1537
1538 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1539 LIM_ENCR_AUTH_INFO_LEN);
1540 if (!encrAuthFrame) {
1541 limLog(pMac, LOGE, FL("failed to allocate memory"));
1542 goto free;
1543 }
1544 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1545 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001546
1547 limEncryptAuthFrame(pMac, keyId,
1548 defaultKey,
1549 plainBody,
1550 encrAuthFrame,key_length);
1551
1552 psessionEntry->limMlmState =
1553 eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001554 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001555
1556 limSendAuthMgmtFrame(pMac,
1557 (tpSirMacAuthFrameBody) encrAuthFrame,
1558 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301559 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301560 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001561
1562 break;
1563 } // end if (pKeyMapEntry)
1564 } // end if (!wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1565 } // end if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1566 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1567 else
1568 {
1569 /**
1570 * Authentication failure.
1571 * Return Auth confirm with received failure code to SME
1572 */
1573
1574 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001575 PELOGE(limLog(pMac, LOGE,
1576 FL("received Auth frame from peer with failure code %d "
1577 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1578 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001579
1580 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1581 pRxAuthFrameBody->authStatusCode,psessionEntry);
1582 } // end if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1583
1584 break;
1585
1586 case SIR_MAC_AUTH_FRAME_3:
1587 // AuthFrame 3
1588
1589 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1590 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301591 // Log error
1592 PELOGE(limLog(pMac, LOGE,
1593 FL("received Auth frame3 from peer with auth algo "
1594 "number %d "MAC_ADDRESS_STR),
1595 pRxAuthFrameBody->authAlgoNumber,
1596 MAC_ADDR_ARRAY(pHdr->sa));)
1597
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 /**
1599 * Received Authentication frame3 with algorithm other than
1600 * Shared Key authentication type. Reject with Auth frame4
1601 * with 'out of sequence' status code.
1602 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301603 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1604 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301606 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1608
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301609 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301611 LIM_NO_WEP_IN_FC,
1612 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001613
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301614 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 }
1616
1617 if (psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE ||
1618 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
1619 {
1620 /**
1621 * Check if wep bit was set in FC. If not set,
1622 * reject with Authentication frame4 with
1623 * 'challenge failure' status code.
1624 */
1625 if (!pHdr->fc.wep)
1626 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301627 // Log error
1628 PELOGE(limLog(pMac, LOGE,
1629 FL("received Auth frame3 from peer with no WEP bit "
1630 "set "MAC_ADDRESS_STR),
1631 MAC_ADDR_ARRAY(pHdr->sa));)
1632
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 /// WEP bit is not set in FC of Auth Frame3
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301634 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1635 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301637 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1639
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301640 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301642 LIM_NO_WEP_IN_FC,
1643 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001644
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301645 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 }
1647
1648 pAuthNode = limSearchPreAuthList(pMac,
1649 pHdr->sa);
1650 if (pAuthNode == NULL)
1651 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301652 // Log error
1653 PELOGE(limLog(pMac, LOGW,
1654 FL("received AuthFrame3 from peer that has no "
1655 "preauth context "MAC_ADDRESS_STR),
1656 MAC_ADDR_ARRAY(pHdr->sa));)
1657
Jeff Johnson295189b2012-06-20 16:38:30 -07001658 /**
1659 * No 'pre-auth' context exists for
1660 * this STA that sent an Authentication
1661 * frame3.
1662 * Send Auth frame4 with 'out of sequence'
1663 * status code.
1664 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301665 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1666 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001667 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301668 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1670
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301671 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301673 LIM_NO_WEP_IN_FC,
1674 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001675
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301676 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001677 }
1678
1679 if (pAuthNode->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)
1680 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301681 // Log error
1682 limLog(pMac, LOGW,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301683 FL("auth response timer timedout for peer "
1684 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 /**
1686 * Received Auth Frame3 after Auth Response timeout.
1687 * Reject by sending Auth Frame4 with
1688 * Auth respone timeout Status Code.
1689 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301690 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1691 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301693 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS;
1695
1696 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301697 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301699 LIM_NO_WEP_IN_FC,
1700 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001701
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 /// Delete pre-auth context of STA
1703 limDeletePreAuthNode(pMac,
1704 pHdr->sa);
1705
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301706 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 } // end switch (pAuthNode->mlmState)
1708
1709 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1710 {
1711 /**
1712 * Received Authenetication Frame 3 with status code
1713 * other than success. Wait until Auth response timeout
1714 * to delete STA context.
1715 */
1716
1717 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001718 PELOGE(limLog(pMac, LOGE,
1719 FL("received Auth frame3 from peer with status code %d "
1720 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1721 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001722
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301723 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 }
1725
1726 /**
1727 * Check if received challenge text is same as one sent in
1728 * Authentication frame3
1729 */
1730
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301731 if (vos_mem_compare(pRxAuthFrameBody->challengeText,
1732 pAuthNode->challengeText,
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301733 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH))
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 {
1735 /// Challenge match. STA is autheticated !
1736
1737 /// Delete Authentication response timer if running
1738 limDeactivateAndChangePerStaIdTimer(pMac,
1739 eLIM_AUTH_RSP_TIMER,
1740 pAuthNode->authNodeIdx);
1741
1742 pAuthNode->fTimerStarted = 0;
1743 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1744
1745 /**
1746 * Send Authentication Frame4 with 'success' Status Code.
1747 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301748 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1749 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001750 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301751 authFrame->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001752
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301753 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301755 LIM_NO_WEP_IN_FC,
1756 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001757
1758 /// Send Auth indication to SME
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301759 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 (tANI_U8 *) pHdr->sa,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301761 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001762 mlmAuthInd.authType = (tAniAuthType)
1763 pRxAuthFrameBody->authAlgoNumber;
1764 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
1765
1766 limPostSmeMessage(pMac,
1767 LIM_MLM_AUTH_IND,
1768 (tANI_U32 *) &mlmAuthInd);
1769
1770 break;
1771 }
1772 else
1773 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301774 // Log error
1775 PELOGE( limLog(pMac, LOGW,
1776 FL("Challenge failure for peer "
1777 MAC_ADDRESS_STR),
1778 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 /**
1780 * Challenge Failure.
1781 * Send Authentication frame4 with 'challenge failure'
1782 * status code and wait until Auth response timeout to
1783 * delete STA context.
1784 */
1785
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301786 authFrame->authAlgoNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001787 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301788 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001789 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301790 authFrame->authStatusCode =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001791 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001792
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301793 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301795 LIM_NO_WEP_IN_FC,
1796 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001797
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301798 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 }
1800 } // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE || ...
1801
1802 break;
1803
1804 case SIR_MAC_AUTH_FRAME_4:
1805 // AuthFrame 4
1806 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE)
1807 {
1808 /**
1809 * Received Authentication frame4 in an unexpected state.
1810 * Log error and ignore the frame.
1811 */
1812
1813 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301814 limLog(pMac, LOG1,
Abhishek Singh208848c2013-12-18 19:02:52 +05301815 FL("received unexpected Auth frame4 from peer in state "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301816 "%d, addr "MAC_ADDRESS_STR), psessionEntry->limMlmState,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301817 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001818
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301819 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 }
1821
1822 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1823 {
1824 /**
1825 * Received Authentication frame4 with algorithm other than
1826 * Shared Key authentication type.
1827 * Wait until Auth failure timeout to report authentication
1828 * failure to SME.
1829 */
1830
1831 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001832 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301833 FL("received Auth frame4 from peer with invalid auth "
1834 "algo %d "MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001835 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001836
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301837 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 }
1839
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301840 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1841 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1842 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 {
1844 /**
1845 * Received Authentication frame from an entity
1846 * other than one to which request was initiated.
1847 * Wait until Authentication Failure Timeout.
1848 */
1849
1850 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001851 PELOGE(limLog(pMac, LOGW,
1852 FL("received Auth frame4 from unexpected peer "
1853 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001854
1855 break;
1856 }
1857
1858 if (pRxAuthFrameBody->authAlgoNumber !=
1859 pMac->lim.gpLimMlmAuthReq->authType)
1860 {
1861 /**
1862 * Received Authentication frame with an auth algorithm
1863 * other than one requested.
1864 * Wait until Authentication Failure Timeout.
1865 */
1866
Mohit Khanna23863762012-09-11 17:40:09 -07001867 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301868 FL("received Authentication frame from peer with "
1869 "invalid auth seq number %d "
1870 MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001871 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001872
1873 break;
1874 }
1875
1876 if (pRxAuthFrameBody->authStatusCode ==
1877 eSIR_MAC_SUCCESS_STATUS)
1878 {
1879 /**
1880 * Authentication Success !
1881 * Inform SME of same.
1882 */
1883 psessionEntry->limCurrentAuthType = eSIR_SHARED_KEY;
1884
1885 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1886 if (pAuthNode == NULL)
1887 {
1888 // Log error
1889 limLog(pMac, LOGW,
1890 FL("Max pre-auth nodes reached "));
1891 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1892
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301893 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301895 limLog(pMac, LOG1,
1896 FL("Alloc new data: peer " MAC_ADDRESS_STR),
1897 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001898
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301899 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1901 sizeof(tSirMacAddr));
1902 pAuthNode->fTimerStarted = 0;
1903 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301904 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1905 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301906 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 limAddPreAuthNode(pMac, pAuthNode);
1908
1909 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1910 pRxAuthFrameBody->authStatusCode,psessionEntry);
1911
1912 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1913 else
1914 {
1915 /**
1916 * Authentication failure.
1917 * Return Auth confirm with received failure code to SME
1918 */
1919
1920 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001921 PELOGE(limLog(pMac, LOGE, FL("Authentication failure from peer "
1922 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001923
1924 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1925 pRxAuthFrameBody->authStatusCode,psessionEntry);
1926 } // end if (pRxAuthFrameBody->Status == 0)
1927
1928 break;
1929
1930 default:
1931 /// Invalid Authentication Frame received. Ignore it.
1932
1933 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001934 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301935 FL("received Auth frame from peer with invalid auth seq "
1936 "number %d " MAC_ADDRESS_STR),
1937 pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001938 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001939
1940 break;
1941 } // end switch (pRxAuthFrameBody->authTransactionSeqNumber)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301942
1943free:
1944 if (authFrame)
1945 vos_mem_free(authFrame);
1946 if (rxAuthFrame)
1947 vos_mem_free(rxAuthFrame);
1948 if (encrAuthFrame)
1949 vos_mem_free(encrAuthFrame);
1950 if (plainBody)
1951 vos_mem_free(plainBody);
1952 if (challengeTextArray)
1953 vos_mem_free(challengeTextArray);
1954
Jeff Johnson295189b2012-06-20 16:38:30 -07001955} /*** end limProcessAuthFrame() ***/
1956
1957
1958
1959
1960
1961#ifdef WLAN_FEATURE_VOWIFI_11R
1962
1963/*----------------------------------------------------------------------
1964 *
1965 * Pass the received Auth frame. This is possibly the pre-auth from the
1966 * neighbor AP, in the same mobility domain.
1967 * This will be used in case of 11r FT.
1968 *
1969 * !!!! This is going to be renoved for the next checkin. We will be creating
1970 * the session before sending out the Auth. Thus when auth response
1971 * is received we will have a session in progress. !!!!!
1972 *----------------------------------------------------------------------
1973 */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001974tSirRetStatus limProcessAuthFrameNoSession(tpAniSirGlobal pMac, tANI_U8 *pBd, void *body)
Jeff Johnson295189b2012-06-20 16:38:30 -07001975{
1976 tpSirMacMgmtHdr pHdr;
1977 tpPESession psessionEntry = NULL;
1978 tANI_U8 *pBody;
1979 tANI_U16 frameLen;
1980 tSirMacAuthFrameBody rxAuthFrame;
1981 tSirMacAuthFrameBody *pRxAuthFrameBody = NULL;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001982 tSirRetStatus ret_status = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001983
1984 pHdr = WDA_GET_RX_MAC_HEADER(pBd);
1985 pBody = WDA_GET_RX_MPDU_DATA(pBd);
1986 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd);
1987
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05301988 /*
1989 * since, roaming is not supported in sta + mon scc, ignore
1990 * pre-auth when capture on monitor mode is started
1991 */
1992 if (vos_check_monitor_state())
1993 {
1994 limLog(pMac, LOG1, FL("Ignore pre-auth frame in monitor mode"));
1995 return eSIR_FAILURE;
1996 }
1997
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301998 limLog(pMac, LOG1, FL("Auth Frame Received: BSSID " MAC_ADDRESS_STR
1999 " (RSSI %d)"),MAC_ADDR_ARRAY(pHdr->bssId),
2000 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 // Check for the operating channel and see what needs to be done next.
2002 psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
2003 if (psessionEntry == NULL)
2004 {
Abhishek Singh208848c2013-12-18 19:02:52 +05302005 limLog(pMac, LOGE, FL("Error: Unable to find session id while in "
2006 "pre-auth phase for FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 return eSIR_FAILURE;
2008 }
2009
2010 if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL)
2011 {
Abhishek Singh208848c2013-12-18 19:02:52 +05302012 limLog(pMac, LOGE, FL("Error: No FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 // No FT in progress.
2014 return eSIR_FAILURE;
2015 }
2016
2017 if (frameLen == 0)
2018 {
Abhishek Singh208848c2013-12-18 19:02:52 +05302019 limLog(pMac, LOGE, FL("Error: Frame len = 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 return eSIR_FAILURE;
2021 }
2022#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002023 limPrintMacAddr(pMac, pHdr->bssId, LOG2);
2024 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOG2);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002025 limLog(pMac,LOG2,FL("seqControl 0x%X"),
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002026 ((pHdr->seqControl.seqNumHi << 8) |
2027 (pHdr->seqControl.seqNumLo << 4) |
2028 (pHdr->seqControl.fragNum)));
Jeff Johnson295189b2012-06-20 16:38:30 -07002029#endif
2030
2031 // Check that its the same bssId we have for preAuth
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05302032 if (!vos_mem_compare(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
2033 pHdr->bssId, sizeof( tSirMacAddr )))
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05302035 limLog(pMac, LOGE, FL("Error: NOT same bssid as preauth BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 // In this case SME if indeed has triggered a
2037 // pre auth it will time out.
2038 return eSIR_FAILURE;
2039 }
2040
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002041 if (eANI_BOOLEAN_TRUE ==
2042 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed)
2043 {
2044 /*
2045 * This is likely a duplicate for the same pre-auth request.
2046 * PE/LIM already posted a response to SME. Hence, drop it.
2047 * TBD:
2048 * 1) How did we even receive multiple auth responses?
2049 * 2) Do we need to delete pre-auth session? Suppose we
2050 * previously received an auth resp with failure which
2051 * would not have created the session and forwarded to SME.
2052 * And, we subsequently received an auth resp with success
2053 * which would have created the session. This will now be
2054 * dropped without being forwarded to SME! However, it is
2055 * very unlikely to receive auth responses from the same
2056 * AP with different reason codes.
2057 * NOTE: return eSIR_SUCCESS so that the packet is dropped
2058 * as this was indeed a response from the BSSID we tried to
2059 * pre-auth.
2060 */
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002061 PELOGE(limLog(pMac,LOG1,"Auth rsp already posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07002062 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002063 pMac->ft.ftPEContext.pftSessionEntry););
2064 return eSIR_SUCCESS;
2065 }
2066 else
2067 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002068 PELOGE(limLog(pMac,LOGW,"Auth rsp not yet posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07002069 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002070 pMac->ft.ftPEContext.pftSessionEntry););
2071 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
2072 eANI_BOOLEAN_TRUE;
2073 }
2074
Jeff Johnson295189b2012-06-20 16:38:30 -07002075#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002076 limLog(pMac, LOG1, FL("Pre-Auth response received from neighbor"));
2077 limLog(pMac, LOG1, FL("Pre-Auth done state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002078#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302079
2080 limLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
2081 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
2082
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 // Stopping timer now, that we have our unicast from the AP
2084 // of our choice.
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302085 if (!pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
2086 limDeactivateAndChangeTimer(pMac, eLIM_FT_PREAUTH_RSP_TIMER);
2087
2088#ifdef WLAN_FEATURE_LFR_MBB
2089 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
2090 limDeactivateAndChangeTimer(pMac, eLIM_PREAUTH_MBB_RSP_TIMER);
2091#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002092
2093
2094 // Save off the auth resp.
2095 if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame) != eSIR_SUCCESS))
2096 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05302097 limLog(pMac, LOGE, FL("failed to convert Auth frame to struct"));
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302098
2099#ifdef WLAN_FEATURE_LFR_MBB
2100 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
2101 lim_handle_pre_auth_mbb_rsp(pMac, eSIR_FAILURE, psessionEntry);
2102 return eSIR_FAILURE;
2103 }
2104#endif
2105
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
2107 return eSIR_FAILURE;
2108 }
2109 pRxAuthFrameBody = &rxAuthFrame;
2110
2111#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002112 PELOGE(limLog(pMac, LOG1,
2113 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
2115 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
2116 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
2117#endif
2118
2119 switch (pRxAuthFrameBody->authTransactionSeqNumber)
2120 {
2121 case SIR_MAC_AUTH_FRAME_2:
2122 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
2123 {
2124#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08002125 PELOGE(limLog( pMac, LOGE, "Auth status code received is %d",
2126 (tANI_U32) pRxAuthFrameBody->authStatusCode););
Jeff Johnson295189b2012-06-20 16:38:30 -07002127#endif
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08002128 if (eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS == pRxAuthFrameBody->authStatusCode)
2129 ret_status = eSIR_LIM_MAX_STA_REACHED_ERROR;
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 }
2131 else
2132 {
2133 ret_status = eSIR_SUCCESS;
2134 }
2135 break;
2136
2137 default:
2138#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002139 PELOGE(limLog( pMac, LOGE, "Seq. no incorrect expected 2 received %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber);)
2141#endif
2142 break;
2143 }
2144
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302145#ifdef WLAN_FEATURE_LFR_MBB
2146 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
2147 lim_handle_pre_auth_mbb_rsp(pMac, ret_status, psessionEntry);
2148 return ret_status;
2149 }
2150#endif
2151
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 // Send the Auth response to SME
2153 limHandleFTPreAuthRsp(pMac, ret_status, pBody, frameLen, psessionEntry);
2154
2155 return ret_status;
2156}
2157
2158#endif /* WLAN_FEATURE_VOWIFI_11R */
2159