Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Srinivas Girigowda | f936d82 | 2017-03-19 23:23:59 -0700 | [diff] [blame] | 2 | * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -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. |
| 20 | */ |
| 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 | |
| 28 | /* |
| 29 | * |
| 30 | * This file lim_process_auth_frame.cc contains the code |
| 31 | * for processing received Authentication Frame. |
| 32 | * Author: Chandra Modumudi |
| 33 | * Date: 03/11/02 |
| 34 | * History:- |
| 35 | * Date Modified by Modification Information |
| 36 | * -------------------------------------------------------------------- |
| 37 | * 05/12/2010 js To support Shared key authentication at AP side |
| 38 | * |
| 39 | */ |
| 40 | |
| 41 | #include "wni_api.h" |
| 42 | #include "wni_cfg.h" |
| 43 | #include "ani_global.h" |
| 44 | #include "cfg_api.h" |
| 45 | |
| 46 | #include "utils_api.h" |
| 47 | #include "lim_utils.h" |
| 48 | #include "lim_assoc_utils.h" |
| 49 | #include "lim_security_utils.h" |
| 50 | #include "lim_ser_des_utils.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 51 | #include "lim_ft.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 52 | #include "cds_utils.h" |
yeshwanth sriram guntuka | fde0d52 | 2017-08-17 19:52:11 +0530 | [diff] [blame] | 53 | #include "lim_send_messages.h" |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 54 | #include "lim_process_fils.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * is_auth_valid |
| 58 | * |
| 59 | ***FUNCTION: |
| 60 | * This function is called by lim_process_auth_frame() upon Authentication |
| 61 | * frame reception. |
| 62 | * |
| 63 | ***LOGIC: |
| 64 | * This function is used to test validity of auth frame: |
| 65 | * - AUTH1 and AUTH3 must be received in AP mode |
| 66 | * - AUTH2 and AUTH4 must be received in STA mode |
| 67 | * - AUTH3 and AUTH4 must have challenge text IE, that is,'type' field has been set to |
| 68 | * SIR_MAC_CHALLENGE_TEXT_EID by parser |
| 69 | * - |
| 70 | * |
| 71 | ***ASSUMPTIONS: |
| 72 | * |
| 73 | ***NOTE: |
| 74 | * |
| 75 | * @param *auth - Pointer to extracted auth frame body |
| 76 | * |
| 77 | * @return 0 or 1 (Valid) |
| 78 | */ |
| 79 | |
| 80 | static inline unsigned int is_auth_valid(tpAniSirGlobal pMac, |
| 81 | tpSirMacAuthFrameBody auth, |
| 82 | tpPESession sessionEntry) |
| 83 | { |
| 84 | unsigned int valid = 1; |
| 85 | |
| 86 | if (((auth->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1) || |
| 87 | (auth->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_3)) && |
Rajeev Kumar | be5d7fd | 2016-04-15 14:35:12 -0700 | [diff] [blame] | 88 | (LIM_IS_STA_ROLE(sessionEntry))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 89 | valid = 0; |
| 90 | |
| 91 | if (((auth->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_2) || |
| 92 | (auth->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_4)) && |
Rajeev Kumar | be5d7fd | 2016-04-15 14:35:12 -0700 | [diff] [blame] | 93 | (LIM_IS_AP_ROLE(sessionEntry))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 94 | valid = 0; |
| 95 | |
| 96 | if (((auth->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_3) || |
| 97 | (auth->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_4)) && |
| 98 | (auth->type != SIR_MAC_CHALLENGE_TEXT_EID) && |
| 99 | (auth->authAlgoNumber != eSIR_SHARED_KEY)) |
| 100 | valid = 0; |
| 101 | |
| 102 | return valid; |
| 103 | } |
| 104 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 105 | static void lim_process_auth_shared_system_algo(tpAniSirGlobal mac_ctx, |
| 106 | tpSirMacMgmtHdr mac_hdr, |
| 107 | tSirMacAuthFrameBody *rx_auth_frm_body, |
| 108 | tSirMacAuthFrameBody *auth_frame, |
| 109 | uint8_t *challenge_txt_arr, |
| 110 | tpPESession pe_session) |
| 111 | { |
| 112 | uint32_t val; |
| 113 | uint8_t cfg_privacy_opt_imp, *challenge; |
| 114 | struct tLimPreAuthNode *auth_node; |
| 115 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 116 | pe_debug("=======> eSIR_SHARED_KEY"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 117 | if (LIM_IS_AP_ROLE(pe_session)) |
| 118 | val = pe_session->privacy; |
| 119 | else if (wlan_cfg_get_int(mac_ctx, |
| 120 | WNI_CFG_PRIVACY_ENABLED, &val) != eSIR_SUCCESS) |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 121 | pe_warn("couldnt retrieve Privacy option"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 122 | cfg_privacy_opt_imp = (uint8_t) val; |
| 123 | if (!cfg_privacy_opt_imp) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 124 | pe_err("rx Auth frame for unsupported auth algorithm %d " |
| 125 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 126 | rx_auth_frm_body->authAlgoNumber, |
| 127 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 128 | |
| 129 | /* |
| 130 | * Authenticator does not have WEP |
| 131 | * implemented. |
| 132 | * Reject by sending Authentication frame |
| 133 | * with Auth algorithm not supported status |
| 134 | * code. |
| 135 | */ |
| 136 | auth_frame->authAlgoNumber = rx_auth_frm_body->authAlgoNumber; |
| 137 | auth_frame->authTransactionSeqNumber = |
| 138 | rx_auth_frm_body->authTransactionSeqNumber + 1; |
| 139 | auth_frame->authStatusCode = |
| 140 | eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS; |
| 141 | |
| 142 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 143 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 144 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 145 | return; |
| 146 | } else { |
| 147 | /* Create entry for this STA in pre-auth list */ |
| 148 | auth_node = lim_acquire_free_pre_auth_node(mac_ctx, |
| 149 | &mac_ctx->lim.gLimPreAuthTimerTable); |
| 150 | if (auth_node == NULL) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 151 | pe_warn("Max preauth-nodes reached"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 152 | lim_print_mac_addr(mac_ctx, mac_hdr->sa, LOGW); |
| 153 | return; |
| 154 | } |
| 155 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 156 | qdf_mem_copy((uint8_t *) auth_node->peerMacAddr, mac_hdr->sa, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 157 | sizeof(tSirMacAddr)); |
| 158 | auth_node->mlmState = eLIM_MLM_WT_AUTH_FRAME3_STATE; |
| 159 | auth_node->authType = |
| 160 | (tAniAuthType) rx_auth_frm_body->authAlgoNumber; |
| 161 | auth_node->fSeen = 0; |
| 162 | auth_node->fTimerStarted = 0; |
| 163 | auth_node->seq_num = ((mac_hdr->seqControl.seqNumHi << 4) | |
| 164 | (mac_hdr->seqControl.seqNumLo)); |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 165 | auth_node->timestamp = qdf_mc_timer_get_system_ticks(); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 166 | lim_add_pre_auth_node(mac_ctx, auth_node); |
| 167 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 168 | pe_debug("Alloc new data: %p id: %d peer ", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 169 | auth_node, auth_node->authNodeIdx); |
| 170 | lim_print_mac_addr(mac_ctx, mac_hdr->sa, LOG1); |
| 171 | /* / Create and activate Auth Response timer */ |
| 172 | if (tx_timer_change_context(&auth_node->timer, |
| 173 | auth_node->authNodeIdx) != TX_SUCCESS) { |
| 174 | /* Could not start Auth response timer. Log error */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 175 | pe_warn("Unable to chg context auth response timer for peer"); |
Nishank Aggarwal | abfd70b | 2017-03-11 16:48:25 +0530 | [diff] [blame] | 176 | lim_print_mac_addr(mac_ctx, mac_hdr->sa, LOGW); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 177 | |
| 178 | /* |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 179 | * Send Auth frame with unspecified failure status code. |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 180 | */ |
| 181 | |
| 182 | auth_frame->authAlgoNumber = |
| 183 | rx_auth_frm_body->authAlgoNumber; |
| 184 | auth_frame->authTransactionSeqNumber = |
| 185 | rx_auth_frm_body->authTransactionSeqNumber + 1; |
| 186 | auth_frame->authStatusCode = |
| 187 | eSIR_MAC_UNSPEC_FAILURE_STATUS; |
| 188 | |
| 189 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 190 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 191 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 192 | lim_delete_pre_auth_node(mac_ctx, mac_hdr->sa); |
| 193 | return; |
| 194 | } |
| 195 | lim_activate_auth_rsp_timer(mac_ctx, auth_node); |
| 196 | auth_node->fTimerStarted = 1; |
| 197 | /* |
| 198 | * get random bytes and use as challenge text. |
| 199 | * If it fails we already have random stack bytes. |
| 200 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 201 | if (!QDF_IS_STATUS_SUCCESS(cds_rand_get_bytes(0, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 202 | (uint8_t *) challenge_txt_arr, |
| 203 | SIR_MAC_AUTH_CHALLENGE_LENGTH))) |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 204 | pe_err("Challenge text preparation failed"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 205 | challenge = auth_node->challengeText; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 206 | qdf_mem_copy(challenge, (uint8_t *)challenge_txt_arr, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 207 | sizeof(challenge_txt_arr)); |
| 208 | /* |
| 209 | * Sending Authenticaton frame with challenge. |
| 210 | */ |
| 211 | auth_frame->authAlgoNumber = rx_auth_frm_body->authAlgoNumber; |
| 212 | auth_frame->authTransactionSeqNumber = |
| 213 | rx_auth_frm_body->authTransactionSeqNumber + 1; |
| 214 | auth_frame->authStatusCode = eSIR_MAC_SUCCESS_STATUS; |
| 215 | auth_frame->type = SIR_MAC_CHALLENGE_TEXT_EID; |
| 216 | auth_frame->length = SIR_MAC_AUTH_CHALLENGE_LENGTH; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 217 | qdf_mem_copy(auth_frame->challengeText, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 218 | auth_node->challengeText, |
| 219 | SIR_MAC_AUTH_CHALLENGE_LENGTH); |
| 220 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 221 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 222 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 223 | } |
| 224 | } |
| 225 | |
| 226 | static void lim_process_auth_open_system_algo(tpAniSirGlobal mac_ctx, |
| 227 | tpSirMacMgmtHdr mac_hdr, |
| 228 | tSirMacAuthFrameBody *rx_auth_frm_body, |
| 229 | tSirMacAuthFrameBody *auth_frame, |
| 230 | tpPESession pe_session) |
| 231 | { |
| 232 | struct tLimPreAuthNode *auth_node; |
| 233 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 234 | pe_debug("=======> eSIR_OPEN_SYSTEM"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 235 | /* Create entry for this STA in pre-auth list */ |
| 236 | auth_node = lim_acquire_free_pre_auth_node(mac_ctx, |
| 237 | &mac_ctx->lim.gLimPreAuthTimerTable); |
| 238 | if (auth_node == NULL) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 239 | pe_warn("Max pre-auth nodes reached "); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 240 | lim_print_mac_addr(mac_ctx, mac_hdr->sa, LOGW); |
| 241 | return; |
| 242 | } |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 243 | pe_debug("Alloc new data: %p peer", auth_node); |
| 244 | lim_print_mac_addr(mac_ctx, mac_hdr->sa, LOGD); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 245 | qdf_mem_copy((uint8_t *) auth_node->peerMacAddr, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 246 | mac_hdr->sa, sizeof(tSirMacAddr)); |
| 247 | auth_node->mlmState = eLIM_MLM_AUTHENTICATED_STATE; |
| 248 | auth_node->authType = (tAniAuthType) rx_auth_frm_body->authAlgoNumber; |
| 249 | auth_node->fSeen = 0; |
| 250 | auth_node->fTimerStarted = 0; |
| 251 | auth_node->seq_num = ((mac_hdr->seqControl.seqNumHi << 4) | |
| 252 | (mac_hdr->seqControl.seqNumLo)); |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 253 | auth_node->timestamp = qdf_mc_timer_get_system_ticks(); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 254 | lim_add_pre_auth_node(mac_ctx, auth_node); |
| 255 | /* |
| 256 | * Send Authenticaton frame with Success |
| 257 | * status code. |
| 258 | */ |
| 259 | auth_frame->authAlgoNumber = rx_auth_frm_body->authAlgoNumber; |
| 260 | auth_frame->authTransactionSeqNumber = |
| 261 | rx_auth_frm_body->authTransactionSeqNumber + 1; |
| 262 | auth_frame->authStatusCode = eSIR_MAC_SUCCESS_STATUS; |
| 263 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, mac_hdr->sa, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 264 | LIM_NO_WEP_IN_FC, |
| 265 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | static void lim_process_auth_frame_type1(tpAniSirGlobal mac_ctx, |
| 269 | tpSirMacMgmtHdr mac_hdr, |
| 270 | tSirMacAuthFrameBody *rx_auth_frm_body, |
| 271 | uint8_t *rx_pkt_info, uint16_t curr_seq_num, |
| 272 | tSirMacAuthFrameBody *auth_frame, tpPESession pe_session) |
| 273 | { |
| 274 | tpDphHashNode sta_ds_ptr = NULL; |
| 275 | struct tLimPreAuthNode *auth_node; |
| 276 | uint8_t challenge_txt_arr[SIR_MAC_AUTH_CHALLENGE_LENGTH]; |
| 277 | uint32_t maxnum_preauth; |
| 278 | uint16_t associd = 0; |
| 279 | |
| 280 | /* AuthFrame 1 */ |
| 281 | sta_ds_ptr = dph_lookup_hash_entry(mac_ctx, mac_hdr->sa, |
| 282 | &associd, &pe_session->dph.dphHashTable); |
| 283 | if (sta_ds_ptr) { |
| 284 | tLimMlmDisassocReq *pMlmDisassocReq = NULL; |
| 285 | tLimMlmDeauthReq *pMlmDeauthReq = NULL; |
Srinivas Girigowda | 74a66d6 | 2017-06-21 23:28:25 -0700 | [diff] [blame] | 286 | bool isConnected = true; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 287 | |
| 288 | pMlmDisassocReq = |
| 289 | mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq; |
| 290 | if (pMlmDisassocReq && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 291 | (!qdf_mem_cmp((uint8_t *) mac_hdr->sa, (uint8_t *) |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 292 | &pMlmDisassocReq->peer_macaddr.bytes, |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 293 | QDF_MAC_ADDR_SIZE))) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 294 | pe_debug("TODO:Ack for disassoc frame is pending Issue delsta for " |
| 295 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 296 | MAC_ADDR_ARRAY( |
| 297 | pMlmDisassocReq->peer_macaddr.bytes)); |
| 298 | lim_process_disassoc_ack_timeout(mac_ctx); |
Srinivas Girigowda | 74a66d6 | 2017-06-21 23:28:25 -0700 | [diff] [blame] | 299 | isConnected = false; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 300 | } |
| 301 | pMlmDeauthReq = |
| 302 | mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq; |
| 303 | if (pMlmDeauthReq && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 304 | (!qdf_mem_cmp((uint8_t *) mac_hdr->sa, (uint8_t *) |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 305 | &pMlmDeauthReq->peer_macaddr.bytes, |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 306 | QDF_MAC_ADDR_SIZE))) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 307 | pe_debug("TODO:Ack for deauth frame is pending Issue delsta for " |
| 308 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 309 | MAC_ADDR_ARRAY( |
| 310 | pMlmDeauthReq->peer_macaddr.bytes)); |
| 311 | lim_process_deauth_ack_timeout(mac_ctx); |
Srinivas Girigowda | 74a66d6 | 2017-06-21 23:28:25 -0700 | [diff] [blame] | 312 | isConnected = false; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /* |
| 316 | * pStaDS != NULL and isConnected = 1 means the STA is already |
| 317 | * connected, But SAP received the Auth from that station. |
| 318 | * For non PMF connection send Deauth frame as STA will retry |
| 319 | * to connect back. |
| 320 | * |
| 321 | * For PMF connection the AP should not tear down or otherwise |
| 322 | * modify the state of the existing association until the |
| 323 | * SA-Query procedure determines that the original SA is |
| 324 | * invalid. |
| 325 | */ |
| 326 | if (isConnected |
| 327 | #ifdef WLAN_FEATURE_11W |
| 328 | && !sta_ds_ptr->rmfEnabled |
| 329 | #endif |
| 330 | ) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 331 | pe_err("STA is already connected but received auth frame" |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 332 | "Send the Deauth and lim Delete Station Context" |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 333 | "(staId: %d, associd: %d) ", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 334 | sta_ds_ptr->staIndex, associd); |
| 335 | lim_send_deauth_mgmt_frame(mac_ctx, |
| 336 | eSIR_MAC_UNSPEC_FAILURE_REASON, |
| 337 | (uint8_t *) mac_hdr->sa, |
| 338 | pe_session, false); |
| 339 | lim_trigger_sta_deletion(mac_ctx, sta_ds_ptr, |
| 340 | pe_session); |
| 341 | return; |
| 342 | } |
| 343 | } |
| 344 | /* Check if there exists pre-auth context for this STA */ |
| 345 | auth_node = lim_search_pre_auth_list(mac_ctx, mac_hdr->sa); |
| 346 | if (auth_node) { |
| 347 | /* Pre-auth context exists for the STA */ |
| 348 | if (!(mac_hdr->fc.retry == 0 || |
| 349 | auth_node->seq_num != curr_seq_num)) { |
| 350 | /* |
| 351 | * This can happen when first authentication frame is |
| 352 | * received but ACK lost at STA side, in this case 2nd |
| 353 | * auth frame is already in transmission queue |
| 354 | */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 355 | pe_warn("STA is initiating Auth after ACK lost"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 356 | return; |
| 357 | } |
| 358 | /* |
| 359 | * STA is initiating brand-new Authentication |
| 360 | * sequence after local Auth Response timeout Or STA |
| 361 | * retrying to transmit First Auth frame due to packet |
| 362 | * drop OTA Delete Pre-auth node and fall through. |
| 363 | */ |
| 364 | if (auth_node->fTimerStarted) |
| 365 | lim_deactivate_and_change_per_sta_id_timer( |
| 366 | mac_ctx, eLIM_AUTH_RSP_TIMER, |
| 367 | auth_node->authNodeIdx); |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 368 | pe_debug("STA is initiating brand-new Auth"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 369 | lim_delete_pre_auth_node(mac_ctx, mac_hdr->sa); |
| 370 | /* |
| 371 | * SAP Mode:Disassociate the station and |
| 372 | * delete its entry if we have its entry |
| 373 | * already and received "auth" from the |
| 374 | * same station. |
| 375 | * SAP dphHashTable.size = 8 |
| 376 | */ |
| 377 | for (associd = 0; associd < pe_session->dph.dphHashTable.size; |
| 378 | associd++) { |
| 379 | sta_ds_ptr = dph_get_hash_entry(mac_ctx, associd, |
| 380 | &pe_session->dph.dphHashTable); |
| 381 | if (NULL == sta_ds_ptr) |
| 382 | continue; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 383 | if (sta_ds_ptr->valid && (!qdf_mem_cmp( |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 384 | (uint8_t *)&sta_ds_ptr->staAddr, |
| 385 | (uint8_t *) &(mac_hdr->sa), |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 386 | (uint8_t) sizeof(tSirMacAddr)))) |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 387 | break; |
| 388 | sta_ds_ptr = NULL; |
| 389 | } |
| 390 | |
| 391 | if (NULL != sta_ds_ptr |
| 392 | #ifdef WLAN_FEATURE_11W |
| 393 | && !sta_ds_ptr->rmfEnabled |
| 394 | #endif |
| 395 | ) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 396 | pe_debug("lim Delete Station Context staId: %d associd: %d", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 397 | sta_ds_ptr->staIndex, associd); |
| 398 | lim_send_deauth_mgmt_frame(mac_ctx, |
| 399 | eSIR_MAC_UNSPEC_FAILURE_REASON, |
| 400 | (uint8_t *)auth_node->peerMacAddr, |
| 401 | pe_session, false); |
| 402 | lim_trigger_sta_deletion(mac_ctx, sta_ds_ptr, |
| 403 | pe_session); |
| 404 | return; |
| 405 | } |
| 406 | } |
| 407 | if (wlan_cfg_get_int(mac_ctx, WNI_CFG_MAX_NUM_PRE_AUTH, |
| 408 | (uint32_t *) &maxnum_preauth) != eSIR_SUCCESS) |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 409 | pe_warn("could not retrieve MaxNumPreAuth"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 410 | |
| 411 | if (mac_ctx->lim.gLimNumPreAuthContexts == maxnum_preauth && |
| 412 | !lim_delete_open_auth_pre_auth_node(mac_ctx)) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 413 | pe_err("Max no of preauth context reached"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 414 | /* |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 415 | * Maximum number of pre-auth contexts reached. |
| 416 | * Send Authentication frame with unspecified failure |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 417 | */ |
| 418 | auth_frame->authAlgoNumber = rx_auth_frm_body->authAlgoNumber; |
| 419 | auth_frame->authTransactionSeqNumber = |
| 420 | rx_auth_frm_body->authTransactionSeqNumber + 1; |
| 421 | auth_frame->authStatusCode = |
| 422 | eSIR_MAC_UNSPEC_FAILURE_STATUS; |
| 423 | |
| 424 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 425 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 426 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 427 | return; |
| 428 | } |
| 429 | /* No Pre-auth context exists for the STA. */ |
| 430 | if (lim_is_auth_algo_supported(mac_ctx, |
| 431 | (tAniAuthType) rx_auth_frm_body->authAlgoNumber, |
| 432 | pe_session)) { |
Arif Hussain | ee67701 | 2017-01-26 17:50:13 -0800 | [diff] [blame] | 433 | |
Arif Hussain | 7631afa | 2017-02-08 14:35:00 -0800 | [diff] [blame] | 434 | if (lim_get_session_by_macaddr(mac_ctx, mac_hdr->sa)) { |
Arif Hussain | ee67701 | 2017-01-26 17:50:13 -0800 | [diff] [blame] | 435 | |
| 436 | auth_frame->authAlgoNumber = |
| 437 | rx_auth_frm_body->authAlgoNumber; |
| 438 | auth_frame->authTransactionSeqNumber = |
| 439 | rx_auth_frm_body->authTransactionSeqNumber + 1; |
| 440 | auth_frame->authStatusCode = |
| 441 | eSIR_MAC_WME_INVALID_PARAMS_STATUS; |
| 442 | |
| 443 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
| 444 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 445 | pe_session, false); |
| 446 | return; |
| 447 | } |
| 448 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 449 | switch (rx_auth_frm_body->authAlgoNumber) { |
| 450 | case eSIR_OPEN_SYSTEM: |
| 451 | lim_process_auth_open_system_algo(mac_ctx, mac_hdr, |
| 452 | rx_auth_frm_body, auth_frame, pe_session); |
| 453 | break; |
| 454 | |
| 455 | case eSIR_SHARED_KEY: |
| 456 | lim_process_auth_shared_system_algo(mac_ctx, mac_hdr, |
| 457 | rx_auth_frm_body, auth_frame, |
| 458 | challenge_txt_arr, pe_session); |
| 459 | break; |
| 460 | default: |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 461 | pe_err("rx Auth frm for unsupported auth algo %d " |
| 462 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 463 | rx_auth_frm_body->authAlgoNumber, |
| 464 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 465 | |
| 466 | /* |
| 467 | * Responding party does not support the |
| 468 | * authentication algorithm requested by |
| 469 | * sending party. |
| 470 | * Reject by sending Authentication frame |
| 471 | * with auth algorithm not supported status code |
| 472 | */ |
| 473 | auth_frame->authAlgoNumber = |
| 474 | rx_auth_frm_body->authAlgoNumber; |
| 475 | auth_frame->authTransactionSeqNumber = |
| 476 | rx_auth_frm_body->authTransactionSeqNumber + 1; |
| 477 | auth_frame->authStatusCode = |
| 478 | eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS; |
| 479 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 480 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 481 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 482 | return; |
| 483 | } |
| 484 | } else { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 485 | pe_err("received Authentication frame for unsupported auth algorithm %d " |
| 486 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 487 | rx_auth_frm_body->authAlgoNumber, |
| 488 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 489 | |
| 490 | /* |
| 491 | * Responding party does not support the |
| 492 | * authentication algorithm requested by sending party. |
| 493 | * Reject Authentication with StatusCode=13. |
| 494 | */ |
| 495 | auth_frame->authAlgoNumber = rx_auth_frm_body->authAlgoNumber; |
| 496 | auth_frame->authTransactionSeqNumber = |
| 497 | rx_auth_frm_body->authTransactionSeqNumber + 1; |
| 498 | auth_frame->authStatusCode = |
| 499 | eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS; |
| 500 | |
| 501 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
| 502 | mac_hdr->sa, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 503 | LIM_NO_WEP_IN_FC, |
| 504 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 505 | return; |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | static void lim_process_auth_frame_type2(tpAniSirGlobal mac_ctx, |
| 510 | tpSirMacMgmtHdr mac_hdr, |
| 511 | tSirMacAuthFrameBody *rx_auth_frm_body, |
| 512 | tSirMacAuthFrameBody *auth_frame, |
| 513 | uint8_t *plainbody, |
| 514 | uint8_t *body_ptr, uint16_t frame_len, |
| 515 | tpPESession pe_session) |
| 516 | { |
| 517 | uint8_t key_id, cfg_privacy_opt_imp; |
| 518 | uint32_t val, key_length = 8; |
| 519 | uint8_t defaultkey[SIR_MAC_KEY_LENGTH]; |
| 520 | struct tLimPreAuthNode *auth_node; |
yeshwanth sriram guntuka | 343a3f2 | 2017-07-27 18:30:18 +0530 | [diff] [blame] | 521 | uint8_t *encr_auth_frame; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 522 | |
| 523 | /* AuthFrame 2 */ |
| 524 | if (pe_session->limMlmState != eLIM_MLM_WT_AUTH_FRAME2_STATE) { |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 525 | /** |
| 526 | * Check if a Reassociation is in progress and this is a |
| 527 | * Pre-Auth frame |
| 528 | */ |
Rajeev Kumar | be5d7fd | 2016-04-15 14:35:12 -0700 | [diff] [blame] | 529 | if (LIM_IS_STA_ROLE(pe_session) && |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 530 | (pe_session->limSmeState == eLIM_SME_WT_REASSOC_STATE) && |
| 531 | (rx_auth_frm_body->authStatusCode == |
| 532 | eSIR_MAC_SUCCESS_STATUS) && |
| 533 | (pe_session->ftPEContext.pFTPreAuthReq != NULL) && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 534 | (!qdf_mem_cmp( |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 535 | pe_session->ftPEContext.pFTPreAuthReq->preAuthbssId, |
| 536 | mac_hdr->sa, sizeof(tSirMacAddr)))) { |
| 537 | |
| 538 | /* Update the FTIEs in the saved auth response */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 539 | pe_warn("rx PreAuth frm2 in smestate: %d from: %pM", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 540 | pe_session->limSmeState, mac_hdr->sa); |
| 541 | pe_session->ftPEContext.saved_auth_rsp_length = 0; |
| 542 | |
| 543 | if ((body_ptr != NULL) && (frame_len < MAX_FTIE_SIZE)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 544 | qdf_mem_copy( |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 545 | pe_session->ftPEContext.saved_auth_rsp, |
| 546 | body_ptr, frame_len); |
| 547 | pe_session->ftPEContext.saved_auth_rsp_length = |
| 548 | frame_len; |
| 549 | } |
Deepak Dhamdhere | 262d95a | 2016-01-10 16:36:53 -0800 | [diff] [blame] | 550 | } else { |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 551 | /* |
| 552 | * Received Auth frame2 in an unexpected state. |
| 553 | * Log error and ignore the frame. |
| 554 | */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 555 | pe_debug("rx Auth frm2 from peer in state: %d addr", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 556 | pe_session->limMlmState); |
| 557 | lim_print_mac_addr(mac_ctx, mac_hdr->sa, LOG1); |
| 558 | } |
| 559 | return; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 560 | } |
| 561 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 562 | if (qdf_mem_cmp((uint8_t *) mac_hdr->sa, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 563 | (uint8_t *) &mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr, |
| 564 | sizeof(tSirMacAddr))) { |
| 565 | /* |
| 566 | * Received Authentication frame from an entity |
| 567 | * other than one request was initiated. |
| 568 | * Wait until Authentication Failure Timeout. |
| 569 | */ |
| 570 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 571 | pe_warn("received Auth frame2 from unexpected peer" |
| 572 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(mac_hdr->sa)); |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 573 | return; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | if (rx_auth_frm_body->authStatusCode == |
| 577 | eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS) { |
| 578 | /* |
| 579 | * Interoperability workaround: Linksys WAP4400N is returning |
| 580 | * wrong authType in OpenAuth response in case of |
| 581 | * SharedKey AP configuration. Pretend we don't see that, |
| 582 | * so upper layer can fallback to SharedKey authType, |
| 583 | * and successfully connect to the AP. |
| 584 | */ |
| 585 | if (rx_auth_frm_body->authAlgoNumber != |
| 586 | mac_ctx->lim.gpLimMlmAuthReq->authType) { |
| 587 | rx_auth_frm_body->authAlgoNumber = |
| 588 | mac_ctx->lim.gpLimMlmAuthReq->authType; |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | if (rx_auth_frm_body->authAlgoNumber != |
| 593 | mac_ctx->lim.gpLimMlmAuthReq->authType) { |
| 594 | /* |
| 595 | * Received Authentication frame with an auth |
| 596 | * algorithm other than one requested. |
| 597 | * Wait until Authentication Failure Timeout. |
| 598 | */ |
| 599 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 600 | pe_warn("rx Auth frame2 for unexpected auth algo number %d " |
| 601 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 602 | rx_auth_frm_body->authAlgoNumber, |
| 603 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 604 | return; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | if (rx_auth_frm_body->authStatusCode != eSIR_MAC_SUCCESS_STATUS) { |
| 608 | /* |
| 609 | * Authentication failure. |
| 610 | * Return Auth confirm with received failure code to SME |
| 611 | */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 612 | pe_err("rx Auth frame from peer with failure code %d " |
| 613 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 614 | rx_auth_frm_body->authStatusCode, |
| 615 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 616 | lim_restore_from_auth_state(mac_ctx, eSIR_SME_AUTH_REFUSED, |
| 617 | rx_auth_frm_body->authStatusCode, |
| 618 | pe_session); |
| 619 | return; |
| 620 | } |
| 621 | |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 622 | if (lim_process_fils_auth_frame2(mac_ctx, pe_session, |
| 623 | rx_auth_frm_body)) { |
| 624 | lim_restore_from_auth_state(mac_ctx, eSIR_SME_SUCCESS, |
| 625 | rx_auth_frm_body->authStatusCode, pe_session); |
| 626 | return; |
| 627 | } |
| 628 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 629 | if (rx_auth_frm_body->authAlgoNumber == eSIR_OPEN_SYSTEM) { |
| 630 | pe_session->limCurrentAuthType = eSIR_OPEN_SYSTEM; |
| 631 | auth_node = lim_acquire_free_pre_auth_node(mac_ctx, |
| 632 | &mac_ctx->lim.gLimPreAuthTimerTable); |
| 633 | if (auth_node == NULL) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 634 | pe_warn("Max pre-auth nodes reached"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 635 | lim_print_mac_addr(mac_ctx, mac_hdr->sa, LOGW); |
| 636 | return; |
| 637 | } |
| 638 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 639 | pe_debug("Alloc new data: %p peer", auth_node); |
| 640 | lim_print_mac_addr(mac_ctx, mac_hdr->sa, LOGD); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 641 | qdf_mem_copy((uint8_t *) auth_node->peerMacAddr, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 642 | mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr, |
| 643 | sizeof(tSirMacAddr)); |
| 644 | auth_node->fTimerStarted = 0; |
| 645 | auth_node->authType = |
| 646 | mac_ctx->lim.gpLimMlmAuthReq->authType; |
| 647 | auth_node->seq_num = |
| 648 | ((mac_hdr->seqControl.seqNumHi << 4) | |
| 649 | (mac_hdr->seqControl.seqNumLo)); |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 650 | auth_node->timestamp = qdf_mc_timer_get_system_ticks(); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 651 | lim_add_pre_auth_node(mac_ctx, auth_node); |
| 652 | lim_restore_from_auth_state(mac_ctx, eSIR_SME_SUCCESS, |
| 653 | rx_auth_frm_body->authStatusCode, pe_session); |
| 654 | } else { |
| 655 | /* Shared key authentication */ |
| 656 | if (LIM_IS_AP_ROLE(pe_session)) |
| 657 | val = pe_session->privacy; |
| 658 | else if (wlan_cfg_get_int(mac_ctx, |
| 659 | WNI_CFG_PRIVACY_ENABLED, |
| 660 | &val) != eSIR_SUCCESS) |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 661 | pe_warn("couldnt retrieve Privacy option"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 662 | cfg_privacy_opt_imp = (uint8_t) val; |
| 663 | if (!cfg_privacy_opt_imp) { |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 664 | /* |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 665 | * Requesting STA does not have WEP implemented. |
| 666 | * Reject with unsupported authentication algo |
| 667 | * Status code & wait until auth failure timeout |
| 668 | */ |
| 669 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 670 | pe_err("rx Auth frm from peer for unsupported auth algo %d " |
| 671 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 672 | rx_auth_frm_body->authAlgoNumber, |
| 673 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 674 | |
| 675 | auth_frame->authAlgoNumber = |
| 676 | rx_auth_frm_body->authAlgoNumber; |
| 677 | auth_frame->authTransactionSeqNumber = |
| 678 | rx_auth_frm_body->authTransactionSeqNumber + 1; |
| 679 | auth_frame->authStatusCode = |
| 680 | eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS; |
| 681 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
| 682 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 683 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 684 | return; |
| 685 | } |
| 686 | if (rx_auth_frm_body->type != SIR_MAC_CHALLENGE_TEXT_EID) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 687 | pe_err("rx auth frm with invalid challenge txtie"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 688 | return; |
| 689 | } |
| 690 | if (wlan_cfg_get_int(mac_ctx, WNI_CFG_WEP_DEFAULT_KEYID, |
| 691 | &val) != eSIR_SUCCESS) |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 692 | pe_warn("could not retrieve Default key_id"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 693 | key_id = (uint8_t) val; |
| 694 | val = SIR_MAC_KEY_LENGTH; |
| 695 | if (LIM_IS_AP_ROLE(pe_session)) { |
| 696 | tpSirKeys key_ptr = |
| 697 | &pe_session->WEPKeyMaterial[key_id].key[0]; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 698 | qdf_mem_copy(defaultkey, key_ptr->key, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 699 | key_ptr->keyLength); |
| 700 | } else if (wlan_cfg_get_str(mac_ctx, |
| 701 | (uint16_t)(WNI_CFG_WEP_DEFAULT_KEY_1 + key_id), |
| 702 | defaultkey, &val) != eSIR_SUCCESS) { |
| 703 | /* Couldnt get Default key from CFG. */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 704 | pe_warn("cant retrieve Defaultkey"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 705 | auth_frame->authAlgoNumber = |
| 706 | rx_auth_frm_body->authAlgoNumber; |
| 707 | auth_frame->authTransactionSeqNumber = |
| 708 | rx_auth_frm_body->authTransactionSeqNumber + 1; |
| 709 | auth_frame->authStatusCode = |
| 710 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 711 | lim_send_auth_mgmt_frame(mac_ctx, |
| 712 | auth_frame, mac_hdr->sa, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 713 | LIM_NO_WEP_IN_FC, |
| 714 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 715 | lim_restore_from_auth_state(mac_ctx, |
| 716 | eSIR_SME_INVALID_WEP_DEFAULT_KEY, |
| 717 | eSIR_MAC_UNSPEC_FAILURE_REASON, |
| 718 | pe_session); |
| 719 | return; |
| 720 | } |
| 721 | key_length = val; |
| 722 | ((tpSirMacAuthFrameBody)plainbody)->authAlgoNumber = |
| 723 | sir_swap_u16if_needed(rx_auth_frm_body->authAlgoNumber); |
| 724 | ((tpSirMacAuthFrameBody)plainbody)->authTransactionSeqNumber = |
| 725 | sir_swap_u16if_needed((uint16_t)( |
| 726 | rx_auth_frm_body->authTransactionSeqNumber |
| 727 | + 1)); |
| 728 | ((tpSirMacAuthFrameBody)plainbody)->authStatusCode = |
| 729 | eSIR_MAC_SUCCESS_STATUS; |
| 730 | ((tpSirMacAuthFrameBody)plainbody)->type = |
| 731 | SIR_MAC_CHALLENGE_TEXT_EID; |
| 732 | ((tpSirMacAuthFrameBody)plainbody)->length = |
yeshwanth sriram guntuka | 343a3f2 | 2017-07-27 18:30:18 +0530 | [diff] [blame] | 733 | rx_auth_frm_body->length; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 734 | qdf_mem_copy((uint8_t *) ( |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 735 | (tpSirMacAuthFrameBody)plainbody)->challengeText, |
| 736 | rx_auth_frm_body->challengeText, |
yeshwanth sriram guntuka | 343a3f2 | 2017-07-27 18:30:18 +0530 | [diff] [blame] | 737 | rx_auth_frm_body->length); |
| 738 | encr_auth_frame = qdf_mem_malloc(rx_auth_frm_body->length + |
| 739 | LIM_ENCR_AUTH_INFO_LEN); |
| 740 | if (!encr_auth_frame) { |
| 741 | pe_err("failed to allocate memory"); |
| 742 | return; |
| 743 | } |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 744 | lim_encrypt_auth_frame(mac_ctx, key_id, |
| 745 | defaultkey, plainbody, |
| 746 | encr_auth_frame, key_length); |
| 747 | pe_session->limMlmState = eLIM_MLM_WT_AUTH_FRAME4_STATE; |
| 748 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, |
| 749 | pe_session->peSessionId, |
| 750 | pe_session->limMlmState)); |
| 751 | lim_send_auth_mgmt_frame(mac_ctx, |
| 752 | (tpSirMacAuthFrameBody)encr_auth_frame, |
yeshwanth sriram guntuka | 343a3f2 | 2017-07-27 18:30:18 +0530 | [diff] [blame] | 753 | mac_hdr->sa, rx_auth_frm_body->length, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 754 | pe_session, false); |
yeshwanth sriram guntuka | 343a3f2 | 2017-07-27 18:30:18 +0530 | [diff] [blame] | 755 | qdf_mem_free(encr_auth_frame); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 756 | return; |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | static void lim_process_auth_frame_type3(tpAniSirGlobal mac_ctx, |
| 761 | tpSirMacMgmtHdr mac_hdr, |
| 762 | tSirMacAuthFrameBody *rx_auth_frm_body, |
| 763 | tSirMacAuthFrameBody *auth_frame, |
| 764 | tpPESession pe_session) |
| 765 | { |
| 766 | struct tLimPreAuthNode *auth_node; |
| 767 | |
| 768 | /* AuthFrame 3 */ |
| 769 | if (rx_auth_frm_body->authAlgoNumber != eSIR_SHARED_KEY) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 770 | pe_err("rx Auth frame3 from peer with auth algo number %d " |
| 771 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 772 | rx_auth_frm_body->authAlgoNumber, |
| 773 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 774 | /* |
| 775 | * Received Authentication frame3 with algorithm other than |
| 776 | * Shared Key authentication type. Reject with Auth frame4 |
| 777 | * with 'out of sequence' status code. |
| 778 | */ |
| 779 | auth_frame->authAlgoNumber = eSIR_SHARED_KEY; |
| 780 | auth_frame->authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_4; |
| 781 | auth_frame->authStatusCode = |
| 782 | eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS; |
| 783 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 784 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 785 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 786 | return; |
| 787 | } |
| 788 | |
| 789 | if (LIM_IS_AP_ROLE(pe_session) || |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 790 | LIM_IS_IBSS_ROLE(pe_session)) { |
| 791 | /* |
| 792 | * Check if wep bit was set in FC. If not set, |
| 793 | * reject with Authentication frame4 with |
| 794 | * 'challenge failure' status code. |
| 795 | */ |
| 796 | if (!mac_hdr->fc.wep) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 797 | pe_err("received Auth frame3 from peer with no WEP bit set " |
| 798 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 799 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 800 | /* WEP bit is not set in FC of Auth Frame3 */ |
| 801 | auth_frame->authAlgoNumber = eSIR_SHARED_KEY; |
| 802 | auth_frame->authTransactionSeqNumber = |
| 803 | SIR_MAC_AUTH_FRAME_4; |
| 804 | auth_frame->authStatusCode = |
| 805 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 806 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
| 807 | mac_hdr->sa, |
| 808 | LIM_NO_WEP_IN_FC, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 809 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 810 | return; |
| 811 | } |
| 812 | |
| 813 | auth_node = lim_search_pre_auth_list(mac_ctx, mac_hdr->sa); |
| 814 | if (auth_node == NULL) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 815 | pe_warn("received AuthFrame3 from peer that has no preauth context " |
| 816 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 817 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 818 | /* |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 819 | * No 'pre-auth' context exists for this STA that sent |
| 820 | * an Authentication frame3. Send Auth frame4 with |
| 821 | * 'out of sequence' status code. |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 822 | */ |
| 823 | auth_frame->authAlgoNumber = eSIR_SHARED_KEY; |
| 824 | auth_frame->authTransactionSeqNumber = |
| 825 | SIR_MAC_AUTH_FRAME_4; |
| 826 | auth_frame->authStatusCode = |
| 827 | eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS; |
| 828 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 829 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 830 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 831 | return; |
| 832 | } |
| 833 | |
| 834 | if (auth_node->mlmState == eLIM_MLM_AUTH_RSP_TIMEOUT_STATE) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 835 | pe_warn("auth response timer timedout for peer " |
| 836 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 837 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 838 | /* |
| 839 | * Received Auth Frame3 after Auth Response timeout. |
| 840 | * Reject by sending Auth Frame4 with |
| 841 | * Auth respone timeout Status Code. |
| 842 | */ |
| 843 | auth_frame->authAlgoNumber = eSIR_SHARED_KEY; |
| 844 | auth_frame->authTransactionSeqNumber = |
| 845 | SIR_MAC_AUTH_FRAME_4; |
| 846 | auth_frame->authStatusCode = |
| 847 | eSIR_MAC_AUTH_RSP_TIMEOUT_STATUS; |
| 848 | |
| 849 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 850 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 851 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 852 | /* Delete pre-auth context of STA */ |
| 853 | lim_delete_pre_auth_node(mac_ctx, mac_hdr->sa); |
| 854 | return; |
| 855 | } |
| 856 | if (rx_auth_frm_body->authStatusCode != |
| 857 | eSIR_MAC_SUCCESS_STATUS) { |
| 858 | /* |
| 859 | * Received Authenetication Frame 3 with status code |
| 860 | * other than success. Wait until Auth response timeout |
| 861 | * to delete STA context. |
| 862 | */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 863 | pe_err("rx Auth frm3 from peer with status code %d " |
| 864 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 865 | rx_auth_frm_body->authStatusCode, |
| 866 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 867 | return; |
| 868 | } |
| 869 | /* |
| 870 | * Check if received challenge text is same as one sent in |
| 871 | * Authentication frame3 |
| 872 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 873 | if (!qdf_mem_cmp(rx_auth_frm_body->challengeText, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 874 | auth_node->challengeText, |
| 875 | SIR_MAC_AUTH_CHALLENGE_LENGTH)) { |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 876 | /* |
| 877 | * Challenge match. STA is autheticated |
| 878 | * Delete Authentication response timer if running |
| 879 | */ |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 880 | lim_deactivate_and_change_per_sta_id_timer(mac_ctx, |
| 881 | eLIM_AUTH_RSP_TIMER, auth_node->authNodeIdx); |
| 882 | |
| 883 | auth_node->fTimerStarted = 0; |
| 884 | auth_node->mlmState = eLIM_MLM_AUTHENTICATED_STATE; |
| 885 | |
| 886 | /* |
| 887 | * Send Auth Frame4 with 'success' Status Code. |
| 888 | */ |
| 889 | auth_frame->authAlgoNumber = eSIR_SHARED_KEY; |
| 890 | auth_frame->authTransactionSeqNumber = |
| 891 | SIR_MAC_AUTH_FRAME_4; |
| 892 | auth_frame->authStatusCode = |
| 893 | eSIR_MAC_SUCCESS_STATUS; |
| 894 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 895 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 896 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 897 | return; |
| 898 | } else { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 899 | pe_warn("Challenge failure for peer "MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 900 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 901 | /* |
| 902 | * Challenge Failure. |
| 903 | * Send Authentication frame4 with 'challenge failure' |
| 904 | * status code and wait until Auth response timeout to |
| 905 | * delete STA context. |
| 906 | */ |
| 907 | auth_frame->authAlgoNumber = |
| 908 | rx_auth_frm_body->authAlgoNumber; |
| 909 | auth_frame->authTransactionSeqNumber = |
| 910 | SIR_MAC_AUTH_FRAME_4; |
| 911 | auth_frame->authStatusCode = |
| 912 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 913 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 914 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 915 | pe_session, false); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 916 | return; |
| 917 | } |
| 918 | } |
| 919 | } |
| 920 | |
| 921 | static void lim_process_auth_frame_type4(tpAniSirGlobal mac_ctx, |
| 922 | tpSirMacMgmtHdr mac_hdr, |
| 923 | tSirMacAuthFrameBody *rx_auth_frm_body, |
| 924 | tpPESession pe_session) |
| 925 | { |
| 926 | struct tLimPreAuthNode *auth_node; |
| 927 | |
| 928 | if (pe_session->limMlmState != eLIM_MLM_WT_AUTH_FRAME4_STATE) { |
| 929 | /* |
| 930 | * Received Authentication frame4 in an unexpected state. |
| 931 | * Log error and ignore the frame. |
| 932 | */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 933 | pe_warn("received unexpected Auth frame4 from peer in state %d, addr " |
| 934 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 935 | pe_session->limMlmState, |
| 936 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 937 | return; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | if (rx_auth_frm_body->authAlgoNumber != eSIR_SHARED_KEY) { |
| 941 | /* |
| 942 | * Received Authentication frame4 with algorithm other than |
| 943 | * Shared Key authentication type. |
| 944 | * Wait until Auth failure timeout to report authentication |
| 945 | * failure to SME. |
| 946 | */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 947 | pe_err("received Auth frame4 from peer with invalid auth algo %d" |
| 948 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 949 | rx_auth_frm_body->authAlgoNumber, |
| 950 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 951 | return; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 952 | } |
| 953 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 954 | if (qdf_mem_cmp((uint8_t *) mac_hdr->sa, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 955 | (uint8_t *) &mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr, |
| 956 | sizeof(tSirMacAddr))) { |
| 957 | /* |
| 958 | * Received Authentication frame from an entity |
| 959 | * other than one to which request was initiated. |
| 960 | * Wait until Authentication Failure Timeout. |
| 961 | */ |
| 962 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 963 | pe_warn("received Auth frame4 from unexpected peer "MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 964 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 965 | return; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | if (rx_auth_frm_body->authAlgoNumber != |
| 969 | mac_ctx->lim.gpLimMlmAuthReq->authType) { |
| 970 | /* |
| 971 | * Received Authentication frame with an auth algorithm |
| 972 | * other than one requested. |
| 973 | * Wait until Authentication Failure Timeout. |
| 974 | */ |
| 975 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 976 | pe_err("received Authentication frame from peer with invalid auth seq number %d " |
| 977 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 978 | rx_auth_frm_body->authTransactionSeqNumber, |
| 979 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 980 | return; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | if (rx_auth_frm_body->authStatusCode == eSIR_MAC_SUCCESS_STATUS) { |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 984 | /* |
| 985 | * Authentication Success, Inform SME of same. |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 986 | */ |
| 987 | pe_session->limCurrentAuthType = eSIR_SHARED_KEY; |
| 988 | auth_node = lim_acquire_free_pre_auth_node(mac_ctx, |
| 989 | &mac_ctx->lim.gLimPreAuthTimerTable); |
| 990 | if (auth_node == NULL) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 991 | pe_warn("Max pre-auth nodes reached"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 992 | lim_print_mac_addr(mac_ctx, mac_hdr->sa, LOGW); |
| 993 | return; |
| 994 | } |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 995 | pe_debug("Alloc new data: %p peer", auth_node); |
| 996 | lim_print_mac_addr(mac_ctx, mac_hdr->sa, LOGD); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 997 | qdf_mem_copy((uint8_t *) auth_node->peerMacAddr, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 998 | mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr, |
| 999 | sizeof(tSirMacAddr)); |
| 1000 | auth_node->fTimerStarted = 0; |
| 1001 | auth_node->authType = mac_ctx->lim.gpLimMlmAuthReq->authType; |
| 1002 | auth_node->seq_num = ((mac_hdr->seqControl.seqNumHi << 4) | |
| 1003 | (mac_hdr->seqControl.seqNumLo)); |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 1004 | auth_node->timestamp = qdf_mc_timer_get_system_ticks(); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1005 | lim_add_pre_auth_node(mac_ctx, auth_node); |
| 1006 | lim_restore_from_auth_state(mac_ctx, eSIR_SME_SUCCESS, |
| 1007 | rx_auth_frm_body->authStatusCode, pe_session); |
| 1008 | } else { |
| 1009 | /* |
| 1010 | * Authentication failure. |
| 1011 | * Return Auth confirm with received failure code to SME |
| 1012 | */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1013 | pe_err("Authentication failure from peer "MAC_ADDRESS_STR, |
| 1014 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1015 | lim_restore_from_auth_state(mac_ctx, eSIR_SME_AUTH_REFUSED, |
| 1016 | rx_auth_frm_body->authStatusCode, |
| 1017 | pe_session); |
| 1018 | } |
| 1019 | } |
| 1020 | |
yeshwanth sriram guntuka | fde0d52 | 2017-08-17 19:52:11 +0530 | [diff] [blame] | 1021 | void lim_send_open_system_auth(void *ctx, uint32_t param) |
| 1022 | { |
| 1023 | tLimMlmAuthReq *auth_req; |
| 1024 | tpPESession session_entry; |
| 1025 | tpAniSirGlobal mac_ctx = (tpAniSirGlobal)ctx; |
| 1026 | uint8_t session_id; |
| 1027 | |
| 1028 | session_id = mac_ctx->lim.limTimers.open_sys_auth_timer.sessionId; |
| 1029 | session_entry = pe_find_session_by_session_id(mac_ctx, session_id); |
| 1030 | |
| 1031 | if (!session_entry) |
| 1032 | return; |
| 1033 | /* Trigger MAC based Authentication */ |
| 1034 | auth_req = qdf_mem_malloc(sizeof(tLimMlmAuthReq)); |
| 1035 | if (!auth_req) { |
| 1036 | pe_err("mlmAuthReq :Memory alloc failed"); |
| 1037 | lim_handle_sme_join_result(mac_ctx, |
| 1038 | eSIR_SME_AUTH_TIMEOUT_RESULT_CODE, |
| 1039 | eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS, |
| 1040 | session_entry); |
| 1041 | tx_timer_deactivate(&mac_ctx->lim.limTimers. |
| 1042 | open_sys_auth_timer); |
| 1043 | return; |
| 1044 | } |
| 1045 | sir_copy_mac_addr(auth_req->peerMacAddr, session_entry->bssId); |
| 1046 | auth_req->authType = eSIR_OPEN_SYSTEM; |
| 1047 | /* Update PE session Id */ |
| 1048 | auth_req->sessionId = session_id; |
| 1049 | if (wlan_cfg_get_int(mac_ctx, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT, |
| 1050 | (uint32_t *) &auth_req->authFailureTimeout) != eSIR_SUCCESS) { |
| 1051 | pe_err("Fail:retrieve AuthFailureTimeout"); |
| 1052 | } |
| 1053 | lim_post_mlm_message(mac_ctx, LIM_MLM_AUTH_REQ, (uint32_t *) auth_req); |
| 1054 | tx_timer_deactivate(&mac_ctx->lim.limTimers.open_sys_auth_timer); |
| 1055 | |
| 1056 | } |
| 1057 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1058 | /** |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1059 | * lim_process_auth_frame() - to process auth frame |
| 1060 | * @mac_ctx - Pointer to Global MAC structure |
| 1061 | * @rx_pkt_info - A pointer to Rx packet info structure |
| 1062 | * @session - A pointer to session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1063 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1064 | * This function is called by limProcessMessageQueue() upon Authentication |
| 1065 | * frame reception. |
| 1066 | * |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1067 | * LOGIC: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1068 | * This function processes received Authentication frame and responds |
| 1069 | * with either next Authentication frame in sequence to peer MAC entity |
| 1070 | * or LIM_MLM_AUTH_IND on AP or LIM_MLM_AUTH_CNF on STA. |
| 1071 | * |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1072 | * NOTE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1073 | * 1. Authentication failures are reported to SME with same status code |
| 1074 | * received from the peer MAC entity. |
| 1075 | * 2. Authentication frame2/4 received with alogirthm number other than |
| 1076 | * one requested in frame1/3 are logged with an error and auth confirm |
| 1077 | * will be sent to SME only after auth failure timeout. |
| 1078 | * 3. Inconsistency in the spec: |
| 1079 | * On receiving Auth frame2, specs says that if WEP key mapping key |
| 1080 | * or default key is NULL, Auth frame3 with a status code 15 (challenge |
| 1081 | * failure to be returned to peer entity. However, section 7.2.3.10, |
| 1082 | * table 14 says that status code field is 'reserved' for frame3 ! |
| 1083 | * In the current implementation, Auth frame3 is returned with status |
| 1084 | * code 15 overriding section 7.2.3.10. |
| 1085 | * 4. If number pre-authentications reach configrable max limit, |
| 1086 | * Authentication frame with 'unspecified failure' status code is |
| 1087 | * returned to requesting entity. |
| 1088 | * |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1089 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1090 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1091 | void |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1092 | lim_process_auth_frame(tpAniSirGlobal mac_ctx, uint8_t *rx_pkt_info, |
| 1093 | tpPESession pe_session) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1094 | { |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1095 | uint8_t *body_ptr, key_id, cfg_privacy_opt_imp; |
| 1096 | uint8_t defaultkey[SIR_MAC_KEY_LENGTH]; |
Krishna Kumaar Natarajan | 9cc71e6 | 2017-07-24 21:08:29 -0700 | [diff] [blame] | 1097 | uint8_t plainbody[LIM_ENCR_AUTH_BODY_LEN]; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1098 | uint8_t decrypt_result; |
| 1099 | uint16_t frame_len, curr_seq_num = 0; |
| 1100 | uint32_t val, key_length = 8; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1101 | tSirMacAuthFrameBody *rx_auth_frm_body, *rx_auth_frame, *auth_frame; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1102 | tpSirMacMgmtHdr mac_hdr; |
| 1103 | struct tLimPreAuthNode *auth_node; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1104 | |
| 1105 | /* Get pointer to Authentication frame header and body */ |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1106 | mac_hdr = WMA_GET_RX_MAC_HEADER(rx_pkt_info); |
| 1107 | frame_len = WMA_GET_RX_PAYLOAD_LEN(rx_pkt_info); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1108 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1109 | if (!frame_len) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1110 | /* Log error */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1111 | pe_err("received Auth frame with no body from: %pM", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1112 | mac_hdr->sa); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1113 | return; |
| 1114 | } |
| 1115 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1116 | if (lim_is_group_addr(mac_hdr->sa)) { |
| 1117 | /* |
| 1118 | * Received Auth frame from a BC/MC address |
| 1119 | * Log error and ignore it |
| 1120 | */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1121 | pe_err("received Auth frame from a BC/MC addr: %pM", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1122 | mac_hdr->sa); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1123 | return; |
| 1124 | } |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1125 | curr_seq_num = (mac_hdr->seqControl.seqNumHi << 4) | |
| 1126 | (mac_hdr->seqControl.seqNumLo); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1127 | |
Srinivas Girigowda | 2b5d47c | 2017-03-29 00:28:46 -0700 | [diff] [blame] | 1128 | pe_info("Sessionid: %d System role: %d limMlmState: %d: Auth response Received BSSID: "MAC_ADDRESS_STR" RSSI: %d", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1129 | pe_session->peSessionId, GET_LIM_SYSTEM_ROLE(pe_session), |
| 1130 | pe_session->limMlmState, MAC_ADDR_ARRAY(mac_hdr->bssId), |
| 1131 | (uint) abs((int8_t) WMA_GET_RX_RSSI_NORMALIZED(rx_pkt_info))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1132 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1133 | body_ptr = WMA_GET_RX_MPDU_DATA(rx_pkt_info); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1134 | |
| 1135 | /* Restore default failure timeout */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1136 | if (QDF_P2P_CLIENT_MODE == pe_session->pePersona && |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1137 | pe_session->defaultAuthFailureTimeout) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1138 | pe_debug("Restore default failure timeout"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1139 | cfg_set_int(mac_ctx, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT, |
| 1140 | pe_session->defaultAuthFailureTimeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1141 | } |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1142 | |
| 1143 | rx_auth_frame = qdf_mem_malloc(sizeof(tSirMacAuthFrameBody)); |
| 1144 | if (!rx_auth_frame) { |
| 1145 | pe_err("failed to allocate memory"); |
| 1146 | return; |
| 1147 | } |
| 1148 | |
| 1149 | auth_frame = qdf_mem_malloc(sizeof(tSirMacAuthFrameBody)); |
| 1150 | if (!auth_frame) { |
| 1151 | pe_err("failed to allocate memory"); |
| 1152 | goto free; |
| 1153 | } |
| 1154 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1155 | /* |
| 1156 | * Determine if WEP bit is set in the FC or received MAC header |
| 1157 | * Note: WEP bit is set in FC of MAC header. |
| 1158 | */ |
| 1159 | if (mac_hdr->fc.wep) { |
| 1160 | /* |
| 1161 | * If TKIP counter measures enabled then issue Deauth |
| 1162 | * frame to station |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1163 | */ |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1164 | if (pe_session->bTkipCntrMeasActive && |
| 1165 | LIM_IS_AP_ROLE(pe_session)) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1166 | pe_err("Tkip counter enabled, send deauth to: %pM", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1167 | mac_hdr->sa); |
| 1168 | lim_send_deauth_mgmt_frame(mac_ctx, |
| 1169 | eSIR_MAC_MIC_FAILURE_REASON, |
| 1170 | mac_hdr->sa, pe_session, false); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1171 | goto free; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1172 | } |
| 1173 | /* Extract key ID from IV (most 2 bits of 4th byte of IV) */ |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1174 | key_id = (*(body_ptr + 3)) >> 6; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1175 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1176 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1177 | * On STA in infrastructure BSS, Authentication frames received |
| 1178 | * with WEP bit set in the FC must be rejected with challenge |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1179 | * failure status code (wierd thing in the spec - this should've |
| 1180 | * been rejected with unspecified failure/unexpected assertion |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1181 | * of wep bit (this status code does not exist though) or |
| 1182 | * Out-of-sequence-Authentication-Frame status code. |
| 1183 | */ |
Rajeev Kumar | be5d7fd | 2016-04-15 14:35:12 -0700 | [diff] [blame] | 1184 | if (LIM_IS_STA_ROLE(pe_session)) { |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1185 | auth_frame->authAlgoNumber = eSIR_SHARED_KEY; |
| 1186 | auth_frame->authTransactionSeqNumber = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1187 | SIR_MAC_AUTH_FRAME_4; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1188 | auth_frame->authStatusCode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1189 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
| 1190 | /* Log error */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1191 | pe_err("rx Auth frm with wep bit set role: %d %pM", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1192 | GET_LIM_SYSTEM_ROLE(pe_session), mac_hdr->sa); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1193 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1194 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 1195 | pe_session, false); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1196 | goto free; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1197 | } |
| 1198 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1199 | if (frame_len < LIM_ENCR_AUTH_BODY_LEN) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1200 | /* Log error */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1201 | pe_err("Not enough size: %d to decry rx Auth frm", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1202 | frame_len); |
| 1203 | lim_print_mac_addr(mac_ctx, mac_hdr->sa, LOGE); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1204 | goto free; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1205 | } |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1206 | if (LIM_IS_AP_ROLE(pe_session)) { |
| 1207 | val = pe_session->privacy; |
| 1208 | } else if (wlan_cfg_get_int(mac_ctx, WNI_CFG_PRIVACY_ENABLED, |
| 1209 | &val) != eSIR_SUCCESS) { |
| 1210 | /* |
| 1211 | * Accept Authentication frame only if Privacy is |
| 1212 | * implemented, if Could not get Privacy option |
| 1213 | * from CFG then Log fatal error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1214 | */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1215 | pe_warn("could not retrieve Privacy option"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1216 | } |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1217 | cfg_privacy_opt_imp = (uint8_t) val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1218 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1219 | if (!cfg_privacy_opt_imp) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1220 | pe_err("received Authentication frame3 from peer that while privacy option is turned OFF " |
| 1221 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1222 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 1223 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1224 | * Privacy option is not implemented. |
| 1225 | * So reject Authentication frame received with |
| 1226 | * WEP bit set by sending Authentication frame |
| 1227 | * with 'challenge failure' status code. This is |
| 1228 | * another strange thing in the spec. Status code |
| 1229 | * should have been 'unsupported algorithm' status code. |
| 1230 | */ |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1231 | auth_frame->authAlgoNumber = eSIR_SHARED_KEY; |
| 1232 | auth_frame->authTransactionSeqNumber = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1233 | SIR_MAC_AUTH_FRAME_4; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1234 | auth_frame->authStatusCode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1235 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1236 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1237 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 1238 | pe_session, false); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1239 | goto free; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1240 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1241 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1242 | /* |
| 1243 | * Privacy option is implemented. Check if the received frame is |
| 1244 | * Authentication frame3 and there is a context for requesting |
| 1245 | * STA. If not, reject with unspecified failure status code |
| 1246 | */ |
| 1247 | auth_node = lim_search_pre_auth_list(mac_ctx, mac_hdr->sa); |
| 1248 | if (auth_node == NULL) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1249 | pe_err("rx Auth frame with no preauth ctx with WEP bit set " |
| 1250 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1251 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 1252 | /* |
| 1253 | * No 'pre-auth' context exists for this STA |
| 1254 | * that sent an Authentication frame with FC |
| 1255 | * bit set. Send Auth frame4 with |
| 1256 | * 'out of sequence' status code. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1257 | */ |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1258 | auth_frame->authAlgoNumber = eSIR_SHARED_KEY; |
| 1259 | auth_frame->authTransactionSeqNumber = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1260 | SIR_MAC_AUTH_FRAME_4; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1261 | auth_frame->authStatusCode = |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1262 | eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1263 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1264 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 1265 | pe_session, false); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1266 | goto free; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1267 | } |
| 1268 | /* Change the auth-response timeout */ |
| 1269 | lim_deactivate_and_change_per_sta_id_timer(mac_ctx, |
| 1270 | eLIM_AUTH_RSP_TIMER, auth_node->authNodeIdx); |
| 1271 | |
| 1272 | /* 'Pre-auth' status exists for STA */ |
| 1273 | if ((auth_node->mlmState != eLIM_MLM_WT_AUTH_FRAME3_STATE) && |
| 1274 | (auth_node->mlmState != |
| 1275 | eLIM_MLM_AUTH_RSP_TIMEOUT_STATE)) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1276 | pe_err("received Authentication frame from peer that is in state %d " |
| 1277 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1278 | auth_node->mlmState, |
| 1279 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 1280 | /* |
| 1281 | * Should not have received Authentication frame |
| 1282 | * with WEP bit set in FC in other states. |
| 1283 | * Reject by sending Authenticaton frame with |
| 1284 | * out of sequence Auth frame status code. |
| 1285 | */ |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1286 | auth_frame->authAlgoNumber = eSIR_SHARED_KEY; |
| 1287 | auth_frame->authTransactionSeqNumber = |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1288 | SIR_MAC_AUTH_FRAME_4; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1289 | auth_frame->authStatusCode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1290 | eSIR_MAC_AUTH_FRAME_OUT_OF_SEQ_STATUS; |
| 1291 | |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1292 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1293 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 1294 | pe_session, false); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1295 | goto free; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1296 | } |
| 1297 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1298 | val = SIR_MAC_KEY_LENGTH; |
| 1299 | |
| 1300 | if (LIM_IS_AP_ROLE(pe_session)) { |
| 1301 | tpSirKeys key_ptr; |
| 1302 | key_ptr = &pe_session->WEPKeyMaterial[key_id].key[0]; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1303 | qdf_mem_copy(defaultkey, key_ptr->key, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1304 | key_ptr->keyLength); |
| 1305 | val = key_ptr->keyLength; |
| 1306 | } else if (wlan_cfg_get_str(mac_ctx, |
| 1307 | (uint16_t) (WNI_CFG_WEP_DEFAULT_KEY_1 + key_id), |
| 1308 | defaultkey, &val) != eSIR_SUCCESS) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1309 | pe_warn("could not retrieve Default key"); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1310 | |
| 1311 | /* |
| 1312 | * Send Authentication frame |
| 1313 | * with challenge failure status code |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1314 | */ |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1315 | auth_frame->authAlgoNumber = eSIR_SHARED_KEY; |
| 1316 | auth_frame->authTransactionSeqNumber = |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1317 | SIR_MAC_AUTH_FRAME_4; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1318 | auth_frame->authStatusCode = |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1319 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1320 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1321 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 1322 | pe_session, false); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1323 | goto free; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1324 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1325 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1326 | key_length = val; |
| 1327 | decrypt_result = lim_decrypt_auth_frame(mac_ctx, defaultkey, |
| 1328 | body_ptr, plainbody, key_length, |
| 1329 | (uint16_t) (frame_len - |
| 1330 | SIR_MAC_WEP_IV_LENGTH)); |
| 1331 | if (decrypt_result == LIM_DECRYPT_ICV_FAIL) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1332 | pe_err("received Authentication frame from peer that failed decryption: " |
| 1333 | MAC_ADDRESS_STR, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1334 | MAC_ADDR_ARRAY(mac_hdr->sa)); |
| 1335 | /* ICV failure */ |
| 1336 | lim_delete_pre_auth_node(mac_ctx, mac_hdr->sa); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1337 | auth_frame->authAlgoNumber = eSIR_SHARED_KEY; |
| 1338 | auth_frame->authTransactionSeqNumber = |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1339 | SIR_MAC_AUTH_FRAME_4; |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1340 | auth_frame->authStatusCode = |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1341 | eSIR_MAC_CHALLENGE_FAILURE_STATUS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1342 | |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1343 | lim_send_auth_mgmt_frame(mac_ctx, auth_frame, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1344 | mac_hdr->sa, LIM_NO_WEP_IN_FC, |
| 1345 | pe_session, false); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1346 | goto free; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1347 | } |
| 1348 | if ((sir_convert_auth_frame2_struct(mac_ctx, plainbody, |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1349 | frame_len - 8, rx_auth_frame) != eSIR_SUCCESS) |
| 1350 | || (!is_auth_valid(mac_ctx, rx_auth_frame, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1351 | pe_session))) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1352 | pe_err("failed to convert Auth Frame to structure or Auth is not valid"); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1353 | goto free; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1354 | } |
| 1355 | } else if ((sir_convert_auth_frame2_struct(mac_ctx, body_ptr, |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1356 | frame_len, rx_auth_frame) != eSIR_SUCCESS) |
| 1357 | || (!is_auth_valid(mac_ctx, rx_auth_frame, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1358 | pe_session))) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1359 | pe_err("failed to convert Auth Frame to structure or Auth is not valid"); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1360 | goto free; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1361 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1362 | |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1363 | rx_auth_frm_body = rx_auth_frame; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1364 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1365 | pe_debug("Received Auth frame with type: %d seqnum: %d status: %d %d", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1366 | (uint32_t) rx_auth_frm_body->authAlgoNumber, |
| 1367 | (uint32_t) rx_auth_frm_body->authTransactionSeqNumber, |
| 1368 | (uint32_t) rx_auth_frm_body->authStatusCode, |
| 1369 | (uint32_t) mac_ctx->lim.gLimNumPreAuthContexts); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1370 | |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1371 | if (!lim_is_valid_fils_auth_frame(mac_ctx, pe_session, |
| 1372 | rx_auth_frm_body)) { |
| 1373 | pe_err("Received invalid FILS auth packet"); |
| 1374 | goto free; |
| 1375 | } |
| 1376 | |
Rajeev Kumar | 9b755ef | 2016-04-14 15:32:21 -0700 | [diff] [blame] | 1377 | /* |
| 1378 | * IOT Workaround: with invalid WEP key, some APs reply |
| 1379 | * AuthFrame 4 with invalid seqNumber. This AuthFrame |
| 1380 | * will be dropped by driver, thus driver sends the |
| 1381 | * generic status code instead of protocol status code. |
| 1382 | * As a workaround, override AuthFrame 4's seqNumber. |
| 1383 | */ |
| 1384 | if ((pe_session->limMlmState == |
| 1385 | eLIM_MLM_WT_AUTH_FRAME4_STATE) && |
| 1386 | (rx_auth_frm_body->authTransactionSeqNumber != |
| 1387 | SIR_MAC_AUTH_FRAME_1) && |
| 1388 | (rx_auth_frm_body->authTransactionSeqNumber != |
| 1389 | SIR_MAC_AUTH_FRAME_2) && |
| 1390 | (rx_auth_frm_body->authTransactionSeqNumber != |
| 1391 | SIR_MAC_AUTH_FRAME_3)) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1392 | pe_warn("Override AuthFrame 4's seqNumber to 4"); |
Rajeev Kumar | 9b755ef | 2016-04-14 15:32:21 -0700 | [diff] [blame] | 1393 | rx_auth_frm_body->authTransactionSeqNumber = |
| 1394 | SIR_MAC_AUTH_FRAME_4; |
| 1395 | } |
| 1396 | |
| 1397 | |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1398 | switch (rx_auth_frm_body->authTransactionSeqNumber) { |
| 1399 | case SIR_MAC_AUTH_FRAME_1: |
| 1400 | lim_process_auth_frame_type1(mac_ctx, |
| 1401 | mac_hdr, rx_auth_frm_body, rx_pkt_info, |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1402 | curr_seq_num, auth_frame, pe_session); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1403 | break; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1404 | case SIR_MAC_AUTH_FRAME_2: |
| 1405 | lim_process_auth_frame_type2(mac_ctx, |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1406 | mac_hdr, rx_auth_frm_body, auth_frame, plainbody, |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1407 | body_ptr, frame_len, pe_session); |
| 1408 | break; |
| 1409 | case SIR_MAC_AUTH_FRAME_3: |
| 1410 | lim_process_auth_frame_type3(mac_ctx, |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1411 | mac_hdr, rx_auth_frm_body, auth_frame, pe_session); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1412 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1413 | case SIR_MAC_AUTH_FRAME_4: |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1414 | lim_process_auth_frame_type4(mac_ctx, |
| 1415 | mac_hdr, rx_auth_frm_body, pe_session); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1416 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1417 | default: |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1418 | /* Invalid Authentication Frame received. Ignore it. */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1419 | pe_warn("rx auth frm with invalid authseq no: %d from: %pM", |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1420 | rx_auth_frm_body->authTransactionSeqNumber, |
| 1421 | mac_hdr->sa); |
Krunal Soni | 7ff8603 | 2016-01-19 19:20:55 -0800 | [diff] [blame] | 1422 | break; |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1423 | } |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame^] | 1424 | free: |
| 1425 | if (auth_frame) |
| 1426 | qdf_mem_free(auth_frame); |
| 1427 | if (rx_auth_frame) |
| 1428 | qdf_mem_free(rx_auth_frame); |
Krunal Soni | a8f946d | 2016-01-06 20:06:06 -0800 | [diff] [blame] | 1429 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1430 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1431 | /*---------------------------------------------------------------------- |
| 1432 | * |
| 1433 | * Pass the received Auth frame. This is possibly the pre-auth from the |
| 1434 | * neighbor AP, in the same mobility domain. |
| 1435 | * This will be used in case of 11r FT. |
| 1436 | * |
| 1437 | * !!!! This is going to be renoved for the next checkin. We will be creating |
| 1438 | * the session before sending out the Auth. Thus when auth response |
| 1439 | * is received we will have a session in progress. !!!!! |
| 1440 | ***---------------------------------------------------------------------- |
| 1441 | */ |
| 1442 | tSirRetStatus lim_process_auth_frame_no_session(tpAniSirGlobal pMac, uint8_t *pBd, |
| 1443 | void *body) |
| 1444 | { |
| 1445 | tpSirMacMgmtHdr pHdr; |
| 1446 | tpPESession psessionEntry = NULL; |
| 1447 | uint8_t *pBody; |
| 1448 | uint16_t frameLen; |
| 1449 | tSirMacAuthFrameBody rxAuthFrame; |
| 1450 | tSirMacAuthFrameBody *pRxAuthFrameBody = NULL; |
| 1451 | tSirRetStatus ret_status = eSIR_FAILURE; |
| 1452 | int i; |
| 1453 | |
| 1454 | pHdr = WMA_GET_RX_MAC_HEADER(pBd); |
| 1455 | pBody = WMA_GET_RX_MPDU_DATA(pBd); |
| 1456 | frameLen = WMA_GET_RX_PAYLOAD_LEN(pBd); |
| 1457 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1458 | pe_info("Auth Frame Received: BSSID " MAC_ADDRESS_STR " (RSSI %d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1459 | MAC_ADDR_ARRAY(pHdr->bssId), |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 1460 | (uint) abs((int8_t) WMA_GET_RX_RSSI_NORMALIZED(pBd))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1461 | |
| 1462 | /* Auth frame has come on a new BSS, however, we need to find the session |
| 1463 | * from where the auth-req was sent to the new AP |
| 1464 | */ |
| 1465 | for (i = 0; i < pMac->lim.maxBssId; i++) { |
| 1466 | /* Find first free room in session table */ |
| 1467 | if (pMac->lim.gpSession[i].valid == true && |
| 1468 | pMac->lim.gpSession[i].ftPEContext.ftPreAuthSession == |
| 1469 | true) { |
| 1470 | /* Found the session */ |
| 1471 | psessionEntry = &pMac->lim.gpSession[i]; |
| 1472 | pMac->lim.gpSession[i].ftPEContext.ftPreAuthSession = |
| 1473 | false; |
| 1474 | } |
| 1475 | } |
| 1476 | |
| 1477 | if (psessionEntry == NULL) { |
Varun Reddy Yeturu | aa5a80c | 2017-05-23 18:40:07 -0700 | [diff] [blame] | 1478 | pe_debug("cannot find session id in FT pre-auth phase"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1479 | return eSIR_FAILURE; |
| 1480 | } |
| 1481 | |
| 1482 | if (psessionEntry->ftPEContext.pFTPreAuthReq == NULL) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1483 | pe_err("Error: No FT"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1484 | /* No FT in progress. */ |
| 1485 | return eSIR_FAILURE; |
| 1486 | } |
| 1487 | |
| 1488 | if (frameLen == 0) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1489 | pe_err("Error: Frame len = 0"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1490 | return eSIR_FAILURE; |
| 1491 | } |
Nishank Aggarwal | abfd70b | 2017-03-11 16:48:25 +0530 | [diff] [blame] | 1492 | lim_print_mac_addr(pMac, pHdr->bssId, LOGD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1493 | lim_print_mac_addr(pMac, |
| 1494 | psessionEntry->ftPEContext.pFTPreAuthReq->preAuthbssId, |
Nishank Aggarwal | abfd70b | 2017-03-11 16:48:25 +0530 | [diff] [blame] | 1495 | LOGD); |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1496 | pe_debug("seqControl: 0x%X", |
Deepak Dhamdhere | 26bda45 | 2016-01-09 22:54:48 -0800 | [diff] [blame] | 1497 | ((pHdr->seqControl.seqNumHi << 8) | |
| 1498 | (pHdr->seqControl.seqNumLo << 4) | |
| 1499 | (pHdr->seqControl.fragNum))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1500 | |
| 1501 | /* Check that its the same bssId we have for preAuth */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1502 | if (qdf_mem_cmp |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1503 | (psessionEntry->ftPEContext.pFTPreAuthReq->preAuthbssId, |
| 1504 | pHdr->bssId, sizeof(tSirMacAddr))) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1505 | pe_err("Error: Same bssid as preauth BSSID"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1506 | /* In this case SME if indeed has triggered a */ |
| 1507 | /* pre auth it will time out. */ |
| 1508 | return eSIR_FAILURE; |
| 1509 | } |
| 1510 | |
| 1511 | if (true == |
| 1512 | psessionEntry->ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed) { |
| 1513 | /* |
| 1514 | * This is likely a duplicate for the same pre-auth request. |
| 1515 | * PE/LIM already posted a response to SME. Hence, drop it. |
| 1516 | * TBD: |
| 1517 | * 1) How did we even receive multiple auth responses? |
| 1518 | * 2) Do we need to delete pre-auth session? Suppose we |
| 1519 | * previously received an auth resp with failure which |
| 1520 | * would not have created the session and forwarded to SME. |
| 1521 | * And, we subsequently received an auth resp with success |
| 1522 | * which would have created the session. This will now be |
| 1523 | * dropped without being forwarded to SME! However, it is |
| 1524 | * very unlikely to receive auth responses from the same |
| 1525 | * AP with different reason codes. |
| 1526 | * NOTE: return eSIR_SUCCESS so that the packet is dropped |
| 1527 | * as this was indeed a response from the BSSID we tried to |
| 1528 | * pre-auth. |
| 1529 | */ |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1530 | pe_debug("Auth rsp already posted to SME" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1531 | " (session %p, FT session %p)", psessionEntry, |
| 1532 | psessionEntry); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1533 | return eSIR_SUCCESS; |
| 1534 | } else { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1535 | pe_warn("Auth rsp not yet posted to SME" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1536 | " (session %p, FT session %p)", psessionEntry, |
| 1537 | psessionEntry); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1538 | psessionEntry->ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed = |
| 1539 | true; |
| 1540 | } |
| 1541 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1542 | pe_debug("Pre-Auth response received from neighbor"); |
| 1543 | pe_debug("Pre-Auth done state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1544 | /* Stopping timer now, that we have our unicast from the AP */ |
| 1545 | /* of our choice. */ |
| 1546 | lim_deactivate_and_change_timer(pMac, eLIM_FT_PREAUTH_RSP_TIMER); |
| 1547 | |
| 1548 | /* Save off the auth resp. */ |
| 1549 | if ((sir_convert_auth_frame2_struct(pMac, pBody, frameLen, &rxAuthFrame) != |
| 1550 | eSIR_SUCCESS)) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1551 | pe_err("failed to convert Auth frame to struct"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1552 | lim_handle_ft_pre_auth_rsp(pMac, eSIR_FAILURE, NULL, 0, |
| 1553 | psessionEntry); |
| 1554 | return eSIR_FAILURE; |
| 1555 | } |
| 1556 | pRxAuthFrameBody = &rxAuthFrame; |
| 1557 | |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1558 | pe_debug("Received Auth frame with type: %d seqnum: %d status: %d %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1559 | (uint32_t) pRxAuthFrameBody->authAlgoNumber, |
| 1560 | (uint32_t) pRxAuthFrameBody->authTransactionSeqNumber, |
| 1561 | (uint32_t) pRxAuthFrameBody->authStatusCode, |
| 1562 | (uint32_t) pMac->lim.gLimNumPreAuthContexts); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1563 | switch (pRxAuthFrameBody->authTransactionSeqNumber) { |
| 1564 | case SIR_MAC_AUTH_FRAME_2: |
| 1565 | if (pRxAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS) { |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1566 | pe_err("Auth status code received is %d", |
Deepak Dhamdhere | 26bda45 | 2016-01-09 22:54:48 -0800 | [diff] [blame] | 1567 | (uint32_t) pRxAuthFrameBody->authStatusCode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1568 | if (eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS == |
| 1569 | pRxAuthFrameBody->authStatusCode) |
| 1570 | ret_status = eSIR_LIM_MAX_STA_REACHED_ERROR; |
| 1571 | } else { |
| 1572 | ret_status = eSIR_SUCCESS; |
| 1573 | } |
| 1574 | break; |
| 1575 | |
| 1576 | default: |
Nishank Aggarwal | 2dfc519 | 2017-03-24 20:20:15 +0530 | [diff] [blame] | 1577 | pe_warn("Seq. no incorrect expected 2 received %d", |
Deepak Dhamdhere | 26bda45 | 2016-01-09 22:54:48 -0800 | [diff] [blame] | 1578 | (uint32_t) pRxAuthFrameBody->authTransactionSeqNumber); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1579 | break; |
| 1580 | } |
| 1581 | |
| 1582 | /* Send the Auth response to SME */ |
| 1583 | lim_handle_ft_pre_auth_rsp(pMac, ret_status, pBody, frameLen, psessionEntry); |
| 1584 | |
| 1585 | return ret_status; |
| 1586 | } |