blob: e3242b627d58de385a4172e8fe3401dfdae7f334 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
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.
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"
Jeff Johnson295189b2012-06-20 16:38:30 -070042#include "wniCfgSta.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
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530127 PELOG2(limLog(pMac, LOGE,
128 FL("Received Disassoc frame for Addr: "MAC_ADDRESS_STR"(mlm state=%s, sme state=%d),"
129 "with reason code %d from "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->da),
130 limMlmStateStr(psessionEntry->limMlmState), psessionEntry->limSmeState, reasonCode,
131 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700132
133 /**
134 * Extract 'associated' context for STA, if any.
135 * This is maintained by DPH and created by LIM.
136 */
137 pStaDs = dphLookupHashEntry(pMac, pHdr->sa, &aid, &psessionEntry->dph.dphHashTable);
138
139 if (pStaDs == NULL)
140 {
141 /**
142 * Disassociating STA is not associated.
143 * Log error.
144 */
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530145 PELOGE(limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530146 FL("received Disassoc frame from STA that does not have context "
147 "reasonCode=%d, addr "MAC_ADDRESS_STR),
148 reasonCode,MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700149
150 return;
151 }
152
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -0800153 if (limCheckDisassocDeauthAckPending(pMac, (tANI_U8*)pHdr->sa))
154 {
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530155 PELOGE(limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530156 FL("Ignore the DisAssoc received, while waiting "
157 "for ack of disassoc/deauth"));)
Madan Mohan Koyyalamudi25b6f8b2012-12-04 16:17:31 -0800158 limCleanUpDisassocDeauthReq(pMac,(tANI_U8*)pHdr->sa, 1);
159 return;
160 }
161
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 /** If we are in the Wait for ReAssoc Rsp state */
163 if (limIsReassocInProgress(pMac,psessionEntry)) {
164 /** If we had received the DisAssoc from,
165 * a. the Current AP during ReAssociate to different AP in same ESS
166 * b. Unknown AP
167 * drop/ignore the DisAssoc received
168 */
169 if (!IS_REASSOC_BSSID(pMac,pHdr->sa,psessionEntry)) {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530170 PELOGE(limLog(pMac, LOGE, FL("Ignore the DisAssoc received, while "
171 "Processing ReAssoc with different/unknown AP"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 return;
173 }
174 /** If the Disassoc is received from the new AP to which we tried to ReAssociate
175 * Drop ReAssoc and Restore the Previous context( current connected AP).
176 */
177 if (!IS_CURRENT_BSSID(pMac, pHdr->sa,psessionEntry)) {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530178 PELOGE(limLog(pMac, LOGE, FL("received Disassoc from the New AP to "
179 "which ReAssoc is sent "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 limRestorePreReassocState(pMac,
181 eSIR_SME_REASSOC_REFUSED, reasonCode,psessionEntry);
182 return;
183 }
184 }
185
186 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
187 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
188 {
189 switch (reasonCode)
190 {
191 case eSIR_MAC_UNSPEC_FAILURE_REASON:
192 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
193 case eSIR_MAC_DISASSOC_LEAVING_BSS_REASON:
194 case eSIR_MAC_MIC_FAILURE_REASON:
195 case eSIR_MAC_4WAY_HANDSHAKE_TIMEOUT_REASON:
196 case eSIR_MAC_GR_KEY_UPDATE_TIMEOUT_REASON:
197 case eSIR_MAC_RSN_IE_MISMATCH_REASON:
198 case eSIR_MAC_1X_AUTH_FAILURE_REASON:
199 // Valid reasonCode in received Disassociation frame
200 break;
201
202 default:
203 // Invalid reasonCode in received Disassociation frame
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530204 PELOGE(limLog(pMac, LOGE,
205 FL("received Disassoc frame with invalid reasonCode "
206 "%d from "MAC_ADDRESS_STR),
207 reasonCode, MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700208 break;
209 }
210 }
211 else if ( ((psessionEntry->limSystemRole == eLIM_STA_ROLE) ||
212 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
213 ((psessionEntry->limSmeState != eLIM_SME_WT_JOIN_STATE) &&
214 (psessionEntry->limSmeState != eLIM_SME_WT_AUTH_STATE) &&
215 (psessionEntry->limSmeState != eLIM_SME_WT_ASSOC_STATE) &&
216 (psessionEntry->limSmeState != eLIM_SME_WT_REASSOC_STATE) ))
217 {
218 switch (reasonCode)
219 {
220 case eSIR_MAC_UNSPEC_FAILURE_REASON:
221 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
222 case eSIR_MAC_DISASSOC_DUE_TO_DISABILITY_REASON:
223 case eSIR_MAC_CLASS2_FRAME_FROM_NON_AUTH_STA_REASON:
224 case eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_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:
Chet Lanctot186b5732013-03-18 10:26:30 -0700230 case eSIR_MAC_PREV_AUTH_NOT_VALID_REASON:
Jeff Johnson295189b2012-06-20 16:38:30 -0700231 // Valid reasonCode in received Disassociation frame
232 break;
233
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -0700234 case eSIR_MAC_DEAUTH_LEAVING_BSS_REASON:
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 case eSIR_MAC_DISASSOC_LEAVING_BSS_REASON:
236 // Valid reasonCode in received Disassociation frame
237 // as long as we're not about to channel switch
Jeff Johnsone7245742012-09-05 17:12:55 -0700238 if(psessionEntry->gLimChannelSwitch.state != eLIM_CHANNEL_SWITCH_IDLE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 {
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530240 limLog(pMac, LOGE,
Jeff Johnson295189b2012-06-20 16:38:30 -0700241 FL("Ignoring disassoc frame due to upcoming "
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530242 "channel switch, from "MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700243 return;
244 }
245 break;
246
247 default:
248 // Invalid reasonCode in received Disassociation frame
249 // Log error and ignore the frame
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530250 PELOGE(limLog(pMac, LOGE,
251 FL("received Disassoc frame with invalid reasonCode "
252 "%d from "MAC_ADDRESS_STR), reasonCode,
253 MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 return;
255 }
256 }
257 else
258 {
259 // Received Disassociation frame in either IBSS
Srinivas Girigowdac03c5a82013-07-01 13:44:54 -0700260 // or un-known role. Log and ignore it
Kaushik, Sushant2c823f92014-07-18 16:47:48 +0530261 limLog(pMac, LOG1,
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530262 FL("received Disassoc frame with invalid reasonCode %d in role "
263 "%d in sme state %d from "MAC_ADDRESS_STR), reasonCode,
264 psessionEntry->limSystemRole, psessionEntry->limSmeState,
265 MAC_ADDR_ARRAY(pHdr->sa));
Jeff Johnson295189b2012-06-20 16:38:30 -0700266
267 return;
268 }
269
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 if ((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
271 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE))
272 {
273 /**
274 * Already in the process of deleting context for the peer
275 * and received Disassociation frame. Log and Ignore.
276 */
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530277 PELOGE(limLog(pMac, LOGE,
278 FL("received Disassoc frame in state %d from "MAC_ADDRESS_STR),
279 pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700280
281 return;
282 }
283
284 if (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE)
285 {
286 /**
287 * Requesting STA is in some 'transient' state?
288 * Log error.
289 */
Abhishek Singh50f7b422014-05-05 12:19:03 +0530290 if (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_ASSOC_CNF_STATE)
291 pStaDs->mlmStaContext.updateContext = 1;
292
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530293 PELOGE(limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +0530294 FL("received Disassoc frame from peer that is in state %d, addr "
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530295 MAC_ADDRESS_STR),
296 pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
Abhishek Singh50f7b422014-05-05 12:19:03 +0530297
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 } // if (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE)
299
300 pStaDs->mlmStaContext.cleanupTrigger = eLIM_PEER_ENTITY_DISASSOC;
301 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes) reasonCode;
302
303 // Issue Disassoc Indication to SME.
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530304 vos_mem_copy((tANI_U8 *) &mlmDisassocInd.peerMacAddr,
305 (tANI_U8 *) pStaDs->staAddr,
306 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700307 mlmDisassocInd.reasonCode =
308 (tANI_U8) pStaDs->mlmStaContext.disassocReason;
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 mlmDisassocInd.disassocTrigger = eLIM_PEER_ENTITY_DISASSOC;
310
311 /* Update PE session Id */
312 mlmDisassocInd.sessionId = psessionEntry->peSessionId;
313
314 if (limIsReassocInProgress(pMac,psessionEntry)) {
315
316 /* If we're in the middle of ReAssoc and received disassoc from
317 * the ReAssoc AP, then notify SME by sending REASSOC_RSP with
318 * failure result code. By design, SME will then issue "Disassoc"
319 * and cleanup will happen at that time.
320 */
Abhishek Singh6f9d2c82013-12-24 15:29:53 +0530321 PELOGE(limLog(pMac, LOGE, FL("received Disassoc from AP while waiting "
322 "for Reassoc Rsp"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700323
324 if (psessionEntry->limAssocResponseData) {
Hema Aparna Medicharlaeef78fc2013-07-12 11:47:01 +0530325 vos_mem_free(psessionEntry->limAssocResponseData);
Jeff Johnson295189b2012-06-20 16:38:30 -0700326 psessionEntry->limAssocResponseData = NULL;
327 }
328
329 limRestorePreReassocState(pMac,eSIR_SME_REASSOC_REFUSED, reasonCode,psessionEntry);
330 return;
331 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700332
333 limPostSmeMessage(pMac, LIM_MLM_DISASSOC_IND,
334 (tANI_U32 *) &mlmDisassocInd);
335
336
337 // send eWNI_SME_DISASSOC_IND to SME
338 limSendSmeDisassocInd(pMac, pStaDs,psessionEntry);
339
340 return;
341} /*** end limProcessDisassocFrame() ***/
342