blob: 805ad5f0cde04460bde283da26fe8c68cd840938 [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
206 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
207 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
208 {
209 switch (reasonCode)
210 {
211 case eSIR_MAC_UNSPEC_FAILURE_REASON:
212 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
213 case eSIR_MAC_DISASSOC_LEAVING_BSS_REASON:
214 case eSIR_MAC_MIC_FAILURE_REASON:
215 case eSIR_MAC_4WAY_HANDSHAKE_TIMEOUT_REASON:
216 case eSIR_MAC_GR_KEY_UPDATE_TIMEOUT_REASON:
217 case eSIR_MAC_RSN_IE_MISMATCH_REASON:
218 case eSIR_MAC_1X_AUTH_FAILURE_REASON:
219 // Valid reasonCode in received Disassociation frame
220 break;
221
222 default:
223 // Invalid reasonCode in received Disassociation frame
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530224 PELOGE(limLog(pMac, LOGE,
225 FL("received Disassoc frame with invalid reasonCode "
226 "%d from "MAC_ADDRESS_STR),
227 reasonCode, MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 break;
229 }
230 }
231 else if ( ((psessionEntry->limSystemRole == eLIM_STA_ROLE) ||
232 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
233 ((psessionEntry->limSmeState != eLIM_SME_WT_JOIN_STATE) &&
234 (psessionEntry->limSmeState != eLIM_SME_WT_AUTH_STATE) &&
235 (psessionEntry->limSmeState != eLIM_SME_WT_ASSOC_STATE) &&
236 (psessionEntry->limSmeState != eLIM_SME_WT_REASSOC_STATE) ))
237 {
238 switch (reasonCode)
239 {
240 case eSIR_MAC_UNSPEC_FAILURE_REASON:
241 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
242 case eSIR_MAC_DISASSOC_DUE_TO_DISABILITY_REASON:
243 case eSIR_MAC_CLASS2_FRAME_FROM_NON_AUTH_STA_REASON:
244 case eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_REASON:
245 case eSIR_MAC_MIC_FAILURE_REASON:
246 case eSIR_MAC_4WAY_HANDSHAKE_TIMEOUT_REASON:
247 case eSIR_MAC_GR_KEY_UPDATE_TIMEOUT_REASON:
248 case eSIR_MAC_RSN_IE_MISMATCH_REASON:
249 case eSIR_MAC_1X_AUTH_FAILURE_REASON:
Chet Lanctot186b5732013-03-18 10:26:30 -0700250 case eSIR_MAC_PREV_AUTH_NOT_VALID_REASON:
Sreelakshmi Konamki3c589502016-07-21 11:14:53 +0530251 case eSIR_MAC_PEER_REJECT_MECHANISIM_REASON:
Jeff Johnson295189b2012-06-20 16:38:30 -0700252 // Valid reasonCode in received Disassociation frame
253 break;
254
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -0700255 case eSIR_MAC_DEAUTH_LEAVING_BSS_REASON:
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 case eSIR_MAC_DISASSOC_LEAVING_BSS_REASON:
257 // Valid reasonCode in received Disassociation frame
258 // as long as we're not about to channel switch
Jeff Johnsone7245742012-09-05 17:12:55 -0700259 if(psessionEntry->gLimChannelSwitch.state != eLIM_CHANNEL_SWITCH_IDLE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700260 {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530261 limLog(pMac, LOGE,
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 FL("Ignoring disassoc frame due to upcoming "
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530263 "channel switch, from "MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 return;
265 }
266 break;
267
268 default:
269 // Invalid reasonCode in received Disassociation frame
270 // Log error and ignore the frame
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530271 PELOGE(limLog(pMac, LOGE,
272 FL("received Disassoc frame with invalid reasonCode "
273 "%d from "MAC_ADDRESS_STR), reasonCode,
274 MAC_ADDR_ARRAY(pHdr->sa));)
Sreelakshmi Konamki3c589502016-07-21 11:14:53 +0530275 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 }
277 }
278 else
279 {
280 // Received Disassociation frame in either IBSS
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -0700281 // or un-known role. Log and ignore it
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530282 limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530283 FL("received Disassoc frame with invalid reasonCode %d in role "
284 "%d in sme state %d from "MAC_ADDRESS_STR), reasonCode,
285 psessionEntry->limSystemRole, psessionEntry->limSmeState,
286 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288 return;
289 }
290
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 if ((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
Sushant Kaushikefe08fa2015-07-06 14:54:09 +0530292 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE))
Jeff Johnson295189b2012-06-20 16:38:30 -0700293 {
294 /**
295 * Already in the process of deleting context for the peer
296 * and received Disassociation frame. Log and Ignore.
297 */
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530298 PELOGE(limLog(pMac, LOGE,
Sachin Ahuja60a50612015-04-20 17:55:08 +0530299 FL("received Disassoc frame in state %d from "MAC_ADDRESS_STR
300 ",isDisassocDeauthInProgress : %d\n"),
301 pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa),
302 pStaDs->isDisassocDeauthInProgress);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700303
304 return;
305 }
306
307 if (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE)
308 {
309 /**
310 * Requesting STA is in some 'transient' state?
311 * Log error.
312 */
Abhishek Singh50f7b422014-05-05 12:19:03 +0530313 if (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_ASSOC_CNF_STATE)
314 pStaDs->mlmStaContext.updateContext = 1;
315
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530316 PELOGE(limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +0530317 FL("received Disassoc frame from peer that is in state %d, addr "
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530318 MAC_ADDRESS_STR),
319 pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
Abhishek Singh50f7b422014-05-05 12:19:03 +0530320
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 } // if (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE)
322
323 pStaDs->mlmStaContext.cleanupTrigger = eLIM_PEER_ENTITY_DISASSOC;
324 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes) reasonCode;
325
326 // Issue Disassoc Indication to SME.
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530327 vos_mem_copy((tANI_U8 *) &mlmDisassocInd.peerMacAddr,
328 (tANI_U8 *) pStaDs->staAddr,
329 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 mlmDisassocInd.reasonCode =
331 (tANI_U8) pStaDs->mlmStaContext.disassocReason;
Jeff Johnson295189b2012-06-20 16:38:30 -0700332 mlmDisassocInd.disassocTrigger = eLIM_PEER_ENTITY_DISASSOC;
333
334 /* Update PE session Id */
335 mlmDisassocInd.sessionId = psessionEntry->peSessionId;
336
337 if (limIsReassocInProgress(pMac,psessionEntry)) {
338
339 /* If we're in the middle of ReAssoc and received disassoc from
340 * the ReAssoc AP, then notify SME by sending REASSOC_RSP with
341 * failure result code. By design, SME will then issue "Disassoc"
342 * and cleanup will happen at that time.
343 */
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530344 PELOGE(limLog(pMac, LOGE, FL("received Disassoc from AP while waiting "
345 "for Reassoc Rsp"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700346
347 if (psessionEntry->limAssocResponseData) {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530348 vos_mem_free(psessionEntry->limAssocResponseData);
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 psessionEntry->limAssocResponseData = NULL;
350 }
351
352 limRestorePreReassocState(pMac,eSIR_SME_REASSOC_REFUSED, reasonCode,psessionEntry);
353 return;
354 }
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +0530355 limUpdateLostLinkParams(pMac, psessionEntry, pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 limPostSmeMessage(pMac, LIM_MLM_DISASSOC_IND,
357 (tANI_U32 *) &mlmDisassocInd);
358
359
360 // send eWNI_SME_DISASSOC_IND to SME
361 limSendSmeDisassocInd(pMac, pStaDs,psessionEntry);
362
363 return;
364} /*** end limProcessDisassocFrame() ***/
365