blob: 8a3012473f6d31951678b049e064cc8c56d30e00 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala9c070ad2013-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 Khannac0b992f2012-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 Khannac0b992f2012-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
1780 if (-1 == wlan_hdd_saveTdlsPeer(pRoamInfo)) {
1781 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1782 "wlan_hdd_saveTdlsPeer() failed");
1783 }
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 Rajesh381fd572013-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 Khannac0b992f2012-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 ;
Hoonki Lee068d4142013-01-16 17:40:54 -08001879
1880#ifdef WLAN_FEATURE_TDLS_DEBUG
1881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1882 ("hdd_tdlsStatusUpdate: %s staIdx %d %02x:%02x:%02x:%02x:%02x:%02x \n"), roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" :
1883 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER": "UNKNOWN",
1884 pRoamInfo->staId,
1885 pRoamInfo->peerMac[0],
1886 pRoamInfo->peerMac[1],
1887 pRoamInfo->peerMac[2],
1888 pRoamInfo->peerMac[3],
1889 pRoamInfo->peerMac[4],
1890 pRoamInfo->peerMac[5]) ;
1891#endif
Mohit Khannac0b992f2012-12-04 15:08:18 -08001892 switch( roamResult )
1893 {
1894 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
1895 {
1896 tANI_U8 staIdx = 0 ;
Lee Hoonkibd80e062013-01-29 02:07:07 -08001897
1898 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
1899 {
1900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1901 ("%s: Add Sta is failed."),__func__ );
1902 break;
1903 }
Mohit Khannac0b992f2012-12-04 15:08:18 -08001904 /*
1905 * check if there is available index for this new TDLS STA
1906 * since TDLS is setup in BSS, we need to start from +1
1907 */
1908 for ( staIdx = 0 ;
1909 staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
1910 {
1911 if (0 == pHddStaCtx->conn_info.staId[staIdx] )
1912 {
1913 pHddStaCtx->conn_info.staId[staIdx] = pRoamInfo->staId;
1914
1915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1916 ("TDLS: STA IDX at %d \
1917 and mac = %d: %02x,%02x, %02x, %02x, %02x, %02x\n"),
1918 staIdx, pHddStaCtx->conn_info.staId[staIdx],
1919 pRoamInfo->peerMac[0],
1920 pRoamInfo->peerMac[1],
1921 pRoamInfo->peerMac[2],
1922 pRoamInfo->peerMac[3],
1923 pRoamInfo->peerMac[4],
1924 pRoamInfo->peerMac[5]) ;
1925
1926 vos_copy_macaddr(
1927 &pHddStaCtx->conn_info.peerMacAddress[staIdx],
1928 (v_MACADDR_t *)pRoamInfo->peerMac) ;
1929 status = eHAL_STATUS_SUCCESS ;
1930 break ;
1931 }
1932 }
1933 if(eHAL_STATUS_SUCCESS == status)
1934 {
Madan Mohan Koyyalamudi211efc62012-12-03 15:55:46 -08001935 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
1936 v_BOOL_t fConnected = FALSE;
1937
1938 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1939 if( fConnected )
1940 {
1941 /* start TDLS client registration with TL */
1942 status = hdd_roamRegisterTDLSSTA( pAdapter, pRoamInfo,
1943 ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )? 1 : 0 ) ;
1944 }
Mohit Khannac0b992f2012-12-04 15:08:18 -08001945 }
1946 break ;
1947 }
1948 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
1949 {
1950 tANI_U8 staIdx = 0 ;
1951 status = eHAL_STATUS_FAILURE ;
1952
1953 for ( staIdx = 0 ;
1954 staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
1955 {
1956 if (pRoamInfo->staId == pHddStaCtx->conn_info.staId[staIdx] )
1957 {
1958 pHddStaCtx->conn_info.staId[staIdx] = 0 ;
1959 vos_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[staIdx],
1960 sizeof(v_MACADDR_t)) ;
1961 status = eHAL_STATUS_SUCCESS ;
1962
1963 break ;
1964 }
1965 }
1966 if(eHAL_STATUS_SUCCESS == status)
1967 {
1968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1969 ("HDD: del STA IDX = %x\n"), pRoamInfo->staId) ;
Hoonki Leebec7bad2013-01-16 19:29:14 -08001970 wlan_hdd_removeTdlsPeer(pRoamInfo);
Chauhan Rajesh381fd572013-01-24 21:00:15 -08001971 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
Mohit Khannac0b992f2012-12-04 15:08:18 -08001972 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = NULL;
1973 }
1974 break ;
1975 }
1976 default:
1977 {
1978 break ;
1979 }
1980 }
1981
1982 return status ;
1983}
1984#endif
1985
Jeff Johnson295189b2012-06-20 16:38:30 -07001986eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
1987 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
1988{
1989 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1990 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05301991 hdd_wext_state_t *pWextState = NULL;
1992 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07001993 VOS_STATUS status = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001994
1995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1996 "CSR Callback: status= %d result= %d roamID=%ld",
1997 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001998
1999 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302000 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002001 {
2002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302003 "invalid adapter or adapter has invalid magic");
2004 return eHAL_STATUS_FAILURE;
2005 }
2006
2007 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2008 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2009
2010 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2011 {
2012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2013 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002014 return eHAL_STATUS_FAILURE;
2015 }
2016
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 switch( roamStatus )
2018 {
2019 case eCSR_ROAM_SESSION_OPENED:
2020 if(pAdapter != NULL)
2021 {
2022 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2023 complete(&pAdapter->session_open_comp_var);
2024 }
2025 break;
2026
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002027#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 /* We did pre-auth,then we attempted a 11r or ccx reassoc.
2029 * reassoc failed due to failure, timeout, reject from ap
2030 * in any case tell the OS, our carrier is off and mark
2031 * interface down */
2032 case eCSR_ROAM_FT_REASSOC_FAILED:
2033 hddLog(LOG1, FL("Reassoc Failed\n"));
2034 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2035 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2036 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
2037#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
2038#ifdef MSM_PLATFORM
2039 hdd_conf_mcastbcast_filter((WLAN_HDD_GET_CTX(pAdapter)), FALSE);
2040#endif
2041#endif
2042 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2043 }
2044 pHddStaCtx->ft_carrier_on = FALSE;
2045 break;
2046
2047 case eCSR_ROAM_FT_START:
2048 // When we roam for CCX and 11r, we dont want the
2049 // OS to be informed that the link is down. So mark
2050 // the link ready for ft_start. After this the
2051 // eCSR_ROAM_SHOULD_ROAM will be received.
2052 // Where in we will not mark the link down
2053 // Also we want to stop tx at this point when we will be
2054 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002055 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 {
2057 struct net_device *dev = pAdapter->dev;
2058 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002059 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002060 * Deregister for this STA with TL with the objective to flush
2061 * all the packets for this STA from wmm_tx_queue. If not done here,
2062 * we would run into a race condition (CR390567) wherein TX
2063 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2064 * been deleted. And, these packets get assigned with a STA idx of
2065 * self-sta (since the peer STA has been deleted) and get transmitted
2066 * on the new channel before the reassoc request. Since there will be
2067 * no ACK on the new channel, each packet gets retransmitted which
2068 * takes several seconds before the transmission of reassoc request.
2069 * This leads to reassoc-timeout and roam failure.
2070 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002071 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2072 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2073 {
2074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2075 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2076 pHddStaCtx->conn_info.staId[0], status, status );
2077 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 }
2080 pHddStaCtx->ft_carrier_on = TRUE;
2081 break;
2082#endif
2083
2084 case eCSR_ROAM_SHOULD_ROAM:
2085 // Dont need to do anything
2086 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 struct net_device *dev = pAdapter->dev;
2088 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2089 // notify apps that we can't pass traffic anymore
2090 netif_tx_disable(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002091#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 if (pHddStaCtx->ft_carrier_on == FALSE)
2093 {
2094#endif
2095 netif_carrier_off(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002096#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 }
2098#endif
2099
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002100#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 //We should clear all sta register with TL, for now, only one.
2102 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2103 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2104 {
2105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2106 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2107 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002108 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002110#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002111 // Clear saved connection information in HDD
2112 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
2113 }
2114 break;
2115 case eCSR_ROAM_LOSTLINK:
2116 case eCSR_ROAM_DISASSOCIATED:
2117 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2120 "****eCSR_ROAM_DISASSOCIATED****");
2121 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2122 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2123 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
2124 hdd_conf_mcastbcast_filter((WLAN_HDD_GET_CTX(pAdapter)), FALSE);
2125 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2126 }
2127#ifdef WLAN_FEATURE_PACKET_FILTERING
2128 if (pHddCtx->cfg_ini->isMcAddrListFilter)
2129 {
2130 /*Multicast addr filtering is enabled*/
2131 if(pHddCtx->mc_addr_list.isFilterApplied)
2132 {
2133 /*Filter applied during suspend mode*/
2134 /*Clear it here*/
Jeff Johnsone7245742012-09-05 17:12:55 -07002135 wlan_hdd_set_mc_addr_list(pHddCtx, FALSE, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 }
2137 }
2138#endif
2139
Jeff Johnsone7245742012-09-05 17:12:55 -07002140 if (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode)
2141 {
2142 /* Disconnected from current AP. Reset the country code information
2143 * so that it re-initialize the valid channel list*/
2144 hdd_ResetCountryCodeAfterDisAssoc(pAdapter);
2145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 }
2147 break;
2148 case eCSR_ROAM_IBSS_LEAVE:
2149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2150 "****eCSR_ROAM_IBSS_LEAVE****");
2151 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2152 break;
2153 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2155 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
2156 if ( (roamResult != eCSR_ROAM_RESULT_ASSOCIATED)
2157 && ( (pWextState->roamProfile.EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY)
2158 || (pWextState->roamProfile.EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)
2159 )
2160 && (eCSR_AUTH_TYPE_SHARED_KEY != pWextState->roamProfile.AuthType.authType[0])
2161 )
2162 {
2163 v_U32_t roamId = 0;
2164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2165 "****WEP open authentication failed, trying with shared authentication****");
2166 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
2167 pWextState->roamProfile.AuthType.authType[0] = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2168 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2169 halStatus = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &(pWextState->roamProfile), &roamId);
2170 }
2171 else
2172 {
2173 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2174 }
2175
2176 break;
2177 case eCSR_ROAM_ASSOCIATION_FAILURE:
2178 halStatus = hdd_AssociationCompletionHandler( pAdapter,
2179 pRoamInfo, roamId, roamStatus, roamResult );
2180 break;
2181 case eCSR_ROAM_IBSS_IND:
2182 halStatus = roamRoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2183 break;
2184
2185 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2186 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2187 break;
2188
2189 case eCSR_ROAM_MIC_ERROR_IND:
2190 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2191 break;
2192
2193 case eCSR_ROAM_SET_KEY_COMPLETE:
2194 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2195 break;
2196#ifdef WLAN_FEATURE_VOWIFI_11R
2197 case eCSR_ROAM_FT_RESPONSE:
2198 hdd_SendFTEvent(pAdapter);
2199 break;
2200#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002201#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002202 case eCSR_ROAM_PMK_NOTIFY:
Jeff Johnson43971f52012-07-17 12:26:56 -07002203 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
2204 {
2205 /* Notify the supplicant of a new candidate */
2206 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2207 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002208 break;
2209#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002210
2211#ifdef WLAN_FEATURE_P2P
2212 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2213 hdd_indicateMgmtFrame( pAdapter,
2214 pRoamInfo->nFrameLength,
2215 pRoamInfo->pbFrames,
2216 pRoamInfo->frameType,
Chilam NGde0b4112013-01-19 12:27:36 +05302217 pRoamInfo->rxChan,
2218 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 break;
2220 case eCSR_ROAM_REMAIN_CHAN_READY:
2221 hdd_remainChanReadyHandler( pAdapter );
2222 break;
2223 case eCSR_ROAM_SEND_ACTION_CNF:
2224 hdd_sendActionCnf( pAdapter,
2225 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2226 break;
2227#endif
Mohit Khannac0b992f2012-12-04 15:08:18 -08002228#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyyalamudi9ea58272012-12-27 17:26:52 -08002229 case eCSR_ROAM_TDLS_STATUS_UPDATE:
2230 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
2231 roamId, roamStatus, roamResult );
2232 break ;
Mohit Khannac0b992f2012-12-04 15:08:18 -08002233#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 default:
2235 break;
2236 }
2237 return( halStatus );
2238}
2239eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
2240{
2241 eCsrAuthType auth_type;
2242 // is the auth type supported?
2243 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
2244 {
2245 auth_type = eCSR_AUTH_TYPE_RSN;
2246 } else
2247 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
2248 {
2249 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
2250 } else
2251#ifdef WLAN_FEATURE_VOWIFI_11R
2252 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
2253 {
2254 // Check for 11r FT Authentication with PSK
2255 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
2256 } else
2257 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
2258 {
2259 // Check for 11R FT Authentication with 802.1X
2260 auth_type = eCSR_AUTH_TYPE_FT_RSN;
2261 } else
2262#endif
2263#ifdef FEATURE_WLAN_CCX
2264 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
2265 {
2266 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2267 } else
2268#endif /* FEATURE_WLAN_CCX */
2269 {
2270 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2271 }
2272 return auth_type;
2273}
2274#ifdef WLAN_SOFTAP_FEATURE
2275eCsrAuthType
2276hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
2277#else
2278static eCsrAuthType hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
2279#endif
2280{
2281 eCsrAuthType auth_type;
2282 // is the auth type supported?
2283 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
2284 {
2285 auth_type = eCSR_AUTH_TYPE_WPA;
2286 } else
2287 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
2288 {
2289 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
2290 } else
2291#ifdef FEATURE_WLAN_CCX
2292 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
2293 {
2294 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
2295 } else
2296#endif /* FEATURE_WLAN_CCX */
2297 {
2298 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2299 }
2300 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2301 return auth_type;
2302}
2303#ifdef WLAN_SOFTAP_FEATURE
2304eCsrEncryptionType
2305hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
2306#else
2307static eCsrEncryptionType hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
2308#endif
2309{
2310 eCsrEncryptionType cipher_type;
2311 // is the cipher type supported?
2312 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
2313 {
2314 cipher_type = eCSR_ENCRYPT_TYPE_AES;
2315 }
2316 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
2317 {
2318 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
2319 }
2320 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
2321 {
2322 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
2323 }
2324 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
2325 {
2326 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2327 }
2328 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2329 {
2330 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2331 }
2332 else
2333 {
2334 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2335 }
2336 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2337 return cipher_type;
2338}
2339/* To find if the MAC address is NULL */
2340static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
2341{
2342 int i;
2343 for (i = 0; i < length; i++)
2344 {
2345 if (0x00 != (macAddr[i]))
2346 {
2347 return FALSE;
2348 }
2349 }
2350 return TRUE;
2351} /****** end hdd_IsMACAddrNULL() ******/
2352#ifdef WLAN_SOFTAP_FEATURE
2353eCsrEncryptionType
2354hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
2355#else
2356static eCsrEncryptionType
2357hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
2358#endif
2359{
2360 eCsrEncryptionType cipher_type;
2361 // is the cipher type supported?
2362 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
2363 {
2364 cipher_type = eCSR_ENCRYPT_TYPE_AES;
2365 } else
2366 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
2367 {
2368 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
2369 } else
2370 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
2371 {
2372 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
2373 } else
2374 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
2375 {
2376 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2377 } else
2378 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
2379 {
2380 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2381 } else
2382 {
2383 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2384 }
2385 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2386 return cipher_type;
2387}
2388
2389static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
2390 struct ether_addr *pBssid,
2391 eCsrEncryptionType *pEncryptType,
2392 eCsrEncryptionType *mcEncryptType,
2393 eCsrAuthType *pAuthType,
2394 u_int16_t gen_ie_len,
2395 u_int8_t *gen_ie)
2396{
2397 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
2398 eHalStatus result;
2399 tDot11fIERSN dot11RSNIE;
2400 tDot11fIEWPA dot11WPAIE;
2401 tANI_U32 i;
2402 tANI_U8 *pRsnIe;
2403 tANI_U16 RSNIeLen;
2404 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
2405
2406 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
2407 flag to 0 */
2408 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
2409 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
2410
2411 // Validity checks
2412 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
2413 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
2414 return -EINVAL;
2415 // Type check
2416 if ( gen_ie[0] == DOT11F_EID_RSN)
2417 {
2418 // Validity checks
2419 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
2420 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
2421 {
2422 return -EINVAL;
2423 }
2424 // Skip past the EID byte and length byte
2425 pRsnIe = gen_ie + 2;
2426 RSNIeLen = gen_ie_len - 2;
2427 // Unpack the RSN IE
2428 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
2429 pRsnIe,
2430 RSNIeLen,
2431 &dot11RSNIE);
2432 // Copy out the encryption and authentication types
2433 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002434 __func__, dot11RSNIE.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002436 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 /*Here we have followed the apple base code,
2438 but probably I suspect we can do something different*/
2439 //dot11RSNIE.akm_suite_count
2440 // Just translate the FIRST one
2441 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
2442 //dot11RSNIE.pwise_cipher_suite_count
2443 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
2444 //dot11RSNIE.gp_cipher_suite_count
2445 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
2446 // Set the PMKSA ID Cache for this interface
2447 for (i=0; i<dot11RSNIE.pmkid_count; i++)
2448 {
2449 if ( pBssid == NULL)
2450 {
2451 break;
2452 }
2453 if ( hdd_IsMACAddrNULL( (u_char *) pBssid , sizeof( (char *) pBssid)))
2454 {
2455 break;
2456 }
2457 // For right now, I assume setASSOCIATE() has passed in the bssid.
2458 vos_mem_copy(PMKIDCache[i].BSSID,
2459 pBssid, ETHER_ADDR_LEN);
2460 vos_mem_copy(PMKIDCache[i].PMKID,
2461 dot11RSNIE.pmkid[i],
2462 CSR_RSN_PMKID_SIZE);
2463 }
2464 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
2465 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %ld."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002466 __func__, i );
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 // Finally set the PMKSA ID Cache in CSR
2468 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
2469 PMKIDCache,
2470 dot11RSNIE.pmkid_count );
2471 }
2472 else if (gen_ie[0] == DOT11F_EID_WPA)
2473 {
2474 // Validity checks
2475 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
2476 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
2477 {
2478 return -EINVAL;
2479 }
2480 // Skip past the EID byte and length byte - and four byte WiFi OUI
2481 pRsnIe = gen_ie + 2 + 4;
2482 RSNIeLen = gen_ie_len - (2 + 4);
2483 // Unpack the WPA IE
2484 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
2485 pRsnIe,
2486 RSNIeLen,
2487 &dot11WPAIE);
2488 // Copy out the encryption and authentication types
2489 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002490 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002492 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07002493 //dot11WPAIE.auth_suite_count
2494 // Just translate the FIRST one
2495 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
2496 //dot11WPAIE.unicast_cipher_count
2497 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
2498 //dot11WPAIE.unicast_cipher_count
2499 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
2500 }
2501 else
2502 {
2503 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
2504 return -EINVAL;
2505 }
2506 return 0;
2507}
2508int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
2509{
2510 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2511 v_U32_t status = 0;
2512 eCsrEncryptionType RSNEncryptType;
2513 eCsrEncryptionType mcRSNEncryptType;
2514 struct ether_addr bSsid; // MAC address of assoc peer
2515 // MAC address of assoc peer
2516 // But, this routine is only called when we are NOT associated.
2517 vos_mem_copy(bSsid.ether_addr_octet,
2518 pWextState->roamProfile.BSSIDs.bssid,
2519 sizeof(bSsid.ether_addr_octet));
2520 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
2521 {
2522 //continue
2523 }
2524 else
2525 {
2526 return 0;
2527 }
2528 // The actual processing may eventually be more extensive than this.
2529 // Right now, just consume any PMKIDs that are sent in by the app.
2530 status = hdd_ProcessGENIE(pAdapter,
2531 &bSsid, // MAC address of assoc peer
2532 &RSNEncryptType,
2533 &mcRSNEncryptType,
2534 RSNAuthType,
2535 pWextState->WPARSNIE[1]+2,
2536 pWextState->WPARSNIE);
2537 if (status == 0)
2538 {
2539 // Now copy over all the security attributes you have parsed out
2540 pWextState->roamProfile.EncryptionType.numEntries = 1;
2541 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
2542
2543 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
2544 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002545 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 }
2547 return 0;
2548}
2549int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
2550{
2551 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2552 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
2553 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2554 ENTER();
2555
2556 pRoamProfile->AuthType.numEntries = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002557 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d\n", __func__, pHddStaCtx->conn_info.authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002558
2559 switch( pHddStaCtx->conn_info.authType)
2560 {
2561 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2562#ifdef FEATURE_WLAN_CCX
2563 case eCSR_AUTH_TYPE_CCKM_WPA:
2564 case eCSR_AUTH_TYPE_CCKM_RSN:
2565#endif
2566 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
2567
2568 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
2569 } else
2570 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
2571
2572#ifdef FEATURE_WLAN_CCX
2573 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
2574 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2575 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002576 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
2578 } else
2579 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002580 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
2582 } else
2583#endif
2584 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2585 == IW_AUTH_KEY_MGMT_802_1X) {
2586 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
2587 } else
2588 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2589 == IW_AUTH_KEY_MGMT_PSK) {
2590 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
2591 } else {
2592 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
2593 }
2594 }
2595 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
2596#ifdef FEATURE_WLAN_CCX
2597 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
2598 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2599 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002600 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
2602 } else
2603 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002604 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
2606 } else
2607#endif
2608
2609#ifdef WLAN_FEATURE_VOWIFI_11R
2610 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
2611 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2612 == IW_AUTH_KEY_MGMT_802_1X)) {
2613 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07002614 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
2616 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2617 == IW_AUTH_KEY_MGMT_PSK)) {
2618 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
2619 } else
2620#endif
2621
2622 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2623 == IW_AUTH_KEY_MGMT_802_1X) {
2624 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
2625 } else
2626 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2627 == IW_AUTH_KEY_MGMT_PSK) {
2628 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
2629 } else {
2630 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
2631 }
2632 }
2633 break;
2634
2635 case eCSR_AUTH_TYPE_SHARED_KEY:
2636
2637 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
2638 break;
2639 default:
2640
2641#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002642 hddLog( LOG1, "%s: In default, unknown auth type.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002643#endif /* FEATURE_WLAN_CCX */
2644 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
2645 break;
2646 }
2647
2648 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002649 __func__, pWextState->roamProfile.AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002650
2651 EXIT();
2652 return 0;
2653}
2654
2655/**---------------------------------------------------------------------------
2656
2657 \brief iw_set_essid() -
2658 This function sets the ssid received from wpa_supplicant
2659 to the CSR roam profile.
2660
2661 \param - dev - Pointer to the net device.
2662 - info - Pointer to the iw_request_info.
2663 - wrqu - Pointer to the iwreq_data.
2664 - extra - Pointer to the data.
2665 \return - 0 for success, non zero for failure
2666
2667 --------------------------------------------------------------------------*/
2668
2669int iw_set_essid(struct net_device *dev,
2670 struct iw_request_info *info,
2671 union iwreq_data *wrqu, char *extra)
2672{
2673 v_U32_t status = 0;
2674 hdd_wext_state_t *pWextState;
2675 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2676 v_U32_t roamId;
2677 tCsrRoamProfile *pRoamProfile;
2678 eMib_dot11DesiredBssType connectedBssType;
2679 eCsrAuthType RSNAuthType;
2680 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2681 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2682
2683 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2684
2685 ENTER();
2686
2687 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2688 {
2689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2690 "%s:LOGP in Progress. Ignore!!!",__func__);
2691 return 0;
2692 }
2693
2694 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
2695 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
2696 return -EBUSY;
2697 }
2698 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
2699 return -EINVAL;
2700 pRoamProfile = &pWextState->roamProfile;
2701 if (pRoamProfile)
2702 {
2703 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
2704 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
2705 {
2706 VOS_STATUS vosStatus;
2707 // need to issue a disconnect to CSR.
2708 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2709 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
2710
2711 if(VOS_STATUS_SUCCESS == vosStatus)
2712 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
2713 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2714 }
2715 }
2716 /** wpa_supplicant 0.8.x, wext driver uses */
2717 else
2718 {
2719 return -EINVAL;
2720 }
2721 /** wpa_supplicant 0.8.x, wext driver uses */
2722#ifdef CONFIG_CFG80211
2723 /** when cfg80211 defined, wpa_supplicant wext driver uses
2724 zero-length, null-string ssid for force disconnection.
2725 after disconnection (if previously connected) and cleaning ssid,
2726 driver MUST return success */
2727 if ( 0 == wrqu->essid.length ) {
2728 return 0;
2729 }
2730#endif
2731
2732 status = hdd_wmm_get_uapsd_mask(pAdapter,
2733 &pWextState->roamProfile.uapsd_mask);
2734 if (VOS_STATUS_SUCCESS != status)
2735 {
2736 pWextState->roamProfile.uapsd_mask = 0;
2737 }
2738 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
2739
2740 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
2741
2742 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
2743 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
2744 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
2745 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
2746
2747 //set gen ie
2748 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
2749
2750 //set auth
2751 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
2752 }
2753#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002754 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 if (pAdapter->wapi_info.nWapiMode)
2756 {
2757 switch (pAdapter->wapi_info.wapiAuthMode)
2758 {
2759 case WAPI_AUTH_MODE_PSK:
2760 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002761 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 pRoamProfile->AuthType.numEntries = 1;
2763 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
2764 break;
2765 }
2766 case WAPI_AUTH_MODE_CERT:
2767 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002768 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 pRoamProfile->AuthType.numEntries = 1;
2770 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
2771 break;
2772 }
2773 } // End of switch
2774 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
2775 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
2776 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002777 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002778 pRoamProfile->EncryptionType.numEntries = 1;
2779 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
2780 pRoamProfile->mcEncryptionType.numEntries = 1;
2781 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
2782 }
2783 }
2784#endif /* FEATURE_WLAN_WAPI */
2785 /* if previous genIE is not NULL, update AssocIE */
2786 if (0 != pWextState->genIE.length)
2787 {
2788 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
2789 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
2790 pWextState->genIE.length);
2791 pWextState->assocAddIE.length = pWextState->genIE.length;
2792 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
2793 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
2794
2795 /* clear previous genIE after use it */
2796 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2797 }
2798
2799 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
2800 pWextState->roamProfile.bWPSAssociation = FALSE;
2801
2802 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
2803 pWextState->roamProfile.nAddIEAssocLength))
2804 pWextState->roamProfile.bWPSAssociation = TRUE;
2805
2806
2807 // Disable auto BMPS entry by PMC until DHCP is done
2808 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
2809
2810 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2811 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
2812 status = sme_RoamConnect( hHal,pAdapter->sessionId, &(pWextState->roamProfile),&roamId);
2813 pRoamProfile->ChannelInfo.ChannelList = NULL;
2814 pRoamProfile->ChannelInfo.numOfChannels = 0;
2815
2816 EXIT();
2817 return status;
2818}
2819/**---------------------------------------------------------------------------
2820
2821 \brief iw_get_essid() -
2822 This function returns the essid to the wpa_supplicant.
2823
2824 \param - dev - Pointer to the net device.
2825 - info - Pointer to the iw_request_info.
2826 - wrqu - Pointer to the iwreq_data.
2827 - extra - Pointer to the data.
2828 \return - 0 for success, non zero for failure
2829
2830 --------------------------------------------------------------------------*/
2831int iw_get_essid(struct net_device *dev,
2832 struct iw_request_info *info,
2833 struct iw_point *dwrq, char *extra)
2834{
2835 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2836 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2837 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2838 ENTER();
2839
2840 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
2841 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
2842 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
2843 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
2844 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
2845 {
2846 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
2847 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
2848 dwrq->flags = 1;
2849 } else {
2850 memset(extra, 0, dwrq->length);
2851 dwrq->length = 0;
2852 dwrq->flags = 0;
2853 }
2854 EXIT();
2855 return 0;
2856}
2857/**---------------------------------------------------------------------------
2858
2859 \brief iw_set_auth() -
2860 This function sets the auth type received from the wpa_supplicant.
2861
2862 \param - dev - Pointer to the net device.
2863 - info - Pointer to the iw_request_info.
2864 - wrqu - Pointer to the iwreq_data.
2865 - extra - Pointer to the data.
2866 \return - 0 for success, non zero for failure
2867
2868 --------------------------------------------------------------------------*/
2869int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
2870 union iwreq_data *wrqu,char *extra)
2871{
2872 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2873 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2874 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2875 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
2876 eCsrEncryptionType mcEncryptionType;
2877 eCsrEncryptionType ucEncryptionType;
2878
2879 ENTER();
2880 switch(wrqu->param.flags & IW_AUTH_INDEX)
2881 {
2882 case IW_AUTH_WPA_VERSION:
2883
2884 pWextState->wpaVersion = wrqu->param.value;
2885
2886 break;
2887
2888 case IW_AUTH_CIPHER_PAIRWISE:
2889 {
2890 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
2891 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
2892 }
2893 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
2894 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
2895 }
2896 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
2897 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
2898 }
2899
2900 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
2901
2902 if( (IW_AUTH_KEY_MGMT_802_1X
2903 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
2904 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
2905 /*Dynamic WEP key*/
2906 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
2907 else
2908 /*Static WEP key*/
2909 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2910 }
2911 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
2912
2913 if( ( IW_AUTH_KEY_MGMT_802_1X
2914 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
2915 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
2916 /*Dynamic WEP key*/
2917 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
2918 else
2919 /*Static WEP key*/
2920 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2921
2922 }
2923 else {
2924
2925 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002926 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 return -EINVAL;
2928 }
2929
2930 pRoamProfile->EncryptionType.numEntries = 1;
2931 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
2932 }
2933 break;
2934 case IW_AUTH_CIPHER_GROUP:
2935 {
2936 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
2937 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
2938 }
2939
2940 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
2941 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
2942 }
2943
2944 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
2945 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
2946 }
2947
2948 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
2949
2950 if( ( IW_AUTH_KEY_MGMT_802_1X
2951 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
2952 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
2953
2954 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
2955
2956 else
2957 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2958 }
2959
2960 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
2961 {
2962 /*Dynamic WEP keys won't work with shared keys*/
2963 if( ( IW_AUTH_KEY_MGMT_802_1X
2964 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
2965 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
2966 {
2967 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
2968 }
2969 else
2970 {
2971 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2972 }
2973 }
2974 else {
2975
2976 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002977 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 return -EINVAL;
2979 }
2980
2981 pRoamProfile->mcEncryptionType.numEntries = 1;
2982 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
2983 }
2984 break;
2985
2986 case IW_AUTH_80211_AUTH_ALG:
2987 {
2988 /*Save the auth algo here and set auth type to SME Roam profile
2989 in the iw_set_ap_address*/
2990 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
2991 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
2992
2993 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
2994 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
2995
2996 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
2997 /*Not supported*/
2998 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
2999 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3000 }
3001 break;
3002
3003 case IW_AUTH_KEY_MGMT:
3004 {
3005#ifdef FEATURE_WLAN_CCX
3006#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3007 /*Check for CCKM AKM type */
3008 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003009 //hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
3010 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 /* Set the CCKM bit in authKeyMgmt */
3012 /* Right now, this breaks all ref to authKeyMgmt because our
3013 * code doesn't realize it is a "bitfield"
3014 */
3015 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3016 /*Set the key management to 802.1X*/
3017 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
3018 pWextState->isCCXConnection = eANI_BOOLEAN_TRUE;
3019 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3020 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3021 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3022 /*Save the key management*/
3023 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3024 //pWextState->authKeyMgmt = wrqu->param.value;
3025 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3026 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3027 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3028 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3029 /*Save the key management anyway*/
3030 pWextState->authKeyMgmt = wrqu->param.value;
3031 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3032 /*Save the key management*/
3033 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3034 //pWextState->authKeyMgmt = wrqu->param.value;
3035 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3036 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3037 }
3038#else
3039 /*Save the key management*/
3040 pWextState->authKeyMgmt = wrqu->param.value;
3041#endif /* FEATURE_WLAN_CCX */
3042 }
3043 break;
3044
3045 case IW_AUTH_TKIP_COUNTERMEASURES:
3046 {
3047 if(wrqu->param.value) {
3048 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3049 "Counter Measure started %d", wrqu->param.value);
3050 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3051 }
3052 else {
3053 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3054 "Counter Measure stopped=%d", wrqu->param.value);
3055 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3056 }
3057 }
3058 break;
3059 case IW_AUTH_DROP_UNENCRYPTED:
3060 case IW_AUTH_WPA_ENABLED:
3061 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3062 case IW_AUTH_ROAMING_CONTROL:
3063 case IW_AUTH_PRIVACY_INVOKED:
3064
3065 default:
3066
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003067 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 wrqu->param.flags & IW_AUTH_INDEX);
3069 break;
3070 }
3071
3072 EXIT();
3073 return 0;
3074}
3075/**---------------------------------------------------------------------------
3076
3077 \brief iw_get_auth() -
3078 This function returns the auth type to the wpa_supplicant.
3079
3080 \param - dev - Pointer to the net device.
3081 - info - Pointer to the iw_request_info.
3082 - wrqu - Pointer to the iwreq_data.
3083 - extra - Pointer to the data.
3084 \return - 0 for success, non zero for failure
3085
3086 --------------------------------------------------------------------------*/
3087int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3088 union iwreq_data *wrqu,char *extra)
3089{
3090 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3091 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3092 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3093 ENTER();
3094 switch(pRoamProfile->negotiatedAuthType)
3095 {
3096 case eCSR_AUTH_TYPE_WPA_NONE:
3097 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3098 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3099 break;
3100 case eCSR_AUTH_TYPE_WPA:
3101 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3102 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3103 break;
3104#ifdef WLAN_FEATURE_VOWIFI_11R
3105 case eCSR_AUTH_TYPE_FT_RSN:
3106#endif
3107 case eCSR_AUTH_TYPE_RSN:
3108 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3109 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3110 break;
3111 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3112 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3113 break;
3114 case eCSR_AUTH_TYPE_SHARED_KEY:
3115 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3116 break;
3117 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003118 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3120 break;
3121 case eCSR_AUTH_TYPE_AUTOSWITCH:
3122 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3123 break;
3124 case eCSR_AUTH_TYPE_WPA_PSK:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003125 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3127 return -EIO;
3128#ifdef WLAN_FEATURE_VOWIFI_11R
3129 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3130#endif
3131 case eCSR_AUTH_TYPE_RSN_PSK:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003132 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3134 return -EIO;
3135 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003136 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3138 return -EIO;
3139 }
3140 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3141 {
3142 switch(pRoamProfile->negotiatedUCEncryptionType)
3143 {
3144 case eCSR_ENCRYPT_TYPE_NONE:
3145 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3146 break;
3147 case eCSR_ENCRYPT_TYPE_WEP40:
3148 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3149 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3150 break;
3151 case eCSR_ENCRYPT_TYPE_TKIP:
3152 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3153 break;
3154 case eCSR_ENCRYPT_TYPE_WEP104:
3155 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3156 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3157 break;
3158 case eCSR_ENCRYPT_TYPE_AES:
3159 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3160 break;
3161 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003162 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 return -EIO;
3164 }
3165 }
3166
3167 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
3168 {
3169 switch(pRoamProfile->negotiatedMCEncryptionType)
3170 {
3171 case eCSR_ENCRYPT_TYPE_NONE:
3172 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3173 break;
3174 case eCSR_ENCRYPT_TYPE_WEP40:
3175 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3176 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3177 break;
3178 case eCSR_ENCRYPT_TYPE_TKIP:
3179 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3180 break;
3181 case eCSR_ENCRYPT_TYPE_WEP104:
3182 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3183 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3184 break;
3185 case eCSR_ENCRYPT_TYPE_AES:
3186 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3187 break;
3188 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003189 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 return -EIO;
3191 }
3192 }
3193
3194 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003195 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 EXIT();
3197 return 0;
3198}
3199/**---------------------------------------------------------------------------
3200
3201 \brief iw_set_ap_address() -
3202 This function calls the sme_RoamConnect function to associate
3203 to the AP with the specified BSSID received from the wpa_supplicant.
3204
3205 \param - dev - Pointer to the net device.
3206 - info - Pointer to the iw_request_info.
3207 - wrqu - Pointer to the iwreq_data.
3208 - extra - Pointer to the data.
3209 \return - 0 for success, non zero for failure
3210
3211 --------------------------------------------------------------------------*/
3212int iw_set_ap_address(struct net_device *dev,
3213 struct iw_request_info *info,
3214 union iwreq_data *wrqu, char *extra)
3215{
3216 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3217 v_U8_t *pMacAddress=NULL;
3218 ENTER();
3219 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
3220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%02x:%02x:%02x:%02x:%02x:%02x",pMacAddress[0],pMacAddress[1],
3221 pMacAddress[2],pMacAddress[3],pMacAddress[4],pMacAddress[5]);
3222 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3223 EXIT();
3224
3225 return 0;
3226}
3227/**---------------------------------------------------------------------------
3228
3229 \brief iw_get_ap_address() -
3230 This function returns the BSSID to the wpa_supplicant
3231 \param - dev - Pointer to the net device.
3232 - info - Pointer to the iw_request_info.
3233 - wrqu - Pointer to the iwreq_data.
3234 - extra - Pointer to the data.
3235 \return - 0 for success, non zero for failure
3236
3237 --------------------------------------------------------------------------*/
3238int iw_get_ap_address(struct net_device *dev,
3239 struct iw_request_info *info,
3240 union iwreq_data *wrqu, char *extra)
3241{
3242 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3243 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3244
3245 ENTER();
3246
3247 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3248 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3249 {
3250 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,sizeof(wrqu->ap_addr.sa_data));
3251 }
3252 else
3253 {
3254 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
3255 }
3256 EXIT();
3257 return 0;
3258}
Jeff Johnsond13512a2012-07-17 11:42:19 -07003259
3260
3261/**---------------------------------------------------------------------------
3262
3263 \brief hdd_ResetCountryCodeAfterDisAssoc -
3264 This function reset the country code to default
Madan Mohan Koyyalamudic1275fc2012-12-12 16:49:33 -08003265 \param - pAdapter - Pointer to HDD adapter
Jeff Johnsond13512a2012-07-17 11:42:19 -07003266 \return - nothing
3267
3268 --------------------------------------------------------------------------*/
3269void hdd_ResetCountryCodeAfterDisAssoc(hdd_adapter_t *pAdapter)
3270{
3271 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3272 tSmeConfigParams smeConfig;
3273 eHalStatus status = eHAL_STATUS_SUCCESS;
3274 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
3275 tANI_U8 currentCountryCode[3] = SME_INVALID_COUNTRY_CODE;
3276
3277 sme_GetConfigParam(pHddCtx->hHal, &smeConfig);
3278
3279 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3280 "%s: 11d is %s\n",__func__,
3281 smeConfig.csrConfig.Is11dSupportEnabled ? "Enabled" : "Disabled");
3282 /* Reset country code only when 11d is enabled
3283 */
3284 if (smeConfig.csrConfig.Is11dSupportEnabled)
3285 {
3286 sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, &defaultCountryCode[0]);
3287 sme_GetCurrentCountryCode(pHddCtx->hHal, &currentCountryCode[0]);
3288
3289 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3290 "%s: Default country code: %c%c%c, Current Country code: %c%c%c \n",
3291 __func__,
3292 defaultCountryCode[0], defaultCountryCode[1], defaultCountryCode[2],
3293 currentCountryCode[0], currentCountryCode[1], currentCountryCode[2]);
3294 /* Reset country code only when there is a mismatch
3295 * between current country code and default country code
3296 */
3297 if ((defaultCountryCode[0] != currentCountryCode[0]) ||
3298 (defaultCountryCode[1] != currentCountryCode[1]) ||
3299 (defaultCountryCode[2] != currentCountryCode[2]))
3300 {
3301 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3302 "%s: Disconnected from the AP/Assoc failed and "
3303 "resetting the country code to default\n",__func__);
3304 /*reset the country code of previous connection*/
3305 status = (int)sme_ChangeCountryCode(pHddCtx->hHal, NULL,
3306 &defaultCountryCode[0], pAdapter,
3307 pHddCtx->pvosContext
3308 );
3309 if( 0 != status )
3310 {
3311 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3312 "%s: failed to Reset the Country Code\n",__func__);
3313 }
3314 }
3315 }
Kirand170dcb2013-01-31 10:43:43 -08003316 else if (smeConfig.csrConfig.Is11hSupportEnabled)
3317 {
3318 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3319 "%s: Disconnected from the AP/Assoc failed and "
3320 "resetting the 5G power values to default", __func__);
3321 sme_ResetPowerValuesFor5G (pHddCtx->hHal);
3322 }
Jeff Johnsond13512a2012-07-17 11:42:19 -07003323}
3324