Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [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. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * |
| 24 | * Airgo Networks, Inc proprietary. All rights reserved. |
| 25 | * This file limProcessAuthFrame.cc contains the code |
| 26 | * for processing received Authentication Frame. |
| 27 | * Author: Chandra Modumudi |
| 28 | * Date: 03/11/02 |
| 29 | * History:- |
| 30 | * Date Modified by Modification Information |
| 31 | * -------------------------------------------------------------------- |
| 32 | * 05/12/2010 js To support Shared key authentication at AP side |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | #include "wniApi.h" |
| 37 | #ifdef FEATURE_WLAN_NON_INTEGRATED_SOC |
| 38 | #include "halDataStruct.h" |
| 39 | #endif |
| 40 | #if (WNI_POLARIS_FW_PRODUCT == AP) |
| 41 | #include "wniCfgAp.h" |
| 42 | #else |
| 43 | #include "wniCfgSta.h" |
| 44 | #endif |
| 45 | #include "aniGlobal.h" |
| 46 | #include "cfgApi.h" |
| 47 | |
| 48 | #include "utilsApi.h" |
| 49 | #include "limUtils.h" |
| 50 | #include "limAssocUtils.h" |
| 51 | #include "limSecurityUtils.h" |
| 52 | #include "limSerDesUtils.h" |
| 53 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 54 | #include "limFT.h" |
| 55 | #endif |
| 56 | #include "vos_utils.h" |
| 57 | |
| 58 | |
| 59 | /** |
| 60 | * isAuthValid |
| 61 | * |
| 62 | *FUNCTION: |
| 63 | * This function is called by limProcessAuthFrame() upon Authentication |
| 64 | * frame reception. |
| 65 | * |
| 66 | *LOGIC: |
| 67 | * This function is used to test validity of auth frame: |
| 68 | * - AUTH1 and AUTH3 must be received in AP mode |
| 69 | * - AUTH2 and AUTH4 must be received in STA mode |
| 70 | * - AUTH3 and AUTH4 must have challenge text IE, that is,'type' field has been set to |
| 71 | * SIR_MAC_CHALLENGE_TEXT_EID by parser |
| 72 | * - |
| 73 | * |
| 74 | *ASSUMPTIONS: |
| 75 | * |
| 76 | *NOTE: |
| 77 | * |
| 78 | * @param *auth - Pointer to extracted auth frame body |
| 79 | * |
| 80 | * @return 0 or 1 (Valid) |
| 81 | */ |
| 82 | |
| 83 | |
| 84 | static inline unsigned int isAuthValid(tpAniSirGlobal pMac, tpSirMacAuthFrameBody auth,tpPESession sessionEntry) { |
| 85 | unsigned int valid; |
| 86 | valid=1; |
| 87 | |
| 88 | if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_1)|| |
| 89 | (auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)) && |
| 90 | ((sessionEntry->limSystemRole == eLIM_STA_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))) |
| 91 | valid=0; |
| 92 | |
| 93 | if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_2)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&& |
| 94 | ((sessionEntry->limSystemRole == eLIM_AP_ROLE)||(sessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))) |
| 95 | valid=0; |
| 96 | |
| 97 | if ( ((auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_3)||(auth->authTransactionSeqNumber==SIR_MAC_AUTH_FRAME_4))&& |
| 98 | (auth->type!=SIR_MAC_CHALLENGE_TEXT_EID)&&(auth->authAlgoNumber != eSIR_SHARED_KEY)) |
| 99 | valid=0; |
| 100 | |
| 101 | return valid; |
| 102 | } |
| 103 | |
| 104 | |
| 105 | /** |
| 106 | * limProcessAuthFrame |
| 107 | * |
| 108 | *FUNCTION: |
| 109 | * This function is called by limProcessMessageQueue() upon Authentication |
| 110 | * frame reception. |
| 111 | * |
| 112 | *LOGIC: |
| 113 | * This function processes received Authentication frame and responds |
| 114 | * with either next Authentication frame in sequence to peer MAC entity |
| 115 | * or LIM_MLM_AUTH_IND on AP or LIM_MLM_AUTH_CNF on STA. |
| 116 | * |
| 117 | *ASSUMPTIONS: |
| 118 | * |
| 119 | *NOTE: |
| 120 | * 1. Authentication failures are reported to SME with same status code |
| 121 | * received from the peer MAC entity. |
| 122 | * 2. Authentication frame2/4 received with alogirthm number other than |
| 123 | * one requested in frame1/3 are logged with an error and auth confirm |
| 124 | * will be sent to SME only after auth failure timeout. |
| 125 | * 3. Inconsistency in the spec: |
| 126 | * On receiving Auth frame2, specs says that if WEP key mapping key |
| 127 | * or default key is NULL, Auth frame3 with a status code 15 (challenge |
| 128 | * failure to be returned to peer entity. However, section 7.2.3.10, |
| 129 | * table 14 says that status code field is 'reserved' for frame3 ! |
| 130 | * In the current implementation, Auth frame3 is returned with status |
| 131 | * code 15 overriding section 7.2.3.10. |
| 132 | * 4. If number pre-authentications reach configrable max limit, |
| 133 | * Authentication frame with 'unspecified failure' status code is |
| 134 | * returned to requesting entity. |
| 135 | * |
| 136 | * @param pMac - Pointer to Global MAC structure |
| 137 | * @param *pRxPacketInfo - A pointer to Rx packet info structure |
| 138 | * @return None |
| 139 | */ |
| 140 | |
| 141 | void |
| 142 | limProcessAuthFrame(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tpPESession psessionEntry) |
| 143 | { |
| 144 | tANI_U8 *pBody, keyId, cfgPrivacyOptImp, |
| 145 | defaultKey[SIR_MAC_KEY_LENGTH], |
| 146 | encrAuthFrame[LIM_ENCR_AUTH_BODY_LEN], |
| 147 | plainBody[256]; |
| 148 | tANI_U16 frameLen; |
| 149 | //tANI_U32 authRspTimeout, maxNumPreAuth, val; |
| 150 | tANI_U32 maxNumPreAuth, val; |
| 151 | tSirMacAuthFrameBody *pRxAuthFrameBody, rxAuthFrame, authFrame; |
| 152 | tpSirMacMgmtHdr pHdr; |
| 153 | tCfgWepKeyEntry *pKeyMapEntry = NULL; |
| 154 | struct tLimPreAuthNode *pAuthNode; |
| 155 | tLimMlmAuthInd mlmAuthInd; |
| 156 | tANI_U8 decryptResult; |
| 157 | tANI_U8 *pChallenge; |
| 158 | tANI_U32 key_length=8; |
| 159 | tANI_U8 challengeTextArray[SIR_MAC_AUTH_CHALLENGE_LENGTH]; |
| 160 | #ifdef WLAN_SOFTAP_FEATURE |
| 161 | tpDphHashNode pStaDs = NULL; |
| 162 | tANI_U16 assocId = 0; |
| 163 | #endif |
| 164 | /* Added For BT -AMP support */ |
| 165 | // Get pointer to Authentication frame header and body |
| 166 | |
| 167 | |
| 168 | pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo); |
| 169 | frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo); |
| 170 | |
| 171 | |
| 172 | if (!frameLen) |
| 173 | { |
| 174 | // Log error |
| 175 | limLog(pMac, LOGE, |
| 176 | FL("received Authentication frame with no body from ")); |
| 177 | limPrintMacAddr(pMac, pHdr->sa, LOGE); |
| 178 | |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | if (limIsGroupAddr(pHdr->sa)) |
| 183 | { |
| 184 | // Received Auth frame from a BC/MC address |
| 185 | // Log error and ignore it |
| 186 | PELOG1(limLog(pMac, LOG1, |
| 187 | FL("received Auth frame from a BC/MC address - "));) |
| 188 | PELOG1( limPrintMacAddr(pMac, pHdr->sa, LOG1);) |
| 189 | |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo); |
| 194 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 195 | //PELOG3(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG3, (tANI_U8*)pBd, ((tpHalBufDesc) pBd)->mpduDataOffset + frameLen);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 196 | |
| 197 | |
| 198 | |
| 199 | /// Determine if WEP bit is set in the FC or received MAC header |
| 200 | if (pHdr->fc.wep) |
| 201 | { |
| 202 | /** |
| 203 | * WEP bit is set in FC of MAC header. |
| 204 | */ |
| 205 | |
| 206 | #ifdef WLAN_SOFTAP_FEATURE |
| 207 | // If TKIP counter measures enabled issue Deauth frame to station |
| 208 | if ((psessionEntry->bTkipCntrMeasActive) && (psessionEntry->limSystemRole == eLIM_AP_ROLE)) |
| 209 | { |
| 210 | PELOGE( limLog(pMac, LOGE, |
| 211 | FL("Tkip counter measures Enabled, sending Deauth frame to")); ) |
| 212 | limPrintMacAddr(pMac, pHdr->sa, LOGE); |
| 213 | |
| 214 | limSendDeauthMgmtFrame( pMac, eSIR_MAC_MIC_FAILURE_REASON, |
| 215 | pHdr->sa, psessionEntry ); |
| 216 | return; |
| 217 | } |
| 218 | #endif |
| 219 | |
| 220 | // Extract key ID from IV (most 2 bits of 4th byte of IV) |
| 221 | |
| 222 | keyId = (*(pBody + 3)) >> 6; |
| 223 | |
| 224 | /** |
| 225 | * On STA in infrastructure BSS, Authentication frames received |
| 226 | * with WEP bit set in the FC must be rejected with challenge |
| 227 | * failure status code (wierd thing in the spec - this should have |
| 228 | * been rejected with unspecified failure or unexpected assertion |
| 229 | * of wep bit (this status code does not exist though) or |
| 230 | * Out-of-sequence-Authentication-Frame status code. |
| 231 | */ |
| 232 | |
| 233 | if (psessionEntry->limSystemRole == eLIM_STA_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) |
| 234 | { |
| 235 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 236 | authFrame.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4; |
| 237 | authFrame.authStatusCode = eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 238 | |
| 239 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 240 | pHdr->sa, |
| 241 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 242 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 243 | PELOGE(limLog(pMac, LOGE, |
| 244 | FL("received Authentication frame with wep bit set on role=%d "MAC_ADDRESS_STR), |
| 245 | psessionEntry->limSystemRole, MAC_ADDR_ARRAY(pHdr->sa) );) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 246 | |
| 247 | return; |
| 248 | } |
| 249 | |
| 250 | if (frameLen < LIM_ENCR_AUTH_BODY_LEN) |
| 251 | { |
| 252 | // Log error |
| 253 | limLog(pMac, LOGE, |
| 254 | FL("Not enough size [%d] to decrypt received Auth frame"), |
| 255 | frameLen); |
| 256 | limPrintMacAddr(pMac, pHdr->sa, LOGE); |
| 257 | |
| 258 | return; |
| 259 | } |
| 260 | #ifdef WLAN_SOFTAP_FEATURE |
| 261 | if(psessionEntry->limSystemRole == eLIM_AP_ROLE) |
| 262 | { |
| 263 | val = psessionEntry->privacy; |
| 264 | } |
| 265 | else |
| 266 | #endif |
| 267 | // Accept Authentication frame only if Privacy is implemented |
| 268 | if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED, |
| 269 | &val) != eSIR_SUCCESS) |
| 270 | { |
| 271 | /** |
| 272 | * Could not get Privacy option |
| 273 | * from CFG. Log error. |
| 274 | */ |
| 275 | limLog(pMac, LOGP, FL("could not retrieve Privacy option\n")); |
| 276 | } |
| 277 | |
| 278 | cfgPrivacyOptImp = (tANI_U8)val; |
| 279 | if (cfgPrivacyOptImp) |
| 280 | { |
| 281 | /** |
| 282 | * Privacy option is implemented. |
| 283 | * Check if the received frame is Authentication |
| 284 | * frame3 and there is a context for requesting STA. |
| 285 | * If not, reject with unspecified failure status code |
| 286 | */ |
| 287 | pAuthNode = limSearchPreAuthList(pMac, pHdr->sa); |
| 288 | |
| 289 | if (pAuthNode == NULL) |
| 290 | { |
| 291 | /** |
| 292 | * No 'pre-auth' context exists for this STA that sent |
| 293 | * an Authentication frame with FC bit set. |
| 294 | * Send Auth frame4 with 'out of sequence' status code. |
| 295 | */ |
| 296 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 297 | authFrame.authTransactionSeqNumber = |
| 298 | SIR_MAC_AUTH_FRAME_4; |
| 299 | authFrame.authStatusCode = |
| 300 | eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS; |
| 301 | |
| 302 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 303 | pHdr->sa, |
| 304 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 305 | |
| 306 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 307 | PELOGE(limLog(pMac, LOGE, |
| 308 | FL("received Authentication frame from peer that has " |
| 309 | "no preauth context with WEP bit set "MAC_ADDRESS_STR), |
| 310 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 311 | |
| 312 | return; |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | /// Change the auth-response timeout |
| 317 | limDeactivateAndChangePerStaIdTimer(pMac, |
| 318 | eLIM_AUTH_RSP_TIMER, |
| 319 | pAuthNode->authNodeIdx); |
| 320 | |
| 321 | /// 'Pre-auth' status exists for STA |
| 322 | if ((pAuthNode->mlmState != |
| 323 | eLIM_MLM_WT_AUTH_FRAME3_STATE) && |
| 324 | (pAuthNode->mlmState != |
| 325 | eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)) |
| 326 | { |
| 327 | /** |
| 328 | * Should not have received Authentication frame |
| 329 | * with WEP bit set in FC in other states. |
| 330 | * Reject by sending Authenticaton frame with |
| 331 | * out of sequence Auth frame status code. |
| 332 | */ |
| 333 | |
| 334 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 335 | authFrame.authTransactionSeqNumber = |
| 336 | SIR_MAC_AUTH_FRAME_4; |
| 337 | authFrame.authStatusCode = |
| 338 | eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS; |
| 339 | |
| 340 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 341 | pHdr->sa, |
| 342 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 343 | |
| 344 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 345 | PELOGE(limLog(pMac, LOGE, |
| 346 | FL("received Authentication frame from peer that is in state %d " |
| 347 | MAC_ADDRESS_STR), pAuthNode->mlmState, MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 348 | |
| 349 | return; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * Check if there exists a key mappping key |
| 355 | * for the STA that sent Authentication frame |
| 356 | */ |
| 357 | pKeyMapEntry = limLookUpKeyMappings(pHdr->sa); |
| 358 | |
| 359 | if (pKeyMapEntry) |
| 360 | { |
| 361 | if (!pKeyMapEntry->wepOn) |
| 362 | { |
| 363 | /** |
| 364 | * Key Mapping entry has null key. |
| 365 | * Send Authentication frame |
| 366 | * with challenge failure status code |
| 367 | */ |
| 368 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 369 | authFrame.authTransactionSeqNumber = |
| 370 | SIR_MAC_AUTH_FRAME_4; |
| 371 | authFrame.authStatusCode = |
| 372 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 373 | |
| 374 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 375 | pHdr->sa, |
| 376 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 377 | |
| 378 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 379 | PELOGE(limLog(pMac, LOGE, |
| 380 | FL("received Auth frame3 from peer that has NULL key map entry " |
| 381 | MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 382 | |
| 383 | return; |
| 384 | } // if (!pKeyMapEntry->wepOn) |
| 385 | else |
| 386 | { |
| 387 | decryptResult = limDecryptAuthFrame(pMac, pKeyMapEntry->key, |
| 388 | pBody, |
| 389 | plainBody, |
| 390 | key_length, |
| 391 | (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH)); |
| 392 | if (decryptResult == LIM_DECRYPT_ICV_FAIL) |
| 393 | { |
| 394 | /// ICV failure |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 395 | PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == LIM_DECRYPT_ICV_FAIL ..."));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 396 | limDeletePreAuthNode(pMac, |
| 397 | pHdr->sa); |
| 398 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 399 | authFrame.authTransactionSeqNumber = |
| 400 | SIR_MAC_AUTH_FRAME_4; |
| 401 | authFrame.authStatusCode = |
| 402 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 403 | |
| 404 | limSendAuthMgmtFrame( |
| 405 | pMac, &authFrame, |
| 406 | pHdr->sa, |
| 407 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 408 | |
| 409 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 410 | PELOGE(limLog(pMac, LOGE, |
| 411 | FL("received Authentication frame from peer that failed decryption, Addr " |
| 412 | MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 413 | |
| 414 | return; |
| 415 | } |
| 416 | |
| 417 | if ((sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8, &rxAuthFrame)!=eSIR_SUCCESS)||(!isAuthValid(pMac, &rxAuthFrame,psessionEntry))) |
| 418 | return; |
| 419 | |
| 420 | |
| 421 | } // end if (pKeyMapEntry->key == NULL) |
| 422 | } // if keyMappings has entry |
| 423 | else |
| 424 | { |
| 425 | |
| 426 | val = SIR_MAC_KEY_LENGTH; |
| 427 | |
| 428 | #ifdef WLAN_SOFTAP_FEATURE |
| 429 | if(psessionEntry->limSystemRole == eLIM_AP_ROLE) |
| 430 | { |
| 431 | tpSirKeys pKey; |
| 432 | pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0]; |
| 433 | palCopyMemory( pMac->hHdd, defaultKey, pKey->key, pKey->keyLength); |
| 434 | val = pKey->keyLength; |
| 435 | } |
| 436 | else |
| 437 | #endif |
| 438 | if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId), |
| 439 | defaultKey, &val) != eSIR_SUCCESS) |
| 440 | { |
| 441 | /// Could not get Default key from CFG. |
| 442 | //Log error. |
| 443 | limLog(pMac, LOGP, |
| 444 | FL("could not retrieve Default key\n")); |
| 445 | |
| 446 | /** |
| 447 | * Send Authentication frame |
| 448 | * with challenge failure status code |
| 449 | */ |
| 450 | |
| 451 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 452 | authFrame.authTransactionSeqNumber = |
| 453 | SIR_MAC_AUTH_FRAME_4; |
| 454 | authFrame.authStatusCode = |
| 455 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 456 | |
| 457 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 458 | pHdr->sa, |
| 459 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 460 | |
| 461 | return; |
| 462 | } |
| 463 | |
| 464 | key_length=val; |
| 465 | |
| 466 | decryptResult = limDecryptAuthFrame(pMac, defaultKey, |
| 467 | pBody, |
| 468 | plainBody, |
| 469 | key_length, |
| 470 | (tANI_U16) (frameLen-SIR_MAC_WEP_IV_LENGTH)); |
| 471 | if (decryptResult == LIM_DECRYPT_ICV_FAIL) |
| 472 | { |
| 473 | PELOGW(limLog(pMac, LOGW, FL("=====> decryptResult == LIM_DECRYPT_ICV_FAIL ...\n"));) |
| 474 | /// ICV failure |
| 475 | limDeletePreAuthNode(pMac, |
| 476 | pHdr->sa); |
| 477 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 478 | authFrame.authTransactionSeqNumber = |
| 479 | SIR_MAC_AUTH_FRAME_4; |
| 480 | authFrame.authStatusCode = |
| 481 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 482 | |
| 483 | limSendAuthMgmtFrame( |
| 484 | pMac, &authFrame, |
| 485 | pHdr->sa, |
| 486 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 487 | |
| 488 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 489 | PELOGE(limLog(pMac, LOGE, |
| 490 | FL("received Authentication frame from peer that failed decryption: " |
| 491 | MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 492 | |
| 493 | return; |
| 494 | } |
| 495 | if ((sirConvertAuthFrame2Struct(pMac, plainBody, frameLen-8, &rxAuthFrame)!=eSIR_SUCCESS)||(!isAuthValid(pMac, &rxAuthFrame,psessionEntry))) |
| 496 | return; |
| 497 | |
| 498 | } // End of check for Key Mapping/Default key presence |
| 499 | } |
| 500 | else |
| 501 | { |
| 502 | /** |
| 503 | * Privacy option is not implemented. |
| 504 | * So reject Authentication frame received with |
| 505 | * WEP bit set by sending Authentication frame |
| 506 | * with 'challenge failure' status code. This is |
| 507 | * another strange thing in the spec. Status code |
| 508 | * should have been 'unsupported algorithm' status code. |
| 509 | */ |
| 510 | |
| 511 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 512 | authFrame.authTransactionSeqNumber = |
| 513 | SIR_MAC_AUTH_FRAME_4; |
| 514 | authFrame.authStatusCode = |
| 515 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 516 | |
| 517 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 518 | pHdr->sa, |
| 519 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 520 | |
| 521 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 522 | PELOGE(limLog(pMac, LOGE, |
| 523 | FL("received Authentication frame3 from peer that while privacy option is turned OFF " |
| 524 | MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 525 | |
| 526 | return; |
| 527 | } // else if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED)) |
| 528 | } // if (fc.wep) |
| 529 | else |
| 530 | { |
| 531 | |
| 532 | |
| 533 | if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame)!=eSIR_SUCCESS)||(!isAuthValid(pMac, &rxAuthFrame,psessionEntry))) |
| 534 | return; |
| 535 | } |
| 536 | |
| 537 | |
| 538 | pRxAuthFrameBody = &rxAuthFrame; |
| 539 | |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 540 | PELOGW(limLog(pMac, LOGW, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 541 | FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)\n"), |
| 542 | (tANI_U32) pRxAuthFrameBody->authAlgoNumber, |
| 543 | (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber, |
| 544 | (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);) |
| 545 | |
| 546 | switch (pRxAuthFrameBody->authTransactionSeqNumber) |
| 547 | { |
| 548 | case SIR_MAC_AUTH_FRAME_1: |
| 549 | // AuthFrame 1 |
| 550 | |
| 551 | /// Check if there exists pre-auth context for this STA |
| 552 | pAuthNode = limSearchPreAuthList(pMac, pHdr->sa); |
| 553 | if (pAuthNode) |
| 554 | { |
| 555 | /// Pre-auth context exists for the STA |
| 556 | if (pHdr->fc.retry == 0) |
| 557 | { |
| 558 | /** |
| 559 | * STA is initiating brand-new Authentication |
| 560 | * sequence after local Auth Response timeout. |
| 561 | * Or STA retrying to transmit First Auth frame due to packet drop OTA |
| 562 | * Delete Pre-auth node and fall through. |
| 563 | */ |
| 564 | if(pAuthNode->fTimerStarted) |
| 565 | { |
| 566 | limDeactivateAndChangePerStaIdTimer(pMac, |
| 567 | eLIM_AUTH_RSP_TIMER, |
| 568 | pAuthNode->authNodeIdx); |
| 569 | } |
| 570 | PELOGE(limLog(pMac, LOGE, FL("STA is initiating brand-new Authentication ...\n"));) |
| 571 | limDeletePreAuthNode(pMac, |
| 572 | pHdr->sa); |
| 573 | #ifdef WLAN_SOFTAP_FEATURE |
| 574 | /** |
| 575 | * SAP Mode:Disassociate the station and |
| 576 | * delete its entry if we have its entry |
| 577 | * already and received "auth" from the |
| 578 | * same station. |
| 579 | */ |
| 580 | |
| 581 | for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8 |
| 582 | { |
| 583 | pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable); |
| 584 | |
| 585 | if (NULL == pStaDs) |
| 586 | continue; |
| 587 | |
| 588 | if (pStaDs->valid) |
| 589 | { |
| 590 | if (palEqualMemory( pMac->hHdd,(tANI_U8 *) &pStaDs->staAddr, |
| 591 | (tANI_U8 *) &(pHdr->sa), (tANI_U8) (sizeof(tSirMacAddr))) ) |
| 592 | break; |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | if (NULL != pStaDs) |
| 597 | { |
| 598 | PELOGE(limLog(pMac, LOGE, FL("lim Delete Station Context (staId: %d, assocId: %d) \n"),pStaDs->staIndex, assocId);) |
| 599 | limSendDeauthMgmtFrame(pMac, |
| 600 | eSIR_MAC_UNSPEC_FAILURE_REASON, (tANI_U8 *) pAuthNode->peerMacAddr,psessionEntry); |
| 601 | limTriggerSTAdeletion(pMac, pStaDs, psessionEntry); |
| 602 | return; |
| 603 | } |
| 604 | #endif |
| 605 | } |
| 606 | else |
| 607 | { |
| 608 | /* |
| 609 | * This can happen when first authentication frame is received |
| 610 | * but ACK lost at STA side, in this case 2nd auth frame is already |
| 611 | * in transmission queue |
| 612 | * */ |
| 613 | PELOGE(limLog(pMac, LOGE, FL("STA is initiating Authentication after ACK lost...\n"));) |
| 614 | return; |
| 615 | } |
| 616 | } |
| 617 | if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH, |
| 618 | (tANI_U32 *) &maxNumPreAuth) != eSIR_SUCCESS) |
| 619 | { |
| 620 | /** |
| 621 | * Could not get MaxNumPreAuth |
| 622 | * from CFG. Log error. |
| 623 | */ |
| 624 | limLog(pMac, LOGP, |
| 625 | FL("could not retrieve MaxNumPreAuth\n")); |
| 626 | } |
| 627 | #ifdef ANI_AP_SDK_OPT |
| 628 | if(maxNumPreAuth > SIR_SDK_OPT_MAX_NUM_PRE_AUTH) |
| 629 | maxNumPreAuth = SIR_SDK_OPT_MAX_NUM_PRE_AUTH; |
| 630 | #endif // ANI_AP_SDK_OPT |
| 631 | if (pMac->lim.gLimNumPreAuthContexts == maxNumPreAuth) |
| 632 | { |
| 633 | /** |
| 634 | * Maximum number of pre-auth contexts |
| 635 | * reached. Send Authentication frame |
| 636 | * with unspecified failure |
| 637 | */ |
| 638 | authFrame.authAlgoNumber = |
| 639 | pRxAuthFrameBody->authAlgoNumber; |
| 640 | authFrame.authTransactionSeqNumber = |
| 641 | pRxAuthFrameBody->authTransactionSeqNumber + 1; |
| 642 | authFrame.authStatusCode = |
| 643 | eSIR_MAC_UNSPEC_FAILURE_STATUS; |
| 644 | |
| 645 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 646 | pHdr->sa, |
| 647 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 648 | |
| 649 | return; |
| 650 | } |
| 651 | /// No Pre-auth context exists for the STA. |
| 652 | #ifdef WLAN_SOFTAP_FEATURE |
| 653 | if (limIsAuthAlgoSupported( |
| 654 | pMac, |
| 655 | (tAniAuthType) |
| 656 | pRxAuthFrameBody->authAlgoNumber, psessionEntry)) |
| 657 | #else |
| 658 | if (limIsAuthAlgoSupported( |
| 659 | pMac, |
| 660 | (tAniAuthType) |
| 661 | pRxAuthFrameBody->authAlgoNumber)) |
| 662 | |
| 663 | #endif |
| 664 | { |
| 665 | switch (pRxAuthFrameBody->authAlgoNumber) |
| 666 | { |
| 667 | case eSIR_OPEN_SYSTEM: |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 668 | PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_OPEN_SYSTEM ...\n"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 669 | /// Create entry for this STA in pre-auth list |
| 670 | pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable); |
| 671 | if (pAuthNode == NULL) |
| 672 | { |
| 673 | // Log error |
| 674 | limLog(pMac, LOGW, |
| 675 | FL("Max pre-auth nodes reached ")); |
| 676 | limPrintMacAddr(pMac, pHdr->sa, LOGW); |
| 677 | |
| 678 | return; |
| 679 | } |
| 680 | |
| 681 | PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer \n"), pAuthNode); |
| 682 | limPrintMacAddr(pMac, pHdr->sa, LOG1);) |
| 683 | |
| 684 | palCopyMemory( pMac->hHdd, |
| 685 | (tANI_U8 *) pAuthNode->peerMacAddr, |
| 686 | pHdr->sa, |
| 687 | sizeof(tSirMacAddr)); |
| 688 | |
| 689 | pAuthNode->mlmState = |
| 690 | eLIM_MLM_AUTHENTICATED_STATE; |
| 691 | pAuthNode->authType = (tAniAuthType) |
| 692 | pRxAuthFrameBody->authAlgoNumber; |
| 693 | pAuthNode->fSeen = 0; |
| 694 | pAuthNode->fTimerStarted = 0; |
| 695 | limAddPreAuthNode(pMac, pAuthNode); |
| 696 | |
| 697 | /** |
| 698 | * Send Authenticaton frame with Success |
| 699 | * status code. |
| 700 | */ |
| 701 | |
| 702 | authFrame.authAlgoNumber = |
| 703 | pRxAuthFrameBody->authAlgoNumber; |
| 704 | authFrame.authTransactionSeqNumber = |
| 705 | pRxAuthFrameBody->authTransactionSeqNumber + 1; |
| 706 | authFrame.authStatusCode = eSIR_MAC_SUCCESS_STATUS; |
| 707 | limSendAuthMgmtFrame( |
| 708 | pMac, &authFrame, |
| 709 | pHdr->sa, |
| 710 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 711 | |
| 712 | /// Send Auth indication to SME |
| 713 | |
| 714 | palCopyMemory( pMac->hHdd, |
| 715 | (tANI_U8 *) mlmAuthInd.peerMacAddr, |
| 716 | (tANI_U8 *) pHdr->sa, |
| 717 | sizeof(tSirMacAddr)); |
| 718 | mlmAuthInd.authType = (tAniAuthType) |
| 719 | pRxAuthFrameBody->authAlgoNumber; |
| 720 | mlmAuthInd.sessionId = psessionEntry->smeSessionId; |
| 721 | |
| 722 | limPostSmeMessage(pMac, |
| 723 | LIM_MLM_AUTH_IND, |
| 724 | (tANI_U32 *) &mlmAuthInd); |
| 725 | break; |
| 726 | |
| 727 | case eSIR_SHARED_KEY: |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 728 | PELOGW(limLog(pMac, LOGW, FL("=======> eSIR_SHARED_KEY ...\n"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 729 | #ifdef WLAN_SOFTAP_FEATURE |
| 730 | if(psessionEntry->limSystemRole == eLIM_AP_ROLE) |
| 731 | { |
| 732 | val = psessionEntry->privacy; |
| 733 | } |
| 734 | else |
| 735 | #endif |
| 736 | if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED, |
| 737 | &val) != eSIR_SUCCESS) |
| 738 | { |
| 739 | /** |
| 740 | * Could not get Privacy option |
| 741 | * from CFG. Log error. |
| 742 | */ |
| 743 | limLog(pMac, LOGP, |
| 744 | FL("could not retrieve Privacy option\n")); |
| 745 | } |
| 746 | cfgPrivacyOptImp = (tANI_U8)val; |
| 747 | if (!cfgPrivacyOptImp) |
| 748 | { |
| 749 | /** |
| 750 | * Authenticator does not have WEP |
| 751 | * implemented. |
| 752 | * Reject by sending Authentication frame |
| 753 | * with Auth algorithm not supported status |
| 754 | * code. |
| 755 | */ |
| 756 | |
| 757 | authFrame.authAlgoNumber = |
| 758 | pRxAuthFrameBody->authAlgoNumber; |
| 759 | authFrame.authTransactionSeqNumber = |
| 760 | pRxAuthFrameBody->authTransactionSeqNumber + 1; |
| 761 | authFrame.authStatusCode = |
| 762 | eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS; |
| 763 | |
| 764 | limSendAuthMgmtFrame( |
| 765 | pMac, &authFrame, |
| 766 | pHdr->sa, |
| 767 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 768 | |
| 769 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 770 | PELOGE(limLog(pMac, LOGE, |
| 771 | FL("received Auth frame for unsupported auth algorithm %d " |
| 772 | MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber, |
| 773 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 774 | |
| 775 | return; |
| 776 | } |
| 777 | else |
| 778 | { |
| 779 | // Create entry for this STA |
| 780 | //in pre-auth list |
| 781 | pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable); |
| 782 | if (pAuthNode == NULL) |
| 783 | { |
| 784 | // Log error |
| 785 | limLog(pMac, LOGW, |
| 786 | FL("Max pre-auth nodes reached ")); |
| 787 | limPrintMacAddr(pMac, pHdr->sa, LOGW); |
| 788 | |
| 789 | return; |
| 790 | } |
| 791 | |
| 792 | palCopyMemory( pMac->hHdd, |
| 793 | (tANI_U8 *) pAuthNode->peerMacAddr, |
| 794 | pHdr->sa, |
| 795 | sizeof(tSirMacAddr)); |
| 796 | |
| 797 | pAuthNode->mlmState = |
| 798 | eLIM_MLM_WT_AUTH_FRAME3_STATE; |
| 799 | pAuthNode->authType = |
| 800 | (tAniAuthType) |
| 801 | pRxAuthFrameBody->authAlgoNumber; |
| 802 | pAuthNode->fSeen = 0; |
| 803 | pAuthNode->fTimerStarted = 0; |
| 804 | limAddPreAuthNode(pMac, pAuthNode); |
| 805 | |
| 806 | PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x id %d peer \n"), |
| 807 | pAuthNode, pAuthNode->authNodeIdx);) |
| 808 | PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);) |
| 809 | |
| 810 | /// Create and activate Auth Response timer |
| 811 | if (tx_timer_change_context(&pAuthNode->timer, pAuthNode->authNodeIdx) != TX_SUCCESS) |
| 812 | { |
| 813 | /// Could not start Auth response timer. |
| 814 | // Log error |
| 815 | limLog(pMac, LOGP, |
| 816 | FL("Unable to chg context auth response timer for peer ")); |
| 817 | limPrintMacAddr(pMac, pHdr->sa, LOGP); |
| 818 | |
| 819 | /** |
| 820 | * Send Authenticaton frame with |
| 821 | * unspecified failure status code. |
| 822 | */ |
| 823 | |
| 824 | authFrame.authAlgoNumber = |
| 825 | pRxAuthFrameBody->authAlgoNumber; |
| 826 | authFrame.authTransactionSeqNumber = |
| 827 | pRxAuthFrameBody->authTransactionSeqNumber + 1; |
| 828 | authFrame.authStatusCode = |
| 829 | eSIR_MAC_UNSPEC_FAILURE_STATUS; |
| 830 | |
| 831 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 832 | pHdr->sa, |
| 833 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 834 | |
| 835 | limDeletePreAuthNode(pMac, pHdr->sa); |
| 836 | return; |
| 837 | } |
| 838 | |
| 839 | limActivateAuthRspTimer(pMac, pAuthNode); |
| 840 | |
| 841 | pAuthNode->fTimerStarted = 1; |
| 842 | |
| 843 | // get random bytes and use as |
| 844 | // challenge text |
| 845 | // TODO |
| 846 | //if( !VOS_IS_STATUS_SUCCESS( vos_rand_get_bytes( 0, (tANI_U8 *)challengeTextArray, SIR_MAC_AUTH_CHALLENGE_LENGTH ) ) ) |
| 847 | { |
| 848 | limLog(pMac, LOGE,FL("Challenge text preparation failed in limProcessAuthFrame")); |
| 849 | } |
| 850 | |
| 851 | pChallenge = pAuthNode->challengeText; |
| 852 | |
| 853 | palCopyMemory( pMac->hHdd, |
| 854 | pChallenge, |
| 855 | (tANI_U8 *) challengeTextArray, |
| 856 | sizeof(challengeTextArray)); |
| 857 | |
| 858 | /** |
| 859 | * Sending Authenticaton frame with challenge. |
| 860 | */ |
| 861 | |
| 862 | authFrame.authAlgoNumber = |
| 863 | pRxAuthFrameBody->authAlgoNumber; |
| 864 | authFrame.authTransactionSeqNumber = |
| 865 | pRxAuthFrameBody->authTransactionSeqNumber + 1; |
| 866 | authFrame.authStatusCode = |
| 867 | eSIR_MAC_SUCCESS_STATUS; |
| 868 | authFrame.type = SIR_MAC_CHALLENGE_TEXT_EID; |
| 869 | authFrame.length = SIR_MAC_AUTH_CHALLENGE_LENGTH; |
| 870 | palCopyMemory( pMac->hHdd, |
| 871 | authFrame.challengeText, |
| 872 | pAuthNode->challengeText, |
| 873 | SIR_MAC_AUTH_CHALLENGE_LENGTH); |
| 874 | |
| 875 | limSendAuthMgmtFrame( |
| 876 | pMac, &authFrame, |
| 877 | pHdr->sa, |
| 878 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 879 | } // if (wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED)) |
| 880 | |
| 881 | break; |
| 882 | |
| 883 | default: |
| 884 | /** |
| 885 | * Responding party does not support the |
| 886 | * authentication algorithm requested by |
| 887 | * sending party. |
| 888 | * Reject by sending Authentication frame |
| 889 | * with auth algorithm not supported status code |
| 890 | */ |
| 891 | |
| 892 | authFrame.authAlgoNumber = |
| 893 | pRxAuthFrameBody->authAlgoNumber; |
| 894 | authFrame.authTransactionSeqNumber = |
| 895 | pRxAuthFrameBody->authTransactionSeqNumber + 1; |
| 896 | authFrame.authStatusCode = |
| 897 | eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS; |
| 898 | |
| 899 | limSendAuthMgmtFrame( |
| 900 | pMac, &authFrame, |
| 901 | pHdr->sa, |
| 902 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 903 | |
| 904 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 905 | PELOGE( limLog(pMac, LOGE, |
| 906 | FL("received Auth frame for unsupported auth algorithm %d " |
| 907 | MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber, |
| 908 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 909 | |
| 910 | return; |
| 911 | } // end switch(pRxAuthFrameBody->authAlgoNumber) |
| 912 | } // if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber)) |
| 913 | else |
| 914 | { |
| 915 | /** |
| 916 | * Responding party does not support the |
| 917 | * authentication algorithm requested by sending party. |
| 918 | * Reject Authentication with StatusCode=13. |
| 919 | */ |
| 920 | authFrame.authAlgoNumber = |
| 921 | pRxAuthFrameBody->authAlgoNumber; |
| 922 | authFrame.authTransactionSeqNumber = |
| 923 | pRxAuthFrameBody->authTransactionSeqNumber + 1; |
| 924 | authFrame.authStatusCode = |
| 925 | eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS; |
| 926 | |
| 927 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 928 | pHdr->sa, |
| 929 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 930 | |
| 931 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 932 | PELOGE(limLog(pMac, LOGE, |
| 933 | FL("received Authentication frame for unsupported auth algorithm %d " |
| 934 | MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber, |
| 935 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 936 | return; |
| 937 | } //end if (limIsAuthAlgoSupported(pRxAuthFrameBody->authAlgoNumber)) |
| 938 | break; |
| 939 | |
| 940 | case SIR_MAC_AUTH_FRAME_2: |
| 941 | // AuthFrame 2 |
| 942 | |
| 943 | if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME2_STATE) |
| 944 | { |
| 945 | /** |
| 946 | * Received Authentication frame2 in an unexpected state. |
| 947 | * Log error and ignore the frame. |
| 948 | */ |
| 949 | |
| 950 | // Log error |
| 951 | PELOG1(limLog(pMac, LOG1, |
| 952 | FL("received Auth frame2 from peer in state %d, addr "), |
| 953 | psessionEntry->limMlmState);) |
| 954 | PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);) |
| 955 | |
| 956 | return; |
| 957 | } |
| 958 | |
| 959 | if ( !palEqualMemory( pMac->hHdd,(tANI_U8 *) pHdr->sa, |
| 960 | (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr, |
| 961 | sizeof(tSirMacAddr)) ) |
| 962 | { |
| 963 | /** |
| 964 | * Received Authentication frame from an entity |
| 965 | * other than one request was initiated. |
| 966 | * Wait until Authentication Failure Timeout. |
| 967 | */ |
| 968 | |
| 969 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 970 | PELOGW(limLog(pMac, LOGW, |
| 971 | FL("received Auth frame2 from unexpected peer "MAC_ADDRESS_STR), |
| 972 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 973 | |
| 974 | break; |
| 975 | } |
| 976 | |
| 977 | if (pRxAuthFrameBody->authStatusCode == |
| 978 | eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS) |
| 979 | { |
| 980 | /** |
| 981 | * Interoperability workaround: Linksys WAP4400N is returning |
| 982 | * wrong authType in OpenAuth response in case of |
| 983 | * SharedKey AP configuration. Pretend we don't see that, |
| 984 | * so upper layer can fallback to SharedKey authType, |
| 985 | * and successfully connect to the AP. |
| 986 | */ |
| 987 | if (pRxAuthFrameBody->authAlgoNumber != |
| 988 | pMac->lim.gpLimMlmAuthReq->authType) |
| 989 | { |
| 990 | pRxAuthFrameBody->authAlgoNumber = |
| 991 | pMac->lim.gpLimMlmAuthReq->authType; |
| 992 | } |
| 993 | } |
| 994 | |
| 995 | if (pRxAuthFrameBody->authAlgoNumber != |
| 996 | pMac->lim.gpLimMlmAuthReq->authType) |
| 997 | { |
| 998 | /** |
| 999 | * Received Authentication frame with an auth |
| 1000 | * algorithm other than one requested. |
| 1001 | * Wait until Authentication Failure Timeout. |
| 1002 | */ |
| 1003 | |
| 1004 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1005 | PELOGW(limLog(pMac, LOGW, |
| 1006 | FL("received Auth frame2 for unexpected auth algo number %d " |
| 1007 | MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber, |
| 1008 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1009 | |
| 1010 | break; |
| 1011 | } |
| 1012 | |
| 1013 | if (pRxAuthFrameBody->authStatusCode == |
| 1014 | eSIR_MAC_SUCCESS_STATUS) |
| 1015 | { |
| 1016 | if (pRxAuthFrameBody->authAlgoNumber == |
| 1017 | eSIR_OPEN_SYSTEM) |
| 1018 | { |
| 1019 | psessionEntry->limCurrentAuthType = eSIR_OPEN_SYSTEM; |
| 1020 | |
| 1021 | pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable); |
| 1022 | |
| 1023 | if (pAuthNode == NULL) |
| 1024 | { |
| 1025 | // Log error |
| 1026 | limLog(pMac, LOGW, |
| 1027 | FL("Max pre-auth nodes reached ")); |
| 1028 | limPrintMacAddr(pMac, pHdr->sa, LOGW); |
| 1029 | |
| 1030 | return; |
| 1031 | } |
| 1032 | |
| 1033 | PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer \n"), pAuthNode);) |
| 1034 | PELOG1(limPrintMacAddr(pMac, pHdr->sa, LOG1);) |
| 1035 | |
| 1036 | palCopyMemory( pMac->hHdd, |
| 1037 | (tANI_U8 *) pAuthNode->peerMacAddr, |
| 1038 | pMac->lim.gpLimMlmAuthReq->peerMacAddr, |
| 1039 | sizeof(tSirMacAddr)); |
| 1040 | pAuthNode->fTimerStarted = 0; |
| 1041 | pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType; |
| 1042 | limAddPreAuthNode(pMac, pAuthNode); |
| 1043 | |
| 1044 | limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS, |
| 1045 | pRxAuthFrameBody->authStatusCode,psessionEntry); |
| 1046 | } // if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) |
| 1047 | else |
| 1048 | { |
| 1049 | // Shared key authentication |
| 1050 | |
| 1051 | #ifdef WLAN_SOFTAP_FEATURE |
| 1052 | if(psessionEntry->limSystemRole == eLIM_AP_ROLE) |
| 1053 | { |
| 1054 | val = psessionEntry->privacy; |
| 1055 | } |
| 1056 | else |
| 1057 | #endif |
| 1058 | if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED, |
| 1059 | &val) != eSIR_SUCCESS) |
| 1060 | { |
| 1061 | /** |
| 1062 | * Could not get Privacy option |
| 1063 | * from CFG. Log error. |
| 1064 | */ |
| 1065 | limLog(pMac, LOGP, |
| 1066 | FL("could not retrieve Privacy option\n")); |
| 1067 | } |
| 1068 | cfgPrivacyOptImp = (tANI_U8)val; |
| 1069 | if (!cfgPrivacyOptImp) |
| 1070 | { |
| 1071 | /** |
| 1072 | * Requesting STA does not have WEP implemented. |
| 1073 | * Reject with unsupported authentication algorithm |
| 1074 | * Status code and wait until auth failure timeout |
| 1075 | */ |
| 1076 | |
| 1077 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1078 | PELOGE( limLog(pMac, LOGE, |
| 1079 | FL("received Auth frame from peer for unsupported auth algo %d " |
| 1080 | MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber, |
| 1081 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1082 | |
| 1083 | authFrame.authAlgoNumber = |
| 1084 | pRxAuthFrameBody->authAlgoNumber; |
| 1085 | authFrame.authTransactionSeqNumber = |
| 1086 | pRxAuthFrameBody->authTransactionSeqNumber + 1; |
| 1087 | authFrame.authStatusCode = |
| 1088 | eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS; |
| 1089 | |
| 1090 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 1091 | pHdr->sa, |
| 1092 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 1093 | return; |
| 1094 | } |
| 1095 | else |
| 1096 | { |
| 1097 | |
| 1098 | if (pRxAuthFrameBody->type != |
| 1099 | SIR_MAC_CHALLENGE_TEXT_EID) |
| 1100 | { |
| 1101 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1102 | PELOGE(limLog(pMac, LOGE, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1103 | FL("received Auth frame with invalid challenge text IE\n"));) |
| 1104 | |
| 1105 | return; |
| 1106 | } |
| 1107 | |
| 1108 | /** |
| 1109 | * Check if there exists a key mappping key |
| 1110 | * for the STA that sent Authentication frame |
| 1111 | */ |
| 1112 | pKeyMapEntry = limLookUpKeyMappings( |
| 1113 | pHdr->sa); |
| 1114 | |
| 1115 | if (pKeyMapEntry) |
| 1116 | { |
| 1117 | if (pKeyMapEntry->key == NULL) |
| 1118 | { |
| 1119 | /** |
| 1120 | * Key Mapping entry has null key. |
| 1121 | * Send Auth frame with |
| 1122 | * challenge failure status code |
| 1123 | */ |
| 1124 | authFrame.authAlgoNumber = |
| 1125 | pRxAuthFrameBody->authAlgoNumber; |
| 1126 | authFrame.authTransactionSeqNumber = |
| 1127 | pRxAuthFrameBody->authTransactionSeqNumber + 1; |
| 1128 | authFrame.authStatusCode = |
| 1129 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 1130 | |
| 1131 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 1132 | pHdr->sa, |
| 1133 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 1134 | |
| 1135 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1136 | PELOGE(limLog(pMac, LOGE, |
| 1137 | FL("received Auth frame from peer when key mapping key is NULL" |
| 1138 | MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1139 | |
| 1140 | limRestoreFromAuthState(pMac, eSIR_SME_NO_KEY_MAPPING_KEY_FOR_PEER, |
| 1141 | eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry); |
| 1142 | |
| 1143 | return; |
| 1144 | } // if (pKeyMapEntry->key == NULL) |
| 1145 | else |
| 1146 | { |
| 1147 | ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber = |
| 1148 | sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber); |
| 1149 | ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber = |
| 1150 | sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1)); |
| 1151 | ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS; |
| 1152 | ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID; |
| 1153 | ((tpSirMacAuthFrameBody) plainBody)->length = SIR_MAC_AUTH_CHALLENGE_LENGTH; |
| 1154 | palCopyMemory( pMac->hHdd, (tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText, |
| 1155 | pRxAuthFrameBody->challengeText, |
| 1156 | SIR_MAC_AUTH_CHALLENGE_LENGTH); |
| 1157 | |
| 1158 | limEncryptAuthFrame(pMac, 0, |
| 1159 | pKeyMapEntry->key, |
| 1160 | plainBody, |
| 1161 | encrAuthFrame,key_length); |
| 1162 | |
| 1163 | psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1164 | MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1165 | |
| 1166 | limSendAuthMgmtFrame(pMac, |
| 1167 | (tpSirMacAuthFrameBody) encrAuthFrame, |
| 1168 | pHdr->sa, |
| 1169 | LIM_WEP_IN_FC,psessionEntry); |
| 1170 | |
| 1171 | break; |
| 1172 | } // end if (pKeyMapEntry->key == NULL) |
| 1173 | } // if (pKeyMapEntry) |
| 1174 | else |
| 1175 | { |
| 1176 | if (wlan_cfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, |
| 1177 | &val) != eSIR_SUCCESS) |
| 1178 | { |
| 1179 | /** |
| 1180 | * Could not get Default keyId |
| 1181 | * from CFG. Log error. |
| 1182 | */ |
| 1183 | limLog(pMac, LOGP, |
| 1184 | FL("could not retrieve Default keyId\n")); |
| 1185 | } |
| 1186 | keyId = (tANI_U8)val; |
| 1187 | |
| 1188 | val = SIR_MAC_KEY_LENGTH; |
| 1189 | |
| 1190 | #ifdef WLAN_SOFTAP_FEATURE |
| 1191 | if(psessionEntry->limSystemRole == eLIM_AP_ROLE) |
| 1192 | { |
| 1193 | tpSirKeys pKey; |
| 1194 | pKey = &psessionEntry->WEPKeyMaterial[keyId].key[0]; |
| 1195 | palCopyMemory( pMac->hHdd, defaultKey, pKey->key, pKey->keyLength); |
| 1196 | } |
| 1197 | else |
| 1198 | #endif |
| 1199 | if (wlan_cfgGetStr(pMac, (tANI_U16) (WNI_CFG_WEP_DEFAULT_KEY_1 + keyId), |
| 1200 | defaultKey, |
| 1201 | &val) |
| 1202 | != eSIR_SUCCESS) |
| 1203 | { |
| 1204 | /// Could not get Default key from CFG. |
| 1205 | //Log error. |
| 1206 | limLog(pMac, LOGP, |
| 1207 | FL("could not retrieve Default key\n")); |
| 1208 | |
| 1209 | authFrame.authAlgoNumber = |
| 1210 | pRxAuthFrameBody->authAlgoNumber; |
| 1211 | authFrame.authTransactionSeqNumber = |
| 1212 | pRxAuthFrameBody->authTransactionSeqNumber + 1; |
| 1213 | authFrame.authStatusCode = |
| 1214 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 1215 | |
| 1216 | limSendAuthMgmtFrame( |
| 1217 | pMac, &authFrame, |
| 1218 | pHdr->sa, |
| 1219 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 1220 | |
| 1221 | limRestoreFromAuthState(pMac, eSIR_SME_INVALID_WEP_DEFAULT_KEY, |
| 1222 | eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry); |
| 1223 | |
| 1224 | break; |
| 1225 | } |
| 1226 | key_length=val; |
| 1227 | ((tpSirMacAuthFrameBody) plainBody)->authAlgoNumber = |
| 1228 | sirSwapU16ifNeeded(pRxAuthFrameBody->authAlgoNumber); |
| 1229 | ((tpSirMacAuthFrameBody) plainBody)->authTransactionSeqNumber = |
| 1230 | sirSwapU16ifNeeded((tANI_U16) (pRxAuthFrameBody->authTransactionSeqNumber + 1)); |
| 1231 | ((tpSirMacAuthFrameBody) plainBody)->authStatusCode = eSIR_MAC_SUCCESS_STATUS; |
| 1232 | ((tpSirMacAuthFrameBody) plainBody)->type = SIR_MAC_CHALLENGE_TEXT_EID; |
| 1233 | ((tpSirMacAuthFrameBody) plainBody)->length = SIR_MAC_AUTH_CHALLENGE_LENGTH; |
| 1234 | palCopyMemory( pMac->hHdd, (tANI_U8 *) ((tpSirMacAuthFrameBody) plainBody)->challengeText, |
| 1235 | pRxAuthFrameBody->challengeText, |
| 1236 | SIR_MAC_AUTH_CHALLENGE_LENGTH); |
| 1237 | |
| 1238 | limEncryptAuthFrame(pMac, keyId, |
| 1239 | defaultKey, |
| 1240 | plainBody, |
| 1241 | encrAuthFrame,key_length); |
| 1242 | |
| 1243 | psessionEntry->limMlmState = |
| 1244 | eLIM_MLM_WT_AUTH_FRAME4_STATE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1245 | MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1246 | |
| 1247 | limSendAuthMgmtFrame(pMac, |
| 1248 | (tpSirMacAuthFrameBody) encrAuthFrame, |
| 1249 | pHdr->sa, |
| 1250 | LIM_WEP_IN_FC,psessionEntry); |
| 1251 | |
| 1252 | break; |
| 1253 | } // end if (pKeyMapEntry) |
| 1254 | } // end if (!wlan_cfgGetInt(CFG_PRIVACY_OPTION_IMPLEMENTED)) |
| 1255 | } // end if (pRxAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) |
| 1256 | } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS) |
| 1257 | else |
| 1258 | { |
| 1259 | /** |
| 1260 | * Authentication failure. |
| 1261 | * Return Auth confirm with received failure code to SME |
| 1262 | */ |
| 1263 | |
| 1264 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1265 | PELOGE(limLog(pMac, LOGE, |
| 1266 | FL("received Auth frame from peer with failure code %d " |
| 1267 | MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode, |
| 1268 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1269 | |
| 1270 | limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED, |
| 1271 | pRxAuthFrameBody->authStatusCode,psessionEntry); |
| 1272 | } // end if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS) |
| 1273 | |
| 1274 | break; |
| 1275 | |
| 1276 | case SIR_MAC_AUTH_FRAME_3: |
| 1277 | // AuthFrame 3 |
| 1278 | |
| 1279 | if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY) |
| 1280 | { |
| 1281 | /** |
| 1282 | * Received Authentication frame3 with algorithm other than |
| 1283 | * Shared Key authentication type. Reject with Auth frame4 |
| 1284 | * with 'out of sequence' status code. |
| 1285 | */ |
| 1286 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 1287 | authFrame.authTransactionSeqNumber = |
| 1288 | SIR_MAC_AUTH_FRAME_4; |
| 1289 | authFrame.authStatusCode = |
| 1290 | eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS; |
| 1291 | |
| 1292 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 1293 | pHdr->sa, |
| 1294 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 1295 | |
| 1296 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1297 | PELOGE(limLog(pMac, LOGE, |
| 1298 | FL("received Auth frame3 from peer with auth algo number %d " |
| 1299 | MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber, |
| 1300 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1301 | |
| 1302 | return; |
| 1303 | } |
| 1304 | |
| 1305 | if (psessionEntry->limSystemRole == eLIM_AP_ROLE || psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE || |
| 1306 | psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) |
| 1307 | { |
| 1308 | /** |
| 1309 | * Check if wep bit was set in FC. If not set, |
| 1310 | * reject with Authentication frame4 with |
| 1311 | * 'challenge failure' status code. |
| 1312 | */ |
| 1313 | if (!pHdr->fc.wep) |
| 1314 | { |
| 1315 | /// WEP bit is not set in FC of Auth Frame3 |
| 1316 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 1317 | authFrame.authTransactionSeqNumber = |
| 1318 | SIR_MAC_AUTH_FRAME_4; |
| 1319 | authFrame.authStatusCode = |
| 1320 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 1321 | |
| 1322 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 1323 | pHdr->sa, |
| 1324 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 1325 | |
| 1326 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1327 | PELOGE(limLog(pMac, LOGE, |
| 1328 | FL("received Auth frame3 from peer with no WEP bit set "MAC_ADDRESS_STR), |
| 1329 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1330 | |
| 1331 | return; |
| 1332 | } |
| 1333 | |
| 1334 | pAuthNode = limSearchPreAuthList(pMac, |
| 1335 | pHdr->sa); |
| 1336 | if (pAuthNode == NULL) |
| 1337 | { |
| 1338 | /** |
| 1339 | * No 'pre-auth' context exists for |
| 1340 | * this STA that sent an Authentication |
| 1341 | * frame3. |
| 1342 | * Send Auth frame4 with 'out of sequence' |
| 1343 | * status code. |
| 1344 | */ |
| 1345 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 1346 | authFrame.authTransactionSeqNumber = |
| 1347 | SIR_MAC_AUTH_FRAME_4; |
| 1348 | authFrame.authStatusCode = |
| 1349 | eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS; |
| 1350 | |
| 1351 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 1352 | pHdr->sa, |
| 1353 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 1354 | |
| 1355 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1356 | PELOGE(limLog(pMac, LOGW, |
| 1357 | FL("received AuthFrame3 from peer that has no preauth context " |
| 1358 | MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1359 | |
| 1360 | return; |
| 1361 | } |
| 1362 | |
| 1363 | if (pAuthNode->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE) |
| 1364 | { |
| 1365 | /** |
| 1366 | * Received Auth Frame3 after Auth Response timeout. |
| 1367 | * Reject by sending Auth Frame4 with |
| 1368 | * Auth respone timeout Status Code. |
| 1369 | */ |
| 1370 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 1371 | authFrame.authTransactionSeqNumber = |
| 1372 | SIR_MAC_AUTH_FRAME_4; |
| 1373 | authFrame.authStatusCode = |
| 1374 | eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS; |
| 1375 | |
| 1376 | limSendAuthMgmtFrame( |
| 1377 | pMac, &authFrame, |
| 1378 | pHdr->sa, |
| 1379 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 1380 | |
| 1381 | // Log error |
| 1382 | limLog(pMac, LOGW, |
| 1383 | FL("auth response timer timedout for peer ")); |
| 1384 | limPrintMacAddr(pMac, pHdr->sa, LOGW); |
| 1385 | |
| 1386 | /// Delete pre-auth context of STA |
| 1387 | limDeletePreAuthNode(pMac, |
| 1388 | pHdr->sa); |
| 1389 | |
| 1390 | return; |
| 1391 | } // end switch (pAuthNode->mlmState) |
| 1392 | |
| 1393 | if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS) |
| 1394 | { |
| 1395 | /** |
| 1396 | * Received Authenetication Frame 3 with status code |
| 1397 | * other than success. Wait until Auth response timeout |
| 1398 | * to delete STA context. |
| 1399 | */ |
| 1400 | |
| 1401 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1402 | PELOGE(limLog(pMac, LOGE, |
| 1403 | FL("received Auth frame3 from peer with status code %d " |
| 1404 | MAC_ADDRESS_STR), pRxAuthFrameBody->authStatusCode, |
| 1405 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1406 | |
| 1407 | return; |
| 1408 | } |
| 1409 | |
| 1410 | /** |
| 1411 | * Check if received challenge text is same as one sent in |
| 1412 | * Authentication frame3 |
| 1413 | */ |
| 1414 | |
| 1415 | if (palEqualMemory( pMac->hHdd,pRxAuthFrameBody->challengeText, |
| 1416 | pAuthNode->challengeText, |
| 1417 | SIR_MAC_AUTH_CHALLENGE_LENGTH)) |
| 1418 | { |
| 1419 | /// Challenge match. STA is autheticated ! |
| 1420 | |
| 1421 | /// Delete Authentication response timer if running |
| 1422 | limDeactivateAndChangePerStaIdTimer(pMac, |
| 1423 | eLIM_AUTH_RSP_TIMER, |
| 1424 | pAuthNode->authNodeIdx); |
| 1425 | |
| 1426 | pAuthNode->fTimerStarted = 0; |
| 1427 | pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE; |
| 1428 | |
| 1429 | /** |
| 1430 | * Send Authentication Frame4 with 'success' Status Code. |
| 1431 | */ |
| 1432 | authFrame.authAlgoNumber = eSIR_SHARED_KEY; |
| 1433 | authFrame.authTransactionSeqNumber = |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame^] | 1434 | SIR_MAC_AUTH_FRAME_4; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1435 | authFrame.authStatusCode = eSIR_MAC_SUCCESS_STATUS; |
| 1436 | |
| 1437 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 1438 | pHdr->sa, |
| 1439 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 1440 | |
| 1441 | /// Send Auth indication to SME |
| 1442 | palCopyMemory( pMac->hHdd, |
| 1443 | (tANI_U8 *) mlmAuthInd.peerMacAddr, |
| 1444 | (tANI_U8 *) pHdr->sa, |
| 1445 | sizeof(tSirMacAddr)); |
| 1446 | mlmAuthInd.authType = (tAniAuthType) |
| 1447 | pRxAuthFrameBody->authAlgoNumber; |
| 1448 | mlmAuthInd.sessionId = psessionEntry->smeSessionId; |
| 1449 | |
| 1450 | limPostSmeMessage(pMac, |
| 1451 | LIM_MLM_AUTH_IND, |
| 1452 | (tANI_U32 *) &mlmAuthInd); |
| 1453 | |
| 1454 | break; |
| 1455 | } |
| 1456 | else |
| 1457 | { |
| 1458 | /** |
| 1459 | * Challenge Failure. |
| 1460 | * Send Authentication frame4 with 'challenge failure' |
| 1461 | * status code and wait until Auth response timeout to |
| 1462 | * delete STA context. |
| 1463 | */ |
| 1464 | |
| 1465 | authFrame.authAlgoNumber = |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame^] | 1466 | pRxAuthFrameBody->authAlgoNumber; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1467 | authFrame.authTransactionSeqNumber = |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame^] | 1468 | SIR_MAC_AUTH_FRAME_4; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1469 | authFrame.authStatusCode = |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame^] | 1470 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1471 | |
| 1472 | limSendAuthMgmtFrame(pMac, &authFrame, |
| 1473 | pHdr->sa, |
| 1474 | LIM_NO_WEP_IN_FC,psessionEntry); |
| 1475 | |
| 1476 | // Log error |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame^] | 1477 | PELOGE( limLog(pMac, LOGW, |
| 1478 | FL("Challenge failure for peer "MAC_ADDRESS_STR), |
| 1479 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1480 | return; |
| 1481 | } |
| 1482 | } // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE || ... |
| 1483 | |
| 1484 | break; |
| 1485 | |
| 1486 | case SIR_MAC_AUTH_FRAME_4: |
| 1487 | // AuthFrame 4 |
| 1488 | if (psessionEntry->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE) |
| 1489 | { |
| 1490 | /** |
| 1491 | * Received Authentication frame4 in an unexpected state. |
| 1492 | * Log error and ignore the frame. |
| 1493 | */ |
| 1494 | |
| 1495 | // Log error |
| 1496 | PELOG1(limLog(pMac, LOG1, |
| 1497 | FL("received unexpected Auth frame4 from peer in state %d, addr "), |
| 1498 | psessionEntry->limMlmState);) |
| 1499 | PELOG1( limPrintMacAddr(pMac, pHdr->sa, LOG1);) |
| 1500 | |
| 1501 | return; |
| 1502 | } |
| 1503 | |
| 1504 | if (pRxAuthFrameBody->authAlgoNumber != eSIR_SHARED_KEY) |
| 1505 | { |
| 1506 | /** |
| 1507 | * Received Authentication frame4 with algorithm other than |
| 1508 | * Shared Key authentication type. |
| 1509 | * Wait until Auth failure timeout to report authentication |
| 1510 | * failure to SME. |
| 1511 | */ |
| 1512 | |
| 1513 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1514 | PELOGE(limLog(pMac, LOGE, |
| 1515 | FL("received Auth frame4 from peer with invalid auth algo %d " |
| 1516 | MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber, |
| 1517 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1518 | |
| 1519 | return; |
| 1520 | } |
| 1521 | |
| 1522 | if ( !palEqualMemory( pMac->hHdd,(tANI_U8 *) pHdr->sa, |
| 1523 | (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr, |
| 1524 | sizeof(tSirMacAddr)) ) |
| 1525 | { |
| 1526 | /** |
| 1527 | * Received Authentication frame from an entity |
| 1528 | * other than one to which request was initiated. |
| 1529 | * Wait until Authentication Failure Timeout. |
| 1530 | */ |
| 1531 | |
| 1532 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1533 | PELOGE(limLog(pMac, LOGW, |
| 1534 | FL("received Auth frame4 from unexpected peer " |
| 1535 | MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1536 | |
| 1537 | break; |
| 1538 | } |
| 1539 | |
| 1540 | if (pRxAuthFrameBody->authAlgoNumber != |
| 1541 | pMac->lim.gpLimMlmAuthReq->authType) |
| 1542 | { |
| 1543 | /** |
| 1544 | * Received Authentication frame with an auth algorithm |
| 1545 | * other than one requested. |
| 1546 | * Wait until Authentication Failure Timeout. |
| 1547 | */ |
| 1548 | |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1549 | PELOGE(limLog(pMac, LOGE, |
| 1550 | FL("received Authentication frame from peer with invalid auth seq number %d " |
| 1551 | MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber, |
| 1552 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1553 | |
| 1554 | break; |
| 1555 | } |
| 1556 | |
| 1557 | if (pRxAuthFrameBody->authStatusCode == |
| 1558 | eSIR_MAC_SUCCESS_STATUS) |
| 1559 | { |
| 1560 | /** |
| 1561 | * Authentication Success ! |
| 1562 | * Inform SME of same. |
| 1563 | */ |
| 1564 | psessionEntry->limCurrentAuthType = eSIR_SHARED_KEY; |
| 1565 | |
| 1566 | pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable); |
| 1567 | if (pAuthNode == NULL) |
| 1568 | { |
| 1569 | // Log error |
| 1570 | limLog(pMac, LOGW, |
| 1571 | FL("Max pre-auth nodes reached ")); |
| 1572 | limPrintMacAddr(pMac, pHdr->sa, LOGW); |
| 1573 | |
| 1574 | return; |
| 1575 | } |
| 1576 | PELOG1(limLog(pMac, LOG1, FL("Alloc new data: %x peer \n"), pAuthNode); |
| 1577 | limPrintMacAddr(pMac, pHdr->sa, LOG1);) |
| 1578 | |
| 1579 | palCopyMemory( pMac->hHdd, |
| 1580 | (tANI_U8 *) pAuthNode->peerMacAddr, |
| 1581 | pMac->lim.gpLimMlmAuthReq->peerMacAddr, |
| 1582 | sizeof(tSirMacAddr)); |
| 1583 | pAuthNode->fTimerStarted = 0; |
| 1584 | pAuthNode->authType = pMac->lim.gpLimMlmAuthReq->authType; |
| 1585 | limAddPreAuthNode(pMac, pAuthNode); |
| 1586 | |
| 1587 | limRestoreFromAuthState(pMac, eSIR_SME_SUCCESS, |
| 1588 | pRxAuthFrameBody->authStatusCode,psessionEntry); |
| 1589 | |
| 1590 | } // if (pRxAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS) |
| 1591 | else |
| 1592 | { |
| 1593 | /** |
| 1594 | * Authentication failure. |
| 1595 | * Return Auth confirm with received failure code to SME |
| 1596 | */ |
| 1597 | |
| 1598 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1599 | PELOGE(limLog(pMac, LOGE, FL("Authentication failure from peer " |
| 1600 | MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1601 | |
| 1602 | limRestoreFromAuthState(pMac, eSIR_SME_AUTH_REFUSED, |
| 1603 | pRxAuthFrameBody->authStatusCode,psessionEntry); |
| 1604 | } // end if (pRxAuthFrameBody->Status == 0) |
| 1605 | |
| 1606 | break; |
| 1607 | |
| 1608 | default: |
| 1609 | /// Invalid Authentication Frame received. Ignore it. |
| 1610 | |
| 1611 | // Log error |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 1612 | PELOGE(limLog(pMac, LOGE, |
| 1613 | FL("received Auth frame from peer with invalid auth seq number %d " |
| 1614 | MAC_ADDRESS_STR), pRxAuthFrameBody->authTransactionSeqNumber, |
| 1615 | MAC_ADDR_ARRAY(pHdr->sa));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1616 | |
| 1617 | break; |
| 1618 | } // end switch (pRxAuthFrameBody->authTransactionSeqNumber) |
| 1619 | } /*** end limProcessAuthFrame() ***/ |
| 1620 | |
| 1621 | |
| 1622 | |
| 1623 | |
| 1624 | |
| 1625 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 1626 | |
| 1627 | /*---------------------------------------------------------------------- |
| 1628 | * |
| 1629 | * Pass the received Auth frame. This is possibly the pre-auth from the |
| 1630 | * neighbor AP, in the same mobility domain. |
| 1631 | * This will be used in case of 11r FT. |
| 1632 | * |
| 1633 | * !!!! This is going to be renoved for the next checkin. We will be creating |
| 1634 | * the session before sending out the Auth. Thus when auth response |
| 1635 | * is received we will have a session in progress. !!!!! |
| 1636 | *---------------------------------------------------------------------- |
| 1637 | */ |
| 1638 | int limProcessAuthFrameNoSession(tpAniSirGlobal pMac, tANI_U8 *pBd, void *body) |
| 1639 | { |
| 1640 | tpSirMacMgmtHdr pHdr; |
| 1641 | tpPESession psessionEntry = NULL; |
| 1642 | tANI_U8 *pBody; |
| 1643 | tANI_U16 frameLen; |
| 1644 | tSirMacAuthFrameBody rxAuthFrame; |
| 1645 | tSirMacAuthFrameBody *pRxAuthFrameBody = NULL; |
| 1646 | int ret_status = eSIR_FAILURE; |
| 1647 | |
| 1648 | pHdr = WDA_GET_RX_MAC_HEADER(pBd); |
| 1649 | pBody = WDA_GET_RX_MPDU_DATA(pBd); |
| 1650 | frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd); |
| 1651 | |
| 1652 | // Check for the operating channel and see what needs to be done next. |
| 1653 | psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry; |
| 1654 | if (psessionEntry == NULL) |
| 1655 | { |
| 1656 | limLog(pMac, LOGW, FL("Error: Unable to find session id while in pre-auth phase for FT")); |
| 1657 | return eSIR_FAILURE; |
| 1658 | } |
| 1659 | |
| 1660 | if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL) |
| 1661 | { |
| 1662 | // No FT in progress. |
| 1663 | return eSIR_FAILURE; |
| 1664 | } |
| 1665 | |
| 1666 | if (frameLen == 0) |
| 1667 | { |
| 1668 | return eSIR_FAILURE; |
| 1669 | } |
| 1670 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
| 1671 | limPrintMacAddr(pMac, pHdr->bssId, LOGE); |
| 1672 | limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE); |
| 1673 | #endif |
| 1674 | |
| 1675 | // Check that its the same bssId we have for preAuth |
| 1676 | if (!palEqualMemory( pMac->hHdd, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, |
| 1677 | pHdr->bssId, sizeof( tSirMacAddr ))) |
| 1678 | { |
| 1679 | // In this case SME if indeed has triggered a |
| 1680 | // pre auth it will time out. |
| 1681 | return eSIR_FAILURE; |
| 1682 | } |
| 1683 | |
| 1684 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
| 1685 | limLog(pMac, LOGE, FL("Pre-Auth response received from neighbor")); |
| 1686 | limLog(pMac, LOGE, FL("Pre-Auth done state")); |
| 1687 | #endif |
| 1688 | // Stopping timer now, that we have our unicast from the AP |
| 1689 | // of our choice. |
| 1690 | limDeactivateAndChangeTimer(pMac, eLIM_FT_PREAUTH_RSP_TIMER); |
| 1691 | |
| 1692 | |
| 1693 | // Save off the auth resp. |
| 1694 | if ((sirConvertAuthFrame2Struct(pMac, pBody, frameLen, &rxAuthFrame) != eSIR_SUCCESS)) |
| 1695 | { |
| 1696 | limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry); |
| 1697 | return eSIR_FAILURE; |
| 1698 | } |
| 1699 | pRxAuthFrameBody = &rxAuthFrame; |
| 1700 | |
| 1701 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
| 1702 | PELOGE(limLog(pMac, LOGE, |
| 1703 | FL("Received Auth frame with type=%d seqnum=%d, status=%d (%d)\n"), |
| 1704 | (tANI_U32) pRxAuthFrameBody->authAlgoNumber, |
| 1705 | (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber, |
| 1706 | (tANI_U32) pRxAuthFrameBody->authStatusCode,(tANI_U32)pMac->lim.gLimNumPreAuthContexts);) |
| 1707 | #endif |
| 1708 | |
| 1709 | switch (pRxAuthFrameBody->authTransactionSeqNumber) |
| 1710 | { |
| 1711 | case SIR_MAC_AUTH_FRAME_2: |
| 1712 | if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS) |
| 1713 | { |
| 1714 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
| 1715 | PELOGE(limLog( pMac, LOGE, "Auth status code received is %d\n", |
| 1716 | (tANI_U32) pRxAuthFrameBody->authStatusCode);) |
| 1717 | #endif |
| 1718 | } |
| 1719 | else |
| 1720 | { |
| 1721 | ret_status = eSIR_SUCCESS; |
| 1722 | } |
| 1723 | break; |
| 1724 | |
| 1725 | default: |
| 1726 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
| 1727 | PELOGE(limLog( pMac, LOGE, "Seq. no incorrect expected 2 received %d\n", |
| 1728 | (tANI_U32) pRxAuthFrameBody->authTransactionSeqNumber);) |
| 1729 | #endif |
| 1730 | break; |
| 1731 | } |
| 1732 | |
| 1733 | // Send the Auth response to SME |
| 1734 | limHandleFTPreAuthRsp(pMac, ret_status, pBody, frameLen, psessionEntry); |
| 1735 | |
| 1736 | return ret_status; |
| 1737 | } |
| 1738 | |
| 1739 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
| 1740 | |