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