blob: 32e15b2abf51838e8b251330dbea880a8e995aaf [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Satyanarayana Dash6f438272015-03-03 18:01:06 +05302 * Copyright (c) 2012-2015 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"
52
53
54/**
55 * limProcessDisassocFrame
56 *
57 *FUNCTION:
58 * This function is called by limProcessMessageQueue() upon
59 * Disassociation frame reception.
60 *
61 *LOGIC:
62 *
63 *ASSUMPTIONS:
64 * DPH drops packets for STA with 'valid' bit in pStaDs set to '0'.
65 *
66 *NOTE:
67 *
68 * @param pMac - Pointer to Global MAC structure
69 * @param *pRxPacketInfo - A pointer to Rx packet info structure
70 * @return None
71 */
72void
73limProcessDisassocFrame(tpAniSirGlobal pMac, tANI_U8 *pRxPacketInfo, tpPESession psessionEntry)
74{
75 tANI_U8 *pBody;
76 tANI_U16 aid, reasonCode;
77 tpSirMacMgmtHdr pHdr;
78 tpDphHashNode pStaDs;
79 tLimMlmDisassocInd mlmDisassocInd;
Chet Lanctot186b5732013-03-18 10:26:30 -070080#ifdef WLAN_FEATURE_11W
81 tANI_U32 frameLen;
82#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070083
84 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
85 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
86
87
88 if (limIsGroupAddr(pHdr->sa))
89 {
90 // Received Disassoc frame from a BC/MC address
91 // Log error and ignore it
Kaushik, Sushant2c823f92014-07-18 16:47:48 +053092 PELOGE(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -070093 FL("received Disassoc frame from a BC/MC address"));)
Jeff Johnson295189b2012-06-20 16:38:30 -070094
95 return;
96 }
97
98 if (limIsGroupAddr(pHdr->da) && !limIsAddrBC(pHdr->da))
99 {
100 // Received Disassoc frame for a MC address
101 // Log error and ignore it
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530102 PELOGE(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700103 FL("received Disassoc frame for a MC address"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
105 return;
106 }
107
Chet Lanctot186b5732013-03-18 10:26:30 -0700108#ifdef WLAN_FEATURE_11W
109 /* PMF: If this session is a PMF session, then ensure that this frame was protected */
110 if(psessionEntry->limRmfEnabled && (WDA_GET_RX_DPU_FEEDBACK(pRxPacketInfo) & DPU_FEEDBACK_UNPROTECTED_ERROR))
111 {
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530112 PELOGE(limLog(pMac, LOG1, FL("received an unprotected disassoc from AP"));)
Chet Lanctot186b5732013-03-18 10:26:30 -0700113 // If the frame received is unprotected, forward it to the supplicant to initiate
114 // an SA query
115 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
116 //send the unprotected frame indication to SME
117 limSendSmeUnprotectedMgmtFrameInd( pMac, pHdr->fc.subType,
118 (tANI_U8*)pHdr, (frameLen + sizeof(tSirMacMgmtHdr)),
119 psessionEntry->smeSessionId, psessionEntry);
120 return;
121 }
122#endif
123
Jeff Johnson295189b2012-06-20 16:38:30 -0700124 // Get reasonCode from Disassociation frame body
125 reasonCode = sirReadU16(pBody);
126
Abhishek Singh525045c2014-12-15 17:18:45 +0530127 limLog(pMac, LOGE,
128 FL("Received Disassoc frame for Addr: "MAC_ADDRESS_STR
129 "(mlm state=%s, sme state=%d),"
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530130 "with reason code %d from "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->da),
Abhishek Singh525045c2014-12-15 17:18:45 +0530131 limMlmStateStr(psessionEntry->limMlmState), psessionEntry->limSmeState,
132 reasonCode, MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700133
134 /**
135 * Extract 'associated' context for STA, if any.
136 * This is maintained by DPH and created by LIM.
137 */
138 pStaDs = dphLookupHashEntry(pMac, pHdr->sa, &aid, &psessionEntry->dph.dphHashTable);
139
140 if (pStaDs == NULL)
141 {
142 /**
143 * Disassociating STA is not associated.
144 * Log error.
145 */
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530146 PELOGE(limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530147 FL("received Disassoc frame from STA that does not have context "
148 "reasonCode=%d, addr "MAC_ADDRESS_STR),
149 reasonCode,MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700150
151 return;
152 }
153
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -0800154 if (limCheckDisassocDeauthAckPending(pMac, (tANI_U8*)pHdr->sa))
155 {
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530156 PELOGE(limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530157 FL("Ignore the DisAssoc received, while waiting "
158 "for ack of disassoc/deauth"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -0800159 limCleanUpDisassocDeauthReq(pMac,(tANI_U8*)pHdr->sa, 1);
160 return;
161 }
162
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 /** If we are in the Wait for ReAssoc Rsp state */
164 if (limIsReassocInProgress(pMac,psessionEntry)) {
165 /** If we had received the DisAssoc from,
166 * a. the Current AP during ReAssociate to different AP in same ESS
167 * b. Unknown AP
168 * drop/ignore the DisAssoc received
169 */
170 if (!IS_REASSOC_BSSID(pMac,pHdr->sa,psessionEntry)) {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530171 PELOGE(limLog(pMac, LOGE, FL("Ignore the DisAssoc received, while "
172 "Processing ReAssoc with different/unknown AP"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 return;
174 }
175 /** If the Disassoc is received from the new AP to which we tried to ReAssociate
176 * Drop ReAssoc and Restore the Previous context( current connected AP).
177 */
178 if (!IS_CURRENT_BSSID(pMac, pHdr->sa,psessionEntry)) {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530179 PELOGE(limLog(pMac, LOGE, FL("received Disassoc from the New AP to "
180 "which ReAssoc is sent "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700181 limRestorePreReassocState(pMac,
182 eSIR_SME_REASSOC_REFUSED, reasonCode,psessionEntry);
183 return;
184 }
185 }
186
187 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
188 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
189 {
190 switch (reasonCode)
191 {
192 case eSIR_MAC_UNSPEC_FAILURE_REASON:
193 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
194 case eSIR_MAC_DISASSOC_LEAVING_BSS_REASON:
195 case eSIR_MAC_MIC_FAILURE_REASON:
196 case eSIR_MAC_4WAY_HANDSHAKE_TIMEOUT_REASON:
197 case eSIR_MAC_GR_KEY_UPDATE_TIMEOUT_REASON:
198 case eSIR_MAC_RSN_IE_MISMATCH_REASON:
199 case eSIR_MAC_1X_AUTH_FAILURE_REASON:
200 // Valid reasonCode in received Disassociation frame
201 break;
202
203 default:
204 // Invalid reasonCode in received Disassociation frame
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530205 PELOGE(limLog(pMac, LOGE,
206 FL("received Disassoc frame with invalid reasonCode "
207 "%d from "MAC_ADDRESS_STR),
208 reasonCode, MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 break;
210 }
211 }
212 else if ( ((psessionEntry->limSystemRole == eLIM_STA_ROLE) ||
213 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
214 ((psessionEntry->limSmeState != eLIM_SME_WT_JOIN_STATE) &&
215 (psessionEntry->limSmeState != eLIM_SME_WT_AUTH_STATE) &&
216 (psessionEntry->limSmeState != eLIM_SME_WT_ASSOC_STATE) &&
217 (psessionEntry->limSmeState != eLIM_SME_WT_REASSOC_STATE) ))
218 {
219 switch (reasonCode)
220 {
221 case eSIR_MAC_UNSPEC_FAILURE_REASON:
222 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
223 case eSIR_MAC_DISASSOC_DUE_TO_DISABILITY_REASON:
224 case eSIR_MAC_CLASS2_FRAME_FROM_NON_AUTH_STA_REASON:
225 case eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_REASON:
226 case eSIR_MAC_MIC_FAILURE_REASON:
227 case eSIR_MAC_4WAY_HANDSHAKE_TIMEOUT_REASON:
228 case eSIR_MAC_GR_KEY_UPDATE_TIMEOUT_REASON:
229 case eSIR_MAC_RSN_IE_MISMATCH_REASON:
230 case eSIR_MAC_1X_AUTH_FAILURE_REASON:
Chet Lanctot186b5732013-03-18 10:26:30 -0700231 case eSIR_MAC_PREV_AUTH_NOT_VALID_REASON:
Jeff Johnson295189b2012-06-20 16:38:30 -0700232 // Valid reasonCode in received Disassociation frame
233 break;
234
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -0700235 case eSIR_MAC_DEAUTH_LEAVING_BSS_REASON:
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 case eSIR_MAC_DISASSOC_LEAVING_BSS_REASON:
237 // Valid reasonCode in received Disassociation frame
238 // as long as we're not about to channel switch
Jeff Johnsone7245742012-09-05 17:12:55 -0700239 if(psessionEntry->gLimChannelSwitch.state != eLIM_CHANNEL_SWITCH_IDLE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700240 {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530241 limLog(pMac, LOGE,
Jeff Johnson295189b2012-06-20 16:38:30 -0700242 FL("Ignoring disassoc frame due to upcoming "
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530243 "channel switch, from "MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 return;
245 }
246 break;
247
248 default:
249 // Invalid reasonCode in received Disassociation frame
250 // Log error and ignore the frame
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530251 PELOGE(limLog(pMac, LOGE,
252 FL("received Disassoc frame with invalid reasonCode "
253 "%d from "MAC_ADDRESS_STR), reasonCode,
254 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 return;
256 }
257 }
258 else
259 {
260 // Received Disassociation frame in either IBSS
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -0700261 // or un-known role. Log and ignore it
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530262 limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530263 FL("received Disassoc frame with invalid reasonCode %d in role "
264 "%d in sme state %d from "MAC_ADDRESS_STR), reasonCode,
265 psessionEntry->limSystemRole, psessionEntry->limSmeState,
266 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700267
268 return;
269 }
270
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 if ((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
Sushant Kaushikefe08fa2015-07-06 14:54:09 +0530272 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE))
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 {
274 /**
275 * Already in the process of deleting context for the peer
276 * and received Disassociation frame. Log and Ignore.
277 */
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530278 PELOGE(limLog(pMac, LOGE,
Sachin Ahuja60a50612015-04-20 17:55:08 +0530279 FL("received Disassoc frame in state %d from "MAC_ADDRESS_STR
280 ",isDisassocDeauthInProgress : %d\n"),
281 pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa),
282 pStaDs->isDisassocDeauthInProgress);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700283
284 return;
285 }
286
287 if (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE)
288 {
289 /**
290 * Requesting STA is in some 'transient' state?
291 * Log error.
292 */
Abhishek Singh50f7b422014-05-05 12:19:03 +0530293 if (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_ASSOC_CNF_STATE)
294 pStaDs->mlmStaContext.updateContext = 1;
295
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530296 PELOGE(limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +0530297 FL("received Disassoc frame from peer that is in state %d, addr "
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530298 MAC_ADDRESS_STR),
299 pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
Abhishek Singh50f7b422014-05-05 12:19:03 +0530300
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 } // if (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE)
302
303 pStaDs->mlmStaContext.cleanupTrigger = eLIM_PEER_ENTITY_DISASSOC;
304 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes) reasonCode;
305
306 // Issue Disassoc Indication to SME.
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530307 vos_mem_copy((tANI_U8 *) &mlmDisassocInd.peerMacAddr,
308 (tANI_U8 *) pStaDs->staAddr,
309 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 mlmDisassocInd.reasonCode =
311 (tANI_U8) pStaDs->mlmStaContext.disassocReason;
Jeff Johnson295189b2012-06-20 16:38:30 -0700312 mlmDisassocInd.disassocTrigger = eLIM_PEER_ENTITY_DISASSOC;
313
314 /* Update PE session Id */
315 mlmDisassocInd.sessionId = psessionEntry->peSessionId;
316
317 if (limIsReassocInProgress(pMac,psessionEntry)) {
318
319 /* If we're in the middle of ReAssoc and received disassoc from
320 * the ReAssoc AP, then notify SME by sending REASSOC_RSP with
321 * failure result code. By design, SME will then issue "Disassoc"
322 * and cleanup will happen at that time.
323 */
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530324 PELOGE(limLog(pMac, LOGE, FL("received Disassoc from AP while waiting "
325 "for Reassoc Rsp"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700326
327 if (psessionEntry->limAssocResponseData) {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530328 vos_mem_free(psessionEntry->limAssocResponseData);
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 psessionEntry->limAssocResponseData = NULL;
330 }
331
332 limRestorePreReassocState(pMac,eSIR_SME_REASSOC_REFUSED, reasonCode,psessionEntry);
333 return;
334 }
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +0530335 limUpdateLostLinkParams(pMac, psessionEntry, pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700336 limPostSmeMessage(pMac, LIM_MLM_DISASSOC_IND,
337 (tANI_U32 *) &mlmDisassocInd);
338
339
340 // send eWNI_SME_DISASSOC_IND to SME
341 limSendSmeDisassocInd(pMac, pStaDs,psessionEntry);
342
343 return;
344} /*** end limProcessDisassocFrame() ***/
345