blob: 806ff12d18efca7a3d657cdf7fd1d6457ee4aecd [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved.
3 *
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"
Jeff Johnson295189b2012-06-20 16:38:30 -070041#include "wniCfgSta.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"
54
55
56/**
57 * isAuthValid
58 *
59 *FUNCTION:
60 * This function is called by limProcessAuthFrame() upon Authentication
61 * frame reception.
62 *
63 *LOGIC:
64 * This function is used to test validity of auth frame:
65 * - AUTH1 and AUTH3 must be received in AP mode
66 * - AUTH2 and AUTH4 must be received in STA mode
67 * - AUTH3 and AUTH4 must have challenge text IE, that is,'type' field has been set to
68 * SIR_MAC_CHALLENGE_TEXT_EID by parser
69 * -
70 *
71 *ASSUMPTIONS:
72 *
73 *NOTE:
74 *
75 * @param *auth - Pointer to extracted auth frame body
76 *
77 * @return 0 or 1 (Valid)
78 */
79
80
81static inline unsigned int isAuthValid(tpAniSirGlobal pMac, tpSirMacAuthFrameBody auth,tpPESession sessionEntry) {
82 unsigned int valid;
83 valid=1;
84
85 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_1)||
86 (auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)) &&
87 ((sessionEntry->limSystemRole == eLIM_STA_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)))
88 valid=0;
89
90 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_2)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&&
91 ((sessionEntry->limSystemRole == eLIM_AP_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)))
92 valid=0;
93
94 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&&
95 (auth->type!=SIR_MAC_CHALLENGE_TEXT_EID)&&(auth->authAlgoNumber != eSIR_SHARED_KEY))
96 valid=0;
97
98 return valid;
99}
100
101
102/**
103 * limProcessAuthFrame
104 *
105 *FUNCTION:
106 * This function is called by limProcessMessageQueue() upon Authentication
107 * frame reception.
108 *
109 *LOGIC:
110 * This function processes received Authentication frame and responds
111 * with either next Authentication frame in sequence to peer MAC entity
112 * or LIM_MLM_AUTH_IND on AP or LIM_MLM_AUTH_CNF on STA.
113 *
114 *ASSUMPTIONS:
115 *
116 *NOTE:
117 * 1. Authentication failures are reported to SME with same status code
118 * received from the peer MAC entity.
119 * 2. Authentication frame2/4 received with alogirthm number other than
120 * one requested in frame1/3 are logged with an error and auth confirm
121 * will be sent to SME only after auth failure timeout.
122 * 3. Inconsistency in the spec:
123 * On receiving Auth frame2, specs says that if WEP key mapping key
124 * or default key is NULL, Auth frame3 with a status code 15 (challenge
125 * failure to be returned to peer entity. However, section 7.2.3.10,
126 * table 14 says that status code field is 'reserved' for frame3 !
127 * In the current implementation, Auth frame3 is returned with status
128 * code 15 overriding section 7.2.3.10.
129 * 4. If number pre-authentications reach configrable max limit,
130 * Authentication frame with 'unspecified failure' status code is
131 * returned to requesting entity.
132 *
133 * @param pMac - Pointer to Global MAC structure
134 * @param *pRxPacketInfo - A pointer to Rx packet info structure
135 * @return None
136 */
137
138void
139limProcessAuthFrame(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tpPESession psessionEntry)
140{
141 tANI_U8 *pBody, keyId, cfgPrivacyOptImp,
142 defaultKey[SIR_MAC_KEY_LENGTH],
143 encrAuthFrame[LIM_ENCR_AUTH_BODY_LEN],
144 plainBody[256];
145 tANI_U16 frameLen;
146 //tANI_U32 authRspTimeout, maxNumPreAuth, val;
147 tANI_U32 maxNumPreAuth, val;
148 tSirMacAuthFrameBody *pRxAuthFrameBody, rxAuthFrame, authFrame;
149 tpSirMacMgmtHdr pHdr;
150 tCfgWepKeyEntry *pKeyMapEntry = NULL;
151 struct tLimPreAuthNode *pAuthNode;
152 tLimMlmAuthInd mlmAuthInd;
153 tANI_U8 decryptResult;
154 tANI_U8 *pChallenge;
155 tANI_U32 key_length=8;
156 tANI_U8 challengeTextArray[SIR_MAC_AUTH_CHALLENGE_LENGTH];
Jeff Johnson295189b2012-06-20 16:38:30 -0700157 tpDphHashNode pStaDs = NULL;
158 tANI_U16 assocId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 /* Added For BT -AMP support */
160 // Get pointer to Authentication frame header and body
161
162
163 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
164 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
165
166
167 if (!frameLen)
168 {
169 // Log error
170 limLog(pMac, LOGE,
171 FL("received Authentication frame with no body from "));
172 limPrintMacAddr(pMac, pHdr->sa, LOGE);
173
174 return;
175 }
176
177 if (limIsGroupAddr(pHdr->sa))
178 {
179 // Received Auth frame from a BC/MC address
180 // Log error and ignore it
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530181 PELOGE(limLog(pMac, LOGE,
Jeff Johnson295189b2012-06-20 16:38:30 -0700182 FL("received Auth frame from a BC/MC address - "));)
183 PELOG1( limPrintMacAddr(pMac, pHdr->sa, LOG1);)
184
185 return;
186 }
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530187 limLog(pMac, LOG1,
188 FL("Sessionid: %d System role : %d limMlmState: %d :Auth "
189 "Frame Received: BSSID: "MAC_ADDRESS_STR " (RSSI %d)"),
190 psessionEntry->peSessionId, psessionEntry->limSystemRole,
191 psessionEntry->limMlmState, MAC_ADDR_ARRAY(pHdr->bssId),
192 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo)));
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800193
Jeff Johnson295189b2012-06-20 16:38:30 -0700194 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
195
Jeff Johnsone7245742012-09-05 17:12:55 -0700196 //PELOG3(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG3, (tANI_U8*)pBd, ((tpHalBufDesc) pBd)->mpduDataOffset + frameLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700197
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800198 //Restore default failure timeout
199 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
200 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530201 limLog(pMac, LOG1, FL("Restore default failure timeout"));
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800202 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
203 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
204 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700205
206 /// Determine if WEP bit is set in the FC or received MAC header
207 if (pHdr->fc.wep)
208 {
209 /**
210 * WEP bit is set in FC of MAC header.
211 */
212
Jeff Johnson295189b2012-06-20 16:38:30 -0700213 // If TKIP counter measures enabled issue Deauth frame to station
214 if ((psessionEntry->bTkipCntrMeasActive) && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
215 {
216 PELOGE( limLog(pMac, LOGE,
217 FL("Tkip counter measures Enabled, sending Deauth frame to")); )
218 limPrintMacAddr(pMac, pHdr->sa, LOGE);
219
220 limSendDeauthMgmtFrame( pMac, eSIR_MAC_MIC_FAILURE_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800221 pHdr->sa, psessionEntry, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700222 return;
223 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700224
225 // Extract key ID from IV (most 2 bits of 4th byte of IV)
226
227 keyId = (*(pBody + 3)) >> 6;
228
229 /**
230 * On STA in infrastructure BSS, Authentication frames received
231 * with WEP bit set in the FC must be rejected with challenge
232 * failure status code (wierd thing in the spec - this should have
233 * been rejected with unspecified failure or unexpected assertion
234 * of wep bit (this status code does not exist though) or
235 * Out-of-sequence-Authentication-Frame status code.
236 */
237
238 if (psessionEntry->limSystemRole == eLIM_STA_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)
239 {
240 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
241 authFrame.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
242 authFrame.authStatusCode = eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Abhishek Singh208848c2013-12-18 19:02:52 +0530243 // Log error
244 PELOGE(limLog(pMac, LOGE,
245 FL("received Authentication frame with wep bit set on "
246 "role=%d "MAC_ADDRESS_STR),
247 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pHdr->sa) );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 limSendAuthMgmtFrame(pMac, &authFrame,
249 pHdr->sa,
250 LIM_NO_WEP_IN_FC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700251 return;
252 }
253
254 if (frameLen < LIM_ENCR_AUTH_BODY_LEN)
255 {
256 // Log error
257 limLog(pMac, LOGE,
258 FL("Not enough size [%d] to decrypt received Auth frame"),
259 frameLen);
260 limPrintMacAddr(pMac, pHdr->sa, LOGE);
261
262 return;
263 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
265 {
266 val = psessionEntry->privacy;
267 }
268 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 // Accept Authentication frame only if Privacy is implemented
270 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
271 &val) != eSIR_SUCCESS)
272 {
273 /**
274 * Could not get Privacy option
275 * from CFG. Log error.
276 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700277 limLog(pMac, LOGP, FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 }
279
280 cfgPrivacyOptImp = (tANI_U8)val;
281 if (cfgPrivacyOptImp)
282 {
283 /**
284 * Privacy option is implemented.
285 * Check if the received frame is Authentication
286 * frame3 and there is a context for requesting STA.
287 * If not, reject with unspecified failure status code
288 */
289 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
290
291 if (pAuthNode == NULL)
292 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530293 // Log error
294 PELOGE(limLog(pMac, LOGE,
295 FL("received Authentication frame from peer that has "
296 "no preauth context with WEP bit set "MAC_ADDRESS_STR),
297 MAC_ADDR_ARRAY(pHdr->sa));)
298
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 /**
300 * No 'pre-auth' context exists for this STA that sent
301 * an Authentication frame with FC bit set.
302 * Send Auth frame4 with 'out of sequence' status code.
303 */
304 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
305 authFrame.authTransactionSeqNumber =
306 SIR_MAC_AUTH_FRAME_4;
307 authFrame.authStatusCode =
308 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
309
310 limSendAuthMgmtFrame(pMac, &authFrame,
311 pHdr->sa,
312 LIM_NO_WEP_IN_FC,psessionEntry);
313
Jeff Johnson295189b2012-06-20 16:38:30 -0700314 return;
315 }
316 else
317 {
318 /// Change the auth-response timeout
319 limDeactivateAndChangePerStaIdTimer(pMac,
320 eLIM_AUTH_RSP_TIMER,
321 pAuthNode->authNodeIdx);
322
323 /// 'Pre-auth' status exists for STA
324 if ((pAuthNode->mlmState !=
325 eLIM_MLM_WT_AUTH_FRAME3_STATE) &&
326 (pAuthNode->mlmState !=
327 eLIM_MLM_AUTH_RSP_TIMEOUT_STATE))
328 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530329 // Log error
330 PELOGE(limLog(pMac, LOGE,
331 FL("received Authentication frame from peer that is "
332 "in state %d "MAC_ADDRESS_STR),
333 pAuthNode->mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
334
Jeff Johnson295189b2012-06-20 16:38:30 -0700335 /**
336 * Should not have received Authentication frame
337 * with WEP bit set in FC in other states.
338 * Reject by sending Authenticaton frame with
339 * out of sequence Auth frame status code.
340 */
341
342 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
343 authFrame.authTransactionSeqNumber =
344 SIR_MAC_AUTH_FRAME_4;
345 authFrame.authStatusCode =
346 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
347
348 limSendAuthMgmtFrame(pMac, &authFrame,
349 pHdr->sa,
350 LIM_NO_WEP_IN_FC,psessionEntry);
351
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 return;
353 }
354 }
355
356 /**
357 * Check if there exists a key mappping key
358 * for the STA that sent Authentication frame
359 */
360 pKeyMapEntry = limLookUpKeyMappings(pHdr->sa);
361
362 if (pKeyMapEntry)
363 {
364 if (!pKeyMapEntry->wepOn)
365 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530366 // Log error
367 PELOGE(limLog(pMac, LOGE,
368 FL("received Auth frame3 from peer that has NULL "
369 "key map entry "
370 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));)
371
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 /**
373 * Key Mapping entry has null key.
374 * Send Authentication frame
375 * with challenge failure status code
376 */
377 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
378 authFrame.authTransactionSeqNumber =
379 SIR_MAC_AUTH_FRAME_4;
380 authFrame.authStatusCode =
381 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
382
383 limSendAuthMgmtFrame(pMac, &authFrame,
384 pHdr->sa,
385 LIM_NO_WEP_IN_FC,psessionEntry);
386
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 return;
388 } // if (!pKeyMapEntry->wepOn)
389 else
390 {
391 decryptResult = limDecryptAuthFrame(pMac, pKeyMapEntry->key,
392 pBody,
393 plainBody,
394 key_length,
395 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
396 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
397 {
398 /// ICV failure
Abhishek Singh208848c2013-12-18 19:02:52 +0530399 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
400 "LIM_DECRYPT_ICV_FAIL ..."));)
401 // Log error
402 PELOGE(limLog(pMac, LOGE,
403 FL("received Authentication frame from peer "
404 "that failed decryption, Addr "
405 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
406
Jeff Johnson295189b2012-06-20 16:38:30 -0700407 limDeletePreAuthNode(pMac,
408 pHdr->sa);
409 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
410 authFrame.authTransactionSeqNumber =
411 SIR_MAC_AUTH_FRAME_4;
412 authFrame.authStatusCode =
413 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
414
415 limSendAuthMgmtFrame(
416 pMac, &authFrame,
417 pHdr->sa,
418 LIM_NO_WEP_IN_FC,psessionEntry);
419
Jeff Johnson295189b2012-06-20 16:38:30 -0700420
421 return;
422 }
423
Abhishek Singh208848c2013-12-18 19:02:52 +0530424 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
425 &rxAuthFrame)!=eSIR_SUCCESS ) ||
426 ( !isAuthValid(pMac, &rxAuthFrame,psessionEntry) ) )
427 {
428 PELOGE(limLog(pMac, LOGE,
429 FL("failed to convert Auth Frame to structure "
430 "or Auth is not valid "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700431 return;
Abhishek Singh208848c2013-12-18 19:02:52 +0530432 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700433
434
435 } // end if (pKeyMapEntry->key == NULL)
436 } // if keyMappings has entry
437 else
438 {
439
440 val = SIR_MAC_KEY_LENGTH;
441
Jeff Johnson295189b2012-06-20 16:38:30 -0700442 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
443 {
444 tpSirKeys pKey;
445 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530446 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 val = pKey->keyLength;
448 }
449 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
451 defaultKey, &val) != eSIR_SUCCESS)
452 {
453 /// Could not get Default key from CFG.
454 //Log error.
455 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700456 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700457
458 /**
459 * Send Authentication frame
460 * with challenge failure status code
461 */
462
463 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
464 authFrame.authTransactionSeqNumber =
465 SIR_MAC_AUTH_FRAME_4;
466 authFrame.authStatusCode =
467 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
468
469 limSendAuthMgmtFrame(pMac, &authFrame,
470 pHdr->sa,
471 LIM_NO_WEP_IN_FC,psessionEntry);
472
473 return;
474 }
475
476 key_length=val;
477
478 decryptResult = limDecryptAuthFrame(pMac, defaultKey,
479 pBody,
480 plainBody,
481 key_length,
482 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
483 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
484 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530485 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
486 "LIM_DECRYPT_ICV_FAIL ..."));)
487 // Log error
488 PELOGE(limLog(pMac, LOGE,
489 FL("received Authentication frame from peer that "
490 "failed decryption: "
491 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 /// ICV failure
493 limDeletePreAuthNode(pMac,
494 pHdr->sa);
495 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
496 authFrame.authTransactionSeqNumber =
497 SIR_MAC_AUTH_FRAME_4;
498 authFrame.authStatusCode =
499 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
500
501 limSendAuthMgmtFrame(
502 pMac, &authFrame,
503 pHdr->sa,
504 LIM_NO_WEP_IN_FC,psessionEntry);
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 return;
507 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530508 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530509 &rxAuthFrame)!=eSIR_SUCCESS ) ||
Abhishek Singh208848c2013-12-18 19:02:52 +0530510 ( !isAuthValid(pMac, &rxAuthFrame, psessionEntry) ) )
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530511 {
512 limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +0530513 FL("failed to convert Auth Frame to structure "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530514 "or Auth is not valid "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 return;
Abhishek Singh208848c2013-12-18 19:02:52 +0530516 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700517 } // End of check for Key Mapping/Default key presence
518 }
519 else
520 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530521 // Log error
522 PELOGE(limLog(pMac, LOGE,
523 FL("received Authentication frame3 from peer that while "
524 "privacy option is turned OFF "
525 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 /**
527 * Privacy option is not implemented.
528 * So reject Authentication frame received with
529 * WEP bit set by sending Authentication frame
530 * with 'challenge failure' status code. This is
531 * another strange thing in the spec. Status code
532 * should have been 'unsupported algorithm' status code.
533 */
534
535 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
536 authFrame.authTransactionSeqNumber =
537 SIR_MAC_AUTH_FRAME_4;
538 authFrame.authStatusCode =
539 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
540
541 limSendAuthMgmtFrame(pMac, &authFrame,
542 pHdr->sa,
543 LIM_NO_WEP_IN_FC,psessionEntry);
544
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 return;
546 } // else if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
547 } // if (fc.wep)
548 else
549 {
550
551
Abhishek Singh208848c2013-12-18 19:02:52 +0530552 if ( ( sirConvertAuthFrame2Struct(pMac, pBody,
553 frameLen, &rxAuthFrame)!=eSIR_SUCCESS ) ||
554 ( !isAuthValid(pMac, &rxAuthFrame,psessionEntry) ) )
555 {
556 PELOGE(limLog(pMac, LOGE,
557 FL("failed to convert Auth Frame to structure or Auth is "
558 "not valid "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 return;
Abhishek Singh208848c2013-12-18 19:02:52 +0530560 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 }
562
563
564 pRxAuthFrameBody = &rxAuthFrame;
565
Mohit Khanna23863762012-09-11 17:40:09 -0700566 PELOGW(limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700567 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700568 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
569 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
570 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
571
572 switch (pRxAuthFrameBody->authTransactionSeqNumber)
573 {
574 case SIR_MAC_AUTH_FRAME_1:
575 // AuthFrame 1
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800576
577 pStaDs = dphLookupHashEntry(pMac, pHdr->sa,
578 &assocId, &psessionEntry->dph.dphHashTable);
579 if (pStaDs)
580 {
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530581 tLimMlmDisassocReq *pMlmDisassocReq = NULL;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800582 tLimMlmDeauthReq *pMlmDeauthReq = NULL;
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530583 tAniBool isConnected = eSIR_TRUE;
584
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800585 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
586 if (pMlmDisassocReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530587 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800588 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530589 sizeof(tSirMacAddr))))
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800590 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800591 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for disassoc "
592 "frame is pending Issue delsta for "
593 MAC_ADDRESS_STR),
594 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700595 limProcessDisassocAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530596 isConnected = eSIR_FALSE;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800597 }
598 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
599 if (pMlmDeauthReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530600 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800601 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
602 sizeof(tSirMacAddr))))
603 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800604 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for deauth frame "
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700605 "is pending Issue delsta for "
Arif Hussain24bafea2013-11-15 15:10:03 -0800606 MAC_ADDRESS_STR),
607 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700608 limProcessDeauthAckTimeout(pMac);
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530609 isConnected = eSIR_FALSE;
610 }
611
612 /* pStaDS != NULL and isConnected = 1 means the STA is already
613 * connected, But SAP received the Auth from that station.
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530614 * For non PMF connection send Deauth frame as STA will retry
615 * to connect back.
616 *
617 * For PMF connection the AP should not tear down or otherwise
618 * modify the state of the existing association until the
619 * SA-Query procedure determines that the original SA is
620 * invalid.
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530621 */
Abhishek Singh13fbb1d2014-06-04 19:51:05 +0530622 if (isConnected
623#ifdef WLAN_FEATURE_11W
624 && !pStaDs->rmfEnabled
625#endif
626 )
Abhishek Singhb1c829a2014-05-05 11:06:54 +0530627 {
628 limLog(pMac, LOGE,
629 FL("STA is already connected but received auth frame"
630 "Send the Deauth and lim Delete Station Context"
631 "(staId: %d, assocId: %d) "),
632 pStaDs->staIndex, assocId);
633 limSendDeauthMgmtFrame(pMac, eSIR_MAC_UNSPEC_FAILURE_REASON,
634 (tANI_U8 *) pHdr->sa, psessionEntry, FALSE);
635 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
636 return;
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800637 }
638 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700639
640 /// Check if there exists pre-auth context for this STA
641 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
642 if (pAuthNode)
643 {
644 /// Pre-auth context exists for the STA
645 if (pHdr->fc.retry == 0)
646 {
647 /**
648 * STA is initiating brand-new Authentication
649 * sequence after local Auth Response timeout.
650 * Or STA retrying to transmit First Auth frame due to packet drop OTA
651 * Delete Pre-auth node and fall through.
652 */
653 if(pAuthNode->fTimerStarted)
654 {
655 limDeactivateAndChangePerStaIdTimer(pMac,
656 eLIM_AUTH_RSP_TIMER,
657 pAuthNode->authNodeIdx);
658 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530659 PELOGE(limLog(pMac, LOGE, FL("STA is initiating brand-new "
660 "Authentication ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 limDeletePreAuthNode(pMac,
662 pHdr->sa);
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 /**
664 * SAP Mode:Disassociate the station and
665 * delete its entry if we have its entry
666 * already and received "auth" from the
667 * same station.
668 */
669
670 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
671 {
672 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
673
674 if (NULL == pStaDs)
675 continue;
676
677 if (pStaDs->valid)
678 {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530679 if (vos_mem_compare((tANI_U8 *) &pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 (tANI_U8 *) &(pHdr->sa), (tANI_U8) (sizeof(tSirMacAddr))) )
681 break;
682 }
Edhar, Mahesh Kumar29013e82014-02-05 10:38:08 +0530683
684 pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 }
686
Abhishek Singhe9417492014-09-25 15:55:36 +0530687 if (NULL != pStaDs
688#ifdef WLAN_FEATURE_11W
689 && !pStaDs->rmfEnabled
690#endif
691 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530693 PELOGE(limLog(pMac, LOGE, FL("lim Delete Station "
694 "Context (staId: %d, assocId: %d) "),pStaDs->staIndex,
695 assocId);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 limSendDeauthMgmtFrame(pMac,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800697 eSIR_MAC_UNSPEC_FAILURE_REASON, (tANI_U8 *) pAuthNode->peerMacAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
699 return;
700 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 }
702 else
703 {
704 /*
705 * This can happen when first authentication frame is received
706 * but ACK lost at STA side, in this case 2nd auth frame is already
707 * in transmission queue
708 * */
Abhishek Singh208848c2013-12-18 19:02:52 +0530709 PELOGE(limLog(pMac, LOGE, FL("STA is initiating "
710 "Authentication after ACK lost..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 return;
712 }
713 }
714 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
715 (tANI_U32 *) &maxNumPreAuth) != eSIR_SUCCESS)
716 {
717 /**
718 * Could not get MaxNumPreAuth
719 * from CFG. Log error.
720 */
721 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700722 FL("could not retrieve MaxNumPreAuth"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 if (pMac->lim.gLimNumPreAuthContexts == maxNumPreAuth)
725 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530726 PELOGE(limLog(pMac, LOGE, FL("Max number of "
727 "preauth context reached"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700728 /**
729 * Maximum number of pre-auth contexts
730 * reached. Send Authentication frame
731 * with unspecified failure
732 */
733 authFrame.authAlgoNumber =
734 pRxAuthFrameBody->authAlgoNumber;
735 authFrame.authTransactionSeqNumber =
736 pRxAuthFrameBody->authTransactionSeqNumber + 1;
737 authFrame.authStatusCode =
738 eSIR_MAC_UNSPEC_FAILURE_STATUS;
739
740 limSendAuthMgmtFrame(pMac, &authFrame,
741 pHdr->sa,
742 LIM_NO_WEP_IN_FC,psessionEntry);
743
744 return;
745 }
746 /// No Pre-auth context exists for the STA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 if (limIsAuthAlgoSupported(
748 pMac,
749 (tAniAuthType)
750 pRxAuthFrameBody->authAlgoNumber, psessionEntry))
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 {
752 switch (pRxAuthFrameBody->authAlgoNumber)
753 {
754 case eSIR_OPEN_SYSTEM:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700755 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_OPEN_SYSTEM ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 /// Create entry for this STA in pre-auth list
757 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
758 if (pAuthNode == NULL)
759 {
760 // Log error
761 limLog(pMac, LOGW,
762 FL("Max pre-auth nodes reached "));
763 limPrintMacAddr(pMac, pHdr->sa, LOGW);
764
765 return;
766 }
767
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700768 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer "), pAuthNode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 limPrintMacAddr(pMac, pHdr->sa, LOG1);)
770
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530771 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
772 pHdr->sa,
773 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700774
775 pAuthNode->mlmState =
776 eLIM_MLM_AUTHENTICATED_STATE;
777 pAuthNode->authType = (tAniAuthType)
778 pRxAuthFrameBody->authAlgoNumber;
779 pAuthNode->fSeen = 0;
780 pAuthNode->fTimerStarted = 0;
781 limAddPreAuthNode(pMac, pAuthNode);
782
783 /**
784 * Send Authenticaton frame with Success
785 * status code.
786 */
787
788 authFrame.authAlgoNumber =
789 pRxAuthFrameBody->authAlgoNumber;
790 authFrame.authTransactionSeqNumber =
791 pRxAuthFrameBody->authTransactionSeqNumber + 1;
792 authFrame.authStatusCode = eSIR_MAC_SUCCESS_STATUS;
793 limSendAuthMgmtFrame(
794 pMac, &authFrame,
795 pHdr->sa,
796 LIM_NO_WEP_IN_FC,psessionEntry);
797
798 /// Send Auth indication to SME
799
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530800 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 (tANI_U8 *) pHdr->sa,
802 sizeof(tSirMacAddr));
803 mlmAuthInd.authType = (tAniAuthType)
804 pRxAuthFrameBody->authAlgoNumber;
805 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
806
807 limPostSmeMessage(pMac,
808 LIM_MLM_AUTH_IND,
809 (tANI_U32 *) &mlmAuthInd);
810 break;
811
812 case eSIR_SHARED_KEY:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700813 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_SHARED_KEY ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
815 {
816 val = psessionEntry->privacy;
817 }
818 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
820 &val) != eSIR_SUCCESS)
821 {
822 /**
823 * Could not get Privacy option
824 * from CFG. Log error.
825 */
826 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700827 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 }
829 cfgPrivacyOptImp = (tANI_U8)val;
830 if (!cfgPrivacyOptImp)
831 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530832 // Log error
833 PELOGE(limLog(pMac, LOGE,
834 FL("received Auth frame for unsupported auth algorithm %d "
835 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
836 MAC_ADDR_ARRAY(pHdr->sa));)
837
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 /**
839 * Authenticator does not have WEP
840 * implemented.
841 * Reject by sending Authentication frame
842 * with Auth algorithm not supported status
843 * code.
844 */
845
846 authFrame.authAlgoNumber =
847 pRxAuthFrameBody->authAlgoNumber;
848 authFrame.authTransactionSeqNumber =
849 pRxAuthFrameBody->authTransactionSeqNumber + 1;
850 authFrame.authStatusCode =
851 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
852
853 limSendAuthMgmtFrame(
854 pMac, &authFrame,
855 pHdr->sa,
856 LIM_NO_WEP_IN_FC,psessionEntry);
857
Jeff Johnson295189b2012-06-20 16:38:30 -0700858 return;
859 }
860 else
861 {
862 // Create entry for this STA
863 //in pre-auth list
864 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
865 if (pAuthNode == NULL)
866 {
867 // Log error
868 limLog(pMac, LOGW,
869 FL("Max pre-auth nodes reached "));
870 limPrintMacAddr(pMac, pHdr->sa, LOGW);
871
872 return;
873 }
874
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530875 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
876 pHdr->sa,
877 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700878
879 pAuthNode->mlmState =
880 eLIM_MLM_WT_AUTH_FRAME3_STATE;
881 pAuthNode->authType =
882 (tAniAuthType)
883 pRxAuthFrameBody->authAlgoNumber;
884 pAuthNode->fSeen = 0;
885 pAuthNode->fTimerStarted = 0;
886 limAddPreAuthNode(pMac, pAuthNode);
887
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700888 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x id %d peer "),
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 pAuthNode, pAuthNode->authNodeIdx);)
890 PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);)
891
892 /// Create and activate Auth Response timer
893 if (tx_timer_change_context(&pAuthNode->timer, pAuthNode->authNodeIdx) != TX_SUCCESS)
894 {
895 /// Could not start Auth response timer.
896 // Log error
897 limLog(pMac, LOGP,
898 FL("Unable to chg context auth response timer for peer "));
899 limPrintMacAddr(pMac, pHdr->sa, LOGP);
900
901 /**
902 * Send Authenticaton frame with
903 * unspecified failure status code.
904 */
905
906 authFrame.authAlgoNumber =
907 pRxAuthFrameBody->authAlgoNumber;
908 authFrame.authTransactionSeqNumber =
909 pRxAuthFrameBody->authTransactionSeqNumber + 1;
910 authFrame.authStatusCode =
911 eSIR_MAC_UNSPEC_FAILURE_STATUS;
912
913 limSendAuthMgmtFrame(pMac, &authFrame,
914 pHdr->sa,
915 LIM_NO_WEP_IN_FC,psessionEntry);
916
917 limDeletePreAuthNode(pMac, pHdr->sa);
918 return;
919 }
920
921 limActivateAuthRspTimer(pMac, pAuthNode);
922
923 pAuthNode->fTimerStarted = 1;
924
925 // get random bytes and use as
926 // challenge text
927 // TODO
928 //if( !VOS_IS_STATUS_SUCCESS( vos_rand_get_bytes( 0, (tANI_U8 *)challengeTextArray, SIR_MAC_AUTH_CHALLENGE_LENGTH ) ) )
929 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530930 limLog(pMac, LOGE,FL("Challenge text "
931 "preparation failed in limProcessAuthFrame"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 }
933
934 pChallenge = pAuthNode->challengeText;
935
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530936 vos_mem_copy(pChallenge,
937 (tANI_U8 *) challengeTextArray,
938 sizeof(challengeTextArray));
Jeff Johnson295189b2012-06-20 16:38:30 -0700939
940 /**
941 * Sending Authenticaton frame with challenge.
942 */
943
944 authFrame.authAlgoNumber =
945 pRxAuthFrameBody->authAlgoNumber;
946 authFrame.authTransactionSeqNumber =
947 pRxAuthFrameBody->authTransactionSeqNumber + 1;
948 authFrame.authStatusCode =
949 eSIR_MAC_SUCCESS_STATUS;
950 authFrame.type = SIR_MAC_CHALLENGE_TEXT_EID;
951 authFrame.length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530952 vos_mem_copy(authFrame.challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 pAuthNode->challengeText,
954 SIR_MAC_AUTH_CHALLENGE_LENGTH);
955
956 limSendAuthMgmtFrame(
957 pMac, &authFrame,
958 pHdr->sa,
959 LIM_NO_WEP_IN_FC,psessionEntry);
960 } // if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
961
962 break;
963
964 default:
Abhishek Singh208848c2013-12-18 19:02:52 +0530965 // Log error
966 PELOGE( limLog(pMac, LOGE,
967 FL("received Auth frame for unsupported auth "
968 "algorithm %d "MAC_ADDRESS_STR),
969 pRxAuthFrameBody->authAlgoNumber,
970 MAC_ADDR_ARRAY(pHdr->sa));)
971
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 /**
973 * Responding party does not support the
974 * authentication algorithm requested by
975 * sending party.
976 * Reject by sending Authentication frame
977 * with auth algorithm not supported status code
978 */
979
980 authFrame.authAlgoNumber =
981 pRxAuthFrameBody->authAlgoNumber;
982 authFrame.authTransactionSeqNumber =
983 pRxAuthFrameBody->authTransactionSeqNumber + 1;
984 authFrame.authStatusCode =
985 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
986
987 limSendAuthMgmtFrame(
988 pMac, &authFrame,
989 pHdr->sa,
990 LIM_NO_WEP_IN_FC,psessionEntry);
991
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 return;
993 } // end switch(pRxAuthFrameBody->authAlgoNumber)
994 } // if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
995 else
996 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530997 // Log error
998 PELOGE(limLog(pMac, LOGE,
999 FL("received Authentication frame for unsupported auth "
1000 "algorithm %d "MAC_ADDRESS_STR),
1001 pRxAuthFrameBody->authAlgoNumber,
1002 MAC_ADDR_ARRAY(pHdr->sa));)
1003
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 /**
1005 * Responding party does not support the
1006 * authentication algorithm requested by sending party.
1007 * Reject Authentication with StatusCode=13.
1008 */
1009 authFrame.authAlgoNumber =
1010 pRxAuthFrameBody->authAlgoNumber;
1011 authFrame.authTransactionSeqNumber =
1012 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1013 authFrame.authStatusCode =
1014 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1015
1016 limSendAuthMgmtFrame(pMac, &authFrame,
1017 pHdr->sa,
1018 LIM_NO_WEP_IN_FC,psessionEntry);
1019
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 return;
1021 } //end if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1022 break;
1023
1024 case SIR_MAC_AUTH_FRAME_2:
1025 // AuthFrame 2
1026
1027 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME2_STATE)
1028 {
1029 /**
1030 * Received Authentication frame2 in an unexpected state.
1031 * Log error and ignore the frame.
1032 */
1033
1034 // Log error
1035 PELOG1(limLog(pMac, LOG1,
1036 FL("received Auth frame2 from peer in state %d, addr "),
1037 psessionEntry->limMlmState);)
1038 PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);)
1039
1040 return;
1041 }
1042
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301043 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1044 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1045 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 {
1047 /**
1048 * Received Authentication frame from an entity
1049 * other than one request was initiated.
1050 * Wait until Authentication Failure Timeout.
1051 */
1052
1053 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001054 PELOGW(limLog(pMac, LOGW,
Abhishek Singh208848c2013-12-18 19:02:52 +05301055 FL("received Auth frame2 from unexpected peer "
1056 MAC_ADDRESS_STR),
Mohit Khanna23863762012-09-11 17:40:09 -07001057 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001058
1059 break;
1060 }
1061
1062 if (pRxAuthFrameBody->authStatusCode ==
1063 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS)
1064 {
1065 /**
1066 * Interoperability workaround: Linksys WAP4400N is returning
1067 * wrong authType in OpenAuth response in case of
1068 * SharedKey AP configuration. Pretend we don't see that,
1069 * so upper layer can fallback to SharedKey authType,
1070 * and successfully connect to the AP.
1071 */
1072 if (pRxAuthFrameBody->authAlgoNumber !=
1073 pMac->lim.gpLimMlmAuthReq->authType)
1074 {
1075 pRxAuthFrameBody->authAlgoNumber =
1076 pMac->lim.gpLimMlmAuthReq->authType;
1077 }
1078 }
1079
1080 if (pRxAuthFrameBody->authAlgoNumber !=
1081 pMac->lim.gpLimMlmAuthReq->authType)
1082 {
1083 /**
1084 * Received Authentication frame with an auth
1085 * algorithm other than one requested.
1086 * Wait until Authentication Failure Timeout.
1087 */
1088
1089 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001090 PELOGW(limLog(pMac, LOGW,
1091 FL("received Auth frame2 for unexpected auth algo number %d "
Abhishek Singh208848c2013-12-18 19:02:52 +05301092 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001093 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001094
1095 break;
1096 }
1097
1098 if (pRxAuthFrameBody->authStatusCode ==
1099 eSIR_MAC_SUCCESS_STATUS)
1100 {
1101 if (pRxAuthFrameBody->authAlgoNumber ==
1102 eSIR_OPEN_SYSTEM)
1103 {
1104 psessionEntry->limCurrentAuthType = eSIR_OPEN_SYSTEM;
1105
1106 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1107
1108 if (pAuthNode == NULL)
1109 {
1110 // Log error
1111 limLog(pMac, LOGW,
1112 FL("Max pre-auth nodes reached "));
1113 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1114
1115 return;
1116 }
1117
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001118 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer "), pAuthNode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);)
1120
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301121 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1123 sizeof(tSirMacAddr));
1124 pAuthNode->fTimerStarted = 0;
1125 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
1126 limAddPreAuthNode(pMac, pAuthNode);
1127
1128 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1129 pRxAuthFrameBody->authStatusCode,psessionEntry);
1130 } // if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1131 else
1132 {
1133 // Shared key authentication
1134
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1136 {
1137 val = psessionEntry->privacy;
1138 }
1139 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1141 &val) != eSIR_SUCCESS)
1142 {
1143 /**
1144 * Could not get Privacy option
1145 * from CFG. Log error.
1146 */
1147 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001148 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 }
1150 cfgPrivacyOptImp = (tANI_U8)val;
1151 if (!cfgPrivacyOptImp)
1152 {
1153 /**
1154 * Requesting STA does not have WEP implemented.
1155 * Reject with unsupported authentication algorithm
1156 * Status code and wait until auth failure timeout
1157 */
1158
1159 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001160 PELOGE( limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301161 FL("received Auth frame from peer for "
1162 "unsupported auth algo %d "
1163 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001164 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001165
1166 authFrame.authAlgoNumber =
1167 pRxAuthFrameBody->authAlgoNumber;
1168 authFrame.authTransactionSeqNumber =
1169 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1170 authFrame.authStatusCode =
1171 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1172
1173 limSendAuthMgmtFrame(pMac, &authFrame,
1174 pHdr->sa,
1175 LIM_NO_WEP_IN_FC,psessionEntry);
1176 return;
1177 }
1178 else
1179 {
1180
1181 if (pRxAuthFrameBody->type !=
1182 SIR_MAC_CHALLENGE_TEXT_EID)
1183 {
1184 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001185 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301186 FL("received Auth frame with invalid "
1187 "challenge text IE"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001188
1189 return;
1190 }
1191
1192 /**
1193 * Check if there exists a key mappping key
1194 * for the STA that sent Authentication frame
1195 */
1196 pKeyMapEntry = limLookUpKeyMappings(
1197 pHdr->sa);
1198
1199 if (pKeyMapEntry)
1200 {
1201 if (pKeyMapEntry->key == NULL)
1202 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301203 // Log error
1204 PELOGE(limLog(pMac, LOGE,
1205 FL("received Auth frame from peer when "
1206 "key mapping key is NULL"MAC_ADDRESS_STR),
1207 MAC_ADDR_ARRAY(pHdr->sa));)
1208
Jeff Johnson295189b2012-06-20 16:38:30 -07001209 /**
1210 * Key Mapping entry has null key.
1211 * Send Auth frame with
1212 * challenge failure status code
1213 */
1214 authFrame.authAlgoNumber =
1215 pRxAuthFrameBody->authAlgoNumber;
1216 authFrame.authTransactionSeqNumber =
1217 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1218 authFrame.authStatusCode =
1219 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1220
1221 limSendAuthMgmtFrame(pMac, &authFrame,
1222 pHdr->sa,
1223 LIM_NO_WEP_IN_FC,psessionEntry);
1224
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 limRestoreFromAuthState(pMac, eSIR_SME_NO_KEY_MAPPING_KEY_FOR_PEER,
1226 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1227
1228 return;
1229 } // if (pKeyMapEntry->key == NULL)
1230 else
1231 {
1232 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1233 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1234 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1235 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1236 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1237 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
1238 ((tpSirMacAuthFrameBody) plainBody)->length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301239 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 pRxAuthFrameBody->challengeText,
1241 SIR_MAC_AUTH_CHALLENGE_LENGTH);
1242
1243 limEncryptAuthFrame(pMac, 0,
1244 pKeyMapEntry->key,
1245 plainBody,
1246 encrAuthFrame,key_length);
1247
1248 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001249 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001250
1251 limSendAuthMgmtFrame(pMac,
1252 (tpSirMacAuthFrameBody) encrAuthFrame,
1253 pHdr->sa,
1254 LIM_WEP_IN_FC,psessionEntry);
1255
1256 break;
1257 } // end if (pKeyMapEntry->key == NULL)
1258 } // if (pKeyMapEntry)
1259 else
1260 {
1261 if (wlan_cfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID,
1262 &val) != eSIR_SUCCESS)
1263 {
1264 /**
1265 * Could not get Default keyId
1266 * from CFG. Log error.
1267 */
1268 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001269 FL("could not retrieve Default keyId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 }
1271 keyId = (tANI_U8)val;
1272
1273 val = SIR_MAC_KEY_LENGTH;
1274
Jeff Johnson295189b2012-06-20 16:38:30 -07001275 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1276 {
1277 tpSirKeys pKey;
1278 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301279 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 }
1281 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
1283 defaultKey,
1284 &val)
1285 != eSIR_SUCCESS)
1286 {
1287 /// Could not get Default key from CFG.
1288 //Log error.
1289 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001290 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001291
1292 authFrame.authAlgoNumber =
1293 pRxAuthFrameBody->authAlgoNumber;
1294 authFrame.authTransactionSeqNumber =
1295 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1296 authFrame.authStatusCode =
1297 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1298
1299 limSendAuthMgmtFrame(
1300 pMac, &authFrame,
1301 pHdr->sa,
1302 LIM_NO_WEP_IN_FC,psessionEntry);
1303
1304 limRestoreFromAuthState(pMac, eSIR_SME_INVALID_WEP_DEFAULT_KEY,
1305 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1306
1307 break;
1308 }
1309 key_length=val;
1310 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1311 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1312 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1313 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1314 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1315 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
1316 ((tpSirMacAuthFrameBody) plainBody)->length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301317 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 pRxAuthFrameBody->challengeText,
1319 SIR_MAC_AUTH_CHALLENGE_LENGTH);
1320
1321 limEncryptAuthFrame(pMac, keyId,
1322 defaultKey,
1323 plainBody,
1324 encrAuthFrame,key_length);
1325
1326 psessionEntry->limMlmState =
1327 eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001328 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001329
1330 limSendAuthMgmtFrame(pMac,
1331 (tpSirMacAuthFrameBody) encrAuthFrame,
1332 pHdr->sa,
1333 LIM_WEP_IN_FC,psessionEntry);
1334
1335 break;
1336 } // end if (pKeyMapEntry)
1337 } // end if (!wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1338 } // end if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1339 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1340 else
1341 {
1342 /**
1343 * Authentication failure.
1344 * Return Auth confirm with received failure code to SME
1345 */
1346
1347 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001348 PELOGE(limLog(pMac, LOGE,
1349 FL("received Auth frame from peer with failure code %d "
1350 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1351 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001352
1353 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1354 pRxAuthFrameBody->authStatusCode,psessionEntry);
1355 } // end if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1356
1357 break;
1358
1359 case SIR_MAC_AUTH_FRAME_3:
1360 // AuthFrame 3
1361
1362 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1363 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301364 // Log error
1365 PELOGE(limLog(pMac, LOGE,
1366 FL("received Auth frame3 from peer with auth algo "
1367 "number %d "MAC_ADDRESS_STR),
1368 pRxAuthFrameBody->authAlgoNumber,
1369 MAC_ADDR_ARRAY(pHdr->sa));)
1370
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 /**
1372 * Received Authentication frame3 with algorithm other than
1373 * Shared Key authentication type. Reject with Auth frame4
1374 * with 'out of sequence' status code.
1375 */
1376 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1377 authFrame.authTransactionSeqNumber =
1378 SIR_MAC_AUTH_FRAME_4;
1379 authFrame.authStatusCode =
1380 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1381
1382 limSendAuthMgmtFrame(pMac, &authFrame,
1383 pHdr->sa,
1384 LIM_NO_WEP_IN_FC,psessionEntry);
1385
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 return;
1387 }
1388
1389 if (psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE ||
1390 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
1391 {
1392 /**
1393 * Check if wep bit was set in FC. If not set,
1394 * reject with Authentication frame4 with
1395 * 'challenge failure' status code.
1396 */
1397 if (!pHdr->fc.wep)
1398 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301399 // Log error
1400 PELOGE(limLog(pMac, LOGE,
1401 FL("received Auth frame3 from peer with no WEP bit "
1402 "set "MAC_ADDRESS_STR),
1403 MAC_ADDR_ARRAY(pHdr->sa));)
1404
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 /// WEP bit is not set in FC of Auth Frame3
1406 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1407 authFrame.authTransactionSeqNumber =
1408 SIR_MAC_AUTH_FRAME_4;
1409 authFrame.authStatusCode =
1410 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1411
1412 limSendAuthMgmtFrame(pMac, &authFrame,
1413 pHdr->sa,
1414 LIM_NO_WEP_IN_FC,psessionEntry);
1415
Jeff Johnson295189b2012-06-20 16:38:30 -07001416 return;
1417 }
1418
1419 pAuthNode = limSearchPreAuthList(pMac,
1420 pHdr->sa);
1421 if (pAuthNode == NULL)
1422 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301423 // Log error
1424 PELOGE(limLog(pMac, LOGW,
1425 FL("received AuthFrame3 from peer that has no "
1426 "preauth context "MAC_ADDRESS_STR),
1427 MAC_ADDR_ARRAY(pHdr->sa));)
1428
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 /**
1430 * No 'pre-auth' context exists for
1431 * this STA that sent an Authentication
1432 * frame3.
1433 * Send Auth frame4 with 'out of sequence'
1434 * status code.
1435 */
1436 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1437 authFrame.authTransactionSeqNumber =
1438 SIR_MAC_AUTH_FRAME_4;
1439 authFrame.authStatusCode =
1440 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1441
1442 limSendAuthMgmtFrame(pMac, &authFrame,
1443 pHdr->sa,
1444 LIM_NO_WEP_IN_FC,psessionEntry);
1445
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 return;
1447 }
1448
1449 if (pAuthNode->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)
1450 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301451 // Log error
1452 limLog(pMac, LOGW,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301453 FL("auth response timer timedout for peer "
1454 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 /**
1456 * Received Auth Frame3 after Auth Response timeout.
1457 * Reject by sending Auth Frame4 with
1458 * Auth respone timeout Status Code.
1459 */
1460 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1461 authFrame.authTransactionSeqNumber =
1462 SIR_MAC_AUTH_FRAME_4;
1463 authFrame.authStatusCode =
1464 eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS;
1465
1466 limSendAuthMgmtFrame(
1467 pMac, &authFrame,
1468 pHdr->sa,
1469 LIM_NO_WEP_IN_FC,psessionEntry);
1470
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 /// Delete pre-auth context of STA
1472 limDeletePreAuthNode(pMac,
1473 pHdr->sa);
1474
1475 return;
1476 } // end switch (pAuthNode->mlmState)
1477
1478 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1479 {
1480 /**
1481 * Received Authenetication Frame 3 with status code
1482 * other than success. Wait until Auth response timeout
1483 * to delete STA context.
1484 */
1485
1486 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001487 PELOGE(limLog(pMac, LOGE,
1488 FL("received Auth frame3 from peer with status code %d "
1489 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1490 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001491
1492 return;
1493 }
1494
1495 /**
1496 * Check if received challenge text is same as one sent in
1497 * Authentication frame3
1498 */
1499
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301500 if (vos_mem_compare(pRxAuthFrameBody->challengeText,
1501 pAuthNode->challengeText,
1502 SIR_MAC_AUTH_CHALLENGE_LENGTH))
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 {
1504 /// Challenge match. STA is autheticated !
1505
1506 /// Delete Authentication response timer if running
1507 limDeactivateAndChangePerStaIdTimer(pMac,
1508 eLIM_AUTH_RSP_TIMER,
1509 pAuthNode->authNodeIdx);
1510
1511 pAuthNode->fTimerStarted = 0;
1512 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1513
1514 /**
1515 * Send Authentication Frame4 with 'success' Status Code.
1516 */
1517 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1518 authFrame.authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001519 SIR_MAC_AUTH_FRAME_4;
Jeff Johnson295189b2012-06-20 16:38:30 -07001520 authFrame.authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1521
1522 limSendAuthMgmtFrame(pMac, &authFrame,
1523 pHdr->sa,
1524 LIM_NO_WEP_IN_FC,psessionEntry);
1525
1526 /// Send Auth indication to SME
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301527 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 (tANI_U8 *) pHdr->sa,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301529 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 mlmAuthInd.authType = (tAniAuthType)
1531 pRxAuthFrameBody->authAlgoNumber;
1532 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
1533
1534 limPostSmeMessage(pMac,
1535 LIM_MLM_AUTH_IND,
1536 (tANI_U32 *) &mlmAuthInd);
1537
1538 break;
1539 }
1540 else
1541 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301542 // Log error
1543 PELOGE( limLog(pMac, LOGW,
1544 FL("Challenge failure for peer "
1545 MAC_ADDRESS_STR),
1546 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 /**
1548 * Challenge Failure.
1549 * Send Authentication frame4 with 'challenge failure'
1550 * status code and wait until Auth response timeout to
1551 * delete STA context.
1552 */
1553
1554 authFrame.authAlgoNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001555 pRxAuthFrameBody->authAlgoNumber;
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 authFrame.authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001557 SIR_MAC_AUTH_FRAME_4;
Jeff Johnson295189b2012-06-20 16:38:30 -07001558 authFrame.authStatusCode =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001559 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001560
1561 limSendAuthMgmtFrame(pMac, &authFrame,
1562 pHdr->sa,
1563 LIM_NO_WEP_IN_FC,psessionEntry);
1564
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 return;
1566 }
1567 } // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE || ...
1568
1569 break;
1570
1571 case SIR_MAC_AUTH_FRAME_4:
1572 // AuthFrame 4
1573 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE)
1574 {
1575 /**
1576 * Received Authentication frame4 in an unexpected state.
1577 * Log error and ignore the frame.
1578 */
1579
1580 // Log error
1581 PELOG1(limLog(pMac, LOG1,
Abhishek Singh208848c2013-12-18 19:02:52 +05301582 FL("received unexpected Auth frame4 from peer in state "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301583 "%d, addr "MAC_ADDRESS_STR), psessionEntry->limMlmState,
1584 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001585
1586 return;
1587 }
1588
1589 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1590 {
1591 /**
1592 * Received Authentication frame4 with algorithm other than
1593 * Shared Key authentication type.
1594 * Wait until Auth failure timeout to report authentication
1595 * failure to SME.
1596 */
1597
1598 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001599 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301600 FL("received Auth frame4 from peer with invalid auth "
1601 "algo %d "MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001602 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001603
1604 return;
1605 }
1606
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301607 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1608 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1609 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 {
1611 /**
1612 * Received Authentication frame from an entity
1613 * other than one to which request was initiated.
1614 * Wait until Authentication Failure Timeout.
1615 */
1616
1617 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001618 PELOGE(limLog(pMac, LOGW,
1619 FL("received Auth frame4 from unexpected peer "
1620 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001621
1622 break;
1623 }
1624
1625 if (pRxAuthFrameBody->authAlgoNumber !=
1626 pMac->lim.gpLimMlmAuthReq->authType)
1627 {
1628 /**
1629 * Received Authentication frame with an auth algorithm
1630 * other than one requested.
1631 * Wait until Authentication Failure Timeout.
1632 */
1633
Mohit Khanna23863762012-09-11 17:40:09 -07001634 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301635 FL("received Authentication frame from peer with "
1636 "invalid auth seq number %d "
1637 MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001638 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001639
1640 break;
1641 }
1642
1643 if (pRxAuthFrameBody->authStatusCode ==
1644 eSIR_MAC_SUCCESS_STATUS)
1645 {
1646 /**
1647 * Authentication Success !
1648 * Inform SME of same.
1649 */
1650 psessionEntry->limCurrentAuthType = eSIR_SHARED_KEY;
1651
1652 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1653 if (pAuthNode == NULL)
1654 {
1655 // Log error
1656 limLog(pMac, LOGW,
1657 FL("Max pre-auth nodes reached "));
1658 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1659
1660 return;
1661 }
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001662 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer "), pAuthNode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 limPrintMacAddr(pMac, pHdr->sa, LOG1);)
1664
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301665 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1667 sizeof(tSirMacAddr));
1668 pAuthNode->fTimerStarted = 0;
1669 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
1670 limAddPreAuthNode(pMac, pAuthNode);
1671
1672 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1673 pRxAuthFrameBody->authStatusCode,psessionEntry);
1674
1675 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1676 else
1677 {
1678 /**
1679 * Authentication failure.
1680 * Return Auth confirm with received failure code to SME
1681 */
1682
1683 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001684 PELOGE(limLog(pMac, LOGE, FL("Authentication failure from peer "
1685 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001686
1687 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1688 pRxAuthFrameBody->authStatusCode,psessionEntry);
1689 } // end if (pRxAuthFrameBody->Status == 0)
1690
1691 break;
1692
1693 default:
1694 /// Invalid Authentication Frame received. Ignore it.
1695
1696 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001697 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301698 FL("received Auth frame from peer with invalid auth seq "
1699 "number %d " MAC_ADDRESS_STR),
1700 pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001701 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001702
1703 break;
1704 } // end switch (pRxAuthFrameBody->authTransactionSeqNumber)
1705} /*** end limProcessAuthFrame() ***/
1706
1707
1708
1709
1710
1711#ifdef WLAN_FEATURE_VOWIFI_11R
1712
1713/*----------------------------------------------------------------------
1714 *
1715 * Pass the received Auth frame. This is possibly the pre-auth from the
1716 * neighbor AP, in the same mobility domain.
1717 * This will be used in case of 11r FT.
1718 *
1719 * !!!! This is going to be renoved for the next checkin. We will be creating
1720 * the session before sending out the Auth. Thus when auth response
1721 * is received we will have a session in progress. !!!!!
1722 *----------------------------------------------------------------------
1723 */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001724tSirRetStatus limProcessAuthFrameNoSession(tpAniSirGlobal pMac, tANI_U8 *pBd, void *body)
Jeff Johnson295189b2012-06-20 16:38:30 -07001725{
1726 tpSirMacMgmtHdr pHdr;
1727 tpPESession psessionEntry = NULL;
1728 tANI_U8 *pBody;
1729 tANI_U16 frameLen;
1730 tSirMacAuthFrameBody rxAuthFrame;
1731 tSirMacAuthFrameBody *pRxAuthFrameBody = NULL;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001732 tSirRetStatus ret_status = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001733
1734 pHdr = WDA_GET_RX_MAC_HEADER(pBd);
1735 pBody = WDA_GET_RX_MPDU_DATA(pBd);
1736 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd);
1737
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301738 limLog(pMac, LOG1, FL("Auth Frame Received: BSSID " MAC_ADDRESS_STR
1739 " (RSSI %d)"),MAC_ADDR_ARRAY(pHdr->bssId),
1740 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 // Check for the operating channel and see what needs to be done next.
1742 psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
1743 if (psessionEntry == NULL)
1744 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301745 limLog(pMac, LOGE, FL("Error: Unable to find session id while in "
1746 "pre-auth phase for FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 return eSIR_FAILURE;
1748 }
1749
1750 if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL)
1751 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301752 limLog(pMac, LOGE, FL("Error: No FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 // No FT in progress.
1754 return eSIR_FAILURE;
1755 }
1756
1757 if (frameLen == 0)
1758 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301759 limLog(pMac, LOGE, FL("Error: Frame len = 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 return eSIR_FAILURE;
1761 }
1762#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001763 limPrintMacAddr(pMac, pHdr->bssId, LOG2);
1764 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOG2);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001765 limLog(pMac,LOG2,FL("seqControl 0x%X"),
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001766 ((pHdr->seqControl.seqNumHi << 8) |
1767 (pHdr->seqControl.seqNumLo << 4) |
1768 (pHdr->seqControl.fragNum)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001769#endif
1770
1771 // Check that its the same bssId we have for preAuth
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301772 if (!vos_mem_compare(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1773 pHdr->bssId, sizeof( tSirMacAddr )))
Jeff Johnson295189b2012-06-20 16:38:30 -07001774 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301775 limLog(pMac, LOGE, FL("Error: NOT same bssid as preauth BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 // In this case SME if indeed has triggered a
1777 // pre auth it will time out.
1778 return eSIR_FAILURE;
1779 }
1780
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001781 if (eANI_BOOLEAN_TRUE ==
1782 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed)
1783 {
1784 /*
1785 * This is likely a duplicate for the same pre-auth request.
1786 * PE/LIM already posted a response to SME. Hence, drop it.
1787 * TBD:
1788 * 1) How did we even receive multiple auth responses?
1789 * 2) Do we need to delete pre-auth session? Suppose we
1790 * previously received an auth resp with failure which
1791 * would not have created the session and forwarded to SME.
1792 * And, we subsequently received an auth resp with success
1793 * which would have created the session. This will now be
1794 * dropped without being forwarded to SME! However, it is
1795 * very unlikely to receive auth responses from the same
1796 * AP with different reason codes.
1797 * NOTE: return eSIR_SUCCESS so that the packet is dropped
1798 * as this was indeed a response from the BSSID we tried to
1799 * pre-auth.
1800 */
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001801 PELOGE(limLog(pMac,LOG1,"Auth rsp already posted to SME"
1802 " (session %p, FT session %p)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001803 pMac->ft.ftPEContext.pftSessionEntry););
1804 return eSIR_SUCCESS;
1805 }
1806 else
1807 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001808 PELOGE(limLog(pMac,LOGW,"Auth rsp not yet posted to SME"
1809 " (session %p, FT session %p)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001810 pMac->ft.ftPEContext.pftSessionEntry););
1811 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
1812 eANI_BOOLEAN_TRUE;
1813 }
1814
Jeff Johnson295189b2012-06-20 16:38:30 -07001815#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001816 limLog(pMac, LOG1, FL("Pre-Auth response received from neighbor"));
1817 limLog(pMac, LOG1, FL("Pre-Auth done state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001818#endif
1819 // Stopping timer now, that we have our unicast from the AP
1820 // of our choice.
1821 limDeactivateAndChangeTimer(pMac, eLIM_FT_PREAUTH_RSP_TIMER);
1822
1823
1824 // Save off the auth resp.
1825 if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame) != eSIR_SUCCESS))
1826 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301827 limLog(pMac, LOGE, FL("failed to convert Auth frame to struct"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
1829 return eSIR_FAILURE;
1830 }
1831 pRxAuthFrameBody = &rxAuthFrame;
1832
1833#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001834 PELOGE(limLog(pMac, LOG1,
1835 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
1837 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
1838 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
1839#endif
1840
1841 switch (pRxAuthFrameBody->authTransactionSeqNumber)
1842 {
1843 case SIR_MAC_AUTH_FRAME_2:
1844 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1845 {
1846#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001847 PELOGE(limLog( pMac, LOGE, "Auth status code received is %d",
1848 (tANI_U32) pRxAuthFrameBody->authStatusCode););
Jeff Johnson295189b2012-06-20 16:38:30 -07001849#endif
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001850 if (eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS == pRxAuthFrameBody->authStatusCode)
1851 ret_status = eSIR_LIM_MAX_STA_REACHED_ERROR;
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 }
1853 else
1854 {
1855 ret_status = eSIR_SUCCESS;
1856 }
1857 break;
1858
1859 default:
1860#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001861 PELOGE(limLog( pMac, LOGE, "Seq. no incorrect expected 2 received %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001862 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber);)
1863#endif
1864 break;
1865 }
1866
1867 // Send the Auth response to SME
1868 limHandleFTPreAuthRsp(pMac, ret_status, pBody, frameLen, psessionEntry);
1869
1870 return ret_status;
1871}
1872
1873#endif /* WLAN_FEATURE_VOWIFI_11R */
1874