blob: 00e4dd58f93b54e55ffea760b6c146cca37e47a7 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2013 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
6/*
Jeff Johnson295189b2012-06-20 16:38:30 -07007 * This file limProcessAuthFrame.cc contains the code
8 * for processing received Authentication Frame.
9 * Author: Chandra Modumudi
10 * Date: 03/11/02
11 * History:-
12 * Date Modified by Modification Information
13 * --------------------------------------------------------------------
14 * 05/12/2010 js To support Shared key authentication at AP side
15 *
16 */
17
18#include "wniApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070019#include "wniCfgSta.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070020#include "aniGlobal.h"
21#include "cfgApi.h"
22
23#include "utilsApi.h"
24#include "limUtils.h"
25#include "limAssocUtils.h"
26#include "limSecurityUtils.h"
27#include "limSerDesUtils.h"
28#ifdef WLAN_FEATURE_VOWIFI_11R
29#include "limFT.h"
30#endif
31#include "vos_utils.h"
32
33
34/**
35 * isAuthValid
36 *
37 *FUNCTION:
38 * This function is called by limProcessAuthFrame() upon Authentication
39 * frame reception.
40 *
41 *LOGIC:
42 * This function is used to test validity of auth frame:
43 * - AUTH1 and AUTH3 must be received in AP mode
44 * - AUTH2 and AUTH4 must be received in STA mode
45 * - AUTH3 and AUTH4 must have challenge text IE, that is,'type' field has been set to
46 * SIR_MAC_CHALLENGE_TEXT_EID by parser
47 * -
48 *
49 *ASSUMPTIONS:
50 *
51 *NOTE:
52 *
53 * @param *auth - Pointer to extracted auth frame body
54 *
55 * @return 0 or 1 (Valid)
56 */
57
58
59static inline unsigned int isAuthValid(tpAniSirGlobal pMac, tpSirMacAuthFrameBody auth,tpPESession sessionEntry) {
60 unsigned int valid;
61 valid=1;
62
63 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_1)||
64 (auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)) &&
65 ((sessionEntry->limSystemRole == eLIM_STA_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)))
66 valid=0;
67
68 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_2)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&&
69 ((sessionEntry->limSystemRole == eLIM_AP_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)))
70 valid=0;
71
72 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&&
73 (auth->type!=SIR_MAC_CHALLENGE_TEXT_EID)&&(auth->authAlgoNumber != eSIR_SHARED_KEY))
74 valid=0;
75
76 return valid;
77}
78
79
80/**
81 * limProcessAuthFrame
82 *
83 *FUNCTION:
84 * This function is called by limProcessMessageQueue() upon Authentication
85 * frame reception.
86 *
87 *LOGIC:
88 * This function processes received Authentication frame and responds
89 * with either next Authentication frame in sequence to peer MAC entity
90 * or LIM_MLM_AUTH_IND on AP or LIM_MLM_AUTH_CNF on STA.
91 *
92 *ASSUMPTIONS:
93 *
94 *NOTE:
95 * 1. Authentication failures are reported to SME with same status code
96 * received from the peer MAC entity.
97 * 2. Authentication frame2/4 received with alogirthm number other than
98 * one requested in frame1/3 are logged with an error and auth confirm
99 * will be sent to SME only after auth failure timeout.
100 * 3. Inconsistency in the spec:
101 * On receiving Auth frame2, specs says that if WEP key mapping key
102 * or default key is NULL, Auth frame3 with a status code 15 (challenge
103 * failure to be returned to peer entity. However, section 7.2.3.10,
104 * table 14 says that status code field is 'reserved' for frame3 !
105 * In the current implementation, Auth frame3 is returned with status
106 * code 15 overriding section 7.2.3.10.
107 * 4. If number pre-authentications reach configrable max limit,
108 * Authentication frame with 'unspecified failure' status code is
109 * returned to requesting entity.
110 *
111 * @param pMac - Pointer to Global MAC structure
112 * @param *pRxPacketInfo - A pointer to Rx packet info structure
113 * @return None
114 */
115
116void
117limProcessAuthFrame(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tpPESession psessionEntry)
118{
119 tANI_U8 *pBody, keyId, cfgPrivacyOptImp,
120 defaultKey[SIR_MAC_KEY_LENGTH],
121 encrAuthFrame[LIM_ENCR_AUTH_BODY_LEN],
122 plainBody[256];
123 tANI_U16 frameLen;
124 //tANI_U32 authRspTimeout, maxNumPreAuth, val;
125 tANI_U32 maxNumPreAuth, val;
126 tSirMacAuthFrameBody *pRxAuthFrameBody, rxAuthFrame, authFrame;
127 tpSirMacMgmtHdr pHdr;
128 tCfgWepKeyEntry *pKeyMapEntry = NULL;
129 struct tLimPreAuthNode *pAuthNode;
130 tLimMlmAuthInd mlmAuthInd;
131 tANI_U8 decryptResult;
132 tANI_U8 *pChallenge;
133 tANI_U32 key_length=8;
134 tANI_U8 challengeTextArray[SIR_MAC_AUTH_CHALLENGE_LENGTH];
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 tpDphHashNode pStaDs = NULL;
136 tANI_U16 assocId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 /* Added For BT -AMP support */
138 // Get pointer to Authentication frame header and body
139
140
141 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
142 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
143
144
145 if (!frameLen)
146 {
147 // Log error
148 limLog(pMac, LOGE,
149 FL("received Authentication frame with no body from "));
150 limPrintMacAddr(pMac, pHdr->sa, LOGE);
151
152 return;
153 }
154
155 if (limIsGroupAddr(pHdr->sa))
156 {
157 // Received Auth frame from a BC/MC address
158 // Log error and ignore it
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530159 PELOGE(limLog(pMac, LOGE,
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 FL("received Auth frame from a BC/MC address - "));)
161 PELOG1( limPrintMacAddr(pMac, pHdr->sa, LOG1);)
162
163 return;
164 }
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530165 limLog(pMac, LOG1,
166 FL("Sessionid: %d System role : %d limMlmState: %d :Auth "
167 "Frame Received: BSSID: "MAC_ADDRESS_STR " (RSSI %d)"),
168 psessionEntry->peSessionId, psessionEntry->limSystemRole,
169 psessionEntry->limMlmState, MAC_ADDR_ARRAY(pHdr->bssId),
170 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo)));
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800171
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
173
Jeff Johnsone7245742012-09-05 17:12:55 -0700174 //PELOG3(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG3, (tANI_U8*)pBd, ((tpHalBufDesc) pBd)->mpduDataOffset + frameLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700175
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800176 //Restore default failure timeout
177 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
178 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530179 limLog(pMac, LOG1, FL("Restore default failure timeout"));
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800180 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
181 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
182 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700183
184 /// Determine if WEP bit is set in the FC or received MAC header
185 if (pHdr->fc.wep)
186 {
187 /**
188 * WEP bit is set in FC of MAC header.
189 */
190
Jeff Johnson295189b2012-06-20 16:38:30 -0700191 // If TKIP counter measures enabled issue Deauth frame to station
192 if ((psessionEntry->bTkipCntrMeasActive) && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
193 {
194 PELOGE( limLog(pMac, LOGE,
195 FL("Tkip counter measures Enabled, sending Deauth frame to")); )
196 limPrintMacAddr(pMac, pHdr->sa, LOGE);
197
198 limSendDeauthMgmtFrame( pMac, eSIR_MAC_MIC_FAILURE_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800199 pHdr->sa, psessionEntry, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700200 return;
201 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700202
203 // Extract key ID from IV (most 2 bits of 4th byte of IV)
204
205 keyId = (*(pBody + 3)) >> 6;
206
207 /**
208 * On STA in infrastructure BSS, Authentication frames received
209 * with WEP bit set in the FC must be rejected with challenge
210 * failure status code (wierd thing in the spec - this should have
211 * been rejected with unspecified failure or unexpected assertion
212 * of wep bit (this status code does not exist though) or
213 * Out-of-sequence-Authentication-Frame status code.
214 */
215
216 if (psessionEntry->limSystemRole == eLIM_STA_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)
217 {
218 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
219 authFrame.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
220 authFrame.authStatusCode = eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Abhishek Singh208848c2013-12-18 19:02:52 +0530221 // Log error
222 PELOGE(limLog(pMac, LOGE,
223 FL("received Authentication frame with wep bit set on "
224 "role=%d "MAC_ADDRESS_STR),
225 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pHdr->sa) );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700226 limSendAuthMgmtFrame(pMac, &authFrame,
227 pHdr->sa,
228 LIM_NO_WEP_IN_FC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 return;
230 }
231
232 if (frameLen < LIM_ENCR_AUTH_BODY_LEN)
233 {
234 // Log error
235 limLog(pMac, LOGE,
236 FL("Not enough size [%d] to decrypt received Auth frame"),
237 frameLen);
238 limPrintMacAddr(pMac, pHdr->sa, LOGE);
239
240 return;
241 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700242 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
243 {
244 val = psessionEntry->privacy;
245 }
246 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700247 // Accept Authentication frame only if Privacy is implemented
248 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
249 &val) != eSIR_SUCCESS)
250 {
251 /**
252 * Could not get Privacy option
253 * from CFG. Log error.
254 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700255 limLog(pMac, LOGP, FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 }
257
258 cfgPrivacyOptImp = (tANI_U8)val;
259 if (cfgPrivacyOptImp)
260 {
261 /**
262 * Privacy option is implemented.
263 * Check if the received frame is Authentication
264 * frame3 and there is a context for requesting STA.
265 * If not, reject with unspecified failure status code
266 */
267 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
268
269 if (pAuthNode == NULL)
270 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530271 // Log error
272 PELOGE(limLog(pMac, LOGE,
273 FL("received Authentication frame from peer that has "
274 "no preauth context with WEP bit set "MAC_ADDRESS_STR),
275 MAC_ADDR_ARRAY(pHdr->sa));)
276
Jeff Johnson295189b2012-06-20 16:38:30 -0700277 /**
278 * No 'pre-auth' context exists for this STA that sent
279 * an Authentication frame with FC bit set.
280 * Send Auth frame4 with 'out of sequence' status code.
281 */
282 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
283 authFrame.authTransactionSeqNumber =
284 SIR_MAC_AUTH_FRAME_4;
285 authFrame.authStatusCode =
286 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
287
288 limSendAuthMgmtFrame(pMac, &authFrame,
289 pHdr->sa,
290 LIM_NO_WEP_IN_FC,psessionEntry);
291
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 return;
293 }
294 else
295 {
296 /// Change the auth-response timeout
297 limDeactivateAndChangePerStaIdTimer(pMac,
298 eLIM_AUTH_RSP_TIMER,
299 pAuthNode->authNodeIdx);
300
301 /// 'Pre-auth' status exists for STA
302 if ((pAuthNode->mlmState !=
303 eLIM_MLM_WT_AUTH_FRAME3_STATE) &&
304 (pAuthNode->mlmState !=
305 eLIM_MLM_AUTH_RSP_TIMEOUT_STATE))
306 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530307 // Log error
308 PELOGE(limLog(pMac, LOGE,
309 FL("received Authentication frame from peer that is "
310 "in state %d "MAC_ADDRESS_STR),
311 pAuthNode->mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
312
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 /**
314 * Should not have received Authentication frame
315 * with WEP bit set in FC in other states.
316 * Reject by sending Authenticaton frame with
317 * out of sequence Auth frame status code.
318 */
319
320 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
321 authFrame.authTransactionSeqNumber =
322 SIR_MAC_AUTH_FRAME_4;
323 authFrame.authStatusCode =
324 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
325
326 limSendAuthMgmtFrame(pMac, &authFrame,
327 pHdr->sa,
328 LIM_NO_WEP_IN_FC,psessionEntry);
329
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 return;
331 }
332 }
333
334 /**
335 * Check if there exists a key mappping key
336 * for the STA that sent Authentication frame
337 */
338 pKeyMapEntry = limLookUpKeyMappings(pHdr->sa);
339
340 if (pKeyMapEntry)
341 {
342 if (!pKeyMapEntry->wepOn)
343 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530344 // Log error
345 PELOGE(limLog(pMac, LOGE,
346 FL("received Auth frame3 from peer that has NULL "
347 "key map entry "
348 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));)
349
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 /**
351 * Key Mapping entry has null key.
352 * Send Authentication frame
353 * with challenge failure status code
354 */
355 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
356 authFrame.authTransactionSeqNumber =
357 SIR_MAC_AUTH_FRAME_4;
358 authFrame.authStatusCode =
359 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
360
361 limSendAuthMgmtFrame(pMac, &authFrame,
362 pHdr->sa,
363 LIM_NO_WEP_IN_FC,psessionEntry);
364
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 return;
366 } // if (!pKeyMapEntry->wepOn)
367 else
368 {
369 decryptResult = limDecryptAuthFrame(pMac, pKeyMapEntry->key,
370 pBody,
371 plainBody,
372 key_length,
373 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
374 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
375 {
376 /// ICV failure
Abhishek Singh208848c2013-12-18 19:02:52 +0530377 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
378 "LIM_DECRYPT_ICV_FAIL ..."));)
379 // Log error
380 PELOGE(limLog(pMac, LOGE,
381 FL("received Authentication frame from peer "
382 "that failed decryption, Addr "
383 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
384
Jeff Johnson295189b2012-06-20 16:38:30 -0700385 limDeletePreAuthNode(pMac,
386 pHdr->sa);
387 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
388 authFrame.authTransactionSeqNumber =
389 SIR_MAC_AUTH_FRAME_4;
390 authFrame.authStatusCode =
391 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
392
393 limSendAuthMgmtFrame(
394 pMac, &authFrame,
395 pHdr->sa,
396 LIM_NO_WEP_IN_FC,psessionEntry);
397
Jeff Johnson295189b2012-06-20 16:38:30 -0700398
399 return;
400 }
401
Abhishek Singh208848c2013-12-18 19:02:52 +0530402 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
403 &rxAuthFrame)!=eSIR_SUCCESS ) ||
404 ( !isAuthValid(pMac, &rxAuthFrame,psessionEntry) ) )
405 {
406 PELOGE(limLog(pMac, LOGE,
407 FL("failed to convert Auth Frame to structure "
408 "or Auth is not valid "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 return;
Abhishek Singh208848c2013-12-18 19:02:52 +0530410 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700411
412
413 } // end if (pKeyMapEntry->key == NULL)
414 } // if keyMappings has entry
415 else
416 {
417
418 val = SIR_MAC_KEY_LENGTH;
419
Jeff Johnson295189b2012-06-20 16:38:30 -0700420 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
421 {
422 tpSirKeys pKey;
423 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530424 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -0700425 val = pKey->keyLength;
426 }
427 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700428 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
429 defaultKey, &val) != eSIR_SUCCESS)
430 {
431 /// Could not get Default key from CFG.
432 //Log error.
433 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700434 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700435
436 /**
437 * Send Authentication frame
438 * with challenge failure status code
439 */
440
441 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
442 authFrame.authTransactionSeqNumber =
443 SIR_MAC_AUTH_FRAME_4;
444 authFrame.authStatusCode =
445 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
446
447 limSendAuthMgmtFrame(pMac, &authFrame,
448 pHdr->sa,
449 LIM_NO_WEP_IN_FC,psessionEntry);
450
451 return;
452 }
453
454 key_length=val;
455
456 decryptResult = limDecryptAuthFrame(pMac, defaultKey,
457 pBody,
458 plainBody,
459 key_length,
460 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
461 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
462 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530463 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == "
464 "LIM_DECRYPT_ICV_FAIL ..."));)
465 // Log error
466 PELOGE(limLog(pMac, LOGE,
467 FL("received Authentication frame from peer that "
468 "failed decryption: "
469 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 /// ICV failure
471 limDeletePreAuthNode(pMac,
472 pHdr->sa);
473 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
474 authFrame.authTransactionSeqNumber =
475 SIR_MAC_AUTH_FRAME_4;
476 authFrame.authStatusCode =
477 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
478
479 limSendAuthMgmtFrame(
480 pMac, &authFrame,
481 pHdr->sa,
482 LIM_NO_WEP_IN_FC,psessionEntry);
483
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 return;
485 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530486 if ( ( sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530487 &rxAuthFrame)!=eSIR_SUCCESS ) ||
Abhishek Singh208848c2013-12-18 19:02:52 +0530488 ( !isAuthValid(pMac, &rxAuthFrame, psessionEntry) ) )
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530489 {
490 limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +0530491 FL("failed to convert Auth Frame to structure "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +0530492 "or Auth is not valid "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 return;
Abhishek Singh208848c2013-12-18 19:02:52 +0530494 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 } // End of check for Key Mapping/Default key presence
496 }
497 else
498 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530499 // Log error
500 PELOGE(limLog(pMac, LOGE,
501 FL("received Authentication frame3 from peer that while "
502 "privacy option is turned OFF "
503 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700504 /**
505 * Privacy option is not implemented.
506 * So reject Authentication frame received with
507 * WEP bit set by sending Authentication frame
508 * with 'challenge failure' status code. This is
509 * another strange thing in the spec. Status code
510 * should have been 'unsupported algorithm' status code.
511 */
512
513 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
514 authFrame.authTransactionSeqNumber =
515 SIR_MAC_AUTH_FRAME_4;
516 authFrame.authStatusCode =
517 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
518
519 limSendAuthMgmtFrame(pMac, &authFrame,
520 pHdr->sa,
521 LIM_NO_WEP_IN_FC,psessionEntry);
522
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 return;
524 } // else if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
525 } // if (fc.wep)
526 else
527 {
528
529
Abhishek Singh208848c2013-12-18 19:02:52 +0530530 if ( ( sirConvertAuthFrame2Struct(pMac, pBody,
531 frameLen, &rxAuthFrame)!=eSIR_SUCCESS ) ||
532 ( !isAuthValid(pMac, &rxAuthFrame,psessionEntry) ) )
533 {
534 PELOGE(limLog(pMac, LOGE,
535 FL("failed to convert Auth Frame to structure or Auth is "
536 "not valid "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 return;
Abhishek Singh208848c2013-12-18 19:02:52 +0530538 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 }
540
541
542 pRxAuthFrameBody = &rxAuthFrame;
543
Mohit Khanna23863762012-09-11 17:40:09 -0700544 PELOGW(limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700545 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
547 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
548 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
549
550 switch (pRxAuthFrameBody->authTransactionSeqNumber)
551 {
552 case SIR_MAC_AUTH_FRAME_1:
553 // AuthFrame 1
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800554
555 pStaDs = dphLookupHashEntry(pMac, pHdr->sa,
556 &assocId, &psessionEntry->dph.dphHashTable);
557 if (pStaDs)
558 {
559 tLimMlmDisassocReq *pMlmDisassocReq = NULL;
560 tLimMlmDeauthReq *pMlmDeauthReq = NULL;
561 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
562 if (pMlmDisassocReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530563 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800564 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530565 sizeof(tSirMacAddr))))
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800566 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800567 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for disassoc "
568 "frame is pending Issue delsta for "
569 MAC_ADDRESS_STR),
570 MAC_ADDR_ARRAY(pMlmDisassocReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700571 limProcessDisassocAckTimeout(pMac);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800572 }
573 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
574 if (pMlmDeauthReq &&
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530575 (vos_mem_compare((tANI_U8 *) pHdr->sa,
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800576 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
577 sizeof(tSirMacAddr))))
578 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800579 PELOGE(limLog(pMac, LOGE, FL("TODO:Ack for deauth frame "
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700580 "is pending Issue delsta for "
Arif Hussain24bafea2013-11-15 15:10:03 -0800581 MAC_ADDRESS_STR),
582 MAC_ADDR_ARRAY(pMlmDeauthReq->peerMacAddr));)
Sudhir Sattayappa Kohalli446de942013-07-24 18:20:02 -0700583 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800584 }
585 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700586
587 /// Check if there exists pre-auth context for this STA
588 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
589 if (pAuthNode)
590 {
591 /// Pre-auth context exists for the STA
592 if (pHdr->fc.retry == 0)
593 {
594 /**
595 * STA is initiating brand-new Authentication
596 * sequence after local Auth Response timeout.
597 * Or STA retrying to transmit First Auth frame due to packet drop OTA
598 * Delete Pre-auth node and fall through.
599 */
600 if(pAuthNode->fTimerStarted)
601 {
602 limDeactivateAndChangePerStaIdTimer(pMac,
603 eLIM_AUTH_RSP_TIMER,
604 pAuthNode->authNodeIdx);
605 }
Abhishek Singh208848c2013-12-18 19:02:52 +0530606 PELOGE(limLog(pMac, LOGE, FL("STA is initiating brand-new "
607 "Authentication ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 limDeletePreAuthNode(pMac,
609 pHdr->sa);
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 /**
611 * SAP Mode:Disassociate the station and
612 * delete its entry if we have its entry
613 * already and received "auth" from the
614 * same station.
615 */
616
617 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
618 {
619 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
620
621 if (NULL == pStaDs)
622 continue;
623
624 if (pStaDs->valid)
625 {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530626 if (vos_mem_compare((tANI_U8 *) &pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 (tANI_U8 *) &(pHdr->sa), (tANI_U8) (sizeof(tSirMacAddr))) )
628 break;
629 }
Edhar, Mahesh Kumar29013e82014-02-05 10:38:08 +0530630
631 pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 }
633
634 if (NULL != pStaDs)
635 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530636 PELOGE(limLog(pMac, LOGE, FL("lim Delete Station "
637 "Context (staId: %d, assocId: %d) "),pStaDs->staIndex,
638 assocId);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 limSendDeauthMgmtFrame(pMac,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800640 eSIR_MAC_UNSPEC_FAILURE_REASON, (tANI_U8 *) pAuthNode->peerMacAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
642 return;
643 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 }
645 else
646 {
647 /*
648 * This can happen when first authentication frame is received
649 * but ACK lost at STA side, in this case 2nd auth frame is already
650 * in transmission queue
651 * */
Abhishek Singh208848c2013-12-18 19:02:52 +0530652 PELOGE(limLog(pMac, LOGE, FL("STA is initiating "
653 "Authentication after ACK lost..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 return;
655 }
656 }
657 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
658 (tANI_U32 *) &maxNumPreAuth) != eSIR_SUCCESS)
659 {
660 /**
661 * Could not get MaxNumPreAuth
662 * from CFG. Log error.
663 */
664 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700665 FL("could not retrieve MaxNumPreAuth"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 if (pMac->lim.gLimNumPreAuthContexts == maxNumPreAuth)
668 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530669 PELOGE(limLog(pMac, LOGE, FL("Max number of "
670 "preauth context reached"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700671 /**
672 * Maximum number of pre-auth contexts
673 * reached. Send Authentication frame
674 * with unspecified failure
675 */
676 authFrame.authAlgoNumber =
677 pRxAuthFrameBody->authAlgoNumber;
678 authFrame.authTransactionSeqNumber =
679 pRxAuthFrameBody->authTransactionSeqNumber + 1;
680 authFrame.authStatusCode =
681 eSIR_MAC_UNSPEC_FAILURE_STATUS;
682
683 limSendAuthMgmtFrame(pMac, &authFrame,
684 pHdr->sa,
685 LIM_NO_WEP_IN_FC,psessionEntry);
686
687 return;
688 }
689 /// No Pre-auth context exists for the STA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 if (limIsAuthAlgoSupported(
691 pMac,
692 (tAniAuthType)
693 pRxAuthFrameBody->authAlgoNumber, psessionEntry))
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 {
695 switch (pRxAuthFrameBody->authAlgoNumber)
696 {
697 case eSIR_OPEN_SYSTEM:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700698 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_OPEN_SYSTEM ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 /// Create entry for this STA in pre-auth list
700 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
701 if (pAuthNode == NULL)
702 {
703 // Log error
704 limLog(pMac, LOGW,
705 FL("Max pre-auth nodes reached "));
706 limPrintMacAddr(pMac, pHdr->sa, LOGW);
707
708 return;
709 }
710
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700711 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer "), pAuthNode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 limPrintMacAddr(pMac, pHdr->sa, LOG1);)
713
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530714 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
715 pHdr->sa,
716 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700717
718 pAuthNode->mlmState =
719 eLIM_MLM_AUTHENTICATED_STATE;
720 pAuthNode->authType = (tAniAuthType)
721 pRxAuthFrameBody->authAlgoNumber;
722 pAuthNode->fSeen = 0;
723 pAuthNode->fTimerStarted = 0;
724 limAddPreAuthNode(pMac, pAuthNode);
725
726 /**
727 * Send Authenticaton frame with Success
728 * status code.
729 */
730
731 authFrame.authAlgoNumber =
732 pRxAuthFrameBody->authAlgoNumber;
733 authFrame.authTransactionSeqNumber =
734 pRxAuthFrameBody->authTransactionSeqNumber + 1;
735 authFrame.authStatusCode = eSIR_MAC_SUCCESS_STATUS;
736 limSendAuthMgmtFrame(
737 pMac, &authFrame,
738 pHdr->sa,
739 LIM_NO_WEP_IN_FC,psessionEntry);
740
741 /// Send Auth indication to SME
742
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530743 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 (tANI_U8 *) pHdr->sa,
745 sizeof(tSirMacAddr));
746 mlmAuthInd.authType = (tAniAuthType)
747 pRxAuthFrameBody->authAlgoNumber;
748 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
749
750 limPostSmeMessage(pMac,
751 LIM_MLM_AUTH_IND,
752 (tANI_U32 *) &mlmAuthInd);
753 break;
754
755 case eSIR_SHARED_KEY:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700756 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_SHARED_KEY ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
758 {
759 val = psessionEntry->privacy;
760 }
761 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
763 &val) != eSIR_SUCCESS)
764 {
765 /**
766 * Could not get Privacy option
767 * from CFG. Log error.
768 */
769 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700770 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700771 }
772 cfgPrivacyOptImp = (tANI_U8)val;
773 if (!cfgPrivacyOptImp)
774 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530775 // Log error
776 PELOGE(limLog(pMac, LOGE,
777 FL("received Auth frame for unsupported auth algorithm %d "
778 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
779 MAC_ADDR_ARRAY(pHdr->sa));)
780
Jeff Johnson295189b2012-06-20 16:38:30 -0700781 /**
782 * Authenticator does not have WEP
783 * implemented.
784 * Reject by sending Authentication frame
785 * with Auth algorithm not supported status
786 * code.
787 */
788
789 authFrame.authAlgoNumber =
790 pRxAuthFrameBody->authAlgoNumber;
791 authFrame.authTransactionSeqNumber =
792 pRxAuthFrameBody->authTransactionSeqNumber + 1;
793 authFrame.authStatusCode =
794 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
795
796 limSendAuthMgmtFrame(
797 pMac, &authFrame,
798 pHdr->sa,
799 LIM_NO_WEP_IN_FC,psessionEntry);
800
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 return;
802 }
803 else
804 {
805 // Create entry for this STA
806 //in pre-auth list
807 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
808 if (pAuthNode == NULL)
809 {
810 // Log error
811 limLog(pMac, LOGW,
812 FL("Max pre-auth nodes reached "));
813 limPrintMacAddr(pMac, pHdr->sa, LOGW);
814
815 return;
816 }
817
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530818 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
819 pHdr->sa,
820 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700821
822 pAuthNode->mlmState =
823 eLIM_MLM_WT_AUTH_FRAME3_STATE;
824 pAuthNode->authType =
825 (tAniAuthType)
826 pRxAuthFrameBody->authAlgoNumber;
827 pAuthNode->fSeen = 0;
828 pAuthNode->fTimerStarted = 0;
829 limAddPreAuthNode(pMac, pAuthNode);
830
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700831 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x id %d peer "),
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 pAuthNode, pAuthNode->authNodeIdx);)
833 PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);)
834
835 /// Create and activate Auth Response timer
836 if (tx_timer_change_context(&pAuthNode->timer, pAuthNode->authNodeIdx) != TX_SUCCESS)
837 {
838 /// Could not start Auth response timer.
839 // Log error
840 limLog(pMac, LOGP,
841 FL("Unable to chg context auth response timer for peer "));
842 limPrintMacAddr(pMac, pHdr->sa, LOGP);
843
844 /**
845 * Send Authenticaton frame with
846 * unspecified failure status code.
847 */
848
849 authFrame.authAlgoNumber =
850 pRxAuthFrameBody->authAlgoNumber;
851 authFrame.authTransactionSeqNumber =
852 pRxAuthFrameBody->authTransactionSeqNumber + 1;
853 authFrame.authStatusCode =
854 eSIR_MAC_UNSPEC_FAILURE_STATUS;
855
856 limSendAuthMgmtFrame(pMac, &authFrame,
857 pHdr->sa,
858 LIM_NO_WEP_IN_FC,psessionEntry);
859
860 limDeletePreAuthNode(pMac, pHdr->sa);
861 return;
862 }
863
864 limActivateAuthRspTimer(pMac, pAuthNode);
865
866 pAuthNode->fTimerStarted = 1;
867
868 // get random bytes and use as
869 // challenge text
870 // TODO
871 //if( !VOS_IS_STATUS_SUCCESS( vos_rand_get_bytes( 0, (tANI_U8 *)challengeTextArray, SIR_MAC_AUTH_CHALLENGE_LENGTH ) ) )
872 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530873 limLog(pMac, LOGE,FL("Challenge text "
874 "preparation failed in limProcessAuthFrame"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 }
876
877 pChallenge = pAuthNode->challengeText;
878
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530879 vos_mem_copy(pChallenge,
880 (tANI_U8 *) challengeTextArray,
881 sizeof(challengeTextArray));
Jeff Johnson295189b2012-06-20 16:38:30 -0700882
883 /**
884 * Sending Authenticaton frame with challenge.
885 */
886
887 authFrame.authAlgoNumber =
888 pRxAuthFrameBody->authAlgoNumber;
889 authFrame.authTransactionSeqNumber =
890 pRxAuthFrameBody->authTransactionSeqNumber + 1;
891 authFrame.authStatusCode =
892 eSIR_MAC_SUCCESS_STATUS;
893 authFrame.type = SIR_MAC_CHALLENGE_TEXT_EID;
894 authFrame.length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530895 vos_mem_copy(authFrame.challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 pAuthNode->challengeText,
897 SIR_MAC_AUTH_CHALLENGE_LENGTH);
898
899 limSendAuthMgmtFrame(
900 pMac, &authFrame,
901 pHdr->sa,
902 LIM_NO_WEP_IN_FC,psessionEntry);
903 } // if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
904
905 break;
906
907 default:
Abhishek Singh208848c2013-12-18 19:02:52 +0530908 // Log error
909 PELOGE( limLog(pMac, LOGE,
910 FL("received Auth frame for unsupported auth "
911 "algorithm %d "MAC_ADDRESS_STR),
912 pRxAuthFrameBody->authAlgoNumber,
913 MAC_ADDR_ARRAY(pHdr->sa));)
914
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 /**
916 * Responding party does not support the
917 * authentication algorithm requested by
918 * sending party.
919 * Reject by sending Authentication frame
920 * with auth algorithm not supported status code
921 */
922
923 authFrame.authAlgoNumber =
924 pRxAuthFrameBody->authAlgoNumber;
925 authFrame.authTransactionSeqNumber =
926 pRxAuthFrameBody->authTransactionSeqNumber + 1;
927 authFrame.authStatusCode =
928 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
929
930 limSendAuthMgmtFrame(
931 pMac, &authFrame,
932 pHdr->sa,
933 LIM_NO_WEP_IN_FC,psessionEntry);
934
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 return;
936 } // end switch(pRxAuthFrameBody->authAlgoNumber)
937 } // if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
938 else
939 {
Abhishek Singh208848c2013-12-18 19:02:52 +0530940 // Log error
941 PELOGE(limLog(pMac, LOGE,
942 FL("received Authentication frame for unsupported auth "
943 "algorithm %d "MAC_ADDRESS_STR),
944 pRxAuthFrameBody->authAlgoNumber,
945 MAC_ADDR_ARRAY(pHdr->sa));)
946
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 /**
948 * Responding party does not support the
949 * authentication algorithm requested by sending party.
950 * Reject Authentication with StatusCode=13.
951 */
952 authFrame.authAlgoNumber =
953 pRxAuthFrameBody->authAlgoNumber;
954 authFrame.authTransactionSeqNumber =
955 pRxAuthFrameBody->authTransactionSeqNumber + 1;
956 authFrame.authStatusCode =
957 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
958
959 limSendAuthMgmtFrame(pMac, &authFrame,
960 pHdr->sa,
961 LIM_NO_WEP_IN_FC,psessionEntry);
962
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 return;
964 } //end if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
965 break;
966
967 case SIR_MAC_AUTH_FRAME_2:
968 // AuthFrame 2
969
970 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME2_STATE)
971 {
972 /**
973 * Received Authentication frame2 in an unexpected state.
974 * Log error and ignore the frame.
975 */
976
977 // Log error
978 PELOG1(limLog(pMac, LOG1,
979 FL("received Auth frame2 from peer in state %d, addr "),
980 psessionEntry->limMlmState);)
981 PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);)
982
983 return;
984 }
985
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530986 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
987 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
988 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 {
990 /**
991 * Received Authentication frame from an entity
992 * other than one request was initiated.
993 * Wait until Authentication Failure Timeout.
994 */
995
996 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -0700997 PELOGW(limLog(pMac, LOGW,
Abhishek Singh208848c2013-12-18 19:02:52 +0530998 FL("received Auth frame2 from unexpected peer "
999 MAC_ADDRESS_STR),
Mohit Khanna23863762012-09-11 17:40:09 -07001000 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001001
1002 break;
1003 }
1004
1005 if (pRxAuthFrameBody->authStatusCode ==
1006 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS)
1007 {
1008 /**
1009 * Interoperability workaround: Linksys WAP4400N is returning
1010 * wrong authType in OpenAuth response in case of
1011 * SharedKey AP configuration. Pretend we don't see that,
1012 * so upper layer can fallback to SharedKey authType,
1013 * and successfully connect to the AP.
1014 */
1015 if (pRxAuthFrameBody->authAlgoNumber !=
1016 pMac->lim.gpLimMlmAuthReq->authType)
1017 {
1018 pRxAuthFrameBody->authAlgoNumber =
1019 pMac->lim.gpLimMlmAuthReq->authType;
1020 }
1021 }
1022
1023 if (pRxAuthFrameBody->authAlgoNumber !=
1024 pMac->lim.gpLimMlmAuthReq->authType)
1025 {
1026 /**
1027 * Received Authentication frame with an auth
1028 * algorithm other than one requested.
1029 * Wait until Authentication Failure Timeout.
1030 */
1031
1032 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001033 PELOGW(limLog(pMac, LOGW,
1034 FL("received Auth frame2 for unexpected auth algo number %d "
Abhishek Singh208848c2013-12-18 19:02:52 +05301035 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001036 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001037
1038 break;
1039 }
1040
1041 if (pRxAuthFrameBody->authStatusCode ==
1042 eSIR_MAC_SUCCESS_STATUS)
1043 {
1044 if (pRxAuthFrameBody->authAlgoNumber ==
1045 eSIR_OPEN_SYSTEM)
1046 {
1047 psessionEntry->limCurrentAuthType = eSIR_OPEN_SYSTEM;
1048
1049 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1050
1051 if (pAuthNode == NULL)
1052 {
1053 // Log error
1054 limLog(pMac, LOGW,
1055 FL("Max pre-auth nodes reached "));
1056 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1057
1058 return;
1059 }
1060
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001061 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer "), pAuthNode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);)
1063
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301064 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1066 sizeof(tSirMacAddr));
1067 pAuthNode->fTimerStarted = 0;
1068 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
1069 limAddPreAuthNode(pMac, pAuthNode);
1070
1071 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1072 pRxAuthFrameBody->authStatusCode,psessionEntry);
1073 } // if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1074 else
1075 {
1076 // Shared key authentication
1077
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1079 {
1080 val = psessionEntry->privacy;
1081 }
1082 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1084 &val) != eSIR_SUCCESS)
1085 {
1086 /**
1087 * Could not get Privacy option
1088 * from CFG. Log error.
1089 */
1090 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001091 FL("could not retrieve Privacy option"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 }
1093 cfgPrivacyOptImp = (tANI_U8)val;
1094 if (!cfgPrivacyOptImp)
1095 {
1096 /**
1097 * Requesting STA does not have WEP implemented.
1098 * Reject with unsupported authentication algorithm
1099 * Status code and wait until auth failure timeout
1100 */
1101
1102 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001103 PELOGE( limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301104 FL("received Auth frame from peer for "
1105 "unsupported auth algo %d "
1106 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001107 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001108
1109 authFrame.authAlgoNumber =
1110 pRxAuthFrameBody->authAlgoNumber;
1111 authFrame.authTransactionSeqNumber =
1112 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1113 authFrame.authStatusCode =
1114 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1115
1116 limSendAuthMgmtFrame(pMac, &authFrame,
1117 pHdr->sa,
1118 LIM_NO_WEP_IN_FC,psessionEntry);
1119 return;
1120 }
1121 else
1122 {
1123
1124 if (pRxAuthFrameBody->type !=
1125 SIR_MAC_CHALLENGE_TEXT_EID)
1126 {
1127 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001128 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301129 FL("received Auth frame with invalid "
1130 "challenge text IE"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001131
1132 return;
1133 }
1134
1135 /**
1136 * Check if there exists a key mappping key
1137 * for the STA that sent Authentication frame
1138 */
1139 pKeyMapEntry = limLookUpKeyMappings(
1140 pHdr->sa);
1141
1142 if (pKeyMapEntry)
1143 {
1144 if (pKeyMapEntry->key == NULL)
1145 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301146 // Log error
1147 PELOGE(limLog(pMac, LOGE,
1148 FL("received Auth frame from peer when "
1149 "key mapping key is NULL"MAC_ADDRESS_STR),
1150 MAC_ADDR_ARRAY(pHdr->sa));)
1151
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 /**
1153 * Key Mapping entry has null key.
1154 * Send Auth frame with
1155 * challenge failure status code
1156 */
1157 authFrame.authAlgoNumber =
1158 pRxAuthFrameBody->authAlgoNumber;
1159 authFrame.authTransactionSeqNumber =
1160 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1161 authFrame.authStatusCode =
1162 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1163
1164 limSendAuthMgmtFrame(pMac, &authFrame,
1165 pHdr->sa,
1166 LIM_NO_WEP_IN_FC,psessionEntry);
1167
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 limRestoreFromAuthState(pMac, eSIR_SME_NO_KEY_MAPPING_KEY_FOR_PEER,
1169 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1170
1171 return;
1172 } // if (pKeyMapEntry->key == NULL)
1173 else
1174 {
1175 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1176 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1177 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1178 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1179 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1180 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
1181 ((tpSirMacAuthFrameBody) plainBody)->length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301182 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001183 pRxAuthFrameBody->challengeText,
1184 SIR_MAC_AUTH_CHALLENGE_LENGTH);
1185
1186 limEncryptAuthFrame(pMac, 0,
1187 pKeyMapEntry->key,
1188 plainBody,
1189 encrAuthFrame,key_length);
1190
1191 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001192 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001193
1194 limSendAuthMgmtFrame(pMac,
1195 (tpSirMacAuthFrameBody) encrAuthFrame,
1196 pHdr->sa,
1197 LIM_WEP_IN_FC,psessionEntry);
1198
1199 break;
1200 } // end if (pKeyMapEntry->key == NULL)
1201 } // if (pKeyMapEntry)
1202 else
1203 {
1204 if (wlan_cfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID,
1205 &val) != eSIR_SUCCESS)
1206 {
1207 /**
1208 * Could not get Default keyId
1209 * from CFG. Log error.
1210 */
1211 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001212 FL("could not retrieve Default keyId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 }
1214 keyId = (tANI_U8)val;
1215
1216 val = SIR_MAC_KEY_LENGTH;
1217
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1219 {
1220 tpSirKeys pKey;
1221 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301222 vos_mem_copy(defaultKey, pKey->key, pKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 }
1224 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
1226 defaultKey,
1227 &val)
1228 != eSIR_SUCCESS)
1229 {
1230 /// Could not get Default key from CFG.
1231 //Log error.
1232 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001233 FL("could not retrieve Default key"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001234
1235 authFrame.authAlgoNumber =
1236 pRxAuthFrameBody->authAlgoNumber;
1237 authFrame.authTransactionSeqNumber =
1238 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1239 authFrame.authStatusCode =
1240 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1241
1242 limSendAuthMgmtFrame(
1243 pMac, &authFrame,
1244 pHdr->sa,
1245 LIM_NO_WEP_IN_FC,psessionEntry);
1246
1247 limRestoreFromAuthState(pMac, eSIR_SME_INVALID_WEP_DEFAULT_KEY,
1248 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1249
1250 break;
1251 }
1252 key_length=val;
1253 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1254 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1255 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1256 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1257 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1258 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
1259 ((tpSirMacAuthFrameBody) plainBody)->length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301260 vos_mem_copy((tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 pRxAuthFrameBody->challengeText,
1262 SIR_MAC_AUTH_CHALLENGE_LENGTH);
1263
1264 limEncryptAuthFrame(pMac, keyId,
1265 defaultKey,
1266 plainBody,
1267 encrAuthFrame,key_length);
1268
1269 psessionEntry->limMlmState =
1270 eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001271 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001272
1273 limSendAuthMgmtFrame(pMac,
1274 (tpSirMacAuthFrameBody) encrAuthFrame,
1275 pHdr->sa,
1276 LIM_WEP_IN_FC,psessionEntry);
1277
1278 break;
1279 } // end if (pKeyMapEntry)
1280 } // end if (!wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1281 } // end if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1282 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1283 else
1284 {
1285 /**
1286 * Authentication failure.
1287 * Return Auth confirm with received failure code to SME
1288 */
1289
1290 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001291 PELOGE(limLog(pMac, LOGE,
1292 FL("received Auth frame from peer with failure code %d "
1293 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1294 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001295
1296 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1297 pRxAuthFrameBody->authStatusCode,psessionEntry);
1298 } // end if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1299
1300 break;
1301
1302 case SIR_MAC_AUTH_FRAME_3:
1303 // AuthFrame 3
1304
1305 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1306 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301307 // Log error
1308 PELOGE(limLog(pMac, LOGE,
1309 FL("received Auth frame3 from peer with auth algo "
1310 "number %d "MAC_ADDRESS_STR),
1311 pRxAuthFrameBody->authAlgoNumber,
1312 MAC_ADDR_ARRAY(pHdr->sa));)
1313
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 /**
1315 * Received Authentication frame3 with algorithm other than
1316 * Shared Key authentication type. Reject with Auth frame4
1317 * with 'out of sequence' status code.
1318 */
1319 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1320 authFrame.authTransactionSeqNumber =
1321 SIR_MAC_AUTH_FRAME_4;
1322 authFrame.authStatusCode =
1323 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1324
1325 limSendAuthMgmtFrame(pMac, &authFrame,
1326 pHdr->sa,
1327 LIM_NO_WEP_IN_FC,psessionEntry);
1328
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 return;
1330 }
1331
1332 if (psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE ||
1333 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
1334 {
1335 /**
1336 * Check if wep bit was set in FC. If not set,
1337 * reject with Authentication frame4 with
1338 * 'challenge failure' status code.
1339 */
1340 if (!pHdr->fc.wep)
1341 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301342 // Log error
1343 PELOGE(limLog(pMac, LOGE,
1344 FL("received Auth frame3 from peer with no WEP bit "
1345 "set "MAC_ADDRESS_STR),
1346 MAC_ADDR_ARRAY(pHdr->sa));)
1347
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 /// WEP bit is not set in FC of Auth Frame3
1349 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1350 authFrame.authTransactionSeqNumber =
1351 SIR_MAC_AUTH_FRAME_4;
1352 authFrame.authStatusCode =
1353 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1354
1355 limSendAuthMgmtFrame(pMac, &authFrame,
1356 pHdr->sa,
1357 LIM_NO_WEP_IN_FC,psessionEntry);
1358
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 return;
1360 }
1361
1362 pAuthNode = limSearchPreAuthList(pMac,
1363 pHdr->sa);
1364 if (pAuthNode == NULL)
1365 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301366 // Log error
1367 PELOGE(limLog(pMac, LOGW,
1368 FL("received AuthFrame3 from peer that has no "
1369 "preauth context "MAC_ADDRESS_STR),
1370 MAC_ADDR_ARRAY(pHdr->sa));)
1371
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 /**
1373 * No 'pre-auth' context exists for
1374 * this STA that sent an Authentication
1375 * frame3.
1376 * Send Auth frame4 with 'out of sequence'
1377 * status code.
1378 */
1379 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1380 authFrame.authTransactionSeqNumber =
1381 SIR_MAC_AUTH_FRAME_4;
1382 authFrame.authStatusCode =
1383 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1384
1385 limSendAuthMgmtFrame(pMac, &authFrame,
1386 pHdr->sa,
1387 LIM_NO_WEP_IN_FC,psessionEntry);
1388
Jeff Johnson295189b2012-06-20 16:38:30 -07001389 return;
1390 }
1391
1392 if (pAuthNode->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)
1393 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301394 // Log error
1395 limLog(pMac, LOGW,
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301396 FL("auth response timer timedout for peer "
1397 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -07001398 /**
1399 * Received Auth Frame3 after Auth Response timeout.
1400 * Reject by sending Auth Frame4 with
1401 * Auth respone timeout Status Code.
1402 */
1403 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1404 authFrame.authTransactionSeqNumber =
1405 SIR_MAC_AUTH_FRAME_4;
1406 authFrame.authStatusCode =
1407 eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS;
1408
1409 limSendAuthMgmtFrame(
1410 pMac, &authFrame,
1411 pHdr->sa,
1412 LIM_NO_WEP_IN_FC,psessionEntry);
1413
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 /// Delete pre-auth context of STA
1415 limDeletePreAuthNode(pMac,
1416 pHdr->sa);
1417
1418 return;
1419 } // end switch (pAuthNode->mlmState)
1420
1421 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1422 {
1423 /**
1424 * Received Authenetication Frame 3 with status code
1425 * other than success. Wait until Auth response timeout
1426 * to delete STA context.
1427 */
1428
1429 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001430 PELOGE(limLog(pMac, LOGE,
1431 FL("received Auth frame3 from peer with status code %d "
1432 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1433 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001434
1435 return;
1436 }
1437
1438 /**
1439 * Check if received challenge text is same as one sent in
1440 * Authentication frame3
1441 */
1442
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301443 if (vos_mem_compare(pRxAuthFrameBody->challengeText,
1444 pAuthNode->challengeText,
1445 SIR_MAC_AUTH_CHALLENGE_LENGTH))
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 {
1447 /// Challenge match. STA is autheticated !
1448
1449 /// Delete Authentication response timer if running
1450 limDeactivateAndChangePerStaIdTimer(pMac,
1451 eLIM_AUTH_RSP_TIMER,
1452 pAuthNode->authNodeIdx);
1453
1454 pAuthNode->fTimerStarted = 0;
1455 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1456
1457 /**
1458 * Send Authentication Frame4 with 'success' Status Code.
1459 */
1460 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1461 authFrame.authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001462 SIR_MAC_AUTH_FRAME_4;
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 authFrame.authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1464
1465 limSendAuthMgmtFrame(pMac, &authFrame,
1466 pHdr->sa,
1467 LIM_NO_WEP_IN_FC,psessionEntry);
1468
1469 /// Send Auth indication to SME
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301470 vos_mem_copy((tANI_U8 *) mlmAuthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 (tANI_U8 *) pHdr->sa,
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301472 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 mlmAuthInd.authType = (tAniAuthType)
1474 pRxAuthFrameBody->authAlgoNumber;
1475 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
1476
1477 limPostSmeMessage(pMac,
1478 LIM_MLM_AUTH_IND,
1479 (tANI_U32 *) &mlmAuthInd);
1480
1481 break;
1482 }
1483 else
1484 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301485 // Log error
1486 PELOGE( limLog(pMac, LOGW,
1487 FL("Challenge failure for peer "
1488 MAC_ADDRESS_STR),
1489 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 /**
1491 * Challenge Failure.
1492 * Send Authentication frame4 with 'challenge failure'
1493 * status code and wait until Auth response timeout to
1494 * delete STA context.
1495 */
1496
1497 authFrame.authAlgoNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001498 pRxAuthFrameBody->authAlgoNumber;
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 authFrame.authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001500 SIR_MAC_AUTH_FRAME_4;
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 authFrame.authStatusCode =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001502 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001503
1504 limSendAuthMgmtFrame(pMac, &authFrame,
1505 pHdr->sa,
1506 LIM_NO_WEP_IN_FC,psessionEntry);
1507
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 return;
1509 }
1510 } // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE || ...
1511
1512 break;
1513
1514 case SIR_MAC_AUTH_FRAME_4:
1515 // AuthFrame 4
1516 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE)
1517 {
1518 /**
1519 * Received Authentication frame4 in an unexpected state.
1520 * Log error and ignore the frame.
1521 */
1522
1523 // Log error
1524 PELOG1(limLog(pMac, LOG1,
Abhishek Singh208848c2013-12-18 19:02:52 +05301525 FL("received unexpected Auth frame4 from peer in state "
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301526 "%d, addr "MAC_ADDRESS_STR), psessionEntry->limMlmState,
1527 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001528
1529 return;
1530 }
1531
1532 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1533 {
1534 /**
1535 * Received Authentication frame4 with algorithm other than
1536 * Shared Key authentication type.
1537 * Wait until Auth failure timeout to report authentication
1538 * failure to SME.
1539 */
1540
1541 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001542 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301543 FL("received Auth frame4 from peer with invalid auth "
1544 "algo %d "MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001545 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001546
1547 return;
1548 }
1549
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301550 if ( !vos_mem_compare((tANI_U8 *) pHdr->sa,
1551 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1552 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 {
1554 /**
1555 * Received Authentication frame from an entity
1556 * other than one to which request was initiated.
1557 * Wait until Authentication Failure Timeout.
1558 */
1559
1560 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001561 PELOGE(limLog(pMac, LOGW,
1562 FL("received Auth frame4 from unexpected peer "
1563 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001564
1565 break;
1566 }
1567
1568 if (pRxAuthFrameBody->authAlgoNumber !=
1569 pMac->lim.gpLimMlmAuthReq->authType)
1570 {
1571 /**
1572 * Received Authentication frame with an auth algorithm
1573 * other than one requested.
1574 * Wait until Authentication Failure Timeout.
1575 */
1576
Mohit Khanna23863762012-09-11 17:40:09 -07001577 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301578 FL("received Authentication frame from peer with "
1579 "invalid auth seq number %d "
1580 MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001581 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001582
1583 break;
1584 }
1585
1586 if (pRxAuthFrameBody->authStatusCode ==
1587 eSIR_MAC_SUCCESS_STATUS)
1588 {
1589 /**
1590 * Authentication Success !
1591 * Inform SME of same.
1592 */
1593 psessionEntry->limCurrentAuthType = eSIR_SHARED_KEY;
1594
1595 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1596 if (pAuthNode == NULL)
1597 {
1598 // Log error
1599 limLog(pMac, LOGW,
1600 FL("Max pre-auth nodes reached "));
1601 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1602
1603 return;
1604 }
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001605 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer "), pAuthNode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 limPrintMacAddr(pMac, pHdr->sa, LOG1);)
1607
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301608 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1610 sizeof(tSirMacAddr));
1611 pAuthNode->fTimerStarted = 0;
1612 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
1613 limAddPreAuthNode(pMac, pAuthNode);
1614
1615 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1616 pRxAuthFrameBody->authStatusCode,psessionEntry);
1617
1618 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1619 else
1620 {
1621 /**
1622 * Authentication failure.
1623 * Return Auth confirm with received failure code to SME
1624 */
1625
1626 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001627 PELOGE(limLog(pMac, LOGE, FL("Authentication failure from peer "
1628 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001629
1630 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1631 pRxAuthFrameBody->authStatusCode,psessionEntry);
1632 } // end if (pRxAuthFrameBody->Status == 0)
1633
1634 break;
1635
1636 default:
1637 /// Invalid Authentication Frame received. Ignore it.
1638
1639 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001640 PELOGE(limLog(pMac, LOGE,
Abhishek Singh208848c2013-12-18 19:02:52 +05301641 FL("received Auth frame from peer with invalid auth seq "
1642 "number %d " MAC_ADDRESS_STR),
1643 pRxAuthFrameBody->authTransactionSeqNumber,
Mohit Khanna23863762012-09-11 17:40:09 -07001644 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001645
1646 break;
1647 } // end switch (pRxAuthFrameBody->authTransactionSeqNumber)
1648} /*** end limProcessAuthFrame() ***/
1649
1650
1651
1652
1653
1654#ifdef WLAN_FEATURE_VOWIFI_11R
1655
1656/*----------------------------------------------------------------------
1657 *
1658 * Pass the received Auth frame. This is possibly the pre-auth from the
1659 * neighbor AP, in the same mobility domain.
1660 * This will be used in case of 11r FT.
1661 *
1662 * !!!! This is going to be renoved for the next checkin. We will be creating
1663 * the session before sending out the Auth. Thus when auth response
1664 * is received we will have a session in progress. !!!!!
1665 *----------------------------------------------------------------------
1666 */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001667tSirRetStatus limProcessAuthFrameNoSession(tpAniSirGlobal pMac, tANI_U8 *pBd, void *body)
Jeff Johnson295189b2012-06-20 16:38:30 -07001668{
1669 tpSirMacMgmtHdr pHdr;
1670 tpPESession psessionEntry = NULL;
1671 tANI_U8 *pBody;
1672 tANI_U16 frameLen;
1673 tSirMacAuthFrameBody rxAuthFrame;
1674 tSirMacAuthFrameBody *pRxAuthFrameBody = NULL;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001675 tSirRetStatus ret_status = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001676
1677 pHdr = WDA_GET_RX_MAC_HEADER(pBd);
1678 pBody = WDA_GET_RX_MPDU_DATA(pBd);
1679 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd);
1680
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301681 limLog(pMac, LOG1, FL("Auth Frame Received: BSSID " MAC_ADDRESS_STR
1682 " (RSSI %d)"),MAC_ADDR_ARRAY(pHdr->bssId),
1683 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 // Check for the operating channel and see what needs to be done next.
1685 psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
1686 if (psessionEntry == NULL)
1687 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301688 limLog(pMac, LOGE, FL("Error: Unable to find session id while in "
1689 "pre-auth phase for FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001690 return eSIR_FAILURE;
1691 }
1692
1693 if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL)
1694 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301695 limLog(pMac, LOGE, FL("Error: No FT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 // No FT in progress.
1697 return eSIR_FAILURE;
1698 }
1699
1700 if (frameLen == 0)
1701 {
Abhishek Singh208848c2013-12-18 19:02:52 +05301702 limLog(pMac, LOGE, FL("Error: Frame len = 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 return eSIR_FAILURE;
1704 }
1705#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001706 limPrintMacAddr(pMac, pHdr->bssId, LOG2);
1707 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOG2);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001708 limLog(pMac,LOG2,FL("seqControl 0x%X"),
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001709 ((pHdr->seqControl.seqNumHi << 8) |
1710 (pHdr->seqControl.seqNumLo << 4) |
1711 (pHdr->seqControl.fragNum)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001712#endif
1713
1714 // Check that its the same bssId we have for preAuth
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +05301715 if (!vos_mem_compare(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1716 pHdr->bssId, sizeof( tSirMacAddr )))
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301718 limLog(pMac, LOGE, FL("Error: NOT same bssid as preauth BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 // In this case SME if indeed has triggered a
1720 // pre auth it will time out.
1721 return eSIR_FAILURE;
1722 }
1723
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001724 if (eANI_BOOLEAN_TRUE ==
1725 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed)
1726 {
1727 /*
1728 * This is likely a duplicate for the same pre-auth request.
1729 * PE/LIM already posted a response to SME. Hence, drop it.
1730 * TBD:
1731 * 1) How did we even receive multiple auth responses?
1732 * 2) Do we need to delete pre-auth session? Suppose we
1733 * previously received an auth resp with failure which
1734 * would not have created the session and forwarded to SME.
1735 * And, we subsequently received an auth resp with success
1736 * which would have created the session. This will now be
1737 * dropped without being forwarded to SME! However, it is
1738 * very unlikely to receive auth responses from the same
1739 * AP with different reason codes.
1740 * NOTE: return eSIR_SUCCESS so that the packet is dropped
1741 * as this was indeed a response from the BSSID we tried to
1742 * pre-auth.
1743 */
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001744 PELOGE(limLog(pMac,LOG1,"Auth rsp already posted to SME"
1745 " (session %p, FT session %p)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001746 pMac->ft.ftPEContext.pftSessionEntry););
1747 return eSIR_SUCCESS;
1748 }
1749 else
1750 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001751 PELOGE(limLog(pMac,LOGW,"Auth rsp not yet posted to SME"
1752 " (session %p, FT session %p)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001753 pMac->ft.ftPEContext.pftSessionEntry););
1754 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
1755 eANI_BOOLEAN_TRUE;
1756 }
1757
Jeff Johnson295189b2012-06-20 16:38:30 -07001758#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001759 limLog(pMac, LOG1, FL("Pre-Auth response received from neighbor"));
1760 limLog(pMac, LOG1, FL("Pre-Auth done state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001761#endif
1762 // Stopping timer now, that we have our unicast from the AP
1763 // of our choice.
1764 limDeactivateAndChangeTimer(pMac, eLIM_FT_PREAUTH_RSP_TIMER);
1765
1766
1767 // Save off the auth resp.
1768 if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame) != eSIR_SUCCESS))
1769 {
Abhishek Singhdb6e96e2013-12-30 14:16:10 +05301770 limLog(pMac, LOGE, FL("failed to convert Auth frame to struct"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001771 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
1772 return eSIR_FAILURE;
1773 }
1774 pRxAuthFrameBody = &rxAuthFrame;
1775
1776#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001777 PELOGE(limLog(pMac, LOG1,
1778 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
1780 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
1781 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
1782#endif
1783
1784 switch (pRxAuthFrameBody->authTransactionSeqNumber)
1785 {
1786 case SIR_MAC_AUTH_FRAME_2:
1787 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1788 {
1789#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001790 PELOGE(limLog( pMac, LOGE, "Auth status code received is %d",
1791 (tANI_U32) pRxAuthFrameBody->authStatusCode););
Jeff Johnson295189b2012-06-20 16:38:30 -07001792#endif
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001793 if (eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS == pRxAuthFrameBody->authStatusCode)
1794 ret_status = eSIR_LIM_MAX_STA_REACHED_ERROR;
Jeff Johnson295189b2012-06-20 16:38:30 -07001795 }
1796 else
1797 {
1798 ret_status = eSIR_SUCCESS;
1799 }
1800 break;
1801
1802 default:
1803#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001804 PELOGE(limLog( pMac, LOGE, "Seq. no incorrect expected 2 received %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber);)
1806#endif
1807 break;
1808 }
1809
1810 // Send the Auth response to SME
1811 limHandleFTPreAuthRsp(pMac, ret_status, pBody, frameLen, psessionEntry);
1812
1813 return ret_status;
1814}
1815
1816#endif /* WLAN_FEATURE_VOWIFI_11R */
1817