blob: 01b1c38e9b1bc44c7ea2f8a82694025f869a3c54 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Yeshwanth Sriram Guntuka04ed7502019-08-06 17:03:40 +05302 * Copyright (c) 2012-2017, 2019 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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.
Kiet Lamaa8e15a2014-02-11 23:30:06 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080022/*
Kiet Lam842dad02014-02-18 18:44:02 -080023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * This file limProcessDisassocFrame.cc contains the code
30 * for processing Disassocation Frame.
31 * Author: Chandra Modumudi
32 * Date: 03/24/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 *
37 */
38#include "palTypes.h"
39#include "wniApi.h"
40#include "sirApi.h"
41#include "aniGlobal.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053042#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44#include "utilsApi.h"
45#include "limTypes.h"
46#include "limUtils.h"
47#include "limAssocUtils.h"
48#include "limSecurityUtils.h"
49#include "limSerDesUtils.h"
50#include "limSendMessages.h"
51#include "schApi.h"
Padma, Santhosh Kumar071de2d2017-02-02 20:38:03 +053052#ifdef WLAN_FEATURE_LFR_MBB
53#include "lim_mbb.h"
54#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56
57/**
58 * limProcessDisassocFrame
59 *
60 *FUNCTION:
61 * This function is called by limProcessMessageQueue() upon
62 * Disassociation frame reception.
63 *
64 *LOGIC:
65 *
66 *ASSUMPTIONS:
67 * DPH drops packets for STA with 'valid' bit in pStaDs set to '0'.
68 *
69 *NOTE:
70 *
71 * @param pMac - Pointer to Global MAC structure
72 * @param *pRxPacketInfo - A pointer to Rx packet info structure
73 * @return None
74 */
75void
76limProcessDisassocFrame(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tpPESession psessionEntry)
77{
78 tANI_U8 *pBody;
79 tANI_U16 aid, reasonCode;
80 tpSirMacMgmtHdr pHdr;
81 tpDphHashNode pStaDs;
82 tLimMlmDisassocInd mlmDisassocInd;
Yeshwanth Sriram Guntuka04ed7502019-08-06 17:03:40 +053083 tANI_U32 frame_len;
Jeff Johnson295189b2012-06-20 16:38:30 -070084
85 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
86 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
Yeshwanth Sriram Guntuka04ed7502019-08-06 17:03:40 +053087 frame_len = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
88
89 if (frame_len < 2) {
90 limLog(pMac, LOGE, FL("frame len less than 2"));
91 return;
92 }
Jeff Johnson295189b2012-06-20 16:38:30 -070093
Jeff Johnson295189b2012-06-20 16:38:30 -070094 if (limIsGroupAddr(pHdr->sa))
95 {
96 // Received Disassoc frame from a BC/MC address
97 // Log error and ignore it
Kaushik, Sushant2c823f92014-07-18 16:47:48 +053098 PELOGE(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -070099 FL("received Disassoc frame from a BC/MC address"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700100
101 return;
102 }
103
104 if (limIsGroupAddr(pHdr->da) && !limIsAddrBC(pHdr->da))
105 {
106 // Received Disassoc frame for a MC address
107 // Log error and ignore it
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530108 PELOGE(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700109 FL("received Disassoc frame for a MC address"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700110
111 return;
112 }
113
Hanumanth Reddy Pothulaf4b44992017-11-23 15:26:28 +0530114 if (LIM_IS_STA_ROLE(psessionEntry) &&
115 ((eLIM_SME_WT_DISASSOC_STATE == psessionEntry->limSmeState) ||
116 (eLIM_SME_WT_DEAUTH_STATE == psessionEntry->limSmeState))) {
117 PELOGE(limLog(pMac, LOG1,
118 FL("recevied disaasoc frame in %d limsmestate... droping this"),
119 psessionEntry->limSmeState);)
120 return;
121 }
122
123
Chet Lanctot186b5732013-03-18 10:26:30 -0700124#ifdef WLAN_FEATURE_11W
125 /* PMF: If this session is a PMF session, then ensure that this frame was protected */
126 if(psessionEntry->limRmfEnabled && (WDA_GET_RX_DPU_FEEDBACK(pRxPacketInfo) & DPU_FEEDBACK_UNPROTECTED_ERROR))
127 {
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530128 PELOGE(limLog(pMac, LOG1, FL("received an unprotected disassoc from AP"));)
Chet Lanctot186b5732013-03-18 10:26:30 -0700129 // If the frame received is unprotected, forward it to the supplicant to initiate
130 // an SA query
Chet Lanctot186b5732013-03-18 10:26:30 -0700131 //send the unprotected frame indication to SME
132 limSendSmeUnprotectedMgmtFrameInd( pMac, pHdr->fc.subType,
Yeshwanth Sriram Guntuka04ed7502019-08-06 17:03:40 +0530133 (tANI_U8*)pHdr, (frame_len + sizeof(tSirMacMgmtHdr)),
Chet Lanctot186b5732013-03-18 10:26:30 -0700134 psessionEntry->smeSessionId, psessionEntry);
135 return;
136 }
137#endif
138
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 // Get reasonCode from Disassociation frame body
140 reasonCode = sirReadU16(pBody);
141
Abhishek Singh525045c2014-12-15 17:18:45 +0530142 limLog(pMac, LOGE,
143 FL("Received Disassoc frame for Addr: "MAC_ADDRESS_STR
144 "(mlm state=%s, sme state=%d),"
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530145 "with reason code %d from "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->da),
Abhishek Singh525045c2014-12-15 17:18:45 +0530146 limMlmStateStr(psessionEntry->limMlmState), psessionEntry->limSmeState,
147 reasonCode, MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700148
149 /**
150 * Extract 'associated' context for STA, if any.
151 * This is maintained by DPH and created by LIM.
152 */
153 pStaDs = dphLookupHashEntry(pMac, pHdr->sa, &aid, &psessionEntry->dph.dphHashTable);
154
155 if (pStaDs == NULL)
156 {
157 /**
158 * Disassociating STA is not associated.
159 * Log error.
160 */
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530161 PELOGE(limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530162 FL("received Disassoc frame from STA that does not have context "
163 "reasonCode=%d, addr "MAC_ADDRESS_STR),
164 reasonCode,MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700165
166 return;
167 }
168
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -0800169 if (limCheckDisassocDeauthAckPending(pMac, (tANI_U8*)pHdr->sa))
170 {
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530171 PELOGE(limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530172 FL("Ignore the DisAssoc received, while waiting "
173 "for ack of disassoc/deauth"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -0800174 limCleanUpDisassocDeauthReq(pMac,(tANI_U8*)pHdr->sa, 1);
175 return;
176 }
177
Padma, Santhosh Kumar071de2d2017-02-02 20:38:03 +0530178#ifdef WLAN_FEATURE_LFR_MBB
179 if (lim_is_mbb_reassoc_in_progress(pMac, psessionEntry)) {
180 limLog(pMac, LOGE, FL("Ignore Disassoc frame as LFR MBB in progress"));
181 return;
182 }
183#endif
184
Jeff Johnson295189b2012-06-20 16:38:30 -0700185 /** If we are in the Wait for ReAssoc Rsp state */
186 if (limIsReassocInProgress(pMac,psessionEntry)) {
187 /** If we had received the DisAssoc from,
188 * a. the Current AP during ReAssociate to different AP in same ESS
189 * b. Unknown AP
190 * drop/ignore the DisAssoc received
191 */
192 if (!IS_REASSOC_BSSID(pMac,pHdr->sa,psessionEntry)) {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530193 PELOGE(limLog(pMac, LOGE, FL("Ignore the DisAssoc received, while "
194 "Processing ReAssoc with different/unknown AP"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 return;
196 }
197 /** If the Disassoc is received from the new AP to which we tried to ReAssociate
198 * Drop ReAssoc and Restore the Previous context( current connected AP).
199 */
200 if (!IS_CURRENT_BSSID(pMac, pHdr->sa,psessionEntry)) {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530201 PELOGE(limLog(pMac, LOGE, FL("received Disassoc from the New AP to "
202 "which ReAssoc is sent "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700203 limRestorePreReassocState(pMac,
204 eSIR_SME_REASSOC_REFUSED, reasonCode,psessionEntry);
205 return;
206 }
207 }
208
gaurank kathpalia524f2732019-04-04 14:32:19 +0530209 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE) &&
210 psessionEntry->limMlmState == eLIM_MLM_WT_ADD_STA_RSP_STATE) {
211 PELOGE(limLog(pMac, LOGE, FL("received Disassoc from the AP in"
212 "add sta response state, disconnecting"));)
213 psessionEntry->fDeauthReceived = true;
214 return;
215 }
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
218 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
219 {
220 switch (reasonCode)
221 {
222 case eSIR_MAC_UNSPEC_FAILURE_REASON:
223 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
224 case eSIR_MAC_DISASSOC_LEAVING_BSS_REASON:
225 case eSIR_MAC_MIC_FAILURE_REASON:
226 case eSIR_MAC_4WAY_HANDSHAKE_TIMEOUT_REASON:
227 case eSIR_MAC_GR_KEY_UPDATE_TIMEOUT_REASON:
228 case eSIR_MAC_RSN_IE_MISMATCH_REASON:
229 case eSIR_MAC_1X_AUTH_FAILURE_REASON:
230 // Valid reasonCode in received Disassociation frame
231 break;
232
233 default:
234 // Invalid reasonCode in received Disassociation frame
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530235 PELOGE(limLog(pMac, LOGE,
236 FL("received Disassoc frame with invalid reasonCode "
237 "%d from "MAC_ADDRESS_STR),
238 reasonCode, MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 break;
240 }
241 }
242 else if ( ((psessionEntry->limSystemRole == eLIM_STA_ROLE) ||
243 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
244 ((psessionEntry->limSmeState != eLIM_SME_WT_JOIN_STATE) &&
245 (psessionEntry->limSmeState != eLIM_SME_WT_AUTH_STATE) &&
246 (psessionEntry->limSmeState != eLIM_SME_WT_ASSOC_STATE) &&
247 (psessionEntry->limSmeState != eLIM_SME_WT_REASSOC_STATE) ))
248 {
249 switch (reasonCode)
250 {
251 case eSIR_MAC_UNSPEC_FAILURE_REASON:
252 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
253 case eSIR_MAC_DISASSOC_DUE_TO_DISABILITY_REASON:
254 case eSIR_MAC_CLASS2_FRAME_FROM_NON_AUTH_STA_REASON:
255 case eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_REASON:
256 case eSIR_MAC_MIC_FAILURE_REASON:
257 case eSIR_MAC_4WAY_HANDSHAKE_TIMEOUT_REASON:
258 case eSIR_MAC_GR_KEY_UPDATE_TIMEOUT_REASON:
259 case eSIR_MAC_RSN_IE_MISMATCH_REASON:
260 case eSIR_MAC_1X_AUTH_FAILURE_REASON:
Chet Lanctot186b5732013-03-18 10:26:30 -0700261 case eSIR_MAC_PREV_AUTH_NOT_VALID_REASON:
Sreelakshmi Konamki3c589502016-07-21 11:14:53 +0530262 case eSIR_MAC_PEER_REJECT_MECHANISIM_REASON:
Jeff Johnson295189b2012-06-20 16:38:30 -0700263 // Valid reasonCode in received Disassociation frame
264 break;
265
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -0700266 case eSIR_MAC_DEAUTH_LEAVING_BSS_REASON:
Jeff Johnson295189b2012-06-20 16:38:30 -0700267 case eSIR_MAC_DISASSOC_LEAVING_BSS_REASON:
268 // Valid reasonCode in received Disassociation frame
269 // as long as we're not about to channel switch
Jeff Johnsone7245742012-09-05 17:12:55 -0700270 if(psessionEntry->gLimChannelSwitch.state != eLIM_CHANNEL_SWITCH_IDLE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530272 limLog(pMac, LOGE,
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 FL("Ignoring disassoc frame due to upcoming "
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530274 "channel switch, from "MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 return;
276 }
277 break;
278
279 default:
280 // Invalid reasonCode in received Disassociation frame
281 // Log error and ignore the frame
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530282 PELOGE(limLog(pMac, LOGE,
283 FL("received Disassoc frame with invalid reasonCode "
284 "%d from "MAC_ADDRESS_STR), reasonCode,
285 MAC_ADDR_ARRAY(pHdr->sa));)
Sreelakshmi Konamki3c589502016-07-21 11:14:53 +0530286 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 }
288 }
289 else
290 {
291 // Received Disassociation frame in either IBSS
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -0700292 // or un-known role. Log and ignore it
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530293 limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530294 FL("received Disassoc frame with invalid reasonCode %d in role "
295 "%d in sme state %d from "MAC_ADDRESS_STR), reasonCode,
296 psessionEntry->limSystemRole, psessionEntry->limSmeState,
297 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700298
299 return;
300 }
301
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 if ((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
Pankaj Singh84fe6732020-01-14 20:27:47 +0530303 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE) ||
304 pStaDs->sta_deletion_in_progress)
Jeff Johnson295189b2012-06-20 16:38:30 -0700305 {
306 /**
307 * Already in the process of deleting context for the peer
308 * and received Disassociation frame. Log and Ignore.
309 */
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530310 PELOGE(limLog(pMac, LOGE,
Sachin Ahuja60a50612015-04-20 17:55:08 +0530311 FL("received Disassoc frame in state %d from "MAC_ADDRESS_STR
312 ",isDisassocDeauthInProgress : %d\n"),
313 pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa),
314 pStaDs->isDisassocDeauthInProgress);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700315
316 return;
317 }
Pankaj Singh84fe6732020-01-14 20:27:47 +0530318 pStaDs->sta_deletion_in_progress = true;
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 if (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE)
320 {
321 /**
322 * Requesting STA is in some 'transient' state?
323 * Log error.
324 */
Abhishek Singh50f7b422014-05-05 12:19:03 +0530325 if (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_ASSOC_CNF_STATE)
326 pStaDs->mlmStaContext.updateContext = 1;
327
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530328 PELOGE(limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +0530329 FL("received Disassoc frame from peer that is in state %d, addr "
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530330 MAC_ADDRESS_STR),
331 pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
Abhishek Singh50f7b422014-05-05 12:19:03 +0530332
Jeff Johnson295189b2012-06-20 16:38:30 -0700333 } // if (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE)
334
335 pStaDs->mlmStaContext.cleanupTrigger = eLIM_PEER_ENTITY_DISASSOC;
336 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes) reasonCode;
337
338 // Issue Disassoc Indication to SME.
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530339 vos_mem_copy((tANI_U8 *) &mlmDisassocInd.peerMacAddr,
340 (tANI_U8 *) pStaDs->staAddr,
341 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700342 mlmDisassocInd.reasonCode =
343 (tANI_U8) pStaDs->mlmStaContext.disassocReason;
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 mlmDisassocInd.disassocTrigger = eLIM_PEER_ENTITY_DISASSOC;
345
346 /* Update PE session Id */
347 mlmDisassocInd.sessionId = psessionEntry->peSessionId;
348
349 if (limIsReassocInProgress(pMac,psessionEntry)) {
350
351 /* If we're in the middle of ReAssoc and received disassoc from
352 * the ReAssoc AP, then notify SME by sending REASSOC_RSP with
353 * failure result code. By design, SME will then issue "Disassoc"
354 * and cleanup will happen at that time.
355 */
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530356 PELOGE(limLog(pMac, LOGE, FL("received Disassoc from AP while waiting "
357 "for Reassoc Rsp"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700358
359 if (psessionEntry->limAssocResponseData) {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530360 vos_mem_free(psessionEntry->limAssocResponseData);
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 psessionEntry->limAssocResponseData = NULL;
362 }
363
364 limRestorePreReassocState(pMac,eSIR_SME_REASSOC_REFUSED, reasonCode,psessionEntry);
365 return;
366 }
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +0530367 limUpdateLostLinkParams(pMac, psessionEntry, pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700368 limPostSmeMessage(pMac, LIM_MLM_DISASSOC_IND,
369 (tANI_U32 *) &mlmDisassocInd);
370
371
372 // send eWNI_SME_DISASSOC_IND to SME
373 limSendSmeDisassocInd(pMac, pStaDs,psessionEntry);
374
375 return;
376} /*** end limProcessDisassocFrame() ***/
377