blob: d1c774f0d19422e22d048a89f50350f34a3b9011 [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;
378 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, 0, eLIM_PRE_AUTH_CLEANUP_TIMER));
379 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
645 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, 0, pMac->lim.gLimMlmState));
646
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,
1003 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
1004 tLimMlmRemoveKeyCnf *mlmRemoveKeyCnf)
1005{
1006 // Prepare and Send LIM_MLM_REMOVEKEYS_CNF
1007 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmRemoveKeyCnf->peerMacAddr,
1008 (tANI_U8 *) pMlmRemoveKeyReq->peerMacAddr,
1009 sizeof(tSirMacAddr));
1010
1011 /// Free up buffer allocated for mlmRemoveKeysReq
1012 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmRemoveKeyReq );
1013 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
1014
1015 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState; //Restore the state.
1016 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, 0, pMac->lim.gLimMlmState));
1017
1018 limPostSmeMessage( pMac,
1019 LIM_MLM_REMOVEKEY_CNF,
1020 (tANI_U32 *) mlmRemoveKeyCnf );
1021}
1022
1023/**
1024 * limSendSetBssKeyReq()
1025 *
1026 *FUNCTION:
1027 * This function is called from limProcessMlmSetKeysReq(),
1028 * when PE is trying to setup the Group Keys related
1029 * to a specified encryption type
1030 *
1031 *LOGIC:
1032 *
1033 *ASSUMPTIONS:
1034 * NA
1035 *
1036 *NOTE:
1037 * NA
1038 *
1039 * @param pMac Pointer to Global MAC structure
1040 * @param pMlmSetKeysReq Pointer to MLM_SETKEYS_REQ buffer
1041 * @return none
1042 */
1043void limSendSetBssKeyReq( tpAniSirGlobal pMac,
1044 tLimMlmSetKeysReq *pMlmSetKeysReq,
1045 tpPESession psessionEntry)
1046{
1047tSirMsgQ msgQ;
1048tpSetBssKeyParams pSetBssKeyParams = NULL;
1049tLimMlmSetKeysCnf mlmSetKeysCnf;
1050tSirRetStatus retCode;
1051tANI_U32 val = 0;
1052
1053 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
1054 {
1055 limLog( pMac, LOG1,
1056 FL( "numKeys = %d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS\n" ), pMlmSetKeysReq->numKeys);
1057
1058 // Respond to SME with error code
1059 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1060 goto end;
1061 }
1062
1063 // Package WDA_SET_BSSKEY_REQ message parameters
1064
1065 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1066 (void **) &pSetBssKeyParams,
1067 sizeof( tSetBssKeyParams )))
1068 {
1069 limLog( pMac, LOGE,
1070 FL( "Unable to PAL allocate memory during SET_BSSKEY\n" ));
1071
1072 // Respond to SME with error code
1073 mlmSetKeysCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1074 goto end;
1075 }
1076 else
1077 palZeroMemory( pMac->hHdd,
1078 (void *) pSetBssKeyParams,
1079 sizeof( tSetBssKeyParams ));
1080
1081 // Update the WDA_SET_BSSKEY_REQ parameters
1082 pSetBssKeyParams->bssIdx = psessionEntry->bssIdx;
1083 pSetBssKeyParams->encType = pMlmSetKeysReq->edType;
1084 pSetBssKeyParams->numKeys = pMlmSetKeysReq->numKeys;
1085
1086 if(eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SINGLE_TID_RC, &val))
1087 {
1088 limLog( pMac, LOGP, FL( "Unable to read WNI_CFG_SINGLE_TID_RC\n" ));
1089 }
1090
1091 pSetBssKeyParams->singleTidRc = (tANI_U8)val;
1092
1093 /* Update PE session Id*/
1094 pSetBssKeyParams->sessionId = psessionEntry ->peSessionId;
1095
1096 palCopyMemory( pMac->hHdd,
1097 (tANI_U8 *) &pSetBssKeyParams->key,
1098 (tANI_U8 *) &pMlmSetKeysReq->key,
1099 sizeof( tSirKeys ) * pMlmSetKeysReq->numKeys );
1100
1101 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1102 msgQ.type = WDA_SET_BSSKEY_REQ;
1103 //
1104 // FIXME_GEN4
1105 // A global counter (dialog token) is required to keep track of
1106 // all PE <-> HAL communication(s)
1107 //
1108 msgQ.reserved = 0;
1109 msgQ.bodyptr = pSetBssKeyParams;
1110 msgQ.bodyval = 0;
1111
1112 limLog( pMac, LOGW,
1113 FL( "Sending WDA_SET_BSSKEY_REQ...\n" ));
1114 MTRACE(macTraceMsgTx(pMac, 0, msgQ.type));
1115 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1116 {
1117 limLog( pMac, LOGE,
1118 FL("Posting SET_BSSKEY to HAL failed, reason=%X\n"),
1119 retCode );
1120
1121 // Respond to SME with LIM_MLM_SETKEYS_CNF
1122 mlmSetKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1123 }
1124 else
1125 return; // Continue after WDA_SET_BSSKEY_RSP...
1126
1127end:
1128 limPostSmeSetKeysCnf( pMac,
1129 pMlmSetKeysReq,
1130 &mlmSetKeysCnf );
1131
1132}
1133
1134/**
1135 * @function : limSendSetStaKeyReq()
1136 *
1137 * @brief : This function is called from limProcessMlmSetKeysReq(),
1138 * when PE is trying to setup the Unicast Keys related
1139 * to a specified STA with specified encryption type
1140 *
1141 *LOGIC:
1142 *
1143 *ASSUMPTIONS:
1144 * NA
1145 *
1146 *NOTE:
1147 * NA
1148 *
1149 * @param pMac Pointer to Global MAC structure
1150 * @param pMlmSetKeysReq Pointer to MLM_SETKEYS_REQ buffer
1151 * @param staIdx STA index for which the keys are being set
1152 * @param defWEPIdx The default WEP key index [0..3]
1153 * @return none
1154 */
1155void limSendSetStaKeyReq( tpAniSirGlobal pMac,
1156 tLimMlmSetKeysReq *pMlmSetKeysReq,
1157 tANI_U16 staIdx,
1158 tANI_U8 defWEPIdx,
1159 tpPESession sessionEntry)
1160{
1161tSirMsgQ msgQ;
1162tpSetStaKeyParams pSetStaKeyParams = NULL;
1163tLimMlmSetKeysCnf mlmSetKeysCnf;
1164tSirRetStatus retCode;
1165tANI_U32 val = 0;
1166
1167 // Package WDA_SET_STAKEY_REQ message parameters
1168 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **) &pSetStaKeyParams,
1169 sizeof( tSetStaKeyParams ))) {
1170 limLog( pMac, LOGP, FL( "Unable to PAL allocate memory during SET_BSSKEY\n" ));
1171 return;
1172 }else
1173 palZeroMemory( pMac->hHdd, (void *) pSetStaKeyParams, sizeof( tSetStaKeyParams ));
1174
1175 // Update the WDA_SET_STAKEY_REQ parameters
1176 pSetStaKeyParams->staIdx = staIdx;
1177 pSetStaKeyParams->encType = pMlmSetKeysReq->edType;
1178
1179
1180 if(eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SINGLE_TID_RC, &val))
1181 {
1182 limLog( pMac, LOGP, FL( "Unable to read WNI_CFG_SINGLE_TID_RC\n" ));
1183 }
1184
1185 pSetStaKeyParams->singleTidRc = (tANI_U8)val;
1186
1187 /* Update PE session ID*/
1188 pSetStaKeyParams->sessionId = sessionEntry->peSessionId;
1189
1190 /**
1191 * For WEP - defWEPIdx indicates the default WEP
1192 * Key to be used for TX
1193 * For all others, there's just one key that can
1194 * be used and hence it is assumed that
1195 * defWEPIdx = 0 (from the caller)
1196 */
1197
1198 pSetStaKeyParams->defWEPIdx = defWEPIdx;
1199
1200 /** Store the Previous MlmState*/
1201 sessionEntry->limPrevMlmState = sessionEntry->limMlmState;
1202 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1203
1204 if(sessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE && !pMlmSetKeysReq->key[0].unicast) {
1205 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_BCASTKEY_STATE;
1206 msgQ.type = WDA_SET_STA_BCASTKEY_REQ;
1207 }else {
1208 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_KEY_STATE;
1209 msgQ.type = WDA_SET_STAKEY_REQ;
1210 }
1211 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, 0, pMac->lim.gLimMlmState));
1212
1213 /**
1214 * In the Case of WEP_DYNAMIC, ED_TKIP and ED_CCMP
1215 * the Key[0] contains the KEY, so just copy that alone,
1216 * for the case of WEP_STATIC the hal gets the key from cfg
1217 */
1218 switch( pMlmSetKeysReq->edType ) {
1219 case eSIR_ED_WEP40:
1220 case eSIR_ED_WEP104:
1221 // FIXME! Is this OK?
1222 if( 0 == pMlmSetKeysReq->numKeys ) {
1223#ifdef WLAN_SOFTAP_FEATURE
1224 tANI_U32 i;
1225
1226 for(i=0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS ;i++)
1227 {
1228 palCopyMemory( pMac->hHdd,
1229 (tANI_U8 *) &pSetStaKeyParams->key[i],
1230 (tANI_U8 *) &pMlmSetKeysReq->key[i], sizeof( tSirKeys ));
1231 }
1232#endif
1233 pSetStaKeyParams->wepType = eSIR_WEP_STATIC;
1234 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_KEY_STATE;
1235 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, 0, pMac->lim.gLimMlmState));
1236 }else {
1237 pSetStaKeyParams->wepType = eSIR_WEP_DYNAMIC;
1238 palCopyMemory( pMac->hHdd,
1239 (tANI_U8 *) &pSetStaKeyParams->key,
1240 (tANI_U8 *) &pMlmSetKeysReq->key[0], sizeof( tSirKeys ));
1241 }
1242 break;
1243 case eSIR_ED_TKIP:
1244 case eSIR_ED_CCMP:
1245#ifdef FEATURE_WLAN_WAPI
1246 case eSIR_ED_WPI:
1247#endif
1248 {
1249 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pSetStaKeyParams->key,
1250 (tANI_U8 *) &pMlmSetKeysReq->key[0], sizeof( tSirKeys ));
1251 }
1252 break;
1253 default:
1254 break;
1255 }
1256
1257
1258 //
1259 // FIXME_GEN4
1260 // A global counter (dialog token) is required to keep track of
1261 // all PE <-> HAL communication(s)
1262 //
1263 msgQ.reserved = 0;
1264 msgQ.bodyptr = pSetStaKeyParams;
1265 msgQ.bodyval = 0;
1266
1267 limLog( pMac, LOG1, FL( "Sending WDA_SET_STAKEY_REQ...\n" ));
1268 MTRACE(macTraceMsgTx(pMac, 0, msgQ.type));
1269 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ ))) {
1270 limLog( pMac, LOGE, FL("Posting SET_STAKEY to HAL failed, reason=%X\n"), retCode );
1271 // Respond to SME with LIM_MLM_SETKEYS_CNF
1272 mlmSetKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1273 }else
1274 return; // Continue after WDA_SET_STAKEY_RSP...
1275
1276 limPostSmeSetKeysCnf( pMac, pMlmSetKeysReq, &mlmSetKeysCnf );
1277}
1278
1279/**
1280 * limSendRemoveBssKeyReq()
1281 *
1282 *FUNCTION:
1283 * This function is called from limProcessMlmRemoveReq(),
1284 * when PE is trying to Remove a Group Key related
1285 * to a specified encryption type
1286 *
1287 *LOGIC:
1288 *
1289 *ASSUMPTIONS:
1290 * NA
1291 *
1292 *NOTE:
1293 * NA
1294 *
1295 * @param pMac Pointer to Global MAC structure
1296 * @param pMlmRemoveKeyReq Pointer to MLM_REMOVEKEY_REQ buffer
1297 * @return none
1298 */
1299void limSendRemoveBssKeyReq( tpAniSirGlobal pMac,
1300 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
1301 tpPESession psessionEntry)
1302{
1303tSirMsgQ msgQ;
1304tpRemoveBssKeyParams pRemoveBssKeyParams = NULL;
1305tLimMlmRemoveKeyCnf mlmRemoveKeysCnf;
1306tSirRetStatus retCode;
1307
1308 // Package WDA_REMOVE_BSSKEY_REQ message parameters
1309
1310 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1311 (void **) &pRemoveBssKeyParams,
1312 sizeof( tRemoveBssKeyParams )))
1313 {
1314 limLog( pMac, LOGE,
1315 FL( "Unable to PAL allocate memory during REMOVE_BSSKEY\n" ));
1316
1317 // Respond to SME with error code
1318 mlmRemoveKeysCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1319 goto end;
1320 }
1321 else
1322 palZeroMemory( pMac->hHdd,
1323 (void *) pRemoveBssKeyParams,
1324 sizeof( tRemoveBssKeyParams ));
1325
1326 // Update the WDA_REMOVE_BSSKEY_REQ parameters
1327 pRemoveBssKeyParams->bssIdx = psessionEntry->bssIdx;
1328 pRemoveBssKeyParams->encType = pMlmRemoveKeyReq->edType;
1329 pRemoveBssKeyParams->keyId = pMlmRemoveKeyReq->keyId;
1330 pRemoveBssKeyParams->wepType = pMlmRemoveKeyReq->wepType;
1331
1332 /* Update PE session Id*/
1333
1334 pRemoveBssKeyParams->sessionId = psessionEntry->peSessionId;
1335
1336 msgQ.type = WDA_REMOVE_BSSKEY_REQ;
1337 //
1338 // FIXME_GEN4
1339 // A global counter (dialog token) is required to keep track of
1340 // all PE <-> HAL communication(s)
1341 //
1342 msgQ.reserved = 0;
1343 msgQ.bodyptr = pRemoveBssKeyParams;
1344 msgQ.bodyval = 0;
1345
1346 limLog( pMac, LOGW,
1347 FL( "Sending WDA_REMOVE_BSSKEY_REQ...\n" ));
1348 MTRACE(macTraceMsgTx(pMac, 0, msgQ.type));
1349
1350 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1351 {
1352 limLog( pMac, LOGE,
1353 FL("Posting REMOVE_BSSKEY to HAL failed, reason=%X\n"),
1354 retCode );
1355
1356 // Respond to SME with LIM_MLM_REMOVEKEYS_CNF
1357 mlmRemoveKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1358 }
1359 else
1360 return;
1361
1362end:
1363 limPostSmeRemoveKeyCnf( pMac,
1364 pMlmRemoveKeyReq,
1365 &mlmRemoveKeysCnf );
1366
1367}
1368
1369/**
1370 * limSendRemoveStaKeyReq()
1371 *
1372 *FUNCTION:
1373 * This function is called from limProcessMlmRemoveKeysReq(),
1374 * when PE is trying to setup the Unicast Keys related
1375 * to a specified STA with specified encryption type
1376 *
1377 *LOGIC:
1378 *
1379 *ASSUMPTIONS:
1380 * NA
1381 *
1382 *NOTE:
1383 * NA
1384 *
1385 * @param pMac Pointer to Global MAC structure
1386 * @param pMlmRemoveKeysReq Pointer to MLM_REMOVEKEYS_REQ buffer
1387 * @param staIdx STA index for which the keys are being set
1388 * @return none
1389 */
1390void limSendRemoveStaKeyReq( tpAniSirGlobal pMac,
1391 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
1392 tANI_U16 staIdx ,
1393 tpPESession sessionEntry)
1394{
1395tSirMsgQ msgQ;
1396tpRemoveStaKeyParams pRemoveStaKeyParams = NULL;
1397tLimMlmRemoveKeyCnf mlmRemoveKeyCnf;
1398tSirRetStatus retCode;
1399
1400
1401
1402 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1403 (void **) &pRemoveStaKeyParams,
1404 sizeof( tRemoveStaKeyParams )))
1405 {
1406 limLog( pMac, LOGE,
1407 FL( "Unable to PAL allocate memory during REMOVE_STAKEY\n" ));
1408
1409 // Respond to SME with error code
1410 mlmRemoveKeyCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1411 goto end;
1412 }
1413 else
1414 palZeroMemory( pMac->hHdd,
1415 (void *) pRemoveStaKeyParams,
1416 sizeof( tRemoveStaKeyParams ));
1417
1418 if( (pMlmRemoveKeyReq->edType == eSIR_ED_WEP104 || pMlmRemoveKeyReq->edType == eSIR_ED_WEP40) &&
1419 pMlmRemoveKeyReq->wepType == eSIR_WEP_STATIC )
1420 {
1421 PELOGE(limLog(pMac, LOGE, FL("Request to remove static WEP keys through station interface\n Should use BSS interface\n"));)
1422 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1423 goto end;
1424 }
1425
1426 // Update the WDA_REMOVEKEY_REQ parameters
1427 pRemoveStaKeyParams->staIdx = staIdx;
1428 pRemoveStaKeyParams->encType = pMlmRemoveKeyReq->edType;
1429 pRemoveStaKeyParams->keyId = pMlmRemoveKeyReq->keyId;
1430 pRemoveStaKeyParams->unicast = pMlmRemoveKeyReq->unicast;
1431
1432 /* Update PE session ID*/
1433 pRemoveStaKeyParams->sessionId = sessionEntry->peSessionId;
1434
1435 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1436
1437 msgQ.type = WDA_REMOVE_STAKEY_REQ;
1438 //
1439 // FIXME_GEN4
1440 // A global counter (dialog token) is required to keep track of
1441 // all PE <-> HAL communication(s)
1442 //
1443 msgQ.reserved = 0;
1444 msgQ.bodyptr = pRemoveStaKeyParams;
1445 msgQ.bodyval = 0;
1446
1447 limLog( pMac, LOGW,
1448 FL( "Sending WDA_REMOVE_STAKEY_REQ...\n" ));
1449 MTRACE(macTraceMsgTx(pMac, 0, msgQ.type));
1450 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1451 {
1452 limLog( pMac, LOGE,
1453 FL("Posting REMOVE_STAKEY to HAL failed, reason=%X\n"),
1454 retCode );
1455
1456 // Respond to SME with LIM_MLM_REMOVEKEY_CNF
1457 mlmRemoveKeyCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1458 }
1459 else
1460 return;
1461
1462end:
1463 limPostSmeRemoveKeyCnf( pMac,
1464 pMlmRemoveKeyReq,
1465 &mlmRemoveKeyCnf );
1466
1467}
1468
1469