blob: 968c348629ba8ee6ebeffb2808a7d89aeb0a42f2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -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.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080022/*
Kiet Lam842dad02014-02-18 18:44:02 -080023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * This file limUtils.cc contains the utility functions
30 * LIM uses.
31 * Author: Chandra Modumudi
32 * Date: 02/13/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 */
37
38#include "aniGlobal.h"
39#include "wniApi.h"
40
41#include "sirCommon.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070042#include "wniCfgSta.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070043#include "cfgApi.h"
44
Jeff Johnson295189b2012-06-20 16:38:30 -070045
46#include "utilsApi.h"
47#include "limUtils.h"
48#include "limSecurityUtils.h"
49#include "limSession.h"
50
51
52#define LIM_SEED_LENGTH 16
53
54/**
55 * limIsAuthAlgoSupported()
56 *
57 *FUNCTION:
58 * This function is called in various places within LIM code
59 * to determine whether passed authentication algorithm is enabled
60 * or not
61 *
62 *LOGIC:
63 *
64 *ASSUMPTIONS:
65 * NA
66 *
67 *NOTE:
68 * NA
69 *
70 * @param authType Indicates MAC based authentication type
71 * (eSIR_OPEN_SYSTEM or eSIR_SHARED_KEY)
72 * If Shared Key authentication to be used,
73 * 'Privacy Option Implemented' flag is also
74 * checked.
75 *
76 * @return true if passed authType is enabled else false
77 */
Jeff Johnson295189b2012-06-20 16:38:30 -070078tANI_U8
79limIsAuthAlgoSupported(tpAniSirGlobal pMac, tAniAuthType authType, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070080{
81 tANI_U32 algoEnable, privacyOptImp;
82
83 if (authType == eSIR_OPEN_SYSTEM)
84 {
85
Jeff Johnson295189b2012-06-20 16:38:30 -070086 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
87 {
88 if((psessionEntry->authType == eSIR_OPEN_SYSTEM) || (psessionEntry->authType == eSIR_AUTO_SWITCH))
89 return true;
90 else
91 return false;
92 }
Jeff Johnson295189b2012-06-20 16:38:30 -070093
94 if (wlan_cfgGetInt(pMac, WNI_CFG_OPEN_SYSTEM_AUTH_ENABLE,
95 &algoEnable) != eSIR_SUCCESS)
96 {
97 /**
98 * Could not get AuthAlgo1 Enable value
99 * from CFG. Log error.
100 */
101 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700102 FL("could not retrieve AuthAlgo1 Enable value"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700103
104 return false;
105 }
106 else
107 return ( (algoEnable > 0 ? true : false) );
108 }
109 else
110 {
111
Jeff Johnson295189b2012-06-20 16:38:30 -0700112 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
113 {
114 if((psessionEntry->authType == eSIR_SHARED_KEY) || (psessionEntry->authType == eSIR_AUTO_SWITCH))
115 algoEnable = true;
116 else
117 algoEnable = false;
118
119 }
120 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
122 if (wlan_cfgGetInt(pMac, WNI_CFG_SHARED_KEY_AUTH_ENABLE,
123 &algoEnable) != eSIR_SUCCESS)
124 {
125 /**
126 * Could not get AuthAlgo2 Enable value
127 * from CFG. Log error.
128 */
129 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700130 FL("could not retrieve AuthAlgo2 Enable value"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700131
132 return false;
133 }
134
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
136 {
137 privacyOptImp = psessionEntry->privacy;
138 }
139 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700140
141 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
142 &privacyOptImp) != eSIR_SUCCESS)
143 {
144 /**
145 * Could not get PrivacyOptionImplemented value
146 * from CFG. Log error.
147 */
148 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700149 FL("could not retrieve PrivacyOptImplemented value"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700150
151 return false;
152 }
153 return (algoEnable && privacyOptImp);
154 }
155} /****** end limIsAuthAlgoSupported() ******/
156
157
158
159/**
160 * limInitPreAuthList
161 *
162 *FUNCTION:
163 * This function is called while starting a BSS at AP
164 * to initialize MAC authenticated STA list. This may also be called
165 * while joining/starting an IBSS if MAC authentication is allowed
166 * in IBSS mode.
167 *
168 *LOGIC:
169 *
170 *ASSUMPTIONS:
171 *
172 *NOTE:
173 *
174 * @param pMac - Pointer to Global MAC structure
175 * @return None
176 */
177
178void
179limInitPreAuthList(tpAniSirGlobal pMac)
180{
181 pMac->lim.pLimPreAuthList = NULL;
182
Jeff Johnson295189b2012-06-20 16:38:30 -0700183} /*** end limInitPreAuthList() ***/
184
185
186
187/**
188 * limDeletePreAuthList
189 *
190 *FUNCTION:
191 * This function is called cleanup Pre-auth list either on
192 * AP or on STA when moving from one persona to other.
193 *
194 *LOGIC:
195 *
196 *ASSUMPTIONS:
197 *
198 *NOTE:
199 *
200 * @param pMac - Pointer to Global MAC structure
201 * @return None
202 */
203
204void
205limDeletePreAuthList(tpAniSirGlobal pMac)
206{
207 struct tLimPreAuthNode *pCurrNode, *pTempNode;
208
209 pCurrNode = pTempNode = pMac->lim.pLimPreAuthList;
210 while (pCurrNode != NULL)
211 {
212 pTempNode = pCurrNode->next;
213
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530214 limLog(pMac, LOG1, FL("=====> limDeletePreAuthList "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 limReleasePreAuthNode(pMac, pCurrNode);
216
217 pCurrNode = pTempNode;
218 }
219 pMac->lim.pLimPreAuthList = NULL;
220} /*** end limDeletePreAuthList() ***/
221
222
223
224/**
225 * limSearchPreAuthList
226 *
227 *FUNCTION:
228 * This function is called when Authentication frame is received
229 * by AP (or at a STA in IBSS supporting MAC based authentication)
230 * to search if a STA is in the middle of MAC Authentication
231 * transaction sequence.
232 *
233 *LOGIC:
234 *
235 *ASSUMPTIONS:
236 *
237 *NOTE:
238 *
239 * @param macAddr - MAC address of the STA that sent
240 * Authentication frame.
241 *
242 * @return Pointer to pre-auth node if found, else NULL
243 */
244
245struct tLimPreAuthNode *
246limSearchPreAuthList(tpAniSirGlobal pMac, tSirMacAddr macAddr)
247{
248 struct tLimPreAuthNode *pTempNode = pMac->lim.pLimPreAuthList;
249
250 while (pTempNode != NULL)
251 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530252 if (vos_mem_compare( (tANI_U8 *) macAddr,
253 (tANI_U8 *) &pTempNode->peerMacAddr,
254 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 break;
256
257 pTempNode = pTempNode->next;
258 }
259
260 return pTempNode;
261} /*** end limSearchPreAuthList() ***/
262
263
264
265/**
266 * limAddPreAuthNode
267 *
268 *FUNCTION:
269 * This function is called at AP while sending Authentication
270 * frame2.
271 * This may also be called on a STA in IBSS if MAC authentication is
272 * allowed in IBSS mode.
273 *
274 *LOGIC:
275 * Node is always added to the front of the list
276 *
277 *ASSUMPTIONS:
278 *
279 *NOTE:
280 *
281 * @param pMac - Pointer to Global MAC structure
282 * @param pAuthNode - Pointer to pre-auth node to be added to the list.
283 *
284 * @return None
285 */
286
287void
288limAddPreAuthNode(tpAniSirGlobal pMac, struct tLimPreAuthNode *pAuthNode)
289{
290 pMac->lim.gLimNumPreAuthContexts++;
291
292 pAuthNode->next = pMac->lim.pLimPreAuthList;
293
294 pMac->lim.pLimPreAuthList = pAuthNode;
295} /*** end limAddPreAuthNode() ***/
296
297
298/**
299 * limReleasePreAuthNode
300 *
301 *FUNCTION:
302 * This function is called to realease the accquired
303 * pre auth node from list.
304 *
305 *LOGIC:
306 *
307 *ASSUMPTIONS:
308 *
309 *NOTE:
310 *
311 * @param pMac - Pointer to Global MAC structure
312 * @param pAuthNode - Pointer to Pre Auth node to be released
313 * @return None
314 */
315
316void
317limReleasePreAuthNode(tpAniSirGlobal pMac, tpLimPreAuthNode pAuthNode)
318{
319 pAuthNode->fFree = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -0700320 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, NO_SESSION, eLIM_PRE_AUTH_CLEANUP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 tx_timer_deactivate(&pAuthNode->timer);
322 pMac->lim.gLimNumPreAuthContexts--;
323} /*** end limReleasePreAuthNode() ***/
324
325
326/**
327 * limDeletePreAuthNode
328 *
329 *FUNCTION:
330 * This function is called at AP when a pre-authenticated STA is
331 * Associated/Reassociated or when AuthFrame4 is received after
332 * Auth Response timeout.
333 * This may also be called on a STA in IBSS if MAC authentication and
334 * Association/Reassociation is allowed in IBSS mode.
335 *
336 *LOGIC:
337 *
338 *ASSUMPTIONS:
339 *
340 *NOTE:
341 *
342 * @param pMac - Pointer to Global MAC structure
343 * @param peerMacAddr - MAC address of the STA that need to be deleted
344 * from pre-auth node list.
345 *
346 * @return None
347 */
348
349void
350limDeletePreAuthNode(tpAniSirGlobal pMac, tSirMacAddr macAddr)
351{
352 struct tLimPreAuthNode *pPrevNode, *pTempNode;
353
354 pTempNode = pPrevNode = pMac->lim.pLimPreAuthList;
355
356 if (pTempNode == NULL)
357 return;
358
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530359 if (vos_mem_compare( (tANI_U8 *) macAddr,
360 (tANI_U8 *) &pTempNode->peerMacAddr,
361 sizeof(tSirMacAddr)) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700362 {
363 // First node to be deleted
364
365 pMac->lim.pLimPreAuthList = pTempNode->next;
366
Jeff Johnson295189b2012-06-20 16:38:30 -0700367
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530368 limLog(pMac, LOG1, FL(" first node to delete"));
369 limLog(pMac, LOG1,
370 FL(" Release data entry:%p idx %d peer: " MAC_ADDRESS_STR),
371 pTempNode, pTempNode->authNodeIdx,
372 MAC_ADDR_ARRAY(macAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 limReleasePreAuthNode(pMac, pTempNode);
374
375 return;
376 }
377
378 pTempNode = pTempNode->next;
379
380 while (pTempNode != NULL)
381 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530382 if (vos_mem_compare( (tANI_U8 *) macAddr,
383 (tANI_U8 *) &pTempNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 sizeof(tSirMacAddr)) )
385 {
386 // Found node to be deleted
387
388 pPrevNode->next = pTempNode->next;
389
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530390 limLog(pMac, LOG1, FL(" subsequent node to delete"));
391 limLog(pMac, LOG1,
392 FL("Release data entry: %p id %d peer: "MAC_ADDRESS_STR),
393 pTempNode, pTempNode->authNodeIdx, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 limReleasePreAuthNode(pMac, pTempNode);
395
396 return;
397 }
398
399 pPrevNode = pTempNode;
400 pTempNode = pTempNode->next;
401 }
402
403 // Should not be here
404 // Log error
405 limLog(pMac, LOGP, FL("peer not found in pre-auth list, addr= "));
406 limPrintMacAddr(pMac, macAddr, LOGP);
407
408} /*** end limDeletePreAuthNode() ***/
409
410
Jeff Johnson295189b2012-06-20 16:38:30 -0700411
412
413
414/**
415 * limRestoreFromPreAuthState
416 *
417 *FUNCTION:
418 * This function is called on STA whenever an Authentication
419 * sequence is complete and state prior to auth need to be
420 * restored.
421 *
422 *LOGIC:
423 * MLM_AUTH_CNF is prepared and sent to SME state machine.
424 * In case of restoring from pre-auth:
425 * - Channel Id is programmed at LO/RF synthesizer
426 * - BSSID is programmed at RHP
427 *
428 *ASSUMPTIONS:
429 *
430 *NOTE:
431 *
432 * @param pMac - Pointer to Global MAC structure
433 * @param resultCode - result of authentication attempt
434 * @return None
435 */
436
437void
438limRestoreFromAuthState(tpAniSirGlobal pMac, tSirResultCodes resultCode, tANI_U16 protStatusCode,tpPESession sessionEntry)
439{
440 tSirMacAddr currentBssId;
441 tLimMlmAuthCnf mlmAuthCnf;
442
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530443 vos_mem_copy( (tANI_U8 *) &mlmAuthCnf.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700444 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
445 sizeof(tSirMacAddr));
446 mlmAuthCnf.authType = pMac->lim.gpLimMlmAuthReq->authType;
447 mlmAuthCnf.resultCode = resultCode;
448 mlmAuthCnf.protStatusCode = protStatusCode;
449
450 /* Update PE session ID*/
451 mlmAuthCnf.sessionId = sessionEntry->peSessionId;
452
453 /// Free up buffer allocated
454 /// for pMac->lim.gLimMlmAuthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530455 vos_mem_free(pMac->lim.gpLimMlmAuthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 pMac->lim.gpLimMlmAuthReq = NULL;
457
458 sessionEntry->limMlmState = sessionEntry->limPrevMlmState;
459
Jeff Johnsone7245742012-09-05 17:12:55 -0700460 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, sessionEntry->peSessionId, sessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700461
462
463 // 'Change' timer for future activations
464 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_FAIL_TIMER);
465
466 #if 0
467 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) != eSIR_SUCCESS)
468 {
469 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700470 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 }
472 #endif //TO SUPPORT BT-AMP
473 sirCopyMacAddr(currentBssId,sessionEntry->bssId);
474
475 if (sessionEntry->limSmeState == eLIM_SME_WT_PRE_AUTH_STATE)
476 {
477 pMac->lim.gLimPreAuthChannelNumber = 0;
478 }
479
480 limPostSmeMessage(pMac,
481 LIM_MLM_AUTH_CNF,
482 (tANI_U32 *) &mlmAuthCnf);
483} /*** end limRestoreFromAuthState() ***/
484
485
486
487/**
488 * limLookUpKeyMappings()
489 *
490 *FUNCTION:
491 * This function is called in limProcessAuthFrame() function
492 * to determine if there exists a Key Mapping key for a given
493 * MAC address.
494 *
495 *LOGIC:
496 *
497 *ASSUMPTIONS:
498 * NA
499 *
500 *NOTE:
501 * NA
502 *
503 * @param macAddr MAC address of the peer STA for which existence
504 * of Key Mapping key is to be determined
505 *
506 * @return pKeyMapEntry - Pointer to the keyMapEntry returned by CFG
507 */
508
509tCfgWepKeyEntry *
510limLookUpKeyMappings(tSirMacAddr macAddr)
511{
512 return NULL;
513} /****** end limLookUpKeyMappings() ******/
514
515
516
517/**
518 * limEncryptAuthFrame()
519 *
520 *FUNCTION:
521 * This function is called in limProcessAuthFrame() function
522 * to encrypt Authentication frame3 body.
523 *
524 *LOGIC:
525 *
526 *ASSUMPTIONS:
527 * NA
528 *
529 *NOTE:
530 * NA
531 *
532 * @param pMac Pointer to Global MAC structure
533 * @param keyId key id to used
534 * @param pKey Pointer to the key to be used for encryption
535 * @param pPlainText Pointer to the body to be encrypted
536 * @param pEncrBody Pointer to the encrypted auth frame body
537 * @param keyLength 8 (WEP40) or 16 (WEP104)
538 * @return None
539 */
540
541void
542limEncryptAuthFrame(tpAniSirGlobal pMac, tANI_U8 keyId, tANI_U8 *pKey, tANI_U8 *pPlainText,
543 tANI_U8 *pEncrBody, tANI_U32 keyLength)
544{
545 tANI_U8 seed[LIM_SEED_LENGTH], icv[SIR_MAC_WEP_ICV_LENGTH];
546
547 keyLength += 3;
548
549 // Bytes 0-2 of seed is IV
550 // Read TSF timestamp into seed to get random IV - 1st 3 bytes
551 halGetTxTSFtimer(pMac, (tSirMacTimeStamp *) &seed);
552
553 // Bytes 3-7 of seed is key
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530554 vos_mem_copy((tANI_U8 *) &seed[3], pKey, keyLength - 3);
Jeff Johnson295189b2012-06-20 16:38:30 -0700555
556 // Compute CRC-32 and place them in last 4 bytes of plain text
557 limComputeCrc32(icv, pPlainText, sizeof(tSirMacAuthFrameBody));
558
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530559 vos_mem_copy( pPlainText + sizeof(tSirMacAuthFrameBody),
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 icv, SIR_MAC_WEP_ICV_LENGTH);
561
562 // Run RC4 on plain text with the seed
563 limRC4(pEncrBody + SIR_MAC_WEP_IV_LENGTH,
564 (tANI_U8 *) pPlainText, seed, keyLength,
565 LIM_ENCR_AUTH_BODY_LEN - SIR_MAC_WEP_IV_LENGTH);
566
567 // Prepare IV
568 pEncrBody[0] = seed[0];
569 pEncrBody[1] = seed[1];
570 pEncrBody[2] = seed[2];
571 pEncrBody[3] = keyId << 6;
572} /****** end limEncryptAuthFrame() ******/
573
574
575
576/**
577 * limComputeCrc32()
578 *
579 *FUNCTION:
580 * This function is called to compute CRC-32 on a given source.
581 * Used while encrypting/decrypting Authentication frame 3.
582 *
583 *LOGIC:
584 *
585 *ASSUMPTIONS:
586 * NA
587 *
588 *NOTE:
589 * NA
590 *
591 * @param pDest Destination location for computed CRC
592 * @param pSrc Source location to be CRC computed
593 * @param len Length over which CRC to be computed
594 * @return None
595 */
596
597void
598limComputeCrc32(tANI_U8 *pDest, tANI_U8 * pSrc, tANI_U8 len)
599{
600 tANI_U32 crc;
601 int i;
602
603 crc = 0;
604 crc = ~crc;
605
606 while(len-- > 0)
607 crc = limCrcUpdate(crc, *pSrc++);
608
609 crc = ~crc;
610
611 for (i=0; i < SIR_MAC_WEP_IV_LENGTH; i++)
612 {
613 pDest[i] = (tANI_U8)crc;
614 crc >>= 8;
615 }
616} /****** end limComputeCrc32() ******/
617
618
619
620/**
621 * limRC4()
622 *
623 *FUNCTION:
624 * This function is called to run RC4 algorithm. Called while
625 * encrypting/decrypting Authentication frame 3.
626 *
627 *LOGIC:
628 *
629 *ASSUMPTIONS:
630 * NA
631 *
632 *NOTE:
633 * NA
634 *
635 * @param pDest Destination location for encrypted text
636 * @param pSrc Source location to be encrypted
637 * @param seed Contains seed (IV + key) for PRNG
638 * @param keyLength 8 (WEP40) or 16 (WEP104)
639 * @param frameLen Length of the frame
640 *
641 * @return None
642 */
643
644void
645limRC4(tANI_U8 *pDest, tANI_U8 *pSrc, tANI_U8 *seed, tANI_U32 keyLength, tANI_U16 frameLen)
646{
647 typedef struct
648 {
649 tANI_U8 i, j;
650 tANI_U8 sbox[256];
651 } tRC4Context;
652
653 tRC4Context ctx;
654
655 {
656 tANI_U16 i, j, k;
657
658 //
659 // Initialize sbox using seed
660 //
661
662 ctx.i = ctx.j = 0;
663 for (i=0; i<256; i++)
664 ctx.sbox[i] = (tANI_U8)i;
665
666 j = 0;
667 k = 0;
668 for (i=0; i<256; i++)
669 {
670 tANI_U8 temp;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -0700671 if ( k < LIM_SEED_LENGTH )
672 j = (tANI_U8)(j + ctx.sbox[i] + seed[k]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 temp = ctx.sbox[i];
674 ctx.sbox[i] = ctx.sbox[j];
675 ctx.sbox[j] = temp;
676
677 if (++k >= keyLength)
678 k = 0;
679 }
680 }
681
682 {
683 tANI_U8 i = ctx.i;
684 tANI_U8 j = ctx.j;
685 tANI_U8 len = (tANI_U8) frameLen;
686
687 while (len-- > 0)
688 {
689 tANI_U8 temp1, temp2;
690
691 i = (tANI_U8)(i+1);
692 temp1 = ctx.sbox[i];
693 j = (tANI_U8)(j + temp1);
694
695 ctx.sbox[i] = temp2 = ctx.sbox[j];
696 ctx.sbox[j] = temp1;
697
698 temp1 = (tANI_U8)(temp1 + temp2);
699 temp1 = ctx.sbox[temp1];
700 temp2 = (tANI_U8)(pSrc ? *pSrc++ : 0);
701
702 *pDest++ = (tANI_U8)(temp1 ^ temp2);
703 }
704
705 ctx.i = i;
706 ctx.j = j;
707 }
708} /****** end limRC4() ******/
709
710
711
712/**
713 * limDecryptAuthFrame()
714 *
715 *FUNCTION:
716 * This function is called in limProcessAuthFrame() function
717 * to decrypt received Authentication frame3 body.
718 *
719 *LOGIC:
720 *
721 *ASSUMPTIONS:
722 * NA
723 *
724 *NOTE:
725 * NA
726 *
727 * @param pMac Pointer to Global MAC structure
728 * @param pKey Pointer to the key to be used for decryption
729 * @param pEncrBody Pointer to the body to be decrypted
730 * @param pPlainBody Pointer to the decrypted body
731 * @param keyLength 8 (WEP40) or 16 (WEP104)
732 *
733 * @return Decrypt result - eSIR_SUCCESS for success and
734 * LIM_DECRYPT_ICV_FAIL for ICV mismatch.
735 * If decryption is a success, pBody will
736 * have decrypted auth frame body.
737 */
738
739tANI_U8
740limDecryptAuthFrame(tpAniSirGlobal pMac, tANI_U8 *pKey, tANI_U8 *pEncrBody,
741 tANI_U8 *pPlainBody, tANI_U32 keyLength, tANI_U16 frameLen)
742{
743 tANI_U8 seed[LIM_SEED_LENGTH], icv[SIR_MAC_WEP_ICV_LENGTH];
744 int i;
745 keyLength += 3;
746
747
748 // Bytes 0-2 of seed is received IV
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530749 vos_mem_copy((tANI_U8 *) seed, pEncrBody, SIR_MAC_WEP_IV_LENGTH - 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700750
751 // Bytes 3-7 of seed is key
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530752 vos_mem_copy((tANI_U8 *) &seed[3], pKey, keyLength - 3);
Jeff Johnson295189b2012-06-20 16:38:30 -0700753
754 // Run RC4 on encrypted text with the seed
755 limRC4(pPlainBody,
756 pEncrBody + SIR_MAC_WEP_IV_LENGTH,
757 seed,
758 keyLength,
759 frameLen);
760
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700761 PELOG4(limLog(pMac, LOG4, FL("plainbody is "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG4, pPlainBody, frameLen);)
763
764 // Compute CRC-32 and place them in last 4 bytes of encrypted body
765 limComputeCrc32(icv,
766 (tANI_U8 *) pPlainBody,
767 (tANI_U8) (frameLen - SIR_MAC_WEP_ICV_LENGTH));
768
769 // Compare RX_ICV with computed ICV
770 for (i = 0; i < SIR_MAC_WEP_ICV_LENGTH; i++)
771 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700772 PELOG4(limLog(pMac, LOG4, FL(" computed ICV%d[%x], rxed ICV%d[%x]"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 i, icv[i], i, pPlainBody[frameLen - SIR_MAC_WEP_ICV_LENGTH + i]);)
774 if (icv[i] != pPlainBody[frameLen - SIR_MAC_WEP_ICV_LENGTH + i])
775 return LIM_DECRYPT_ICV_FAIL;
776 }
777
778 return eSIR_SUCCESS;
779} /****** end limDecryptAuthFrame() ******/
780
781/**
782 * limPostSmeSetKeysCnf
783 *
784 * A utility API to send MLM_SETKEYS_CNF to SME
785 */
786void limPostSmeSetKeysCnf( tpAniSirGlobal pMac,
787 tLimMlmSetKeysReq *pMlmSetKeysReq,
788 tLimMlmSetKeysCnf *mlmSetKeysCnf)
789{
790 // Prepare and Send LIM_MLM_SETKEYS_CNF
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530791 vos_mem_copy( (tANI_U8 *) &mlmSetKeysCnf->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 (tANI_U8 *) pMlmSetKeysReq->peerMacAddr,
793 sizeof(tSirMacAddr));
794
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530795 vos_mem_copy( (tANI_U8 *) &mlmSetKeysCnf->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 (tANI_U8 *) pMlmSetKeysReq->peerMacAddr,
797 sizeof(tSirMacAddr));
798
Jeff Johnson295189b2012-06-20 16:38:30 -0700799
800 /// Free up buffer allocated for mlmSetKeysReq
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +0530801 vos_mem_zero(pMlmSetKeysReq, sizeof(tLimMlmSetKeysReq));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530802 vos_mem_free( pMlmSetKeysReq );
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 pMac->lim.gpLimMlmSetKeysReq = NULL;
804
805 limPostSmeMessage( pMac,
806 LIM_MLM_SETKEYS_CNF,
807 (tANI_U32 *) mlmSetKeysCnf );
808}
809
810/**
811 * limPostSmeRemoveKeysCnf
812 *
813 * A utility API to send MLM_REMOVEKEY_CNF to SME
814 */
815void limPostSmeRemoveKeyCnf( tpAniSirGlobal pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -0700816 tpPESession psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
818 tLimMlmRemoveKeyCnf *mlmRemoveKeyCnf)
819{
820 // Prepare and Send LIM_MLM_REMOVEKEYS_CNF
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530821 vos_mem_copy( (tANI_U8 *) &mlmRemoveKeyCnf->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 (tANI_U8 *) pMlmRemoveKeyReq->peerMacAddr,
823 sizeof(tSirMacAddr));
824
825 /// Free up buffer allocated for mlmRemoveKeysReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530826 vos_mem_free( pMlmRemoveKeyReq );
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
828
Jeff Johnsone7245742012-09-05 17:12:55 -0700829 psessionEntry->limMlmState = psessionEntry->limPrevMlmState; //Restore the state.
830 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700831
832 limPostSmeMessage( pMac,
833 LIM_MLM_REMOVEKEY_CNF,
834 (tANI_U32 *) mlmRemoveKeyCnf );
835}
836
837/**
838 * limSendSetBssKeyReq()
839 *
840 *FUNCTION:
841 * This function is called from limProcessMlmSetKeysReq(),
842 * when PE is trying to setup the Group Keys related
843 * to a specified encryption type
844 *
845 *LOGIC:
846 *
847 *ASSUMPTIONS:
848 * NA
849 *
850 *NOTE:
851 * NA
852 *
853 * @param pMac Pointer to Global MAC structure
854 * @param pMlmSetKeysReq Pointer to MLM_SETKEYS_REQ buffer
855 * @return none
856 */
857void limSendSetBssKeyReq( tpAniSirGlobal pMac,
858 tLimMlmSetKeysReq *pMlmSetKeysReq,
859 tpPESession psessionEntry)
860{
861tSirMsgQ msgQ;
862tpSetBssKeyParams pSetBssKeyParams = NULL;
863tLimMlmSetKeysCnf mlmSetKeysCnf;
864tSirRetStatus retCode;
865tANI_U32 val = 0;
866
867 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
868 {
869 limLog( pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700870 FL( "numKeys = %d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS" ), pMlmSetKeysReq->numKeys);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871
872 // Respond to SME with error code
873 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
874 goto end;
875 }
876
877 // Package WDA_SET_BSSKEY_REQ message parameters
878
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530879 pSetBssKeyParams = vos_mem_malloc(sizeof( tSetBssKeyParams ));
880 if ( NULL == pSetBssKeyParams )
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 {
882 limLog( pMac, LOGE,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530883 FL( "Unable to allocate memory during SET_BSSKEY" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700884
885 // Respond to SME with error code
886 mlmSetKeysCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
887 goto end;
888 }
889 else
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530890 vos_mem_set( (void *) pSetBssKeyParams,
891 sizeof( tSetBssKeyParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700892
893 // Update the WDA_SET_BSSKEY_REQ parameters
894 pSetBssKeyParams->bssIdx = psessionEntry->bssIdx;
895 pSetBssKeyParams->encType = pMlmSetKeysReq->edType;
Jeff Johnsone7245742012-09-05 17:12:55 -0700896
Jeff Johnson295189b2012-06-20 16:38:30 -0700897
898 if(eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SINGLE_TID_RC, &val))
899 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700900 limLog( pMac, LOGP, FL( "Unable to read WNI_CFG_SINGLE_TID_RC" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 }
902
903 pSetBssKeyParams->singleTidRc = (tANI_U8)val;
904
905 /* Update PE session Id*/
906 pSetBssKeyParams->sessionId = psessionEntry ->peSessionId;
907
Jeff Johnsone7245742012-09-05 17:12:55 -0700908 if(pMlmSetKeysReq->key[0].keyId &&
909 ((pMlmSetKeysReq->edType == eSIR_ED_WEP40) ||
910 (pMlmSetKeysReq->edType == eSIR_ED_WEP104))
911 )
912 {
913 /* IF the key id is non-zero and encryption type is WEP, Send all the 4
914 * keys to HAL with filling the key at right index in pSetBssKeyParams->key. */
915 pSetBssKeyParams->numKeys = SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530916 vos_mem_copy( (tANI_U8 *) &pSetBssKeyParams->key[pMlmSetKeysReq->key[0].keyId],
917 (tANI_U8 *) &pMlmSetKeysReq->key[0], sizeof(pMlmSetKeysReq->key[0]));
Jeff Johnsone7245742012-09-05 17:12:55 -0700918
919 }
920 else
921 {
922 pSetBssKeyParams->numKeys = pMlmSetKeysReq->numKeys;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530923 vos_mem_copy( (tANI_U8 *) &pSetBssKeyParams->key,
924 (tANI_U8 *) &pMlmSetKeysReq->key,
925 sizeof( tSirKeys ) * pMlmSetKeysReq->numKeys );
Jeff Johnsone7245742012-09-05 17:12:55 -0700926 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700927
928 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
929 msgQ.type = WDA_SET_BSSKEY_REQ;
930 //
931 // FIXME_GEN4
932 // A global counter (dialog token) is required to keep track of
933 // all PE <-> HAL communication(s)
934 //
935 msgQ.reserved = 0;
936 msgQ.bodyptr = pSetBssKeyParams;
937 msgQ.bodyval = 0;
938
939 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700940 FL( "Sending WDA_SET_BSSKEY_REQ..." ));
Jeff Johnsone7245742012-09-05 17:12:55 -0700941 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
943 {
944 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700945 FL("Posting SET_BSSKEY to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 retCode );
947
948 // Respond to SME with LIM_MLM_SETKEYS_CNF
949 mlmSetKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
950 }
951 else
952 return; // Continue after WDA_SET_BSSKEY_RSP...
953
954end:
955 limPostSmeSetKeysCnf( pMac,
956 pMlmSetKeysReq,
957 &mlmSetKeysCnf );
958
959}
960
961/**
962 * @function : limSendSetStaKeyReq()
963 *
964 * @brief : This function is called from limProcessMlmSetKeysReq(),
965 * when PE is trying to setup the Unicast Keys related
966 * to a specified STA with specified encryption type
967 *
968 *LOGIC:
969 *
970 *ASSUMPTIONS:
971 * NA
972 *
973 *NOTE:
974 * NA
975 *
976 * @param pMac Pointer to Global MAC structure
977 * @param pMlmSetKeysReq Pointer to MLM_SETKEYS_REQ buffer
978 * @param staIdx STA index for which the keys are being set
979 * @param defWEPIdx The default WEP key index [0..3]
980 * @return none
981 */
982void limSendSetStaKeyReq( tpAniSirGlobal pMac,
983 tLimMlmSetKeysReq *pMlmSetKeysReq,
984 tANI_U16 staIdx,
985 tANI_U8 defWEPIdx,
986 tpPESession sessionEntry)
987{
988tSirMsgQ msgQ;
989tpSetStaKeyParams pSetStaKeyParams = NULL;
990tLimMlmSetKeysCnf mlmSetKeysCnf;
991tSirRetStatus retCode;
992tANI_U32 val = 0;
993
994 // Package WDA_SET_STAKEY_REQ message parameters
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530995 pSetStaKeyParams = vos_mem_malloc(sizeof( tSetStaKeyParams ));
996 if ( NULL == pSetStaKeyParams )
997 {
998 limLog( pMac, LOGP, FL( "Unable to allocate memory during SET_BSSKEY" ));
999 return;
1000 }
1001 else
1002 vos_mem_set( (void *) pSetStaKeyParams, sizeof( tSetStaKeyParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001003
1004 // Update the WDA_SET_STAKEY_REQ parameters
1005 pSetStaKeyParams->staIdx = staIdx;
1006 pSetStaKeyParams->encType = pMlmSetKeysReq->edType;
1007
1008
1009 if(eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SINGLE_TID_RC, &val))
1010 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001011 limLog( pMac, LOGP, FL( "Unable to read WNI_CFG_SINGLE_TID_RC" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 }
1013
1014 pSetStaKeyParams->singleTidRc = (tANI_U8)val;
1015
1016 /* Update PE session ID*/
1017 pSetStaKeyParams->sessionId = sessionEntry->peSessionId;
1018
1019 /**
1020 * For WEP - defWEPIdx indicates the default WEP
1021 * Key to be used for TX
1022 * For all others, there's just one key that can
1023 * be used and hence it is assumed that
1024 * defWEPIdx = 0 (from the caller)
1025 */
1026
1027 pSetStaKeyParams->defWEPIdx = defWEPIdx;
1028
1029 /** Store the Previous MlmState*/
1030 sessionEntry->limPrevMlmState = sessionEntry->limMlmState;
1031 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1032
1033 if(sessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE && !pMlmSetKeysReq->key[0].unicast) {
1034 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_BCASTKEY_STATE;
1035 msgQ.type = WDA_SET_STA_BCASTKEY_REQ;
1036 }else {
1037 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_KEY_STATE;
1038 msgQ.type = WDA_SET_STAKEY_REQ;
1039 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001040 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, sessionEntry->peSessionId, sessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001041
1042 /**
1043 * In the Case of WEP_DYNAMIC, ED_TKIP and ED_CCMP
1044 * the Key[0] contains the KEY, so just copy that alone,
1045 * for the case of WEP_STATIC the hal gets the key from cfg
1046 */
1047 switch( pMlmSetKeysReq->edType ) {
1048 case eSIR_ED_WEP40:
1049 case eSIR_ED_WEP104:
1050 // FIXME! Is this OK?
1051 if( 0 == pMlmSetKeysReq->numKeys ) {
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 tANI_U32 i;
1053
1054 for(i=0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS ;i++)
1055 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301056 vos_mem_copy( (tANI_U8 *) &pSetStaKeyParams->key[i],
1057 (tANI_U8 *) &pMlmSetKeysReq->key[i], sizeof( tSirKeys ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 pSetStaKeyParams->wepType = eSIR_WEP_STATIC;
1060 sessionEntry->limMlmState = eLIM_MLM_WT_SET_STA_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001061 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, sessionEntry->peSessionId, sessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 }else {
Jeff Johnsone7245742012-09-05 17:12:55 -07001063 /*This case the keys are coming from upper layer so need to fill the
1064 * key at the default wep key index and send to the HAL */
Kaushik, Sushant40e595a2014-05-03 15:58:30 +05301065 if (defWEPIdx >= SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
1066 {
1067 limLog( pMac, LOGE, FL("WEPIdx length %d more than "
1068 "the Max limit, reset to Max"),defWEPIdx);
Mukul Sharmad2b81862014-07-01 21:01:04 +05301069 vos_mem_free (pSetStaKeyParams);
Kaushik, Sushant40e595a2014-05-03 15:58:30 +05301070 return;
1071 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301072 vos_mem_copy((tANI_U8 *) &pSetStaKeyParams->key[defWEPIdx],
Kaushik, Sushant40e595a2014-05-03 15:58:30 +05301073 (tANI_U8 *) &pMlmSetKeysReq->key[0],
1074 sizeof( pMlmSetKeysReq->key[0] ));
Jeff Johnsone7245742012-09-05 17:12:55 -07001075 pMlmSetKeysReq->numKeys = SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
Kaushik, Sushant40e595a2014-05-03 15:58:30 +05301076
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 }
1078 break;
1079 case eSIR_ED_TKIP:
1080 case eSIR_ED_CCMP:
1081#ifdef FEATURE_WLAN_WAPI
1082 case eSIR_ED_WPI:
1083#endif
1084 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301085 vos_mem_copy( (tANI_U8 *) &pSetStaKeyParams->key,
1086 (tANI_U8 *) &pMlmSetKeysReq->key[0], sizeof( tSirKeys ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 }
1088 break;
1089 default:
1090 break;
1091 }
1092
1093
1094 //
1095 // FIXME_GEN4
1096 // A global counter (dialog token) is required to keep track of
1097 // all PE <-> HAL communication(s)
1098 //
1099 msgQ.reserved = 0;
1100 msgQ.bodyptr = pSetStaKeyParams;
1101 msgQ.bodyval = 0;
1102
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001103 limLog( pMac, LOG1, FL( "Sending WDA_SET_STAKEY_REQ..." ));
Jeff Johnsone7245742012-09-05 17:12:55 -07001104 MTRACE(macTraceMsgTx(pMac, sessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ ))) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001106 limLog( pMac, LOGE, FL("Posting SET_STAKEY to HAL failed, reason=%X"), retCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 // Respond to SME with LIM_MLM_SETKEYS_CNF
1108 mlmSetKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1109 }else
1110 return; // Continue after WDA_SET_STAKEY_RSP...
1111
1112 limPostSmeSetKeysCnf( pMac, pMlmSetKeysReq, &mlmSetKeysCnf );
1113}
1114
1115/**
1116 * limSendRemoveBssKeyReq()
1117 *
1118 *FUNCTION:
1119 * This function is called from limProcessMlmRemoveReq(),
1120 * when PE is trying to Remove a Group Key related
1121 * to a specified encryption type
1122 *
1123 *LOGIC:
1124 *
1125 *ASSUMPTIONS:
1126 * NA
1127 *
1128 *NOTE:
1129 * NA
1130 *
1131 * @param pMac Pointer to Global MAC structure
1132 * @param pMlmRemoveKeyReq Pointer to MLM_REMOVEKEY_REQ buffer
1133 * @return none
1134 */
1135void limSendRemoveBssKeyReq( tpAniSirGlobal pMac,
1136 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
1137 tpPESession psessionEntry)
1138{
1139tSirMsgQ msgQ;
1140tpRemoveBssKeyParams pRemoveBssKeyParams = NULL;
1141tLimMlmRemoveKeyCnf mlmRemoveKeysCnf;
1142tSirRetStatus retCode;
1143
1144 // Package WDA_REMOVE_BSSKEY_REQ message parameters
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301145 pRemoveBssKeyParams = vos_mem_malloc(sizeof( tRemoveBssKeyParams ));
1146 if ( NULL == pRemoveBssKeyParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 {
1148 limLog( pMac, LOGE,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301149 FL( "Unable to allocate memory during REMOVE_BSSKEY" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001150
1151 // Respond to SME with error code
1152 mlmRemoveKeysCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1153 goto end;
1154 }
1155 else
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301156 vos_mem_set( (void *) pRemoveBssKeyParams,
1157 sizeof( tRemoveBssKeyParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001158
1159 // Update the WDA_REMOVE_BSSKEY_REQ parameters
1160 pRemoveBssKeyParams->bssIdx = psessionEntry->bssIdx;
1161 pRemoveBssKeyParams->encType = pMlmRemoveKeyReq->edType;
1162 pRemoveBssKeyParams->keyId = pMlmRemoveKeyReq->keyId;
1163 pRemoveBssKeyParams->wepType = pMlmRemoveKeyReq->wepType;
1164
1165 /* Update PE session Id*/
1166
1167 pRemoveBssKeyParams->sessionId = psessionEntry->peSessionId;
1168
1169 msgQ.type = WDA_REMOVE_BSSKEY_REQ;
1170 //
1171 // FIXME_GEN4
1172 // A global counter (dialog token) is required to keep track of
1173 // all PE <-> HAL communication(s)
1174 //
1175 msgQ.reserved = 0;
1176 msgQ.bodyptr = pRemoveBssKeyParams;
1177 msgQ.bodyval = 0;
1178
1179 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001180 FL( "Sending WDA_REMOVE_BSSKEY_REQ..." ));
Jeff Johnsone7245742012-09-05 17:12:55 -07001181 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001182
1183 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1184 {
1185 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001186 FL("Posting REMOVE_BSSKEY to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 retCode );
1188
1189 // Respond to SME with LIM_MLM_REMOVEKEYS_CNF
1190 mlmRemoveKeysCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1191 }
1192 else
1193 return;
1194
1195end:
1196 limPostSmeRemoveKeyCnf( pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07001197 psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 pMlmRemoveKeyReq,
1199 &mlmRemoveKeysCnf );
1200
1201}
1202
1203/**
1204 * limSendRemoveStaKeyReq()
1205 *
1206 *FUNCTION:
1207 * This function is called from limProcessMlmRemoveKeysReq(),
1208 * when PE is trying to setup the Unicast Keys related
1209 * to a specified STA with specified encryption type
1210 *
1211 *LOGIC:
1212 *
1213 *ASSUMPTIONS:
1214 * NA
1215 *
1216 *NOTE:
1217 * NA
1218 *
1219 * @param pMac Pointer to Global MAC structure
1220 * @param pMlmRemoveKeysReq Pointer to MLM_REMOVEKEYS_REQ buffer
1221 * @param staIdx STA index for which the keys are being set
1222 * @return none
1223 */
1224void limSendRemoveStaKeyReq( tpAniSirGlobal pMac,
1225 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301226 tANI_U16 staIdx,
Jeff Johnsone7245742012-09-05 17:12:55 -07001227 tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07001228{
1229tSirMsgQ msgQ;
1230tpRemoveStaKeyParams pRemoveStaKeyParams = NULL;
1231tLimMlmRemoveKeyCnf mlmRemoveKeyCnf;
1232tSirRetStatus retCode;
1233
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301234 pRemoveStaKeyParams = vos_mem_malloc(sizeof( tRemoveStaKeyParams ));
1235 if ( NULL == pRemoveStaKeyParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07001236 {
1237 limLog( pMac, LOGE,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301238 FL( "Unable to allocate memory during REMOVE_STAKEY" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001239
1240 // Respond to SME with error code
1241 mlmRemoveKeyCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1242 goto end;
1243 }
1244 else
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301245 vos_mem_set( (void *) pRemoveStaKeyParams,
1246 sizeof( tRemoveStaKeyParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001247
1248 if( (pMlmRemoveKeyReq->edType == eSIR_ED_WEP104 || pMlmRemoveKeyReq->edType == eSIR_ED_WEP40) &&
1249 pMlmRemoveKeyReq->wepType == eSIR_WEP_STATIC )
1250 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001251 PELOGE(limLog(pMac, LOGE, FL("Request to remove static WEP keys through station interface\n Should use BSS interface"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1253 goto end;
1254 }
Jeff Johnson2e77e8c2013-04-03 15:10:02 -07001255
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 // Update the WDA_REMOVEKEY_REQ parameters
1257 pRemoveStaKeyParams->staIdx = staIdx;
1258 pRemoveStaKeyParams->encType = pMlmRemoveKeyReq->edType;
1259 pRemoveStaKeyParams->keyId = pMlmRemoveKeyReq->keyId;
1260 pRemoveStaKeyParams->unicast = pMlmRemoveKeyReq->unicast;
1261
1262 /* Update PE session ID*/
Jeff Johnsone7245742012-09-05 17:12:55 -07001263 pRemoveStaKeyParams->sessionId = psessionEntry->peSessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001264
1265 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnson2e77e8c2013-04-03 15:10:02 -07001266
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 msgQ.type = WDA_REMOVE_STAKEY_REQ;
1268 //
1269 // FIXME_GEN4
1270 // A global counter (dialog token) is required to keep track of
1271 // all PE <-> HAL communication(s)
1272 //
1273 msgQ.reserved = 0;
1274 msgQ.bodyptr = pRemoveStaKeyParams;
1275 msgQ.bodyval = 0;
1276
1277 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001278 FL( "Sending WDA_REMOVE_STAKEY_REQ..." ));
Jeff Johnsone7245742012-09-05 17:12:55 -07001279 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson2e77e8c2013-04-03 15:10:02 -07001280 retCode = wdaPostCtrlMsg( pMac, &msgQ );
1281 if (eSIR_SUCCESS != retCode)
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 {
1283 limLog( pMac, LOGE,
Jeff Johnson2e77e8c2013-04-03 15:10:02 -07001284 FL("Posting REMOVE_STAKEY to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 retCode );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301286 vos_mem_free(pRemoveStaKeyParams);
Kiran Kumar Lokerefdf42412013-07-17 17:40:58 -07001287 pRemoveStaKeyParams = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001288
1289 // Respond to SME with LIM_MLM_REMOVEKEY_CNF
1290 mlmRemoveKeyCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1291 }
1292 else
Jeff Johnson2e77e8c2013-04-03 15:10:02 -07001293 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001294
1295end:
Kiran Kumar Lokerefdf42412013-07-17 17:40:58 -07001296 if (pRemoveStaKeyParams)
1297 {
Kiet Lam842c3e12013-11-16 22:40:57 +05301298 vos_mem_free(pRemoveStaKeyParams);
Kiran Kumar Lokerefdf42412013-07-17 17:40:58 -07001299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 limPostSmeRemoveKeyCnf( pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07001301 psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 pMlmRemoveKeyReq,
1303 &mlmRemoveKeyCnf );
1304
1305}
1306
1307