blob: f665e31f15bb318b71faa8b22ad96f801a9578bd [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -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.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/*
43 *
44 * Airgo Networks, Inc proprietary. All rights reserved.
45 * This file limProcessAuthFrame.cc contains the code
46 * for processing received Authentication Frame.
47 * Author: Chandra Modumudi
48 * Date: 03/11/02
49 * History:-
50 * Date Modified by Modification Information
51 * --------------------------------------------------------------------
52 * 05/12/2010 js To support Shared key authentication at AP side
53 *
54 */
55
56#include "wniApi.h"
57#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
58#include "halDataStruct.h"
59#endif
60#if (WNI_POLARIS_FW_PRODUCT == AP)
61#include "wniCfgAp.h"
62#else
63#include "wniCfgSta.h"
64#endif
65#include "aniGlobal.h"
66#include "cfgApi.h"
67
68#include "utilsApi.h"
69#include "limUtils.h"
70#include "limAssocUtils.h"
71#include "limSecurityUtils.h"
72#include "limSerDesUtils.h"
73#ifdef WLAN_FEATURE_VOWIFI_11R
74#include "limFT.h"
75#endif
76#include "vos_utils.h"
77
78
79/**
80 * isAuthValid
81 *
82 *FUNCTION:
83 * This function is called by limProcessAuthFrame() upon Authentication
84 * frame reception.
85 *
86 *LOGIC:
87 * This function is used to test validity of auth frame:
88 * - AUTH1 and AUTH3 must be received in AP mode
89 * - AUTH2 and AUTH4 must be received in STA mode
90 * - AUTH3 and AUTH4 must have challenge text IE, that is,'type' field has been set to
91 * SIR_MAC_CHALLENGE_TEXT_EID by parser
92 * -
93 *
94 *ASSUMPTIONS:
95 *
96 *NOTE:
97 *
98 * @param *auth - Pointer to extracted auth frame body
99 *
100 * @return 0 or 1 (Valid)
101 */
102
103
104static inline unsigned int isAuthValid(tpAniSirGlobal pMac, tpSirMacAuthFrameBody auth,tpPESession sessionEntry) {
105 unsigned int valid;
106 valid=1;
107
108 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_1)||
109 (auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)) &&
110 ((sessionEntry->limSystemRole == eLIM_STA_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)))
111 valid=0;
112
113 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_2)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&&
114 ((sessionEntry->limSystemRole == eLIM_AP_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)))
115 valid=0;
116
117 if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&&
118 (auth->type!=SIR_MAC_CHALLENGE_TEXT_EID)&&(auth->authAlgoNumber != eSIR_SHARED_KEY))
119 valid=0;
120
121 return valid;
122}
123
124
125/**
126 * limProcessAuthFrame
127 *
128 *FUNCTION:
129 * This function is called by limProcessMessageQueue() upon Authentication
130 * frame reception.
131 *
132 *LOGIC:
133 * This function processes received Authentication frame and responds
134 * with either next Authentication frame in sequence to peer MAC entity
135 * or LIM_MLM_AUTH_IND on AP or LIM_MLM_AUTH_CNF on STA.
136 *
137 *ASSUMPTIONS:
138 *
139 *NOTE:
140 * 1. Authentication failures are reported to SME with same status code
141 * received from the peer MAC entity.
142 * 2. Authentication frame2/4 received with alogirthm number other than
143 * one requested in frame1/3 are logged with an error and auth confirm
144 * will be sent to SME only after auth failure timeout.
145 * 3. Inconsistency in the spec:
146 * On receiving Auth frame2, specs says that if WEP key mapping key
147 * or default key is NULL, Auth frame3 with a status code 15 (challenge
148 * failure to be returned to peer entity. However, section 7.2.3.10,
149 * table 14 says that status code field is 'reserved' for frame3 !
150 * In the current implementation, Auth frame3 is returned with status
151 * code 15 overriding section 7.2.3.10.
152 * 4. If number pre-authentications reach configrable max limit,
153 * Authentication frame with 'unspecified failure' status code is
154 * returned to requesting entity.
155 *
156 * @param pMac - Pointer to Global MAC structure
157 * @param *pRxPacketInfo - A pointer to Rx packet info structure
158 * @return None
159 */
160
161void
162limProcessAuthFrame(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tpPESession psessionEntry)
163{
164 tANI_U8 *pBody, keyId, cfgPrivacyOptImp,
165 defaultKey[SIR_MAC_KEY_LENGTH],
166 encrAuthFrame[LIM_ENCR_AUTH_BODY_LEN],
167 plainBody[256];
168 tANI_U16 frameLen;
169 //tANI_U32 authRspTimeout, maxNumPreAuth, val;
170 tANI_U32 maxNumPreAuth, val;
171 tSirMacAuthFrameBody *pRxAuthFrameBody, rxAuthFrame, authFrame;
172 tpSirMacMgmtHdr pHdr;
173 tCfgWepKeyEntry *pKeyMapEntry = NULL;
174 struct tLimPreAuthNode *pAuthNode;
175 tLimMlmAuthInd mlmAuthInd;
176 tANI_U8 decryptResult;
177 tANI_U8 *pChallenge;
178 tANI_U32 key_length=8;
179 tANI_U8 challengeTextArray[SIR_MAC_AUTH_CHALLENGE_LENGTH];
180#ifdef WLAN_SOFTAP_FEATURE
181 tpDphHashNode pStaDs = NULL;
182 tANI_U16 assocId = 0;
183#endif
184 /* Added For BT -AMP support */
185 // Get pointer to Authentication frame header and body
186
187
188 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
189 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
190
191
192 if (!frameLen)
193 {
194 // Log error
195 limLog(pMac, LOGE,
196 FL("received Authentication frame with no body from "));
197 limPrintMacAddr(pMac, pHdr->sa, LOGE);
198
199 return;
200 }
201
202 if (limIsGroupAddr(pHdr->sa))
203 {
204 // Received Auth frame from a BC/MC address
205 // Log error and ignore it
206 PELOG1(limLog(pMac, LOG1,
207 FL("received Auth frame from a BC/MC address - "));)
208 PELOG1( limPrintMacAddr(pMac, pHdr->sa, LOG1);)
209
210 return;
211 }
212
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800213 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
214 FL("Auth Frame Received: BSSID %02x:%02x:%02x:%02x:%02x:%02x (Rssi %d)"),
215 pHdr->bssId[0], pHdr->bssId[1], pHdr->bssId[2],
216 pHdr->bssId[3], pHdr->bssId[4], pHdr->bssId[5],
217 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo)));
218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
220
Jeff Johnsone7245742012-09-05 17:12:55 -0700221 //PELOG3(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG3, (tANI_U8*)pBd, ((tpHalBufDesc) pBd)->mpduDataOffset + frameLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700222
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -0800223#ifdef WLAN_FEATURE_P2P
224 //Restore default failure timeout
225 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona && psessionEntry->defaultAuthFailureTimeout)
226 {
227 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,
228 psessionEntry->defaultAuthFailureTimeout, NULL, eANI_BOOLEAN_FALSE);
229 }
230#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700231
232 /// Determine if WEP bit is set in the FC or received MAC header
233 if (pHdr->fc.wep)
234 {
235 /**
236 * WEP bit is set in FC of MAC header.
237 */
238
239#ifdef WLAN_SOFTAP_FEATURE
240 // If TKIP counter measures enabled issue Deauth frame to station
241 if ((psessionEntry->bTkipCntrMeasActive) && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
242 {
243 PELOGE( limLog(pMac, LOGE,
244 FL("Tkip counter measures Enabled, sending Deauth frame to")); )
245 limPrintMacAddr(pMac, pHdr->sa, LOGE);
246
247 limSendDeauthMgmtFrame( pMac, eSIR_MAC_MIC_FAILURE_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800248 pHdr->sa, psessionEntry, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700249 return;
250 }
251#endif
252
253 // Extract key ID from IV (most 2 bits of 4th byte of IV)
254
255 keyId = (*(pBody + 3)) >> 6;
256
257 /**
258 * On STA in infrastructure BSS, Authentication frames received
259 * with WEP bit set in the FC must be rejected with challenge
260 * failure status code (wierd thing in the spec - this should have
261 * been rejected with unspecified failure or unexpected assertion
262 * of wep bit (this status code does not exist though) or
263 * Out-of-sequence-Authentication-Frame status code.
264 */
265
266 if (psessionEntry->limSystemRole == eLIM_STA_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)
267 {
268 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
269 authFrame.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4;
270 authFrame.authStatusCode = eSIR_MAC_CHALLENGE_FAILURE_STATUS;
271
272 limSendAuthMgmtFrame(pMac, &authFrame,
273 pHdr->sa,
274 LIM_NO_WEP_IN_FC,psessionEntry);
275 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -0700276 PELOGE(limLog(pMac, LOGE,
277 FL("received Authentication frame with wep bit set on role=%d "MAC_ADDRESS_STR),
278 psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pHdr->sa) );)
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280 return;
281 }
282
283 if (frameLen < LIM_ENCR_AUTH_BODY_LEN)
284 {
285 // Log error
286 limLog(pMac, LOGE,
287 FL("Not enough size [%d] to decrypt received Auth frame"),
288 frameLen);
289 limPrintMacAddr(pMac, pHdr->sa, LOGE);
290
291 return;
292 }
293#ifdef WLAN_SOFTAP_FEATURE
294 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
295 {
296 val = psessionEntry->privacy;
297 }
298 else
299#endif
300 // Accept Authentication frame only if Privacy is implemented
301 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
302 &val) != eSIR_SUCCESS)
303 {
304 /**
305 * Could not get Privacy option
306 * from CFG. Log error.
307 */
308 limLog(pMac, LOGP, FL("could not retrieve Privacy option\n"));
309 }
310
311 cfgPrivacyOptImp = (tANI_U8)val;
312 if (cfgPrivacyOptImp)
313 {
314 /**
315 * Privacy option is implemented.
316 * Check if the received frame is Authentication
317 * frame3 and there is a context for requesting STA.
318 * If not, reject with unspecified failure status code
319 */
320 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
321
322 if (pAuthNode == NULL)
323 {
324 /**
325 * No 'pre-auth' context exists for this STA that sent
326 * an Authentication frame with FC bit set.
327 * Send Auth frame4 with 'out of sequence' status code.
328 */
329 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
330 authFrame.authTransactionSeqNumber =
331 SIR_MAC_AUTH_FRAME_4;
332 authFrame.authStatusCode =
333 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
334
335 limSendAuthMgmtFrame(pMac, &authFrame,
336 pHdr->sa,
337 LIM_NO_WEP_IN_FC,psessionEntry);
338
339 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -0700340 PELOGE(limLog(pMac, LOGE,
341 FL("received Authentication frame from peer that has "
342 "no preauth context with WEP bit set "MAC_ADDRESS_STR),
343 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700344
345 return;
346 }
347 else
348 {
349 /// Change the auth-response timeout
350 limDeactivateAndChangePerStaIdTimer(pMac,
351 eLIM_AUTH_RSP_TIMER,
352 pAuthNode->authNodeIdx);
353
354 /// 'Pre-auth' status exists for STA
355 if ((pAuthNode->mlmState !=
356 eLIM_MLM_WT_AUTH_FRAME3_STATE) &&
357 (pAuthNode->mlmState !=
358 eLIM_MLM_AUTH_RSP_TIMEOUT_STATE))
359 {
360 /**
361 * Should not have received Authentication frame
362 * with WEP bit set in FC in other states.
363 * Reject by sending Authenticaton frame with
364 * out of sequence Auth frame status code.
365 */
366
367 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
368 authFrame.authTransactionSeqNumber =
369 SIR_MAC_AUTH_FRAME_4;
370 authFrame.authStatusCode =
371 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
372
373 limSendAuthMgmtFrame(pMac, &authFrame,
374 pHdr->sa,
375 LIM_NO_WEP_IN_FC,psessionEntry);
376
377 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -0700378 PELOGE(limLog(pMac, LOGE,
379 FL("received Authentication frame from peer that is in state %d "
380 MAC_ADDRESS_STR), pAuthNode->mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
382 return;
383 }
384 }
385
386 /**
387 * Check if there exists a key mappping key
388 * for the STA that sent Authentication frame
389 */
390 pKeyMapEntry = limLookUpKeyMappings(pHdr->sa);
391
392 if (pKeyMapEntry)
393 {
394 if (!pKeyMapEntry->wepOn)
395 {
396 /**
397 * Key Mapping entry has null key.
398 * Send Authentication frame
399 * with challenge failure status code
400 */
401 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
402 authFrame.authTransactionSeqNumber =
403 SIR_MAC_AUTH_FRAME_4;
404 authFrame.authStatusCode =
405 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
406
407 limSendAuthMgmtFrame(pMac, &authFrame,
408 pHdr->sa,
409 LIM_NO_WEP_IN_FC,psessionEntry);
410
411 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -0700412 PELOGE(limLog(pMac, LOGE,
413 FL("received Auth frame3 from peer that has NULL key map entry "
414 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700415
416 return;
417 } // if (!pKeyMapEntry->wepOn)
418 else
419 {
420 decryptResult = limDecryptAuthFrame(pMac, pKeyMapEntry->key,
421 pBody,
422 plainBody,
423 key_length,
424 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
425 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
426 {
427 /// ICV failure
Mohit Khanna23863762012-09-11 17:40:09 -0700428 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == LIM_DECRYPT_ICV_FAIL ..."));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700429 limDeletePreAuthNode(pMac,
430 pHdr->sa);
431 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
432 authFrame.authTransactionSeqNumber =
433 SIR_MAC_AUTH_FRAME_4;
434 authFrame.authStatusCode =
435 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
436
437 limSendAuthMgmtFrame(
438 pMac, &authFrame,
439 pHdr->sa,
440 LIM_NO_WEP_IN_FC,psessionEntry);
441
442 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -0700443 PELOGE(limLog(pMac, LOGE,
444 FL("received Authentication frame from peer that failed decryption, Addr "
445 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700446
447 return;
448 }
449
450 if ((sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8, &rxAuthFrame)!=eSIR_SUCCESS)||(!isAuthValid(pMac, &rxAuthFrame,psessionEntry)))
451 return;
452
453
454 } // end if (pKeyMapEntry->key == NULL)
455 } // if keyMappings has entry
456 else
457 {
458
459 val = SIR_MAC_KEY_LENGTH;
460
461#ifdef WLAN_SOFTAP_FEATURE
462 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
463 {
464 tpSirKeys pKey;
465 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
466 palCopyMemory( pMac->hHdd, defaultKey, pKey->key, pKey->keyLength);
467 val = pKey->keyLength;
468 }
469 else
470#endif
471 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
472 defaultKey, &val) != eSIR_SUCCESS)
473 {
474 /// Could not get Default key from CFG.
475 //Log error.
476 limLog(pMac, LOGP,
477 FL("could not retrieve Default key\n"));
478
479 /**
480 * Send Authentication frame
481 * with challenge failure status code
482 */
483
484 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
485 authFrame.authTransactionSeqNumber =
486 SIR_MAC_AUTH_FRAME_4;
487 authFrame.authStatusCode =
488 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
489
490 limSendAuthMgmtFrame(pMac, &authFrame,
491 pHdr->sa,
492 LIM_NO_WEP_IN_FC,psessionEntry);
493
494 return;
495 }
496
497 key_length=val;
498
499 decryptResult = limDecryptAuthFrame(pMac, defaultKey,
500 pBody,
501 plainBody,
502 key_length,
503 (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH));
504 if (decryptResult == LIM_DECRYPT_ICV_FAIL)
505 {
506 PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == LIM_DECRYPT_ICV_FAIL ...\n"));)
507 /// ICV failure
508 limDeletePreAuthNode(pMac,
509 pHdr->sa);
510 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
511 authFrame.authTransactionSeqNumber =
512 SIR_MAC_AUTH_FRAME_4;
513 authFrame.authStatusCode =
514 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
515
516 limSendAuthMgmtFrame(
517 pMac, &authFrame,
518 pHdr->sa,
519 LIM_NO_WEP_IN_FC,psessionEntry);
520
521 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -0700522 PELOGE(limLog(pMac, LOGE,
523 FL("received Authentication frame from peer that failed decryption: "
524 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700525
526 return;
527 }
528 if ((sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8, &rxAuthFrame)!=eSIR_SUCCESS)||(!isAuthValid(pMac, &rxAuthFrame,psessionEntry)))
529 return;
530
531 } // End of check for Key Mapping/Default key presence
532 }
533 else
534 {
535 /**
536 * Privacy option is not implemented.
537 * So reject Authentication frame received with
538 * WEP bit set by sending Authentication frame
539 * with 'challenge failure' status code. This is
540 * another strange thing in the spec. Status code
541 * should have been 'unsupported algorithm' status code.
542 */
543
544 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
545 authFrame.authTransactionSeqNumber =
546 SIR_MAC_AUTH_FRAME_4;
547 authFrame.authStatusCode =
548 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
549
550 limSendAuthMgmtFrame(pMac, &authFrame,
551 pHdr->sa,
552 LIM_NO_WEP_IN_FC,psessionEntry);
553
554 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -0700555 PELOGE(limLog(pMac, LOGE,
556 FL("received Authentication frame3 from peer that while privacy option is turned OFF "
557 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700558
559 return;
560 } // else if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
561 } // if (fc.wep)
562 else
563 {
564
565
566 if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame)!=eSIR_SUCCESS)||(!isAuthValid(pMac, &rxAuthFrame,psessionEntry)))
567 return;
568 }
569
570
571 pRxAuthFrameBody = &rxAuthFrame;
572
Mohit Khanna23863762012-09-11 17:40:09 -0700573 PELOGW(limLog(pMac, LOGW,
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)\n"),
575 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
576 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
577 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
578
579 switch (pRxAuthFrameBody->authTransactionSeqNumber)
580 {
581 case SIR_MAC_AUTH_FRAME_1:
582 // AuthFrame 1
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -0800583
584 pStaDs = dphLookupHashEntry(pMac, pHdr->sa,
585 &assocId, &psessionEntry->dph.dphHashTable);
586 if (pStaDs)
587 {
588 tLimMlmDisassocReq *pMlmDisassocReq = NULL;
589 tLimMlmDeauthReq *pMlmDeauthReq = NULL;
590 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
591 if (pMlmDisassocReq &&
592 (palEqualMemory( pMac->hHdd,(tANI_U8 *) pHdr->sa,
593 (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
594 sizeof(tSirMacAddr))))
595 {
596 PELOGE(limLog(pMac, LOGP, FL("\nTODO:Ack for disassoc frame is pending"
597 "Issue delsta for %02x:%02x:%02x:%02x:%02x:%02x"),
598 pMlmDisassocReq->peerMacAddr[0],
599 pMlmDisassocReq->peerMacAddr[1],
600 pMlmDisassocReq->peerMacAddr[2],
601 pMlmDisassocReq->peerMacAddr[3],
602 pMlmDisassocReq->peerMacAddr[4],
603 pMlmDisassocReq->peerMacAddr[5]);)
604 }
605 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
606 if (pMlmDeauthReq &&
607 (palEqualMemory( pMac->hHdd,(tANI_U8 *) pHdr->sa,
608 (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
609 sizeof(tSirMacAddr))))
610 {
611 PELOGE(limLog(pMac, LOGP, FL("\nTODO:Ack for disassoc frame is pending"
612 "Issue delsta for %02x:%02x:%02x:%02x:%02x:%02x"),
613 pMlmDeauthReq->peerMacAddr[0],
614 pMlmDeauthReq->peerMacAddr[1],
615 pMlmDeauthReq->peerMacAddr[2],
616 pMlmDeauthReq->peerMacAddr[3],
617 pMlmDeauthReq->peerMacAddr[4],
618 pMlmDeauthReq->peerMacAddr[5]
619 );)
620 }
621 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700622
623 /// Check if there exists pre-auth context for this STA
624 pAuthNode = limSearchPreAuthList(pMac, pHdr->sa);
625 if (pAuthNode)
626 {
627 /// Pre-auth context exists for the STA
628 if (pHdr->fc.retry == 0)
629 {
630 /**
631 * STA is initiating brand-new Authentication
632 * sequence after local Auth Response timeout.
633 * Or STA retrying to transmit First Auth frame due to packet drop OTA
634 * Delete Pre-auth node and fall through.
635 */
636 if(pAuthNode->fTimerStarted)
637 {
638 limDeactivateAndChangePerStaIdTimer(pMac,
639 eLIM_AUTH_RSP_TIMER,
640 pAuthNode->authNodeIdx);
641 }
642 PELOGE(limLog(pMac, LOGE, FL("STA is initiating brand-new Authentication ...\n"));)
643 limDeletePreAuthNode(pMac,
644 pHdr->sa);
645#ifdef WLAN_SOFTAP_FEATURE
646 /**
647 * SAP Mode:Disassociate the station and
648 * delete its entry if we have its entry
649 * already and received "auth" from the
650 * same station.
651 */
652
653 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
654 {
655 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
656
657 if (NULL == pStaDs)
658 continue;
659
660 if (pStaDs->valid)
661 {
662 if (palEqualMemory( pMac->hHdd,(tANI_U8 *) &pStaDs->staAddr,
663 (tANI_U8 *) &(pHdr->sa), (tANI_U8) (sizeof(tSirMacAddr))) )
664 break;
665 }
666 }
667
668 if (NULL != pStaDs)
669 {
670 PELOGE(limLog(pMac, LOGE, FL("lim Delete Station Context (staId: %d, assocId: %d) \n"),pStaDs->staIndex, assocId);)
671 limSendDeauthMgmtFrame(pMac,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -0800672 eSIR_MAC_UNSPEC_FAILURE_REASON, (tANI_U8 *) pAuthNode->peerMacAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
674 return;
675 }
676#endif
677 }
678 else
679 {
680 /*
681 * This can happen when first authentication frame is received
682 * but ACK lost at STA side, in this case 2nd auth frame is already
683 * in transmission queue
684 * */
685 PELOGE(limLog(pMac, LOGE, FL("STA is initiating Authentication after ACK lost...\n"));)
686 return;
687 }
688 }
689 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
690 (tANI_U32 *) &maxNumPreAuth) != eSIR_SUCCESS)
691 {
692 /**
693 * Could not get MaxNumPreAuth
694 * from CFG. Log error.
695 */
696 limLog(pMac, LOGP,
697 FL("could not retrieve MaxNumPreAuth\n"));
698 }
699#ifdef ANI_AP_SDK_OPT
700 if(maxNumPreAuth > SIR_SDK_OPT_MAX_NUM_PRE_AUTH)
701 maxNumPreAuth = SIR_SDK_OPT_MAX_NUM_PRE_AUTH;
702#endif // ANI_AP_SDK_OPT
703 if (pMac->lim.gLimNumPreAuthContexts == maxNumPreAuth)
704 {
705 /**
706 * Maximum number of pre-auth contexts
707 * reached. Send Authentication frame
708 * with unspecified failure
709 */
710 authFrame.authAlgoNumber =
711 pRxAuthFrameBody->authAlgoNumber;
712 authFrame.authTransactionSeqNumber =
713 pRxAuthFrameBody->authTransactionSeqNumber + 1;
714 authFrame.authStatusCode =
715 eSIR_MAC_UNSPEC_FAILURE_STATUS;
716
717 limSendAuthMgmtFrame(pMac, &authFrame,
718 pHdr->sa,
719 LIM_NO_WEP_IN_FC,psessionEntry);
720
721 return;
722 }
723 /// No Pre-auth context exists for the STA.
724#ifdef WLAN_SOFTAP_FEATURE
725 if (limIsAuthAlgoSupported(
726 pMac,
727 (tAniAuthType)
728 pRxAuthFrameBody->authAlgoNumber, psessionEntry))
729#else
730 if (limIsAuthAlgoSupported(
731 pMac,
732 (tAniAuthType)
733 pRxAuthFrameBody->authAlgoNumber))
734
735#endif
736 {
737 switch (pRxAuthFrameBody->authAlgoNumber)
738 {
739 case eSIR_OPEN_SYSTEM:
Mohit Khanna23863762012-09-11 17:40:09 -0700740 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_OPEN_SYSTEM ...\n"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 /// Create entry for this STA in pre-auth list
742 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
743 if (pAuthNode == NULL)
744 {
745 // Log error
746 limLog(pMac, LOGW,
747 FL("Max pre-auth nodes reached "));
748 limPrintMacAddr(pMac, pHdr->sa, LOGW);
749
750 return;
751 }
752
753 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer \n"), pAuthNode);
754 limPrintMacAddr(pMac, pHdr->sa, LOG1);)
755
756 palCopyMemory( pMac->hHdd,
757 (tANI_U8 *) pAuthNode->peerMacAddr,
758 pHdr->sa,
759 sizeof(tSirMacAddr));
760
761 pAuthNode->mlmState =
762 eLIM_MLM_AUTHENTICATED_STATE;
763 pAuthNode->authType = (tAniAuthType)
764 pRxAuthFrameBody->authAlgoNumber;
765 pAuthNode->fSeen = 0;
766 pAuthNode->fTimerStarted = 0;
767 limAddPreAuthNode(pMac, pAuthNode);
768
769 /**
770 * Send Authenticaton frame with Success
771 * status code.
772 */
773
774 authFrame.authAlgoNumber =
775 pRxAuthFrameBody->authAlgoNumber;
776 authFrame.authTransactionSeqNumber =
777 pRxAuthFrameBody->authTransactionSeqNumber + 1;
778 authFrame.authStatusCode = eSIR_MAC_SUCCESS_STATUS;
779 limSendAuthMgmtFrame(
780 pMac, &authFrame,
781 pHdr->sa,
782 LIM_NO_WEP_IN_FC,psessionEntry);
783
784 /// Send Auth indication to SME
785
786 palCopyMemory( pMac->hHdd,
787 (tANI_U8 *) mlmAuthInd.peerMacAddr,
788 (tANI_U8 *) pHdr->sa,
789 sizeof(tSirMacAddr));
790 mlmAuthInd.authType = (tAniAuthType)
791 pRxAuthFrameBody->authAlgoNumber;
792 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
793
794 limPostSmeMessage(pMac,
795 LIM_MLM_AUTH_IND,
796 (tANI_U32 *) &mlmAuthInd);
797 break;
798
799 case eSIR_SHARED_KEY:
Mohit Khanna23863762012-09-11 17:40:09 -0700800 PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_SHARED_KEY ...\n"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700801#ifdef WLAN_SOFTAP_FEATURE
802 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
803 {
804 val = psessionEntry->privacy;
805 }
806 else
807#endif
808 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
809 &val) != eSIR_SUCCESS)
810 {
811 /**
812 * Could not get Privacy option
813 * from CFG. Log error.
814 */
815 limLog(pMac, LOGP,
816 FL("could not retrieve Privacy option\n"));
817 }
818 cfgPrivacyOptImp = (tANI_U8)val;
819 if (!cfgPrivacyOptImp)
820 {
821 /**
822 * Authenticator does not have WEP
823 * implemented.
824 * Reject by sending Authentication frame
825 * with Auth algorithm not supported status
826 * code.
827 */
828
829 authFrame.authAlgoNumber =
830 pRxAuthFrameBody->authAlgoNumber;
831 authFrame.authTransactionSeqNumber =
832 pRxAuthFrameBody->authTransactionSeqNumber + 1;
833 authFrame.authStatusCode =
834 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
835
836 limSendAuthMgmtFrame(
837 pMac, &authFrame,
838 pHdr->sa,
839 LIM_NO_WEP_IN_FC,psessionEntry);
840
841 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -0700842 PELOGE(limLog(pMac, LOGE,
843 FL("received Auth frame for unsupported auth algorithm %d "
844 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
845 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700846
847 return;
848 }
849 else
850 {
851 // Create entry for this STA
852 //in pre-auth list
853 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
854 if (pAuthNode == NULL)
855 {
856 // Log error
857 limLog(pMac, LOGW,
858 FL("Max pre-auth nodes reached "));
859 limPrintMacAddr(pMac, pHdr->sa, LOGW);
860
861 return;
862 }
863
864 palCopyMemory( pMac->hHdd,
865 (tANI_U8 *) pAuthNode->peerMacAddr,
866 pHdr->sa,
867 sizeof(tSirMacAddr));
868
869 pAuthNode->mlmState =
870 eLIM_MLM_WT_AUTH_FRAME3_STATE;
871 pAuthNode->authType =
872 (tAniAuthType)
873 pRxAuthFrameBody->authAlgoNumber;
874 pAuthNode->fSeen = 0;
875 pAuthNode->fTimerStarted = 0;
876 limAddPreAuthNode(pMac, pAuthNode);
877
878 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x id %d peer \n"),
879 pAuthNode, pAuthNode->authNodeIdx);)
880 PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);)
881
882 /// Create and activate Auth Response timer
883 if (tx_timer_change_context(&pAuthNode->timer, pAuthNode->authNodeIdx) != TX_SUCCESS)
884 {
885 /// Could not start Auth response timer.
886 // Log error
887 limLog(pMac, LOGP,
888 FL("Unable to chg context auth response timer for peer "));
889 limPrintMacAddr(pMac, pHdr->sa, LOGP);
890
891 /**
892 * Send Authenticaton frame with
893 * unspecified failure status code.
894 */
895
896 authFrame.authAlgoNumber =
897 pRxAuthFrameBody->authAlgoNumber;
898 authFrame.authTransactionSeqNumber =
899 pRxAuthFrameBody->authTransactionSeqNumber + 1;
900 authFrame.authStatusCode =
901 eSIR_MAC_UNSPEC_FAILURE_STATUS;
902
903 limSendAuthMgmtFrame(pMac, &authFrame,
904 pHdr->sa,
905 LIM_NO_WEP_IN_FC,psessionEntry);
906
907 limDeletePreAuthNode(pMac, pHdr->sa);
908 return;
909 }
910
911 limActivateAuthRspTimer(pMac, pAuthNode);
912
913 pAuthNode->fTimerStarted = 1;
914
915 // get random bytes and use as
916 // challenge text
917 // TODO
918 //if( !VOS_IS_STATUS_SUCCESS( vos_rand_get_bytes( 0, (tANI_U8 *)challengeTextArray, SIR_MAC_AUTH_CHALLENGE_LENGTH ) ) )
919 {
920 limLog(pMac, LOGE,FL("Challenge text preparation failed in limProcessAuthFrame"));
921 }
922
923 pChallenge = pAuthNode->challengeText;
924
925 palCopyMemory( pMac->hHdd,
926 pChallenge,
927 (tANI_U8 *) challengeTextArray,
928 sizeof(challengeTextArray));
929
930 /**
931 * Sending Authenticaton frame with challenge.
932 */
933
934 authFrame.authAlgoNumber =
935 pRxAuthFrameBody->authAlgoNumber;
936 authFrame.authTransactionSeqNumber =
937 pRxAuthFrameBody->authTransactionSeqNumber + 1;
938 authFrame.authStatusCode =
939 eSIR_MAC_SUCCESS_STATUS;
940 authFrame.type = SIR_MAC_CHALLENGE_TEXT_EID;
941 authFrame.length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
942 palCopyMemory( pMac->hHdd,
943 authFrame.challengeText,
944 pAuthNode->challengeText,
945 SIR_MAC_AUTH_CHALLENGE_LENGTH);
946
947 limSendAuthMgmtFrame(
948 pMac, &authFrame,
949 pHdr->sa,
950 LIM_NO_WEP_IN_FC,psessionEntry);
951 } // if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
952
953 break;
954
955 default:
956 /**
957 * Responding party does not support the
958 * authentication algorithm requested by
959 * sending party.
960 * Reject by sending Authentication frame
961 * with auth algorithm not supported status code
962 */
963
964 authFrame.authAlgoNumber =
965 pRxAuthFrameBody->authAlgoNumber;
966 authFrame.authTransactionSeqNumber =
967 pRxAuthFrameBody->authTransactionSeqNumber + 1;
968 authFrame.authStatusCode =
969 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
970
971 limSendAuthMgmtFrame(
972 pMac, &authFrame,
973 pHdr->sa,
974 LIM_NO_WEP_IN_FC,psessionEntry);
975
976 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -0700977 PELOGE( limLog(pMac, LOGE,
978 FL("received Auth frame for unsupported auth algorithm %d "
979 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
980 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700981
982 return;
983 } // end switch(pRxAuthFrameBody->authAlgoNumber)
984 } // if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
985 else
986 {
987 /**
988 * Responding party does not support the
989 * authentication algorithm requested by sending party.
990 * Reject Authentication with StatusCode=13.
991 */
992 authFrame.authAlgoNumber =
993 pRxAuthFrameBody->authAlgoNumber;
994 authFrame.authTransactionSeqNumber =
995 pRxAuthFrameBody->authTransactionSeqNumber + 1;
996 authFrame.authStatusCode =
997 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
998
999 limSendAuthMgmtFrame(pMac, &authFrame,
1000 pHdr->sa,
1001 LIM_NO_WEP_IN_FC,psessionEntry);
1002
1003 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001004 PELOGE(limLog(pMac, LOGE,
1005 FL("received Authentication frame for unsupported auth algorithm %d "
1006 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
1007 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 return;
1009 } //end if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber))
1010 break;
1011
1012 case SIR_MAC_AUTH_FRAME_2:
1013 // AuthFrame 2
1014
1015 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME2_STATE)
1016 {
1017 /**
1018 * Received Authentication frame2 in an unexpected state.
1019 * Log error and ignore the frame.
1020 */
1021
1022 // Log error
1023 PELOG1(limLog(pMac, LOG1,
1024 FL("received Auth frame2 from peer in state %d, addr "),
1025 psessionEntry->limMlmState);)
1026 PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);)
1027
1028 return;
1029 }
1030
1031 if ( !palEqualMemory( pMac->hHdd,(tANI_U8 *) pHdr->sa,
1032 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1033 sizeof(tSirMacAddr)) )
1034 {
1035 /**
1036 * Received Authentication frame from an entity
1037 * other than one request was initiated.
1038 * Wait until Authentication Failure Timeout.
1039 */
1040
1041 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001042 PELOGW(limLog(pMac, LOGW,
1043 FL("received Auth frame2 from unexpected peer "MAC_ADDRESS_STR),
1044 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001045
1046 break;
1047 }
1048
1049 if (pRxAuthFrameBody->authStatusCode ==
1050 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS)
1051 {
1052 /**
1053 * Interoperability workaround: Linksys WAP4400N is returning
1054 * wrong authType in OpenAuth response in case of
1055 * SharedKey AP configuration. Pretend we don't see that,
1056 * so upper layer can fallback to SharedKey authType,
1057 * and successfully connect to the AP.
1058 */
1059 if (pRxAuthFrameBody->authAlgoNumber !=
1060 pMac->lim.gpLimMlmAuthReq->authType)
1061 {
1062 pRxAuthFrameBody->authAlgoNumber =
1063 pMac->lim.gpLimMlmAuthReq->authType;
1064 }
1065 }
1066
1067 if (pRxAuthFrameBody->authAlgoNumber !=
1068 pMac->lim.gpLimMlmAuthReq->authType)
1069 {
1070 /**
1071 * Received Authentication frame with an auth
1072 * algorithm other than one requested.
1073 * Wait until Authentication Failure Timeout.
1074 */
1075
1076 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001077 PELOGW(limLog(pMac, LOGW,
1078 FL("received Auth frame2 for unexpected auth algo number %d "
1079 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
1080 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001081
1082 break;
1083 }
1084
1085 if (pRxAuthFrameBody->authStatusCode ==
1086 eSIR_MAC_SUCCESS_STATUS)
1087 {
1088 if (pRxAuthFrameBody->authAlgoNumber ==
1089 eSIR_OPEN_SYSTEM)
1090 {
1091 psessionEntry->limCurrentAuthType = eSIR_OPEN_SYSTEM;
1092
1093 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1094
1095 if (pAuthNode == NULL)
1096 {
1097 // Log error
1098 limLog(pMac, LOGW,
1099 FL("Max pre-auth nodes reached "));
1100 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1101
1102 return;
1103 }
1104
1105 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer \n"), pAuthNode);)
1106 PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);)
1107
1108 palCopyMemory( pMac->hHdd,
1109 (tANI_U8 *) pAuthNode->peerMacAddr,
1110 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1111 sizeof(tSirMacAddr));
1112 pAuthNode->fTimerStarted = 0;
1113 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
1114 limAddPreAuthNode(pMac, pAuthNode);
1115
1116 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1117 pRxAuthFrameBody->authStatusCode,psessionEntry);
1118 } // if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1119 else
1120 {
1121 // Shared key authentication
1122
1123#ifdef WLAN_SOFTAP_FEATURE
1124 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1125 {
1126 val = psessionEntry->privacy;
1127 }
1128 else
1129#endif
1130 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1131 &val) != eSIR_SUCCESS)
1132 {
1133 /**
1134 * Could not get Privacy option
1135 * from CFG. Log error.
1136 */
1137 limLog(pMac, LOGP,
1138 FL("could not retrieve Privacy option\n"));
1139 }
1140 cfgPrivacyOptImp = (tANI_U8)val;
1141 if (!cfgPrivacyOptImp)
1142 {
1143 /**
1144 * Requesting STA does not have WEP implemented.
1145 * Reject with unsupported authentication algorithm
1146 * Status code and wait until auth failure timeout
1147 */
1148
1149 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001150 PELOGE( limLog(pMac, LOGE,
1151 FL("received Auth frame from peer for unsupported auth algo %d "
1152 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
1153 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001154
1155 authFrame.authAlgoNumber =
1156 pRxAuthFrameBody->authAlgoNumber;
1157 authFrame.authTransactionSeqNumber =
1158 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1159 authFrame.authStatusCode =
1160 eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS;
1161
1162 limSendAuthMgmtFrame(pMac, &authFrame,
1163 pHdr->sa,
1164 LIM_NO_WEP_IN_FC,psessionEntry);
1165 return;
1166 }
1167 else
1168 {
1169
1170 if (pRxAuthFrameBody->type !=
1171 SIR_MAC_CHALLENGE_TEXT_EID)
1172 {
1173 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001174 PELOGE(limLog(pMac, LOGE,
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 FL("received Auth frame with invalid challenge text IE\n"));)
1176
1177 return;
1178 }
1179
1180 /**
1181 * Check if there exists a key mappping key
1182 * for the STA that sent Authentication frame
1183 */
1184 pKeyMapEntry = limLookUpKeyMappings(
1185 pHdr->sa);
1186
1187 if (pKeyMapEntry)
1188 {
1189 if (pKeyMapEntry->key == NULL)
1190 {
1191 /**
1192 * Key Mapping entry has null key.
1193 * Send Auth frame with
1194 * challenge failure status code
1195 */
1196 authFrame.authAlgoNumber =
1197 pRxAuthFrameBody->authAlgoNumber;
1198 authFrame.authTransactionSeqNumber =
1199 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1200 authFrame.authStatusCode =
1201 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1202
1203 limSendAuthMgmtFrame(pMac, &authFrame,
1204 pHdr->sa,
1205 LIM_NO_WEP_IN_FC,psessionEntry);
1206
1207 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001208 PELOGE(limLog(pMac, LOGE,
1209 FL("received Auth frame from peer when key mapping key is NULL"
1210 MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001211
1212 limRestoreFromAuthState(pMac, eSIR_SME_NO_KEY_MAPPING_KEY_FOR_PEER,
1213 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1214
1215 return;
1216 } // if (pKeyMapEntry->key == NULL)
1217 else
1218 {
1219 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1220 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1221 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1222 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1223 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1224 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
1225 ((tpSirMacAuthFrameBody) plainBody)->length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
1226 palCopyMemory( pMac->hHdd, (tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
1227 pRxAuthFrameBody->challengeText,
1228 SIR_MAC_AUTH_CHALLENGE_LENGTH);
1229
1230 limEncryptAuthFrame(pMac, 0,
1231 pKeyMapEntry->key,
1232 plainBody,
1233 encrAuthFrame,key_length);
1234
1235 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001236 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001237
1238 limSendAuthMgmtFrame(pMac,
1239 (tpSirMacAuthFrameBody) encrAuthFrame,
1240 pHdr->sa,
1241 LIM_WEP_IN_FC,psessionEntry);
1242
1243 break;
1244 } // end if (pKeyMapEntry->key == NULL)
1245 } // if (pKeyMapEntry)
1246 else
1247 {
1248 if (wlan_cfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID,
1249 &val) != eSIR_SUCCESS)
1250 {
1251 /**
1252 * Could not get Default keyId
1253 * from CFG. Log error.
1254 */
1255 limLog(pMac, LOGP,
1256 FL("could not retrieve Default keyId\n"));
1257 }
1258 keyId = (tANI_U8)val;
1259
1260 val = SIR_MAC_KEY_LENGTH;
1261
1262#ifdef WLAN_SOFTAP_FEATURE
1263 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1264 {
1265 tpSirKeys pKey;
1266 pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0];
1267 palCopyMemory( pMac->hHdd, defaultKey, pKey->key, pKey->keyLength);
1268 }
1269 else
1270#endif
1271 if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId),
1272 defaultKey,
1273 &val)
1274 != eSIR_SUCCESS)
1275 {
1276 /// Could not get Default key from CFG.
1277 //Log error.
1278 limLog(pMac, LOGP,
1279 FL("could not retrieve Default key\n"));
1280
1281 authFrame.authAlgoNumber =
1282 pRxAuthFrameBody->authAlgoNumber;
1283 authFrame.authTransactionSeqNumber =
1284 pRxAuthFrameBody->authTransactionSeqNumber + 1;
1285 authFrame.authStatusCode =
1286 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1287
1288 limSendAuthMgmtFrame(
1289 pMac, &authFrame,
1290 pHdr->sa,
1291 LIM_NO_WEP_IN_FC,psessionEntry);
1292
1293 limRestoreFromAuthState(pMac, eSIR_SME_INVALID_WEP_DEFAULT_KEY,
1294 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
1295
1296 break;
1297 }
1298 key_length=val;
1299 ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber =
1300 sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber);
1301 ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber =
1302 sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1));
1303 ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1304 ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID;
1305 ((tpSirMacAuthFrameBody) plainBody)->length = SIR_MAC_AUTH_CHALLENGE_LENGTH;
1306 palCopyMemory( pMac->hHdd, (tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText,
1307 pRxAuthFrameBody->challengeText,
1308 SIR_MAC_AUTH_CHALLENGE_LENGTH);
1309
1310 limEncryptAuthFrame(pMac, keyId,
1311 defaultKey,
1312 plainBody,
1313 encrAuthFrame,key_length);
1314
1315 psessionEntry->limMlmState =
1316 eLIM_MLM_WT_AUTH_FRAME4_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001317 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001318
1319 limSendAuthMgmtFrame(pMac,
1320 (tpSirMacAuthFrameBody) encrAuthFrame,
1321 pHdr->sa,
1322 LIM_WEP_IN_FC,psessionEntry);
1323
1324 break;
1325 } // end if (pKeyMapEntry)
1326 } // end if (!wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED))
1327 } // end if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM)
1328 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1329 else
1330 {
1331 /**
1332 * Authentication failure.
1333 * Return Auth confirm with received failure code to SME
1334 */
1335
1336 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001337 PELOGE(limLog(pMac, LOGE,
1338 FL("received Auth frame from peer with failure code %d "
1339 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1340 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001341
1342 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1343 pRxAuthFrameBody->authStatusCode,psessionEntry);
1344 } // end if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1345
1346 break;
1347
1348 case SIR_MAC_AUTH_FRAME_3:
1349 // AuthFrame 3
1350
1351 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1352 {
1353 /**
1354 * Received Authentication frame3 with algorithm other than
1355 * Shared Key authentication type. Reject with Auth frame4
1356 * with 'out of sequence' status code.
1357 */
1358 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1359 authFrame.authTransactionSeqNumber =
1360 SIR_MAC_AUTH_FRAME_4;
1361 authFrame.authStatusCode =
1362 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1363
1364 limSendAuthMgmtFrame(pMac, &authFrame,
1365 pHdr->sa,
1366 LIM_NO_WEP_IN_FC,psessionEntry);
1367
1368 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001369 PELOGE(limLog(pMac, LOGE,
1370 FL("received Auth frame3 from peer with auth algo number %d "
1371 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
1372 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001373
1374 return;
1375 }
1376
1377 if (psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE ||
1378 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
1379 {
1380 /**
1381 * Check if wep bit was set in FC. If not set,
1382 * reject with Authentication frame4 with
1383 * 'challenge failure' status code.
1384 */
1385 if (!pHdr->fc.wep)
1386 {
1387 /// WEP bit is not set in FC of Auth Frame3
1388 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1389 authFrame.authTransactionSeqNumber =
1390 SIR_MAC_AUTH_FRAME_4;
1391 authFrame.authStatusCode =
1392 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
1393
1394 limSendAuthMgmtFrame(pMac, &authFrame,
1395 pHdr->sa,
1396 LIM_NO_WEP_IN_FC,psessionEntry);
1397
1398 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001399 PELOGE(limLog(pMac, LOGE,
1400 FL("received Auth frame3 from peer with no WEP bit set "MAC_ADDRESS_STR),
1401 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001402
1403 return;
1404 }
1405
1406 pAuthNode = limSearchPreAuthList(pMac,
1407 pHdr->sa);
1408 if (pAuthNode == NULL)
1409 {
1410 /**
1411 * No 'pre-auth' context exists for
1412 * this STA that sent an Authentication
1413 * frame3.
1414 * Send Auth frame4 with 'out of sequence'
1415 * status code.
1416 */
1417 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1418 authFrame.authTransactionSeqNumber =
1419 SIR_MAC_AUTH_FRAME_4;
1420 authFrame.authStatusCode =
1421 eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS;
1422
1423 limSendAuthMgmtFrame(pMac, &authFrame,
1424 pHdr->sa,
1425 LIM_NO_WEP_IN_FC,psessionEntry);
1426
1427 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001428 PELOGE(limLog(pMac, LOGW,
1429 FL("received AuthFrame3 from peer that has no preauth context "
1430 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001431
1432 return;
1433 }
1434
1435 if (pAuthNode->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)
1436 {
1437 /**
1438 * Received Auth Frame3 after Auth Response timeout.
1439 * Reject by sending Auth Frame4 with
1440 * Auth respone timeout Status Code.
1441 */
1442 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1443 authFrame.authTransactionSeqNumber =
1444 SIR_MAC_AUTH_FRAME_4;
1445 authFrame.authStatusCode =
1446 eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS;
1447
1448 limSendAuthMgmtFrame(
1449 pMac, &authFrame,
1450 pHdr->sa,
1451 LIM_NO_WEP_IN_FC,psessionEntry);
1452
1453 // Log error
1454 limLog(pMac, LOGW,
1455 FL("auth response timer timedout for peer "));
1456 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1457
1458 /// Delete pre-auth context of STA
1459 limDeletePreAuthNode(pMac,
1460 pHdr->sa);
1461
1462 return;
1463 } // end switch (pAuthNode->mlmState)
1464
1465 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1466 {
1467 /**
1468 * Received Authenetication Frame 3 with status code
1469 * other than success. Wait until Auth response timeout
1470 * to delete STA context.
1471 */
1472
1473 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001474 PELOGE(limLog(pMac, LOGE,
1475 FL("received Auth frame3 from peer with status code %d "
1476 MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode,
1477 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001478
1479 return;
1480 }
1481
1482 /**
1483 * Check if received challenge text is same as one sent in
1484 * Authentication frame3
1485 */
1486
1487 if (palEqualMemory( pMac->hHdd,pRxAuthFrameBody->challengeText,
1488 pAuthNode->challengeText,
1489 SIR_MAC_AUTH_CHALLENGE_LENGTH))
1490 {
1491 /// Challenge match. STA is autheticated !
1492
1493 /// Delete Authentication response timer if running
1494 limDeactivateAndChangePerStaIdTimer(pMac,
1495 eLIM_AUTH_RSP_TIMER,
1496 pAuthNode->authNodeIdx);
1497
1498 pAuthNode->fTimerStarted = 0;
1499 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1500
1501 /**
1502 * Send Authentication Frame4 with 'success' Status Code.
1503 */
1504 authFrame.authAlgoNumber = eSIR_SHARED_KEY;
1505 authFrame.authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001506 SIR_MAC_AUTH_FRAME_4;
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 authFrame.authStatusCode = eSIR_MAC_SUCCESS_STATUS;
1508
1509 limSendAuthMgmtFrame(pMac, &authFrame,
1510 pHdr->sa,
1511 LIM_NO_WEP_IN_FC,psessionEntry);
1512
1513 /// Send Auth indication to SME
1514 palCopyMemory( pMac->hHdd,
1515 (tANI_U8 *) mlmAuthInd.peerMacAddr,
1516 (tANI_U8 *) pHdr->sa,
1517 sizeof(tSirMacAddr));
1518 mlmAuthInd.authType = (tAniAuthType)
1519 pRxAuthFrameBody->authAlgoNumber;
1520 mlmAuthInd.sessionId = psessionEntry->smeSessionId;
1521
1522 limPostSmeMessage(pMac,
1523 LIM_MLM_AUTH_IND,
1524 (tANI_U32 *) &mlmAuthInd);
1525
1526 break;
1527 }
1528 else
1529 {
1530 /**
1531 * Challenge Failure.
1532 * Send Authentication frame4 with 'challenge failure'
1533 * status code and wait until Auth response timeout to
1534 * delete STA context.
1535 */
1536
1537 authFrame.authAlgoNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001538 pRxAuthFrameBody->authAlgoNumber;
Jeff Johnson295189b2012-06-20 16:38:30 -07001539 authFrame.authTransactionSeqNumber =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001540 SIR_MAC_AUTH_FRAME_4;
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 authFrame.authStatusCode =
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001542 eSIR_MAC_CHALLENGE_FAILURE_STATUS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001543
1544 limSendAuthMgmtFrame(pMac, &authFrame,
1545 pHdr->sa,
1546 LIM_NO_WEP_IN_FC,psessionEntry);
1547
1548 // Log error
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001549 PELOGE( limLog(pMac, LOGW,
1550 FL("Challenge failure for peer "MAC_ADDRESS_STR),
1551 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 return;
1553 }
1554 } // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE || ...
1555
1556 break;
1557
1558 case SIR_MAC_AUTH_FRAME_4:
1559 // AuthFrame 4
1560 if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE)
1561 {
1562 /**
1563 * Received Authentication frame4 in an unexpected state.
1564 * Log error and ignore the frame.
1565 */
1566
1567 // Log error
1568 PELOG1(limLog(pMac, LOG1,
1569 FL("received unexpected Auth frame4 from peer in state %d, addr "),
1570 psessionEntry->limMlmState);)
1571 PELOG1( limPrintMacAddr(pMac, pHdr->sa, LOG1);)
1572
1573 return;
1574 }
1575
1576 if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY)
1577 {
1578 /**
1579 * Received Authentication frame4 with algorithm other than
1580 * Shared Key authentication type.
1581 * Wait until Auth failure timeout to report authentication
1582 * failure to SME.
1583 */
1584
1585 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001586 PELOGE(limLog(pMac, LOGE,
1587 FL("received Auth frame4 from peer with invalid auth algo %d "
1588 MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
1589 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001590
1591 return;
1592 }
1593
1594 if ( !palEqualMemory( pMac->hHdd,(tANI_U8 *) pHdr->sa,
1595 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1596 sizeof(tSirMacAddr)) )
1597 {
1598 /**
1599 * Received Authentication frame from an entity
1600 * other than one to which request was initiated.
1601 * Wait until Authentication Failure Timeout.
1602 */
1603
1604 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001605 PELOGE(limLog(pMac, LOGW,
1606 FL("received Auth frame4 from unexpected peer "
1607 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001608
1609 break;
1610 }
1611
1612 if (pRxAuthFrameBody->authAlgoNumber !=
1613 pMac->lim.gpLimMlmAuthReq->authType)
1614 {
1615 /**
1616 * Received Authentication frame with an auth algorithm
1617 * other than one requested.
1618 * Wait until Authentication Failure Timeout.
1619 */
1620
Mohit Khanna23863762012-09-11 17:40:09 -07001621 PELOGE(limLog(pMac, LOGE,
1622 FL("received Authentication frame from peer with invalid auth seq number %d "
1623 MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber,
1624 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001625
1626 break;
1627 }
1628
1629 if (pRxAuthFrameBody->authStatusCode ==
1630 eSIR_MAC_SUCCESS_STATUS)
1631 {
1632 /**
1633 * Authentication Success !
1634 * Inform SME of same.
1635 */
1636 psessionEntry->limCurrentAuthType = eSIR_SHARED_KEY;
1637
1638 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1639 if (pAuthNode == NULL)
1640 {
1641 // Log error
1642 limLog(pMac, LOGW,
1643 FL("Max pre-auth nodes reached "));
1644 limPrintMacAddr(pMac, pHdr->sa, LOGW);
1645
1646 return;
1647 }
1648 PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer \n"), pAuthNode);
1649 limPrintMacAddr(pMac, pHdr->sa, LOG1);)
1650
1651 palCopyMemory( pMac->hHdd,
1652 (tANI_U8 *) pAuthNode->peerMacAddr,
1653 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
1654 sizeof(tSirMacAddr));
1655 pAuthNode->fTimerStarted = 0;
1656 pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType;
1657 limAddPreAuthNode(pMac, pAuthNode);
1658
1659 limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS,
1660 pRxAuthFrameBody->authStatusCode,psessionEntry);
1661
1662 } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS)
1663 else
1664 {
1665 /**
1666 * Authentication failure.
1667 * Return Auth confirm with received failure code to SME
1668 */
1669
1670 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001671 PELOGE(limLog(pMac, LOGE, FL("Authentication failure from peer "
1672 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001673
1674 limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED,
1675 pRxAuthFrameBody->authStatusCode,psessionEntry);
1676 } // end if (pRxAuthFrameBody->Status == 0)
1677
1678 break;
1679
1680 default:
1681 /// Invalid Authentication Frame received. Ignore it.
1682
1683 // Log error
Mohit Khanna23863762012-09-11 17:40:09 -07001684 PELOGE(limLog(pMac, LOGE,
1685 FL("received Auth frame from peer with invalid auth seq number %d "
1686 MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber,
1687 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001688
1689 break;
1690 } // end switch (pRxAuthFrameBody->authTransactionSeqNumber)
1691} /*** end limProcessAuthFrame() ***/
1692
1693
1694
1695
1696
1697#ifdef WLAN_FEATURE_VOWIFI_11R
1698
1699/*----------------------------------------------------------------------
1700 *
1701 * Pass the received Auth frame. This is possibly the pre-auth from the
1702 * neighbor AP, in the same mobility domain.
1703 * This will be used in case of 11r FT.
1704 *
1705 * !!!! This is going to be renoved for the next checkin. We will be creating
1706 * the session before sending out the Auth. Thus when auth response
1707 * is received we will have a session in progress. !!!!!
1708 *----------------------------------------------------------------------
1709 */
1710int limProcessAuthFrameNoSession(tpAniSirGlobal pMac, tANI_U8 *pBd, void *body)
1711{
1712 tpSirMacMgmtHdr pHdr;
1713 tpPESession psessionEntry = NULL;
1714 tANI_U8 *pBody;
1715 tANI_U16 frameLen;
1716 tSirMacAuthFrameBody rxAuthFrame;
1717 tSirMacAuthFrameBody *pRxAuthFrameBody = NULL;
1718 int ret_status = eSIR_FAILURE;
1719
1720 pHdr = WDA_GET_RX_MAC_HEADER(pBd);
1721 pBody = WDA_GET_RX_MPDU_DATA(pBd);
1722 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd);
1723
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001724 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
1725 FL("Auth Frame Received: BSSID %02x:%02x:%02x:%02x:%02x:%02x (Rssi %d)"),
1726 pHdr->bssId[0], pHdr->bssId[1], pHdr->bssId[2],
1727 pHdr->bssId[3], pHdr->bssId[4], pHdr->bssId[5],
1728 (uint)abs((tANI_S8)WDA_GET_RX_RSSI_DB(pBd)));
1729
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 // Check for the operating channel and see what needs to be done next.
1731 psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
1732 if (psessionEntry == NULL)
1733 {
1734 limLog(pMac, LOGW, FL("Error: Unable to find session id while in pre-auth phase for FT"));
1735 return eSIR_FAILURE;
1736 }
1737
1738 if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL)
1739 {
1740 // No FT in progress.
1741 return eSIR_FAILURE;
1742 }
1743
1744 if (frameLen == 0)
1745 {
1746 return eSIR_FAILURE;
1747 }
1748#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001749 limPrintMacAddr(pMac, pHdr->bssId, LOG2);
1750 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOG2);
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001751 limLog(pMac,LOG2,FL("seqControl 0x%X\n"),
1752 ((pHdr->seqControl.seqNumHi << 8) |
1753 (pHdr->seqControl.seqNumLo << 4) |
1754 (pHdr->seqControl.fragNum)));
Jeff Johnson295189b2012-06-20 16:38:30 -07001755#endif
1756
1757 // Check that its the same bssId we have for preAuth
1758 if (!palEqualMemory( pMac->hHdd, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1759 pHdr->bssId, sizeof( tSirMacAddr )))
1760 {
1761 // In this case SME if indeed has triggered a
1762 // pre auth it will time out.
1763 return eSIR_FAILURE;
1764 }
1765
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001766 if (eANI_BOOLEAN_TRUE ==
1767 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed)
1768 {
1769 /*
1770 * This is likely a duplicate for the same pre-auth request.
1771 * PE/LIM already posted a response to SME. Hence, drop it.
1772 * TBD:
1773 * 1) How did we even receive multiple auth responses?
1774 * 2) Do we need to delete pre-auth session? Suppose we
1775 * previously received an auth resp with failure which
1776 * would not have created the session and forwarded to SME.
1777 * And, we subsequently received an auth resp with success
1778 * which would have created the session. This will now be
1779 * dropped without being forwarded to SME! However, it is
1780 * very unlikely to receive auth responses from the same
1781 * AP with different reason codes.
1782 * NOTE: return eSIR_SUCCESS so that the packet is dropped
1783 * as this was indeed a response from the BSSID we tried to
1784 * pre-auth.
1785 */
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001786 PELOGE(limLog(pMac,LOG1,"Auth rsp already posted to SME"
1787 " (session %p, FT session %p)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001788 pMac->ft.ftPEContext.pftSessionEntry););
1789 return eSIR_SUCCESS;
1790 }
1791 else
1792 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001793 PELOGE(limLog(pMac,LOGW,"Auth rsp not yet posted to SME"
1794 " (session %p, FT session %p)", psessionEntry,
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07001795 pMac->ft.ftPEContext.pftSessionEntry););
1796 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
1797 eANI_BOOLEAN_TRUE;
1798 }
1799
Jeff Johnson295189b2012-06-20 16:38:30 -07001800#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001801 limLog(pMac, LOG1, FL("Pre-Auth response received from neighbor"));
1802 limLog(pMac, LOG1, FL("Pre-Auth done state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001803#endif
1804 // Stopping timer now, that we have our unicast from the AP
1805 // of our choice.
1806 limDeactivateAndChangeTimer(pMac, eLIM_FT_PREAUTH_RSP_TIMER);
1807
1808
1809 // Save off the auth resp.
1810 if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame) != eSIR_SUCCESS))
1811 {
1812 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
1813 return eSIR_FAILURE;
1814 }
1815 pRxAuthFrameBody = &rxAuthFrame;
1816
1817#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001818 PELOGE(limLog(pMac, LOG1,
1819 FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 (tANI_U32) pRxAuthFrameBody->authAlgoNumber,
1821 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber,
1822 (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);)
1823#endif
1824
1825 switch (pRxAuthFrameBody->authTransactionSeqNumber)
1826 {
1827 case SIR_MAC_AUTH_FRAME_2:
1828 if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)
1829 {
1830#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
1831 PELOGE(limLog( pMac, LOGE, "Auth status code received is %d\n",
1832 (tANI_U32) pRxAuthFrameBody->authStatusCode);)
1833#endif
1834 }
1835 else
1836 {
1837 ret_status = eSIR_SUCCESS;
1838 }
1839 break;
1840
1841 default:
1842#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
1843 PELOGE(limLog( pMac, LOGE, "Seq. no incorrect expected 2 received %d\n",
1844 (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber);)
1845#endif
1846 break;
1847 }
1848
1849 // Send the Auth response to SME
1850 limHandleFTPreAuthRsp(pMac, ret_status, pBody, frameLen, psessionEntry);
1851
1852 return ret_status;
1853}
1854
1855#endif /* WLAN_FEATURE_VOWIFI_11R */
1856