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