blob: 668b4ae1ef9ee553192c951f1e706b78fb00fce2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, 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.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/**========================================================================
43
44 \file wlan_hdd_assoc.c
45 \brief WLAN Host Device Driver implementation
46
47 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
48
49 Qualcomm Confidential and Proprietary.
50
51 ========================================================================*/
52/**=========================================================================
53 EDIT HISTORY FOR FILE
54
55
56 This section contains comments describing changes made to the module.
57 Notice that changes are listed in reverse chronological order.
58
59
60 $Header:$ $DateTime: $ $Author: $
61
62
63 when who what, where, why
64 -------- --- --------------------------------------------------------
65 05/06/09 Shailender Created module.
66 ==========================================================================*/
67
68#include "wlan_hdd_includes.h"
69#include <aniGlobal.h>
70#include "dot11f.h"
71#include "wlan_nlink_common.h"
72#include "wlan_btc_svc.h"
73#include "wlan_hdd_power.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070074#include <linux/ieee80211.h>
75#include <linux/wireless.h>
76#include <net/cfg80211.h>
77#include "wlan_hdd_cfg80211.h"
78#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#include "wlan_hdd_p2p.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080080#ifdef FEATURE_WLAN_TDLS
81#include "wlan_hdd_tdls.h"
82#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070083#include "sme_Api.h"
84
85v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
86
87struct ether_addr
88{
89 u_char ether_addr_octet[6];
90};
91// These are needed to recognize WPA and RSN suite types
92#define HDD_WPA_OUI_SIZE 4
93v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
94v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
95v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
96v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
97v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
98v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
99#ifdef FEATURE_WLAN_CCX
100v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
101#endif /* FEATURE_WLAN_CCX */
102#define HDD_RSN_OUI_SIZE 4
103v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
104v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
105v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
106v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
107v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
108v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
109#ifdef FEATURE_WLAN_CCX
110v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
111#endif /* FEATURE_WLAN_CCX */
112
113#if defined(WLAN_FEATURE_VOWIFI_11R)
114// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700115#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
116#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700117#endif
118
119#define BEACON_FRAME_IES_OFFSET 12
120
Jeff Johnsond13512a2012-07-17 11:42:19 -0700121void hdd_ResetCountryCodeAfterDisAssoc(hdd_adapter_t *pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700122
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530123v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
124 eConnectionState connState )
125{
126 // save the new connection state
Jeff Johnson295189b2012-06-20 16:38:30 -0700127 pHddStaCtx->conn_info.connState = connState;
128}
129
130// returns FALSE if not connected.
131// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
132// returns the connection state. Can specify NULL if you dont' want to get the actual state.
133
134static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
135 eConnectionState *pConnState )
136{
137 v_BOOL_t fConnected;
138 eConnectionState connState;
139
140 // get the connection state.
141 connState = pHddStaCtx->conn_info.connState;
142 // Set the fConnected return variable based on the Connected State.
143 if ( eConnectionState_Associated == connState ||
144 eConnectionState_IbssConnected == connState )
145 {
146 fConnected = VOS_TRUE;
147 }
148 else
149 {
150 fConnected = VOS_FALSE;
151 }
152
153 if ( pConnState )
154 {
155 *pConnState = connState;
156 }
157
158 return( fConnected );
159}
160
161v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
162{
163 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
164}
165
166//TODO - Not used anyhwere. Can be removed.
167#if 0
168//
169v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
170{
171 v_BOOL_t fConnectedInfra = FALSE;
172 eConnectionState connState;
173
174 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
175 {
176 if ( eConnectionState_Associated == connState )
177 {
178 fConnectedInfra = TRUE;
179 }
180 }
181
182 return( fConnectedInfra );
183}
184#endif
185
186static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
187{
188 v_BOOL_t fConnected = VOS_FALSE;
189
190 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
191
192 if ( pConnectedCipherAlgo )
193 {
194 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
195 }
196
197 return( fConnected );
198}
199
200inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
201{
202 v_BOOL_t fConnected = VOS_FALSE;
203
204 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
205
206 if ( pConnectedBssType )
207 {
208 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
209 }
210
211 return( fConnected );
212}
213
214static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
215{
216 switch( csrRoamBssType )
217 {
218 case eCSR_BSS_TYPE_INFRASTRUCTURE:
219 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
220 break;
221
222 case eCSR_BSS_TYPE_IBSS:
223 case eCSR_BSS_TYPE_START_IBSS:
224 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
225 break;
226
227 /** We will never set the BssType to 'any' when attempting a connection
228 so CSR should never send this back to us.*/
229 case eCSR_BSS_TYPE_ANY:
230 default:
231 VOS_ASSERT( 0 );
232 break;
233 }
234
235}
236
237void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
238{
239 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
240 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
241
242 VOS_ASSERT( pRoamInfo );
243
244 if ( pRoamInfo )
245 {
246 // Save the BSSID for the connection...
247 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
248 {
249 VOS_ASSERT( pRoamInfo->pBssDesc );
250 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
251
252 // Save the Station ID for this station from the 'Roam Info'.
253 //For IBSS mode, staId is assigned in NEW_PEER_IND
254 //For reassoc, the staID doesn't change and it may be invalid in this structure
255 //so no change here.
256 if( !pRoamInfo->fReassocReq )
257 {
258 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
259 }
260 }
261 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
262 {
263 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
264 }
265 else
266 {
267 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
268 // or we can't function.
269 VOS_ASSERT( 0 );
270 }
271
272 // notify WMM
273 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
274
275 if( !pRoamInfo->u.pConnectedProfile )
276 {
277 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
278 }
279 else
280 {
281 // Get Multicast Encryption Type
282 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
283 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
284 // Get Unicast Encrytion Type
285 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
286 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
287
288 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
289
290 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
291
292 // Save the ssid for the connection
293 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
294 }
295 }
296
297 // save the connected BssType
298 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
299
300}
301
302#if defined(WLAN_FEATURE_VOWIFI_11R)
303/*
304 * Send the 11R key information to the supplicant.
305 * Only then can the supplicant generate the PMK-R1.
306 * (BTW, the CCX supplicant also needs the Assoc Resp IEs
307 * for the same purpose.)
308 *
309 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
310 * this contains the R1KHID, R0KHID and the MDID.
311 * For FT, this consists of the Reassoc Rsp FTIEs.
312 * This is the Assoc Response.
313 */
314static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
315 tCsrRoamInfo *pCsrRoamInfo)
316{
317 union iwreq_data wrqu;
318 char *buff;
319 unsigned int len = 0;
320 u8 *pFTAssocRsp = NULL;
321
322 if (pCsrRoamInfo->nAssocRspLength == 0)
323 {
324 hddLog(LOGE,
325 "%s: pCsrRoamInfo->nAssocRspLength=%d",
326 __func__, (int)pCsrRoamInfo->nAssocRspLength);
327 return;
328 }
329
330 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
331 pCsrRoamInfo->nAssocReqLength);
332 if (pFTAssocRsp == NULL)
333 {
334 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
335 return;
336 }
337
338 // pFTAssocRsp needs to point to the IEs
339 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
340 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
341 (unsigned int)pFTAssocRsp[0],
342 (unsigned int)pFTAssocRsp[1]);
343
344 // We need to send the IEs to the supplicant.
345 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
346 if (buff == NULL)
347 {
348 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
349 return;
350 }
351
352 // Send the Assoc Resp, the supplicant needs this for initial Auth.
353 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
354 wrqu.data.length = len;
355 memset(buff, 0, IW_GENERIC_IE_MAX);
356 memcpy(buff, pFTAssocRsp, len);
357 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
358
359 kfree(buff);
360}
361#endif /* WLAN_FEATURE_VOWIFI_11R */
362
363#ifdef WLAN_FEATURE_VOWIFI_11R
364
365/*---------------------------------------------------
366 *
367 * Send the FTIEs, RIC IEs during FT. This is eventually
368 * used to send the FT events to the supplicant
369 *
370 * At the reception of Auth2 we send the RIC followed
371 * by the auth response IEs to the supplicant.
372 * Once both are received in the supplicant, an FT
373 * event is generated to the supplicant.
374 *
375 *---------------------------------------------------
376 */
377void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
378{
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 tANI_U16 auth_resp_len = 0;
380 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
382
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530383#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700384 struct cfg80211_ft_event_params ftEvent;
385 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
386 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530387 v_U8_t target_ap[SIR_MAC_ADDR_LENGTH];
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700388 struct net_device *dev = pAdapter->dev;
389#else
390 char *buff;
391 union iwreq_data wrqu;
392 tANI_U16 str_len;
393#endif
394
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530395#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530396 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
397 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700398
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530399 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800400 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530401 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700402 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530403 hddLog(LOGW,
404 "%s: RIC IEs is of length 0 not sending RIC Information for now",
405 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700406 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700407
408 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530409 ftEvent.ric_ies_len = ric_ies_length;
410 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700411
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530412 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800413 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700414
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530415 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700416 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530417 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700418 return;
419 }
420
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530421 vos_mem_copy(target_ap, ftIe, SIR_MAC_ADDR_LENGTH);
422
423 ftEvent.target_ap = target_ap;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700424
425 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
426 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
427
428 hddLog(LOG1, "%s ftEvent.ies_len %d",__FUNCTION__, ftEvent.ies_len);
429 hddLog(LOG1, "%s ftEvent.ric_ies_len %d",__FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530430 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800431 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
432 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
433 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700434
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530435 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700436
437#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530438 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700439 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530440 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530442 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700443 return;
444 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530445 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700446
447 // Sme needs to send the RIC IEs first
448 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530449 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800450 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530451 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530453 hddLog(LOGW,
454 "%s: RIC IEs is of length 0 not sending RIC Information for now",
455 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 }
457 else
458 {
459 wrqu.data.length = str_len + ric_ies_length;
460 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
461 }
462
463 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530464 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700465 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530466 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
467 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700468
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530469 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530471 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 return;
473 }
474
475 wrqu.data.length = str_len + auth_resp_len;
476 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
477
478 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700479#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700480}
481
482#endif /* WLAN_FEATURE_VOWIFI_11R */
483
484#ifdef FEATURE_WLAN_CCX
485
486/*
487 * Send the CCX required "new AP Channel info" to the supplicant.
488 * (This keeps the supplicant "up to date" on the current channel.)
489 *
490 * The current (new AP) channel information is passed in.
491 */
492static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
493 tCsrRoamInfo *pCsrRoamInfo)
494{
495 union iwreq_data wrqu;
496 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
497
498
499 if (descriptor == NULL)
500 {
501 hddLog(LOGE,
502 "%s: pCsrRoamInfo->pBssDesc=%p\n",
503 __func__, descriptor);
504 return;
505 }
506
507 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
508 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d\n", __func__, descriptor->channelId);
509 memset(&wrqu, '\0', sizeof(wrqu));
510 wrqu.freq.m = descriptor->channelId;
511 wrqu.freq.e = 0;
512 wrqu.freq.i = 0;
513 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
514}
515
516#endif /* FEATURE_WLAN_CCX */
517
518void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
519{
520 union iwreq_data wrqu;
521 u8 *pBeaconIes;
522 u8 currentLen = 0;
523 char *buff;
524 int totalIeLen = 0, currentOffset = 0, strLen;
525
526 memset(&wrqu, '\0', sizeof(wrqu));
527
528 if (0 == pCsrRoamInfo->nBeaconLength)
529 {
530 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
531 return;
532 }
533 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
534 if (pBeaconIes == NULL)
535 {
536 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
537 return;
538 }
539
540 // pBeaconIes needs to point to the IEs
541 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
542 (unsigned int)pBeaconIes[0],
543 (unsigned int)pBeaconIes[1]);
544 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
545
546 // We need to send the IEs to the supplicant.
547 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
548 if (buff == NULL)
549 {
550 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
551 return;
552 }
553 vos_mem_zero(buff, IW_CUSTOM_MAX);
554
555 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
556 currentLen = strLen + 1;
557
558 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
559 do
560 {
561 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
562 * max size and send it to supplicant. Changes are done in supplicant to handle this */
563 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
564 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
565 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
566 currentOffset += currentLen;
567 totalIeLen -= currentLen;
568 wrqu.data.length = strLen + 1 + currentLen;
569 if (totalIeLen)
570 buff[strLen] = 1; // This tells supplicant more chunks are pending
571 else
572 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
573
574 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
575 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
576 } while (totalIeLen > 0);
577
578 kfree(buff);
579}
580
581static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
582{
583 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
584 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
585 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
586 union iwreq_data wrqu;
587 int we_event;
588 char *msg;
589 int type = -1;
590
591#if defined (WLAN_FEATURE_VOWIFI_11R)
592 // Added to find the auth type on the fly at run time
593 // rather than with cfg to see if FT is enabled
594 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
595 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
596#endif
597
598 memset(&wrqu, '\0', sizeof(wrqu));
599 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
600 we_event = SIOCGIWAP;
601
602 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
603 {
604 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
605 type = WLAN_STA_ASSOC_DONE_IND;
606
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700607#ifdef WLAN_FEATURE_P2P_DEBUG
608 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
609 {
610 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
611 {
612 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
613 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
614 "Connecting state to Connected State for 8-way "
615 "Handshake");
616 }
617 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
618 {
619 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
620 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
621 "Connecting state to P2P Client Connection Completed");
622 }
623 }
624#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 pr_info("wlan: connected to %02x:%02x:%02x:%02x:%02x:%02x\n",
626 wrqu.ap_addr.sa_data[0],
627 wrqu.ap_addr.sa_data[1],
628 wrqu.ap_addr.sa_data[2],
629 wrqu.ap_addr.sa_data[3],
630 wrqu.ap_addr.sa_data[4],
631 wrqu.ap_addr.sa_data[5]);
632 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
633
634 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
635 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
636 * and fFTEnable is TRUE */
637#ifdef WLAN_FEATURE_VOWIFI_11R
638 // Send FT Keys to the supplicant when FT is enabled
639 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
640 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
641#ifdef FEATURE_WLAN_CCX
642 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
643 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
644#endif
645 )
646 {
647 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
648 }
649#endif
650 }
651 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
652 {
Jeff Johnson4416a782013-03-25 14:17:50 -0700653 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 type = WLAN_STA_ASSOC_DONE_IND;
655 pr_info("wlan: new IBSS connection to %02x:%02x:%02x:%02x:%02x:%02x",
656 pHddStaCtx->conn_info.bssId[0],
657 pHddStaCtx->conn_info.bssId[1],
658 pHddStaCtx->conn_info.bssId[2],
659 pHddStaCtx->conn_info.bssId[3],
660 pHddStaCtx->conn_info.bssId[4],
661 pHddStaCtx->conn_info.bssId[5]);
662 }
663 else /* Not Associated */
664 {
665 pr_info("wlan: disconnected\n");
666 type = WLAN_STA_DISASSOC_DONE_IND;
667 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
668 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700669 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700670
671 msg = NULL;
672 /*During the WLAN uninitialization,supplicant is stopped before the
673 driver so not sending the status of the connection to supplicant*/
674 if(pHddCtx->isLoadUnloadInProgress != TRUE)
675 {
676 wireless_send_event(dev, we_event, &wrqu, msg);
677#ifdef FEATURE_WLAN_CCX
678 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
679 {
680 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
681 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
682 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
683 }
684#endif
685 }
686 send_btc_nlink_msg(type, 0);
687}
688
689void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
690{
691 // Remove staId, bssId and peerMacAddress
692 pHddStaCtx->conn_info.staId [ 0 ] = 0;
693 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
694 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
695
696 // Clear all security settings
697 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
698 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
699 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
700
701 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
702
703 // Set not-connected state
704 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
705 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
706
707 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
708}
709/* TODO Revist this function. and data path */
710static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
711{
712 VOS_STATUS vosStatus;
713 hdd_disconnect_tx_rx(pAdapter);
714 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
715 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
716 {
717 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
718 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
719 "Status= %d [0x%08lX]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700720 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 }
722 return( vosStatus );
723}
724
725
726static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
727 tANI_U32 roamId, eRoamCmdStatus roamStatus,
728 eCsrRoamResult roamResult )
729{
730 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700731 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 struct net_device *dev = pAdapter->dev;
733 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
734 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700735
736 // Sanity check
737 if(dev == NULL)
738 {
739 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
740 "%s: net_dev is released return", __func__);
741 return eHAL_STATUS_FAILURE;
742 }
743
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 // notify apps that we can't pass traffic anymore
745 netif_tx_disable(dev);
746 netif_carrier_off(dev);
747
Jeff Johnsone7245742012-09-05 17:12:55 -0700748 INIT_COMPLETION(pAdapter->disconnect_comp_var);
749 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
Jeff Johnson295189b2012-06-20 16:38:30 -0700750 /* If only STA mode is on */
751 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
752 {
753 pHddCtx->isAmpAllowed = VOS_TRUE;
754 }
755 hdd_clearRoamProfileIe( pAdapter );
756
757 // indicate 'disconnect' status to wpa_supplicant...
758 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 /* indicate disconnected event to nl80211 */
760 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
761 {
762 /*During the WLAN uninitialization,supplicant is stopped before the
763 driver so not sending the status of the connection to supplicant*/
764 if(pHddCtx->isLoadUnloadInProgress != TRUE)
765 {
766 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
767 "%s: sent disconnected event to nl80211",
768 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700769#ifdef WLAN_FEATURE_P2P_DEBUG
770 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
771 {
772 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
773 {
774 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
775 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
776 "and moved to disconnected state");
777 }
778 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
779 {
780 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
781 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
782 "and moved to inactive state");
783 }
784 }
785#endif
786
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
788 if( eCSR_ROAM_LOSTLINK == roamStatus )
789 {
Mohit Khanna99d5fd02012-09-11 14:51:20 -0700790 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 }
792 else
793 {
794 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
795 }
796
797 //If the Device Mode is Station
798 // and the P2P Client is Connected
799 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700800
801 // In case of JB, as Change-Iface may or maynot be called for p2p0
802 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
803 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
804 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 (vos_concurrent_sessions_running()))
806 {
807 //Enable BMPS only of other Session is P2P Client
808 hdd_context_t *pHddCtx = NULL;
809 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
810
811 if (NULL != pVosContext)
812 {
813 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
814
815 if(NULL != pHddCtx)
816 {
817 //Only P2P Client is there Enable Bmps back
818 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700819 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 {
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -0800821 if (pHddCtx->hdd_wlan_suspended)
822 {
823 if(WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
824 {
825 hdd_reset_pwrparams(pHddCtx);
826 }
827 else
828 {
829 hdd_set_pwrparams(pHddCtx);
830 }
831 }
832
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 hdd_enable_bmps_imps(pHddCtx);
834 }
835 }
836 }
837 }
838 }
839 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700840
841
842 //We should clear all sta register with TL, for now, only one.
Jeff Johnson43971f52012-07-17 12:26:56 -0700843 vstatus = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
844 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 {
846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
847 "hdd_roamDeregisterSTA() failed to for staID %d. "
848 "Status= %d [0x%x]",
849 pHddStaCtx->conn_info.staId[0], status, status );
850
851 status = eHAL_STATUS_FAILURE;
852 }
853
854 pHddCtx->sta_to_adapter[pHddStaCtx->conn_info.staId[0]] = NULL;
855 // Clear saved connection information in HDD
856 hdd_connRemoveConnectInfo( pHddStaCtx );
857
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800858#ifdef FEATURE_WLAN_TDLS
859 wlan_hdd_tdls_disconnection_callback(pAdapter);
860#endif
861
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 //Unblock anyone waiting for disconnect to complete
863 complete(&pAdapter->disconnect_comp_var);
864 return( status );
865}
866static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
867 tCsrRoamInfo *pRoamInfo,
868 v_U8_t staId,
869 v_MACADDR_t *pPeerMacAddress,
870 tSirBssDescription *pBssDesc )
871{
872 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
873 WLAN_STADescType staDesc = {0};
874 eCsrEncryptionType connectedCipherAlgo;
875 v_BOOL_t fConnected;
876 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
877 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
878
879 // Get the Station ID from the one saved during the assocation.
880 staDesc.ucSTAId = staId;
881
882 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
883 {
884 staDesc.wSTAType = WLAN_STA_INFRA;
885
886 // grab the bssid from the connection info in the adapter structure and hand that
887 // over to TL when registering.
888 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
889 }
890 else
891 {
892 // for an IBSS 'connect', setup the Station Descriptor for TL.
893 staDesc.wSTAType = WLAN_STA_IBSS;
894
895 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
896 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
897 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
898 // pass when making an Infrastructure connection.
899 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
900 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
901 }
902
903 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
904
905 // set the QoS field appropriately
906 if (hdd_wmm_is_active(pAdapter))
907 {
908 staDesc.ucQosEnabled = 1;
909 }
910 else
911 {
912 staDesc.ucQosEnabled = 0;
913 }
914
915 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
916 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
917 {
918 staDesc.ucProtectedFrame = 1;
919 }
920 else
921 {
922 staDesc.ucProtectedFrame = 0;
923
924 }
925
926#ifdef FEATURE_WLAN_CCX
927 staDesc.ucIsCcxSta = pRoamInfo->isCCXAssoc;
928#endif //FEATURE_WLAN_CCX
929
930#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
931 /* check whether replay check is valid for the station or not */
932 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
933 {
934 /* Encryption mode is either TKIP or AES
935 and replay check is valid for only these
936 two encryption modes */
937 staDesc.ucIsReplayCheckValid = VOS_TRUE;
938 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
939 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
940 }
941
942 else
943 {
944 /* For other encryption modes replay check is
945 not needed */
946 staDesc.ucIsReplayCheckValid = VOS_FALSE;
947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
948 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
949 }
950#endif
951
952#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700953 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 if (pAdapter->wapi_info.fIsWapiSta)
955 {
956 staDesc.ucIsWapiSta = 1;
957 }
958 else
959 {
960 staDesc.ucIsWapiSta = 0;
961 }
962#endif /* FEATURE_WLAN_WAPI */
963
964 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
965 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 // UMA is Not ready yet, Xlation will be done by TL
968 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 staDesc.ucSwFrameRXXlation = 1;
970 staDesc.ucAddRmvLLC = 1;
971 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
972 staDesc.ucQosEnabled );
973 // Initialize signatures and state
974 staDesc.ucUcastSig = pRoamInfo->ucastSig;
975 staDesc.ucBcastSig = pRoamInfo->bcastSig;
976 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
977 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
978 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -0800979 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "%s: HDD register TL ucInitState=%d", __func__, staDesc.ucInitState );
Jeff Johnson295189b2012-06-20 16:38:30 -0700980 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
981 hdd_rx_packet_cbk,
982 hdd_tx_complete_cbk,
983 hdd_tx_fetch_packet_cbk, &staDesc,
984 pBssDesc->rssi );
985
986 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
987 {
988 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
989 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08lX]",
990 vosStatus, vosStatus );
991 return vosStatus;
992 }
993
994 // if ( WPA ), tell TL to go to 'connected' and after keys come to the driver,
995 // then go to 'authenticated'. For all other authentication types (those that do
996 // not require upper layer authentication) we can put TL directly into 'authenticated'
997 // state.
998
999 VOS_ASSERT( fConnected );
1000
1001 if ( !pRoamInfo->fAuthRequired )
1002 {
1003 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1004 "open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time", pHddStaCtx->conn_info.staId[ 0 ] );
1005
1006 // Connections that do not need Upper layer auth, transition TL directly
1007 // to 'Authenticated' state.
1008 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1009 WLANTL_STA_AUTHENTICATED );
1010
1011 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1012 }
1013 else
1014 {
1015 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1016 "ULA auth StaId= %d. Changing TL state to CONNECTED at Join time", pHddStaCtx->conn_info.staId[ 0 ] );
1017
1018 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1019 WLANTL_STA_CONNECTED );
1020
1021 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1022 }
1023 return( vosStatus );
1024}
1025
Jeff Johnson295189b2012-06-20 16:38:30 -07001026static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1027 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1028{
1029 unsigned int len = 0;
1030 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001031 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 tANI_U32 rspRsnLength = 0;
1033 struct ieee80211_channel *chan;
1034
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001035 if (!rspRsnIe)
1036 {
1037 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001038 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001039 }
1040
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 if (pCsrRoamInfo == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001042 {
1043 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1044 goto done;
1045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001046
1047 if (pCsrRoamInfo->nAssocRspLength == 0)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001048 {
1049 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1050 goto done;
1051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001052
1053 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1054 pCsrRoamInfo->nAssocReqLength);
1055 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001056 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001057
1058 //pFTAssocRsp needs to point to the IEs
1059 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1060 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x\n", __func__,
1061 (unsigned int)pFTAssocRsp[0],
1062 (unsigned int)pFTAssocRsp[1]);
1063
1064 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001065 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001068 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001069
1070 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1071 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1072 reqRsnIe, reqRsnLength,
1073 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001074
1075done:
1076 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001077}
Jeff Johnson295189b2012-06-20 16:38:30 -07001078
1079static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1080 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1081 eCsrRoamResult roamResult )
1082{
1083 struct net_device *dev = pAdapter->dev;
1084 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1085 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1086 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001087 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1088 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001089#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 int ft_carrier_on = FALSE;
1091#endif
1092 int status;
1093
1094 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1095 {
1096 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1097
1098 // Save the connection info from CSR...
1099 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1100#ifdef FEATURE_WLAN_WAPI
1101 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1102 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1103 {
1104 pAdapter->wapi_info.fIsWapiSta = 1;
1105 }
1106 else
1107 {
1108 pAdapter->wapi_info.fIsWapiSta = 0;
1109 }
1110#endif /* FEATURE_WLAN_WAPI */
1111
1112 // indicate 'connect' status to userspace
1113 hdd_SendAssociationEvent(dev,pRoamInfo);
1114
1115
1116 // Initialize the Linkup event completion variable
1117 INIT_COMPLETION(pAdapter->linkup_event_var);
1118
1119 /*
1120 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1121 packet to go up to the application, device activation has to be ensured for proper queue mapping by the
1122 kernel. we have registered net device notifier for device change notification. With this we will come to
1123 know that the device is getting activated properly.
1124 */
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001125#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 if (pHddStaCtx->ft_carrier_on == FALSE)
1127 {
1128#endif
1129 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
1130 pAdapter->isLinkUpSvcNeeded = TRUE;
1131
1132 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
1133 pAdapter->isLinkUpSvcNeeded = TRUE;
1134
1135 // Switch on the Carrier to activate the device
1136 netif_carrier_on(dev);
1137
1138 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1139 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1140 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
1141 if(!status)
1142 {
1143 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1144 }
1145
1146 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1147 pAdapter->isLinkUpSvcNeeded = FALSE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001148#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 }
1150 else {
1151 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001153 }
1154#endif
1155 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1156
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001157#ifdef FEATURE_WLAN_TDLS
1158 wlan_hdd_tdls_connection_callback(pAdapter);
1159#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 //For reassoc, the station is already registered, all we need is to change the state
1161 //of the STA in TL.
1162 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1163 if( !pRoamInfo->fReassocReq )
1164 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001165 struct cfg80211_bss *bss;
1166#ifdef WLAN_FEATURE_VOWIFI_11R
1167 u8 *pFTAssocRsp = NULL;
1168 unsigned int assocRsplen = 0;
1169 u8 *pFTAssocReq = NULL;
1170 unsigned int assocReqlen = 0;
1171 struct ieee80211_channel *chan;
1172#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001175
1176 /* add bss_id to cfg80211 data base */
1177 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1178 if (NULL == bss)
1179 {
1180 pr_err("wlan: Not able to create BSS entry\n");
1181 return eHAL_STATUS_FAILURE;
1182 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001183#ifdef WLAN_FEATURE_VOWIFI_11R
1184 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001185 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001187
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001188 //Association Response
1189 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001190 pRoamInfo->nAssocReqLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001191 if (pFTAssocRsp != NULL)
1192 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001193 // pFTAssocRsp needs to point to the IEs
1194 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1195 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1196 (unsigned int)pFTAssocRsp[0],
1197 (unsigned int)pFTAssocRsp[1]);
1198 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001199 }
1200 else
1201 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001202 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1203 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001204 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001205
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001206 //Association Request
1207 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
1208 pRoamInfo->nBeaconLength);
1209 if (pFTAssocReq != NULL)
1210 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001211 if(!ft_carrier_on)
1212 {
1213 // pFTAssocReq needs to point to the IEs
1214 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1215 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1216 (unsigned int)pFTAssocReq[0],
1217 (unsigned int)pFTAssocReq[1]);
1218 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1219 }
1220 else
1221 {
1222 /* This should contain only the FTIEs */
1223 assocReqlen = pRoamInfo->nAssocReqLength;
1224 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001225 }
1226 else
1227 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001228 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1229 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001230 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001231
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001232 if(ft_carrier_on)
1233 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001234 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
1235 "indication\n", __FUNCTION__, ft_carrier_on);
1236 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1237 (int)pRoamInfo->pBssDesc->channelId);
1238 hddLog(LOG1, "assocReqlen %d assocRsplen %d\n", assocReqlen,
1239 assocRsplen);
1240 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
1241 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1242 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001243 }
1244 else
1245 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001246 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
1247 "indication\n", __FUNCTION__, ft_carrier_on);
1248 cfg80211_connect_result(dev, pRoamInfo->bssid,
1249 pFTAssocReq, assocReqlen,
1250 pFTAssocRsp, assocRsplen,
1251 WLAN_STATUS_SUCCESS,
1252 GFP_KERNEL);
1253 cfg80211_put_bss(bss);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001254 }
1255 }
1256 else
1257#endif
1258 {
1259 /* wpa supplicant expecting WPA/RSN IE in connect result */
1260 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1261 pAdapter->sessionId,
1262 &reqRsnLength,
1263 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001264
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001265 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1266 pAdapter->sessionId,
1267 &rspRsnLength,
1268 rspRsnIe);
1269#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1270 if(ft_carrier_on)
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001271 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001272 else
1273#endif /* FEATURE_WLAN_CCX */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001274
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001275 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001276 /* inform connect result to nl80211 */
1277 cfg80211_connect_result(dev, pRoamInfo->bssid,
1278 reqRsnIe, reqRsnLength,
1279 rspRsnIe, rspRsnLength,
1280 WLAN_STATUS_SUCCESS,
1281 GFP_KERNEL);
1282
1283 cfg80211_put_bss(bss);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 // Register the Station with TL after associated...
1287 vosStatus = hdd_roamRegisterSTA( pAdapter,
1288 pRoamInfo,
1289 pHddStaCtx->conn_info.staId[ 0 ],
1290 NULL,
1291 pRoamInfo->pBssDesc );
1292 }
1293 else
1294 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001295 /* wpa supplicant expecting WPA/RSN IE in connect result */
1296 /* in case of reassociation also need to indicate it to supplicant */
1297 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1298 pAdapter->sessionId,
1299 &reqRsnLength,
1300 reqRsnIe);
1301
1302 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 //Reassoc successfully
1304 if( pRoamInfo->fAuthRequired )
1305 {
1306 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
1307 WLANTL_STA_CONNECTED );
1308 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1309 }
1310 else
1311 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001312 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1313 "%s: staId: %d Changing TL state to AUTHENTICATED",
1314 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
1316 WLANTL_STA_AUTHENTICATED );
1317 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1318 }
1319 }
1320
1321 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1322 {
1323 // perform any WMM-related association processing
1324 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1325 }
1326 else
1327 {
1328 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1329 "Cannot register STA with TL. Failed with vosStatus = %d [%08lX]",
1330 vosStatus, vosStatus );
1331 }
1332
1333 // Start the Queue
1334 netif_tx_wake_all_queues(dev);
1335 }
1336 else
1337 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1339
1340 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001341 pr_info("wlan: connection failed with %02x:%02x:%02x:%02x:%02x:%02x"
1342 " reason:%d and Status:%d\n", pWextState->req_bssId[0],
1343 pWextState->req_bssId[1], pWextState->req_bssId[2],
1344 pWextState->req_bssId[3], pWextState->req_bssId[4],
1345 pWextState->req_bssId[5], roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001346
1347 /*Handle all failure conditions*/
1348 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1349 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
1350 {
1351 pHddCtx->isAmpAllowed = VOS_TRUE;
1352 }
1353
1354 //If the Device Mode is Station
1355 // and the P2P Client is Connected
1356 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001357
1358 // In case of JB, as Change-Iface may or maynot be called for p2p0
1359 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
1360 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1361 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001362 (vos_concurrent_sessions_running()))
1363 {
1364 //Enable BMPS only of other Session is P2P Client
1365 hdd_context_t *pHddCtx = NULL;
1366 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1367
1368 if (NULL != pVosContext)
1369 {
1370 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1371
1372 if(NULL != pHddCtx)
1373 {
1374 //Only P2P Client is there Enable Bmps back
1375 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001376 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 {
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001378 if (pHddCtx->hdd_wlan_suspended)
1379 {
1380 if(WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
1381 {
1382 hdd_reset_pwrparams(pHddCtx);
1383 }
1384 else
1385 {
1386 hdd_set_pwrparams(pHddCtx);
1387 }
1388 }
1389
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 hdd_enable_bmps_imps(pHddCtx);
1391 }
1392 }
1393 }
1394 }
1395
James Zmudafbf5ffc2013-03-25 12:45:35 -07001396 /* CR465478: Only send up a connection failure result when CSR has
1397 * completed operation - with a ASSOCIATION_FAILURE status. */
1398 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus )
Jeff Johnsone7245742012-09-05 17:12:55 -07001399 {
James Zmudafbf5ffc2013-03-25 12:45:35 -07001400 /* inform association failure event to nl80211 */
1401 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1402 {
1403 cfg80211_connect_result ( dev, pWextState->req_bssId,
1404 NULL, 0, NULL, 0,
1405 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1406 GFP_KERNEL );
1407 }
1408 else
1409 {
1410 cfg80211_connect_result ( dev, pWextState->req_bssId,
1411 NULL, 0, NULL, 0,
1412 WLAN_STATUS_UNSPECIFIED_FAILURE,
1413 GFP_KERNEL );
1414 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001416
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001417 /*Clear the roam profile*/
1418 hdd_clearRoamProfileIe( pAdapter );
1419
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 netif_tx_disable(dev);
1421 netif_carrier_off(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07001422
1423 if (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode)
1424 {
1425 /* Association failed; Reset the country code information
1426 * so that it re-initialize the valid channel list*/
1427 hdd_ResetCountryCodeAfterDisAssoc(pAdapter);
1428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 }
1430
1431 return eHAL_STATUS_SUCCESS;
1432}
1433
1434/**============================================================================
1435 *
1436 @brief roamRoamIbssIndicationHandler() - Here we update the status of the
1437 Ibss when we receive information that we have started/joined an ibss session
1438 We always return SUCCESS.
1439
1440 ===========================================================================*/
1441static eHalStatus roamRoamIbssIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1442 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1443 eCsrRoamResult roamResult )
1444{
1445 switch( roamResult )
1446 {
1447 // both IBSS Started and IBSS Join should come in here.
1448 case eCSR_ROAM_RESULT_IBSS_STARTED:
1449 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
1450 {
1451 // we should have a pRoamInfo on this callback...
1452 VOS_ASSERT( pRoamInfo );
1453
1454 // When IBSS Started comes from CSR, we need to move connection state to
1455 // IBSS Disconnected (meaning no peers are in the IBSS).
1456 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssDisconnected );
1457
1458 break;
1459 }
1460
1461 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1462 {
1463 VOS_ASSERT( pRoamInfo );
1464
1465 break;
1466 }
1467
1468 default:
1469 break;
1470 }
1471
1472 return( eHAL_STATUS_SUCCESS );
1473}
1474
1475/**============================================================================
1476 *
1477 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1478 This information is passed to iwconfig later. The peer that joined
1479 last is passed as information to iwconfig.
1480 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
1481 return FALSE.
1482
1483 ===========================================================================*/
1484static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1485{
1486 int fSuccess = FALSE;
1487 int idx = 0;
1488
1489 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1490 {
1491 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1492 {
1493 pHddStaCtx->conn_info.staId[ idx ] = staId;
1494
1495 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
1496
1497 fSuccess = TRUE;
1498 break;
1499 }
1500 }
1501
1502 return( fSuccess );
1503}
1504/**============================================================================
1505 *
1506 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
1507 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
1508 return FALSE.
1509
1510 ===========================================================================*/
1511static int roamRemoveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId )
1512{
1513 int fSuccess = FALSE;
1514 int idx = 0;
1515 v_U8_t valid_idx = 0;
1516 v_U8_t del_idx = 0;
1517
1518 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1519 {
1520 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1521 {
1522 pHddStaCtx->conn_info.staId[ idx ] = 0;
1523
1524 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1525
1526 fSuccess = TRUE;
1527 // Note the deleted Index, if its 0 we need special handling
1528 del_idx = idx;
1529 }
1530 else
1531 {
1532 if (pHddStaCtx->conn_info.staId[idx] != 0)
1533 {
1534 valid_idx = idx;
1535 }
1536 }
1537 }
1538
1539 // Find next active staId, to have a valid sta trigger for TL.
1540 if (fSuccess == TRUE)
1541 {
1542 if (del_idx == 0)
1543 {
1544 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1545 {
1546 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1547 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1548 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1549
1550 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1551 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1552 }
1553 }
1554 }
1555 return( fSuccess );
1556}
1557
1558/**============================================================================
1559 *
1560 @brief roamIbssConnectHandler() : We update the status of the IBSS to
1561 connected in this function.
1562
1563 ===========================================================================*/
1564static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1565{
1566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "IBSS Connect Indication from SME!!!" );
1567 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1568 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1569
1570 // Save the connection info from CSR...
1571 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1572
1573 // Send the bssid address to the wext.
1574 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 /* add bss_id to cfg80211 data base */
1576 wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1577 /* send ibss join indication to nl80211 */
1578 cfg80211_ibss_joined(pAdapter->dev, &pRoamInfo->bssid[0], GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001579
1580 return( eHAL_STATUS_SUCCESS );
1581}
1582/**============================================================================
1583 *
1584 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
1585
1586 ===========================================================================*/
1587static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1588 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1589 eCsrRoamResult roamResult )
1590{
1591 eCsrEncryptionType connectedCipherAlgo;
1592 v_BOOL_t fConnected = FALSE;
1593 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1594 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1595 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1596 ENTER();
1597 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
1598 // then go to 'authenticated'. For all other authentication types (those that do
1599 // not require upper layer authentication) we can put TL directly into 'authenticated'
1600 // state.
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001601
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1603 if( fConnected )
1604 {
1605 // TODO: Considering getting a state machine in HDD later.
1606 // This routuine is invoked twice. 1)set PTK 2)set GTK. The folloing if statement will be
1607 // TRUE when setting GTK. At this time we don't handle the state in detail.
1608 // Related CR: 174048 - TL not in authenticated state
1609 if(( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) && (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired)
1610 {
1611 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1612 "Key set for StaId= %d. Changing TL state to AUTHENTICATED", pHddStaCtx->conn_info.staId[ 0 ] );
1613
1614 // Connections that do not need Upper layer authentication, transition TL
1615 // to 'Authenticated' state after the keys are set.
1616 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
1617 WLANTL_STA_AUTHENTICATED );
1618
1619 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1620 }
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301621 else
1622 {
1623 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1624 pHddStaCtx->conn_info.staId[ 0 ]);
1625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001626
1627 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1628 }
1629 else
1630 {
1631 // possible disassoc after issuing set key and waiting set key complete
1632 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1633 }
1634
1635 EXIT();
1636 return( eHAL_STATUS_SUCCESS );
1637}
1638/**============================================================================
1639 *
1640 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
1641 ===========================================================================*/
1642static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1643 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
1644{
1645 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1646
1647 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
1648 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
1649 {
1650 struct iw_michaelmicfailure msg;
1651 union iwreq_data wreq;
1652 memset(&msg, '\0', sizeof(msg));
1653 msg.src_addr.sa_family = ARPHRD_ETHER;
1654 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
1655 hddLog(LOG1, "MIC MAC %02x:%02x:%02x:%02x:%02x:%02x",
1656 msg.src_addr.sa_data[0],
1657 msg.src_addr.sa_data[1],
1658 msg.src_addr.sa_data[2],
1659 msg.src_addr.sa_data[3],
1660 msg.src_addr.sa_data[4],
1661 msg.src_addr.sa_data[5]);
1662
1663 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
1664 msg.flags = IW_MICFAILURE_GROUP;
1665 else
1666 msg.flags = IW_MICFAILURE_PAIRWISE;
1667 memset(&wreq, 0, sizeof(wreq));
1668 wreq.data.length = sizeof(msg);
1669 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 /* inform mic failure to nl80211 */
1671 cfg80211_michael_mic_failure(pAdapter->dev,
1672 pRoamInfo->u.pMICFailureInfo->taMacAddr,
1673 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
1674 NL80211_KEYTYPE_GROUP :
1675 NL80211_KEYTYPE_PAIRWISE),
1676 pRoamInfo->u.pMICFailureInfo->keyId,
1677 pRoamInfo->u.pMICFailureInfo->TSC,
1678 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001679
1680 }
1681
1682 return( eHAL_STATUS_SUCCESS );
1683}
1684
1685/**============================================================================
1686 *
1687 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
1688 updated regularly here in this function.
1689
1690 ===========================================================================*/
1691static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1692 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1693 eCsrRoamResult roamResult )
1694{
1695 VOS_STATUS vosStatus;
1696
1697 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1698 switch( roamResult )
1699 {
1700 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
1701 {
1702 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1703 "IBSS New Peer indication from SME "
1704 "with peerMac %2x-%2x-%2x-%2x-%2x-%2x and stationID= %d",
1705 pRoamInfo->peerMac[0], pRoamInfo->peerMac[1], pRoamInfo->peerMac[2],
1706 pRoamInfo->peerMac[3], pRoamInfo->peerMac[4], pRoamInfo->peerMac[5],
1707 pRoamInfo->staId );
1708
1709 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
1710 {
1711 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1712 "New IBSS peer but we already have the max we can handle. Can't register this one" );
1713 break;
1714 }
1715
1716 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1717
1718 // Register the Station with TL for the new peer.
1719 vosStatus = hdd_roamRegisterSTA( pAdapter,
1720 pRoamInfo,
1721 pRoamInfo->staId,
1722 (v_MACADDR_t *)pRoamInfo->peerMac,
1723 pRoamInfo->pBssDesc );
1724 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1725 {
1726 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1727 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08lX]",
1728 vosStatus, vosStatus );
1729 }
1730
1731 netif_carrier_on(pAdapter->dev);
1732 netif_tx_start_all_queues(pAdapter->dev);
1733 break;
1734 }
1735
1736 case eCSR_ROAM_RESULT_IBSS_CONNECT:
1737 {
1738
1739 roamIbssConnectHandler( pAdapter, pRoamInfo );
1740
1741 break;
1742 }
1743 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
1744 {
1745
1746 if ( !roamRemoveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId ) )
1747 {
1748 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1749 "IBSS peer departed by cannot find peer in our registration table with TL" );
1750 }
1751
1752 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
1753
1754 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
1755
1756 break;
1757 }
1758 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
1759 {
1760 // Stop only when we are inactive
1761 netif_tx_disable(pAdapter->dev);
1762 netif_carrier_off(pAdapter->dev);
1763 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
1764
1765 // Send the bssid address to the wext.
1766 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
1767 // clean up data path
1768 hdd_disconnect_tx_rx(pAdapter);
1769 break;
1770 }
1771 default:
1772 break;
1773
1774 }
1775
1776 return( eHAL_STATUS_SUCCESS );
1777}
1778
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001779#ifdef FEATURE_WLAN_TDLS
1780/**============================================================================
1781 *
1782 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
1783 TL the new STA. This is called as part of ADD_STA in the TDLS setup
1784 Return: VOS_STATUS
1785
1786 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001787VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
1788 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001789{
1790 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1791 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
1792 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1793 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001794 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
1795 v_BOOL_t fConnected = FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001796
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001797 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1798 if (!fConnected) {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001799 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001800 "%s not connected. ignored", __func__);
1801 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001802 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001803
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001804 /*
1805 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
1806 * be peer MAC, here we are wokrking on direct Link
1807 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001808 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001809
1810 staDesc.wSTAType = WLAN_STA_TDLS ;
1811
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001812 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001813 sizeof(tSirMacAddr) );
1814
1815 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
1816 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1817
1818 /* set the QoS field appropriately ..*/
1819 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
1820 : (staDesc.ucQosEnabled = 0) ;
1821
1822 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
1823 TL QoS_enabled=%d\n", staDesc.ucQosEnabled );
1824
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001825 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001826
1827 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1828 "HDD register TL Sec_enabled= %d.\n", staDesc.ucProtectedFrame );
1829
1830 /*
1831 * UMA is ready we inform TL to do frame translation.
1832 */
1833 staDesc.ucSwFrameTXXlation = 1;
1834 staDesc.ucSwFrameRXXlation = 1;
1835 staDesc.ucAddRmvLLC = 1;
1836
1837 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001838 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001839
1840 /* tdls Direct Link do not need bcastSig */
1841 staDesc.ucBcastSig = 0 ;
1842
1843#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1844 if(staDesc.ucProtectedFrame)
1845 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1846 else
1847 staDesc.ucIsReplayCheckValid = VOS_FALSE;
1848#endif
1849
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001850 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001851
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001852 /* Register the Station with TL... */
1853 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
1854 hdd_rx_packet_cbk,
1855 hdd_tx_complete_cbk,
1856 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
1857
1858 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1859 {
1860 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1861 "WLANTL_RegisterSTAClient() failed to register. \
1862 Status= %d [0x%08lX]", vosStatus, vosStatus );
1863 return vosStatus;
1864 }
1865
1866 return( vosStatus );
1867}
1868
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08001869static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1870{
1871 VOS_STATUS vosStatus;
1872 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1873 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1874 {
1875 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1876 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
1877 "Status= %d [0x%08lX]",
1878 __func__, staId, vosStatus, vosStatus );
1879 }
1880 return( vosStatus );
1881}
1882
1883
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001884/*
1885 * HDD interface between SME and TL to ensure TDLS client registration with
1886 * TL in case of new TDLS client is added and deregistration at the time
1887 * TDLS client is deleted.
1888 */
1889
1890eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
1891 tCsrRoamInfo *pRoamInfo,
1892 tANI_U32 roamId,
1893 eRoamCmdStatus roamStatus,
1894 eCsrRoamResult roamResult)
1895{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001896 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001897 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001898 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001899
1900#ifdef WLAN_FEATURE_TDLS_DEBUG
1901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Leee6bfe942013-02-05 15:01:19 -08001902 ("hdd_tdlsStatusUpdate: %s staIdx %d %02x:%02x:%02x:%02x:%02x:%02x \n"),
1903 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" :
1904 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
1905 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND" :
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001906 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND? "DEL_ALL_TDLS_PEER_IND" :
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001907 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER? "UPDATE_TDLS_PEER" :
Hoonki Leee6bfe942013-02-05 15:01:19 -08001908 "UNKNOWN",
1909 pRoamInfo->staId,
1910 pRoamInfo->peerMac[0],
1911 pRoamInfo->peerMac[1],
1912 pRoamInfo->peerMac[2],
1913 pRoamInfo->peerMac[3],
1914 pRoamInfo->peerMac[4],
1915 pRoamInfo->peerMac[5]) ;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001916#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001917 switch( roamResult )
1918 {
1919 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
1920 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08001921 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
1922 {
1923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001924 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08001925 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001926 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001927 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001928
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001929 /* check if there is available index for this new TDLS STA */
1930 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
1931 {
1932 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
1933 {
1934 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
1935 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
1936
1937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001938 ("TDLS: STA IDX at %d is %d "
1939 "of mac %02x:%02x:%02x:%02x:%02x:%02x"),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001940 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
1941 pRoamInfo->peerMac[0],
1942 pRoamInfo->peerMac[1],
1943 pRoamInfo->peerMac[2],
1944 pRoamInfo->peerMac[3],
1945 pRoamInfo->peerMac[4],
1946 pRoamInfo->peerMac[5]) ;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001947
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001948 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001949 (v_MACADDR_t *)pRoamInfo->peerMac) ;
1950 status = eHAL_STATUS_SUCCESS ;
1951 break ;
1952 }
1953 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001954 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001955 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001956 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001957 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1958 "wlan_hdd_tdls_set_sta_id() failed");
1959 return VOS_FALSE;
1960 }
1961
1962 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1963 /* store the ucast signature which will be used later when
1964 registering to TL
1965 */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001966 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001967 }
1968 else
1969 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001970 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1972 "no availalbe slot in conn_info. staId %d cannot be stored", pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001973 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001974 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001975 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001976 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001977 break ;
1978 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001979 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
1980 {
1981 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
1982 {
1983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1984 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
1985 }
1986 /* store the ucast signature which will be used later when
1987 * registering to TL
1988 */
1989 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
1990 complete(&pAdapter->tdls_add_station_comp);
1991 break;
1992 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001993 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001994 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001995 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001996 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001997 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
1998 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001999 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002001 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2002
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002003 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002004 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002005 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002006
2007 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = NULL;
2008
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002009 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2010 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2011 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002012 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002013 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002014 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002015 break ;
2016 }
2017 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002018 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002019 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002020 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2021 {
2022 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2023 "%s: Sending teardown to supplicant with reason code %u",
2024 __func__, pRoamInfo->reasonCode);
2025
2026#ifdef CONFIG_TDLS_IMPLICIT
2027 cfg80211_tdls_oper_request(pAdapter->dev,
2028 pRoamInfo->peerMac,
2029 NL80211_TDLS_TEARDOWN,
2030 pRoamInfo->reasonCode,
2031 GFP_KERNEL);
2032#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002033 status = eHAL_STATUS_SUCCESS ;
2034 break ;
2035 }
2036 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2037 {
2038 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002039 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002040 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002041 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2042 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002043 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002045 ("hdd_tdlsStatusUpdate: staIdx %d %02x:%02x:%02x:%02x:%02x:%02x"),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002046 pHddCtx->tdlsConnInfo[staIdx].staId,
2047 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[0],
2048 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[1],
2049 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[2],
2050 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[3],
2051 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[4],
2052 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[5]) ;
2053 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2054 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2055 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002056
2057 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[staIdx] = NULL;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002058 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002059 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002060 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2061 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002062
2063 status = eHAL_STATUS_SUCCESS ;
2064 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002065 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002066 }
Hoonki Leee6bfe942013-02-05 15:01:19 -08002067 break ;
2068 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002069 default:
2070 {
2071 break ;
2072 }
2073 }
2074
2075 return status ;
2076}
2077#endif
2078
Jeff Johnson295189b2012-06-20 16:38:30 -07002079eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
2080 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2081{
2082 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2083 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302084 hdd_wext_state_t *pWextState = NULL;
2085 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002086 VOS_STATUS status = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002087
2088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2089 "CSR Callback: status= %d result= %d roamID=%ld",
2090 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002091
2092 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302093 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002094 {
2095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302096 "invalid adapter or adapter has invalid magic");
2097 return eHAL_STATUS_FAILURE;
2098 }
2099
2100 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2101 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2102
2103 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2104 {
2105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2106 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002107 return eHAL_STATUS_FAILURE;
2108 }
2109
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 switch( roamStatus )
2111 {
2112 case eCSR_ROAM_SESSION_OPENED:
2113 if(pAdapter != NULL)
2114 {
2115 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2116 complete(&pAdapter->session_open_comp_var);
2117 }
2118 break;
2119
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002120#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 /* We did pre-auth,then we attempted a 11r or ccx reassoc.
2122 * reassoc failed due to failure, timeout, reject from ap
2123 * in any case tell the OS, our carrier is off and mark
2124 * interface down */
2125 case eCSR_ROAM_FT_REASSOC_FAILED:
2126 hddLog(LOG1, FL("Reassoc Failed\n"));
2127 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2128 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2129 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2131 }
2132 pHddStaCtx->ft_carrier_on = FALSE;
2133 break;
2134
2135 case eCSR_ROAM_FT_START:
2136 // When we roam for CCX and 11r, we dont want the
2137 // OS to be informed that the link is down. So mark
2138 // the link ready for ft_start. After this the
2139 // eCSR_ROAM_SHOULD_ROAM will be received.
2140 // Where in we will not mark the link down
2141 // Also we want to stop tx at this point when we will be
2142 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002143 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 {
2145 struct net_device *dev = pAdapter->dev;
2146 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002147 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002148 * Deregister for this STA with TL with the objective to flush
2149 * all the packets for this STA from wmm_tx_queue. If not done here,
2150 * we would run into a race condition (CR390567) wherein TX
2151 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2152 * been deleted. And, these packets get assigned with a STA idx of
2153 * self-sta (since the peer STA has been deleted) and get transmitted
2154 * on the new channel before the reassoc request. Since there will be
2155 * no ACK on the new channel, each packet gets retransmitted which
2156 * takes several seconds before the transmission of reassoc request.
2157 * This leads to reassoc-timeout and roam failure.
2158 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002159 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2160 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2161 {
2162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2163 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2164 pHddStaCtx->conn_info.staId[0], status, status );
2165 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 }
2168 pHddStaCtx->ft_carrier_on = TRUE;
2169 break;
2170#endif
2171
2172 case eCSR_ROAM_SHOULD_ROAM:
2173 // Dont need to do anything
2174 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 struct net_device *dev = pAdapter->dev;
2176 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2177 // notify apps that we can't pass traffic anymore
2178 netif_tx_disable(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002179#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 if (pHddStaCtx->ft_carrier_on == FALSE)
2181 {
2182#endif
2183 netif_carrier_off(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002184#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 }
2186#endif
2187
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002188#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 //We should clear all sta register with TL, for now, only one.
2190 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2191 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2192 {
2193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2194 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2195 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002196 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002198#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 // Clear saved connection information in HDD
2200 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
2201 }
2202 break;
2203 case eCSR_ROAM_LOSTLINK:
2204 case eCSR_ROAM_DISASSOCIATED:
2205 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2208 "****eCSR_ROAM_DISASSOCIATED****");
2209 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2210 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2211 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
2212 hdd_conf_mcastbcast_filter((WLAN_HDD_GET_CTX(pAdapter)), FALSE);
2213 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2214 }
2215#ifdef WLAN_FEATURE_PACKET_FILTERING
2216 if (pHddCtx->cfg_ini->isMcAddrListFilter)
2217 {
2218 /*Multicast addr filtering is enabled*/
Gopichand Nakkala0f276812013-02-24 14:45:51 +05302219 if (pAdapter->mc_addr_list.isFilterApplied)
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 {
2221 /*Filter applied during suspend mode*/
2222 /*Clear it here*/
Gopichand Nakkala0f276812013-02-24 14:45:51 +05302223 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 }
2225 }
2226#endif
2227
Jeff Johnsone7245742012-09-05 17:12:55 -07002228 if (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode)
2229 {
2230 /* Disconnected from current AP. Reset the country code information
2231 * so that it re-initialize the valid channel list*/
2232 hdd_ResetCountryCodeAfterDisAssoc(pAdapter);
2233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 }
2235 break;
2236 case eCSR_ROAM_IBSS_LEAVE:
2237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2238 "****eCSR_ROAM_IBSS_LEAVE****");
2239 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2240 break;
2241 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2243 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
2244 if ( (roamResult != eCSR_ROAM_RESULT_ASSOCIATED)
2245 && ( (pWextState->roamProfile.EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY)
2246 || (pWextState->roamProfile.EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)
2247 )
2248 && (eCSR_AUTH_TYPE_SHARED_KEY != pWextState->roamProfile.AuthType.authType[0])
2249 )
2250 {
2251 v_U32_t roamId = 0;
2252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2253 "****WEP open authentication failed, trying with shared authentication****");
2254 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
2255 pWextState->roamProfile.AuthType.authType[0] = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2256 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2257 halStatus = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &(pWextState->roamProfile), &roamId);
2258 }
2259 else
2260 {
2261 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2262 }
2263
2264 break;
2265 case eCSR_ROAM_ASSOCIATION_FAILURE:
2266 halStatus = hdd_AssociationCompletionHandler( pAdapter,
2267 pRoamInfo, roamId, roamStatus, roamResult );
2268 break;
2269 case eCSR_ROAM_IBSS_IND:
2270 halStatus = roamRoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2271 break;
2272
2273 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2274 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2275 break;
2276
2277 case eCSR_ROAM_MIC_ERROR_IND:
2278 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2279 break;
2280
2281 case eCSR_ROAM_SET_KEY_COMPLETE:
2282 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2283 break;
2284#ifdef WLAN_FEATURE_VOWIFI_11R
2285 case eCSR_ROAM_FT_RESPONSE:
2286 hdd_SendFTEvent(pAdapter);
2287 break;
2288#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002289#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002290 case eCSR_ROAM_PMK_NOTIFY:
Jeff Johnson43971f52012-07-17 12:26:56 -07002291 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
2292 {
2293 /* Notify the supplicant of a new candidate */
2294 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2295 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002296 break;
2297#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002298
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2300 hdd_indicateMgmtFrame( pAdapter,
2301 pRoamInfo->nFrameLength,
2302 pRoamInfo->pbFrames,
2303 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302304 pRoamInfo->rxChan,
2305 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 break;
2307 case eCSR_ROAM_REMAIN_CHAN_READY:
2308 hdd_remainChanReadyHandler( pAdapter );
2309 break;
2310 case eCSR_ROAM_SEND_ACTION_CNF:
2311 hdd_sendActionCnf( pAdapter,
2312 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2313 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002314#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002315 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002316 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002317 roamId, roamStatus, roamResult );
2318 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002319 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2320 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2321 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002322#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 default:
2324 break;
2325 }
2326 return( halStatus );
2327}
2328eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
2329{
2330 eCsrAuthType auth_type;
2331 // is the auth type supported?
2332 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
2333 {
2334 auth_type = eCSR_AUTH_TYPE_RSN;
2335 } else
2336 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
2337 {
2338 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
2339 } else
2340#ifdef WLAN_FEATURE_VOWIFI_11R
2341 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
2342 {
2343 // Check for 11r FT Authentication with PSK
2344 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
2345 } else
2346 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
2347 {
2348 // Check for 11R FT Authentication with 802.1X
2349 auth_type = eCSR_AUTH_TYPE_FT_RSN;
2350 } else
2351#endif
2352#ifdef FEATURE_WLAN_CCX
2353 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
2354 {
2355 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2356 } else
2357#endif /* FEATURE_WLAN_CCX */
2358 {
2359 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2360 }
2361 return auth_type;
2362}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002363
Jeff Johnson295189b2012-06-20 16:38:30 -07002364eCsrAuthType
2365hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002366{
2367 eCsrAuthType auth_type;
2368 // is the auth type supported?
2369 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
2370 {
2371 auth_type = eCSR_AUTH_TYPE_WPA;
2372 } else
2373 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
2374 {
2375 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
2376 } else
2377#ifdef FEATURE_WLAN_CCX
2378 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
2379 {
2380 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
2381 } else
2382#endif /* FEATURE_WLAN_CCX */
2383 {
2384 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2385 }
2386 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2387 return auth_type;
2388}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002389
Jeff Johnson295189b2012-06-20 16:38:30 -07002390eCsrEncryptionType
2391hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002392{
2393 eCsrEncryptionType cipher_type;
2394 // is the cipher type supported?
2395 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
2396 {
2397 cipher_type = eCSR_ENCRYPT_TYPE_AES;
2398 }
2399 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
2400 {
2401 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
2402 }
2403 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
2404 {
2405 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
2406 }
2407 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
2408 {
2409 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2410 }
2411 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2412 {
2413 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2414 }
2415 else
2416 {
2417 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2418 }
2419 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2420 return cipher_type;
2421}
2422/* To find if the MAC address is NULL */
2423static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
2424{
2425 int i;
2426 for (i = 0; i < length; i++)
2427 {
2428 if (0x00 != (macAddr[i]))
2429 {
2430 return FALSE;
2431 }
2432 }
2433 return TRUE;
2434} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08002435
Jeff Johnson295189b2012-06-20 16:38:30 -07002436eCsrEncryptionType
2437hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002438{
2439 eCsrEncryptionType cipher_type;
2440 // is the cipher type supported?
2441 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
2442 {
2443 cipher_type = eCSR_ENCRYPT_TYPE_AES;
2444 } else
2445 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
2446 {
2447 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
2448 } else
2449 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
2450 {
2451 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
2452 } else
2453 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
2454 {
2455 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2456 } else
2457 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
2458 {
2459 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2460 } else
2461 {
2462 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2463 }
2464 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2465 return cipher_type;
2466}
2467
2468static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
2469 struct ether_addr *pBssid,
2470 eCsrEncryptionType *pEncryptType,
2471 eCsrEncryptionType *mcEncryptType,
2472 eCsrAuthType *pAuthType,
2473 u_int16_t gen_ie_len,
2474 u_int8_t *gen_ie)
2475{
2476 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
2477 eHalStatus result;
2478 tDot11fIERSN dot11RSNIE;
2479 tDot11fIEWPA dot11WPAIE;
2480 tANI_U32 i;
2481 tANI_U8 *pRsnIe;
2482 tANI_U16 RSNIeLen;
2483 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
2484
2485 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
2486 flag to 0 */
2487 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
2488 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
2489
2490 // Validity checks
2491 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
2492 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
2493 return -EINVAL;
2494 // Type check
2495 if ( gen_ie[0] == DOT11F_EID_RSN)
2496 {
2497 // Validity checks
2498 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
2499 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
2500 {
2501 return -EINVAL;
2502 }
2503 // Skip past the EID byte and length byte
2504 pRsnIe = gen_ie + 2;
2505 RSNIeLen = gen_ie_len - 2;
2506 // Unpack the RSN IE
2507 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
2508 pRsnIe,
2509 RSNIeLen,
2510 &dot11RSNIE);
2511 // Copy out the encryption and authentication types
2512 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002513 __func__, dot11RSNIE.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07002514 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002515 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 /*Here we have followed the apple base code,
2517 but probably I suspect we can do something different*/
2518 //dot11RSNIE.akm_suite_count
2519 // Just translate the FIRST one
2520 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
2521 //dot11RSNIE.pwise_cipher_suite_count
2522 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
2523 //dot11RSNIE.gp_cipher_suite_count
2524 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
2525 // Set the PMKSA ID Cache for this interface
2526 for (i=0; i<dot11RSNIE.pmkid_count; i++)
2527 {
2528 if ( pBssid == NULL)
2529 {
2530 break;
2531 }
2532 if ( hdd_IsMACAddrNULL( (u_char *) pBssid , sizeof( (char *) pBssid)))
2533 {
2534 break;
2535 }
2536 // For right now, I assume setASSOCIATE() has passed in the bssid.
2537 vos_mem_copy(PMKIDCache[i].BSSID,
2538 pBssid, ETHER_ADDR_LEN);
2539 vos_mem_copy(PMKIDCache[i].PMKID,
2540 dot11RSNIE.pmkid[i],
2541 CSR_RSN_PMKID_SIZE);
2542 }
2543 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
2544 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %ld."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002545 __func__, i );
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 // Finally set the PMKSA ID Cache in CSR
2547 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
2548 PMKIDCache,
2549 dot11RSNIE.pmkid_count );
2550 }
2551 else if (gen_ie[0] == DOT11F_EID_WPA)
2552 {
2553 // Validity checks
2554 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
2555 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
2556 {
2557 return -EINVAL;
2558 }
2559 // Skip past the EID byte and length byte - and four byte WiFi OUI
2560 pRsnIe = gen_ie + 2 + 4;
2561 RSNIeLen = gen_ie_len - (2 + 4);
2562 // Unpack the WPA IE
2563 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
2564 pRsnIe,
2565 RSNIeLen,
2566 &dot11WPAIE);
2567 // Copy out the encryption and authentication types
2568 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002569 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002571 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07002572 //dot11WPAIE.auth_suite_count
2573 // Just translate the FIRST one
2574 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
2575 //dot11WPAIE.unicast_cipher_count
2576 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
2577 //dot11WPAIE.unicast_cipher_count
2578 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
2579 }
2580 else
2581 {
2582 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
2583 return -EINVAL;
2584 }
2585 return 0;
2586}
2587int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
2588{
2589 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2590 v_U32_t status = 0;
2591 eCsrEncryptionType RSNEncryptType;
2592 eCsrEncryptionType mcRSNEncryptType;
2593 struct ether_addr bSsid; // MAC address of assoc peer
2594 // MAC address of assoc peer
2595 // But, this routine is only called when we are NOT associated.
2596 vos_mem_copy(bSsid.ether_addr_octet,
2597 pWextState->roamProfile.BSSIDs.bssid,
2598 sizeof(bSsid.ether_addr_octet));
2599 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
2600 {
2601 //continue
2602 }
2603 else
2604 {
2605 return 0;
2606 }
2607 // The actual processing may eventually be more extensive than this.
2608 // Right now, just consume any PMKIDs that are sent in by the app.
2609 status = hdd_ProcessGENIE(pAdapter,
2610 &bSsid, // MAC address of assoc peer
2611 &RSNEncryptType,
2612 &mcRSNEncryptType,
2613 RSNAuthType,
2614 pWextState->WPARSNIE[1]+2,
2615 pWextState->WPARSNIE);
2616 if (status == 0)
2617 {
2618 // Now copy over all the security attributes you have parsed out
2619 pWextState->roamProfile.EncryptionType.numEntries = 1;
2620 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
2621
2622 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
2623 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002624 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 }
2626 return 0;
2627}
2628int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
2629{
2630 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2631 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
2632 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2633 ENTER();
2634
2635 pRoamProfile->AuthType.numEntries = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002636 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d\n", __func__, pHddStaCtx->conn_info.authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002637
2638 switch( pHddStaCtx->conn_info.authType)
2639 {
2640 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2641#ifdef FEATURE_WLAN_CCX
2642 case eCSR_AUTH_TYPE_CCKM_WPA:
2643 case eCSR_AUTH_TYPE_CCKM_RSN:
2644#endif
2645 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
2646
2647 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
2648 } else
2649 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
2650
2651#ifdef FEATURE_WLAN_CCX
2652 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
2653 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2654 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002655 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
2657 } else
2658 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002659 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
2661 } else
2662#endif
2663 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2664 == IW_AUTH_KEY_MGMT_802_1X) {
2665 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
2666 } else
2667 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2668 == IW_AUTH_KEY_MGMT_PSK) {
2669 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
2670 } else {
2671 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
2672 }
2673 }
2674 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
2675#ifdef FEATURE_WLAN_CCX
2676 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
2677 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2678 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002679 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
2681 } else
2682 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002683 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
2685 } else
2686#endif
2687
2688#ifdef WLAN_FEATURE_VOWIFI_11R
2689 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
2690 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2691 == IW_AUTH_KEY_MGMT_802_1X)) {
2692 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07002693 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07002694 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
2695 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2696 == IW_AUTH_KEY_MGMT_PSK)) {
2697 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
2698 } else
2699#endif
2700
2701 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2702 == IW_AUTH_KEY_MGMT_802_1X) {
2703 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
2704 } else
2705 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2706 == IW_AUTH_KEY_MGMT_PSK) {
2707 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
2708 } else {
2709 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
2710 }
2711 }
2712 break;
2713
2714 case eCSR_AUTH_TYPE_SHARED_KEY:
2715
2716 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
2717 break;
2718 default:
2719
2720#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002721 hddLog( LOG1, "%s: In default, unknown auth type.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002722#endif /* FEATURE_WLAN_CCX */
2723 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
2724 break;
2725 }
2726
2727 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002728 __func__, pWextState->roamProfile.AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002729
2730 EXIT();
2731 return 0;
2732}
2733
2734/**---------------------------------------------------------------------------
2735
2736 \brief iw_set_essid() -
2737 This function sets the ssid received from wpa_supplicant
2738 to the CSR roam profile.
2739
2740 \param - dev - Pointer to the net device.
2741 - info - Pointer to the iw_request_info.
2742 - wrqu - Pointer to the iwreq_data.
2743 - extra - Pointer to the data.
2744 \return - 0 for success, non zero for failure
2745
2746 --------------------------------------------------------------------------*/
2747
2748int iw_set_essid(struct net_device *dev,
2749 struct iw_request_info *info,
2750 union iwreq_data *wrqu, char *extra)
2751{
2752 v_U32_t status = 0;
2753 hdd_wext_state_t *pWextState;
2754 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2755 v_U32_t roamId;
2756 tCsrRoamProfile *pRoamProfile;
2757 eMib_dot11DesiredBssType connectedBssType;
2758 eCsrAuthType RSNAuthType;
2759 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2760 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2761
2762 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2763
2764 ENTER();
2765
2766 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2767 {
2768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2769 "%s:LOGP in Progress. Ignore!!!",__func__);
2770 return 0;
2771 }
2772
2773 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
2774 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
2775 return -EBUSY;
2776 }
2777 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
2778 return -EINVAL;
2779 pRoamProfile = &pWextState->roamProfile;
2780 if (pRoamProfile)
2781 {
2782 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
2783 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
2784 {
2785 VOS_STATUS vosStatus;
2786 // need to issue a disconnect to CSR.
2787 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2788 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
2789
2790 if(VOS_STATUS_SUCCESS == vosStatus)
2791 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
2792 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2793 }
2794 }
2795 /** wpa_supplicant 0.8.x, wext driver uses */
2796 else
2797 {
2798 return -EINVAL;
2799 }
2800 /** wpa_supplicant 0.8.x, wext driver uses */
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 /** when cfg80211 defined, wpa_supplicant wext driver uses
2802 zero-length, null-string ssid for force disconnection.
2803 after disconnection (if previously connected) and cleaning ssid,
2804 driver MUST return success */
2805 if ( 0 == wrqu->essid.length ) {
2806 return 0;
2807 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002808
2809 status = hdd_wmm_get_uapsd_mask(pAdapter,
2810 &pWextState->roamProfile.uapsd_mask);
2811 if (VOS_STATUS_SUCCESS != status)
2812 {
2813 pWextState->roamProfile.uapsd_mask = 0;
2814 }
2815 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
2816
2817 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
2818
2819 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
2820 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
2821 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
2822 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
2823
2824 //set gen ie
2825 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
2826
2827 //set auth
2828 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
2829 }
2830#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002831 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 if (pAdapter->wapi_info.nWapiMode)
2833 {
2834 switch (pAdapter->wapi_info.wapiAuthMode)
2835 {
2836 case WAPI_AUTH_MODE_PSK:
2837 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002838 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 pRoamProfile->AuthType.numEntries = 1;
2840 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
2841 break;
2842 }
2843 case WAPI_AUTH_MODE_CERT:
2844 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002845 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 pRoamProfile->AuthType.numEntries = 1;
2847 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
2848 break;
2849 }
2850 } // End of switch
2851 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
2852 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
2853 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002854 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 pRoamProfile->EncryptionType.numEntries = 1;
2856 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
2857 pRoamProfile->mcEncryptionType.numEntries = 1;
2858 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
2859 }
2860 }
2861#endif /* FEATURE_WLAN_WAPI */
2862 /* if previous genIE is not NULL, update AssocIE */
2863 if (0 != pWextState->genIE.length)
2864 {
2865 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
2866 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
2867 pWextState->genIE.length);
2868 pWextState->assocAddIE.length = pWextState->genIE.length;
2869 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
2870 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
2871
2872 /* clear previous genIE after use it */
2873 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2874 }
2875
2876 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
2877 pWextState->roamProfile.bWPSAssociation = FALSE;
2878
2879 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
2880 pWextState->roamProfile.nAddIEAssocLength))
2881 pWextState->roamProfile.bWPSAssociation = TRUE;
2882
2883
2884 // Disable auto BMPS entry by PMC until DHCP is done
2885 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
2886
2887 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2888 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
2889 status = sme_RoamConnect( hHal,pAdapter->sessionId, &(pWextState->roamProfile),&roamId);
2890 pRoamProfile->ChannelInfo.ChannelList = NULL;
2891 pRoamProfile->ChannelInfo.numOfChannels = 0;
2892
2893 EXIT();
2894 return status;
2895}
2896/**---------------------------------------------------------------------------
2897
2898 \brief iw_get_essid() -
2899 This function returns the essid to the wpa_supplicant.
2900
2901 \param - dev - Pointer to the net device.
2902 - info - Pointer to the iw_request_info.
2903 - wrqu - Pointer to the iwreq_data.
2904 - extra - Pointer to the data.
2905 \return - 0 for success, non zero for failure
2906
2907 --------------------------------------------------------------------------*/
2908int iw_get_essid(struct net_device *dev,
2909 struct iw_request_info *info,
2910 struct iw_point *dwrq, char *extra)
2911{
2912 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2913 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2914 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2915 ENTER();
2916
2917 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
2918 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
2919 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
2920 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
2921 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
2922 {
2923 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
2924 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
2925 dwrq->flags = 1;
2926 } else {
2927 memset(extra, 0, dwrq->length);
2928 dwrq->length = 0;
2929 dwrq->flags = 0;
2930 }
2931 EXIT();
2932 return 0;
2933}
2934/**---------------------------------------------------------------------------
2935
2936 \brief iw_set_auth() -
2937 This function sets the auth type received from the wpa_supplicant.
2938
2939 \param - dev - Pointer to the net device.
2940 - info - Pointer to the iw_request_info.
2941 - wrqu - Pointer to the iwreq_data.
2942 - extra - Pointer to the data.
2943 \return - 0 for success, non zero for failure
2944
2945 --------------------------------------------------------------------------*/
2946int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
2947 union iwreq_data *wrqu,char *extra)
2948{
2949 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2950 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2951 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2952 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
2953 eCsrEncryptionType mcEncryptionType;
2954 eCsrEncryptionType ucEncryptionType;
2955
2956 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002957
2958 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2959 {
2960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2961 "%s:LOGP in Progress. Ignore!!!", __func__);
2962 return -EBUSY;
2963 }
2964
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 switch(wrqu->param.flags & IW_AUTH_INDEX)
2966 {
2967 case IW_AUTH_WPA_VERSION:
2968
2969 pWextState->wpaVersion = wrqu->param.value;
2970
2971 break;
2972
2973 case IW_AUTH_CIPHER_PAIRWISE:
2974 {
2975 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
2976 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
2977 }
2978 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
2979 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
2980 }
2981 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
2982 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
2983 }
2984
2985 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
2986
2987 if( (IW_AUTH_KEY_MGMT_802_1X
2988 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
2989 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
2990 /*Dynamic WEP key*/
2991 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
2992 else
2993 /*Static WEP key*/
2994 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2995 }
2996 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
2997
2998 if( ( IW_AUTH_KEY_MGMT_802_1X
2999 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
3000 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3001 /*Dynamic WEP key*/
3002 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3003 else
3004 /*Static WEP key*/
3005 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3006
3007 }
3008 else {
3009
3010 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003011 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 return -EINVAL;
3013 }
3014
3015 pRoamProfile->EncryptionType.numEntries = 1;
3016 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
3017 }
3018 break;
3019 case IW_AUTH_CIPHER_GROUP:
3020 {
3021 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3022 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3023 }
3024
3025 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3026 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3027 }
3028
3029 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3030 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3031 }
3032
3033 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
3034
3035 if( ( IW_AUTH_KEY_MGMT_802_1X
3036 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3037 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3038
3039 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3040
3041 else
3042 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3043 }
3044
3045 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3046 {
3047 /*Dynamic WEP keys won't work with shared keys*/
3048 if( ( IW_AUTH_KEY_MGMT_802_1X
3049 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
3050 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3051 {
3052 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3053 }
3054 else
3055 {
3056 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3057 }
3058 }
3059 else {
3060
3061 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003062 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 return -EINVAL;
3064 }
3065
3066 pRoamProfile->mcEncryptionType.numEntries = 1;
3067 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3068 }
3069 break;
3070
3071 case IW_AUTH_80211_AUTH_ALG:
3072 {
3073 /*Save the auth algo here and set auth type to SME Roam profile
3074 in the iw_set_ap_address*/
3075 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
3076 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3077
3078 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3079 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3080
3081 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3082 /*Not supported*/
3083 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3084 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3085 }
3086 break;
3087
3088 case IW_AUTH_KEY_MGMT:
3089 {
3090#ifdef FEATURE_WLAN_CCX
3091#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3092 /*Check for CCKM AKM type */
3093 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003094 //hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
3095 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 /* Set the CCKM bit in authKeyMgmt */
3097 /* Right now, this breaks all ref to authKeyMgmt because our
3098 * code doesn't realize it is a "bitfield"
3099 */
3100 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3101 /*Set the key management to 802.1X*/
3102 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
3103 pWextState->isCCXConnection = eANI_BOOLEAN_TRUE;
3104 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3105 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3106 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3107 /*Save the key management*/
3108 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3109 //pWextState->authKeyMgmt = wrqu->param.value;
3110 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3111 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3112 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3113 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3114 /*Save the key management anyway*/
3115 pWextState->authKeyMgmt = wrqu->param.value;
3116 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3117 /*Save the key management*/
3118 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3119 //pWextState->authKeyMgmt = wrqu->param.value;
3120 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3121 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3122 }
3123#else
3124 /*Save the key management*/
3125 pWextState->authKeyMgmt = wrqu->param.value;
3126#endif /* FEATURE_WLAN_CCX */
3127 }
3128 break;
3129
3130 case IW_AUTH_TKIP_COUNTERMEASURES:
3131 {
3132 if(wrqu->param.value) {
3133 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3134 "Counter Measure started %d", wrqu->param.value);
3135 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3136 }
3137 else {
3138 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3139 "Counter Measure stopped=%d", wrqu->param.value);
3140 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3141 }
3142 }
3143 break;
3144 case IW_AUTH_DROP_UNENCRYPTED:
3145 case IW_AUTH_WPA_ENABLED:
3146 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3147 case IW_AUTH_ROAMING_CONTROL:
3148 case IW_AUTH_PRIVACY_INVOKED:
3149
3150 default:
3151
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003152 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 wrqu->param.flags & IW_AUTH_INDEX);
3154 break;
3155 }
3156
3157 EXIT();
3158 return 0;
3159}
3160/**---------------------------------------------------------------------------
3161
3162 \brief iw_get_auth() -
3163 This function returns the auth type to the wpa_supplicant.
3164
3165 \param - dev - Pointer to the net device.
3166 - info - Pointer to the iw_request_info.
3167 - wrqu - Pointer to the iwreq_data.
3168 - extra - Pointer to the data.
3169 \return - 0 for success, non zero for failure
3170
3171 --------------------------------------------------------------------------*/
3172int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3173 union iwreq_data *wrqu,char *extra)
3174{
3175 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3176 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3177 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3178 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003179
3180 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3181 {
3182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3183 "%s:LOGP in Progress. Ignore!!!", __func__);
3184 return -EBUSY;
3185 }
3186
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 switch(pRoamProfile->negotiatedAuthType)
3188 {
3189 case eCSR_AUTH_TYPE_WPA_NONE:
3190 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3191 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3192 break;
3193 case eCSR_AUTH_TYPE_WPA:
3194 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3195 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3196 break;
3197#ifdef WLAN_FEATURE_VOWIFI_11R
3198 case eCSR_AUTH_TYPE_FT_RSN:
3199#endif
3200 case eCSR_AUTH_TYPE_RSN:
3201 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3202 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3203 break;
3204 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3205 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3206 break;
3207 case eCSR_AUTH_TYPE_SHARED_KEY:
3208 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3209 break;
3210 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003211 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3213 break;
3214 case eCSR_AUTH_TYPE_AUTOSWITCH:
3215 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3216 break;
3217 case eCSR_AUTH_TYPE_WPA_PSK:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003218 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3220 return -EIO;
3221#ifdef WLAN_FEATURE_VOWIFI_11R
3222 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3223#endif
3224 case eCSR_AUTH_TYPE_RSN_PSK:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003225 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3227 return -EIO;
3228 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003229 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3231 return -EIO;
3232 }
3233 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3234 {
3235 switch(pRoamProfile->negotiatedUCEncryptionType)
3236 {
3237 case eCSR_ENCRYPT_TYPE_NONE:
3238 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3239 break;
3240 case eCSR_ENCRYPT_TYPE_WEP40:
3241 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3242 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3243 break;
3244 case eCSR_ENCRYPT_TYPE_TKIP:
3245 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3246 break;
3247 case eCSR_ENCRYPT_TYPE_WEP104:
3248 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3249 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3250 break;
3251 case eCSR_ENCRYPT_TYPE_AES:
3252 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3253 break;
3254 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003255 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 return -EIO;
3257 }
3258 }
3259
3260 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
3261 {
3262 switch(pRoamProfile->negotiatedMCEncryptionType)
3263 {
3264 case eCSR_ENCRYPT_TYPE_NONE:
3265 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3266 break;
3267 case eCSR_ENCRYPT_TYPE_WEP40:
3268 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3269 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3270 break;
3271 case eCSR_ENCRYPT_TYPE_TKIP:
3272 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3273 break;
3274 case eCSR_ENCRYPT_TYPE_WEP104:
3275 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3276 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3277 break;
3278 case eCSR_ENCRYPT_TYPE_AES:
3279 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3280 break;
3281 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003282 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 return -EIO;
3284 }
3285 }
3286
3287 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003288 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 EXIT();
3290 return 0;
3291}
3292/**---------------------------------------------------------------------------
3293
3294 \brief iw_set_ap_address() -
3295 This function calls the sme_RoamConnect function to associate
3296 to the AP with the specified BSSID received from the wpa_supplicant.
3297
3298 \param - dev - Pointer to the net device.
3299 - info - Pointer to the iw_request_info.
3300 - wrqu - Pointer to the iwreq_data.
3301 - extra - Pointer to the data.
3302 \return - 0 for success, non zero for failure
3303
3304 --------------------------------------------------------------------------*/
3305int iw_set_ap_address(struct net_device *dev,
3306 struct iw_request_info *info,
3307 union iwreq_data *wrqu, char *extra)
3308{
3309 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3310 v_U8_t *pMacAddress=NULL;
3311 ENTER();
3312 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
3313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%02x:%02x:%02x:%02x:%02x:%02x",pMacAddress[0],pMacAddress[1],
3314 pMacAddress[2],pMacAddress[3],pMacAddress[4],pMacAddress[5]);
3315 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3316 EXIT();
3317
3318 return 0;
3319}
3320/**---------------------------------------------------------------------------
3321
3322 \brief iw_get_ap_address() -
3323 This function returns the BSSID to the wpa_supplicant
3324 \param - dev - Pointer to the net device.
3325 - info - Pointer to the iw_request_info.
3326 - wrqu - Pointer to the iwreq_data.
3327 - extra - Pointer to the data.
3328 \return - 0 for success, non zero for failure
3329
3330 --------------------------------------------------------------------------*/
3331int iw_get_ap_address(struct net_device *dev,
3332 struct iw_request_info *info,
3333 union iwreq_data *wrqu, char *extra)
3334{
3335 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3336 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3337
3338 ENTER();
3339
3340 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3341 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3342 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003343 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 }
3345 else
3346 {
3347 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
3348 }
3349 EXIT();
3350 return 0;
3351}
Jeff Johnsond13512a2012-07-17 11:42:19 -07003352
3353
3354/**---------------------------------------------------------------------------
3355
3356 \brief hdd_ResetCountryCodeAfterDisAssoc -
3357 This function reset the country code to default
Jeff Johnsona8a1a482012-12-12 16:49:33 -08003358 \param - pAdapter - Pointer to HDD adapter
Jeff Johnsond13512a2012-07-17 11:42:19 -07003359 \return - nothing
3360
3361 --------------------------------------------------------------------------*/
3362void hdd_ResetCountryCodeAfterDisAssoc(hdd_adapter_t *pAdapter)
3363{
3364 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3365 tSmeConfigParams smeConfig;
3366 eHalStatus status = eHAL_STATUS_SUCCESS;
3367 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
3368 tANI_U8 currentCountryCode[3] = SME_INVALID_COUNTRY_CODE;
3369
3370 sme_GetConfigParam(pHddCtx->hHal, &smeConfig);
3371
3372 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3373 "%s: 11d is %s\n",__func__,
3374 smeConfig.csrConfig.Is11dSupportEnabled ? "Enabled" : "Disabled");
3375 /* Reset country code only when 11d is enabled
3376 */
3377 if (smeConfig.csrConfig.Is11dSupportEnabled)
3378 {
3379 sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, &defaultCountryCode[0]);
3380 sme_GetCurrentCountryCode(pHddCtx->hHal, &currentCountryCode[0]);
3381
3382 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3383 "%s: Default country code: %c%c%c, Current Country code: %c%c%c \n",
3384 __func__,
3385 defaultCountryCode[0], defaultCountryCode[1], defaultCountryCode[2],
3386 currentCountryCode[0], currentCountryCode[1], currentCountryCode[2]);
3387 /* Reset country code only when there is a mismatch
3388 * between current country code and default country code
3389 */
3390 if ((defaultCountryCode[0] != currentCountryCode[0]) ||
3391 (defaultCountryCode[1] != currentCountryCode[1]) ||
3392 (defaultCountryCode[2] != currentCountryCode[2]))
3393 {
3394 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3395 "%s: Disconnected from the AP/Assoc failed and "
3396 "resetting the country code to default\n",__func__);
3397 /*reset the country code of previous connection*/
3398 status = (int)sme_ChangeCountryCode(pHddCtx->hHal, NULL,
3399 &defaultCountryCode[0], pAdapter,
3400 pHddCtx->pvosContext
3401 );
3402 if( 0 != status )
3403 {
3404 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3405 "%s: failed to Reset the Country Code\n",__func__);
3406 }
3407 }
3408 }
Kiran4a17ebe2013-01-31 10:43:43 -08003409 else if (smeConfig.csrConfig.Is11hSupportEnabled)
3410 {
3411 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3412 "%s: Disconnected from the AP/Assoc failed and "
3413 "resetting the 5G power values to default", __func__);
3414 sme_ResetPowerValuesFor5G (pHddCtx->hHal);
3415 }
Jeff Johnsond13512a2012-07-17 11:42:19 -07003416}
3417