blob: 44fe9d9f653abebb2309a133a3d73d3858e30807 [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"
74#ifdef CONFIG_CFG80211
75#include <linux/ieee80211.h>
76#include <linux/wireless.h>
77#include <net/cfg80211.h>
78#include "wlan_hdd_cfg80211.h"
79#include "csrInsideApi.h"
80#endif
81#if defined CONFIG_CFG80211
82#include "wlan_hdd_p2p.h"
83#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080084#ifdef FEATURE_WLAN_TDLS
85#include "wlan_hdd_tdls.h"
86#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070087#include "sme_Api.h"
88
89v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
90
91struct ether_addr
92{
93 u_char ether_addr_octet[6];
94};
95// These are needed to recognize WPA and RSN suite types
96#define HDD_WPA_OUI_SIZE 4
97v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
98v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
99v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
100v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
101v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
102v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
103#ifdef FEATURE_WLAN_CCX
104v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
105#endif /* FEATURE_WLAN_CCX */
106#define HDD_RSN_OUI_SIZE 4
107v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
108v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
109v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
110v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
111v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
112v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
113#ifdef FEATURE_WLAN_CCX
114v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
115#endif /* FEATURE_WLAN_CCX */
116
117#if defined(WLAN_FEATURE_VOWIFI_11R)
118// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700119#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
120#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700121#endif
122
123#define BEACON_FRAME_IES_OFFSET 12
124
125#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnsone7245742012-09-05 17:12:55 -0700126extern void wlan_hdd_set_mc_addr_list(hdd_context_t *pHddCtx, v_U8_t set, v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700127#endif
128
Jeff Johnsond13512a2012-07-17 11:42:19 -0700129void hdd_ResetCountryCodeAfterDisAssoc(hdd_adapter_t *pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700130
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530131v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
132 eConnectionState connState )
133{
134 // save the new connection state
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 pHddStaCtx->conn_info.connState = connState;
136}
137
138// returns FALSE if not connected.
139// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
140// returns the connection state. Can specify NULL if you dont' want to get the actual state.
141
142static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
143 eConnectionState *pConnState )
144{
145 v_BOOL_t fConnected;
146 eConnectionState connState;
147
148 // get the connection state.
149 connState = pHddStaCtx->conn_info.connState;
150 // Set the fConnected return variable based on the Connected State.
151 if ( eConnectionState_Associated == connState ||
152 eConnectionState_IbssConnected == connState )
153 {
154 fConnected = VOS_TRUE;
155 }
156 else
157 {
158 fConnected = VOS_FALSE;
159 }
160
161 if ( pConnState )
162 {
163 *pConnState = connState;
164 }
165
166 return( fConnected );
167}
168
169v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
170{
171 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
172}
173
174//TODO - Not used anyhwere. Can be removed.
175#if 0
176//
177v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
178{
179 v_BOOL_t fConnectedInfra = FALSE;
180 eConnectionState connState;
181
182 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
183 {
184 if ( eConnectionState_Associated == connState )
185 {
186 fConnectedInfra = TRUE;
187 }
188 }
189
190 return( fConnectedInfra );
191}
192#endif
193
194static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
195{
196 v_BOOL_t fConnected = VOS_FALSE;
197
198 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
199
200 if ( pConnectedCipherAlgo )
201 {
202 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
203 }
204
205 return( fConnected );
206}
207
208inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
209{
210 v_BOOL_t fConnected = VOS_FALSE;
211
212 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
213
214 if ( pConnectedBssType )
215 {
216 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
217 }
218
219 return( fConnected );
220}
221
222static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
223{
224 switch( csrRoamBssType )
225 {
226 case eCSR_BSS_TYPE_INFRASTRUCTURE:
227 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
228 break;
229
230 case eCSR_BSS_TYPE_IBSS:
231 case eCSR_BSS_TYPE_START_IBSS:
232 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
233 break;
234
235 /** We will never set the BssType to 'any' when attempting a connection
236 so CSR should never send this back to us.*/
237 case eCSR_BSS_TYPE_ANY:
238 default:
239 VOS_ASSERT( 0 );
240 break;
241 }
242
243}
244
245void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
246{
247 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
248 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
249
250 VOS_ASSERT( pRoamInfo );
251
252 if ( pRoamInfo )
253 {
254 // Save the BSSID for the connection...
255 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
256 {
257 VOS_ASSERT( pRoamInfo->pBssDesc );
258 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
259
260 // Save the Station ID for this station from the 'Roam Info'.
261 //For IBSS mode, staId is assigned in NEW_PEER_IND
262 //For reassoc, the staID doesn't change and it may be invalid in this structure
263 //so no change here.
264 if( !pRoamInfo->fReassocReq )
265 {
266 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
267 }
268 }
269 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
270 {
271 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
272 }
273 else
274 {
275 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
276 // or we can't function.
277 VOS_ASSERT( 0 );
278 }
279
280 // notify WMM
281 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
282
283 if( !pRoamInfo->u.pConnectedProfile )
284 {
285 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
286 }
287 else
288 {
289 // Get Multicast Encryption Type
290 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
291 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
292 // Get Unicast Encrytion Type
293 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
294 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
295
296 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
297
298 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
299
300 // Save the ssid for the connection
301 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
302 }
303 }
304
305 // save the connected BssType
306 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
307
308}
309
310#if defined(WLAN_FEATURE_VOWIFI_11R)
311/*
312 * Send the 11R key information to the supplicant.
313 * Only then can the supplicant generate the PMK-R1.
314 * (BTW, the CCX supplicant also needs the Assoc Resp IEs
315 * for the same purpose.)
316 *
317 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
318 * this contains the R1KHID, R0KHID and the MDID.
319 * For FT, this consists of the Reassoc Rsp FTIEs.
320 * This is the Assoc Response.
321 */
322static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
323 tCsrRoamInfo *pCsrRoamInfo)
324{
325 union iwreq_data wrqu;
326 char *buff;
327 unsigned int len = 0;
328 u8 *pFTAssocRsp = NULL;
329
330 if (pCsrRoamInfo->nAssocRspLength == 0)
331 {
332 hddLog(LOGE,
333 "%s: pCsrRoamInfo->nAssocRspLength=%d",
334 __func__, (int)pCsrRoamInfo->nAssocRspLength);
335 return;
336 }
337
338 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
339 pCsrRoamInfo->nAssocReqLength);
340 if (pFTAssocRsp == NULL)
341 {
342 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
343 return;
344 }
345
346 // pFTAssocRsp needs to point to the IEs
347 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
348 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
349 (unsigned int)pFTAssocRsp[0],
350 (unsigned int)pFTAssocRsp[1]);
351
352 // We need to send the IEs to the supplicant.
353 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
354 if (buff == NULL)
355 {
356 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
357 return;
358 }
359
360 // Send the Assoc Resp, the supplicant needs this for initial Auth.
361 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
362 wrqu.data.length = len;
363 memset(buff, 0, IW_GENERIC_IE_MAX);
364 memcpy(buff, pFTAssocRsp, len);
365 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
366
367 kfree(buff);
368}
369#endif /* WLAN_FEATURE_VOWIFI_11R */
370
371#ifdef WLAN_FEATURE_VOWIFI_11R
372
373/*---------------------------------------------------
374 *
375 * Send the FTIEs, RIC IEs during FT. This is eventually
376 * used to send the FT events to the supplicant
377 *
378 * At the reception of Auth2 we send the RIC followed
379 * by the auth response IEs to the supplicant.
380 * Once both are received in the supplicant, an FT
381 * event is generated to the supplicant.
382 *
383 *---------------------------------------------------
384 */
385void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
386{
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 tANI_U16 auth_resp_len = 0;
388 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
390
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700391#if defined(CONFIG_CFG80211) && defined (KERNEL_SUPPORT_11R_CFG80211)
392 struct cfg80211_ft_event_params ftEvent;
393 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
394 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
395 struct net_device *dev = pAdapter->dev;
396#else
397 char *buff;
398 union iwreq_data wrqu;
399 tANI_U16 str_len;
400#endif
401
402#if defined(CONFIG_CFG80211) && defined (KERNEL_SUPPORT_11R_CFG80211)
403 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
404 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
405
406 /* RIC TODO */
407 /*sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800408 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700409 if (ric_ies_length == 0)
410 {
411 hddLog(LOGW, "%s: RIC IEs is of length 0 not sending RIC Information for now", __func__);
412 }
413 else
414 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800415 ftEvent.ric_ies = ricIe;
416 ftEvent.ric_ies_len = ric_ies_length;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700417 }*/
418
419 ftEvent.ric_ies = ricIe;
420 ftEvent.ric_ies_len = 0;
421 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
422
423 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800424 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700425
426 if (auth_resp_len == 0)
427 {
428 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
429 return;
430 }
431
432 vos_mem_copy(ftEvent.target_ap, ftIe, SIR_MAC_ADDR_LENGTH );
433
434 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
435 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
436
437 hddLog(LOG1, "%s ftEvent.ies_len %d",__FUNCTION__, ftEvent.ies_len);
438 hddLog(LOG1, "%s ftEvent.ric_ies_len %d",__FUNCTION__, ftEvent.ric_ies_len );
439 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800440 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
441 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
442 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700443
444 (void)cfg80211_ft_event(dev, ftEvent);
445
446#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 // We need to send the IEs to the supplicant.
448 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Jeff Johnson295189b2012-06-20 16:38:30 -0700449 if (buff == NULL)
450 {
451 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
452 return;
453 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -0700454 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700455
456 // Sme needs to send the RIC IEs first
457 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
458 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800459 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 if (ric_ies_length == 0)
461 {
462 hddLog(LOGW, "%s: RIC IEs is of length 0 not sending RIC Information for now", __func__);
463 }
464 else
465 {
466 wrqu.data.length = str_len + ric_ies_length;
467 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
468 }
469
470 // Sme needs to provide the Auth Resp
471 vos_mem_zero(buff, IW_CUSTOM_MAX);
472 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
473 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800474 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700475
476 if (auth_resp_len == 0)
477 {
478 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
479 return;
480 }
481
482 wrqu.data.length = str_len + auth_resp_len;
483 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
484
485 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700486#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700487}
488
489#endif /* WLAN_FEATURE_VOWIFI_11R */
490
491#ifdef FEATURE_WLAN_CCX
492
493/*
494 * Send the CCX required "new AP Channel info" to the supplicant.
495 * (This keeps the supplicant "up to date" on the current channel.)
496 *
497 * The current (new AP) channel information is passed in.
498 */
499static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
500 tCsrRoamInfo *pCsrRoamInfo)
501{
502 union iwreq_data wrqu;
503 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
504
505
506 if (descriptor == NULL)
507 {
508 hddLog(LOGE,
509 "%s: pCsrRoamInfo->pBssDesc=%p\n",
510 __func__, descriptor);
511 return;
512 }
513
514 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
515 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d\n", __func__, descriptor->channelId);
516 memset(&wrqu, '\0', sizeof(wrqu));
517 wrqu.freq.m = descriptor->channelId;
518 wrqu.freq.e = 0;
519 wrqu.freq.i = 0;
520 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
521}
522
523#endif /* FEATURE_WLAN_CCX */
524
525void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
526{
527 union iwreq_data wrqu;
528 u8 *pBeaconIes;
529 u8 currentLen = 0;
530 char *buff;
531 int totalIeLen = 0, currentOffset = 0, strLen;
532
533 memset(&wrqu, '\0', sizeof(wrqu));
534
535 if (0 == pCsrRoamInfo->nBeaconLength)
536 {
537 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
538 return;
539 }
540 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
541 if (pBeaconIes == NULL)
542 {
543 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
544 return;
545 }
546
547 // pBeaconIes needs to point to the IEs
548 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
549 (unsigned int)pBeaconIes[0],
550 (unsigned int)pBeaconIes[1]);
551 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
552
553 // We need to send the IEs to the supplicant.
554 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
555 if (buff == NULL)
556 {
557 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
558 return;
559 }
560 vos_mem_zero(buff, IW_CUSTOM_MAX);
561
562 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
563 currentLen = strLen + 1;
564
565 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
566 do
567 {
568 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
569 * max size and send it to supplicant. Changes are done in supplicant to handle this */
570 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
571 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
572 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
573 currentOffset += currentLen;
574 totalIeLen -= currentLen;
575 wrqu.data.length = strLen + 1 + currentLen;
576 if (totalIeLen)
577 buff[strLen] = 1; // This tells supplicant more chunks are pending
578 else
579 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
580
581 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
582 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
583 } while (totalIeLen > 0);
584
585 kfree(buff);
586}
587
588static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
589{
590 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
591 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
592 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
593 union iwreq_data wrqu;
594 int we_event;
595 char *msg;
596 int type = -1;
597
598#if defined (WLAN_FEATURE_VOWIFI_11R)
599 // Added to find the auth type on the fly at run time
600 // rather than with cfg to see if FT is enabled
601 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
602 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
603#endif
604
605 memset(&wrqu, '\0', sizeof(wrqu));
606 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
607 we_event = SIOCGIWAP;
608
609 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
610 {
611 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
612 type = WLAN_STA_ASSOC_DONE_IND;
613
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700614#ifdef WLAN_FEATURE_P2P_DEBUG
615 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
616 {
617 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
618 {
619 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
620 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
621 "Connecting state to Connected State for 8-way "
622 "Handshake");
623 }
624 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
625 {
626 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
627 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
628 "Connecting state to P2P Client Connection Completed");
629 }
630 }
631#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 pr_info("wlan: connected to %02x:%02x:%02x:%02x:%02x:%02x\n",
633 wrqu.ap_addr.sa_data[0],
634 wrqu.ap_addr.sa_data[1],
635 wrqu.ap_addr.sa_data[2],
636 wrqu.ap_addr.sa_data[3],
637 wrqu.ap_addr.sa_data[4],
638 wrqu.ap_addr.sa_data[5]);
639 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
640
641 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
642 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
643 * and fFTEnable is TRUE */
644#ifdef WLAN_FEATURE_VOWIFI_11R
645 // Send FT Keys to the supplicant when FT is enabled
646 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
647 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
648#ifdef FEATURE_WLAN_CCX
649 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
650 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
651#endif
652 )
653 {
654 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
655 }
656#endif
657 }
658 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
659 {
660 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, sizeof(wrqu.ap_addr.sa_data));
661 type = WLAN_STA_ASSOC_DONE_IND;
662 pr_info("wlan: new IBSS connection to %02x:%02x:%02x:%02x:%02x:%02x",
663 pHddStaCtx->conn_info.bssId[0],
664 pHddStaCtx->conn_info.bssId[1],
665 pHddStaCtx->conn_info.bssId[2],
666 pHddStaCtx->conn_info.bssId[3],
667 pHddStaCtx->conn_info.bssId[4],
668 pHddStaCtx->conn_info.bssId[5]);
669 }
670 else /* Not Associated */
671 {
672 pr_info("wlan: disconnected\n");
673 type = WLAN_STA_DISASSOC_DONE_IND;
674 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
675 }
676
677 msg = NULL;
678 /*During the WLAN uninitialization,supplicant is stopped before the
679 driver so not sending the status of the connection to supplicant*/
680 if(pHddCtx->isLoadUnloadInProgress != TRUE)
681 {
682 wireless_send_event(dev, we_event, &wrqu, msg);
683#ifdef FEATURE_WLAN_CCX
684 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
685 {
686 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
687 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
688 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
689 }
690#endif
691 }
692 send_btc_nlink_msg(type, 0);
693}
694
695void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
696{
697 // Remove staId, bssId and peerMacAddress
698 pHddStaCtx->conn_info.staId [ 0 ] = 0;
699 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
700 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
701
702 // Clear all security settings
703 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
704 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
705 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
706
707 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
708
709 // Set not-connected state
710 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
711 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
712
713 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
714}
715/* TODO Revist this function. and data path */
716static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
717{
718 VOS_STATUS vosStatus;
719 hdd_disconnect_tx_rx(pAdapter);
720 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
721 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
722 {
723 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
724 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
725 "Status= %d [0x%08lX]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700726 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 }
728 return( vosStatus );
729}
730
731
732static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
733 tANI_U32 roamId, eRoamCmdStatus roamStatus,
734 eCsrRoamResult roamResult )
735{
736 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700737 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700738 struct net_device *dev = pAdapter->dev;
739 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
740 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700741
742 // Sanity check
743 if(dev == NULL)
744 {
745 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
746 "%s: net_dev is released return", __func__);
747 return eHAL_STATUS_FAILURE;
748 }
749
Jeff Johnson295189b2012-06-20 16:38:30 -0700750 // notify apps that we can't pass traffic anymore
751 netif_tx_disable(dev);
752 netif_carrier_off(dev);
753
Jeff Johnsone7245742012-09-05 17:12:55 -0700754 INIT_COMPLETION(pAdapter->disconnect_comp_var);
755 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 /* If only STA mode is on */
757 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
758 {
759 pHddCtx->isAmpAllowed = VOS_TRUE;
760 }
761 hdd_clearRoamProfileIe( pAdapter );
762
763 // indicate 'disconnect' status to wpa_supplicant...
764 hdd_SendAssociationEvent(dev,pRoamInfo);
765#ifdef CONFIG_CFG80211
766 /* indicate disconnected event to nl80211 */
767 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
768 {
769 /*During the WLAN uninitialization,supplicant is stopped before the
770 driver so not sending the status of the connection to supplicant*/
771 if(pHddCtx->isLoadUnloadInProgress != TRUE)
772 {
773 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
774 "%s: sent disconnected event to nl80211",
775 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700776#ifdef WLAN_FEATURE_P2P_DEBUG
777 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
778 {
779 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
780 {
781 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
782 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
783 "and moved to disconnected state");
784 }
785 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
786 {
787 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
788 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
789 "and moved to inactive state");
790 }
791 }
792#endif
793
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
795 if( eCSR_ROAM_LOSTLINK == roamStatus )
796 {
Mohit Khanna99d5fd02012-09-11 14:51:20 -0700797 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 }
799 else
800 {
801 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
802 }
803
804 //If the Device Mode is Station
805 // and the P2P Client is Connected
806 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700807
808 // In case of JB, as Change-Iface may or maynot be called for p2p0
809 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
810 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
811 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 (vos_concurrent_sessions_running()))
813 {
814 //Enable BMPS only of other Session is P2P Client
815 hdd_context_t *pHddCtx = NULL;
816 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
817
818 if (NULL != pVosContext)
819 {
820 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
821
822 if(NULL != pHddCtx)
823 {
824 //Only P2P Client is there Enable Bmps back
825 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700826 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 {
828 hdd_enable_bmps_imps(pHddCtx);
829 }
830 }
831 }
832 }
833 }
834 }
835#endif
836
837
838 //We should clear all sta register with TL, for now, only one.
Jeff Johnson43971f52012-07-17 12:26:56 -0700839 vstatus = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
840 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 {
842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
843 "hdd_roamDeregisterSTA() failed to for staID %d. "
844 "Status= %d [0x%x]",
845 pHddStaCtx->conn_info.staId[0], status, status );
846
847 status = eHAL_STATUS_FAILURE;
848 }
849
850 pHddCtx->sta_to_adapter[pHddStaCtx->conn_info.staId[0]] = NULL;
851 // Clear saved connection information in HDD
852 hdd_connRemoveConnectInfo( pHddStaCtx );
853
854 //Unblock anyone waiting for disconnect to complete
855 complete(&pAdapter->disconnect_comp_var);
856 return( status );
857}
858static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
859 tCsrRoamInfo *pRoamInfo,
860 v_U8_t staId,
861 v_MACADDR_t *pPeerMacAddress,
862 tSirBssDescription *pBssDesc )
863{
864 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
865 WLAN_STADescType staDesc = {0};
866 eCsrEncryptionType connectedCipherAlgo;
867 v_BOOL_t fConnected;
868 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
869 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
870
871 // Get the Station ID from the one saved during the assocation.
872 staDesc.ucSTAId = staId;
873
874 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
875 {
876 staDesc.wSTAType = WLAN_STA_INFRA;
877
878 // grab the bssid from the connection info in the adapter structure and hand that
879 // over to TL when registering.
880 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
881 }
882 else
883 {
884 // for an IBSS 'connect', setup the Station Descriptor for TL.
885 staDesc.wSTAType = WLAN_STA_IBSS;
886
887 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
888 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
889 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
890 // pass when making an Infrastructure connection.
891 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
892 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
893 }
894
895 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
896
897 // set the QoS field appropriately
898 if (hdd_wmm_is_active(pAdapter))
899 {
900 staDesc.ucQosEnabled = 1;
901 }
902 else
903 {
904 staDesc.ucQosEnabled = 0;
905 }
906
907 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
908 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
909 {
910 staDesc.ucProtectedFrame = 1;
911 }
912 else
913 {
914 staDesc.ucProtectedFrame = 0;
915
916 }
917
918#ifdef FEATURE_WLAN_CCX
919 staDesc.ucIsCcxSta = pRoamInfo->isCCXAssoc;
920#endif //FEATURE_WLAN_CCX
921
922#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
923 /* check whether replay check is valid for the station or not */
924 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
925 {
926 /* Encryption mode is either TKIP or AES
927 and replay check is valid for only these
928 two encryption modes */
929 staDesc.ucIsReplayCheckValid = VOS_TRUE;
930 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
931 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
932 }
933
934 else
935 {
936 /* For other encryption modes replay check is
937 not needed */
938 staDesc.ucIsReplayCheckValid = VOS_FALSE;
939 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
940 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
941 }
942#endif
943
944#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700945 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 if (pAdapter->wapi_info.fIsWapiSta)
947 {
948 staDesc.ucIsWapiSta = 1;
949 }
950 else
951 {
952 staDesc.ucIsWapiSta = 0;
953 }
954#endif /* FEATURE_WLAN_WAPI */
955
956 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
957 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
958
959#ifdef FEATURE_WLAN_INTEGRATED_SOC
960 // UMA is Not ready yet, Xlation will be done by TL
961 staDesc.ucSwFrameTXXlation = 1;
962#else
963 /* Enable UMA for TX translation only when there is no concurrent session active */
964 if (vos_concurrent_sessions_running())
965 {
966 staDesc.ucSwFrameTXXlation = 1;
967 }
968 else
969 {
970 staDesc.ucSwFrameTXXlation = 0;
971 }
972#endif
973 staDesc.ucSwFrameRXXlation = 1;
974 staDesc.ucAddRmvLLC = 1;
975 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
976 staDesc.ucQosEnabled );
977 // Initialize signatures and state
978 staDesc.ucUcastSig = pRoamInfo->ucastSig;
979 staDesc.ucBcastSig = pRoamInfo->bcastSig;
980 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
981 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
982 // Register the Station with TL...
983 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
984 hdd_rx_packet_cbk,
985 hdd_tx_complete_cbk,
986 hdd_tx_fetch_packet_cbk, &staDesc,
987 pBssDesc->rssi );
988
989 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
990 {
991 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
992 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08lX]",
993 vosStatus, vosStatus );
994 return vosStatus;
995 }
996
997 // if ( WPA ), tell TL to go to 'connected' and after keys come to the driver,
998 // then go to 'authenticated'. For all other authentication types (those that do
999 // not require upper layer authentication) we can put TL directly into 'authenticated'
1000 // state.
1001
1002 VOS_ASSERT( fConnected );
1003
1004 if ( !pRoamInfo->fAuthRequired )
1005 {
1006 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1007 "open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time", pHddStaCtx->conn_info.staId[ 0 ] );
1008
1009 // Connections that do not need Upper layer auth, transition TL directly
1010 // to 'Authenticated' state.
1011 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1012 WLANTL_STA_AUTHENTICATED );
1013
1014 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1015 }
1016 else
1017 {
1018 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1019 "ULA auth StaId= %d. Changing TL state to CONNECTED at Join time", pHddStaCtx->conn_info.staId[ 0 ] );
1020
1021 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1022 WLANTL_STA_CONNECTED );
1023
1024 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1025 }
1026 return( vosStatus );
1027}
1028
Jeff Johnson295189b2012-06-20 16:38:30 -07001029static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1030 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1031{
1032 unsigned int len = 0;
1033 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001034 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 tANI_U32 rspRsnLength = 0;
1036 struct ieee80211_channel *chan;
1037
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001038 if (!rspRsnIe)
1039 {
1040 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001041 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001042 }
1043
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 if (pCsrRoamInfo == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001045 {
1046 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1047 goto done;
1048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001049
1050 if (pCsrRoamInfo->nAssocRspLength == 0)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001051 {
1052 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1053 goto done;
1054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001055
1056 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1057 pCsrRoamInfo->nAssocReqLength);
1058 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001059 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001060
1061 //pFTAssocRsp needs to point to the IEs
1062 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1063 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x\n", __func__,
1064 (unsigned int)pFTAssocRsp[0],
1065 (unsigned int)pFTAssocRsp[1]);
1066
1067 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001068 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001071 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001072
1073 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1074 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1075 reqRsnIe, reqRsnLength,
1076 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001077
1078done:
1079 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001080}
Jeff Johnson295189b2012-06-20 16:38:30 -07001081
1082static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1083 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1084 eCsrRoamResult roamResult )
1085{
1086 struct net_device *dev = pAdapter->dev;
1087 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1088 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1089 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001090#ifdef CONFIG_CFG80211
1091 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1092 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
1093#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001094#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 int ft_carrier_on = FALSE;
1096#endif
1097 int status;
1098
1099 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1100 {
1101 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1102
1103 // Save the connection info from CSR...
1104 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1105#ifdef FEATURE_WLAN_WAPI
1106 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1107 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1108 {
1109 pAdapter->wapi_info.fIsWapiSta = 1;
1110 }
1111 else
1112 {
1113 pAdapter->wapi_info.fIsWapiSta = 0;
1114 }
1115#endif /* FEATURE_WLAN_WAPI */
1116
1117 // indicate 'connect' status to userspace
1118 hdd_SendAssociationEvent(dev,pRoamInfo);
1119
1120
1121 // Initialize the Linkup event completion variable
1122 INIT_COMPLETION(pAdapter->linkup_event_var);
1123
1124 /*
1125 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1126 packet to go up to the application, device activation has to be ensured for proper queue mapping by the
1127 kernel. we have registered net device notifier for device change notification. With this we will come to
1128 know that the device is getting activated properly.
1129 */
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001130#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 if (pHddStaCtx->ft_carrier_on == FALSE)
1132 {
1133#endif
1134 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
1135 pAdapter->isLinkUpSvcNeeded = TRUE;
1136
1137 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
1138 pAdapter->isLinkUpSvcNeeded = TRUE;
1139
1140 // Switch on the Carrier to activate the device
1141 netif_carrier_on(dev);
1142
1143 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1144 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1145 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
1146 if(!status)
1147 {
1148 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1149 }
1150
1151 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1152 pAdapter->isLinkUpSvcNeeded = FALSE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001153#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001154 }
1155 else {
1156 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001158 }
1159#endif
1160 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1161
1162 //For reassoc, the station is already registered, all we need is to change the state
1163 //of the STA in TL.
1164 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1165 if( !pRoamInfo->fReassocReq )
1166 {
1167#ifdef CONFIG_CFG80211
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001168 struct cfg80211_bss *bss;
1169#ifdef WLAN_FEATURE_VOWIFI_11R
1170 u8 *pFTAssocRsp = NULL;
1171 unsigned int assocRsplen = 0;
1172 u8 *pFTAssocReq = NULL;
1173 unsigned int assocReqlen = 0;
1174 struct ieee80211_channel *chan;
1175#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001178
1179 /* add bss_id to cfg80211 data base */
1180 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1181 if (NULL == bss)
1182 {
1183 pr_err("wlan: Not able to create BSS entry\n");
1184 return eHAL_STATUS_FAILURE;
1185 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001186#ifdef WLAN_FEATURE_VOWIFI_11R
1187 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001188 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001190
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001191 //Association Response
1192 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001193 pRoamInfo->nAssocReqLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001194 if (pFTAssocRsp != NULL)
1195 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001196 // pFTAssocRsp needs to point to the IEs
1197 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1198 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1199 (unsigned int)pFTAssocRsp[0],
1200 (unsigned int)pFTAssocRsp[1]);
1201 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001202 }
1203 else
1204 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001205 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1206 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001207 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001208
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001209 //Association Request
1210 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
1211 pRoamInfo->nBeaconLength);
1212 if (pFTAssocReq != NULL)
1213 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001214 if(!ft_carrier_on)
1215 {
1216 // pFTAssocReq needs to point to the IEs
1217 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1218 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1219 (unsigned int)pFTAssocReq[0],
1220 (unsigned int)pFTAssocReq[1]);
1221 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1222 }
1223 else
1224 {
1225 /* This should contain only the FTIEs */
1226 assocReqlen = pRoamInfo->nAssocReqLength;
1227 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001228 }
1229 else
1230 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001231 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1232 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001233 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001234
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001235 if(ft_carrier_on)
1236 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001237 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
1238 "indication\n", __FUNCTION__, ft_carrier_on);
1239 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1240 (int)pRoamInfo->pBssDesc->channelId);
1241 hddLog(LOG1, "assocReqlen %d assocRsplen %d\n", assocReqlen,
1242 assocRsplen);
1243 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
1244 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1245 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001246 }
1247 else
1248 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001249 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
1250 "indication\n", __FUNCTION__, ft_carrier_on);
1251 cfg80211_connect_result(dev, pRoamInfo->bssid,
1252 pFTAssocReq, assocReqlen,
1253 pFTAssocRsp, assocRsplen,
1254 WLAN_STATUS_SUCCESS,
1255 GFP_KERNEL);
1256 cfg80211_put_bss(bss);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001257 }
1258 }
1259 else
1260#endif
1261 {
1262 /* wpa supplicant expecting WPA/RSN IE in connect result */
1263 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1264 pAdapter->sessionId,
1265 &reqRsnLength,
1266 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001267
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001268 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1269 pAdapter->sessionId,
1270 &rspRsnLength,
1271 rspRsnIe);
1272#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1273 if(ft_carrier_on)
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001274 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001275 else
1276#endif /* FEATURE_WLAN_CCX */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001277
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001278 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001279 /* inform connect result to nl80211 */
1280 cfg80211_connect_result(dev, pRoamInfo->bssid,
1281 reqRsnIe, reqRsnLength,
1282 rspRsnIe, rspRsnLength,
1283 WLAN_STATUS_SUCCESS,
1284 GFP_KERNEL);
1285
1286 cfg80211_put_bss(bss);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001287 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 }
1289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 // Register the Station with TL after associated...
1291 vosStatus = hdd_roamRegisterSTA( pAdapter,
1292 pRoamInfo,
1293 pHddStaCtx->conn_info.staId[ 0 ],
1294 NULL,
1295 pRoamInfo->pBssDesc );
1296 }
1297 else
1298 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001299 /* wpa supplicant expecting WPA/RSN IE in connect result */
1300 /* in case of reassociation also need to indicate it to supplicant */
1301 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1302 pAdapter->sessionId,
1303 &reqRsnLength,
1304 reqRsnIe);
1305
1306 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 //Reassoc successfully
1308 if( pRoamInfo->fAuthRequired )
1309 {
1310 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
1311 WLANTL_STA_CONNECTED );
1312 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1313 }
1314 else
1315 {
1316 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
1317 WLANTL_STA_AUTHENTICATED );
1318 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1319 }
1320 }
1321
1322 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1323 {
1324 // perform any WMM-related association processing
1325 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1326 }
1327 else
1328 {
1329 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1330 "Cannot register STA with TL. Failed with vosStatus = %d [%08lX]",
1331 vosStatus, vosStatus );
1332 }
1333
1334 // Start the Queue
1335 netif_tx_wake_all_queues(dev);
1336 }
1337 else
1338 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1340
1341 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001342 pr_info("wlan: connection failed with %02x:%02x:%02x:%02x:%02x:%02x"
1343 " reason:%d and Status:%d\n", pWextState->req_bssId[0],
1344 pWextState->req_bssId[1], pWextState->req_bssId[2],
1345 pWextState->req_bssId[3], pWextState->req_bssId[4],
1346 pWextState->req_bssId[5], roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001347
1348 /*Handle all failure conditions*/
1349 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1350 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
1351 {
1352 pHddCtx->isAmpAllowed = VOS_TRUE;
1353 }
1354
1355 //If the Device Mode is Station
1356 // and the P2P Client is Connected
1357 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001358
1359 // In case of JB, as Change-Iface may or maynot be called for p2p0
1360 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
1361 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1362 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 (vos_concurrent_sessions_running()))
1364 {
1365 //Enable BMPS only of other Session is P2P Client
1366 hdd_context_t *pHddCtx = NULL;
1367 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1368
1369 if (NULL != pVosContext)
1370 {
1371 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1372
1373 if(NULL != pHddCtx)
1374 {
1375 //Only P2P Client is there Enable Bmps back
1376 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001377 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 {
1379 hdd_enable_bmps_imps(pHddCtx);
1380 }
1381 }
1382 }
1383 }
1384
1385#ifdef CONFIG_CFG80211
1386 /* inform association failure event to nl80211 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001387 if(eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult)
1388 {
1389 cfg80211_connect_result(dev, pWextState->req_bssId,
1390 NULL, 0, NULL, 0,
1391 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1392 GFP_KERNEL);
1393 }
1394 else
1395 {
1396 cfg80211_connect_result(dev, pWextState->req_bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001397 NULL, 0, NULL, 0,
1398 WLAN_STATUS_UNSPECIFIED_FAILURE,
1399 GFP_KERNEL);
Jeff Johnsone7245742012-09-05 17:12:55 -07001400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001401#endif
1402
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001403 /*Clear the roam profile*/
1404 hdd_clearRoamProfileIe( pAdapter );
1405
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 netif_tx_disable(dev);
1407 netif_carrier_off(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07001408
1409 if (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode)
1410 {
1411 /* Association failed; Reset the country code information
1412 * so that it re-initialize the valid channel list*/
1413 hdd_ResetCountryCodeAfterDisAssoc(pAdapter);
1414 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 }
1416
1417 return eHAL_STATUS_SUCCESS;
1418}
1419
1420/**============================================================================
1421 *
1422 @brief roamRoamIbssIndicationHandler() - Here we update the status of the
1423 Ibss when we receive information that we have started/joined an ibss session
1424 We always return SUCCESS.
1425
1426 ===========================================================================*/
1427static eHalStatus roamRoamIbssIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1428 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1429 eCsrRoamResult roamResult )
1430{
1431 switch( roamResult )
1432 {
1433 // both IBSS Started and IBSS Join should come in here.
1434 case eCSR_ROAM_RESULT_IBSS_STARTED:
1435 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
1436 {
1437 // we should have a pRoamInfo on this callback...
1438 VOS_ASSERT( pRoamInfo );
1439
1440 // When IBSS Started comes from CSR, we need to move connection state to
1441 // IBSS Disconnected (meaning no peers are in the IBSS).
1442 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssDisconnected );
1443
1444 break;
1445 }
1446
1447 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1448 {
1449 VOS_ASSERT( pRoamInfo );
1450
1451 break;
1452 }
1453
1454 default:
1455 break;
1456 }
1457
1458 return( eHAL_STATUS_SUCCESS );
1459}
1460
1461/**============================================================================
1462 *
1463 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1464 This information is passed to iwconfig later. The peer that joined
1465 last is passed as information to iwconfig.
1466 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
1467 return FALSE.
1468
1469 ===========================================================================*/
1470static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1471{
1472 int fSuccess = FALSE;
1473 int idx = 0;
1474
1475 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1476 {
1477 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1478 {
1479 pHddStaCtx->conn_info.staId[ idx ] = staId;
1480
1481 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
1482
1483 fSuccess = TRUE;
1484 break;
1485 }
1486 }
1487
1488 return( fSuccess );
1489}
1490/**============================================================================
1491 *
1492 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
1493 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
1494 return FALSE.
1495
1496 ===========================================================================*/
1497static int roamRemoveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId )
1498{
1499 int fSuccess = FALSE;
1500 int idx = 0;
1501 v_U8_t valid_idx = 0;
1502 v_U8_t del_idx = 0;
1503
1504 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1505 {
1506 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1507 {
1508 pHddStaCtx->conn_info.staId[ idx ] = 0;
1509
1510 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1511
1512 fSuccess = TRUE;
1513 // Note the deleted Index, if its 0 we need special handling
1514 del_idx = idx;
1515 }
1516 else
1517 {
1518 if (pHddStaCtx->conn_info.staId[idx] != 0)
1519 {
1520 valid_idx = idx;
1521 }
1522 }
1523 }
1524
1525 // Find next active staId, to have a valid sta trigger for TL.
1526 if (fSuccess == TRUE)
1527 {
1528 if (del_idx == 0)
1529 {
1530 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1531 {
1532 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1533 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1534 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1535
1536 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1537 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1538 }
1539 }
1540 }
1541 return( fSuccess );
1542}
1543
1544/**============================================================================
1545 *
1546 @brief roamIbssConnectHandler() : We update the status of the IBSS to
1547 connected in this function.
1548
1549 ===========================================================================*/
1550static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1551{
1552 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "IBSS Connect Indication from SME!!!" );
1553 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1554 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1555
1556 // Save the connection info from CSR...
1557 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1558
1559 // Send the bssid address to the wext.
1560 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
1561#ifdef CONFIG_CFG80211
1562 /* add bss_id to cfg80211 data base */
1563 wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1564 /* send ibss join indication to nl80211 */
1565 cfg80211_ibss_joined(pAdapter->dev, &pRoamInfo->bssid[0], GFP_KERNEL);
1566#endif
1567
1568 return( eHAL_STATUS_SUCCESS );
1569}
1570/**============================================================================
1571 *
1572 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
1573
1574 ===========================================================================*/
1575static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1576 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1577 eCsrRoamResult roamResult )
1578{
1579 eCsrEncryptionType connectedCipherAlgo;
1580 v_BOOL_t fConnected = FALSE;
1581 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1582 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1583 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1584 ENTER();
1585 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
1586 // then go to 'authenticated'. For all other authentication types (those that do
1587 // not require upper layer authentication) we can put TL directly into 'authenticated'
1588 // state.
1589 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1590 if( fConnected )
1591 {
1592 // TODO: Considering getting a state machine in HDD later.
1593 // This routuine is invoked twice. 1)set PTK 2)set GTK. The folloing if statement will be
1594 // TRUE when setting GTK. At this time we don't handle the state in detail.
1595 // Related CR: 174048 - TL not in authenticated state
1596 if(( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) && (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired)
1597 {
1598 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1599 "Key set for StaId= %d. Changing TL state to AUTHENTICATED", pHddStaCtx->conn_info.staId[ 0 ] );
1600
1601 // Connections that do not need Upper layer authentication, transition TL
1602 // to 'Authenticated' state after the keys are set.
1603 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
1604 WLANTL_STA_AUTHENTICATED );
1605
1606 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1607 }
1608
1609 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1610 }
1611 else
1612 {
1613 // possible disassoc after issuing set key and waiting set key complete
1614 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1615 }
1616
1617 EXIT();
1618 return( eHAL_STATUS_SUCCESS );
1619}
1620/**============================================================================
1621 *
1622 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
1623 ===========================================================================*/
1624static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1625 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
1626{
1627 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1628
1629 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
1630 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
1631 {
1632 struct iw_michaelmicfailure msg;
1633 union iwreq_data wreq;
1634 memset(&msg, '\0', sizeof(msg));
1635 msg.src_addr.sa_family = ARPHRD_ETHER;
1636 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
1637 hddLog(LOG1, "MIC MAC %02x:%02x:%02x:%02x:%02x:%02x",
1638 msg.src_addr.sa_data[0],
1639 msg.src_addr.sa_data[1],
1640 msg.src_addr.sa_data[2],
1641 msg.src_addr.sa_data[3],
1642 msg.src_addr.sa_data[4],
1643 msg.src_addr.sa_data[5]);
1644
1645 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
1646 msg.flags = IW_MICFAILURE_GROUP;
1647 else
1648 msg.flags = IW_MICFAILURE_PAIRWISE;
1649 memset(&wreq, 0, sizeof(wreq));
1650 wreq.data.length = sizeof(msg);
1651 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
1652#ifdef CONFIG_CFG80211
1653 /* inform mic failure to nl80211 */
1654 cfg80211_michael_mic_failure(pAdapter->dev,
1655 pRoamInfo->u.pMICFailureInfo->taMacAddr,
1656 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
1657 NL80211_KEYTYPE_GROUP :
1658 NL80211_KEYTYPE_PAIRWISE),
1659 pRoamInfo->u.pMICFailureInfo->keyId,
1660 pRoamInfo->u.pMICFailureInfo->TSC,
1661 GFP_KERNEL);
1662#endif
1663
1664 }
1665
1666 return( eHAL_STATUS_SUCCESS );
1667}
1668
1669/**============================================================================
1670 *
1671 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
1672 updated regularly here in this function.
1673
1674 ===========================================================================*/
1675static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1676 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1677 eCsrRoamResult roamResult )
1678{
1679 VOS_STATUS vosStatus;
1680
1681 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1682 switch( roamResult )
1683 {
1684 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
1685 {
1686 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1687 "IBSS New Peer indication from SME "
1688 "with peerMac %2x-%2x-%2x-%2x-%2x-%2x and stationID= %d",
1689 pRoamInfo->peerMac[0], pRoamInfo->peerMac[1], pRoamInfo->peerMac[2],
1690 pRoamInfo->peerMac[3], pRoamInfo->peerMac[4], pRoamInfo->peerMac[5],
1691 pRoamInfo->staId );
1692
1693 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
1694 {
1695 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1696 "New IBSS peer but we already have the max we can handle. Can't register this one" );
1697 break;
1698 }
1699
1700 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1701
1702 // Register the Station with TL for the new peer.
1703 vosStatus = hdd_roamRegisterSTA( pAdapter,
1704 pRoamInfo,
1705 pRoamInfo->staId,
1706 (v_MACADDR_t *)pRoamInfo->peerMac,
1707 pRoamInfo->pBssDesc );
1708 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1709 {
1710 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1711 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08lX]",
1712 vosStatus, vosStatus );
1713 }
1714
1715 netif_carrier_on(pAdapter->dev);
1716 netif_tx_start_all_queues(pAdapter->dev);
1717 break;
1718 }
1719
1720 case eCSR_ROAM_RESULT_IBSS_CONNECT:
1721 {
1722
1723 roamIbssConnectHandler( pAdapter, pRoamInfo );
1724
1725 break;
1726 }
1727 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
1728 {
1729
1730 if ( !roamRemoveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId ) )
1731 {
1732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1733 "IBSS peer departed by cannot find peer in our registration table with TL" );
1734 }
1735
1736 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
1737
1738 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
1739
1740 break;
1741 }
1742 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
1743 {
1744 // Stop only when we are inactive
1745 netif_tx_disable(pAdapter->dev);
1746 netif_carrier_off(pAdapter->dev);
1747 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
1748
1749 // Send the bssid address to the wext.
1750 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
1751 // clean up data path
1752 hdd_disconnect_tx_rx(pAdapter);
1753 break;
1754 }
1755 default:
1756 break;
1757
1758 }
1759
1760 return( eHAL_STATUS_SUCCESS );
1761}
1762
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001763#ifdef FEATURE_WLAN_TDLS
1764/**============================================================================
1765 *
1766 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
1767 TL the new STA. This is called as part of ADD_STA in the TDLS setup
1768 Return: VOS_STATUS
1769
1770 ===========================================================================*/
1771static VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
1772 tCsrRoamInfo *pRoamInfo,
1773 v_U8_t tdlsEncryptionEnabled )
1774{
1775 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1776 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
1777 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1778 WLAN_STADescType staDesc = {0};
1779
Hoonki Lee387663d2013-02-05 18:08:43 -08001780 if (-1 == wlan_hdd_tdls_set_sta_id(pRoamInfo->peerMac, pRoamInfo->staId)) {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001781 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee387663d2013-02-05 18:08:43 -08001782 "wlan_hdd_tdls_set_sta_id() failed");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001783 }
1784 /*
1785 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
1786 * be peer MAC, here we are wokrking on direct Link
1787 */
1788 staDesc.ucSTAId = pRoamInfo->staId ;
1789
1790 staDesc.wSTAType = WLAN_STA_TDLS ;
1791
1792 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pRoamInfo->peerMac,
1793 sizeof(tSirMacAddr) );
1794
1795 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
1796 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1797
1798 /* set the QoS field appropriately ..*/
1799 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
1800 : (staDesc.ucQosEnabled = 0) ;
1801
1802 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
1803 TL QoS_enabled=%d\n", staDesc.ucQosEnabled );
1804
1805 staDesc.ucProtectedFrame = tdlsEncryptionEnabled;
1806
1807 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1808 "HDD register TL Sec_enabled= %d.\n", staDesc.ucProtectedFrame );
1809
1810 /*
1811 * UMA is ready we inform TL to do frame translation.
1812 */
1813 staDesc.ucSwFrameTXXlation = 1;
1814 staDesc.ucSwFrameRXXlation = 1;
1815 staDesc.ucAddRmvLLC = 1;
1816
1817 /* Initialize signatures and state */
1818 staDesc.ucUcastSig = pRoamInfo->ucastSig ;
1819
1820 /* tdls Direct Link do not need bcastSig */
1821 staDesc.ucBcastSig = 0 ;
1822
1823#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1824 if(staDesc.ucProtectedFrame)
1825 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1826 else
1827 staDesc.ucIsReplayCheckValid = VOS_FALSE;
1828#endif
1829
1830 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
1831
1832 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1833 /* Register the Station with TL... */
1834 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
1835 hdd_rx_packet_cbk,
1836 hdd_tx_complete_cbk,
1837 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
1838
1839 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1840 {
1841 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1842 "WLANTL_RegisterSTAClient() failed to register. \
1843 Status= %d [0x%08lX]", vosStatus, vosStatus );
1844 return vosStatus;
1845 }
1846
1847 return( vosStatus );
1848}
1849
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08001850static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1851{
1852 VOS_STATUS vosStatus;
1853 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1854 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1855 {
1856 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1857 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
1858 "Status= %d [0x%08lX]",
1859 __func__, staId, vosStatus, vosStatus );
1860 }
1861 return( vosStatus );
1862}
1863
1864
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001865/*
1866 * HDD interface between SME and TL to ensure TDLS client registration with
1867 * TL in case of new TDLS client is added and deregistration at the time
1868 * TDLS client is deleted.
1869 */
1870
1871eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
1872 tCsrRoamInfo *pRoamInfo,
1873 tANI_U32 roamId,
1874 eRoamCmdStatus roamStatus,
1875 eCsrRoamResult roamResult)
1876{
1877 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1878 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001879 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001880
1881#ifdef WLAN_FEATURE_TDLS_DEBUG
1882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Leee6bfe942013-02-05 15:01:19 -08001883 ("hdd_tdlsStatusUpdate: %s staIdx %d %02x:%02x:%02x:%02x:%02x:%02x \n"),
1884 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" :
1885 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
1886 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND" :
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001887 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND? "DEL_ALL_TDLS_PEER_IND" :
Hoonki Leee6bfe942013-02-05 15:01:19 -08001888 "UNKNOWN",
1889 pRoamInfo->staId,
1890 pRoamInfo->peerMac[0],
1891 pRoamInfo->peerMac[1],
1892 pRoamInfo->peerMac[2],
1893 pRoamInfo->peerMac[3],
1894 pRoamInfo->peerMac[4],
1895 pRoamInfo->peerMac[5]) ;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001896#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001897 switch( roamResult )
1898 {
1899 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
1900 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08001901 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
1902 {
1903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1904 ("%s: Add Sta is failed."),__func__ );
1905 break;
1906 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001907 /*
1908 * check if there is available index for this new TDLS STA
1909 * since TDLS is setup in BSS, we need to start from +1
1910 */
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001911 for ( staIdx = 1; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001912 {
1913 if (0 == pHddStaCtx->conn_info.staId[staIdx] )
1914 {
1915 pHddStaCtx->conn_info.staId[staIdx] = pRoamInfo->staId;
1916
1917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1918 ("TDLS: STA IDX at %d \
1919 and mac = %d: %02x,%02x, %02x, %02x, %02x, %02x\n"),
1920 staIdx, pHddStaCtx->conn_info.staId[staIdx],
1921 pRoamInfo->peerMac[0],
1922 pRoamInfo->peerMac[1],
1923 pRoamInfo->peerMac[2],
1924 pRoamInfo->peerMac[3],
1925 pRoamInfo->peerMac[4],
1926 pRoamInfo->peerMac[5]) ;
1927
1928 vos_copy_macaddr(
1929 &pHddStaCtx->conn_info.peerMacAddress[staIdx],
1930 (v_MACADDR_t *)pRoamInfo->peerMac) ;
1931 status = eHAL_STATUS_SUCCESS ;
1932 break ;
1933 }
1934 }
1935 if(eHAL_STATUS_SUCCESS == status)
1936 {
Madan Mohan Koyyalamudi5a07b4b2012-12-03 15:55:46 -08001937 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
1938 v_BOOL_t fConnected = FALSE;
1939
1940 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1941 if( fConnected )
1942 {
1943 /* start TDLS client registration with TL */
1944 status = hdd_roamRegisterTDLSSTA( pAdapter, pRoamInfo,
1945 ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )? 1 : 0 ) ;
1946 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001947 }
1948 break ;
1949 }
1950 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001951 {
1952 /* 0 staIdx is assigned to AP we dont want to touch that */
1953 for ( staIdx = 1; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001954 {
1955 if (pRoamInfo->staId == pHddStaCtx->conn_info.staId[staIdx] )
1956 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1958 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
1959
1960 wlan_hdd_tdls_reset_peer(pRoamInfo->peerMac);
1961 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
1962
1963 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = NULL;
1964
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001965 pHddStaCtx->conn_info.staId[staIdx] = 0 ;
1966 vos_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[staIdx],
1967 sizeof(v_MACADDR_t)) ;
1968 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001969 break ;
1970 }
1971 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001972 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001973 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08001974 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
1975 {
1976 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1977 "%s: Sending teardown to supplicant with reason code %u",
1978 __func__, pRoamInfo->reasonCode);
1979
1980#ifdef CONFIG_TDLS_IMPLICIT
1981 cfg80211_tdls_oper_request(pAdapter->dev,
1982 pRoamInfo->peerMac,
1983 NL80211_TDLS_TEARDOWN,
1984 pRoamInfo->reasonCode,
1985 GFP_KERNEL);
1986#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001987 status = eHAL_STATUS_SUCCESS ;
1988 break ;
1989 }
1990 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
1991 {
1992 /* 0 staIdx is assigned to AP we dont want to touch that */
1993 for ( staIdx = 1; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
1994 {
1995 if (pHddStaCtx->conn_info.staId[staIdx])
1996 {
1997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1998 ("hdd_tdlsStatusUpdate: staIdx %d %02x:%02x:%02x:%02x:%02x:%02x"),
1999 pHddStaCtx->conn_info.staId[staIdx],
2000 pHddStaCtx->conn_info.peerMacAddress[staIdx].bytes[0],
2001 pHddStaCtx->conn_info.peerMacAddress[staIdx].bytes[1],
2002 pHddStaCtx->conn_info.peerMacAddress[staIdx].bytes[2],
2003 pHddStaCtx->conn_info.peerMacAddress[staIdx].bytes[3],
2004 pHddStaCtx->conn_info.peerMacAddress[staIdx].bytes[4],
2005 pHddStaCtx->conn_info.peerMacAddress[staIdx].bytes[5]) ;
2006 wlan_hdd_tdls_reset_peer(pHddStaCtx->conn_info.peerMacAddress[staIdx].bytes);
2007 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddStaCtx->conn_info.staId[staIdx] );
2008
2009 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[staIdx] = NULL;
2010 vos_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[staIdx],
2011 sizeof(v_MACADDR_t)) ;
2012 pHddStaCtx->conn_info.staId[staIdx] = 0 ;
2013
2014 status = eHAL_STATUS_SUCCESS ;
2015 }
2016 }
Hoonki Leee6bfe942013-02-05 15:01:19 -08002017 break ;
2018 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002019 default:
2020 {
2021 break ;
2022 }
2023 }
2024
2025 return status ;
2026}
2027#endif
2028
Jeff Johnson295189b2012-06-20 16:38:30 -07002029eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
2030 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2031{
2032 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2033 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302034 hdd_wext_state_t *pWextState = NULL;
2035 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002036 VOS_STATUS status = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002037
2038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2039 "CSR Callback: status= %d result= %d roamID=%ld",
2040 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002041
2042 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302043 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002044 {
2045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302046 "invalid adapter or adapter has invalid magic");
2047 return eHAL_STATUS_FAILURE;
2048 }
2049
2050 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2051 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2052
2053 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2054 {
2055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2056 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002057 return eHAL_STATUS_FAILURE;
2058 }
2059
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 switch( roamStatus )
2061 {
2062 case eCSR_ROAM_SESSION_OPENED:
2063 if(pAdapter != NULL)
2064 {
2065 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2066 complete(&pAdapter->session_open_comp_var);
2067 }
2068 break;
2069
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002070#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 /* We did pre-auth,then we attempted a 11r or ccx reassoc.
2072 * reassoc failed due to failure, timeout, reject from ap
2073 * in any case tell the OS, our carrier is off and mark
2074 * interface down */
2075 case eCSR_ROAM_FT_REASSOC_FAILED:
2076 hddLog(LOG1, FL("Reassoc Failed\n"));
2077 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2078 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2079 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
2080#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
2081#ifdef MSM_PLATFORM
2082 hdd_conf_mcastbcast_filter((WLAN_HDD_GET_CTX(pAdapter)), FALSE);
2083#endif
2084#endif
2085 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2086 }
2087 pHddStaCtx->ft_carrier_on = FALSE;
2088 break;
2089
2090 case eCSR_ROAM_FT_START:
2091 // When we roam for CCX and 11r, we dont want the
2092 // OS to be informed that the link is down. So mark
2093 // the link ready for ft_start. After this the
2094 // eCSR_ROAM_SHOULD_ROAM will be received.
2095 // Where in we will not mark the link down
2096 // Also we want to stop tx at this point when we will be
2097 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002098 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 {
2100 struct net_device *dev = pAdapter->dev;
2101 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002102 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002103 * Deregister for this STA with TL with the objective to flush
2104 * all the packets for this STA from wmm_tx_queue. If not done here,
2105 * we would run into a race condition (CR390567) wherein TX
2106 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2107 * been deleted. And, these packets get assigned with a STA idx of
2108 * self-sta (since the peer STA has been deleted) and get transmitted
2109 * on the new channel before the reassoc request. Since there will be
2110 * no ACK on the new channel, each packet gets retransmitted which
2111 * takes several seconds before the transmission of reassoc request.
2112 * This leads to reassoc-timeout and roam failure.
2113 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002114 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2115 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2116 {
2117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2118 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2119 pHddStaCtx->conn_info.staId[0], status, status );
2120 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 }
2123 pHddStaCtx->ft_carrier_on = TRUE;
2124 break;
2125#endif
2126
2127 case eCSR_ROAM_SHOULD_ROAM:
2128 // Dont need to do anything
2129 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 struct net_device *dev = pAdapter->dev;
2131 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2132 // notify apps that we can't pass traffic anymore
2133 netif_tx_disable(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002134#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 if (pHddStaCtx->ft_carrier_on == FALSE)
2136 {
2137#endif
2138 netif_carrier_off(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002139#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 }
2141#endif
2142
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002143#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 //We should clear all sta register with TL, for now, only one.
2145 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2146 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2147 {
2148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2149 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2150 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002151 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002153#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 // Clear saved connection information in HDD
2155 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
2156 }
2157 break;
2158 case eCSR_ROAM_LOSTLINK:
2159 case eCSR_ROAM_DISASSOCIATED:
2160 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2163 "****eCSR_ROAM_DISASSOCIATED****");
2164 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2165 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2166 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
2167 hdd_conf_mcastbcast_filter((WLAN_HDD_GET_CTX(pAdapter)), FALSE);
2168 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2169 }
2170#ifdef WLAN_FEATURE_PACKET_FILTERING
2171 if (pHddCtx->cfg_ini->isMcAddrListFilter)
2172 {
2173 /*Multicast addr filtering is enabled*/
2174 if(pHddCtx->mc_addr_list.isFilterApplied)
2175 {
2176 /*Filter applied during suspend mode*/
2177 /*Clear it here*/
Jeff Johnsone7245742012-09-05 17:12:55 -07002178 wlan_hdd_set_mc_addr_list(pHddCtx, FALSE, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 }
2180 }
2181#endif
2182
Jeff Johnsone7245742012-09-05 17:12:55 -07002183 if (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode)
2184 {
2185 /* Disconnected from current AP. Reset the country code information
2186 * so that it re-initialize the valid channel list*/
2187 hdd_ResetCountryCodeAfterDisAssoc(pAdapter);
2188 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 }
2190 break;
2191 case eCSR_ROAM_IBSS_LEAVE:
2192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2193 "****eCSR_ROAM_IBSS_LEAVE****");
2194 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2195 break;
2196 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2198 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
2199 if ( (roamResult != eCSR_ROAM_RESULT_ASSOCIATED)
2200 && ( (pWextState->roamProfile.EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY)
2201 || (pWextState->roamProfile.EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)
2202 )
2203 && (eCSR_AUTH_TYPE_SHARED_KEY != pWextState->roamProfile.AuthType.authType[0])
2204 )
2205 {
2206 v_U32_t roamId = 0;
2207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2208 "****WEP open authentication failed, trying with shared authentication****");
2209 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
2210 pWextState->roamProfile.AuthType.authType[0] = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2211 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2212 halStatus = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &(pWextState->roamProfile), &roamId);
2213 }
2214 else
2215 {
2216 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2217 }
2218
2219 break;
2220 case eCSR_ROAM_ASSOCIATION_FAILURE:
2221 halStatus = hdd_AssociationCompletionHandler( pAdapter,
2222 pRoamInfo, roamId, roamStatus, roamResult );
2223 break;
2224 case eCSR_ROAM_IBSS_IND:
2225 halStatus = roamRoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2226 break;
2227
2228 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2229 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2230 break;
2231
2232 case eCSR_ROAM_MIC_ERROR_IND:
2233 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2234 break;
2235
2236 case eCSR_ROAM_SET_KEY_COMPLETE:
2237 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2238 break;
2239#ifdef WLAN_FEATURE_VOWIFI_11R
2240 case eCSR_ROAM_FT_RESPONSE:
2241 hdd_SendFTEvent(pAdapter);
2242 break;
2243#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002244#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002245 case eCSR_ROAM_PMK_NOTIFY:
Jeff Johnson43971f52012-07-17 12:26:56 -07002246 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
2247 {
2248 /* Notify the supplicant of a new candidate */
2249 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2250 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002251 break;
2252#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002253
2254#ifdef WLAN_FEATURE_P2P
2255 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2256 hdd_indicateMgmtFrame( pAdapter,
2257 pRoamInfo->nFrameLength,
2258 pRoamInfo->pbFrames,
2259 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302260 pRoamInfo->rxChan,
2261 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 break;
2263 case eCSR_ROAM_REMAIN_CHAN_READY:
2264 hdd_remainChanReadyHandler( pAdapter );
2265 break;
2266 case eCSR_ROAM_SEND_ACTION_CNF:
2267 hdd_sendActionCnf( pAdapter,
2268 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2269 break;
2270#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002271#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002272 case eCSR_ROAM_TDLS_STATUS_UPDATE:
2273 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
2274 roamId, roamStatus, roamResult );
2275 break ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002276#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 default:
2278 break;
2279 }
2280 return( halStatus );
2281}
2282eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
2283{
2284 eCsrAuthType auth_type;
2285 // is the auth type supported?
2286 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
2287 {
2288 auth_type = eCSR_AUTH_TYPE_RSN;
2289 } else
2290 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
2291 {
2292 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
2293 } else
2294#ifdef WLAN_FEATURE_VOWIFI_11R
2295 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
2296 {
2297 // Check for 11r FT Authentication with PSK
2298 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
2299 } else
2300 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
2301 {
2302 // Check for 11R FT Authentication with 802.1X
2303 auth_type = eCSR_AUTH_TYPE_FT_RSN;
2304 } else
2305#endif
2306#ifdef FEATURE_WLAN_CCX
2307 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
2308 {
2309 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2310 } else
2311#endif /* FEATURE_WLAN_CCX */
2312 {
2313 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2314 }
2315 return auth_type;
2316}
2317#ifdef WLAN_SOFTAP_FEATURE
2318eCsrAuthType
2319hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
2320#else
2321static eCsrAuthType hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
2322#endif
2323{
2324 eCsrAuthType auth_type;
2325 // is the auth type supported?
2326 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
2327 {
2328 auth_type = eCSR_AUTH_TYPE_WPA;
2329 } else
2330 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
2331 {
2332 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
2333 } else
2334#ifdef FEATURE_WLAN_CCX
2335 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
2336 {
2337 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
2338 } else
2339#endif /* FEATURE_WLAN_CCX */
2340 {
2341 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2342 }
2343 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2344 return auth_type;
2345}
2346#ifdef WLAN_SOFTAP_FEATURE
2347eCsrEncryptionType
2348hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
2349#else
2350static eCsrEncryptionType hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
2351#endif
2352{
2353 eCsrEncryptionType cipher_type;
2354 // is the cipher type supported?
2355 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
2356 {
2357 cipher_type = eCSR_ENCRYPT_TYPE_AES;
2358 }
2359 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
2360 {
2361 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
2362 }
2363 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
2364 {
2365 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
2366 }
2367 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
2368 {
2369 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2370 }
2371 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2372 {
2373 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2374 }
2375 else
2376 {
2377 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2378 }
2379 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2380 return cipher_type;
2381}
2382/* To find if the MAC address is NULL */
2383static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
2384{
2385 int i;
2386 for (i = 0; i < length; i++)
2387 {
2388 if (0x00 != (macAddr[i]))
2389 {
2390 return FALSE;
2391 }
2392 }
2393 return TRUE;
2394} /****** end hdd_IsMACAddrNULL() ******/
2395#ifdef WLAN_SOFTAP_FEATURE
2396eCsrEncryptionType
2397hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
2398#else
2399static eCsrEncryptionType
2400hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
2401#endif
2402{
2403 eCsrEncryptionType cipher_type;
2404 // is the cipher type supported?
2405 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
2406 {
2407 cipher_type = eCSR_ENCRYPT_TYPE_AES;
2408 } else
2409 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
2410 {
2411 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
2412 } else
2413 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
2414 {
2415 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
2416 } else
2417 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
2418 {
2419 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2420 } else
2421 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
2422 {
2423 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2424 } else
2425 {
2426 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2427 }
2428 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2429 return cipher_type;
2430}
2431
2432static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
2433 struct ether_addr *pBssid,
2434 eCsrEncryptionType *pEncryptType,
2435 eCsrEncryptionType *mcEncryptType,
2436 eCsrAuthType *pAuthType,
2437 u_int16_t gen_ie_len,
2438 u_int8_t *gen_ie)
2439{
2440 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
2441 eHalStatus result;
2442 tDot11fIERSN dot11RSNIE;
2443 tDot11fIEWPA dot11WPAIE;
2444 tANI_U32 i;
2445 tANI_U8 *pRsnIe;
2446 tANI_U16 RSNIeLen;
2447 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
2448
2449 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
2450 flag to 0 */
2451 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
2452 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
2453
2454 // Validity checks
2455 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
2456 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
2457 return -EINVAL;
2458 // Type check
2459 if ( gen_ie[0] == DOT11F_EID_RSN)
2460 {
2461 // Validity checks
2462 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
2463 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
2464 {
2465 return -EINVAL;
2466 }
2467 // Skip past the EID byte and length byte
2468 pRsnIe = gen_ie + 2;
2469 RSNIeLen = gen_ie_len - 2;
2470 // Unpack the RSN IE
2471 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
2472 pRsnIe,
2473 RSNIeLen,
2474 &dot11RSNIE);
2475 // Copy out the encryption and authentication types
2476 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002477 __func__, dot11RSNIE.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002479 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 /*Here we have followed the apple base code,
2481 but probably I suspect we can do something different*/
2482 //dot11RSNIE.akm_suite_count
2483 // Just translate the FIRST one
2484 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
2485 //dot11RSNIE.pwise_cipher_suite_count
2486 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
2487 //dot11RSNIE.gp_cipher_suite_count
2488 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
2489 // Set the PMKSA ID Cache for this interface
2490 for (i=0; i<dot11RSNIE.pmkid_count; i++)
2491 {
2492 if ( pBssid == NULL)
2493 {
2494 break;
2495 }
2496 if ( hdd_IsMACAddrNULL( (u_char *) pBssid , sizeof( (char *) pBssid)))
2497 {
2498 break;
2499 }
2500 // For right now, I assume setASSOCIATE() has passed in the bssid.
2501 vos_mem_copy(PMKIDCache[i].BSSID,
2502 pBssid, ETHER_ADDR_LEN);
2503 vos_mem_copy(PMKIDCache[i].PMKID,
2504 dot11RSNIE.pmkid[i],
2505 CSR_RSN_PMKID_SIZE);
2506 }
2507 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
2508 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %ld."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002509 __func__, i );
Jeff Johnson295189b2012-06-20 16:38:30 -07002510 // Finally set the PMKSA ID Cache in CSR
2511 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
2512 PMKIDCache,
2513 dot11RSNIE.pmkid_count );
2514 }
2515 else if (gen_ie[0] == DOT11F_EID_WPA)
2516 {
2517 // Validity checks
2518 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
2519 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
2520 {
2521 return -EINVAL;
2522 }
2523 // Skip past the EID byte and length byte - and four byte WiFi OUI
2524 pRsnIe = gen_ie + 2 + 4;
2525 RSNIeLen = gen_ie_len - (2 + 4);
2526 // Unpack the WPA IE
2527 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
2528 pRsnIe,
2529 RSNIeLen,
2530 &dot11WPAIE);
2531 // Copy out the encryption and authentication types
2532 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002533 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002535 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 //dot11WPAIE.auth_suite_count
2537 // Just translate the FIRST one
2538 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
2539 //dot11WPAIE.unicast_cipher_count
2540 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
2541 //dot11WPAIE.unicast_cipher_count
2542 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
2543 }
2544 else
2545 {
2546 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
2547 return -EINVAL;
2548 }
2549 return 0;
2550}
2551int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
2552{
2553 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2554 v_U32_t status = 0;
2555 eCsrEncryptionType RSNEncryptType;
2556 eCsrEncryptionType mcRSNEncryptType;
2557 struct ether_addr bSsid; // MAC address of assoc peer
2558 // MAC address of assoc peer
2559 // But, this routine is only called when we are NOT associated.
2560 vos_mem_copy(bSsid.ether_addr_octet,
2561 pWextState->roamProfile.BSSIDs.bssid,
2562 sizeof(bSsid.ether_addr_octet));
2563 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
2564 {
2565 //continue
2566 }
2567 else
2568 {
2569 return 0;
2570 }
2571 // The actual processing may eventually be more extensive than this.
2572 // Right now, just consume any PMKIDs that are sent in by the app.
2573 status = hdd_ProcessGENIE(pAdapter,
2574 &bSsid, // MAC address of assoc peer
2575 &RSNEncryptType,
2576 &mcRSNEncryptType,
2577 RSNAuthType,
2578 pWextState->WPARSNIE[1]+2,
2579 pWextState->WPARSNIE);
2580 if (status == 0)
2581 {
2582 // Now copy over all the security attributes you have parsed out
2583 pWextState->roamProfile.EncryptionType.numEntries = 1;
2584 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
2585
2586 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
2587 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002588 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 }
2590 return 0;
2591}
2592int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
2593{
2594 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2595 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
2596 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2597 ENTER();
2598
2599 pRoamProfile->AuthType.numEntries = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002600 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d\n", __func__, pHddStaCtx->conn_info.authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002601
2602 switch( pHddStaCtx->conn_info.authType)
2603 {
2604 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2605#ifdef FEATURE_WLAN_CCX
2606 case eCSR_AUTH_TYPE_CCKM_WPA:
2607 case eCSR_AUTH_TYPE_CCKM_RSN:
2608#endif
2609 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
2610
2611 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
2612 } else
2613 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
2614
2615#ifdef FEATURE_WLAN_CCX
2616 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
2617 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2618 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002619 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
2621 } else
2622 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002623 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
2625 } else
2626#endif
2627 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2628 == IW_AUTH_KEY_MGMT_802_1X) {
2629 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
2630 } else
2631 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2632 == IW_AUTH_KEY_MGMT_PSK) {
2633 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
2634 } else {
2635 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
2636 }
2637 }
2638 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
2639#ifdef FEATURE_WLAN_CCX
2640 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
2641 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2642 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002643 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
2645 } else
2646 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002647 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
2649 } else
2650#endif
2651
2652#ifdef WLAN_FEATURE_VOWIFI_11R
2653 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
2654 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2655 == IW_AUTH_KEY_MGMT_802_1X)) {
2656 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07002657 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
2659 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2660 == IW_AUTH_KEY_MGMT_PSK)) {
2661 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
2662 } else
2663#endif
2664
2665 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2666 == IW_AUTH_KEY_MGMT_802_1X) {
2667 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
2668 } else
2669 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2670 == IW_AUTH_KEY_MGMT_PSK) {
2671 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
2672 } else {
2673 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
2674 }
2675 }
2676 break;
2677
2678 case eCSR_AUTH_TYPE_SHARED_KEY:
2679
2680 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
2681 break;
2682 default:
2683
2684#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002685 hddLog( LOG1, "%s: In default, unknown auth type.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002686#endif /* FEATURE_WLAN_CCX */
2687 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
2688 break;
2689 }
2690
2691 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002692 __func__, pWextState->roamProfile.AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002693
2694 EXIT();
2695 return 0;
2696}
2697
2698/**---------------------------------------------------------------------------
2699
2700 \brief iw_set_essid() -
2701 This function sets the ssid received from wpa_supplicant
2702 to the CSR roam profile.
2703
2704 \param - dev - Pointer to the net device.
2705 - info - Pointer to the iw_request_info.
2706 - wrqu - Pointer to the iwreq_data.
2707 - extra - Pointer to the data.
2708 \return - 0 for success, non zero for failure
2709
2710 --------------------------------------------------------------------------*/
2711
2712int iw_set_essid(struct net_device *dev,
2713 struct iw_request_info *info,
2714 union iwreq_data *wrqu, char *extra)
2715{
2716 v_U32_t status = 0;
2717 hdd_wext_state_t *pWextState;
2718 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2719 v_U32_t roamId;
2720 tCsrRoamProfile *pRoamProfile;
2721 eMib_dot11DesiredBssType connectedBssType;
2722 eCsrAuthType RSNAuthType;
2723 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2724 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2725
2726 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2727
2728 ENTER();
2729
2730 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2731 {
2732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2733 "%s:LOGP in Progress. Ignore!!!",__func__);
2734 return 0;
2735 }
2736
2737 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
2738 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
2739 return -EBUSY;
2740 }
2741 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
2742 return -EINVAL;
2743 pRoamProfile = &pWextState->roamProfile;
2744 if (pRoamProfile)
2745 {
2746 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
2747 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
2748 {
2749 VOS_STATUS vosStatus;
2750 // need to issue a disconnect to CSR.
2751 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2752 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
2753
2754 if(VOS_STATUS_SUCCESS == vosStatus)
2755 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
2756 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2757 }
2758 }
2759 /** wpa_supplicant 0.8.x, wext driver uses */
2760 else
2761 {
2762 return -EINVAL;
2763 }
2764 /** wpa_supplicant 0.8.x, wext driver uses */
2765#ifdef CONFIG_CFG80211
2766 /** when cfg80211 defined, wpa_supplicant wext driver uses
2767 zero-length, null-string ssid for force disconnection.
2768 after disconnection (if previously connected) and cleaning ssid,
2769 driver MUST return success */
2770 if ( 0 == wrqu->essid.length ) {
2771 return 0;
2772 }
2773#endif
2774
2775 status = hdd_wmm_get_uapsd_mask(pAdapter,
2776 &pWextState->roamProfile.uapsd_mask);
2777 if (VOS_STATUS_SUCCESS != status)
2778 {
2779 pWextState->roamProfile.uapsd_mask = 0;
2780 }
2781 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
2782
2783 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
2784
2785 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
2786 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
2787 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
2788 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
2789
2790 //set gen ie
2791 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
2792
2793 //set auth
2794 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
2795 }
2796#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002797 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 if (pAdapter->wapi_info.nWapiMode)
2799 {
2800 switch (pAdapter->wapi_info.wapiAuthMode)
2801 {
2802 case WAPI_AUTH_MODE_PSK:
2803 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002804 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 pRoamProfile->AuthType.numEntries = 1;
2806 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
2807 break;
2808 }
2809 case WAPI_AUTH_MODE_CERT:
2810 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002811 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 pRoamProfile->AuthType.numEntries = 1;
2813 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
2814 break;
2815 }
2816 } // End of switch
2817 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
2818 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
2819 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002820 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 pRoamProfile->EncryptionType.numEntries = 1;
2822 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
2823 pRoamProfile->mcEncryptionType.numEntries = 1;
2824 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
2825 }
2826 }
2827#endif /* FEATURE_WLAN_WAPI */
2828 /* if previous genIE is not NULL, update AssocIE */
2829 if (0 != pWextState->genIE.length)
2830 {
2831 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
2832 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
2833 pWextState->genIE.length);
2834 pWextState->assocAddIE.length = pWextState->genIE.length;
2835 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
2836 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
2837
2838 /* clear previous genIE after use it */
2839 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2840 }
2841
2842 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
2843 pWextState->roamProfile.bWPSAssociation = FALSE;
2844
2845 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
2846 pWextState->roamProfile.nAddIEAssocLength))
2847 pWextState->roamProfile.bWPSAssociation = TRUE;
2848
2849
2850 // Disable auto BMPS entry by PMC until DHCP is done
2851 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
2852
2853 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2854 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
2855 status = sme_RoamConnect( hHal,pAdapter->sessionId, &(pWextState->roamProfile),&roamId);
2856 pRoamProfile->ChannelInfo.ChannelList = NULL;
2857 pRoamProfile->ChannelInfo.numOfChannels = 0;
2858
2859 EXIT();
2860 return status;
2861}
2862/**---------------------------------------------------------------------------
2863
2864 \brief iw_get_essid() -
2865 This function returns the essid to the wpa_supplicant.
2866
2867 \param - dev - Pointer to the net device.
2868 - info - Pointer to the iw_request_info.
2869 - wrqu - Pointer to the iwreq_data.
2870 - extra - Pointer to the data.
2871 \return - 0 for success, non zero for failure
2872
2873 --------------------------------------------------------------------------*/
2874int iw_get_essid(struct net_device *dev,
2875 struct iw_request_info *info,
2876 struct iw_point *dwrq, char *extra)
2877{
2878 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2879 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2880 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2881 ENTER();
2882
2883 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
2884 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
2885 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
2886 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
2887 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
2888 {
2889 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
2890 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
2891 dwrq->flags = 1;
2892 } else {
2893 memset(extra, 0, dwrq->length);
2894 dwrq->length = 0;
2895 dwrq->flags = 0;
2896 }
2897 EXIT();
2898 return 0;
2899}
2900/**---------------------------------------------------------------------------
2901
2902 \brief iw_set_auth() -
2903 This function sets the auth type received from the wpa_supplicant.
2904
2905 \param - dev - Pointer to the net device.
2906 - info - Pointer to the iw_request_info.
2907 - wrqu - Pointer to the iwreq_data.
2908 - extra - Pointer to the data.
2909 \return - 0 for success, non zero for failure
2910
2911 --------------------------------------------------------------------------*/
2912int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
2913 union iwreq_data *wrqu,char *extra)
2914{
2915 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2916 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2917 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2918 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
2919 eCsrEncryptionType mcEncryptionType;
2920 eCsrEncryptionType ucEncryptionType;
2921
2922 ENTER();
2923 switch(wrqu->param.flags & IW_AUTH_INDEX)
2924 {
2925 case IW_AUTH_WPA_VERSION:
2926
2927 pWextState->wpaVersion = wrqu->param.value;
2928
2929 break;
2930
2931 case IW_AUTH_CIPHER_PAIRWISE:
2932 {
2933 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
2934 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
2935 }
2936 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
2937 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
2938 }
2939 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
2940 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
2941 }
2942
2943 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
2944
2945 if( (IW_AUTH_KEY_MGMT_802_1X
2946 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
2947 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
2948 /*Dynamic WEP key*/
2949 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
2950 else
2951 /*Static WEP key*/
2952 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2953 }
2954 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
2955
2956 if( ( IW_AUTH_KEY_MGMT_802_1X
2957 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
2958 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
2959 /*Dynamic WEP key*/
2960 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
2961 else
2962 /*Static WEP key*/
2963 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2964
2965 }
2966 else {
2967
2968 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002969 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 return -EINVAL;
2971 }
2972
2973 pRoamProfile->EncryptionType.numEntries = 1;
2974 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
2975 }
2976 break;
2977 case IW_AUTH_CIPHER_GROUP:
2978 {
2979 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
2980 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
2981 }
2982
2983 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
2984 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
2985 }
2986
2987 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
2988 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
2989 }
2990
2991 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
2992
2993 if( ( IW_AUTH_KEY_MGMT_802_1X
2994 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
2995 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
2996
2997 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
2998
2999 else
3000 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3001 }
3002
3003 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3004 {
3005 /*Dynamic WEP keys won't work with shared keys*/
3006 if( ( IW_AUTH_KEY_MGMT_802_1X
3007 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
3008 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3009 {
3010 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3011 }
3012 else
3013 {
3014 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3015 }
3016 }
3017 else {
3018
3019 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003020 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 return -EINVAL;
3022 }
3023
3024 pRoamProfile->mcEncryptionType.numEntries = 1;
3025 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3026 }
3027 break;
3028
3029 case IW_AUTH_80211_AUTH_ALG:
3030 {
3031 /*Save the auth algo here and set auth type to SME Roam profile
3032 in the iw_set_ap_address*/
3033 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
3034 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3035
3036 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3037 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3038
3039 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3040 /*Not supported*/
3041 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3042 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3043 }
3044 break;
3045
3046 case IW_AUTH_KEY_MGMT:
3047 {
3048#ifdef FEATURE_WLAN_CCX
3049#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3050 /*Check for CCKM AKM type */
3051 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003052 //hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
3053 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 /* Set the CCKM bit in authKeyMgmt */
3055 /* Right now, this breaks all ref to authKeyMgmt because our
3056 * code doesn't realize it is a "bitfield"
3057 */
3058 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3059 /*Set the key management to 802.1X*/
3060 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
3061 pWextState->isCCXConnection = eANI_BOOLEAN_TRUE;
3062 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3063 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3064 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3065 /*Save the key management*/
3066 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3067 //pWextState->authKeyMgmt = wrqu->param.value;
3068 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3069 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3070 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3071 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3072 /*Save the key management anyway*/
3073 pWextState->authKeyMgmt = wrqu->param.value;
3074 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3075 /*Save the key management*/
3076 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3077 //pWextState->authKeyMgmt = wrqu->param.value;
3078 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3079 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3080 }
3081#else
3082 /*Save the key management*/
3083 pWextState->authKeyMgmt = wrqu->param.value;
3084#endif /* FEATURE_WLAN_CCX */
3085 }
3086 break;
3087
3088 case IW_AUTH_TKIP_COUNTERMEASURES:
3089 {
3090 if(wrqu->param.value) {
3091 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3092 "Counter Measure started %d", wrqu->param.value);
3093 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3094 }
3095 else {
3096 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3097 "Counter Measure stopped=%d", wrqu->param.value);
3098 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3099 }
3100 }
3101 break;
3102 case IW_AUTH_DROP_UNENCRYPTED:
3103 case IW_AUTH_WPA_ENABLED:
3104 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3105 case IW_AUTH_ROAMING_CONTROL:
3106 case IW_AUTH_PRIVACY_INVOKED:
3107
3108 default:
3109
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003110 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 wrqu->param.flags & IW_AUTH_INDEX);
3112 break;
3113 }
3114
3115 EXIT();
3116 return 0;
3117}
3118/**---------------------------------------------------------------------------
3119
3120 \brief iw_get_auth() -
3121 This function returns the auth type to the wpa_supplicant.
3122
3123 \param - dev - Pointer to the net device.
3124 - info - Pointer to the iw_request_info.
3125 - wrqu - Pointer to the iwreq_data.
3126 - extra - Pointer to the data.
3127 \return - 0 for success, non zero for failure
3128
3129 --------------------------------------------------------------------------*/
3130int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3131 union iwreq_data *wrqu,char *extra)
3132{
3133 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3134 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3135 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3136 ENTER();
3137 switch(pRoamProfile->negotiatedAuthType)
3138 {
3139 case eCSR_AUTH_TYPE_WPA_NONE:
3140 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3141 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3142 break;
3143 case eCSR_AUTH_TYPE_WPA:
3144 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3145 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3146 break;
3147#ifdef WLAN_FEATURE_VOWIFI_11R
3148 case eCSR_AUTH_TYPE_FT_RSN:
3149#endif
3150 case eCSR_AUTH_TYPE_RSN:
3151 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3152 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3153 break;
3154 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3155 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3156 break;
3157 case eCSR_AUTH_TYPE_SHARED_KEY:
3158 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3159 break;
3160 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003161 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3163 break;
3164 case eCSR_AUTH_TYPE_AUTOSWITCH:
3165 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3166 break;
3167 case eCSR_AUTH_TYPE_WPA_PSK:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003168 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3170 return -EIO;
3171#ifdef WLAN_FEATURE_VOWIFI_11R
3172 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3173#endif
3174 case eCSR_AUTH_TYPE_RSN_PSK:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003175 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3177 return -EIO;
3178 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003179 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3181 return -EIO;
3182 }
3183 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3184 {
3185 switch(pRoamProfile->negotiatedUCEncryptionType)
3186 {
3187 case eCSR_ENCRYPT_TYPE_NONE:
3188 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3189 break;
3190 case eCSR_ENCRYPT_TYPE_WEP40:
3191 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3192 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3193 break;
3194 case eCSR_ENCRYPT_TYPE_TKIP:
3195 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3196 break;
3197 case eCSR_ENCRYPT_TYPE_WEP104:
3198 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3199 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3200 break;
3201 case eCSR_ENCRYPT_TYPE_AES:
3202 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3203 break;
3204 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003205 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 return -EIO;
3207 }
3208 }
3209
3210 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
3211 {
3212 switch(pRoamProfile->negotiatedMCEncryptionType)
3213 {
3214 case eCSR_ENCRYPT_TYPE_NONE:
3215 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3216 break;
3217 case eCSR_ENCRYPT_TYPE_WEP40:
3218 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3219 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3220 break;
3221 case eCSR_ENCRYPT_TYPE_TKIP:
3222 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3223 break;
3224 case eCSR_ENCRYPT_TYPE_WEP104:
3225 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3226 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3227 break;
3228 case eCSR_ENCRYPT_TYPE_AES:
3229 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3230 break;
3231 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003232 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 return -EIO;
3234 }
3235 }
3236
3237 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003238 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 EXIT();
3240 return 0;
3241}
3242/**---------------------------------------------------------------------------
3243
3244 \brief iw_set_ap_address() -
3245 This function calls the sme_RoamConnect function to associate
3246 to the AP with the specified BSSID received from the wpa_supplicant.
3247
3248 \param - dev - Pointer to the net device.
3249 - info - Pointer to the iw_request_info.
3250 - wrqu - Pointer to the iwreq_data.
3251 - extra - Pointer to the data.
3252 \return - 0 for success, non zero for failure
3253
3254 --------------------------------------------------------------------------*/
3255int iw_set_ap_address(struct net_device *dev,
3256 struct iw_request_info *info,
3257 union iwreq_data *wrqu, char *extra)
3258{
3259 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3260 v_U8_t *pMacAddress=NULL;
3261 ENTER();
3262 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
3263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%02x:%02x:%02x:%02x:%02x:%02x",pMacAddress[0],pMacAddress[1],
3264 pMacAddress[2],pMacAddress[3],pMacAddress[4],pMacAddress[5]);
3265 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3266 EXIT();
3267
3268 return 0;
3269}
3270/**---------------------------------------------------------------------------
3271
3272 \brief iw_get_ap_address() -
3273 This function returns the BSSID to the wpa_supplicant
3274 \param - dev - Pointer to the net device.
3275 - info - Pointer to the iw_request_info.
3276 - wrqu - Pointer to the iwreq_data.
3277 - extra - Pointer to the data.
3278 \return - 0 for success, non zero for failure
3279
3280 --------------------------------------------------------------------------*/
3281int iw_get_ap_address(struct net_device *dev,
3282 struct iw_request_info *info,
3283 union iwreq_data *wrqu, char *extra)
3284{
3285 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3286 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3287
3288 ENTER();
3289
3290 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3291 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3292 {
3293 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,sizeof(wrqu->ap_addr.sa_data));
3294 }
3295 else
3296 {
3297 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
3298 }
3299 EXIT();
3300 return 0;
3301}
Jeff Johnsond13512a2012-07-17 11:42:19 -07003302
3303
3304/**---------------------------------------------------------------------------
3305
3306 \brief hdd_ResetCountryCodeAfterDisAssoc -
3307 This function reset the country code to default
Jeff Johnsona8a1a482012-12-12 16:49:33 -08003308 \param - pAdapter - Pointer to HDD adapter
Jeff Johnsond13512a2012-07-17 11:42:19 -07003309 \return - nothing
3310
3311 --------------------------------------------------------------------------*/
3312void hdd_ResetCountryCodeAfterDisAssoc(hdd_adapter_t *pAdapter)
3313{
3314 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3315 tSmeConfigParams smeConfig;
3316 eHalStatus status = eHAL_STATUS_SUCCESS;
3317 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
3318 tANI_U8 currentCountryCode[3] = SME_INVALID_COUNTRY_CODE;
3319
3320 sme_GetConfigParam(pHddCtx->hHal, &smeConfig);
3321
3322 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3323 "%s: 11d is %s\n",__func__,
3324 smeConfig.csrConfig.Is11dSupportEnabled ? "Enabled" : "Disabled");
3325 /* Reset country code only when 11d is enabled
3326 */
3327 if (smeConfig.csrConfig.Is11dSupportEnabled)
3328 {
3329 sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, &defaultCountryCode[0]);
3330 sme_GetCurrentCountryCode(pHddCtx->hHal, &currentCountryCode[0]);
3331
3332 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3333 "%s: Default country code: %c%c%c, Current Country code: %c%c%c \n",
3334 __func__,
3335 defaultCountryCode[0], defaultCountryCode[1], defaultCountryCode[2],
3336 currentCountryCode[0], currentCountryCode[1], currentCountryCode[2]);
3337 /* Reset country code only when there is a mismatch
3338 * between current country code and default country code
3339 */
3340 if ((defaultCountryCode[0] != currentCountryCode[0]) ||
3341 (defaultCountryCode[1] != currentCountryCode[1]) ||
3342 (defaultCountryCode[2] != currentCountryCode[2]))
3343 {
3344 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3345 "%s: Disconnected from the AP/Assoc failed and "
3346 "resetting the country code to default\n",__func__);
3347 /*reset the country code of previous connection*/
3348 status = (int)sme_ChangeCountryCode(pHddCtx->hHal, NULL,
3349 &defaultCountryCode[0], pAdapter,
3350 pHddCtx->pvosContext
3351 );
3352 if( 0 != status )
3353 {
3354 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3355 "%s: failed to Reset the Country Code\n",__func__);
3356 }
3357 }
3358 }
Kiran4a17ebe2013-01-31 10:43:43 -08003359 else if (smeConfig.csrConfig.Is11hSupportEnabled)
3360 {
3361 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3362 "%s: Disconnected from the AP/Assoc failed and "
3363 "resetting the 5G power values to default", __func__);
3364 sme_ResetPowerValuesFor5G (pHddCtx->hHal);
3365 }
Jeff Johnsond13512a2012-07-17 11:42:19 -07003366}
3367