blob: d7385ede92eca397b97b85765319f8eec5b002d4 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
2 * Copyright (c) 2012, Code Aurora Forum. 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
22/*
23 * Airgo Networks, Inc proprietary. All rights reserved.
24 * This file limUtils.cc contains the utility functions
25 * LIM uses.
26 * Author: Chandra Modumudi
27 * Date: 02/13/02
28 * History:-
29 * Date Modified by Modification Information
30 * --------------------------------------------------------------------
31 */
32
33#include "aniGlobal.h"
34#include "wniApi.h"
35
36#include "sirCommon.h"
37#if (WNI_POLARIS_FW_PRODUCT == AP)
38#include "wniCfgAp.h"
39#else
40#include "wniCfgSta.h"
41#endif
42#include "cfgApi.h"
43
44#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
45#include "halDataStruct.h"
46#include "halCommonApi.h"
47#endif
48
49#include "utilsApi.h"
50#include "limUtils.h"
51#include "limSecurityUtils.h"
52#include "limSession.h"
53
54
55#define LIM_SEED_LENGTH 16
56
57/**
58 * limIsAuthAlgoSupported()
59 *
60 *FUNCTION:
61 * This function is called in various places within LIM code
62 * to determine whether passed authentication algorithm is enabled
63 * or not
64 *
65 *LOGIC:
66 *
67 *ASSUMPTIONS:
68 * NA
69 *
70 *NOTE:
71 * NA
72 *
73 * @param authType Indicates MAC based authentication type
74 * (eSIR_OPEN_SYSTEM or eSIR_SHARED_KEY)
75 * If Shared Key authentication to be used,
76 * 'Privacy Option Implemented' flag is also
77 * checked.
78 *
79 * @return true if passed authType is enabled else false
80 */
81#ifdef WLAN_SOFTAP_FEATURE
82tANI_U8
83limIsAuthAlgoSupported(tpAniSirGlobal pMac, tAniAuthType authType, tpPESession psessionEntry)
84#else
85tANI_U8
86limIsAuthAlgoSupported(tpAniSirGlobal pMac, tAniAuthType authType)
87#endif
88{
89 tANI_U32 algoEnable, privacyOptImp;
90
91 if (authType == eSIR_OPEN_SYSTEM)
92 {
93
94#ifdef WLAN_SOFTAP_FEATURE
95 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
96 {
97 if((psessionEntry->authType == eSIR_OPEN_SYSTEM) || (psessionEntry->authType == eSIR_AUTO_SWITCH))
98 return true;
99 else
100 return false;
101 }
102#endif
103
104 if (wlan_cfgGetInt(pMac, WNI_CFG_OPEN_SYSTEM_AUTH_ENABLE,
105 &algoEnable) != eSIR_SUCCESS)
106 {
107 /**
108 * Could not get AuthAlgo1 Enable value
109 * from CFG. Log error.
110 */
111 limLog(pMac, LOGE,
112 FL("could not retrieve AuthAlgo1 Enable value\n"));
113
114 return false;
115 }
116 else
117 return ( (algoEnable > 0 ? true : false) );
118 }
119 else
120 {
121
122#ifdef WLAN_SOFTAP_FEATURE
123 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
124 {
125 if((psessionEntry->authType == eSIR_SHARED_KEY) || (psessionEntry->authType == eSIR_AUTO_SWITCH))
126 algoEnable = true;
127 else
128 algoEnable = false;
129
130 }
131 else
132#endif
133
134 if (wlan_cfgGetInt(pMac, WNI_CFG_SHARED_KEY_AUTH_ENABLE,
135 &algoEnable) != eSIR_SUCCESS)
136 {
137 /**
138 * Could not get AuthAlgo2 Enable value
139 * from CFG. Log error.
140 */
141 limLog(pMac, LOGE,
142 FL("could not retrieve AuthAlgo2 Enable value\n"));
143
144 return false;
145 }
146
147#ifdef WLAN_SOFTAP_FEATURE
148 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
149 {
150 privacyOptImp = psessionEntry->privacy;
151 }
152 else
153#endif
154
155 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
156 &privacyOptImp) != eSIR_SUCCESS)
157 {
158 /**
159 * Could not get PrivacyOptionImplemented value
160 * from CFG. Log error.
161 */
162 limLog(pMac, LOGE,
163 FL("could not retrieve PrivacyOptImplemented value\n"));
164
165 return false;
166 }
167 return (algoEnable && privacyOptImp);
168 }
169} /****** end limIsAuthAlgoSupported() ******/
170
171
172
173/**
174 * limInitPreAuthList
175 *
176 *FUNCTION:
177 * This function is called while starting a BSS at AP
178 * to initialize MAC authenticated STA list. This may also be called
179 * while joining/starting an IBSS if MAC authentication is allowed
180 * in IBSS mode.
181 *
182 *LOGIC:
183 *
184 *ASSUMPTIONS:
185 *
186 *NOTE:
187 *
188 * @param pMac - Pointer to Global MAC structure
189 * @return None
190 */
191
192void
193limInitPreAuthList(tpAniSirGlobal pMac)
194{
195 pMac->lim.pLimPreAuthList = NULL;
196
197#if (WNI_POLARIS_FW_PRODUCT == AP)
198 if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE )
199 {
200 tANI_U32 authClnupTimeout;
201 //tANI_U32 cfgValue;
202
203 if (wlan_cfgGetInt(pMac, WNI_CFG_PREAUTH_CLNUP_TIMEOUT,
204 &authClnupTimeout) != eSIR_SUCCESS)
205 {
206 /**
207 * Could not get PreAuthClnupTimeout value
208 * from CFG. Log error.
209 */
210 limLog(pMac, LOGE,
211 FL("could not retrieve PreAuthClnupTimeout value\n"));
212
213 return;
214 }
215 authClnupTimeout = SYS_MS_TO_TICKS(authClnupTimeout);
216
217 /// Create and start periodic pre-auth context cleanup timeout
218 if (tx_timer_create(&pMac->lim.limTimers.gLimPreAuthClnupTimer,
219 "preAuthCleanup",
220 limTimerHandler,
221 SIR_LIM_PREAUTH_CLNUP_TIMEOUT,
222 authClnupTimeout, authClnupTimeout,
223 TX_AUTO_ACTIVATE) != TX_SUCCESS)
224 {
225 /// Could not create PreAuthCleanup timer.
226 // Log error
227 limLog(pMac, LOGP, FL("could not create PreAuthCleanup timer\n"));
228
229 return;
230 }
231
232#if defined(ANI_OS_TYPE_RTAI_LINUX)
233 tx_timer_set_expiry_list(&pMac->lim.limTimers.gLimPreAuthClnupTimer,
234 LIM_TIMER_EXPIRY_LIST);
235#endif
236 PELOG1(limLog(pMac, LOG1,
237 FL("Created pre-auth cleanup timer\n"));)
238
239 }
240#endif
241} /*** end limInitPreAuthList() ***/
242
243
244
245/**
246 * limDeletePreAuthList
247 *
248 *FUNCTION:
249 * This function is called cleanup Pre-auth list either on
250 * AP or on STA when moving from one persona to other.
251 *
252 *LOGIC:
253 *
254 *ASSUMPTIONS:
255 *
256 *NOTE:
257 *
258 * @param pMac - Pointer to Global MAC structure
259 * @return None
260 */
261
262void
263limDeletePreAuthList(tpAniSirGlobal pMac)
264{
265 struct tLimPreAuthNode *pCurrNode, *pTempNode;
266
267 pCurrNode = pTempNode = pMac->lim.pLimPreAuthList;
268 while (pCurrNode != NULL)
269 {
270 pTempNode = pCurrNode->next;
271
272 PELOG1(limLog(pMac, LOG1, FL("=====> limDeletePreAuthList \n"));)
273 limReleasePreAuthNode(pMac, pCurrNode);
274
275 pCurrNode = pTempNode;
276 }
277 pMac->lim.pLimPreAuthList = NULL;
278} /*** end limDeletePreAuthList() ***/
279
280
281
282/**
283 * limSearchPreAuthList
284 *
285 *FUNCTION:
286 * This function is called when Authentication frame is received
287 * by AP (or at a STA in IBSS supporting MAC based authentication)
288 * to search if a STA is in the middle of MAC Authentication
289 * transaction sequence.
290 *
291 *LOGIC:
292 *
293 *ASSUMPTIONS:
294 *
295 *NOTE:
296 *
297 * @param macAddr - MAC address of the STA that sent
298 * Authentication frame.
299 *
300 * @return Pointer to pre-auth node if found, else NULL
301 */
302
303struct tLimPreAuthNode *
304limSearchPreAuthList(tpAniSirGlobal pMac, tSirMacAddr macAddr)
305{
306 struct tLimPreAuthNode *pTempNode = pMac->lim.pLimPreAuthList;
307
308 while (pTempNode != NULL)
309 {
310 if (palEqualMemory( pMac->hHdd,(tANI_U8 *) macAddr,
311 (tANI_U8 *) &pTempNode->peerMacAddr,
312 sizeof(tSirMacAddr)) )
313 break;
314
315 pTempNode = pTempNode->next;
316 }
317
318 return pTempNode;
319} /*** end limSearchPreAuthList() ***/
320
321
322
323/**
324 * limAddPreAuthNode
325 *
326 *FUNCTION:
327 * This function is called at AP while sending Authentication
328 * frame2.
329 * This may also be called on a STA in IBSS if MAC authentication is
330 * allowed in IBSS mode.
331 *
332 *LOGIC:
333 * Node is always added to the front of the list
334 *
335 *ASSUMPTIONS:
336 *
337 *NOTE:
338 *
339 * @param pMac - Pointer to Global MAC structure
340 * @param pAuthNode - Pointer to pre-auth node to be added to the list.
341 *
342 * @return None
343 */
344
345void
346limAddPreAuthNode(tpAniSirGlobal pMac, struct tLimPreAuthNode *pAuthNode)
347{
348 pMac->lim.gLimNumPreAuthContexts++;
349
350 pAuthNode->next = pMac->lim.pLimPreAuthList;
351
352 pMac->lim.pLimPreAuthList = pAuthNode;
353} /*** end limAddPreAuthNode() ***/
354
355
356/**
357 * limReleasePreAuthNode
358 *
359 *FUNCTION:
360 * This function is called to realease the accquired
361 * pre auth node from list.
362 *
363 *LOGIC:
364 *
365 *ASSUMPTIONS:
366 *
367 *NOTE:
368 *
369 * @param pMac - Pointer to Global MAC structure
370 * @param pAuthNode - Pointer to Pre Auth node to be released
371 * @return None
372 */
373
374void
375limReleasePreAuthNode(tpAniSirGlobal pMac, tpLimPreAuthNode pAuthNode)
376{
377 pAuthNode->fFree = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -0700378 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, NO_SESSION, eLIM_PRE_AUTH_CLEANUP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 tx_timer_deactivate(&pAuthNode->timer);
380 pMac->lim.gLimNumPreAuthContexts--;
381} /*** end limReleasePreAuthNode() ***/
382
383
384/**
385 * limDeletePreAuthNode
386 *
387 *FUNCTION:
388 * This function is called at AP when a pre-authenticated STA is
389 * Associated/Reassociated or when AuthFrame4 is received after
390 * Auth Response timeout.
391 * This may also be called on a STA in IBSS if MAC authentication and
392 * Association/Reassociation is allowed in IBSS mode.
393 *
394 *LOGIC:
395 *
396 *ASSUMPTIONS:
397 *
398 *NOTE:
399 *
400 * @param pMac - Pointer to Global MAC structure
401 * @param peerMacAddr - MAC address of the STA that need to be deleted
402 * from pre-auth node list.
403 *
404 * @return None
405 */
406
407void
408limDeletePreAuthNode(tpAniSirGlobal pMac, tSirMacAddr macAddr)
409{
410 struct tLimPreAuthNode *pPrevNode, *pTempNode;
411
412 pTempNode = pPrevNode = pMac->lim.pLimPreAuthList;
413
414 if (pTempNode == NULL)
415 return;
416
417 if (palEqualMemory( pMac->hHdd,(tANI_U8 *) macAddr,
418 (tANI_U8 *) &pTempNode->peerMacAddr,
419 sizeof(tSirMacAddr)) )
420 {
421 // First node to be deleted
422
423 pMac->lim.pLimPreAuthList = pTempNode->next;
424
425#if (WNI_POLARIS_FW_PRODUCT == AP)
426 // Delete the auth response timer if running
427 if (pTempNode->fTimerStarted)
428 limDeactivateAndChangePerStaIdTimer(pMac,
429 eLIM_AUTH_RSP_TIMER,
430 pTempNode->authNodeIdx);
431
432#endif
433
434 PELOG1(limLog(pMac, LOG1, FL("=====> limDeletePreAuthNode : first node to delete\n"));)
435 PELOG1(limLog(pMac, LOG1, FL("Release data entry: %x id %d peer \n"),
436 pTempNode, pTempNode->authNodeIdx);
437 limPrintMacAddr(pMac, macAddr, LOG1);)
438 limReleasePreAuthNode(pMac, pTempNode);
439
440 return;
441 }
442
443 pTempNode = pTempNode->next;
444
445 while (pTempNode != NULL)
446 {
447 if (palEqualMemory( pMac->hHdd,(tANI_U8 *) macAddr,
448 (tANI_U8 *) &pTempNode->peerMacAddr,
449 sizeof(tSirMacAddr)) )
450 {
451 // Found node to be deleted
452
453 pPrevNode->next = pTempNode->next;
454
455#if (WNI_POLARIS_FW_PRODUCT == AP)
456 // Delete the auth response timer if running
457 if (pTempNode->fTimerStarted)
458 limDeactivateAndChangePerStaIdTimer(pMac,
459 eLIM_AUTH_RSP_TIMER,
460 pTempNode->authNodeIdx);
461#endif
462 PELOG1(limLog(pMac, LOG1, FL("=====> limDeletePreAuthNode : subsequent node to delete\n"));
463 limLog(pMac, LOG1, FL("Release data entry: %x id %d peer \n"),
464 pTempNode, pTempNode->authNodeIdx);
465 limPrintMacAddr(pMac, macAddr, LOG1);)
466 limReleasePreAuthNode(pMac, pTempNode);
467
468 return;
469 }
470
471 pPrevNode = pTempNode;
472 pTempNode = pTempNode->next;
473 }
474
475 // Should not be here
476 // Log error
477 limLog(pMac, LOGP, FL("peer not found in pre-auth list, addr= "));
478 limPrintMacAddr(pMac, macAddr, LOGP);
479
480} /*** end limDeletePreAuthNode() ***/
481
482
483#if (WNI_POLARIS_FW_PRODUCT == AP)
484/**
485 * limPreAuthClnupHandler
486 *
487 *FUNCTION:
488 * This function is called on AP upon peridic Pre-authentication
489 * context cleanup.
490 *
491 *LOGIC:
492 * A Pre-auth node is marked as seen first time it comes across
493 * the list traversal. It'll be deleted if already 'seen' (during
494 * next Pre-auth cleanup).
495 *
496 *ASSUMPTIONS:
497 *
498 *NOTE:
499 *
500 * @param pMac - Pointer to Global MAC structure
501 * @return None
502 */
503
504void
505limPreAuthClnupHandler(tpAniSirGlobal pMac)
506{
507 tANI_U16 aid;
508 tANI_U8 firstNode=false;
509 tpDphHashNode pStaDs;
510 struct tLimPreAuthNode *pPrevNode, *pCurrNode;
511
512#ifdef GEN6_TODO
513 //fetch the sessionEntry based on the sessionId
514 //priority - MEDIUM
515 tpPESession sessionEntry;
516
517 if((sessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimPreAuthClnupTimer.sessionId))== NULL)
518 {
519 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
520 return;
521 }
522#endif
523
524 pCurrNode = pPrevNode = pMac->lim.pLimPreAuthList;
525
526 while (pCurrNode != NULL)
527 {
528 if (pCurrNode->fSeen)
529 {
530 // Found node to be deleted
531
532 if (pCurrNode == pMac->lim.pLimPreAuthList)
533 {
534 // First node being deleted
535 pMac->lim.pLimPreAuthList = pPrevNode = pCurrNode->next;
536 firstNode = true;
537 }
538 else
539 {
540 pPrevNode->next = pCurrNode->next;
541 }
542
543 // Delete the auth response timer if running
544 if (pCurrNode->fTimerStarted)
545 limDeactivateAndChangePerStaIdTimer(pMac,
546 eLIM_AUTH_RSP_TIMER,
547 pCurrNode->authNodeIdx);
548
549 pStaDs = dphLookupHashEntry(pMac,
550 pCurrNode->peerMacAddr,
551 &aid);
552
553 if (!pStaDs)
554 {
555 /**
556 * STA does not have associated context.
557 * Send advisory Deauthentication frame
558 * to STA being deleted
559 */
560 limSendDeauthMgmtFrame(
561 pMac,
562 eSIR_MAC_PREV_AUTH_NOT_VALID_REASON, //=2
563 pCurrNode->peerMacAddr,sessionEntry);
564 }
565
566 limLog(pMac,
567 LOG3,
568 FL("Release preAuth node during periodic cleanup\n"));
569 limReleasePreAuthNode(pMac, pCurrNode);
570
571 if (firstNode)
572 {
573 // First node was deleted
574 if (pMac->lim.pLimPreAuthList == NULL)
575 break;
576
577 pCurrNode = pMac->lim.pLimPreAuthList;
578 firstNode = false;
579 }
580 else
581 {
582 pCurrNode = pPrevNode->next;
583 }
584 }
585 else
586 {
587 // Mark this node as 'seen'. To be deleted next time.
588 pCurrNode->fSeen = 1;
589
590 pPrevNode = pCurrNode;
591 pCurrNode = pCurrNode->next;
592 }
593 }
594} /*** end limPreAuthClnupHandler() ***/
595#endif
596
597
598
599/**
600 * limRestoreFromPreAuthState
601 *
602 *FUNCTION:
603 * This function is called on STA whenever an Authentication
604 * sequence is complete and state prior to auth need to be
605 * restored.
606 *
607 *LOGIC:
608 * MLM_AUTH_CNF is prepared and sent to SME state machine.
609 * In case of restoring from pre-auth:
610 * - Channel Id is programmed at LO/RF synthesizer
611 * - BSSID is programmed at RHP
612 *
613 *ASSUMPTIONS:
614 *
615 *NOTE:
616 *
617 * @param pMac - Pointer to Global MAC structure
618 * @param resultCode - result of authentication attempt
619 * @return None
620 */
621
622void
623limRestoreFromAuthState(tpAniSirGlobal pMac, tSirResultCodes resultCode, tANI_U16 protStatusCode,tpPESession sessionEntry)
624{
625 tSirMacAddr currentBssId;
626 tLimMlmAuthCnf mlmAuthCnf;
627
628 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmAuthCnf.peerMacAddr,
629 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
630 sizeof(tSirMacAddr));
631 mlmAuthCnf.authType = pMac->lim.gpLimMlmAuthReq->authType;
632 mlmAuthCnf.resultCode = resultCode;
633 mlmAuthCnf.protStatusCode = protStatusCode;
634
635 /* Update PE session ID*/
636 mlmAuthCnf.sessionId = sessionEntry->peSessionId;
637
638 /// Free up buffer allocated
639 /// for pMac->lim.gLimMlmAuthReq
640 palFreeMemory( pMac->hHdd, pMac->lim.gpLimMlmAuthReq);
641 pMac->lim.gpLimMlmAuthReq = NULL;
642
643 sessionEntry->limMlmState = sessionEntry->limPrevMlmState;
644
Jeff Johnsone7245742012-09-05 17:12:55 -0700645 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, sessionEntry->peSessionId, sessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700646
647
648 // 'Change' timer for future activations
649 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_FAIL_TIMER);
650
651 #if 0
652 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) != eSIR_SUCCESS)
653 {
654 /// Could not get BSSID from CFG. Log error.
655 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
656 }
657 #endif //TO SUPPORT BT-AMP
658 sirCopyMacAddr(currentBssId,sessionEntry->bssId);
659
660 if (sessionEntry->limSmeState == eLIM_SME_WT_PRE_AUTH_STATE)
661 {
662 pMac->lim.gLimPreAuthChannelNumber = 0;
663 }
664
665 limPostSmeMessage(pMac,
666 LIM_MLM_AUTH_CNF,
667 (tANI_U32 *) &mlmAuthCnf);
668} /*** end limRestoreFromAuthState() ***/
669
670
671
672/**
673 * limLookUpKeyMappings()
674 *
675 *FUNCTION:
676 * This function is called in limProcessAuthFrame() function
677 * to determine if there exists a Key Mapping key for a given
678 * MAC address.
679 *
680 *LOGIC:
681 *
682 *ASSUMPTIONS:
683 * NA
684 *
685 *NOTE:
686 * NA
687 *
688 * @param macAddr MAC address of the peer STA for which existence
689 * of Key Mapping key is to be determined
690 *
691 * @return pKeyMapEntry - Pointer to the keyMapEntry returned by CFG
692 */
693
694tCfgWepKeyEntry *
695limLookUpKeyMappings(tSirMacAddr macAddr)
696{
697 return NULL;
698} /****** end limLookUpKeyMappings() ******/
699
700
701
702/**
703 * limEncryptAuthFrame()
704 *
705 *FUNCTION:
706 * This function is called in limProcessAuthFrame() function
707 * to encrypt Authentication frame3 body.
708 *
709 *LOGIC:
710 *
711 *ASSUMPTIONS:
712 * NA
713 *
714 *NOTE:
715 * NA
716 *
717 * @param pMac Pointer to Global MAC structure
718 * @param keyId key id to used
719 * @param pKey Pointer to the key to be used for encryption
720 * @param pPlainText Pointer to the body to be encrypted
721 * @param pEncrBody Pointer to the encrypted auth frame body
722 * @param keyLength 8 (WEP40) or 16 (WEP104)
723 * @return None
724 */
725
726void
727limEncryptAuthFrame(tpAniSirGlobal pMac, tANI_U8 keyId, tANI_U8 *pKey, tANI_U8 *pPlainText,
728 tANI_U8 *pEncrBody, tANI_U32 keyLength)
729{
730 tANI_U8 seed[LIM_SEED_LENGTH], icv[SIR_MAC_WEP_ICV_LENGTH];
731
732 keyLength += 3;
733
734 // Bytes 0-2 of seed is IV
735 // Read TSF timestamp into seed to get random IV - 1st 3 bytes
736 halGetTxTSFtimer(pMac, (tSirMacTimeStamp *) &seed);
737
738 // Bytes 3-7 of seed is key
739 palCopyMemory( pMac->hHdd, (tANI_U8 *) &seed[3], pKey, keyLength - 3);
740
741 // Compute CRC-32 and place them in last 4 bytes of plain text
742 limComputeCrc32(icv, pPlainText, sizeof(tSirMacAuthFrameBody));
743
744 palCopyMemory( pMac->hHdd, pPlainText + sizeof(tSirMacAuthFrameBody),
745 icv, SIR_MAC_WEP_ICV_LENGTH);
746
747 // Run RC4 on plain text with the seed
748 limRC4(pEncrBody + SIR_MAC_WEP_IV_LENGTH,
749 (tANI_U8 *) pPlainText, seed, keyLength,
750 LIM_ENCR_AUTH_BODY_LEN - SIR_MAC_WEP_IV_LENGTH);
751
752 // Prepare IV
753 pEncrBody[0] = seed[0];
754 pEncrBody[1] = seed[1];
755 pEncrBody[2] = seed[2];
756 pEncrBody[3] = keyId << 6;
757} /****** end limEncryptAuthFrame() ******/
758
759
760
761/**
762 * limComputeCrc32()
763 *
764 *FUNCTION:
765 * This function is called to compute CRC-32 on a given source.
766 * Used while encrypting/decrypting Authentication frame 3.
767 *
768 *LOGIC:
769 *
770 *ASSUMPTIONS:
771 * NA
772 *
773 *NOTE:
774 * NA
775 *
776 * @param pDest Destination location for computed CRC
777 * @param pSrc Source location to be CRC computed
778 * @param len Length over which CRC to be computed
779 * @return None
780 */
781
782void
783limComputeCrc32(tANI_U8 *pDest, tANI_U8 * pSrc, tANI_U8 len)
784{
785 tANI_U32 crc;
786 int i;
787
788 crc = 0;
789 crc = ~crc;
790
791 while(len-- > 0)
792 crc = limCrcUpdate(crc, *pSrc++);
793
794 crc = ~crc;
795
796 for (i=0; i < SIR_MAC_WEP_IV_LENGTH; i++)
797 {
798 pDest[i] = (tANI_U8)crc;
799 crc >>= 8;
800 }
801} /****** end limComputeCrc32() ******/
802
803
804
805/**
806 * limRC4()
807 *
808 *FUNCTION:
809 * This function is called to run RC4 algorithm. Called while
810 * encrypting/decrypting Authentication frame 3.
811 *
812 *LOGIC:
813 *
814 *ASSUMPTIONS:
815 * NA
816 *
817 *NOTE:
818 * NA
819 *
820 * @param pDest Destination location for encrypted text
821 * @param pSrc Source location to be encrypted
822 * @param seed Contains seed (IV + key) for PRNG
823 * @param keyLength 8 (WEP40) or 16 (WEP104)
824 * @param frameLen Length of the frame
825 *
826 * @return None
827 */
828
829void
830limRC4(tANI_U8 *pDest, tANI_U8 *pSrc, tANI_U8 *seed, tANI_U32 keyLength, tANI_U16 frameLen)
831{
832 typedef struct
833 {
834 tANI_U8 i, j;
835 tANI_U8 sbox[256];
836 } tRC4Context;
837
838 tRC4Context ctx;
839
840 {
841 tANI_U16 i, j, k;
842
843 //
844 // Initialize sbox using seed
845 //
846
847 ctx.i = ctx.j = 0;
848 for (i=0; i<256; i++)
849 ctx.sbox[i] = (tANI_U8)i;
850
851 j = 0;
852 k = 0;
853 for (i=0; i<256; i++)
854 {
855 tANI_U8 temp;
856
857 j = (tANI_U8)(j + ctx.sbox[i] + seed[k]);
858 temp = ctx.sbox[i];
859 ctx.sbox[i] = ctx.sbox[j];
860 ctx.sbox[j] = temp;
861
862 if (++k >= keyLength)
863 k = 0;
864 }
865 }
866
867 {
868 tANI_U8 i = ctx.i;
869 tANI_U8 j = ctx.j;
870 tANI_U8 len = (tANI_U8) frameLen;
871
872 while (len-- > 0)
873 {
874 tANI_U8 temp1, temp2;
875
876 i = (tANI_U8)(i+1);
877 temp1 = ctx.sbox[i];
878 j = (tANI_U8)(j + temp1);
879
880 ctx.sbox[i] = temp2 = ctx.sbox[j];
881 ctx.sbox[j] = temp1;
882
883 temp1 = (tANI_U8)(temp1 + temp2);
884 temp1 = ctx.sbox[temp1];
885 temp2 = (tANI_U8)(pSrc ? *pSrc++ : 0);
886
887 *pDest++ = (tANI_U8)(temp1 ^ temp2);
888 }
889
890 ctx.i = i;
891 ctx.j = j;
892 }
893} /****** end limRC4() ******/
894
895
896
897/**
898 * limDecryptAuthFrame()
899 *
900 *FUNCTION:
901 * This function is called in limProcessAuthFrame() function
902 * to decrypt received Authentication frame3 body.
903 *
904 *LOGIC:
905 *
906 *ASSUMPTIONS:
907 * NA
908 *
909 *NOTE:
910 * NA
911 *
912 * @param pMac Pointer to Global MAC structure
913 * @param pKey Pointer to the key to be used for decryption
914 * @param pEncrBody Pointer to the body to be decrypted
915 * @param pPlainBody Pointer to the decrypted body
916 * @param keyLength 8 (WEP40) or 16 (WEP104)
917 *
918 * @return Decrypt result - eSIR_SUCCESS for success and
919 * LIM_DECRYPT_ICV_FAIL for ICV mismatch.
920 * If decryption is a success, pBody will
921 * have decrypted auth frame body.
922 */
923
924tANI_U8
925limDecryptAuthFrame(tpAniSirGlobal pMac, tANI_U8 *pKey, tANI_U8 *pEncrBody,
926 tANI_U8 *pPlainBody, tANI_U32 keyLength, tANI_U16 frameLen)
927{
928 tANI_U8 seed[LIM_SEED_LENGTH], icv[SIR_MAC_WEP_ICV_LENGTH];
929 int i;
930 keyLength += 3;
931
932
933 // Bytes 0-2 of seed is received IV
934 palCopyMemory( pMac->hHdd, (tANI_U8 *) seed, pEncrBody, SIR_MAC_WEP_IV_LENGTH - 1);
935
936 // Bytes 3-7 of seed is key
937 palCopyMemory( pMac->hHdd, (tANI_U8 *) &seed[3], pKey, keyLength - 3);
938
939 // Run RC4 on encrypted text with the seed
940 limRC4(pPlainBody,
941 pEncrBody + SIR_MAC_WEP_IV_LENGTH,
942 seed,
943 keyLength,
944 frameLen);
945
946 PELOG4(limLog(pMac, LOG4, FL("plainbody is \n"));
947 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG4, pPlainBody, frameLen);)
948
949 // Compute CRC-32 and place them in last 4 bytes of encrypted body
950 limComputeCrc32(icv,
951 (tANI_U8 *) pPlainBody,
952 (tANI_U8) (frameLen - SIR_MAC_WEP_ICV_LENGTH));
953
954 // Compare RX_ICV with computed ICV
955 for (i = 0; i < SIR_MAC_WEP_ICV_LENGTH; i++)
956 {
957 PELOG4(limLog(pMac, LOG4, FL(" computed ICV%d[%x], rxed ICV%d[%x]\n"),
958 i, icv[i], i, pPlainBody[frameLen - SIR_MAC_WEP_ICV_LENGTH + i]);)
959 if (icv[i] != pPlainBody[frameLen - SIR_MAC_WEP_ICV_LENGTH + i])
960 return LIM_DECRYPT_ICV_FAIL;
961 }
962
963 return eSIR_SUCCESS;
964} /****** end limDecryptAuthFrame() ******/
965
966/**
967 * limPostSmeSetKeysCnf
968 *
969 * A utility API to send MLM_SETKEYS_CNF to SME
970 */
971void limPostSmeSetKeysCnf( tpAniSirGlobal pMac,
972 tLimMlmSetKeysReq *pMlmSetKeysReq,
973 tLimMlmSetKeysCnf *mlmSetKeysCnf)
974{
975 // Prepare and Send LIM_MLM_SETKEYS_CNF
976 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmSetKeysCnf->peerMacAddr,
977 (tANI_U8 *) pMlmSetKeysReq->peerMacAddr,
978 sizeof(tSirMacAddr));
979
980 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmSetKeysCnf->peerMacAddr,
981 (tANI_U8 *) pMlmSetKeysReq->peerMacAddr,
982 sizeof(tSirMacAddr));
983
984#if (WNI_POLARIS_FW_PRODUCT == AP)
985 mlmSetKeysCnf->aid = pMlmSetKeysReq->aid;
986#endif
987
988 /// Free up buffer allocated for mlmSetKeysReq
989 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmSetKeysReq );
990 pMac->lim.gpLimMlmSetKeysReq = NULL;
991
992 limPostSmeMessage( pMac,
993 LIM_MLM_SETKEYS_CNF,
994 (tANI_U32 *) mlmSetKeysCnf );
995}
996
997/**
998 * limPostSmeRemoveKeysCnf
999 *
1000 * A utility API to send MLM_REMOVEKEY_CNF to SME
1001 */
1002void limPostSmeRemoveKeyCnf( tpAniSirGlobal pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07001003 tpPESession psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
1005 tLimMlmRemoveKeyCnf *mlmRemoveKeyCnf)
1006{
1007 // Prepare and Send LIM_MLM_REMOVEKEYS_CNF
1008 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmRemoveKeyCnf->peerMacAddr,
1009 (tANI_U8 *) pMlmRemoveKeyReq->peerMacAddr,
1010 sizeof(tSirMacAddr));
1011
1012 /// Free up buffer allocated for mlmRemoveKeysReq
1013 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmRemoveKeyReq );
1014 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
1015
Jeff Johnsone7245742012-09-05 17:12:55 -07001016 psessionEntry->limMlmState = psessionEntry->limPrevMlmState; //Restore the state.
1017 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001018
1019 limPostSmeMessage( pMac,
1020 LIM_MLM_REMOVEKEY_CNF,
1021 (tANI_U32 *) mlmRemoveKeyCnf );
1022}
1023
1024/**
1025 * limSendSetBssKeyReq()
1026 *
1027 *FUNCTION:
1028 * This function is called from limProcessMlmSetKeysReq(),
1029 * when PE is trying to setup the Group Keys related
1030 * to a specified encryption type
1031 *
1032 *LOGIC:
1033 *
1034 *ASSUMPTIONS:
1035 * NA
1036 *
1037 *NOTE:
1038 * NA
1039 *
1040 * @param pMac Pointer to Global MAC structure
1041 * @param pMlmSetKeysReq Pointer to MLM_SETKEYS_REQ buffer
1042 * @return none
1043 */
1044void limSendSetBssKeyReq( tpAniSirGlobal pMac,
1045 tLimMlmSetKeysReq *pMlmSetKeysReq,
1046 tpPESession psessionEntry)
1047{
1048tSirMsgQ msgQ;
1049tpSetBssKeyParams pSetBssKeyParams = NULL;
1050tLimMlmSetKeysCnf mlmSetKeysCnf;
1051tSirRetStatus retCode;
1052tANI_U32 val = 0;
1053
1054 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
1055 {
1056 limLog( pMac, LOG1,
1057 FL( "numKeys = %d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS\n" ), pMlmSetKeysReq->numKeys);
1058
1059 // Respond to SME with error code
1060 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1061 goto end;
1062 }
1063
1064 // Package WDA_SET_BSSKEY_REQ message parameters
1065
1066 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1067 (void **) &pSetBssKeyParams,
1068 sizeof( tSetBssKeyParams )))
1069 {
1070 limLog( pMac, LOGE,
1071 FL( "Unable to PAL allocate memory during SET_BSSKEY\n" ));
1072
1073 // Respond to SME with error code
1074 mlmSetKeysCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1075 goto end;
1076 }
1077 else
1078 palZeroMemory( pMac->hHdd,
1079 (void *) pSetBssKeyParams,
1080 sizeof( tSetBssKeyParams ));
1081
1082 // Update the WDA_SET_BSSKEY_REQ parameters
1083 pSetBssKeyParams->bssIdx = psessionEntry->bssIdx;
1084 pSetBssKeyParams->encType = pMlmSetKeysReq->edType;
Jeff Johnsone7245742012-09-05 17:12:55 -07001085
Jeff Johnson295189b2012-06-20 16:38:30 -07001086
1087 if(eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SINGLE_TID_RC, &val))
1088 {
1089 limLog( pMac, LOGP, FL( "Unable to read WNI_CFG_SINGLE_TID_RC\n" ));
1090 }
1091
1092 pSetBssKeyParams->singleTidRc = (tANI_U8)val;
1093
1094 /* Update PE session Id*/
1095 pSetBssKeyParams->sessionId = psessionEntry ->peSessionId;
1096
Jeff Johnsone7245742012-09-05 17:12:55 -07001097 if(pMlmSetKeysReq->key[0].keyId &&
1098 ((pMlmSetKeysReq->edType == eSIR_ED_WEP40) ||
1099 (pMlmSetKeysReq->edType == eSIR_ED_WEP104))
1100 )
1101 {
1102 /* IF the key id is non-zero and encryption type is WEP, Send all the 4
1103 * keys to HAL with filling the key at right index in pSetBssKeyParams->key. */
1104 pSetBssKeyParams->numKeys = SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
1105 palCopyMemory( pMac->hHdd,
1106 (tANI_U8 *) &pSetBssKeyParams->key[pMlmSetKeysReq->key[0].keyId],
1107 (tANI_U8 *) &pMlmSetKeysReq->key[0], sizeof(pMlmSetKeysReq->key[0]));
1108
1109 }
1110 else
1111 {
1112 pSetBssKeyParams->numKeys = pMlmSetKeysReq->numKeys;
1113 palCopyMemory( pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 (tANI_U8 *) &pSetBssKeyParams->key,
1115 (tANI_U8 *) &pMlmSetKeysReq->key,
1116 sizeof( tSirKeys ) * pMlmSetKeysReq->numKeys );
Jeff Johnsone7245742012-09-05 17:12:55 -07001117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001118
1119 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1120 msgQ.type = WDA_SET_BSSKEY_REQ;
1121 //
1122 // FIXME_GEN4
1123 // A global counter (dialog token) is required to keep track of
1124 // all PE <-> HAL communication(s)
1125 //
1126 msgQ.reserved = 0;
1127 msgQ.bodyptr = pSetBssKeyParams;
1128 msgQ.bodyval = 0;
1129
1130 limLog( pMac, LOGW,
1131 FL( "Sending WDA_SET_BSSKEY_REQ...\n" ));
Jeff Johnsone7245742012-09-05 17:12:55 -07001132 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1134 {
1135 limLog( pMac, LOGE,
1136 FL("Posting SET_BSSKEY to HAL failed, reason=%X\n"),
1137 retCode );
1138
1139 // Respond to SME with LIM_MLM_SETKEYS_CNF
1140 mlmSetKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1141 }
1142 else
1143 return; // Continue after WDA_SET_BSSKEY_RSP...
1144
1145end:
1146 limPostSmeSetKeysCnf( pMac,
1147 pMlmSetKeysReq,
1148 &mlmSetKeysCnf );
1149
1150}
1151
1152/**
1153 * @function : limSendSetStaKeyReq()
1154 *
1155 * @brief : This function is called from limProcessMlmSetKeysReq(),
1156 * when PE is trying to setup the Unicast Keys related
1157 * to a specified STA with specified encryption type
1158 *
1159 *LOGIC:
1160 *
1161 *ASSUMPTIONS:
1162 * NA
1163 *
1164 *NOTE:
1165 * NA
1166 *
1167 * @param pMac Pointer to Global MAC structure
1168 * @param pMlmSetKeysReq Pointer to MLM_SETKEYS_REQ buffer
1169 * @param staIdx STA index for which the keys are being set
1170 * @param defWEPIdx The default WEP key index [0..3]
1171 * @return none
1172 */
1173void limSendSetStaKeyReq( tpAniSirGlobal pMac,
1174 tLimMlmSetKeysReq *pMlmSetKeysReq,
1175 tANI_U16 staIdx,
1176 tANI_U8 defWEPIdx,
1177 tpPESession sessionEntry)
1178{
1179tSirMsgQ msgQ;
1180tpSetStaKeyParams pSetStaKeyParams = NULL;
1181tLimMlmSetKeysCnf mlmSetKeysCnf;
1182tSirRetStatus retCode;
1183tANI_U32 val = 0;
1184
1185 // Package WDA_SET_STAKEY_REQ message parameters
1186 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **) &pSetStaKeyParams,
1187 sizeof( tSetStaKeyParams ))) {
1188 limLog( pMac, LOGP, FL( "Unable to PAL allocate memory during SET_BSSKEY\n" ));
1189 return;
1190 }else
1191 palZeroMemory( pMac->hHdd, (void *) pSetStaKeyParams, sizeof( tSetStaKeyParams ));
1192
1193 // Update the WDA_SET_STAKEY_REQ parameters
1194 pSetStaKeyParams->staIdx = staIdx;
1195 pSetStaKeyParams->encType = pMlmSetKeysReq->edType;
1196
1197
1198 if(eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SINGLE_TID_RC, &val))
1199 {
1200 limLog( pMac, LOGP, FL( "Unable to read WNI_CFG_SINGLE_TID_RC\n" ));
1201 }
1202
1203 pSetStaKeyParams->singleTidRc = (tANI_U8)val;
1204
1205 /* Update PE session ID*/
1206 pSetStaKeyParams->sessionId = sessionEntry->peSessionId;
1207
1208 /**
1209 * For WEP - defWEPIdx indicates the default WEP
1210 * Key to be used for TX
1211 * For all others, there's just one key that can
1212 * be used and hence it is assumed that
1213 * defWEPIdx = 0 (from the caller)
1214 */
1215
1216 pSetStaKeyParams->defWEPIdx = defWEPIdx;
1217
1218 /** Store the Previous MlmState*/
1219 sessionEntry->limPrevMlmState = sessionEntry->limMlmState;
1220 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1221
1222 if(sessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE && !pMlmSetKeysReq->key[0].unicast) {
1223 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_BCASTKEY_STATE;
1224 msgQ.type = WDA_SET_STA_BCASTKEY_REQ;
1225 }else {
1226 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_KEY_STATE;
1227 msgQ.type = WDA_SET_STAKEY_REQ;
1228 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001229 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, sessionEntry->peSessionId, sessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001230
1231 /**
1232 * In the Case of WEP_DYNAMIC, ED_TKIP and ED_CCMP
1233 * the Key[0] contains the KEY, so just copy that alone,
1234 * for the case of WEP_STATIC the hal gets the key from cfg
1235 */
1236 switch( pMlmSetKeysReq->edType ) {
1237 case eSIR_ED_WEP40:
1238 case eSIR_ED_WEP104:
1239 // FIXME! Is this OK?
1240 if( 0 == pMlmSetKeysReq->numKeys ) {
1241#ifdef WLAN_SOFTAP_FEATURE
1242 tANI_U32 i;
1243
1244 for(i=0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS ;i++)
1245 {
1246 palCopyMemory( pMac->hHdd,
1247 (tANI_U8 *) &pSetStaKeyParams->key[i],
1248 (tANI_U8 *) &pMlmSetKeysReq->key[i], sizeof( tSirKeys ));
1249 }
1250#endif
1251 pSetStaKeyParams->wepType = eSIR_WEP_STATIC;
1252 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001253 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, sessionEntry->peSessionId, sessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 }else {
Jeff Johnsone7245742012-09-05 17:12:55 -07001255 /*This case the keys are coming from upper layer so need to fill the
1256 * key at the default wep key index and send to the HAL */
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 palCopyMemory( pMac->hHdd,
Jeff Johnsone7245742012-09-05 17:12:55 -07001258 (tANI_U8 *) &pSetStaKeyParams->key[defWEPIdx],
1259 (tANI_U8 *) &pMlmSetKeysReq->key[0], sizeof( pMlmSetKeysReq->key[0] ));
1260 pMlmSetKeysReq->numKeys = SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 }
1262 break;
1263 case eSIR_ED_TKIP:
1264 case eSIR_ED_CCMP:
1265#ifdef FEATURE_WLAN_WAPI
1266 case eSIR_ED_WPI:
1267#endif
1268 {
1269 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pSetStaKeyParams->key,
1270 (tANI_U8 *) &pMlmSetKeysReq->key[0], sizeof( tSirKeys ));
1271 }
1272 break;
1273 default:
1274 break;
1275 }
1276
1277
1278 //
1279 // FIXME_GEN4
1280 // A global counter (dialog token) is required to keep track of
1281 // all PE <-> HAL communication(s)
1282 //
1283 msgQ.reserved = 0;
1284 msgQ.bodyptr = pSetStaKeyParams;
1285 msgQ.bodyval = 0;
1286
1287 limLog( pMac, LOG1, FL( "Sending WDA_SET_STAKEY_REQ...\n" ));
Jeff Johnsone7245742012-09-05 17:12:55 -07001288 MTRACE(macTraceMsgTx(pMac, sessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ ))) {
1290 limLog( pMac, LOGE, FL("Posting SET_STAKEY to HAL failed, reason=%X\n"), retCode );
1291 // Respond to SME with LIM_MLM_SETKEYS_CNF
1292 mlmSetKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1293 }else
1294 return; // Continue after WDA_SET_STAKEY_RSP...
1295
1296 limPostSmeSetKeysCnf( pMac, pMlmSetKeysReq, &mlmSetKeysCnf );
1297}
1298
1299/**
1300 * limSendRemoveBssKeyReq()
1301 *
1302 *FUNCTION:
1303 * This function is called from limProcessMlmRemoveReq(),
1304 * when PE is trying to Remove a Group Key related
1305 * to a specified encryption type
1306 *
1307 *LOGIC:
1308 *
1309 *ASSUMPTIONS:
1310 * NA
1311 *
1312 *NOTE:
1313 * NA
1314 *
1315 * @param pMac Pointer to Global MAC structure
1316 * @param pMlmRemoveKeyReq Pointer to MLM_REMOVEKEY_REQ buffer
1317 * @return none
1318 */
1319void limSendRemoveBssKeyReq( tpAniSirGlobal pMac,
1320 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
1321 tpPESession psessionEntry)
1322{
1323tSirMsgQ msgQ;
1324tpRemoveBssKeyParams pRemoveBssKeyParams = NULL;
1325tLimMlmRemoveKeyCnf mlmRemoveKeysCnf;
1326tSirRetStatus retCode;
1327
1328 // Package WDA_REMOVE_BSSKEY_REQ message parameters
1329
1330 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1331 (void **) &pRemoveBssKeyParams,
1332 sizeof( tRemoveBssKeyParams )))
1333 {
1334 limLog( pMac, LOGE,
1335 FL( "Unable to PAL allocate memory during REMOVE_BSSKEY\n" ));
1336
1337 // Respond to SME with error code
1338 mlmRemoveKeysCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1339 goto end;
1340 }
1341 else
1342 palZeroMemory( pMac->hHdd,
1343 (void *) pRemoveBssKeyParams,
1344 sizeof( tRemoveBssKeyParams ));
1345
1346 // Update the WDA_REMOVE_BSSKEY_REQ parameters
1347 pRemoveBssKeyParams->bssIdx = psessionEntry->bssIdx;
1348 pRemoveBssKeyParams->encType = pMlmRemoveKeyReq->edType;
1349 pRemoveBssKeyParams->keyId = pMlmRemoveKeyReq->keyId;
1350 pRemoveBssKeyParams->wepType = pMlmRemoveKeyReq->wepType;
1351
1352 /* Update PE session Id*/
1353
1354 pRemoveBssKeyParams->sessionId = psessionEntry->peSessionId;
1355
1356 msgQ.type = WDA_REMOVE_BSSKEY_REQ;
1357 //
1358 // FIXME_GEN4
1359 // A global counter (dialog token) is required to keep track of
1360 // all PE <-> HAL communication(s)
1361 //
1362 msgQ.reserved = 0;
1363 msgQ.bodyptr = pRemoveBssKeyParams;
1364 msgQ.bodyval = 0;
1365
1366 limLog( pMac, LOGW,
1367 FL( "Sending WDA_REMOVE_BSSKEY_REQ...\n" ));
Jeff Johnsone7245742012-09-05 17:12:55 -07001368 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001369
1370 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1371 {
1372 limLog( pMac, LOGE,
1373 FL("Posting REMOVE_BSSKEY to HAL failed, reason=%X\n"),
1374 retCode );
1375
1376 // Respond to SME with LIM_MLM_REMOVEKEYS_CNF
1377 mlmRemoveKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1378 }
1379 else
1380 return;
1381
1382end:
1383 limPostSmeRemoveKeyCnf( pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07001384 psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 pMlmRemoveKeyReq,
1386 &mlmRemoveKeysCnf );
1387
1388}
1389
1390/**
1391 * limSendRemoveStaKeyReq()
1392 *
1393 *FUNCTION:
1394 * This function is called from limProcessMlmRemoveKeysReq(),
1395 * when PE is trying to setup the Unicast Keys related
1396 * to a specified STA with specified encryption type
1397 *
1398 *LOGIC:
1399 *
1400 *ASSUMPTIONS:
1401 * NA
1402 *
1403 *NOTE:
1404 * NA
1405 *
1406 * @param pMac Pointer to Global MAC structure
1407 * @param pMlmRemoveKeysReq Pointer to MLM_REMOVEKEYS_REQ buffer
1408 * @param staIdx STA index for which the keys are being set
1409 * @return none
1410 */
1411void limSendRemoveStaKeyReq( tpAniSirGlobal pMac,
1412 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
1413 tANI_U16 staIdx ,
Jeff Johnsone7245742012-09-05 17:12:55 -07001414 tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07001415{
1416tSirMsgQ msgQ;
1417tpRemoveStaKeyParams pRemoveStaKeyParams = NULL;
1418tLimMlmRemoveKeyCnf mlmRemoveKeyCnf;
1419tSirRetStatus retCode;
1420
1421
1422
1423 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1424 (void **) &pRemoveStaKeyParams,
1425 sizeof( tRemoveStaKeyParams )))
1426 {
1427 limLog( pMac, LOGE,
1428 FL( "Unable to PAL allocate memory during REMOVE_STAKEY\n" ));
1429
1430 // Respond to SME with error code
1431 mlmRemoveKeyCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1432 goto end;
1433 }
1434 else
1435 palZeroMemory( pMac->hHdd,
1436 (void *) pRemoveStaKeyParams,
1437 sizeof( tRemoveStaKeyParams ));
1438
1439 if( (pMlmRemoveKeyReq->edType == eSIR_ED_WEP104 || pMlmRemoveKeyReq->edType == eSIR_ED_WEP40) &&
1440 pMlmRemoveKeyReq->wepType == eSIR_WEP_STATIC )
1441 {
1442 PELOGE(limLog(pMac, LOGE, FL("Request to remove static WEP keys through station interface\n Should use BSS interface\n"));)
1443 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1444 goto end;
1445 }
1446
1447 // Update the WDA_REMOVEKEY_REQ parameters
1448 pRemoveStaKeyParams->staIdx = staIdx;
1449 pRemoveStaKeyParams->encType = pMlmRemoveKeyReq->edType;
1450 pRemoveStaKeyParams->keyId = pMlmRemoveKeyReq->keyId;
1451 pRemoveStaKeyParams->unicast = pMlmRemoveKeyReq->unicast;
1452
1453 /* Update PE session ID*/
Jeff Johnsone7245742012-09-05 17:12:55 -07001454 pRemoveStaKeyParams->sessionId = psessionEntry->peSessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001455
1456 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1457
1458 msgQ.type = WDA_REMOVE_STAKEY_REQ;
1459 //
1460 // FIXME_GEN4
1461 // A global counter (dialog token) is required to keep track of
1462 // all PE <-> HAL communication(s)
1463 //
1464 msgQ.reserved = 0;
1465 msgQ.bodyptr = pRemoveStaKeyParams;
1466 msgQ.bodyval = 0;
1467
1468 limLog( pMac, LOGW,
1469 FL( "Sending WDA_REMOVE_STAKEY_REQ...\n" ));
Jeff Johnsone7245742012-09-05 17:12:55 -07001470 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1472 {
1473 limLog( pMac, LOGE,
1474 FL("Posting REMOVE_STAKEY to HAL failed, reason=%X\n"),
1475 retCode );
1476
1477 // Respond to SME with LIM_MLM_REMOVEKEY_CNF
1478 mlmRemoveKeyCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1479 }
1480 else
1481 return;
1482
1483end:
1484 limPostSmeRemoveKeyCnf( pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07001485 psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 pMlmRemoveKeyReq,
1487 &mlmRemoveKeyCnf );
1488
1489}
1490
1491