blob: 3f6c8b4af9175f942804319cbd0134a04f13228f [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 * Airgo Networks, Inc proprietary. All rights reserved.
44 * This file limUtils.cc contains the utility functions
45 * LIM uses.
46 * Author: Chandra Modumudi
47 * Date: 02/13/02
48 * History:-
49 * Date Modified by Modification Information
50 * --------------------------------------------------------------------
51 */
52
53#include "aniGlobal.h"
54#include "wniApi.h"
55
56#include "sirCommon.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include "wniCfgSta.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070058#include "cfgApi.h"
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include "utilsApi.h"
62#include "limUtils.h"
63#include "limSecurityUtils.h"
64#include "limSession.h"
65
66
67#define LIM_SEED_LENGTH 16
68
69/**
70 * limIsAuthAlgoSupported()
71 *
72 *FUNCTION:
73 * This function is called in various places within LIM code
74 * to determine whether passed authentication algorithm is enabled
75 * or not
76 *
77 *LOGIC:
78 *
79 *ASSUMPTIONS:
80 * NA
81 *
82 *NOTE:
83 * NA
84 *
85 * @param authType Indicates MAC based authentication type
86 * (eSIR_OPEN_SYSTEM or eSIR_SHARED_KEY)
87 * If Shared Key authentication to be used,
88 * 'Privacy Option Implemented' flag is also
89 * checked.
90 *
91 * @return true if passed authType is enabled else false
92 */
Jeff Johnson295189b2012-06-20 16:38:30 -070093tANI_U8
94limIsAuthAlgoSupported(tpAniSirGlobal pMac, tAniAuthType authType, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070095{
96 tANI_U32 algoEnable, privacyOptImp;
97
98 if (authType == eSIR_OPEN_SYSTEM)
99 {
100
Jeff Johnson295189b2012-06-20 16:38:30 -0700101 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
102 {
103 if((psessionEntry->authType == eSIR_OPEN_SYSTEM) || (psessionEntry->authType == eSIR_AUTO_SWITCH))
104 return true;
105 else
106 return false;
107 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700108
109 if (wlan_cfgGetInt(pMac, WNI_CFG_OPEN_SYSTEM_AUTH_ENABLE,
110 &algoEnable) != eSIR_SUCCESS)
111 {
112 /**
113 * Could not get AuthAlgo1 Enable value
114 * from CFG. Log error.
115 */
116 limLog(pMac, LOGE,
117 FL("could not retrieve AuthAlgo1 Enable value\n"));
118
119 return false;
120 }
121 else
122 return ( (algoEnable > 0 ? true : false) );
123 }
124 else
125 {
126
Jeff Johnson295189b2012-06-20 16:38:30 -0700127 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
128 {
129 if((psessionEntry->authType == eSIR_SHARED_KEY) || (psessionEntry->authType == eSIR_AUTO_SWITCH))
130 algoEnable = true;
131 else
132 algoEnable = false;
133
134 }
135 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700136
137 if (wlan_cfgGetInt(pMac, WNI_CFG_SHARED_KEY_AUTH_ENABLE,
138 &algoEnable) != eSIR_SUCCESS)
139 {
140 /**
141 * Could not get AuthAlgo2 Enable value
142 * from CFG. Log error.
143 */
144 limLog(pMac, LOGE,
145 FL("could not retrieve AuthAlgo2 Enable value\n"));
146
147 return false;
148 }
149
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
151 {
152 privacyOptImp = psessionEntry->privacy;
153 }
154 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700155
156 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
157 &privacyOptImp) != eSIR_SUCCESS)
158 {
159 /**
160 * Could not get PrivacyOptionImplemented value
161 * from CFG. Log error.
162 */
163 limLog(pMac, LOGE,
164 FL("could not retrieve PrivacyOptImplemented value\n"));
165
166 return false;
167 }
168 return (algoEnable && privacyOptImp);
169 }
170} /****** end limIsAuthAlgoSupported() ******/
171
172
173
174/**
175 * limInitPreAuthList
176 *
177 *FUNCTION:
178 * This function is called while starting a BSS at AP
179 * to initialize MAC authenticated STA list. This may also be called
180 * while joining/starting an IBSS if MAC authentication is allowed
181 * in IBSS mode.
182 *
183 *LOGIC:
184 *
185 *ASSUMPTIONS:
186 *
187 *NOTE:
188 *
189 * @param pMac - Pointer to Global MAC structure
190 * @return None
191 */
192
193void
194limInitPreAuthList(tpAniSirGlobal pMac)
195{
196 pMac->lim.pLimPreAuthList = NULL;
197
Jeff Johnson295189b2012-06-20 16:38:30 -0700198} /*** end limInitPreAuthList() ***/
199
200
201
202/**
203 * limDeletePreAuthList
204 *
205 *FUNCTION:
206 * This function is called cleanup Pre-auth list either on
207 * AP or on STA when moving from one persona to other.
208 *
209 *LOGIC:
210 *
211 *ASSUMPTIONS:
212 *
213 *NOTE:
214 *
215 * @param pMac - Pointer to Global MAC structure
216 * @return None
217 */
218
219void
220limDeletePreAuthList(tpAniSirGlobal pMac)
221{
222 struct tLimPreAuthNode *pCurrNode, *pTempNode;
223
224 pCurrNode = pTempNode = pMac->lim.pLimPreAuthList;
225 while (pCurrNode != NULL)
226 {
227 pTempNode = pCurrNode->next;
228
229 PELOG1(limLog(pMac, LOG1, FL("=====> limDeletePreAuthList \n"));)
230 limReleasePreAuthNode(pMac, pCurrNode);
231
232 pCurrNode = pTempNode;
233 }
234 pMac->lim.pLimPreAuthList = NULL;
235} /*** end limDeletePreAuthList() ***/
236
237
238
239/**
240 * limSearchPreAuthList
241 *
242 *FUNCTION:
243 * This function is called when Authentication frame is received
244 * by AP (or at a STA in IBSS supporting MAC based authentication)
245 * to search if a STA is in the middle of MAC Authentication
246 * transaction sequence.
247 *
248 *LOGIC:
249 *
250 *ASSUMPTIONS:
251 *
252 *NOTE:
253 *
254 * @param macAddr - MAC address of the STA that sent
255 * Authentication frame.
256 *
257 * @return Pointer to pre-auth node if found, else NULL
258 */
259
260struct tLimPreAuthNode *
261limSearchPreAuthList(tpAniSirGlobal pMac, tSirMacAddr macAddr)
262{
263 struct tLimPreAuthNode *pTempNode = pMac->lim.pLimPreAuthList;
264
265 while (pTempNode != NULL)
266 {
267 if (palEqualMemory( pMac->hHdd,(tANI_U8 *) macAddr,
268 (tANI_U8 *) &pTempNode->peerMacAddr,
269 sizeof(tSirMacAddr)) )
270 break;
271
272 pTempNode = pTempNode->next;
273 }
274
275 return pTempNode;
276} /*** end limSearchPreAuthList() ***/
277
278
279
280/**
281 * limAddPreAuthNode
282 *
283 *FUNCTION:
284 * This function is called at AP while sending Authentication
285 * frame2.
286 * This may also be called on a STA in IBSS if MAC authentication is
287 * allowed in IBSS mode.
288 *
289 *LOGIC:
290 * Node is always added to the front of the list
291 *
292 *ASSUMPTIONS:
293 *
294 *NOTE:
295 *
296 * @param pMac - Pointer to Global MAC structure
297 * @param pAuthNode - Pointer to pre-auth node to be added to the list.
298 *
299 * @return None
300 */
301
302void
303limAddPreAuthNode(tpAniSirGlobal pMac, struct tLimPreAuthNode *pAuthNode)
304{
305 pMac->lim.gLimNumPreAuthContexts++;
306
307 pAuthNode->next = pMac->lim.pLimPreAuthList;
308
309 pMac->lim.pLimPreAuthList = pAuthNode;
310} /*** end limAddPreAuthNode() ***/
311
312
313/**
314 * limReleasePreAuthNode
315 *
316 *FUNCTION:
317 * This function is called to realease the accquired
318 * pre auth node from list.
319 *
320 *LOGIC:
321 *
322 *ASSUMPTIONS:
323 *
324 *NOTE:
325 *
326 * @param pMac - Pointer to Global MAC structure
327 * @param pAuthNode - Pointer to Pre Auth node to be released
328 * @return None
329 */
330
331void
332limReleasePreAuthNode(tpAniSirGlobal pMac, tpLimPreAuthNode pAuthNode)
333{
334 pAuthNode->fFree = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -0700335 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, NO_SESSION, eLIM_PRE_AUTH_CLEANUP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700336 tx_timer_deactivate(&pAuthNode->timer);
337 pMac->lim.gLimNumPreAuthContexts--;
338} /*** end limReleasePreAuthNode() ***/
339
340
341/**
342 * limDeletePreAuthNode
343 *
344 *FUNCTION:
345 * This function is called at AP when a pre-authenticated STA is
346 * Associated/Reassociated or when AuthFrame4 is received after
347 * Auth Response timeout.
348 * This may also be called on a STA in IBSS if MAC authentication and
349 * Association/Reassociation is allowed in IBSS mode.
350 *
351 *LOGIC:
352 *
353 *ASSUMPTIONS:
354 *
355 *NOTE:
356 *
357 * @param pMac - Pointer to Global MAC structure
358 * @param peerMacAddr - MAC address of the STA that need to be deleted
359 * from pre-auth node list.
360 *
361 * @return None
362 */
363
364void
365limDeletePreAuthNode(tpAniSirGlobal pMac, tSirMacAddr macAddr)
366{
367 struct tLimPreAuthNode *pPrevNode, *pTempNode;
368
369 pTempNode = pPrevNode = pMac->lim.pLimPreAuthList;
370
371 if (pTempNode == NULL)
372 return;
373
374 if (palEqualMemory( pMac->hHdd,(tANI_U8 *) macAddr,
375 (tANI_U8 *) &pTempNode->peerMacAddr,
376 sizeof(tSirMacAddr)) )
377 {
378 // First node to be deleted
379
380 pMac->lim.pLimPreAuthList = pTempNode->next;
381
Jeff Johnson295189b2012-06-20 16:38:30 -0700382
383 PELOG1(limLog(pMac, LOG1, FL("=====> limDeletePreAuthNode : first node to delete\n"));)
384 PELOG1(limLog(pMac, LOG1, FL("Release data entry: %x id %d peer \n"),
385 pTempNode, pTempNode->authNodeIdx);
386 limPrintMacAddr(pMac, macAddr, LOG1);)
387 limReleasePreAuthNode(pMac, pTempNode);
388
389 return;
390 }
391
392 pTempNode = pTempNode->next;
393
394 while (pTempNode != NULL)
395 {
396 if (palEqualMemory( pMac->hHdd,(tANI_U8 *) macAddr,
397 (tANI_U8 *) &pTempNode->peerMacAddr,
398 sizeof(tSirMacAddr)) )
399 {
400 // Found node to be deleted
401
402 pPrevNode->next = pTempNode->next;
403
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 PELOG1(limLog(pMac, LOG1, FL("=====> limDeletePreAuthNode : subsequent node to delete\n"));
405 limLog(pMac, LOG1, FL("Release data entry: %x id %d peer \n"),
406 pTempNode, pTempNode->authNodeIdx);
407 limPrintMacAddr(pMac, macAddr, LOG1);)
408 limReleasePreAuthNode(pMac, pTempNode);
409
410 return;
411 }
412
413 pPrevNode = pTempNode;
414 pTempNode = pTempNode->next;
415 }
416
417 // Should not be here
418 // Log error
419 limLog(pMac, LOGP, FL("peer not found in pre-auth list, addr= "));
420 limPrintMacAddr(pMac, macAddr, LOGP);
421
422} /*** end limDeletePreAuthNode() ***/
423
424
Jeff Johnson295189b2012-06-20 16:38:30 -0700425
426
427
428/**
429 * limRestoreFromPreAuthState
430 *
431 *FUNCTION:
432 * This function is called on STA whenever an Authentication
433 * sequence is complete and state prior to auth need to be
434 * restored.
435 *
436 *LOGIC:
437 * MLM_AUTH_CNF is prepared and sent to SME state machine.
438 * In case of restoring from pre-auth:
439 * - Channel Id is programmed at LO/RF synthesizer
440 * - BSSID is programmed at RHP
441 *
442 *ASSUMPTIONS:
443 *
444 *NOTE:
445 *
446 * @param pMac - Pointer to Global MAC structure
447 * @param resultCode - result of authentication attempt
448 * @return None
449 */
450
451void
452limRestoreFromAuthState(tpAniSirGlobal pMac, tSirResultCodes resultCode, tANI_U16 protStatusCode,tpPESession sessionEntry)
453{
454 tSirMacAddr currentBssId;
455 tLimMlmAuthCnf mlmAuthCnf;
456
457 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmAuthCnf.peerMacAddr,
458 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
459 sizeof(tSirMacAddr));
460 mlmAuthCnf.authType = pMac->lim.gpLimMlmAuthReq->authType;
461 mlmAuthCnf.resultCode = resultCode;
462 mlmAuthCnf.protStatusCode = protStatusCode;
463
464 /* Update PE session ID*/
465 mlmAuthCnf.sessionId = sessionEntry->peSessionId;
466
467 /// Free up buffer allocated
468 /// for pMac->lim.gLimMlmAuthReq
469 palFreeMemory( pMac->hHdd, pMac->lim.gpLimMlmAuthReq);
470 pMac->lim.gpLimMlmAuthReq = NULL;
471
472 sessionEntry->limMlmState = sessionEntry->limPrevMlmState;
473
Jeff Johnsone7245742012-09-05 17:12:55 -0700474 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, sessionEntry->peSessionId, sessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700475
476
477 // 'Change' timer for future activations
478 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_FAIL_TIMER);
479
480 #if 0
481 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) != eSIR_SUCCESS)
482 {
483 /// Could not get BSSID from CFG. Log error.
484 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
485 }
486 #endif //TO SUPPORT BT-AMP
487 sirCopyMacAddr(currentBssId,sessionEntry->bssId);
488
489 if (sessionEntry->limSmeState == eLIM_SME_WT_PRE_AUTH_STATE)
490 {
491 pMac->lim.gLimPreAuthChannelNumber = 0;
492 }
493
494 limPostSmeMessage(pMac,
495 LIM_MLM_AUTH_CNF,
496 (tANI_U32 *) &mlmAuthCnf);
497} /*** end limRestoreFromAuthState() ***/
498
499
500
501/**
502 * limLookUpKeyMappings()
503 *
504 *FUNCTION:
505 * This function is called in limProcessAuthFrame() function
506 * to determine if there exists a Key Mapping key for a given
507 * MAC address.
508 *
509 *LOGIC:
510 *
511 *ASSUMPTIONS:
512 * NA
513 *
514 *NOTE:
515 * NA
516 *
517 * @param macAddr MAC address of the peer STA for which existence
518 * of Key Mapping key is to be determined
519 *
520 * @return pKeyMapEntry - Pointer to the keyMapEntry returned by CFG
521 */
522
523tCfgWepKeyEntry *
524limLookUpKeyMappings(tSirMacAddr macAddr)
525{
526 return NULL;
527} /****** end limLookUpKeyMappings() ******/
528
529
530
531/**
532 * limEncryptAuthFrame()
533 *
534 *FUNCTION:
535 * This function is called in limProcessAuthFrame() function
536 * to encrypt Authentication frame3 body.
537 *
538 *LOGIC:
539 *
540 *ASSUMPTIONS:
541 * NA
542 *
543 *NOTE:
544 * NA
545 *
546 * @param pMac Pointer to Global MAC structure
547 * @param keyId key id to used
548 * @param pKey Pointer to the key to be used for encryption
549 * @param pPlainText Pointer to the body to be encrypted
550 * @param pEncrBody Pointer to the encrypted auth frame body
551 * @param keyLength 8 (WEP40) or 16 (WEP104)
552 * @return None
553 */
554
555void
556limEncryptAuthFrame(tpAniSirGlobal pMac, tANI_U8 keyId, tANI_U8 *pKey, tANI_U8 *pPlainText,
557 tANI_U8 *pEncrBody, tANI_U32 keyLength)
558{
559 tANI_U8 seed[LIM_SEED_LENGTH], icv[SIR_MAC_WEP_ICV_LENGTH];
560
561 keyLength += 3;
562
563 // Bytes 0-2 of seed is IV
564 // Read TSF timestamp into seed to get random IV - 1st 3 bytes
565 halGetTxTSFtimer(pMac, (tSirMacTimeStamp *) &seed);
566
567 // Bytes 3-7 of seed is key
568 palCopyMemory( pMac->hHdd, (tANI_U8 *) &seed[3], pKey, keyLength - 3);
569
570 // Compute CRC-32 and place them in last 4 bytes of plain text
571 limComputeCrc32(icv, pPlainText, sizeof(tSirMacAuthFrameBody));
572
573 palCopyMemory( pMac->hHdd, pPlainText + sizeof(tSirMacAuthFrameBody),
574 icv, SIR_MAC_WEP_ICV_LENGTH);
575
576 // Run RC4 on plain text with the seed
577 limRC4(pEncrBody + SIR_MAC_WEP_IV_LENGTH,
578 (tANI_U8 *) pPlainText, seed, keyLength,
579 LIM_ENCR_AUTH_BODY_LEN - SIR_MAC_WEP_IV_LENGTH);
580
581 // Prepare IV
582 pEncrBody[0] = seed[0];
583 pEncrBody[1] = seed[1];
584 pEncrBody[2] = seed[2];
585 pEncrBody[3] = keyId << 6;
586} /****** end limEncryptAuthFrame() ******/
587
588
589
590/**
591 * limComputeCrc32()
592 *
593 *FUNCTION:
594 * This function is called to compute CRC-32 on a given source.
595 * Used while encrypting/decrypting Authentication frame 3.
596 *
597 *LOGIC:
598 *
599 *ASSUMPTIONS:
600 * NA
601 *
602 *NOTE:
603 * NA
604 *
605 * @param pDest Destination location for computed CRC
606 * @param pSrc Source location to be CRC computed
607 * @param len Length over which CRC to be computed
608 * @return None
609 */
610
611void
612limComputeCrc32(tANI_U8 *pDest, tANI_U8 * pSrc, tANI_U8 len)
613{
614 tANI_U32 crc;
615 int i;
616
617 crc = 0;
618 crc = ~crc;
619
620 while(len-- > 0)
621 crc = limCrcUpdate(crc, *pSrc++);
622
623 crc = ~crc;
624
625 for (i=0; i < SIR_MAC_WEP_IV_LENGTH; i++)
626 {
627 pDest[i] = (tANI_U8)crc;
628 crc >>= 8;
629 }
630} /****** end limComputeCrc32() ******/
631
632
633
634/**
635 * limRC4()
636 *
637 *FUNCTION:
638 * This function is called to run RC4 algorithm. Called while
639 * encrypting/decrypting Authentication frame 3.
640 *
641 *LOGIC:
642 *
643 *ASSUMPTIONS:
644 * NA
645 *
646 *NOTE:
647 * NA
648 *
649 * @param pDest Destination location for encrypted text
650 * @param pSrc Source location to be encrypted
651 * @param seed Contains seed (IV + key) for PRNG
652 * @param keyLength 8 (WEP40) or 16 (WEP104)
653 * @param frameLen Length of the frame
654 *
655 * @return None
656 */
657
658void
659limRC4(tANI_U8 *pDest, tANI_U8 *pSrc, tANI_U8 *seed, tANI_U32 keyLength, tANI_U16 frameLen)
660{
661 typedef struct
662 {
663 tANI_U8 i, j;
664 tANI_U8 sbox[256];
665 } tRC4Context;
666
667 tRC4Context ctx;
668
669 {
670 tANI_U16 i, j, k;
671
672 //
673 // Initialize sbox using seed
674 //
675
676 ctx.i = ctx.j = 0;
677 for (i=0; i<256; i++)
678 ctx.sbox[i] = (tANI_U8)i;
679
680 j = 0;
681 k = 0;
682 for (i=0; i<256; i++)
683 {
684 tANI_U8 temp;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -0700685 if ( k < LIM_SEED_LENGTH )
686 j = (tANI_U8)(j + ctx.sbox[i] + seed[k]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 temp = ctx.sbox[i];
688 ctx.sbox[i] = ctx.sbox[j];
689 ctx.sbox[j] = temp;
690
691 if (++k >= keyLength)
692 k = 0;
693 }
694 }
695
696 {
697 tANI_U8 i = ctx.i;
698 tANI_U8 j = ctx.j;
699 tANI_U8 len = (tANI_U8) frameLen;
700
701 while (len-- > 0)
702 {
703 tANI_U8 temp1, temp2;
704
705 i = (tANI_U8)(i+1);
706 temp1 = ctx.sbox[i];
707 j = (tANI_U8)(j + temp1);
708
709 ctx.sbox[i] = temp2 = ctx.sbox[j];
710 ctx.sbox[j] = temp1;
711
712 temp1 = (tANI_U8)(temp1 + temp2);
713 temp1 = ctx.sbox[temp1];
714 temp2 = (tANI_U8)(pSrc ? *pSrc++ : 0);
715
716 *pDest++ = (tANI_U8)(temp1 ^ temp2);
717 }
718
719 ctx.i = i;
720 ctx.j = j;
721 }
722} /****** end limRC4() ******/
723
724
725
726/**
727 * limDecryptAuthFrame()
728 *
729 *FUNCTION:
730 * This function is called in limProcessAuthFrame() function
731 * to decrypt received Authentication frame3 body.
732 *
733 *LOGIC:
734 *
735 *ASSUMPTIONS:
736 * NA
737 *
738 *NOTE:
739 * NA
740 *
741 * @param pMac Pointer to Global MAC structure
742 * @param pKey Pointer to the key to be used for decryption
743 * @param pEncrBody Pointer to the body to be decrypted
744 * @param pPlainBody Pointer to the decrypted body
745 * @param keyLength 8 (WEP40) or 16 (WEP104)
746 *
747 * @return Decrypt result - eSIR_SUCCESS for success and
748 * LIM_DECRYPT_ICV_FAIL for ICV mismatch.
749 * If decryption is a success, pBody will
750 * have decrypted auth frame body.
751 */
752
753tANI_U8
754limDecryptAuthFrame(tpAniSirGlobal pMac, tANI_U8 *pKey, tANI_U8 *pEncrBody,
755 tANI_U8 *pPlainBody, tANI_U32 keyLength, tANI_U16 frameLen)
756{
757 tANI_U8 seed[LIM_SEED_LENGTH], icv[SIR_MAC_WEP_ICV_LENGTH];
758 int i;
759 keyLength += 3;
760
761
762 // Bytes 0-2 of seed is received IV
763 palCopyMemory( pMac->hHdd, (tANI_U8 *) seed, pEncrBody, SIR_MAC_WEP_IV_LENGTH - 1);
764
765 // Bytes 3-7 of seed is key
766 palCopyMemory( pMac->hHdd, (tANI_U8 *) &seed[3], pKey, keyLength - 3);
767
768 // Run RC4 on encrypted text with the seed
769 limRC4(pPlainBody,
770 pEncrBody + SIR_MAC_WEP_IV_LENGTH,
771 seed,
772 keyLength,
773 frameLen);
774
775 PELOG4(limLog(pMac, LOG4, FL("plainbody is \n"));
776 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG4, pPlainBody, frameLen);)
777
778 // Compute CRC-32 and place them in last 4 bytes of encrypted body
779 limComputeCrc32(icv,
780 (tANI_U8 *) pPlainBody,
781 (tANI_U8) (frameLen - SIR_MAC_WEP_ICV_LENGTH));
782
783 // Compare RX_ICV with computed ICV
784 for (i = 0; i < SIR_MAC_WEP_ICV_LENGTH; i++)
785 {
786 PELOG4(limLog(pMac, LOG4, FL(" computed ICV%d[%x], rxed ICV%d[%x]\n"),
787 i, icv[i], i, pPlainBody[frameLen - SIR_MAC_WEP_ICV_LENGTH + i]);)
788 if (icv[i] != pPlainBody[frameLen - SIR_MAC_WEP_ICV_LENGTH + i])
789 return LIM_DECRYPT_ICV_FAIL;
790 }
791
792 return eSIR_SUCCESS;
793} /****** end limDecryptAuthFrame() ******/
794
795/**
796 * limPostSmeSetKeysCnf
797 *
798 * A utility API to send MLM_SETKEYS_CNF to SME
799 */
800void limPostSmeSetKeysCnf( tpAniSirGlobal pMac,
801 tLimMlmSetKeysReq *pMlmSetKeysReq,
802 tLimMlmSetKeysCnf *mlmSetKeysCnf)
803{
804 // Prepare and Send LIM_MLM_SETKEYS_CNF
805 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmSetKeysCnf->peerMacAddr,
806 (tANI_U8 *) pMlmSetKeysReq->peerMacAddr,
807 sizeof(tSirMacAddr));
808
809 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmSetKeysCnf->peerMacAddr,
810 (tANI_U8 *) pMlmSetKeysReq->peerMacAddr,
811 sizeof(tSirMacAddr));
812
Jeff Johnson295189b2012-06-20 16:38:30 -0700813
814 /// Free up buffer allocated for mlmSetKeysReq
815 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmSetKeysReq );
816 pMac->lim.gpLimMlmSetKeysReq = NULL;
817
818 limPostSmeMessage( pMac,
819 LIM_MLM_SETKEYS_CNF,
820 (tANI_U32 *) mlmSetKeysCnf );
821}
822
823/**
824 * limPostSmeRemoveKeysCnf
825 *
826 * A utility API to send MLM_REMOVEKEY_CNF to SME
827 */
828void limPostSmeRemoveKeyCnf( tpAniSirGlobal pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -0700829 tpPESession psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
831 tLimMlmRemoveKeyCnf *mlmRemoveKeyCnf)
832{
833 // Prepare and Send LIM_MLM_REMOVEKEYS_CNF
834 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmRemoveKeyCnf->peerMacAddr,
835 (tANI_U8 *) pMlmRemoveKeyReq->peerMacAddr,
836 sizeof(tSirMacAddr));
837
838 /// Free up buffer allocated for mlmRemoveKeysReq
839 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmRemoveKeyReq );
840 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
841
Jeff Johnsone7245742012-09-05 17:12:55 -0700842 psessionEntry->limMlmState = psessionEntry->limPrevMlmState; //Restore the state.
843 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700844
845 limPostSmeMessage( pMac,
846 LIM_MLM_REMOVEKEY_CNF,
847 (tANI_U32 *) mlmRemoveKeyCnf );
848}
849
850/**
851 * limSendSetBssKeyReq()
852 *
853 *FUNCTION:
854 * This function is called from limProcessMlmSetKeysReq(),
855 * when PE is trying to setup the Group Keys related
856 * to a specified encryption type
857 *
858 *LOGIC:
859 *
860 *ASSUMPTIONS:
861 * NA
862 *
863 *NOTE:
864 * NA
865 *
866 * @param pMac Pointer to Global MAC structure
867 * @param pMlmSetKeysReq Pointer to MLM_SETKEYS_REQ buffer
868 * @return none
869 */
870void limSendSetBssKeyReq( tpAniSirGlobal pMac,
871 tLimMlmSetKeysReq *pMlmSetKeysReq,
872 tpPESession psessionEntry)
873{
874tSirMsgQ msgQ;
875tpSetBssKeyParams pSetBssKeyParams = NULL;
876tLimMlmSetKeysCnf mlmSetKeysCnf;
877tSirRetStatus retCode;
878tANI_U32 val = 0;
879
880 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
881 {
882 limLog( pMac, LOG1,
883 FL( "numKeys = %d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS\n" ), pMlmSetKeysReq->numKeys);
884
885 // Respond to SME with error code
886 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
887 goto end;
888 }
889
890 // Package WDA_SET_BSSKEY_REQ message parameters
891
892 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
893 (void **) &pSetBssKeyParams,
894 sizeof( tSetBssKeyParams )))
895 {
896 limLog( pMac, LOGE,
897 FL( "Unable to PAL allocate memory during SET_BSSKEY\n" ));
898
899 // Respond to SME with error code
900 mlmSetKeysCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
901 goto end;
902 }
903 else
904 palZeroMemory( pMac->hHdd,
905 (void *) pSetBssKeyParams,
906 sizeof( tSetBssKeyParams ));
907
908 // Update the WDA_SET_BSSKEY_REQ parameters
909 pSetBssKeyParams->bssIdx = psessionEntry->bssIdx;
910 pSetBssKeyParams->encType = pMlmSetKeysReq->edType;
Jeff Johnsone7245742012-09-05 17:12:55 -0700911
Jeff Johnson295189b2012-06-20 16:38:30 -0700912
913 if(eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SINGLE_TID_RC, &val))
914 {
915 limLog( pMac, LOGP, FL( "Unable to read WNI_CFG_SINGLE_TID_RC\n" ));
916 }
917
918 pSetBssKeyParams->singleTidRc = (tANI_U8)val;
919
920 /* Update PE session Id*/
921 pSetBssKeyParams->sessionId = psessionEntry ->peSessionId;
922
Jeff Johnsone7245742012-09-05 17:12:55 -0700923 if(pMlmSetKeysReq->key[0].keyId &&
924 ((pMlmSetKeysReq->edType == eSIR_ED_WEP40) ||
925 (pMlmSetKeysReq->edType == eSIR_ED_WEP104))
926 )
927 {
928 /* IF the key id is non-zero and encryption type is WEP, Send all the 4
929 * keys to HAL with filling the key at right index in pSetBssKeyParams->key. */
930 pSetBssKeyParams->numKeys = SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
931 palCopyMemory( pMac->hHdd,
932 (tANI_U8 *) &pSetBssKeyParams->key[pMlmSetKeysReq->key[0].keyId],
933 (tANI_U8 *) &pMlmSetKeysReq->key[0], sizeof(pMlmSetKeysReq->key[0]));
934
935 }
936 else
937 {
938 pSetBssKeyParams->numKeys = pMlmSetKeysReq->numKeys;
939 palCopyMemory( pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 (tANI_U8 *) &pSetBssKeyParams->key,
941 (tANI_U8 *) &pMlmSetKeysReq->key,
942 sizeof( tSirKeys ) * pMlmSetKeysReq->numKeys );
Jeff Johnsone7245742012-09-05 17:12:55 -0700943 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700944
945 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
946 msgQ.type = WDA_SET_BSSKEY_REQ;
947 //
948 // FIXME_GEN4
949 // A global counter (dialog token) is required to keep track of
950 // all PE <-> HAL communication(s)
951 //
952 msgQ.reserved = 0;
953 msgQ.bodyptr = pSetBssKeyParams;
954 msgQ.bodyval = 0;
955
956 limLog( pMac, LOGW,
957 FL( "Sending WDA_SET_BSSKEY_REQ...\n" ));
Jeff Johnsone7245742012-09-05 17:12:55 -0700958 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700959 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
960 {
961 limLog( pMac, LOGE,
962 FL("Posting SET_BSSKEY to HAL failed, reason=%X\n"),
963 retCode );
964
965 // Respond to SME with LIM_MLM_SETKEYS_CNF
966 mlmSetKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
967 }
968 else
969 return; // Continue after WDA_SET_BSSKEY_RSP...
970
971end:
972 limPostSmeSetKeysCnf( pMac,
973 pMlmSetKeysReq,
974 &mlmSetKeysCnf );
975
976}
977
978/**
979 * @function : limSendSetStaKeyReq()
980 *
981 * @brief : This function is called from limProcessMlmSetKeysReq(),
982 * when PE is trying to setup the Unicast Keys related
983 * to a specified STA with specified encryption type
984 *
985 *LOGIC:
986 *
987 *ASSUMPTIONS:
988 * NA
989 *
990 *NOTE:
991 * NA
992 *
993 * @param pMac Pointer to Global MAC structure
994 * @param pMlmSetKeysReq Pointer to MLM_SETKEYS_REQ buffer
995 * @param staIdx STA index for which the keys are being set
996 * @param defWEPIdx The default WEP key index [0..3]
997 * @return none
998 */
999void limSendSetStaKeyReq( tpAniSirGlobal pMac,
1000 tLimMlmSetKeysReq *pMlmSetKeysReq,
1001 tANI_U16 staIdx,
1002 tANI_U8 defWEPIdx,
1003 tpPESession sessionEntry)
1004{
1005tSirMsgQ msgQ;
1006tpSetStaKeyParams pSetStaKeyParams = NULL;
1007tLimMlmSetKeysCnf mlmSetKeysCnf;
1008tSirRetStatus retCode;
1009tANI_U32 val = 0;
1010
1011 // Package WDA_SET_STAKEY_REQ message parameters
1012 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **) &pSetStaKeyParams,
1013 sizeof( tSetStaKeyParams ))) {
1014 limLog( pMac, LOGP, FL( "Unable to PAL allocate memory during SET_BSSKEY\n" ));
1015 return;
1016 }else
1017 palZeroMemory( pMac->hHdd, (void *) pSetStaKeyParams, sizeof( tSetStaKeyParams ));
1018
1019 // Update the WDA_SET_STAKEY_REQ parameters
1020 pSetStaKeyParams->staIdx = staIdx;
1021 pSetStaKeyParams->encType = pMlmSetKeysReq->edType;
1022
1023
1024 if(eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SINGLE_TID_RC, &val))
1025 {
1026 limLog( pMac, LOGP, FL( "Unable to read WNI_CFG_SINGLE_TID_RC\n" ));
1027 }
1028
1029 pSetStaKeyParams->singleTidRc = (tANI_U8)val;
1030
1031 /* Update PE session ID*/
1032 pSetStaKeyParams->sessionId = sessionEntry->peSessionId;
1033
1034 /**
1035 * For WEP - defWEPIdx indicates the default WEP
1036 * Key to be used for TX
1037 * For all others, there's just one key that can
1038 * be used and hence it is assumed that
1039 * defWEPIdx = 0 (from the caller)
1040 */
1041
1042 pSetStaKeyParams->defWEPIdx = defWEPIdx;
1043
1044 /** Store the Previous MlmState*/
1045 sessionEntry->limPrevMlmState = sessionEntry->limMlmState;
1046 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1047
1048 if(sessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE && !pMlmSetKeysReq->key[0].unicast) {
1049 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_BCASTKEY_STATE;
1050 msgQ.type = WDA_SET_STA_BCASTKEY_REQ;
1051 }else {
1052 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_KEY_STATE;
1053 msgQ.type = WDA_SET_STAKEY_REQ;
1054 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001055 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, sessionEntry->peSessionId, sessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001056
1057 /**
1058 * In the Case of WEP_DYNAMIC, ED_TKIP and ED_CCMP
1059 * the Key[0] contains the KEY, so just copy that alone,
1060 * for the case of WEP_STATIC the hal gets the key from cfg
1061 */
1062 switch( pMlmSetKeysReq->edType ) {
1063 case eSIR_ED_WEP40:
1064 case eSIR_ED_WEP104:
1065 // FIXME! Is this OK?
1066 if( 0 == pMlmSetKeysReq->numKeys ) {
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 tANI_U32 i;
1068
1069 for(i=0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS ;i++)
1070 {
1071 palCopyMemory( pMac->hHdd,
1072 (tANI_U8 *) &pSetStaKeyParams->key[i],
1073 (tANI_U8 *) &pMlmSetKeysReq->key[i], sizeof( tSirKeys ));
1074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 pSetStaKeyParams->wepType = eSIR_WEP_STATIC;
1076 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001077 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, sessionEntry->peSessionId, sessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 }else {
Jeff Johnsone7245742012-09-05 17:12:55 -07001079 /*This case the keys are coming from upper layer so need to fill the
1080 * key at the default wep key index and send to the HAL */
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 palCopyMemory( pMac->hHdd,
Jeff Johnsone7245742012-09-05 17:12:55 -07001082 (tANI_U8 *) &pSetStaKeyParams->key[defWEPIdx],
1083 (tANI_U8 *) &pMlmSetKeysReq->key[0], sizeof( pMlmSetKeysReq->key[0] ));
1084 pMlmSetKeysReq->numKeys = SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 }
1086 break;
1087 case eSIR_ED_TKIP:
1088 case eSIR_ED_CCMP:
1089#ifdef FEATURE_WLAN_WAPI
1090 case eSIR_ED_WPI:
1091#endif
1092 {
1093 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pSetStaKeyParams->key,
1094 (tANI_U8 *) &pMlmSetKeysReq->key[0], sizeof( tSirKeys ));
1095 }
1096 break;
1097 default:
1098 break;
1099 }
1100
1101
1102 //
1103 // FIXME_GEN4
1104 // A global counter (dialog token) is required to keep track of
1105 // all PE <-> HAL communication(s)
1106 //
1107 msgQ.reserved = 0;
1108 msgQ.bodyptr = pSetStaKeyParams;
1109 msgQ.bodyval = 0;
1110
1111 limLog( pMac, LOG1, FL( "Sending WDA_SET_STAKEY_REQ...\n" ));
Jeff Johnsone7245742012-09-05 17:12:55 -07001112 MTRACE(macTraceMsgTx(pMac, sessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ ))) {
1114 limLog( pMac, LOGE, FL("Posting SET_STAKEY to HAL failed, reason=%X\n"), retCode );
1115 // Respond to SME with LIM_MLM_SETKEYS_CNF
1116 mlmSetKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1117 }else
1118 return; // Continue after WDA_SET_STAKEY_RSP...
1119
1120 limPostSmeSetKeysCnf( pMac, pMlmSetKeysReq, &mlmSetKeysCnf );
1121}
1122
1123/**
1124 * limSendRemoveBssKeyReq()
1125 *
1126 *FUNCTION:
1127 * This function is called from limProcessMlmRemoveReq(),
1128 * when PE is trying to Remove a Group Key related
1129 * to a specified encryption type
1130 *
1131 *LOGIC:
1132 *
1133 *ASSUMPTIONS:
1134 * NA
1135 *
1136 *NOTE:
1137 * NA
1138 *
1139 * @param pMac Pointer to Global MAC structure
1140 * @param pMlmRemoveKeyReq Pointer to MLM_REMOVEKEY_REQ buffer
1141 * @return none
1142 */
1143void limSendRemoveBssKeyReq( tpAniSirGlobal pMac,
1144 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
1145 tpPESession psessionEntry)
1146{
1147tSirMsgQ msgQ;
1148tpRemoveBssKeyParams pRemoveBssKeyParams = NULL;
1149tLimMlmRemoveKeyCnf mlmRemoveKeysCnf;
1150tSirRetStatus retCode;
1151
1152 // Package WDA_REMOVE_BSSKEY_REQ message parameters
1153
1154 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1155 (void **) &pRemoveBssKeyParams,
1156 sizeof( tRemoveBssKeyParams )))
1157 {
1158 limLog( pMac, LOGE,
1159 FL( "Unable to PAL allocate memory during REMOVE_BSSKEY\n" ));
1160
1161 // Respond to SME with error code
1162 mlmRemoveKeysCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1163 goto end;
1164 }
1165 else
1166 palZeroMemory( pMac->hHdd,
1167 (void *) pRemoveBssKeyParams,
1168 sizeof( tRemoveBssKeyParams ));
1169
1170 // Update the WDA_REMOVE_BSSKEY_REQ parameters
1171 pRemoveBssKeyParams->bssIdx = psessionEntry->bssIdx;
1172 pRemoveBssKeyParams->encType = pMlmRemoveKeyReq->edType;
1173 pRemoveBssKeyParams->keyId = pMlmRemoveKeyReq->keyId;
1174 pRemoveBssKeyParams->wepType = pMlmRemoveKeyReq->wepType;
1175
1176 /* Update PE session Id*/
1177
1178 pRemoveBssKeyParams->sessionId = psessionEntry->peSessionId;
1179
1180 msgQ.type = WDA_REMOVE_BSSKEY_REQ;
1181 //
1182 // FIXME_GEN4
1183 // A global counter (dialog token) is required to keep track of
1184 // all PE <-> HAL communication(s)
1185 //
1186 msgQ.reserved = 0;
1187 msgQ.bodyptr = pRemoveBssKeyParams;
1188 msgQ.bodyval = 0;
1189
1190 limLog( pMac, LOGW,
1191 FL( "Sending WDA_REMOVE_BSSKEY_REQ...\n" ));
Jeff Johnsone7245742012-09-05 17:12:55 -07001192 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001193
1194 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1195 {
1196 limLog( pMac, LOGE,
1197 FL("Posting REMOVE_BSSKEY to HAL failed, reason=%X\n"),
1198 retCode );
1199
1200 // Respond to SME with LIM_MLM_REMOVEKEYS_CNF
1201 mlmRemoveKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1202 }
1203 else
1204 return;
1205
1206end:
1207 limPostSmeRemoveKeyCnf( pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07001208 psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07001209 pMlmRemoveKeyReq,
1210 &mlmRemoveKeysCnf );
1211
1212}
1213
1214/**
1215 * limSendRemoveStaKeyReq()
1216 *
1217 *FUNCTION:
1218 * This function is called from limProcessMlmRemoveKeysReq(),
1219 * when PE is trying to setup the Unicast Keys related
1220 * to a specified STA with specified encryption type
1221 *
1222 *LOGIC:
1223 *
1224 *ASSUMPTIONS:
1225 * NA
1226 *
1227 *NOTE:
1228 * NA
1229 *
1230 * @param pMac Pointer to Global MAC structure
1231 * @param pMlmRemoveKeysReq Pointer to MLM_REMOVEKEYS_REQ buffer
1232 * @param staIdx STA index for which the keys are being set
1233 * @return none
1234 */
1235void limSendRemoveStaKeyReq( tpAniSirGlobal pMac,
1236 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
1237 tANI_U16 staIdx ,
Jeff Johnsone7245742012-09-05 17:12:55 -07001238 tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07001239{
1240tSirMsgQ msgQ;
1241tpRemoveStaKeyParams pRemoveStaKeyParams = NULL;
1242tLimMlmRemoveKeyCnf mlmRemoveKeyCnf;
1243tSirRetStatus retCode;
1244
1245
1246
1247 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1248 (void **) &pRemoveStaKeyParams,
1249 sizeof( tRemoveStaKeyParams )))
1250 {
1251 limLog( pMac, LOGE,
1252 FL( "Unable to PAL allocate memory during REMOVE_STAKEY\n" ));
1253
1254 // Respond to SME with error code
1255 mlmRemoveKeyCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1256 goto end;
1257 }
1258 else
1259 palZeroMemory( pMac->hHdd,
1260 (void *) pRemoveStaKeyParams,
1261 sizeof( tRemoveStaKeyParams ));
1262
1263 if( (pMlmRemoveKeyReq->edType == eSIR_ED_WEP104 || pMlmRemoveKeyReq->edType == eSIR_ED_WEP40) &&
1264 pMlmRemoveKeyReq->wepType == eSIR_WEP_STATIC )
1265 {
1266 PELOGE(limLog(pMac, LOGE, FL("Request to remove static WEP keys through station interface\n Should use BSS interface\n"));)
1267 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1268 goto end;
1269 }
Jeff Johnson2e77e8c2013-04-03 15:10:02 -07001270
Jeff Johnson295189b2012-06-20 16:38:30 -07001271 // Update the WDA_REMOVEKEY_REQ parameters
1272 pRemoveStaKeyParams->staIdx = staIdx;
1273 pRemoveStaKeyParams->encType = pMlmRemoveKeyReq->edType;
1274 pRemoveStaKeyParams->keyId = pMlmRemoveKeyReq->keyId;
1275 pRemoveStaKeyParams->unicast = pMlmRemoveKeyReq->unicast;
1276
1277 /* Update PE session ID*/
Jeff Johnsone7245742012-09-05 17:12:55 -07001278 pRemoveStaKeyParams->sessionId = psessionEntry->peSessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001279
1280 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnson2e77e8c2013-04-03 15:10:02 -07001281
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 msgQ.type = WDA_REMOVE_STAKEY_REQ;
1283 //
1284 // FIXME_GEN4
1285 // A global counter (dialog token) is required to keep track of
1286 // all PE <-> HAL communication(s)
1287 //
1288 msgQ.reserved = 0;
1289 msgQ.bodyptr = pRemoveStaKeyParams;
1290 msgQ.bodyval = 0;
1291
1292 limLog( pMac, LOGW,
1293 FL( "Sending WDA_REMOVE_STAKEY_REQ...\n" ));
Jeff Johnsone7245742012-09-05 17:12:55 -07001294 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson2e77e8c2013-04-03 15:10:02 -07001295 retCode = wdaPostCtrlMsg( pMac, &msgQ );
1296 if (eSIR_SUCCESS != retCode)
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 {
1298 limLog( pMac, LOGE,
Jeff Johnson2e77e8c2013-04-03 15:10:02 -07001299 FL("Posting REMOVE_STAKEY to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 retCode );
Jeff Johnson2e77e8c2013-04-03 15:10:02 -07001301 palFreeMemory(pMac->hHdd, pRemoveStaKeyParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001302
1303 // Respond to SME with LIM_MLM_REMOVEKEY_CNF
1304 mlmRemoveKeyCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1305 }
1306 else
Jeff Johnson2e77e8c2013-04-03 15:10:02 -07001307 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001308
1309end:
1310 limPostSmeRemoveKeyCnf( pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07001311 psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 pMlmRemoveKeyReq,
1313 &mlmRemoveKeyCnf );
1314
1315}
1316
1317