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