blob: 58583e0c914b66f706942e2407841318e1c1cadc [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
gaurank kathpalia66414892018-03-21 20:24:39 +05302 * Copyright (c) 2011-2015, 2017-2018 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080028/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * This file limProcessAuthFrame.cc contains the code
30 * for processing received Authentication Frame.
31 * Author: Chandra Modumudi
32 * Date: 03/11/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 * 05/12/2010 js To support Shared key authentication at AP side
37 *
38 */
39
40#include "wniApi.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053041#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070042#include "aniGlobal.h"
43#include "cfgApi.h"
44
45#include "utilsApi.h"
46#include "limUtils.h"
47#include "limAssocUtils.h"
48#include "limSecurityUtils.h"
49#include "limSerDesUtils.h"
50#ifdef WLAN_FEATURE_VOWIFI_11R
51#include "limFT.h"
52#endif
53#include "vos_utils.h"
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053054#ifdef WLAN_FEATURE_LFR_MBB
55#include "lim_mbb.h"
56#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070057
58
59/**
60 * isAuthValid
61 *
62 *FUNCTION:
63 * This function is called by limProcessAuthFrame() upon Authentication
64 * frame reception.
65 *
66 *LOGIC:
67 * This function is used to test validity of auth frame:
68 * - AUTH1 and AUTH3 must be received in AP mode
69 * - AUTH2 and AUTH4 must be received in STA mode
70 * - AUTH3 and AUTH4 must have challenge text IE, that is,'type' field has been set to
71 * SIR_MAC_CHALLENGE_TEXT_EID by parser
72 * -
73 *
74 *ASSUMPTIONS:
75 *
76 *NOTE:
77 *
78 * @param *auth - Pointer to extracted auth frame body
79 *
80 * @return 0 or 1 (Valid)
81 */
82
83
84static inline unsigned int isAuthValid(tpAniSirGlobal pMac, tpSirMacAuthFrameBody auth,tpPESession sessionEntry) {
85 unsigned int valid;
86 valid=1;
87
88 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_1)||
89 (auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)) &&
90 ((sessionEntry->limSystemRole == eLIM_STA_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)))
91 valid=0;
92
93 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_2)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&&
94 ((sessionEntry->limSystemRole == eLIM_AP_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)))
95 valid=0;
96
97 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&&
98 (auth->type!=SIR_MAC_CHALLENGE_TEXT_EID)&&(auth->authAlgoNumber != eSIR_SHARED_KEY))
99 valid=0;
100
101 return valid;
102}
103
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530104#ifdef WLAN_FEATURE_SAE
105/**
106 * lim_process_sae_auth_frame()-Process SAE authentication frame
107 * @mac_ctx: MAC context
108 * @rx_pkt_info: Rx packet
109 * @pe_session: PE session
110 *
111 * Return: None
112 */
113static void lim_process_sae_auth_frame(tpAniSirGlobal mac_ctx,
114 uint8_t *rx_pkt_info,
115 tpPESession pe_session)
116{
117 tpSirMacMgmtHdr mac_hdr;
118
119 mac_hdr = WDA_GET_RX_MAC_HEADER(rx_pkt_info);
120
121 limLog(mac_ctx, LOG1, FL("Received SAE Auth frame type %d subtype %d"),
122 mac_hdr->fc.type, mac_hdr->fc.subType);
123
124 if (pe_session->limMlmState != eLIM_MLM_WT_SAE_AUTH_STATE)
125 limLog(mac_ctx, LOGE,
126 FL("received SAE auth response in unexpected state %x"),
127 pe_session->limMlmState);
128
129 limSendSmeMgmtFrameInd(mac_ctx, pe_session->peSessionId,
130 rx_pkt_info, pe_session,
131 WDA_GET_RX_RSSI_DB(rx_pkt_info));
132}
133#else
134static void lim_process_sae_auth_frame(tpAniSirGlobal mac_ctx,
135 uint8_t *rx_pkt_info,
136 tpPESession pe_session)
137{}
138#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700139
140/**
141 * limProcessAuthFrame
142 *
143 *FUNCTION:
144 * This function is called by limProcessMessageQueue() upon Authentication
145 * frame reception.
146 *
147 *LOGIC:
148 * This function processes received Authentication frame and responds
149 * with either next Authentication frame in sequence to peer MAC entity
150 * or LIM_MLM_AUTH_IND on AP or LIM_MLM_AUTH_CNF on STA.
151 *
152 *ASSUMPTIONS:
153 *
154 *NOTE:
155 * 1. Authentication failures are reported to SME with same status code
156 * received from the peer MAC entity.
157 * 2. Authentication frame2/4 received with alogirthm number other than
158 * one requested in frame1/3 are logged with an error and auth confirm
159 * will be sent to SME only after auth failure timeout.
160 * 3. Inconsistency in the spec:
161 * On receiving Auth frame2, specs says that if WEP key mapping key
162 * or default key is NULL, Auth frame3 with a status code 15 (challenge
163 * failure to be returned to peer entity. However, section 7.2.3.10,
164 * table 14 says that status code field is 'reserved' for frame3 !
165 * In the current implementation, Auth frame3 is returned with status
166 * code 15 overriding section 7.2.3.10.
167 * 4. If number pre-authentications reach configrable max limit,
168 * Authentication frame with 'unspecified failure' status code is
169 * returned to requesting entity.
170 *
171 * @param pMac - Pointer to Global MAC structure
172 * @param *pRxPacketInfo - A pointer to Rx packet info structure
173 * @return None
174 */
175
176void
177limProcessAuthFrame(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tpPESession psessionEntry)
178{
179 tANI_U8 *pBody, keyId, cfgPrivacyOptImp,
180 defaultKey[SIR_MAC_KEY_LENGTH],
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530181 *encrAuthFrame = NULL,
182 *plainBody = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700183 tANI_U16 frameLen;
184 //tANI_U32 authRspTimeout, maxNumPreAuth, val;
185 tANI_U32 maxNumPreAuth, val;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530186 tSirMacAuthFrameBody *pRxAuthFrameBody,
187 *rxAuthFrame = NULL,
188 *authFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 tpSirMacMgmtHdr pHdr;
190 tCfgWepKeyEntry *pKeyMapEntry = NULL;
191 struct tLimPreAuthNode *pAuthNode;
192 tLimMlmAuthInd mlmAuthInd;
193 tANI_U8 decryptResult;
194 tANI_U8 *pChallenge;
195 tANI_U32 key_length=8;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530196 tANI_U8 *challengeTextArray = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 tpDphHashNode pStaDs = NULL;
198 tANI_U16 assocId = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530199 tANI_U16 currSeqNo = 0;
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530200 tANI_U16 auth_alg = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 /* Added For BT -AMP support */
202 // Get pointer to Authentication frame header and body
203
204
205 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
206 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700207
208 if (!frameLen)
209 {
210 // Log error
211 limLog(pMac, LOGE,
212 FL("received Authentication frame with no body from "));
213 limPrintMacAddr(pMac, pHdr->sa, LOGE);
214
215 return;
216 }
217
218 if (limIsGroupAddr(pHdr->sa))
219 {
220 // Received Auth frame from a BC/MC address
221 // Log error and ignore it
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530222 limLog(pMac, LOGE,
223 FL("received Auth frame from a BC/MC address - "));
224 limPrintMacAddr(pMac, pHdr->sa, LOGE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700225
226 return;
227 }
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530228 currSeqNo = (pHdr->seqControl.seqNumHi << 4) | (pHdr->seqControl.seqNumLo);
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530229 limLog(pMac, LOG1,
230 FL("Sessionid: %d System role : %d limMlmState: %d :Auth "
231 "Frame Received: BSSID: "MAC_ADDRESS_STR " (RSSI %d)"),
232 psessionEntry->peSessionId, psessionEntry->limSystemRole,
233 psessionEntry->limMlmState, MAC_ADDR_ARRAY(pHdr->bssId),
234 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo)));
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800235
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
237
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530238 auth_alg = *(uint16_t *)pBody;
239 limLog(pMac, LOG1, FL("auth_alg %d "), auth_alg);
240
Jeff Johnsone7245742012-09-05 17:12:55 -0700241 //PELOG3(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG3, (tANI_U8*)pBd, ((tpHalBufDesc) pBd)->mpduDataOffset + frameLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700242
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800243 //Restore default failure timeout
244 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
245 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530246 limLog(pMac, LOG1, FL("Restore default failure timeout"));
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800247 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
248 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
249 }
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530250
251 rxAuthFrame = vos_mem_malloc(sizeof(tSirMacAuthFrameBody));
252 if (!rxAuthFrame) {
253 limLog(pMac, LOGE, FL("Failed to allocate memory"));
254 return;
255 }
256
257 authFrame = vos_mem_malloc(sizeof(tSirMacAuthFrameBody));
258 if (!authFrame) {
259 limLog(pMac, LOGE, FL("failed to allocate memory"));
260 goto free;
261 }
262
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530263 plainBody = vos_mem_malloc(LIM_ENCR_AUTH_BODY_LEN);
264 if (!plainBody) {
265 limLog(pMac, LOGE, FL("failed to allocate memory"));
266 goto free;
267 }
268
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +0530269 challengeTextArray = vos_mem_malloc(SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530270 if(!challengeTextArray) {
271 limLog(pMac, LOGE, FL("failed to allocate memory"));
272 goto free;
273 }
274
275 vos_mem_set(rxAuthFrame, sizeof(tSirMacAuthFrameBody), 0);
276 vos_mem_set(authFrame, sizeof(tSirMacAuthFrameBody), 0);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530277 vos_mem_set(plainBody, LIM_ENCR_AUTH_BODY_LEN, 0);
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +0530278 vos_mem_set(challengeTextArray, SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280 /// Determine if WEP bit is set in the FC or received MAC header
281 if (pHdr->fc.wep)
282 {
283 /**
284 * WEP bit is set in FC of MAC header.
285 */
286
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 // If TKIP counter measures enabled issue Deauth frame to station
288 if ((psessionEntry->bTkipCntrMeasActive) && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
289 {
290 PELOGE( limLog(pMac, LOGE,
291 FL("Tkip counter measures Enabled, sending Deauth frame to")); )
292 limPrintMacAddr(pMac, pHdr->sa, LOGE);
293
294 limSendDeauthMgmtFrame( pMac, eSIR_MAC_MIC_FAILURE_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800295 pHdr->sa, psessionEntry, FALSE );
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530296 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700298
299 // Extract key ID from IV (most 2 bits of 4th byte of IV)
300
301 keyId = (*(pBody + 3)) >> 6;
302
303 /**
304 * On STA in infrastructure BSS, Authentication frames received
305 * with WEP bit set in the FC must be rejected with challenge
306 * failure status code (wierd thing in the spec - this should have
307 * been rejected with unspecified failure or unexpected assertion
308 * of wep bit (this status code does not exist though) or
309 * Out-of-sequence-Authentication-Frame status code.
310 */
311
312 if (psessionEntry->limSystemRole == eLIM_STA_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)
313 {
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530314 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
315 authFrame->authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
316 authFrame->authStatusCode = eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Abhishek Singh208848c2013-12-18 19:02:52 +0530317 // Log error
318 PELOGE(limLog(pMac, LOGE,
319 FL("received Authentication frame with wep bit set on "
320 "role=%d "MAC_ADDRESS_STR),
321 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pHdr->sa) );)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530322 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530324 LIM_NO_WEP_IN_FC,
325 psessionEntry, eSIR_FALSE);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530326 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 }
328
Vignesh Viswanathan5ab5cde2017-11-21 16:21:34 +0530329 if ((frameLen < LIM_ENCR_AUTH_BODY_LEN_SAP) ||
330 (frameLen > LIM_ENCR_AUTH_BODY_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 {
332 // Log error
333 limLog(pMac, LOGE,
334 FL("Not enough size [%d] to decrypt received Auth frame"),
335 frameLen);
336 limPrintMacAddr(pMac, pHdr->sa, LOGE);
337
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530338 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
341 {
342 val = psessionEntry->privacy;
343 }
344 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 // Accept Authentication frame only if Privacy is implemented
346 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
347 &val) != eSIR_SUCCESS)
348 {
349 /**
350 * Could not get Privacy option
351 * from CFG. Log error.
352 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700353 limLog(pMac, LOGP, FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 }
355
356 cfgPrivacyOptImp = (tANI_U8)val;
357 if (cfgPrivacyOptImp)
358 {
359 /**
360 * Privacy option is implemented.
361 * Check if the received frame is Authentication
362 * frame3 and there is a context for requesting STA.
363 * If not, reject with unspecified failure status code
364 */
365 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
366
367 if (pAuthNode == NULL)
368 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530369 // Log error
370 PELOGE(limLog(pMac, LOGE,
371 FL("received Authentication frame from peer that has "
372 "no preauth context with WEP bit set "MAC_ADDRESS_STR),
373 MAC_ADDR_ARRAY(pHdr->sa));)
374
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 /**
376 * No 'pre-auth' context exists for this STA that sent
377 * an Authentication frame with FC bit set.
378 * Send Auth frame4 with 'out of sequence' status code.
379 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530380 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
381 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530383 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
385
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530386 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530388 LIM_NO_WEP_IN_FC,
389 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700390
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530391 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 }
393 else
394 {
395 /// Change the auth-response timeout
396 limDeactivateAndChangePerStaIdTimer(pMac,
397 eLIM_AUTH_RSP_TIMER,
398 pAuthNode->authNodeIdx);
399
400 /// 'Pre-auth' status exists for STA
401 if ((pAuthNode->mlmState !=
402 eLIM_MLM_WT_AUTH_FRAME3_STATE) &&
403 (pAuthNode->mlmState !=
404 eLIM_MLM_AUTH_RSP_TIMEOUT_STATE))
405 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530406 // Log error
407 PELOGE(limLog(pMac, LOGE,
408 FL("received Authentication frame from peer that is "
409 "in state %d "MAC_ADDRESS_STR),
410 pAuthNode->mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
411
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 /**
413 * Should not have received Authentication frame
414 * with WEP bit set in FC in other states.
415 * Reject by sending Authenticaton frame with
416 * out of sequence Auth frame status code.
417 */
418
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530419 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
420 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530422 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700423 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
424
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530425 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700426 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530427 LIM_NO_WEP_IN_FC,
428 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700429
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530430 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700431 }
432 }
433
434 /**
435 * Check if there exists a key mappping key
436 * for the STA that sent Authentication frame
437 */
438 pKeyMapEntry = limLookUpKeyMappings(pHdr->sa);
439
440 if (pKeyMapEntry)
441 {
442 if (!pKeyMapEntry->wepOn)
443 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530444 // Log error
445 PELOGE(limLog(pMac, LOGE,
446 FL("received Auth frame3 from peer that has NULL "
447 "key map entry "
448 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));)
449
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 /**
451 * Key Mapping entry has null key.
452 * Send Authentication frame
453 * with challenge failure status code
454 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530455 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
456 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700457 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530458 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
460
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530461 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530463 LIM_NO_WEP_IN_FC,
464 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700465
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530466 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 } // if (!pKeyMapEntry->wepOn)
468 else
469 {
470 decryptResult = limDecryptAuthFrame(pMac, pKeyMapEntry->key,
471 pBody,
472 plainBody,
473 key_length,
474 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
475 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
476 {
477 /// ICV failure
Abhishek Singh208848c2013-12-18 19:02:52 +0530478 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
479 "LIM_DECRYPT_ICV_FAIL ..."));)
480 // Log error
481 PELOGE(limLog(pMac, LOGE,
482 FL("received Authentication frame from peer "
483 "that failed decryption, Addr "
484 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
485
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 limDeletePreAuthNode(pMac,
487 pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530488 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
489 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530491 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
493
494 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530495 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530497 LIM_NO_WEP_IN_FC,
498 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700499
Jeff Johnson295189b2012-06-20 16:38:30 -0700500
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530501 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 }
503
Abhishek Singh208848c2013-12-18 19:02:52 +0530504 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530505 rxAuthFrame)!=eSIR_SUCCESS ) ||
506 ( !isAuthValid(pMac, rxAuthFrame,psessionEntry) ) )
Abhishek Singh208848c2013-12-18 19:02:52 +0530507 {
508 PELOGE(limLog(pMac, LOGE,
509 FL("failed to convert Auth Frame to structure "
510 "or Auth is not valid "));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530511 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530512 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700513
514
515 } // end if (pKeyMapEntry->key == NULL)
516 } // if keyMappings has entry
517 else
518 {
519
520 val = SIR_MAC_KEY_LENGTH;
521
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
523 {
524 tpSirKeys pKey;
525 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530526 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 val = pKey->keyLength;
528 }
529 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
531 defaultKey, &val) != eSIR_SUCCESS)
532 {
533 /// Could not get Default key from CFG.
534 //Log error.
535 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700536 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700537
538 /**
539 * Send Authentication frame
540 * with challenge failure status code
541 */
542
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530543 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
544 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530546 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
548
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530549 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530551 LIM_NO_WEP_IN_FC,
552 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700553
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530554 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 }
556
557 key_length=val;
558
559 decryptResult = limDecryptAuthFrame(pMac, defaultKey,
560 pBody,
561 plainBody,
562 key_length,
563 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
564 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
565 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530566 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
567 "LIM_DECRYPT_ICV_FAIL ..."));)
568 // Log error
569 PELOGE(limLog(pMac, LOGE,
570 FL("received Authentication frame from peer that "
571 "failed decryption: "
572 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 /// ICV failure
574 limDeletePreAuthNode(pMac,
575 pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530576 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
577 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700578 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530579 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
581
582 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530583 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530585 LIM_NO_WEP_IN_FC,
586 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530588 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530590 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530591 rxAuthFrame)!=eSIR_SUCCESS ) ||
592 ( !isAuthValid(pMac, rxAuthFrame, psessionEntry) ) )
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530593 {
594 limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +0530595 FL("failed to convert Auth Frame to structure "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530596 "or Auth is not valid "));
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530597 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530598 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 } // End of check for Key Mapping/Default key presence
600 }
601 else
602 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530603 // Log error
604 PELOGE(limLog(pMac, LOGE,
605 FL("received Authentication frame3 from peer that while "
606 "privacy option is turned OFF "
607 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 /**
609 * Privacy option is not implemented.
610 * So reject Authentication frame received with
611 * WEP bit set by sending Authentication frame
612 * with 'challenge failure' status code. This is
613 * another strange thing in the spec. Status code
614 * should have been 'unsupported algorithm' status code.
615 */
616
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530617 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
618 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530620 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700621 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
622
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530623 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700624 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530625 LIM_NO_WEP_IN_FC,
626 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700627
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530628 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 } // else if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
Abhinav Kumard5eacfa2019-08-05 14:56:21 +0530630 } else if ((auth_alg ==
631 eSIR_AUTH_TYPE_SAE) && (LIM_IS_STA_ROLE(psessionEntry))) {
632 lim_process_sae_auth_frame(pMac, pRxPacketInfo, psessionEntry);
633 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 } // if (fc.wep)
635 else
636 {
637
638
Abhishek Singh208848c2013-12-18 19:02:52 +0530639 if ( ( sirConvertAuthFrame2Struct(pMac, pBody,
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530640 frameLen, rxAuthFrame)!=eSIR_SUCCESS ) ||
641 ( !isAuthValid(pMac, rxAuthFrame,psessionEntry) ) )
Abhishek Singh208848c2013-12-18 19:02:52 +0530642 {
643 PELOGE(limLog(pMac, LOGE,
644 FL("failed to convert Auth Frame to structure or Auth is "
645 "not valid "));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530646 goto free;
Abhishek Singh208848c2013-12-18 19:02:52 +0530647 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700648 }
649
650
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530651 pRxAuthFrameBody = rxAuthFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -0700652
Mohit Khanna23863762012-09-11 17:40:09 -0700653 PELOGW(limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700654 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700655 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
656 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
657 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
658
Wang Hu4506bae2015-12-07 14:15:19 +0800659 // IOT Workaround: with invalid WEP password, some APs reply AUTH frame 4
660 // with invalid seqNumber. This AUTH frame will be dropped by driver,
661 // thus driver sends the generic status code instead of protocol status code.
662 // As a workaround, assign the correct seqNumber for the AUTH frame 4.
663 if (psessionEntry->limMlmState == eLIM_MLM_WT_AUTH_FRAME4_STATE &&
664 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_1 &&
665 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_2 &&
666 pRxAuthFrameBody->authTransactionSeqNumber != SIR_MAC_AUTH_FRAME_3) {
667 PELOGE(limLog(pMac, LOGE, FL("Workaround: Assign a correct seqNumber=4 "
668 "for AUTH frame 4"));)
669 pRxAuthFrameBody->authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
670 }
671
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 switch (pRxAuthFrameBody->authTransactionSeqNumber)
673 {
674 case SIR_MAC_AUTH_FRAME_1:
675 // AuthFrame 1
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800676
677 pStaDs = dphLookupHashEntry(pMac, pHdr->sa,
678 &assocId, &psessionEntry->dph.dphHashTable);
679 if (pStaDs)
680 {
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530681 tLimMlmDisassocReq *pMlmDisassocReq = NULL;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800682 tLimMlmDeauthReq *pMlmDeauthReq = NULL;
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530683 tAniBool isConnected = eSIR_TRUE;
684
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800685 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
686 if (pMlmDisassocReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530687 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800688 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530689 sizeof(tSirMacAddr))))
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800690 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800691 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for disassoc "
692 "frame is pending Issue delsta for "
693 MAC_ADDRESS_STR),
694 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700695 limProcessDisassocAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530696 isConnected = eSIR_FALSE;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800697 }
698 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
699 if (pMlmDeauthReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530700 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800701 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
702 sizeof(tSirMacAddr))))
703 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800704 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for deauth frame "
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700705 "is pending Issue delsta for "
Arif Hussain24bafea2013-11-15 15:10:03 -0800706 MAC_ADDRESS_STR),
707 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700708 limProcessDeauthAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530709 isConnected = eSIR_FALSE;
710 }
711
712 /* pStaDS != NULL and isConnected = 1 means the STA is already
713 * connected, But SAP received the Auth from that station.
Abhishek Singh0496a522015-12-14 23:39:23 -0800714 * For non PMF connection send Deauth frame as STA will retry
715 * to connect back.
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530716 *
717 * For PMF connection the AP should not tear down or otherwise
718 * modify the state of the existing association until the
719 * SA-Query procedure determines that the original SA is
720 * invalid.
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530721 */
gaurank kathpalia66414892018-03-21 20:24:39 +0530722 if (isConnected && pStaDs->PrevAuthSeqno != currSeqNo
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530723#ifdef WLAN_FEATURE_11W
724 && !pStaDs->rmfEnabled
725#endif
gaurank kathpalia66414892018-03-21 20:24:39 +0530726 )
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530727 {
Abhishek Singh0496a522015-12-14 23:39:23 -0800728 limLog(pMac, LOGE,
729 FL("STA is already connected but received auth frame"
730 "Send the Deauth and lim Delete Station Context"
731 "(staId: %d, assocId: %d) "),
732 pStaDs->staIndex, assocId);
733 limSendDeauthMgmtFrame(pMac, eSIR_MAC_UNSPEC_FAILURE_REASON,
734 (tANI_U8 *) pHdr->sa, psessionEntry, FALSE);
735 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530736 goto free;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800737 }
738 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700739
740 /// Check if there exists pre-auth context for this STA
741 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
742 if (pAuthNode)
743 {
744 /// Pre-auth context exists for the STA
gaurank kathpalia66414892018-03-21 20:24:39 +0530745 if (pAuthNode->seqNo != currSeqNo)
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 {
747 /**
748 * STA is initiating brand-new Authentication
749 * sequence after local Auth Response timeout.
750 * Or STA retrying to transmit First Auth frame due to packet drop OTA
751 * Delete Pre-auth node and fall through.
752 */
753 if(pAuthNode->fTimerStarted)
754 {
755 limDeactivateAndChangePerStaIdTimer(pMac,
756 eLIM_AUTH_RSP_TIMER,
757 pAuthNode->authNodeIdx);
758 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530759 PELOGE(limLog(pMac, LOGE, FL("STA is initiating brand-new "
760 "Authentication ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 limDeletePreAuthNode(pMac,
762 pHdr->sa);
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 /**
764 * SAP Mode:Disassociate the station and
765 * delete its entry if we have its entry
766 * already and received "auth" from the
767 * same station.
768 */
769
770 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
771 {
772 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
773
774 if (NULL == pStaDs)
775 continue;
776
777 if (pStaDs->valid)
778 {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530779 if (vos_mem_compare((tANI_U8 *) &pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 (tANI_U8 *) &(pHdr->sa), (tANI_U8) (sizeof(tSirMacAddr))) )
781 break;
782 }
Edhar, Mahesh Kumar29013e82014-02-05 10:38:08 +0530783
784 pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700785 }
786
Abhishek Singhe9417492014-09-25 15:55:36 +0530787 if (NULL != pStaDs
788#ifdef WLAN_FEATURE_11W
789 && !pStaDs->rmfEnabled
790#endif
791 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 {
Abhishek Singh0496a522015-12-14 23:39:23 -0800793 PELOGE(limLog(pMac, LOGE, FL("lim Delete Station "
794 "Context (staId: %d, assocId: %d) "),pStaDs->staIndex,
795 assocId);)
796 limSendDeauthMgmtFrame(pMac,
797 eSIR_MAC_UNSPEC_FAILURE_REASON, (tANI_U8 *) pAuthNode->peerMacAddr, psessionEntry, FALSE);
798 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530799 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700800 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 }
802 else
803 {
804 /*
805 * This can happen when first authentication frame is received
806 * but ACK lost at STA side, in this case 2nd auth frame is already
807 * in transmission queue
808 * */
Abhishek Singh208848c2013-12-18 19:02:52 +0530809 PELOGE(limLog(pMac, LOGE, FL("STA is initiating "
810 "Authentication after ACK lost..."));)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530811 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 }
813 }
814 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
815 (tANI_U32 *) &maxNumPreAuth) != eSIR_SUCCESS)
816 {
817 /**
818 * Could not get MaxNumPreAuth
819 * from CFG. Log error.
820 */
821 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700822 FL("could not retrieve MaxNumPreAuth"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700823 }
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530824
825 if (pMac->lim.gLimNumPreAuthContexts == maxNumPreAuth &&
826 !limDeleteOpenAuthPreAuthNode(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530828 PELOGE(limLog(pMac, LOGE, FL("Max number of "
829 "preauth context reached"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 /**
831 * Maximum number of pre-auth contexts
832 * reached. Send Authentication frame
833 * with unspecified failure
834 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530835 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530837 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530839 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 eSIR_MAC_UNSPEC_FAILURE_STATUS;
841
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530842 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530844 LIM_NO_WEP_IN_FC,
845 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700846
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530847 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 }
849 /// No Pre-auth context exists for the STA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700850 if (limIsAuthAlgoSupported(
851 pMac,
852 (tAniAuthType)
853 pRxAuthFrameBody->authAlgoNumber, psessionEntry))
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 {
855 switch (pRxAuthFrameBody->authAlgoNumber)
856 {
857 case eSIR_OPEN_SYSTEM:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700858 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_OPEN_SYSTEM ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 /// Create entry for this STA in pre-auth list
860 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
861 if (pAuthNode == NULL)
862 {
863 // Log error
864 limLog(pMac, LOGW,
865 FL("Max pre-auth nodes reached "));
866 limPrintMacAddr(pMac, pHdr->sa, LOGW);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530867 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 }
869
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530870 limLog(pMac, LOG1,
871 FL("Alloc new data: peer "MAC_ADDRESS_STR),
872 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700873
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530874 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
875 pHdr->sa,
876 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700877
878 pAuthNode->mlmState =
879 eLIM_MLM_AUTHENTICATED_STATE;
880 pAuthNode->authType = (tAniAuthType)
881 pRxAuthFrameBody->authAlgoNumber;
882 pAuthNode->fSeen = 0;
883 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530884 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
885 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530886 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 limAddPreAuthNode(pMac, pAuthNode);
888
889 /**
890 * Send Authenticaton frame with Success
891 * status code.
892 */
893
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530894 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530896 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530898 authFrame->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530900 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530902 LIM_NO_WEP_IN_FC,
903 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700904
905 /// Send Auth indication to SME
906
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530907 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 (tANI_U8 *) pHdr->sa,
909 sizeof(tSirMacAddr));
910 mlmAuthInd.authType = (tAniAuthType)
911 pRxAuthFrameBody->authAlgoNumber;
912 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
913
914 limPostSmeMessage(pMac,
915 LIM_MLM_AUTH_IND,
916 (tANI_U32 *) &mlmAuthInd);
917 break;
918
919 case eSIR_SHARED_KEY:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700920 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_SHARED_KEY ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
922 {
923 val = psessionEntry->privacy;
924 }
925 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
927 &val) != eSIR_SUCCESS)
928 {
929 /**
930 * Could not get Privacy option
931 * from CFG. Log error.
932 */
933 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700934 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 }
936 cfgPrivacyOptImp = (tANI_U8)val;
937 if (!cfgPrivacyOptImp)
938 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530939 // Log error
940 PELOGE(limLog(pMac, LOGE,
941 FL("received Auth frame for unsupported auth algorithm %d "
942 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
943 MAC_ADDR_ARRAY(pHdr->sa));)
944
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 /**
946 * Authenticator does not have WEP
947 * implemented.
948 * Reject by sending Authentication frame
949 * with Auth algorithm not supported status
950 * code.
951 */
952
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530953 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530955 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530957 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
959
960 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530961 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530963 LIM_NO_WEP_IN_FC,
964 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700965
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530966 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 }
968 else
969 {
970 // Create entry for this STA
971 //in pre-auth list
972 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
973 if (pAuthNode == NULL)
974 {
975 // Log error
976 limLog(pMac, LOGW,
977 FL("Max pre-auth nodes reached "));
978 limPrintMacAddr(pMac, pHdr->sa, LOGW);
979
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +0530980 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 }
982
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530983 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
984 pHdr->sa,
985 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700986
987 pAuthNode->mlmState =
988 eLIM_MLM_WT_AUTH_FRAME3_STATE;
989 pAuthNode->authType =
990 (tAniAuthType)
991 pRxAuthFrameBody->authAlgoNumber;
992 pAuthNode->fSeen = 0;
993 pAuthNode->fTimerStarted = 0;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +0530994 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
995 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +0530996 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -0700997 limAddPreAuthNode(pMac, pAuthNode);
998
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530999 limLog(pMac, LOG1,
1000 FL("Alloc new data: id %d peer "MAC_ADDRESS_STR),
1001 pAuthNode->authNodeIdx, MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001002
1003 /// Create and activate Auth Response timer
1004 if (tx_timer_change_context(&pAuthNode->timer, pAuthNode->authNodeIdx) != TX_SUCCESS)
1005 {
1006 /// Could not start Auth response timer.
1007 // Log error
1008 limLog(pMac, LOGP,
1009 FL("Unable to chg context auth response timer for peer "));
1010 limPrintMacAddr(pMac, pHdr->sa, LOGP);
1011
1012 /**
1013 * Send Authenticaton frame with
1014 * unspecified failure status code.
1015 */
1016
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301017 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301019 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301021 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 eSIR_MAC_UNSPEC_FAILURE_STATUS;
1023
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301024 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301026 LIM_NO_WEP_IN_FC,
1027 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001028
1029 limDeletePreAuthNode(pMac, pHdr->sa);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301030 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 }
1032
1033 limActivateAuthRspTimer(pMac, pAuthNode);
1034
1035 pAuthNode->fTimerStarted = 1;
1036
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301037 /*
1038 * get random bytes and use as challenge text
1039 */
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301040 if( !VOS_IS_STATUS_SUCCESS( vos_rand_get_bytes( 0, (tANI_U8 *)challengeTextArray, SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301042 limLog(pMac, LOGE,FL("Challenge text "
1043 "preparation failed in limProcessAuthFrame"));
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301044 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 }
1046
1047 pChallenge = pAuthNode->challengeText;
1048
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301049 vos_mem_copy(pChallenge,
1050 (tANI_U8 *) challengeTextArray,
1051 sizeof(challengeTextArray));
Jeff Johnson295189b2012-06-20 16:38:30 -07001052
1053 /**
1054 * Sending Authenticaton frame with challenge.
1055 */
1056
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301057 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301059 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301061 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 eSIR_MAC_SUCCESS_STATUS;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301063 authFrame->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301064 authFrame->length = SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301065 vos_mem_copy(authFrame->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 pAuthNode->challengeText,
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301067 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -07001068
1069 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301070 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301072 LIM_NO_WEP_IN_FC,
1073 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001074 } // if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1075
1076 break;
1077
1078 default:
Abhishek Singh208848c2013-12-18 19:02:52 +05301079 // Log error
1080 PELOGE( limLog(pMac, LOGE,
1081 FL("received Auth frame for unsupported auth "
1082 "algorithm %d "MAC_ADDRESS_STR),
1083 pRxAuthFrameBody->authAlgoNumber,
1084 MAC_ADDR_ARRAY(pHdr->sa));)
1085
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 /**
1087 * Responding party does not support the
1088 * authentication algorithm requested by
1089 * sending party.
1090 * Reject by sending Authentication frame
1091 * with auth algorithm not supported status code
1092 */
1093
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301094 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301096 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301098 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1100
1101 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301102 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301104 LIM_NO_WEP_IN_FC,
1105 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001106
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301107 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 } // end switch(pRxAuthFrameBody->authAlgoNumber)
1109 } // if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1110 else
1111 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301112 // Log error
1113 PELOGE(limLog(pMac, LOGE,
1114 FL("received Authentication frame for unsupported auth "
1115 "algorithm %d "MAC_ADDRESS_STR),
1116 pRxAuthFrameBody->authAlgoNumber,
1117 MAC_ADDR_ARRAY(pHdr->sa));)
1118
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 /**
1120 * Responding party does not support the
1121 * authentication algorithm requested by sending party.
1122 * Reject Authentication with StatusCode=13.
1123 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301124 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301126 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301128 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001129 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1130
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301131 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301133 LIM_NO_WEP_IN_FC,
1134 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001135
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301136 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 } //end if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1138 break;
1139
1140 case SIR_MAC_AUTH_FRAME_2:
1141 // AuthFrame 2
1142
1143 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME2_STATE)
1144 {
1145 /**
1146 * Received Authentication frame2 in an unexpected state.
1147 * Log error and ignore the frame.
1148 */
1149
1150 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301151 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 FL("received Auth frame2 from peer in state %d, addr "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301153 psessionEntry->limMlmState);
1154 limPrintMacAddr(pMac, pHdr->sa, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001155
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301156 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 }
1158
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301159 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1160 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1161 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001162 {
1163 /**
1164 * Received Authentication frame from an entity
1165 * other than one request was initiated.
1166 * Wait until Authentication Failure Timeout.
1167 */
1168
1169 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001170 PELOGW(limLog(pMac, LOGW,
Abhishek Singh208848c2013-12-18 19:02:52 +05301171 FL("received Auth frame2 from unexpected peer "
1172 MAC_ADDRESS_STR),
Mohit Khanna23863762012-09-11 17:40:09 -07001173 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001174
1175 break;
1176 }
1177
1178 if (pRxAuthFrameBody->authStatusCode ==
1179 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS)
1180 {
1181 /**
1182 * Interoperability workaround: Linksys WAP4400N is returning
1183 * wrong authType in OpenAuth response in case of
1184 * SharedKey AP configuration. Pretend we don't see that,
1185 * so upper layer can fallback to SharedKey authType,
1186 * and successfully connect to the AP.
1187 */
1188 if (pRxAuthFrameBody->authAlgoNumber !=
1189 pMac->lim.gpLimMlmAuthReq->authType)
1190 {
1191 pRxAuthFrameBody->authAlgoNumber =
1192 pMac->lim.gpLimMlmAuthReq->authType;
1193 }
1194 }
1195
1196 if (pRxAuthFrameBody->authAlgoNumber !=
1197 pMac->lim.gpLimMlmAuthReq->authType)
1198 {
1199 /**
1200 * Received Authentication frame with an auth
1201 * algorithm other than one requested.
1202 * Wait until Authentication Failure Timeout.
1203 */
1204
1205 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001206 PELOGW(limLog(pMac, LOGW,
1207 FL("received Auth frame2 for unexpected auth algo number %d "
Abhishek Singh208848c2013-12-18 19:02:52 +05301208 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001209 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001210
1211 break;
1212 }
1213
1214 if (pRxAuthFrameBody->authStatusCode ==
1215 eSIR_MAC_SUCCESS_STATUS)
1216 {
1217 if (pRxAuthFrameBody->authAlgoNumber ==
1218 eSIR_OPEN_SYSTEM)
1219 {
1220 psessionEntry->limCurrentAuthType = eSIR_OPEN_SYSTEM;
1221
1222 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1223
1224 if (pAuthNode == NULL)
1225 {
1226 // Log error
1227 limLog(pMac, LOGW,
1228 FL("Max pre-auth nodes reached "));
1229 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1230
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301231 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 }
1233
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301234 limLog(pMac, LOG1,
1235 FL("Alloc new data: peer "MAC_ADDRESS_STR),
1236 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001237
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301238 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1240 sizeof(tSirMacAddr));
1241 pAuthNode->fTimerStarted = 0;
1242 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301243 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1244 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301245 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 limAddPreAuthNode(pMac, pAuthNode);
1247
1248 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1249 pRxAuthFrameBody->authStatusCode,psessionEntry);
1250 } // if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1251 else
1252 {
1253 // Shared key authentication
1254
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1256 {
1257 val = psessionEntry->privacy;
1258 }
1259 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1261 &val) != eSIR_SUCCESS)
1262 {
1263 /**
1264 * Could not get Privacy option
1265 * from CFG. Log error.
1266 */
1267 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001268 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 }
1270 cfgPrivacyOptImp = (tANI_U8)val;
1271 if (!cfgPrivacyOptImp)
1272 {
1273 /**
1274 * Requesting STA does not have WEP implemented.
1275 * Reject with unsupported authentication algorithm
1276 * Status code and wait until auth failure timeout
1277 */
1278
1279 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001280 PELOGE( limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301281 FL("received Auth frame from peer for "
1282 "unsupported auth algo %d "
1283 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001284 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001285
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301286 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001287 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301288 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301290 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001291 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1292
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301293 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301295 LIM_NO_WEP_IN_FC,
1296 psessionEntry, eSIR_FALSE);
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301297 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 }
1299 else
1300 {
1301
1302 if (pRxAuthFrameBody->type !=
1303 SIR_MAC_CHALLENGE_TEXT_EID)
1304 {
1305 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001306 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301307 FL("received Auth frame with invalid "
1308 "challenge text IE"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001309
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301310 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 }
1312
1313 /**
1314 * Check if there exists a key mappping key
1315 * for the STA that sent Authentication frame
1316 */
1317 pKeyMapEntry = limLookUpKeyMappings(
1318 pHdr->sa);
1319
1320 if (pKeyMapEntry)
1321 {
1322 if (pKeyMapEntry->key == NULL)
1323 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301324 // Log error
1325 PELOGE(limLog(pMac, LOGE,
1326 FL("received Auth frame from peer when "
1327 "key mapping key is NULL"MAC_ADDRESS_STR),
1328 MAC_ADDR_ARRAY(pHdr->sa));)
1329
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 /**
1331 * Key Mapping entry has null key.
1332 * Send Auth frame with
1333 * challenge failure status code
1334 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301335 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301337 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301339 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1341
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301342 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301344 LIM_NO_WEP_IN_FC,
1345 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001346
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 limRestoreFromAuthState(pMac, eSIR_SME_NO_KEY_MAPPING_KEY_FOR_PEER,
1348 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1349
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301350 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 } // if (pKeyMapEntry->key == NULL)
1352 else
1353 {
1354 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1355 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1356 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1357 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1358 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1359 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301360 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301361 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001362 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301363 pRxAuthFrameBody->length);
1364
1365 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1366 LIM_ENCR_AUTH_INFO_LEN);
1367 if (!encrAuthFrame) {
1368 limLog(pMac, LOGE, FL("failed to allocate memory"));
1369 goto free;
1370 }
1371 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1372 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001373
1374 limEncryptAuthFrame(pMac, 0,
1375 pKeyMapEntry->key,
1376 plainBody,
1377 encrAuthFrame,key_length);
1378
1379 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001380 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001381
1382 limSendAuthMgmtFrame(pMac,
1383 (tpSirMacAuthFrameBody) encrAuthFrame,
1384 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301385 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301386 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001387
1388 break;
1389 } // end if (pKeyMapEntry->key == NULL)
1390 } // if (pKeyMapEntry)
1391 else
1392 {
1393 if (wlan_cfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID,
1394 &val) != eSIR_SUCCESS)
1395 {
1396 /**
1397 * Could not get Default keyId
1398 * from CFG. Log error.
1399 */
1400 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001401 FL("could not retrieve Default keyId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 }
1403 keyId = (tANI_U8)val;
1404
1405 val = SIR_MAC_KEY_LENGTH;
1406
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1408 {
1409 tpSirKeys pKey;
1410 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301411 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 }
1413 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
1415 defaultKey,
1416 &val)
1417 != eSIR_SUCCESS)
1418 {
1419 /// Could not get Default key from CFG.
1420 //Log error.
1421 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001422 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001423
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301424 authFrame->authAlgoNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001425 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301426 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 pRxAuthFrameBody->authTransactionSeqNumber + 1;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301428 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1430
1431 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301432 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301434 LIM_NO_WEP_IN_FC,
1435 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001436
1437 limRestoreFromAuthState(pMac, eSIR_SME_INVALID_WEP_DEFAULT_KEY,
1438 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1439
1440 break;
1441 }
1442 key_length=val;
1443 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1444 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1445 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1446 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1447 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1448 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301449 ((tpSirMacAuthFrameBody) plainBody)->length = pRxAuthFrameBody->length;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301450 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001451 pRxAuthFrameBody->challengeText,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301452 pRxAuthFrameBody->length);
1453
1454 encrAuthFrame = vos_mem_malloc(pRxAuthFrameBody->length +
1455 LIM_ENCR_AUTH_INFO_LEN);
1456 if (!encrAuthFrame) {
1457 limLog(pMac, LOGE, FL("failed to allocate memory"));
1458 goto free;
1459 }
1460 vos_mem_set(encrAuthFrame, pRxAuthFrameBody->length +
1461 LIM_ENCR_AUTH_INFO_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001462
1463 limEncryptAuthFrame(pMac, keyId,
1464 defaultKey,
1465 plainBody,
1466 encrAuthFrame,key_length);
1467
1468 psessionEntry->limMlmState =
1469 eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001470 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001471
1472 limSendAuthMgmtFrame(pMac,
1473 (tpSirMacAuthFrameBody) encrAuthFrame,
1474 pHdr->sa,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05301475 pRxAuthFrameBody->length,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301476 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001477
1478 break;
1479 } // end if (pKeyMapEntry)
1480 } // end if (!wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1481 } // end if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1482 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1483 else
1484 {
1485 /**
1486 * Authentication failure.
1487 * Return Auth confirm with received failure code to SME
1488 */
1489
1490 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001491 PELOGE(limLog(pMac, LOGE,
1492 FL("received Auth frame from peer with failure code %d "
1493 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1494 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001495
1496 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1497 pRxAuthFrameBody->authStatusCode,psessionEntry);
1498 } // end if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1499
1500 break;
1501
1502 case SIR_MAC_AUTH_FRAME_3:
1503 // AuthFrame 3
1504
1505 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1506 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301507 // Log error
1508 PELOGE(limLog(pMac, LOGE,
1509 FL("received Auth frame3 from peer with auth algo "
1510 "number %d "MAC_ADDRESS_STR),
1511 pRxAuthFrameBody->authAlgoNumber,
1512 MAC_ADDR_ARRAY(pHdr->sa));)
1513
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 /**
1515 * Received Authentication frame3 with algorithm other than
1516 * Shared Key authentication type. Reject with Auth frame4
1517 * with 'out of sequence' status code.
1518 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301519 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1520 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001521 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301522 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1524
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301525 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301527 LIM_NO_WEP_IN_FC,
1528 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001529
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301530 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 }
1532
1533 if (psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE ||
1534 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
1535 {
1536 /**
1537 * Check if wep bit was set in FC. If not set,
1538 * reject with Authentication frame4 with
1539 * 'challenge failure' status code.
1540 */
1541 if (!pHdr->fc.wep)
1542 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301543 // Log error
1544 PELOGE(limLog(pMac, LOGE,
1545 FL("received Auth frame3 from peer with no WEP bit "
1546 "set "MAC_ADDRESS_STR),
1547 MAC_ADDR_ARRAY(pHdr->sa));)
1548
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 /// WEP bit is not set in FC of Auth Frame3
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301550 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1551 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301553 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1555
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301556 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301558 LIM_NO_WEP_IN_FC,
1559 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001560
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301561 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 }
1563
1564 pAuthNode = limSearchPreAuthList(pMac,
1565 pHdr->sa);
1566 if (pAuthNode == NULL)
1567 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301568 // Log error
1569 PELOGE(limLog(pMac, LOGW,
1570 FL("received AuthFrame3 from peer that has no "
1571 "preauth context "MAC_ADDRESS_STR),
1572 MAC_ADDR_ARRAY(pHdr->sa));)
1573
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 /**
1575 * No 'pre-auth' context exists for
1576 * this STA that sent an Authentication
1577 * frame3.
1578 * Send Auth frame4 with 'out of sequence'
1579 * status code.
1580 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301581 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1582 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301584 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1586
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301587 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001588 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301589 LIM_NO_WEP_IN_FC,
1590 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001591
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301592 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 }
1594
1595 if (pAuthNode->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)
1596 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301597 // Log error
1598 limLog(pMac, LOGW,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301599 FL("auth response timer timedout for peer "
1600 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 /**
1602 * Received Auth Frame3 after Auth Response timeout.
1603 * Reject by sending Auth Frame4 with
1604 * Auth respone timeout Status Code.
1605 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301606 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1607 authFrame->authTransactionSeqNumber =
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301609 authFrame->authStatusCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS;
1611
1612 limSendAuthMgmtFrame(
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301613 pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301615 LIM_NO_WEP_IN_FC,
1616 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001617
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 /// Delete pre-auth context of STA
1619 limDeletePreAuthNode(pMac,
1620 pHdr->sa);
1621
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301622 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 } // end switch (pAuthNode->mlmState)
1624
1625 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1626 {
1627 /**
1628 * Received Authenetication Frame 3 with status code
1629 * other than success. Wait until Auth response timeout
1630 * to delete STA context.
1631 */
1632
1633 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001634 PELOGE(limLog(pMac, LOGE,
1635 FL("received Auth frame3 from peer with status code %d "
1636 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1637 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001638
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301639 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 }
1641
1642 /**
1643 * Check if received challenge text is same as one sent in
1644 * Authentication frame3
1645 */
1646
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301647 if (vos_mem_compare(pRxAuthFrameBody->challengeText,
1648 pAuthNode->challengeText,
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05301649 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH))
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 {
1651 /// Challenge match. STA is autheticated !
1652
1653 /// Delete Authentication response timer if running
1654 limDeactivateAndChangePerStaIdTimer(pMac,
1655 eLIM_AUTH_RSP_TIMER,
1656 pAuthNode->authNodeIdx);
1657
1658 pAuthNode->fTimerStarted = 0;
1659 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1660
1661 /**
1662 * Send Authentication Frame4 with 'success' Status Code.
1663 */
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301664 authFrame->authAlgoNumber = eSIR_SHARED_KEY;
1665 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001666 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301667 authFrame->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001668
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301669 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301671 LIM_NO_WEP_IN_FC,
1672 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001673
1674 /// Send Auth indication to SME
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301675 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 (tANI_U8 *) pHdr->sa,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301677 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 mlmAuthInd.authType = (tAniAuthType)
1679 pRxAuthFrameBody->authAlgoNumber;
1680 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
1681
1682 limPostSmeMessage(pMac,
1683 LIM_MLM_AUTH_IND,
1684 (tANI_U32 *) &mlmAuthInd);
1685
1686 break;
1687 }
1688 else
1689 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301690 // Log error
1691 PELOGE( limLog(pMac, LOGW,
1692 FL("Challenge failure for peer "
1693 MAC_ADDRESS_STR),
1694 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 /**
1696 * Challenge Failure.
1697 * Send Authentication frame4 with 'challenge failure'
1698 * status code and wait until Auth response timeout to
1699 * delete STA context.
1700 */
1701
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301702 authFrame->authAlgoNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001703 pRxAuthFrameBody->authAlgoNumber;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301704 authFrame->authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001705 SIR_MAC_AUTH_FRAME_4;
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301706 authFrame->authStatusCode =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001707 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001708
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301709 limSendAuthMgmtFrame(pMac, authFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07001710 pHdr->sa,
Sushant Kaushik9e923872015-04-02 17:09:31 +05301711 LIM_NO_WEP_IN_FC,
1712 psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001713
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301714 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 }
1716 } // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE || ...
1717
1718 break;
1719
1720 case SIR_MAC_AUTH_FRAME_4:
1721 // AuthFrame 4
1722 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE)
1723 {
1724 /**
1725 * Received Authentication frame4 in an unexpected state.
1726 * Log error and ignore the frame.
1727 */
1728
1729 // Log error
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301730 limLog(pMac, LOG1,
Abhishek Singh208848c2013-12-18 19:02:52 +05301731 FL("received unexpected Auth frame4 from peer in state "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301732 "%d, addr "MAC_ADDRESS_STR), psessionEntry->limMlmState,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301733 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001734
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301735 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 }
1737
1738 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1739 {
1740 /**
1741 * Received Authentication frame4 with algorithm other than
1742 * Shared Key authentication type.
1743 * Wait until Auth failure timeout to report authentication
1744 * failure to SME.
1745 */
1746
1747 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001748 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301749 FL("received Auth frame4 from peer with invalid auth "
1750 "algo %d "MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001751 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001752
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301753 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 }
1755
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301756 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1757 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1758 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001759 {
1760 /**
1761 * Received Authentication frame from an entity
1762 * other than one to which request was initiated.
1763 * Wait until Authentication Failure Timeout.
1764 */
1765
1766 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001767 PELOGE(limLog(pMac, LOGW,
1768 FL("received Auth frame4 from unexpected peer "
1769 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001770
1771 break;
1772 }
1773
1774 if (pRxAuthFrameBody->authAlgoNumber !=
1775 pMac->lim.gpLimMlmAuthReq->authType)
1776 {
1777 /**
1778 * Received Authentication frame with an auth algorithm
1779 * other than one requested.
1780 * Wait until Authentication Failure Timeout.
1781 */
1782
Mohit Khanna23863762012-09-11 17:40:09 -07001783 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301784 FL("received Authentication frame from peer with "
1785 "invalid auth seq number %d "
1786 MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001787 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001788
1789 break;
1790 }
1791
1792 if (pRxAuthFrameBody->authStatusCode ==
1793 eSIR_MAC_SUCCESS_STATUS)
1794 {
1795 /**
1796 * Authentication Success !
1797 * Inform SME of same.
1798 */
1799 psessionEntry->limCurrentAuthType = eSIR_SHARED_KEY;
1800
1801 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1802 if (pAuthNode == NULL)
1803 {
1804 // Log error
1805 limLog(pMac, LOGW,
1806 FL("Max pre-auth nodes reached "));
1807 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1808
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301809 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301811 limLog(pMac, LOG1,
1812 FL("Alloc new data: peer " MAC_ADDRESS_STR),
1813 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001814
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301815 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1817 sizeof(tSirMacAddr));
1818 pAuthNode->fTimerStarted = 0;
1819 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
Sushant Kaushikf9c963c2015-01-28 12:50:26 +05301820 pAuthNode->seqNo = ((pHdr->seqControl.seqNumHi << 4) |
1821 (pHdr->seqControl.seqNumLo));
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301822 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 limAddPreAuthNode(pMac, pAuthNode);
1824
1825 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1826 pRxAuthFrameBody->authStatusCode,psessionEntry);
1827
1828 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1829 else
1830 {
1831 /**
1832 * Authentication failure.
1833 * Return Auth confirm with received failure code to SME
1834 */
1835
1836 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001837 PELOGE(limLog(pMac, LOGE, FL("Authentication failure from peer "
1838 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001839
1840 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1841 pRxAuthFrameBody->authStatusCode,psessionEntry);
1842 } // end if (pRxAuthFrameBody->Status == 0)
1843
1844 break;
1845
1846 default:
1847 /// Invalid Authentication Frame received. Ignore it.
1848
1849 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001850 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301851 FL("received Auth frame from peer with invalid auth seq "
1852 "number %d " MAC_ADDRESS_STR),
1853 pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001854 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001855
1856 break;
1857 } // end switch (pRxAuthFrameBody->authTransactionSeqNumber)
Sridhar Selvaraj82ef6862017-07-27 19:39:58 +05301858
1859free:
1860 if (authFrame)
1861 vos_mem_free(authFrame);
1862 if (rxAuthFrame)
1863 vos_mem_free(rxAuthFrame);
1864 if (encrAuthFrame)
1865 vos_mem_free(encrAuthFrame);
1866 if (plainBody)
1867 vos_mem_free(plainBody);
1868 if (challengeTextArray)
1869 vos_mem_free(challengeTextArray);
1870
Jeff Johnson295189b2012-06-20 16:38:30 -07001871} /*** end limProcessAuthFrame() ***/
1872
1873
1874
1875
1876
1877#ifdef WLAN_FEATURE_VOWIFI_11R
1878
1879/*----------------------------------------------------------------------
1880 *
1881 * Pass the received Auth frame. This is possibly the pre-auth from the
1882 * neighbor AP, in the same mobility domain.
1883 * This will be used in case of 11r FT.
1884 *
1885 * !!!! This is going to be renoved for the next checkin. We will be creating
1886 * the session before sending out the Auth. Thus when auth response
1887 * is received we will have a session in progress. !!!!!
1888 *----------------------------------------------------------------------
1889 */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001890tSirRetStatus limProcessAuthFrameNoSession(tpAniSirGlobal pMac, tANI_U8 *pBd, void *body)
Jeff Johnson295189b2012-06-20 16:38:30 -07001891{
1892 tpSirMacMgmtHdr pHdr;
1893 tpPESession psessionEntry = NULL;
1894 tANI_U8 *pBody;
1895 tANI_U16 frameLen;
1896 tSirMacAuthFrameBody rxAuthFrame;
1897 tSirMacAuthFrameBody *pRxAuthFrameBody = NULL;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001898 tSirRetStatus ret_status = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001899
1900 pHdr = WDA_GET_RX_MAC_HEADER(pBd);
1901 pBody = WDA_GET_RX_MPDU_DATA(pBd);
1902 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd);
1903
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05301904 /*
1905 * since, roaming is not supported in sta + mon scc, ignore
1906 * pre-auth when capture on monitor mode is started
1907 */
1908 if (vos_check_monitor_state())
1909 {
1910 limLog(pMac, LOG1, FL("Ignore pre-auth frame in monitor mode"));
1911 return eSIR_FAILURE;
1912 }
1913
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301914 limLog(pMac, LOG1, FL("Auth Frame Received: BSSID " MAC_ADDRESS_STR
1915 " (RSSI %d)"),MAC_ADDR_ARRAY(pHdr->bssId),
1916 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 // Check for the operating channel and see what needs to be done next.
1918 psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
1919 if (psessionEntry == NULL)
1920 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301921 limLog(pMac, LOGE, FL("Error: Unable to find session id while in "
1922 "pre-auth phase for FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 return eSIR_FAILURE;
1924 }
1925
1926 if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL)
1927 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301928 limLog(pMac, LOGE, FL("Error: No FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 // No FT in progress.
1930 return eSIR_FAILURE;
1931 }
1932
1933 if (frameLen == 0)
1934 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301935 limLog(pMac, LOGE, FL("Error: Frame len = 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001936 return eSIR_FAILURE;
1937 }
1938#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001939 limPrintMacAddr(pMac, pHdr->bssId, LOG2);
1940 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOG2);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001941 limLog(pMac,LOG2,FL("seqControl 0x%X"),
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001942 ((pHdr->seqControl.seqNumHi << 8) |
1943 (pHdr->seqControl.seqNumLo << 4) |
1944 (pHdr->seqControl.fragNum)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001945#endif
1946
1947 // Check that its the same bssId we have for preAuth
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301948 if (!vos_mem_compare(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1949 pHdr->bssId, sizeof( tSirMacAddr )))
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301951 limLog(pMac, LOGE, FL("Error: NOT same bssid as preauth BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 // In this case SME if indeed has triggered a
1953 // pre auth it will time out.
1954 return eSIR_FAILURE;
1955 }
1956
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001957 if (eANI_BOOLEAN_TRUE ==
1958 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed)
1959 {
1960 /*
1961 * This is likely a duplicate for the same pre-auth request.
1962 * PE/LIM already posted a response to SME. Hence, drop it.
1963 * TBD:
1964 * 1) How did we even receive multiple auth responses?
1965 * 2) Do we need to delete pre-auth session? Suppose we
1966 * previously received an auth resp with failure which
1967 * would not have created the session and forwarded to SME.
1968 * And, we subsequently received an auth resp with success
1969 * which would have created the session. This will now be
1970 * dropped without being forwarded to SME! However, it is
1971 * very unlikely to receive auth responses from the same
1972 * AP with different reason codes.
1973 * NOTE: return eSIR_SUCCESS so that the packet is dropped
1974 * as this was indeed a response from the BSSID we tried to
1975 * pre-auth.
1976 */
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001977 PELOGE(limLog(pMac,LOG1,"Auth rsp already posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001978 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001979 pMac->ft.ftPEContext.pftSessionEntry););
1980 return eSIR_SUCCESS;
1981 }
1982 else
1983 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001984 PELOGE(limLog(pMac,LOGW,"Auth rsp not yet posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001985 " (session %pK, FT session %pK)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001986 pMac->ft.ftPEContext.pftSessionEntry););
1987 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
1988 eANI_BOOLEAN_TRUE;
1989 }
1990
Jeff Johnson295189b2012-06-20 16:38:30 -07001991#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001992 limLog(pMac, LOG1, FL("Pre-Auth response received from neighbor"));
1993 limLog(pMac, LOG1, FL("Pre-Auth done state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001994#endif
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301995
1996 limLog(pMac, LOG1, FL("is_preauth_lfr_mbb %d"),
1997 pMac->ft.ftSmeContext.is_preauth_lfr_mbb);
1998
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 // Stopping timer now, that we have our unicast from the AP
2000 // of our choice.
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302001 if (!pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
2002 limDeactivateAndChangeTimer(pMac, eLIM_FT_PREAUTH_RSP_TIMER);
2003
2004#ifdef WLAN_FEATURE_LFR_MBB
2005 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb)
2006 limDeactivateAndChangeTimer(pMac, eLIM_PREAUTH_MBB_RSP_TIMER);
2007#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002008
2009
2010 // Save off the auth resp.
2011 if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame) != eSIR_SUCCESS))
2012 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05302013 limLog(pMac, LOGE, FL("failed to convert Auth frame to struct"));
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302014
2015#ifdef WLAN_FEATURE_LFR_MBB
2016 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
2017 lim_handle_pre_auth_mbb_rsp(pMac, eSIR_FAILURE, psessionEntry);
2018 return eSIR_FAILURE;
2019 }
2020#endif
2021
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
2023 return eSIR_FAILURE;
2024 }
2025 pRxAuthFrameBody = &rxAuthFrame;
2026
2027#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002028 PELOGE(limLog(pMac, LOG1,
2029 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
2031 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
2032 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
2033#endif
2034
2035 switch (pRxAuthFrameBody->authTransactionSeqNumber)
2036 {
2037 case SIR_MAC_AUTH_FRAME_2:
2038 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
2039 {
2040#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08002041 PELOGE(limLog( pMac, LOGE, "Auth status code received is %d",
2042 (tANI_U32) pRxAuthFrameBody->authStatusCode););
Jeff Johnson295189b2012-06-20 16:38:30 -07002043#endif
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08002044 if (eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS == pRxAuthFrameBody->authStatusCode)
2045 ret_status = eSIR_LIM_MAX_STA_REACHED_ERROR;
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 }
2047 else
2048 {
2049 ret_status = eSIR_SUCCESS;
2050 }
2051 break;
2052
2053 default:
2054#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002055 PELOGE(limLog( pMac, LOGE, "Seq. no incorrect expected 2 received %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber);)
2057#endif
2058 break;
2059 }
2060
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05302061#ifdef WLAN_FEATURE_LFR_MBB
2062 if (pMac->ft.ftSmeContext.is_preauth_lfr_mbb) {
2063 lim_handle_pre_auth_mbb_rsp(pMac, ret_status, psessionEntry);
2064 return ret_status;
2065 }
2066#endif
2067
Jeff Johnson295189b2012-06-20 16:38:30 -07002068 // Send the Auth response to SME
2069 limHandleFTPreAuthRsp(pMac, ret_status, pBody, frameLen, psessionEntry);
2070
2071 return ret_status;
2072}
2073
2074#endif /* WLAN_FEATURE_VOWIFI_11R */
2075