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