blob: 88ca7f8aa049e67a4e793157702f4d0913f4adff [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Padma, Santhosh Kumar071de2d2017-02-02 20:38:03 +05302 * Copyright (c) 2012-2017 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;
Chet Lanctot186b5732013-03-18 10:26:30 -070083#ifdef WLAN_FEATURE_11W
84 tANI_U32 frameLen;
85#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070086
87 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
88 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
89
Jeff Johnson295189b2012-06-20 16:38:30 -070090 if (limIsGroupAddr(pHdr->sa))
91 {
92 // Received Disassoc frame from a BC/MC address
93 // Log error and ignore it
Kaushik, Sushant2c823f92014-07-18 16:47:48 +053094 PELOGE(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -070095 FL("received Disassoc frame from a BC/MC address"));)
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97 return;
98 }
99
100 if (limIsGroupAddr(pHdr->da) && !limIsAddrBC(pHdr->da))
101 {
102 // Received Disassoc frame for a MC address
103 // Log error and ignore it
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530104 PELOGE(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700105 FL("received Disassoc frame for a MC address"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700106
107 return;
108 }
109
Hanumanth Reddy Pothulaf4b44992017-11-23 15:26:28 +0530110 if (LIM_IS_STA_ROLE(psessionEntry) &&
111 ((eLIM_SME_WT_DISASSOC_STATE == psessionEntry->limSmeState) ||
112 (eLIM_SME_WT_DEAUTH_STATE == psessionEntry->limSmeState))) {
113 PELOGE(limLog(pMac, LOG1,
114 FL("recevied disaasoc frame in %d limsmestate... droping this"),
115 psessionEntry->limSmeState);)
116 return;
117 }
118
119
Chet Lanctot186b5732013-03-18 10:26:30 -0700120#ifdef WLAN_FEATURE_11W
121 /* PMF: If this session is a PMF session, then ensure that this frame was protected */
122 if(psessionEntry->limRmfEnabled && (WDA_GET_RX_DPU_FEEDBACK(pRxPacketInfo) & DPU_FEEDBACK_UNPROTECTED_ERROR))
123 {
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530124 PELOGE(limLog(pMac, LOG1, FL("received an unprotected disassoc from AP"));)
Chet Lanctot186b5732013-03-18 10:26:30 -0700125 // If the frame received is unprotected, forward it to the supplicant to initiate
126 // an SA query
127 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
128 //send the unprotected frame indication to SME
129 limSendSmeUnprotectedMgmtFrameInd( pMac, pHdr->fc.subType,
130 (tANI_U8*)pHdr, (frameLen + sizeof(tSirMacMgmtHdr)),
131 psessionEntry->smeSessionId, psessionEntry);
132 return;
133 }
134#endif
135
Jeff Johnson295189b2012-06-20 16:38:30 -0700136 // Get reasonCode from Disassociation frame body
137 reasonCode = sirReadU16(pBody);
138
Abhishek Singh525045c2014-12-15 17:18:45 +0530139 limLog(pMac, LOGE,
140 FL("Received Disassoc frame for Addr: "MAC_ADDRESS_STR
141 "(mlm state=%s, sme state=%d),"
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530142 "with reason code %d from "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->da),
Abhishek Singh525045c2014-12-15 17:18:45 +0530143 limMlmStateStr(psessionEntry->limMlmState), psessionEntry->limSmeState,
144 reasonCode, MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700145
146 /**
147 * Extract 'associated' context for STA, if any.
148 * This is maintained by DPH and created by LIM.
149 */
150 pStaDs = dphLookupHashEntry(pMac, pHdr->sa, &aid, &psessionEntry->dph.dphHashTable);
151
152 if (pStaDs == NULL)
153 {
154 /**
155 * Disassociating STA is not associated.
156 * Log error.
157 */
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530158 PELOGE(limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530159 FL("received Disassoc frame from STA that does not have context "
160 "reasonCode=%d, addr "MAC_ADDRESS_STR),
161 reasonCode,MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700162
163 return;
164 }
165
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -0800166 if (limCheckDisassocDeauthAckPending(pMac, (tANI_U8*)pHdr->sa))
167 {
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530168 PELOGE(limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530169 FL("Ignore the DisAssoc received, while waiting "
170 "for ack of disassoc/deauth"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -0800171 limCleanUpDisassocDeauthReq(pMac,(tANI_U8*)pHdr->sa, 1);
172 return;
173 }
174
Padma, Santhosh Kumar071de2d2017-02-02 20:38:03 +0530175#ifdef WLAN_FEATURE_LFR_MBB
176 if (lim_is_mbb_reassoc_in_progress(pMac, psessionEntry)) {
177 limLog(pMac, LOGE, FL("Ignore Disassoc frame as LFR MBB in progress"));
178 return;
179 }
180#endif
181
Jeff Johnson295189b2012-06-20 16:38:30 -0700182 /** If we are in the Wait for ReAssoc Rsp state */
183 if (limIsReassocInProgress(pMac,psessionEntry)) {
184 /** If we had received the DisAssoc from,
185 * a. the Current AP during ReAssociate to different AP in same ESS
186 * b. Unknown AP
187 * drop/ignore the DisAssoc received
188 */
189 if (!IS_REASSOC_BSSID(pMac,pHdr->sa,psessionEntry)) {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530190 PELOGE(limLog(pMac, LOGE, FL("Ignore the DisAssoc received, while "
191 "Processing ReAssoc with different/unknown AP"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 return;
193 }
194 /** If the Disassoc is received from the new AP to which we tried to ReAssociate
195 * Drop ReAssoc and Restore the Previous context( current connected AP).
196 */
197 if (!IS_CURRENT_BSSID(pMac, pHdr->sa,psessionEntry)) {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530198 PELOGE(limLog(pMac, LOGE, FL("received Disassoc from the New AP to "
199 "which ReAssoc is sent "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700200 limRestorePreReassocState(pMac,
201 eSIR_SME_REASSOC_REFUSED, reasonCode,psessionEntry);
202 return;
203 }
204 }
205
gaurank kathpalia524f2732019-04-04 14:32:19 +0530206 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE) &&
207 psessionEntry->limMlmState == eLIM_MLM_WT_ADD_STA_RSP_STATE) {
208 PELOGE(limLog(pMac, LOGE, FL("received Disassoc from the AP in"
209 "add sta response state, disconnecting"));)
210 psessionEntry->fDeauthReceived = true;
211 return;
212 }
213
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
215 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
216 {
217 switch (reasonCode)
218 {
219 case eSIR_MAC_UNSPEC_FAILURE_REASON:
220 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
221 case eSIR_MAC_DISASSOC_LEAVING_BSS_REASON:
222 case eSIR_MAC_MIC_FAILURE_REASON:
223 case eSIR_MAC_4WAY_HANDSHAKE_TIMEOUT_REASON:
224 case eSIR_MAC_GR_KEY_UPDATE_TIMEOUT_REASON:
225 case eSIR_MAC_RSN_IE_MISMATCH_REASON:
226 case eSIR_MAC_1X_AUTH_FAILURE_REASON:
227 // Valid reasonCode in received Disassociation frame
228 break;
229
230 default:
231 // Invalid reasonCode in received Disassociation frame
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530232 PELOGE(limLog(pMac, LOGE,
233 FL("received Disassoc frame with invalid reasonCode "
234 "%d from "MAC_ADDRESS_STR),
235 reasonCode, MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 break;
237 }
238 }
239 else if ( ((psessionEntry->limSystemRole == eLIM_STA_ROLE) ||
240 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
241 ((psessionEntry->limSmeState != eLIM_SME_WT_JOIN_STATE) &&
242 (psessionEntry->limSmeState != eLIM_SME_WT_AUTH_STATE) &&
243 (psessionEntry->limSmeState != eLIM_SME_WT_ASSOC_STATE) &&
244 (psessionEntry->limSmeState != eLIM_SME_WT_REASSOC_STATE) ))
245 {
246 switch (reasonCode)
247 {
248 case eSIR_MAC_UNSPEC_FAILURE_REASON:
249 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
250 case eSIR_MAC_DISASSOC_DUE_TO_DISABILITY_REASON:
251 case eSIR_MAC_CLASS2_FRAME_FROM_NON_AUTH_STA_REASON:
252 case eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_REASON:
253 case eSIR_MAC_MIC_FAILURE_REASON:
254 case eSIR_MAC_4WAY_HANDSHAKE_TIMEOUT_REASON:
255 case eSIR_MAC_GR_KEY_UPDATE_TIMEOUT_REASON:
256 case eSIR_MAC_RSN_IE_MISMATCH_REASON:
257 case eSIR_MAC_1X_AUTH_FAILURE_REASON:
Chet Lanctot186b5732013-03-18 10:26:30 -0700258 case eSIR_MAC_PREV_AUTH_NOT_VALID_REASON:
Sreelakshmi Konamki3c589502016-07-21 11:14:53 +0530259 case eSIR_MAC_PEER_REJECT_MECHANISIM_REASON:
Jeff Johnson295189b2012-06-20 16:38:30 -0700260 // Valid reasonCode in received Disassociation frame
261 break;
262
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -0700263 case eSIR_MAC_DEAUTH_LEAVING_BSS_REASON:
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 case eSIR_MAC_DISASSOC_LEAVING_BSS_REASON:
265 // Valid reasonCode in received Disassociation frame
266 // as long as we're not about to channel switch
Jeff Johnsone7245742012-09-05 17:12:55 -0700267 if(psessionEntry->gLimChannelSwitch.state != eLIM_CHANNEL_SWITCH_IDLE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700268 {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530269 limLog(pMac, LOGE,
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 FL("Ignoring disassoc frame due to upcoming "
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530271 "channel switch, from "MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 return;
273 }
274 break;
275
276 default:
277 // Invalid reasonCode in received Disassociation frame
278 // Log error and ignore the frame
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530279 PELOGE(limLog(pMac, LOGE,
280 FL("received Disassoc frame with invalid reasonCode "
281 "%d from "MAC_ADDRESS_STR), reasonCode,
282 MAC_ADDR_ARRAY(pHdr->sa));)
Sreelakshmi Konamki3c589502016-07-21 11:14:53 +0530283 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 }
285 }
286 else
287 {
288 // Received Disassociation frame in either IBSS
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -0700289 // or un-known role. Log and ignore it
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530290 limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530291 FL("received Disassoc frame with invalid reasonCode %d in role "
292 "%d in sme state %d from "MAC_ADDRESS_STR), reasonCode,
293 psessionEntry->limSystemRole, psessionEntry->limSmeState,
294 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700295
296 return;
297 }
298
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 if ((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
Sushant Kaushikefe08fa2015-07-06 14:54:09 +0530300 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE))
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 {
302 /**
303 * Already in the process of deleting context for the peer
304 * and received Disassociation frame. Log and Ignore.
305 */
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530306 PELOGE(limLog(pMac, LOGE,
Sachin Ahuja60a50612015-04-20 17:55:08 +0530307 FL("received Disassoc frame in state %d from "MAC_ADDRESS_STR
308 ",isDisassocDeauthInProgress : %d\n"),
309 pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa),
310 pStaDs->isDisassocDeauthInProgress);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700311
312 return;
313 }
314
315 if (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE)
316 {
317 /**
318 * Requesting STA is in some 'transient' state?
319 * Log error.
320 */
Abhishek Singh50f7b422014-05-05 12:19:03 +0530321 if (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_ASSOC_CNF_STATE)
322 pStaDs->mlmStaContext.updateContext = 1;
323
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530324 PELOGE(limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +0530325 FL("received Disassoc frame from peer that is in state %d, addr "
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530326 MAC_ADDRESS_STR),
327 pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
Abhishek Singh50f7b422014-05-05 12:19:03 +0530328
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 } // if (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE)
330
331 pStaDs->mlmStaContext.cleanupTrigger = eLIM_PEER_ENTITY_DISASSOC;
332 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes) reasonCode;
333
334 // Issue Disassoc Indication to SME.
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530335 vos_mem_copy((tANI_U8 *) &mlmDisassocInd.peerMacAddr,
336 (tANI_U8 *) pStaDs->staAddr,
337 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 mlmDisassocInd.reasonCode =
339 (tANI_U8) pStaDs->mlmStaContext.disassocReason;
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 mlmDisassocInd.disassocTrigger = eLIM_PEER_ENTITY_DISASSOC;
341
342 /* Update PE session Id */
343 mlmDisassocInd.sessionId = psessionEntry->peSessionId;
344
345 if (limIsReassocInProgress(pMac,psessionEntry)) {
346
347 /* If we're in the middle of ReAssoc and received disassoc from
348 * the ReAssoc AP, then notify SME by sending REASSOC_RSP with
349 * failure result code. By design, SME will then issue "Disassoc"
350 * and cleanup will happen at that time.
351 */
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530352 PELOGE(limLog(pMac, LOGE, FL("received Disassoc from AP while waiting "
353 "for Reassoc Rsp"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700354
355 if (psessionEntry->limAssocResponseData) {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530356 vos_mem_free(psessionEntry->limAssocResponseData);
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 psessionEntry->limAssocResponseData = NULL;
358 }
359
360 limRestorePreReassocState(pMac,eSIR_SME_REASSOC_REFUSED, reasonCode,psessionEntry);
361 return;
362 }
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +0530363 limUpdateLostLinkParams(pMac, psessionEntry, pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700364 limPostSmeMessage(pMac, LIM_MLM_DISASSOC_IND,
365 (tANI_U32 *) &mlmDisassocInd);
366
367
368 // send eWNI_SME_DISASSOC_IND to SME
369 limSendSmeDisassocInd(pMac, pStaDs,psessionEntry);
370
371 return;
372} /*** end limProcessDisassocFrame() ***/
373