blob: 8dd8974a00cd0c1d7d641d0e9bfaf34d69772806 [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
Shailender Karmuchia734f332013-04-19 14:02:48 -070042
Jeff Johnson295189b2012-06-20 16:38:30 -070043/**========================================================================
44
45 \file wlan_hdd_assoc.c
46 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070047
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049/**=========================================================================
50 EDIT HISTORY FOR FILE
51
52
53 This section contains comments describing changes made to the module.
54 Notice that changes are listed in reverse chronological order.
55
56
57 $Header:$ $DateTime: $ $Author: $
58
59
60 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070061 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070062 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070063 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070064
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "wlan_hdd_includes.h"
66#include <aniGlobal.h>
67#include "dot11f.h"
68#include "wlan_nlink_common.h"
69#include "wlan_btc_svc.h"
70#include "wlan_hdd_power.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070071#include <linux/ieee80211.h>
72#include <linux/wireless.h>
73#include <net/cfg80211.h>
74#include "wlan_hdd_cfg80211.h"
75#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080#include "sme_Api.h"
81
82v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
83
Shailender Karmuchia734f332013-04-19 14:02:48 -070084struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070085{
86 u_char ether_addr_octet[6];
87};
88// These are needed to recognize WPA and RSN suite types
89#define HDD_WPA_OUI_SIZE 4
90v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
91v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
92v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
93v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
94v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
95v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
96#ifdef FEATURE_WLAN_CCX
97v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
98#endif /* FEATURE_WLAN_CCX */
99#define HDD_RSN_OUI_SIZE 4
100v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
101v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
102v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
103v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
104v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
105v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
106#ifdef FEATURE_WLAN_CCX
107v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
108#endif /* FEATURE_WLAN_CCX */
Chet Lanctot186b5732013-03-18 10:26:30 -0700109#ifdef WLAN_FEATURE_11W
110v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
111#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700112
Shailender Karmuchia734f332013-04-19 14:02:48 -0700113#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700114// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700115#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
116#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700117#endif
118
119#define BEACON_FRAME_IES_OFFSET 12
120
Jeff Johnsond13512a2012-07-17 11:42:19 -0700121void hdd_ResetCountryCodeAfterDisAssoc(hdd_adapter_t *pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700122
Chet Lanctot186b5732013-03-18 10:26:30 -0700123#ifdef WLAN_FEATURE_11W
124void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
125 tANI_U32 nFrameLength,
126 tANI_U8* pbFrames,
127 tANI_U8 frameType );
128#endif
129
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530130v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
131 eConnectionState connState )
132{
133 // save the new connection state
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 pHddStaCtx->conn_info.connState = connState;
135}
136
137// returns FALSE if not connected.
138// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
139// returns the connection state. Can specify NULL if you dont' want to get the actual state.
140
Shailender Karmuchia734f332013-04-19 14:02:48 -0700141static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
142 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700143{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700144 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700146
Jeff Johnson295189b2012-06-20 16:38:30 -0700147 // get the connection state.
148 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700149 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 if ( eConnectionState_Associated == connState ||
151 eConnectionState_IbssConnected == connState )
152 {
153 fConnected = VOS_TRUE;
154 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700155 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 {
157 fConnected = VOS_FALSE;
158 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700159
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 if ( pConnState )
161 {
162 *pConnState = connState;
163 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700164
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 return( fConnected );
166}
167
168v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
169{
170 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700171}
Jeff Johnson295189b2012-06-20 16:38:30 -0700172
173//TODO - Not used anyhwere. Can be removed.
174#if 0
175//
176v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
177{
178 v_BOOL_t fConnectedInfra = FALSE;
179 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700180
Jeff Johnson295189b2012-06-20 16:38:30 -0700181 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700182 {
183 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 {
185 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700186 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700188
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 return( fConnectedInfra );
190}
191#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700192
Jeff Johnson295189b2012-06-20 16:38:30 -0700193static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
194{
195 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700196
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700198
199 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700200 {
201 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
202 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700203
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 return( fConnected );
205}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700206
Jeff Johnson295189b2012-06-20 16:38:30 -0700207inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
208{
209 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700210
Jeff Johnson295189b2012-06-20 16:38:30 -0700211 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700212
213 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 {
215 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
216 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700217
Jeff Johnson295189b2012-06-20 16:38:30 -0700218 return( fConnected );
219}
220
221static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
222{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700223 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 {
225 case eCSR_BSS_TYPE_INFRASTRUCTURE:
226 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
227 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700228
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 case eCSR_BSS_TYPE_IBSS:
230 case eCSR_BSS_TYPE_START_IBSS:
231 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
232 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700233
234 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700236 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700237 default:
238 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700239 break;
240 }
241
Jeff Johnson295189b2012-06-20 16:38:30 -0700242}
243
244void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
245{
246 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
247 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700248
Jeff Johnson295189b2012-06-20 16:38:30 -0700249 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700250
251 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700252 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700253 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
255 {
256 VOS_ASSERT( pRoamInfo->pBssDesc );
257 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
258
259 // Save the Station ID for this station from the 'Roam Info'.
260 //For IBSS mode, staId is assigned in NEW_PEER_IND
261 //For reassoc, the staID doesn't change and it may be invalid in this structure
262 //so no change here.
263 if( !pRoamInfo->fReassocReq )
264 {
265 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
266 }
267 }
268 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700269 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700271 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 else
273 {
274 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
275 // or we can't function.
276 VOS_ASSERT( 0 );
277 }
278
279 // notify WMM
280 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
281
282 if( !pRoamInfo->u.pConnectedProfile )
283 {
284 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
285 }
286 else
287 {
288 // Get Multicast Encryption Type
289 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
290 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
291 // Get Unicast Encrytion Type
292 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
293 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
294
295 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
296
297 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
298
299 // Save the ssid for the connection
300 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkalad86a14e2013-04-18 16:41:54 +0530301
302 // Save dot11mode in which STA associated to AP
303 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700305 }
306
Jeff Johnson295189b2012-06-20 16:38:30 -0700307 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700308 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
309
Jeff Johnson295189b2012-06-20 16:38:30 -0700310}
311
312#if defined(WLAN_FEATURE_VOWIFI_11R)
313/*
314 * Send the 11R key information to the supplicant.
315 * Only then can the supplicant generate the PMK-R1.
316 * (BTW, the CCX supplicant also needs the Assoc Resp IEs
317 * for the same purpose.)
318 *
319 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
320 * this contains the R1KHID, R0KHID and the MDID.
321 * For FT, this consists of the Reassoc Rsp FTIEs.
322 * This is the Assoc Response.
323 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700324static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700325 tCsrRoamInfo *pCsrRoamInfo)
326{
327 union iwreq_data wrqu;
328 char *buff;
329 unsigned int len = 0;
330 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700331
332 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700333 {
334 hddLog(LOGE,
335 "%s: pCsrRoamInfo->nAssocRspLength=%d",
336 __func__, (int)pCsrRoamInfo->nAssocRspLength);
337 return;
338 }
339
Shailender Karmuchia734f332013-04-19 14:02:48 -0700340 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700341 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700342 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700344 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 return;
346 }
347
348 // pFTAssocRsp needs to point to the IEs
349 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
350 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
351 (unsigned int)pFTAssocRsp[0],
352 (unsigned int)pFTAssocRsp[1]);
353
354 // We need to send the IEs to the supplicant.
355 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700356 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700358 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 return;
360 }
361
362 // Send the Assoc Resp, the supplicant needs this for initial Auth.
363 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700364 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700366 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
368
369 kfree(buff);
370}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700371#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700372
373#ifdef WLAN_FEATURE_VOWIFI_11R
374
375/*---------------------------------------------------
376 *
377 * Send the FTIEs, RIC IEs during FT. This is eventually
378 * used to send the FT events to the supplicant
379 *
380 * At the reception of Auth2 we send the RIC followed
381 * by the auth response IEs to the supplicant.
382 * Once both are received in the supplicant, an FT
383 * event is generated to the supplicant.
384 *
385 *---------------------------------------------------
386 */
387void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
388{
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 tANI_U16 auth_resp_len = 0;
390 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
392
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530393#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700394 struct cfg80211_ft_event_params ftEvent;
395 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
396 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530397 v_U8_t target_ap[SIR_MAC_ADDR_LENGTH];
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700398 struct net_device *dev = pAdapter->dev;
399#else
400 char *buff;
401 union iwreq_data wrqu;
402 tANI_U16 str_len;
403#endif
404
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530405#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530406 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
407 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700408
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530409 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800410 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530411 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700412 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530413 hddLog(LOGW,
414 "%s: RIC IEs is of length 0 not sending RIC Information for now",
415 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700416 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700417
418 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530419 ftEvent.ric_ies_len = ric_ies_length;
420 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700421
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530422 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800423 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700424
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530425 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700426 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530427 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700428 return;
429 }
430
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530431 vos_mem_copy(target_ap, ftIe, SIR_MAC_ADDR_LENGTH);
432
433 ftEvent.target_ap = target_ap;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700434
435 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
436 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
437
438 hddLog(LOG1, "%s ftEvent.ies_len %d",__FUNCTION__, ftEvent.ies_len);
439 hddLog(LOG1, "%s ftEvent.ric_ies_len %d",__FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530440 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800441 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
442 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
443 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700444
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530445 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700446
447#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530448 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700449 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530450 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530452 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 return;
454 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530455 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700456
Shailender Karmuchia734f332013-04-19 14:02:48 -0700457 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700458 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530459 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800460 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530461 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530463 hddLog(LOGW,
464 "%s: RIC IEs is of length 0 not sending RIC Information for now",
465 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 }
467 else
468 {
469 wrqu.data.length = str_len + ric_ies_length;
470 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
471 }
472
473 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530474 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530476 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
477 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700478
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530479 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530481 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 return;
483 }
484
485 wrqu.data.length = str_len + auth_resp_len;
486 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
487
488 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700489#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700490}
491
492#endif /* WLAN_FEATURE_VOWIFI_11R */
493
494#ifdef FEATURE_WLAN_CCX
495
496/*
497 * Send the CCX required "new AP Channel info" to the supplicant.
498 * (This keeps the supplicant "up to date" on the current channel.)
499 *
500 * The current (new AP) channel information is passed in.
501 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700502static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 tCsrRoamInfo *pCsrRoamInfo)
504{
505 union iwreq_data wrqu;
506 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700507
Shailender Karmuchia734f332013-04-19 14:02:48 -0700508
509 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 {
511 hddLog(LOGE,
512 "%s: pCsrRoamInfo->pBssDesc=%p\n",
513 __func__, descriptor);
514 return;
515 }
516
517 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
518 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d\n", __func__, descriptor->channelId);
519 memset(&wrqu, '\0', sizeof(wrqu));
520 wrqu.freq.m = descriptor->channelId;
521 wrqu.freq.e = 0;
522 wrqu.freq.i = 0;
523 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
524}
525
526#endif /* FEATURE_WLAN_CCX */
527
528void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
529{
530 union iwreq_data wrqu;
531 u8 *pBeaconIes;
532 u8 currentLen = 0;
533 char *buff;
534 int totalIeLen = 0, currentOffset = 0, strLen;
535
536 memset(&wrqu, '\0', sizeof(wrqu));
537
538 if (0 == pCsrRoamInfo->nBeaconLength)
539 {
540 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
541 return;
542 }
543 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700544 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700546 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 return;
548 }
549
550 // pBeaconIes needs to point to the IEs
551 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
552 (unsigned int)pBeaconIes[0],
553 (unsigned int)pBeaconIes[1]);
554 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700555
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 // We need to send the IEs to the supplicant.
557 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700558 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700560 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 return;
562 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700563 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700564
565 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
566 currentLen = strLen + 1;
567
568 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
569 do
570 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700571 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 * max size and send it to supplicant. Changes are done in supplicant to handle this */
573 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
574 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
575 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
576 currentOffset += currentLen;
577 totalIeLen -= currentLen;
578 wrqu.data.length = strLen + 1 + currentLen;
579 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700580 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 else
582 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
583
584 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
585 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
586 } while (totalIeLen > 0);
587
588 kfree(buff);
589}
590
591static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
592{
593 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
594 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
595 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
596 union iwreq_data wrqu;
597 int we_event;
598 char *msg;
599 int type = -1;
600
Shailender Karmuchia734f332013-04-19 14:02:48 -0700601#if defined (WLAN_FEATURE_VOWIFI_11R)
602 // Added to find the auth type on the fly at run time
603 // rather than with cfg to see if FT is enabled
604 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
606#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700607
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700609 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700611
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
613 {
614 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
615 type = WLAN_STA_ASSOC_DONE_IND;
616
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700617#ifdef WLAN_FEATURE_P2P_DEBUG
618 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
619 {
620 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
621 {
622 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
623 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
624 "Connecting state to Connected State for 8-way "
625 "Handshake");
626 }
627 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
628 {
629 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
630 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
631 "Connecting state to P2P Client Connection Completed");
632 }
633 }
634#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 pr_info("wlan: connected to %02x:%02x:%02x:%02x:%02x:%02x\n",
636 wrqu.ap_addr.sa_data[0],
637 wrqu.ap_addr.sa_data[1],
638 wrqu.ap_addr.sa_data[2],
639 wrqu.ap_addr.sa_data[3],
640 wrqu.ap_addr.sa_data[4],
641 wrqu.ap_addr.sa_data[5]);
642 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
643
644 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
645 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
646 * and fFTEnable is TRUE */
647#ifdef WLAN_FEATURE_VOWIFI_11R
648 // Send FT Keys to the supplicant when FT is enabled
649 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700650 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Jeff Johnson295189b2012-06-20 16:38:30 -0700651#ifdef FEATURE_WLAN_CCX
652 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
653 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
654#endif
655 )
656 {
657 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
658 }
659#endif
660 }
661 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
662 {
Jeff Johnson4416a782013-03-25 14:17:50 -0700663 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700664 type = WLAN_STA_ASSOC_DONE_IND;
665 pr_info("wlan: new IBSS connection to %02x:%02x:%02x:%02x:%02x:%02x",
666 pHddStaCtx->conn_info.bssId[0],
667 pHddStaCtx->conn_info.bssId[1],
668 pHddStaCtx->conn_info.bssId[2],
669 pHddStaCtx->conn_info.bssId[3],
670 pHddStaCtx->conn_info.bssId[4],
671 pHddStaCtx->conn_info.bssId[5]);
672 }
673 else /* Not Associated */
674 {
675 pr_info("wlan: disconnected\n");
676 type = WLAN_STA_DISASSOC_DONE_IND;
677 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
678 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700679 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700680
681 msg = NULL;
682 /*During the WLAN uninitialization,supplicant is stopped before the
683 driver so not sending the status of the connection to supplicant*/
684 if(pHddCtx->isLoadUnloadInProgress != TRUE)
685 {
686 wireless_send_event(dev, we_event, &wrqu, msg);
687#ifdef FEATURE_WLAN_CCX
688 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700689 {
690 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
691 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
693 }
694#endif
695 }
696 send_btc_nlink_msg(type, 0);
697}
698
699void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
700{
701 // Remove staId, bssId and peerMacAddress
702 pHddStaCtx->conn_info.staId [ 0 ] = 0;
703 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
704 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
705
706 // Clear all security settings
707 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
708 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
709 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
710
711 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
712
713 // Set not-connected state
714 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700715 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Jeff Johnson295189b2012-06-20 16:38:30 -0700716
717 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
718}
719/* TODO Revist this function. and data path */
720static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
721{
722 VOS_STATUS vosStatus;
723 hdd_disconnect_tx_rx(pAdapter);
724 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
725 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
726 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530727 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700728 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
729 "Status= %d [0x%08lX]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700730 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 }
732 return( vosStatus );
733}
734
735
736static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
737 tANI_U32 roamId, eRoamCmdStatus roamStatus,
738 eCsrRoamResult roamResult )
739{
740 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700741 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 struct net_device *dev = pAdapter->dev;
743 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
744 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700745
746 // Sanity check
747 if(dev == NULL)
748 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700749 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700750 "%s: net_dev is released return", __func__);
751 return eHAL_STATUS_FAILURE;
752 }
753
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 // notify apps that we can't pass traffic anymore
755 netif_tx_disable(dev);
756 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700757
Jeff Johnsone7245742012-09-05 17:12:55 -0700758 INIT_COMPLETION(pAdapter->disconnect_comp_var);
759 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 /* If only STA mode is on */
761 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
762 {
763 pHddCtx->isAmpAllowed = VOS_TRUE;
764 }
765 hdd_clearRoamProfileIe( pAdapter );
766
767 // indicate 'disconnect' status to wpa_supplicant...
768 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 /* indicate disconnected event to nl80211 */
770 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
771 {
772 /*During the WLAN uninitialization,supplicant is stopped before the
773 driver so not sending the status of the connection to supplicant*/
774 if(pHddCtx->isLoadUnloadInProgress != TRUE)
775 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700776 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
777 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700779#ifdef WLAN_FEATURE_P2P_DEBUG
780 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
781 {
782 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
783 {
784 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
785 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
786 "and moved to disconnected state");
787 }
788 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
789 {
790 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
791 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
792 "and moved to inactive state");
793 }
794 }
795#endif
796
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
798 if( eCSR_ROAM_LOSTLINK == roamStatus )
799 {
Mohit Khanna99d5fd02012-09-11 14:51:20 -0700800 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 }
802 else
803 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700804 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 }
806
807 //If the Device Mode is Station
808 // and the P2P Client is Connected
809 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700810
811 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700812 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -0700813 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
814 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 (vos_concurrent_sessions_running()))
816 {
817 //Enable BMPS only of other Session is P2P Client
818 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700819 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700820
821 if (NULL != pVosContext)
822 {
823 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
824
825 if(NULL != pHddCtx)
826 {
827 //Only P2P Client is there Enable Bmps back
828 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700829 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 {
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -0800831 if (pHddCtx->hdd_wlan_suspended)
832 {
833 if(WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
834 {
835 hdd_reset_pwrparams(pHddCtx);
836 }
837 else
838 {
839 hdd_set_pwrparams(pHddCtx);
840 }
841 }
842
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 hdd_enable_bmps_imps(pHddCtx);
844 }
845 }
846 }
847 }
848 }
849 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700850
Jeff Johnson295189b2012-06-20 16:38:30 -0700851
852 //We should clear all sta register with TL, for now, only one.
Jeff Johnson43971f52012-07-17 12:26:56 -0700853 vstatus = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
854 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 "hdd_roamDeregisterSTA() failed to for staID %d. "
858 "Status= %d [0x%x]",
859 pHddStaCtx->conn_info.staId[0], status, status );
860
861 status = eHAL_STATUS_FAILURE;
862 }
863
864 pHddCtx->sta_to_adapter[pHddStaCtx->conn_info.staId[0]] = NULL;
865 // Clear saved connection information in HDD
866 hdd_connRemoveConnectInfo( pHddStaCtx );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530867#ifdef WLAN_FEATURE_GTK_OFFLOAD
868 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
869 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
870 {
871 pHddStaCtx->gtkOffloadRequestParams.requested = FALSE;
872 memset(&pHddStaCtx->gtkOffloadRequestParams.gtkOffloadReqParams,
873 0, sizeof (tSirGtkOffloadParams));
874 }
875#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700876
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800877#ifdef FEATURE_WLAN_TDLS
878 wlan_hdd_tdls_disconnection_callback(pAdapter);
879#endif
880
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 //Unblock anyone waiting for disconnect to complete
882 complete(&pAdapter->disconnect_comp_var);
883 return( status );
884}
885static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
886 tCsrRoamInfo *pRoamInfo,
887 v_U8_t staId,
888 v_MACADDR_t *pPeerMacAddress,
889 tSirBssDescription *pBssDesc )
890{
891 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
892 WLAN_STADescType staDesc = {0};
893 eCsrEncryptionType connectedCipherAlgo;
894 v_BOOL_t fConnected;
895 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
896 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700897
898 if ( NULL == pBssDesc)
899 {
900 return VOS_STATUS_E_FAILURE;
901 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 // Get the Station ID from the one saved during the assocation.
903 staDesc.ucSTAId = staId;
904
905 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700907 staDesc.wSTAType = WLAN_STA_INFRA;
908
909 // grab the bssid from the connection info in the adapter structure and hand that
910 // over to TL when registering.
911 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
912 }
913 else
914 {
915 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700917
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
919 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
920 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
921 // pass when making an Infrastructure connection.
922 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
923 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
924 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700925
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
927
928 // set the QoS field appropriately
929 if (hdd_wmm_is_active(pAdapter))
930 {
931 staDesc.ucQosEnabled = 1;
932 }
933 else
934 {
935 staDesc.ucQosEnabled = 0;
936 }
937
938 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
939 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
940 {
941 staDesc.ucProtectedFrame = 1;
942 }
943 else
944 {
945 staDesc.ucProtectedFrame = 0;
946
947 }
948
949#ifdef FEATURE_WLAN_CCX
950 staDesc.ucIsCcxSta = pRoamInfo->isCCXAssoc;
951#endif //FEATURE_WLAN_CCX
952
953#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
954 /* check whether replay check is valid for the station or not */
955 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
956 {
957 /* Encryption mode is either TKIP or AES
958 and replay check is valid for only these
959 two encryption modes */
960 staDesc.ucIsReplayCheckValid = VOS_TRUE;
961 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
962 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
963 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700964
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 else
966 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700967 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700969 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
971 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
972 }
973#endif
974
975#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700976 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 if (pAdapter->wapi_info.fIsWapiSta)
978 {
979 staDesc.ucIsWapiSta = 1;
980 }
981 else
982 {
983 staDesc.ucIsWapiSta = 0;
984 }
985#endif /* FEATURE_WLAN_WAPI */
986
987 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
988 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
989
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 // UMA is Not ready yet, Xlation will be done by TL
991 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 staDesc.ucSwFrameRXXlation = 1;
993 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700994 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 staDesc.ucQosEnabled );
996 // Initialize signatures and state
997 staDesc.ucUcastSig = pRoamInfo->ucastSig;
998 staDesc.ucBcastSig = pRoamInfo->bcastSig;
999 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1000 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001001 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001002 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "%s: HDD register TL ucInitState=%d", __func__, staDesc.ucInitState );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001003 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1004 hdd_rx_packet_cbk,
1005 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 hdd_tx_fetch_packet_cbk, &staDesc,
1007 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001008
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1010 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001011 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08lX]",
1013 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001014 return vosStatus;
1015 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001016
Shailender Karmuchia734f332013-04-19 14:02:48 -07001017 // if ( WPA ), tell TL to go to 'connected' and after keys come to the driver,
1018 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 // not require upper layer authentication) we can put TL directly into 'authenticated'
1020 // state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001021
1022 if (staDesc.wSTAType != WLAN_STA_IBSS)
1023 VOS_ASSERT( fConnected );
1024
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 if ( !pRoamInfo->fAuthRequired )
1026 {
1027 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1028 "open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time", pHddStaCtx->conn_info.staId[ 0 ] );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001029
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 // Connections that do not need Upper layer auth, transition TL directly
Shailender Karmuchia734f332013-04-19 14:02:48 -07001031 // to 'Authenticated' state.
1032 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 WLANTL_STA_AUTHENTICATED );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001034
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 else
1038 {
1039 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1040 "ULA auth StaId= %d. Changing TL state to CONNECTED at Join time", pHddStaCtx->conn_info.staId[ 0 ] );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001041
1042 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 WLANTL_STA_CONNECTED );
1044
1045 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 return( vosStatus );
1048}
1049
Jeff Johnson295189b2012-06-20 16:38:30 -07001050static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1051 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1052{
1053 unsigned int len = 0;
1054 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001055 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 tANI_U32 rspRsnLength = 0;
1057 struct ieee80211_channel *chan;
1058
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001059 if (!rspRsnIe)
1060 {
1061 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001062 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001063 }
1064
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 if (pCsrRoamInfo == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001066 {
1067 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1068 goto done;
1069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001070
1071 if (pCsrRoamInfo->nAssocRspLength == 0)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001072 {
1073 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1074 goto done;
1075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001076
1077 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1078 pCsrRoamInfo->nAssocReqLength);
1079 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001080 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001081
1082 //pFTAssocRsp needs to point to the IEs
1083 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1084 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x\n", __func__,
1085 (unsigned int)pFTAssocRsp[0],
1086 (unsigned int)pFTAssocRsp[1]);
1087
1088 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001089 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001092 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001093
1094 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1095 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1096 reqRsnIe, reqRsnLength,
1097 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001098
1099done:
1100 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001101}
Jeff Johnson295189b2012-06-20 16:38:30 -07001102
Shailender Karmuchia734f332013-04-19 14:02:48 -07001103static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1104 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 eCsrRoamResult roamResult )
1106{
1107 struct net_device *dev = pAdapter->dev;
1108 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1109 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1110 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001111 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1112 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001113#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 int ft_carrier_on = FALSE;
1115#endif
1116 int status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001117
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1119 {
1120 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1121
1122 // Save the connection info from CSR...
1123 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1124#ifdef FEATURE_WLAN_WAPI
1125 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1126 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1127 {
1128 pAdapter->wapi_info.fIsWapiSta = 1;
1129 }
1130 else
1131 {
1132 pAdapter->wapi_info.fIsWapiSta = 0;
1133 }
1134#endif /* FEATURE_WLAN_WAPI */
1135
1136 // indicate 'connect' status to userspace
1137 hdd_SendAssociationEvent(dev,pRoamInfo);
1138
1139
Shailender Karmuchia734f332013-04-19 14:02:48 -07001140 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001141 INIT_COMPLETION(pAdapter->linkup_event_var);
1142
1143 /*
1144 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1145 packet to go up to the application, device activation has to be ensured for proper queue mapping by the
Shailender Karmuchia734f332013-04-19 14:02:48 -07001146 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 know that the device is getting activated properly.
1148 */
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001149#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001150 if (pHddStaCtx->ft_carrier_on == FALSE)
1151 {
1152#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001153 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001154 pAdapter->isLinkUpSvcNeeded = TRUE;
1155
Shailender Karmuchia734f332013-04-19 14:02:48 -07001156 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 pAdapter->isLinkUpSvcNeeded = TRUE;
1158
1159 // Switch on the Carrier to activate the device
1160 netif_carrier_on(dev);
1161
1162 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1163 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1164 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001165 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 {
1167 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1168 }
1169
1170 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1171 pAdapter->isLinkUpSvcNeeded = FALSE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001172#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001174 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 }
1178#endif
1179 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1180
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001181#ifdef FEATURE_WLAN_TDLS
1182 wlan_hdd_tdls_connection_callback(pAdapter);
1183#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 //For reassoc, the station is already registered, all we need is to change the state
1185 //of the STA in TL.
1186 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1187 if( !pRoamInfo->fReassocReq )
1188 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001189 struct cfg80211_bss *bss;
1190#ifdef WLAN_FEATURE_VOWIFI_11R
1191 u8 *pFTAssocRsp = NULL;
1192 unsigned int assocRsplen = 0;
1193 u8 *pFTAssocReq = NULL;
1194 unsigned int assocReqlen = 0;
1195 struct ieee80211_channel *chan;
1196#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001199
1200 /* add bss_id to cfg80211 data base */
1201 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1202 if (NULL == bss)
1203 {
1204 pr_err("wlan: Not able to create BSS entry\n");
1205 return eHAL_STATUS_FAILURE;
1206 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001207#ifdef WLAN_FEATURE_VOWIFI_11R
1208 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001209 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001210 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001211
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001212 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001213 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001214 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001215 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001216 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001217 // pFTAssocRsp needs to point to the IEs
1218 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1219 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1220 (unsigned int)pFTAssocRsp[0],
1221 (unsigned int)pFTAssocRsp[1]);
1222 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001223 }
1224 else
1225 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001226 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1227 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001228 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001229
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001230 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001231 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001232 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001233 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001234 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001235 if(!ft_carrier_on)
1236 {
1237 // pFTAssocReq needs to point to the IEs
1238 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1239 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1240 (unsigned int)pFTAssocReq[0],
1241 (unsigned int)pFTAssocReq[1]);
1242 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1243 }
1244 else
1245 {
1246 /* This should contain only the FTIEs */
1247 assocReqlen = pRoamInfo->nAssocReqLength;
1248 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001249 }
1250 else
1251 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001252 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1253 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001254 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001255
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001256 if(ft_carrier_on)
1257 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001258 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
1259 "indication\n", __FUNCTION__, ft_carrier_on);
1260 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1261 (int)pRoamInfo->pBssDesc->channelId);
1262 hddLog(LOG1, "assocReqlen %d assocRsplen %d\n", assocReqlen,
1263 assocRsplen);
1264 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
1265 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1266 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001267 }
1268 else
1269 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001270 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
1271 "indication\n", __FUNCTION__, ft_carrier_on);
1272 cfg80211_connect_result(dev, pRoamInfo->bssid,
1273 pFTAssocReq, assocReqlen,
1274 pFTAssocRsp, assocRsplen,
1275 WLAN_STATUS_SUCCESS,
1276 GFP_KERNEL);
1277 cfg80211_put_bss(bss);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001278 }
1279 }
1280 else
1281#endif
1282 {
1283 /* wpa supplicant expecting WPA/RSN IE in connect result */
1284 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1285 pAdapter->sessionId,
1286 &reqRsnLength,
1287 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001288
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001289 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1290 pAdapter->sessionId,
1291 &rspRsnLength,
1292 rspRsnIe);
1293#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1294 if(ft_carrier_on)
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001295 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001296 else
1297#endif /* FEATURE_WLAN_CCX */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001298
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001299 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001300 /* inform connect result to nl80211 */
1301 cfg80211_connect_result(dev, pRoamInfo->bssid,
1302 reqRsnIe, reqRsnLength,
1303 rspRsnIe, rspRsnLength,
1304 WLAN_STATUS_SUCCESS,
1305 GFP_KERNEL);
1306
1307 cfg80211_put_bss(bss);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 // Register the Station with TL after associated...
1311 vosStatus = hdd_roamRegisterSTA( pAdapter,
1312 pRoamInfo,
1313 pHddStaCtx->conn_info.staId[ 0 ],
1314 NULL,
1315 pRoamInfo->pBssDesc );
1316 }
1317 else
1318 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001319 /* wpa supplicant expecting WPA/RSN IE in connect result */
1320 /* in case of reassociation also need to indicate it to supplicant */
1321 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1322 pAdapter->sessionId,
1323 &reqRsnLength,
1324 reqRsnIe);
1325
1326 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 //Reassoc successfully
1328 if( pRoamInfo->fAuthRequired )
1329 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001330 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 WLANTL_STA_CONNECTED );
1332 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1333 }
1334 else
1335 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001336 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1337 "%s: staId: %d Changing TL state to AUTHENTICATED",
1338 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001339 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 WLANTL_STA_AUTHENTICATED );
1341 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1342 }
1343 }
1344
1345 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1346 {
1347 // perform any WMM-related association processing
1348 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1349 }
1350 else
1351 {
1352 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1353 "Cannot register STA with TL. Failed with vosStatus = %d [%08lX]",
1354 vosStatus, vosStatus );
1355 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001356#ifdef WLAN_FEATURE_11W
1357 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1358 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1359#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 // Start the Queue
1361 netif_tx_wake_all_queues(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001362 }
1363 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001364 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001365 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1366
1367 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001368 if (pRoamInfo)
1369 pr_info("wlan: connection failed with %02x:%02x:%02x:%02x:%02x:%02x"
1370 " reason:%d and Status:%d\n", pRoamInfo->bssid[0],
1371 pRoamInfo->bssid[1], pRoamInfo->bssid[2],
1372 pRoamInfo->bssid[3], pRoamInfo->bssid[4],
1373 pRoamInfo->bssid[5], roamResult, roamStatus);
1374 else
1375 pr_info("wlan: connection failed with %02x:%02x:%02x:%02x:%02x:%02x"
Jeff Johnson32d95a32012-09-10 13:15:23 -07001376 " reason:%d and Status:%d\n", pWextState->req_bssId[0],
1377 pWextState->req_bssId[1], pWextState->req_bssId[2],
1378 pWextState->req_bssId[3], pWextState->req_bssId[4],
1379 pWextState->req_bssId[5], roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001380
1381 /*Handle all failure conditions*/
1382 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1383 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
1384 {
1385 pHddCtx->isAmpAllowed = VOS_TRUE;
1386 }
1387
1388 //If the Device Mode is Station
1389 // and the P2P Client is Connected
1390 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001391
1392 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001393 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001394 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1395 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 (vos_concurrent_sessions_running()))
1397 {
1398 //Enable BMPS only of other Session is P2P Client
1399 hdd_context_t *pHddCtx = NULL;
1400 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1401
1402 if (NULL != pVosContext)
1403 {
1404 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1405
1406 if(NULL != pHddCtx)
1407 {
1408 //Only P2P Client is there Enable Bmps back
1409 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001410 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 {
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001412 if (pHddCtx->hdd_wlan_suspended)
1413 {
1414 if(WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
1415 {
1416 hdd_reset_pwrparams(pHddCtx);
1417 }
1418 else
1419 {
1420 hdd_set_pwrparams(pHddCtx);
1421 }
1422 }
1423
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 hdd_enable_bmps_imps(pHddCtx);
1425 }
1426 }
1427 }
1428 }
1429
James Zmudafbf5ffc2013-03-25 12:45:35 -07001430 /* CR465478: Only send up a connection failure result when CSR has
1431 * completed operation - with a ASSOCIATION_FAILURE status. */
1432 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus )
Jeff Johnsone7245742012-09-05 17:12:55 -07001433 {
James Zmudafbf5ffc2013-03-25 12:45:35 -07001434 /* inform association failure event to nl80211 */
1435 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1436 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001437 if (pRoamInfo)
1438 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1439 NULL, 0, NULL, 0,
1440 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1441 GFP_KERNEL );
1442 else
1443 cfg80211_connect_result ( dev, pWextState->req_bssId,
1444 NULL, 0, NULL, 0,
1445 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1446 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001447 }
1448 else
1449 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001450 if (pRoamInfo)
1451 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1452 NULL, 0, NULL, 0,
1453 WLAN_STATUS_UNSPECIFIED_FAILURE,
1454 GFP_KERNEL );
1455 else
1456 cfg80211_connect_result ( dev, pWextState->req_bssId,
1457 NULL, 0, NULL, 0,
1458 WLAN_STATUS_UNSPECIFIED_FAILURE,
1459 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001460 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001462
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001463 /*Clear the roam profile*/
1464 hdd_clearRoamProfileIe( pAdapter );
1465
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 netif_tx_disable(dev);
1467 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001468
Jeff Johnsone7245742012-09-05 17:12:55 -07001469 if (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode)
1470 {
1471 /* Association failed; Reset the country code information
1472 * so that it re-initialize the valid channel list*/
1473 hdd_ResetCountryCodeAfterDisAssoc(pAdapter);
1474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 }
1476
1477 return eHAL_STATUS_SUCCESS;
1478}
1479
1480/**============================================================================
1481 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001482 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001483 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001484
Jeff Johnson295189b2012-06-20 16:38:30 -07001485 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001486static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1487 tCsrRoamInfo *pRoamInfo,
1488 tANI_U32 roamId,
1489 eRoamCmdStatus roamStatus,
1490 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001491{
Jeff Johnson81c17882013-05-03 09:53:35 -07001492 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1493 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1494
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 switch( roamResult )
1496 {
1497 // both IBSS Started and IBSS Join should come in here.
1498 case eCSR_ROAM_RESULT_IBSS_STARTED:
1499 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
1500 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001501 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1502 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001503
Jeff Johnson81c17882013-05-03 09:53:35 -07001504 if (NULL == pRoamInfo)
1505 {
1506 VOS_ASSERT(0);
1507 return;
1508 }
1509
1510 /* When IBSS Started comes from CSR, we need to move
1511 * connection state to IBSS Disconnected (meaning no peers
1512 * are in the IBSS).
1513 */
1514 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1515 eConnectionState_IbssDisconnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001516 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1517 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1518 IBSS_BROADCAST_STAID,
1519 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001520
Jeff Johnson81c17882013-05-03 09:53:35 -07001521 if (pRoamInfo->pBssDesc)
1522 {
1523 struct cfg80211_bss *bss;
1524
1525 /* we created the IBSS, notify supplicant */
1526 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1527 MAC_ADDRESS_STR,
1528 __func__, pAdapter->dev->name,
1529 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1530
1531 /* we must first give cfg80211 the BSS information */
1532 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1533 if (NULL == bss)
1534 {
1535 hddLog(VOS_TRACE_LEVEL_ERROR,
1536 "%s: %s: unable to create IBSS entry",
1537 __func__, pAdapter->dev->name);
1538 return;
1539 }
1540
1541 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
1542 cfg80211_put_bss(bss);
1543 }
1544
Shailender Karmuchia734f332013-04-19 14:02:48 -07001545 netif_carrier_on(pAdapter->dev);
1546 netif_tx_start_all_queues(pAdapter->dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 break;
1548 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001549
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1551 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001552 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1553 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 break;
1555 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001556
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001558 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1559 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001560 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001561 }
1562
Jeff Johnson81c17882013-05-03 09:53:35 -07001563 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001564}
1565
1566/**============================================================================
1567 *
1568 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1569 This information is passed to iwconfig later. The peer that joined
1570 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001571 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001573
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 ===========================================================================*/
1575static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1576{
1577 int fSuccess = FALSE;
1578 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001579
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1581 {
1582 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1583 {
1584 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001585
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001587
Jeff Johnson295189b2012-06-20 16:38:30 -07001588 fSuccess = TRUE;
1589 break;
1590 }
1591 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001592
1593 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001594}
1595/**============================================================================
1596 *
1597 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001598 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001600
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 ===========================================================================*/
1602static int roamRemoveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId )
1603{
1604 int fSuccess = FALSE;
1605 int idx = 0;
1606 v_U8_t valid_idx = 0;
1607 v_U8_t del_idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001608
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1610 {
1611 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1612 {
1613 pHddStaCtx->conn_info.staId[ idx ] = 0;
1614
1615 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1616
1617 fSuccess = TRUE;
1618 // Note the deleted Index, if its 0 we need special handling
1619 del_idx = idx;
1620 }
1621 else
1622 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001623 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 {
1625 valid_idx = idx;
1626 }
1627 }
1628 }
1629
1630 // Find next active staId, to have a valid sta trigger for TL.
1631 if (fSuccess == TRUE)
1632 {
1633 if (del_idx == 0)
1634 {
1635 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1636 {
1637 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1638 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1639 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1640
1641 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1642 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1643 }
1644 }
1645 }
1646 return( fSuccess );
1647}
1648
1649/**============================================================================
1650 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001651 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001653
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 ===========================================================================*/
1655static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1656{
1657 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "IBSS Connect Indication from SME!!!" );
1658 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1659 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1660
1661 // Save the connection info from CSR...
1662 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1663
1664 // Send the bssid address to the wext.
1665 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 /* add bss_id to cfg80211 data base */
1667 wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1668 /* send ibss join indication to nl80211 */
1669 cfg80211_ibss_joined(pAdapter->dev, &pRoamInfo->bssid[0], GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001670
1671 return( eHAL_STATUS_SUCCESS );
1672}
1673/**============================================================================
1674 *
1675 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001676
Jeff Johnson295189b2012-06-20 16:38:30 -07001677 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001678static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1679 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 eCsrRoamResult roamResult )
1681{
1682 eCsrEncryptionType connectedCipherAlgo;
1683 v_BOOL_t fConnected = FALSE;
1684 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1685 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1686 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1687 ENTER();
1688 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001689 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07001690 // not require upper layer authentication) we can put TL directly into 'authenticated'
1691 // state.
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001692
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1694 if( fConnected )
1695 {
1696 // TODO: Considering getting a state machine in HDD later.
1697 // This routuine is invoked twice. 1)set PTK 2)set GTK. The folloing if statement will be
1698 // TRUE when setting GTK. At this time we don't handle the state in detail.
1699 // Related CR: 174048 - TL not in authenticated state
1700 if(( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) && (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired)
1701 {
1702 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1703 "Key set for StaId= %d. Changing TL state to AUTHENTICATED", pHddStaCtx->conn_info.staId[ 0 ] );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001704
1705 // Connections that do not need Upper layer authentication, transition TL
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 // to 'Authenticated' state after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001707 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 WLANTL_STA_AUTHENTICATED );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001709
Jeff Johnson295189b2012-06-20 16:38:30 -07001710 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1711 }
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301712 else
1713 {
1714 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1715 pHddStaCtx->conn_info.staId[ 0 ]);
1716 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001717
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1719 }
1720 else
1721 {
1722 // possible disassoc after issuing set key and waiting set key complete
1723 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1724 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001725
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 EXIT();
1727 return( eHAL_STATUS_SUCCESS );
1728}
1729/**============================================================================
1730 *
1731 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
1732 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001733static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07001735{
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1737
1738 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
1739 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
1740 {
1741 struct iw_michaelmicfailure msg;
1742 union iwreq_data wreq;
1743 memset(&msg, '\0', sizeof(msg));
1744 msg.src_addr.sa_family = ARPHRD_ETHER;
1745 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
1746 hddLog(LOG1, "MIC MAC %02x:%02x:%02x:%02x:%02x:%02x",
1747 msg.src_addr.sa_data[0],
1748 msg.src_addr.sa_data[1],
1749 msg.src_addr.sa_data[2],
1750 msg.src_addr.sa_data[3],
1751 msg.src_addr.sa_data[4],
1752 msg.src_addr.sa_data[5]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001753
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
1755 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001756 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 msg.flags = IW_MICFAILURE_PAIRWISE;
1758 memset(&wreq, 0, sizeof(wreq));
1759 wreq.data.length = sizeof(msg);
1760 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001762 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 pRoamInfo->u.pMICFailureInfo->taMacAddr,
1764 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
1765 NL80211_KEYTYPE_GROUP :
1766 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07001767 pRoamInfo->u.pMICFailureInfo->keyId,
1768 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001770
Jeff Johnson295189b2012-06-20 16:38:30 -07001771 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001772
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 return( eHAL_STATUS_SUCCESS );
1774}
1775
1776/**============================================================================
1777 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001778 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001780
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001782static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1783 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 eCsrRoamResult roamResult )
1785{
1786 VOS_STATUS vosStatus;
1787
1788 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1789 switch( roamResult )
1790 {
1791 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
1792 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001793 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1794
1795 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07001797 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
1798 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
1799 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001801
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
1803 {
1804 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1805 "New IBSS peer but we already have the max we can handle. Can't register this one" );
1806 break;
1807 }
1808
1809 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1810
Shailender Karmuchia734f332013-04-19 14:02:48 -07001811 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1812 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
1813 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
1814
1815 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 vosStatus = hdd_roamRegisterSTA( pAdapter,
1817 pRoamInfo,
1818 pRoamInfo->staId,
1819 (v_MACADDR_t *)pRoamInfo->peerMac,
1820 pRoamInfo->pBssDesc );
1821 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1822 {
1823 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1824 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08lX]",
1825 vosStatus, vosStatus );
1826 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001827
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 netif_carrier_on(pAdapter->dev);
1829 netif_tx_start_all_queues(pAdapter->dev);
1830 break;
1831 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001832
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 case eCSR_ROAM_RESULT_IBSS_CONNECT:
1834 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001835
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001837
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
1841 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001842 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001843
Shailender Karmuchia734f332013-04-19 14:02:48 -07001844 if ( !roamRemoveIbssStation( pHddStaCtx, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 {
1846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1847 "IBSS peer departed by cannot find peer in our registration table with TL" );
1848 }
1849
Shailender Karmuchia734f332013-04-19 14:02:48 -07001850 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1851 "IBSS Peer Departed from SME "
1852 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
1853 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
1854 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
1855 pRoamInfo->staId );
1856
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
1858
1859 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
1860
1861 break;
1862 }
1863 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
1864 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001865 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1866 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 // Stop only when we are inactive
1868 netif_tx_disable(pAdapter->dev);
1869 netif_carrier_off(pAdapter->dev);
1870 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001871
Jeff Johnson295189b2012-06-20 16:38:30 -07001872 // Send the bssid address to the wext.
1873 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
1874 // clean up data path
1875 hdd_disconnect_tx_rx(pAdapter);
1876 break;
1877 }
1878 default:
1879 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001880
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001882
Jeff Johnson295189b2012-06-20 16:38:30 -07001883 return( eHAL_STATUS_SUCCESS );
1884}
1885
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001886#ifdef FEATURE_WLAN_TDLS
1887/**============================================================================
1888 *
1889 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
1890 TL the new STA. This is called as part of ADD_STA in the TDLS setup
1891 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07001892
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001893 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001894VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
1895 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001896{
1897 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001898 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001899 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1900 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001901 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
1902 v_BOOL_t fConnected = FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001903
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001904 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1905 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001906 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001907 "%s not connected. ignored", __func__);
1908 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001909 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001910
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001911 /*
1912 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
1913 * be peer MAC, here we are wokrking on direct Link
1914 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001915 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001916
1917 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001918
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001919 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001920 sizeof(tSirMacAddr) );
1921
1922 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
1923 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1924
1925 /* set the QoS field appropriately ..*/
1926 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
1927 : (staDesc.ucQosEnabled = 0) ;
1928
1929 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
1930 TL QoS_enabled=%d\n", staDesc.ucQosEnabled );
1931
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001932 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001933
1934 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1935 "HDD register TL Sec_enabled= %d.\n", staDesc.ucProtectedFrame );
1936
Shailender Karmuchia734f332013-04-19 14:02:48 -07001937 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001938 * UMA is ready we inform TL to do frame translation.
1939 */
1940 staDesc.ucSwFrameTXXlation = 1;
1941 staDesc.ucSwFrameRXXlation = 1;
1942 staDesc.ucAddRmvLLC = 1;
1943
1944 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001945 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001946
1947 /* tdls Direct Link do not need bcastSig */
1948 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001949
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001950#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1951 if(staDesc.ucProtectedFrame)
1952 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1953 else
1954 staDesc.ucIsReplayCheckValid = VOS_FALSE;
1955#endif
1956
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001957 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001958
Shailender Karmuchia734f332013-04-19 14:02:48 -07001959 /* Register the Station with TL... */
1960 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
1961 hdd_rx_packet_cbk,
1962 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001963 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001964
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001965 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1966 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001967 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07001968 "%s: WLANTL_RegisterSTAClient() failed to register. \
1969 Status= %d [0x%08lX]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001970 return vosStatus;
1971 }
1972
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001973 return( vosStatus );
1974}
1975
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08001976static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1977{
1978 VOS_STATUS vosStatus;
1979 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1980 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1981 {
1982 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1983 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
1984 "Status= %d [0x%08lX]",
1985 __func__, staId, vosStatus, vosStatus );
1986 }
1987 return( vosStatus );
1988}
1989
1990
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001991/*
1992 * HDD interface between SME and TL to ensure TDLS client registration with
1993 * TL in case of new TDLS client is added and deregistration at the time
1994 * TDLS client is deleted.
1995 */
1996
Shailender Karmuchia734f332013-04-19 14:02:48 -07001997eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
1998 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001999 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002000 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002001 eCsrRoamResult roamResult)
2002{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002003 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002004 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002005 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002006
2007#ifdef WLAN_FEATURE_TDLS_DEBUG
2008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Leee6bfe942013-02-05 15:01:19 -08002009 ("hdd_tdlsStatusUpdate: %s staIdx %d %02x:%02x:%02x:%02x:%02x:%02x \n"),
2010 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" :
2011 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
2012 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND" :
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002013 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND? "DEL_ALL_TDLS_PEER_IND" :
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002014 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER? "UPDATE_TDLS_PEER" :
Hoonki Leee6bfe942013-02-05 15:01:19 -08002015 "UNKNOWN",
2016 pRoamInfo->staId,
2017 pRoamInfo->peerMac[0],
2018 pRoamInfo->peerMac[1],
2019 pRoamInfo->peerMac[2],
2020 pRoamInfo->peerMac[3],
2021 pRoamInfo->peerMac[4],
2022 pRoamInfo->peerMac[5]) ;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002023#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002024 switch( roamResult )
2025 {
2026 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2027 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002028 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2029 {
2030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002031 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002032 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002033 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002034 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002035
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002036 /* check if there is available index for this new TDLS STA */
2037 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2038 {
2039 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2040 {
2041 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2042 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2043
2044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002045 ("TDLS: STA IDX at %d is %d "
2046 "of mac %02x:%02x:%02x:%02x:%02x:%02x"),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002047 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
2048 pRoamInfo->peerMac[0],
2049 pRoamInfo->peerMac[1],
2050 pRoamInfo->peerMac[2],
2051 pRoamInfo->peerMac[3],
2052 pRoamInfo->peerMac[4],
2053 pRoamInfo->peerMac[5]) ;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002054
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002055 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002056 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2057 status = eHAL_STATUS_SUCCESS ;
2058 break ;
2059 }
2060 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002061 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002062 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002063 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002064 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2065 "wlan_hdd_tdls_set_sta_id() failed");
2066 return VOS_FALSE;
2067 }
2068
2069 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2070 /* store the ucast signature which will be used later when
2071 registering to TL
2072 */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002073 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002074 }
2075 else
2076 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002077 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002079 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002080 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002081 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002082 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002083 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002084 break ;
2085 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002086 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2087 {
2088 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2089 {
2090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2091 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2092 }
2093 /* store the ucast signature which will be used later when
2094 * registering to TL
2095 */
2096 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2097 complete(&pAdapter->tdls_add_station_comp);
2098 break;
2099 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002100 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002101 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002102 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002103 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002104 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002105 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2106 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002107 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002109 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2110
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002111 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac);
2112 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2113 {
2114 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2115 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2116 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002117 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002118 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = NULL;
2119
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002120 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2121 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2122 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002123 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002124 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002125 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002126 break ;
2127 }
2128 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002129 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002130 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002131 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002132 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2133 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002134 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002135 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2136 "%s: Sending teardown to supplicant with reason code %u",
2137 __func__, pRoamInfo->reasonCode);
2138
2139#ifdef CONFIG_TDLS_IMPLICIT
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002140 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac);
2141 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002142#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002143 status = eHAL_STATUS_SUCCESS ;
2144 break ;
2145 }
2146 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2147 {
2148 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002149 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002150 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002151 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2152 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002153 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002155 ("hdd_tdlsStatusUpdate: staIdx %d %02x:%02x:%02x:%02x:%02x:%02x"),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002156 pHddCtx->tdlsConnInfo[staIdx].staId,
2157 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[0],
2158 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[1],
2159 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[2],
2160 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[3],
2161 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[4],
2162 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[5]) ;
2163 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2164 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2165 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002166
2167 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[staIdx] = NULL;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002168 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002169 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002170 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2171 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002172
2173 status = eHAL_STATUS_SUCCESS ;
2174 }
2175 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302176 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002177 break ;
2178 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002179 default:
2180 {
2181 break ;
2182 }
2183 }
2184
2185 return status ;
2186}
2187#endif
2188
Shailender Karmuchia734f332013-04-19 14:02:48 -07002189eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2191{
2192 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2193 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302194 hdd_wext_state_t *pWextState = NULL;
2195 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002196 VOS_STATUS status = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002197
2198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002199 "CSR Callback: status= %d result= %d roamID=%ld",
2200 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002201
2202 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302203 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002204 {
2205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302206 "invalid adapter or adapter has invalid magic");
2207 return eHAL_STATUS_FAILURE;
2208 }
2209
2210 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2211 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2212
2213 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2214 {
2215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2216 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002217 return eHAL_STATUS_FAILURE;
2218 }
2219
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 switch( roamStatus )
2221 {
2222 case eCSR_ROAM_SESSION_OPENED:
2223 if(pAdapter != NULL)
2224 {
2225 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2226 complete(&pAdapter->session_open_comp_var);
2227 }
2228 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002229
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002230#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002231 /* We did pre-auth,then we attempted a 11r or ccx reassoc.
2232 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002233 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 * interface down */
2235 case eCSR_ROAM_FT_REASSOC_FAILED:
2236 hddLog(LOG1, FL("Reassoc Failed\n"));
2237 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2238 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2239 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2241 }
2242 pHddStaCtx->ft_carrier_on = FALSE;
2243 break;
2244
2245 case eCSR_ROAM_FT_START:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002246 // When we roam for CCX and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002248 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 // eCSR_ROAM_SHOULD_ROAM will be received.
2250 // Where in we will not mark the link down
2251 // Also we want to stop tx at this point when we will be
2252 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002253 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 {
2255 struct net_device *dev = pAdapter->dev;
2256 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002257 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002258 * Deregister for this STA with TL with the objective to flush
2259 * all the packets for this STA from wmm_tx_queue. If not done here,
2260 * we would run into a race condition (CR390567) wherein TX
2261 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2262 * been deleted. And, these packets get assigned with a STA idx of
2263 * self-sta (since the peer STA has been deleted) and get transmitted
2264 * on the new channel before the reassoc request. Since there will be
2265 * no ACK on the new channel, each packet gets retransmitted which
2266 * takes several seconds before the transmission of reassoc request.
2267 * This leads to reassoc-timeout and roam failure.
2268 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002269 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2270 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2271 {
2272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2273 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2274 pHddStaCtx->conn_info.staId[0], status, status );
2275 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002276 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 }
2278 pHddStaCtx->ft_carrier_on = TRUE;
2279 break;
2280#endif
2281
2282 case eCSR_ROAM_SHOULD_ROAM:
2283 // Dont need to do anything
2284 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 struct net_device *dev = pAdapter->dev;
2286 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2287 // notify apps that we can't pass traffic anymore
2288 netif_tx_disable(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002289#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 if (pHddStaCtx->ft_carrier_on == FALSE)
2291 {
2292#endif
2293 netif_carrier_off(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002294#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 }
2296#endif
2297
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002298#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 //We should clear all sta register with TL, for now, only one.
2300 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2301 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2302 {
2303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2304 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2305 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002306 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002308#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 // Clear saved connection information in HDD
2310 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
2311 }
2312 break;
2313 case eCSR_ROAM_LOSTLINK:
2314 case eCSR_ROAM_DISASSOCIATED:
2315 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2318 "****eCSR_ROAM_DISASSOCIATED****");
2319 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2320 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2321 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
2322 hdd_conf_mcastbcast_filter((WLAN_HDD_GET_CTX(pAdapter)), FALSE);
2323 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2324 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002325#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 if (pHddCtx->cfg_ini->isMcAddrListFilter)
2327 {
2328 /*Multicast addr filtering is enabled*/
Gopichand Nakkala0f276812013-02-24 14:45:51 +05302329 if (pAdapter->mc_addr_list.isFilterApplied)
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 {
2331 /*Filter applied during suspend mode*/
2332 /*Clear it here*/
Gopichand Nakkala0f276812013-02-24 14:45:51 +05302333 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 }
2335 }
2336#endif
2337
Jeff Johnsone7245742012-09-05 17:12:55 -07002338 if (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode)
2339 {
2340 /* Disconnected from current AP. Reset the country code information
2341 * so that it re-initialize the valid channel list*/
2342 hdd_ResetCountryCodeAfterDisAssoc(pAdapter);
2343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 }
2345 break;
2346 case eCSR_ROAM_IBSS_LEAVE:
2347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2348 "****eCSR_ROAM_IBSS_LEAVE****");
2349 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2350 break;
2351 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2353 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
2354 if ( (roamResult != eCSR_ROAM_RESULT_ASSOCIATED)
Shailender Karmuchia734f332013-04-19 14:02:48 -07002355 && ( (pWextState->roamProfile.EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY)
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 || (pWextState->roamProfile.EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)
2357 )
2358 && (eCSR_AUTH_TYPE_SHARED_KEY != pWextState->roamProfile.AuthType.authType[0])
2359 )
2360 {
2361 v_U32_t roamId = 0;
2362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2363 "****WEP open authentication failed, trying with shared authentication****");
2364 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
2365 pWextState->roamProfile.AuthType.authType[0] = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2366 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2367 halStatus = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &(pWextState->roamProfile), &roamId);
2368 }
2369 else
2370 {
2371 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2372 }
2373
2374 break;
2375 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002376 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 pRoamInfo, roamId, roamStatus, roamResult );
2378 break;
2379 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002380 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2381 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 break;
2383
2384 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2385 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002386 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002387
2388 case eCSR_ROAM_MIC_ERROR_IND:
2389 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2390 break;
2391
2392 case eCSR_ROAM_SET_KEY_COMPLETE:
2393 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2394 break;
2395#ifdef WLAN_FEATURE_VOWIFI_11R
2396 case eCSR_ROAM_FT_RESPONSE:
2397 hdd_SendFTEvent(pAdapter);
2398 break;
2399#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002400#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002401 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002402 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002403 {
2404 /* Notify the supplicant of a new candidate */
2405 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2406 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002407 break;
2408#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002409
Jeff Johnson295189b2012-06-20 16:38:30 -07002410 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2411 hdd_indicateMgmtFrame( pAdapter,
2412 pRoamInfo->nFrameLength,
2413 pRoamInfo->pbFrames,
2414 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302415 pRoamInfo->rxChan,
2416 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 break;
2418 case eCSR_ROAM_REMAIN_CHAN_READY:
2419 hdd_remainChanReadyHandler( pAdapter );
2420 break;
2421 case eCSR_ROAM_SEND_ACTION_CNF:
2422 hdd_sendActionCnf( pAdapter,
2423 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2424 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002425#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002426 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002427 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002428 roamId, roamStatus, roamResult );
2429 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002430 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2431 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2432 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002433#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002434#ifdef WLAN_FEATURE_11W
2435 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2436 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2437 pRoamInfo->pbFrames,
2438 pRoamInfo->frameType);
2439 break;
2440#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 default:
2442 break;
2443 }
2444 return( halStatus );
2445}
Shailender Karmuchia734f332013-04-19 14:02:48 -07002446eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002447{
2448 eCsrAuthType auth_type;
2449 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002450 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 {
2452 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002453 } else
2454 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 {
2456 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002457 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002458#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07002459 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 {
2461 // Check for 11r FT Authentication with PSK
2462 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002463 } else
2464 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 {
2466 // Check for 11R FT Authentication with 802.1X
2467 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002468 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002469#endif
2470#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002471 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 {
2473 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2474 } else
2475#endif /* FEATURE_WLAN_CCX */
Chet Lanctot186b5732013-03-18 10:26:30 -07002476#ifdef WLAN_FEATURE_11W
2477 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
2478 {
2479 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
2480 } else
2481#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002482 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2484 }
2485 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002486}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002487
Shailender Karmuchia734f332013-04-19 14:02:48 -07002488eCsrAuthType
2489hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002490{
2491 eCsrAuthType auth_type;
2492 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002493 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 {
2495 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002496 } else
2497 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 {
2499 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002500 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002501#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002502 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 {
2504 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002505 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002506#endif /* FEATURE_WLAN_CCX */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002507 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2509 }
2510 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2511 return auth_type;
2512}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002513
Shailender Karmuchia734f332013-04-19 14:02:48 -07002514eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002515hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002516{
2517 eCsrEncryptionType cipher_type;
2518 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002519 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 {
2521 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002522 }
2523 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 {
2525 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002526 }
2527 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 {
2529 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002530 }
2531 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 {
2533 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002534 }
2535 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2536 {
2537 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2538 }
2539 else
2540 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2542 }
2543 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2544 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002545}
Jeff Johnson295189b2012-06-20 16:38:30 -07002546/* To find if the MAC address is NULL */
2547static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
2548{
2549 int i;
2550 for (i = 0; i < length; i++)
2551 {
2552 if (0x00 != (macAddr[i]))
2553 {
2554 return FALSE;
2555 }
2556 }
2557 return TRUE;
2558} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08002559
Shailender Karmuchia734f332013-04-19 14:02:48 -07002560eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002561hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002562{
2563 eCsrEncryptionType cipher_type;
2564 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002565 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 {
2567 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002568 } else
2569 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 {
2571 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002572 } else
2573 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 {
2575 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002576 } else
2577 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 {
2579 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002580 } else
2581 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002583 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2584 } else
2585 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2587 }
2588 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2589 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002590}
Jeff Johnson295189b2012-06-20 16:38:30 -07002591
Shailender Karmuchia734f332013-04-19 14:02:48 -07002592static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
2593 struct ether_addr *pBssid,
2594 eCsrEncryptionType *pEncryptType,
2595 eCsrEncryptionType *mcEncryptType,
2596 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07002597#ifdef WLAN_FEATURE_11W
2598 u_int8_t *pMfpRequired,
2599 u_int8_t *pMfpCapable,
2600#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002601 u_int16_t gen_ie_len,
2602 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07002603{
2604 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002605 eHalStatus result;
2606 tDot11fIERSN dot11RSNIE;
2607 tDot11fIEWPA dot11WPAIE;
2608 tANI_U32 i;
2609 tANI_U8 *pRsnIe;
2610 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
2612
2613 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
2614 flag to 0 */
2615 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
2616 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
2617
2618 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002619 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
2620 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 return -EINVAL;
2622 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07002623 if ( gen_ie[0] == DOT11F_EID_RSN)
2624 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002626 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
2628 {
2629 return -EINVAL;
2630 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002631 // Skip past the EID byte and length byte
2632 pRsnIe = gen_ie + 2;
2633 RSNIeLen = gen_ie_len - 2;
2634 // Unpack the RSN IE
2635 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
2636 pRsnIe,
2637 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07002638 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002639 // Copy out the encryption and authentication types
2640 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002641 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002642 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002643 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002644 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 but probably I suspect we can do something different*/
2646 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07002647 // Just translate the FIRST one
2648 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
2649 //dot11RSNIE.pwise_cipher_suite_count
2650 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
2651 //dot11RSNIE.gp_cipher_suite_count
2652 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07002653#ifdef WLAN_FEATURE_11W
2654 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
2655 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
2656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07002658 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002660 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 {
2662 break;
2663 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002664 if ( hdd_IsMACAddrNULL( (u_char *) pBssid , sizeof( (char *) pBssid)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 {
2666 break;
2667 }
2668 // For right now, I assume setASSOCIATE() has passed in the bssid.
2669 vos_mem_copy(PMKIDCache[i].BSSID,
2670 pBssid, ETHER_ADDR_LEN);
2671 vos_mem_copy(PMKIDCache[i].PMKID,
2672 dot11RSNIE.pmkid[i],
2673 CSR_RSN_PMKID_SIZE);
2674 }
2675 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Shailender Karmuchia734f332013-04-19 14:02:48 -07002676 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %ld."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002677 __func__, i );
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 // Finally set the PMKSA ID Cache in CSR
2679 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002680 PMKIDCache,
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 dot11RSNIE.pmkid_count );
2682 }
2683 else if (gen_ie[0] == DOT11F_EID_WPA)
2684 {
2685 // Validity checks
2686 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
2687 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
2688 {
2689 return -EINVAL;
2690 }
2691 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07002692 pRsnIe = gen_ie + 2 + 4;
2693 RSNIeLen = gen_ie_len - (2 + 4);
2694 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
2696 pRsnIe,
2697 RSNIeLen,
2698 &dot11WPAIE);
2699 // Copy out the encryption and authentication types
2700 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002701 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002703 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 //dot11WPAIE.auth_suite_count
2705 // Just translate the FIRST one
2706 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
2707 //dot11WPAIE.unicast_cipher_count
2708 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
2709 //dot11WPAIE.unicast_cipher_count
2710 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
2711 }
2712 else
2713 {
2714 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002715 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 }
2717 return 0;
2718}
2719int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
2720{
2721 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2722 v_U32_t status = 0;
2723 eCsrEncryptionType RSNEncryptType;
2724 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07002725#ifdef WLAN_FEATURE_11W
2726 u_int8_t RSNMfpRequired;
2727 u_int8_t RSNMfpCapable;
2728#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 struct ether_addr bSsid; // MAC address of assoc peer
2730 // MAC address of assoc peer
2731 // But, this routine is only called when we are NOT associated.
2732 vos_mem_copy(bSsid.ether_addr_octet,
2733 pWextState->roamProfile.BSSIDs.bssid,
2734 sizeof(bSsid.ether_addr_octet));
2735 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
2736 {
2737 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07002738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 else
2740 {
2741 return 0;
2742 }
2743 // The actual processing may eventually be more extensive than this.
2744 // Right now, just consume any PMKIDs that are sent in by the app.
2745 status = hdd_ProcessGENIE(pAdapter,
2746 &bSsid, // MAC address of assoc peer
2747 &RSNEncryptType,
2748 &mcRSNEncryptType,
2749 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07002750#ifdef WLAN_FEATURE_11W
2751 &RSNMfpRequired,
2752 &RSNMfpCapable,
2753#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 pWextState->WPARSNIE[1]+2,
2755 pWextState->WPARSNIE);
2756 if (status == 0)
2757 {
2758 // Now copy over all the security attributes you have parsed out
2759 pWextState->roamProfile.EncryptionType.numEntries = 1;
2760 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002761
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
2763 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07002764
2765#ifdef WLAN_FEATURE_11W
2766 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
2767 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
2768#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002769 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 }
2771 return 0;
2772}
2773int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
2774{
2775 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2776 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
2777 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2778 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07002779
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 pRoamProfile->AuthType.numEntries = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002781 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d\n", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002782
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 switch( pHddStaCtx->conn_info.authType)
2784 {
2785 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2786#ifdef FEATURE_WLAN_CCX
2787 case eCSR_AUTH_TYPE_CCKM_WPA:
2788 case eCSR_AUTH_TYPE_CCKM_RSN:
2789#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002790 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
2791
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002793 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002795
Jeff Johnson295189b2012-06-20 16:38:30 -07002796#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002797 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
2798 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2799 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002800 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002801 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
2802 } else
2803 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002804 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002805 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 } else
2807#endif
2808 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2809 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002810 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
2811 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2813 == IW_AUTH_KEY_MGMT_PSK) {
2814 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002815 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 }
2819 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
2820#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002821 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
2822 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2823 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002824 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002825 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07002827 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002828 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002829 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 } else
2831#endif
2832
2833#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07002834 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
2835 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002837 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07002838 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07002839 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2841 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002842 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07002843 } else
2844#endif
2845
Chet Lanctot186b5732013-03-18 10:26:30 -07002846#ifdef WLAN_FEATURE_11W
2847 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
2848 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
2849 } else
2850#endif
2851
Shailender Karmuchia734f332013-04-19 14:02:48 -07002852 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002854 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
2855 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2857 == IW_AUTH_KEY_MGMT_PSK) {
2858 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002859 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002863 break;
2864
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002866
2867 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 break;
2869 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002870
Jeff Johnson295189b2012-06-20 16:38:30 -07002871#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002872 hddLog( LOG1, "%s: In default, unknown auth type.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002873#endif /* FEATURE_WLAN_CCX */
2874 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
2875 break;
2876 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002877
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002879 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002880
Jeff Johnson295189b2012-06-20 16:38:30 -07002881 EXIT();
2882 return 0;
2883}
2884
2885/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07002886
2887 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07002889 to the CSR roam profile.
2890
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 \param - dev - Pointer to the net device.
2892 - info - Pointer to the iw_request_info.
2893 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002894 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07002896
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 --------------------------------------------------------------------------*/
2898
Shailender Karmuchia734f332013-04-19 14:02:48 -07002899int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 struct iw_request_info *info,
2901 union iwreq_data *wrqu, char *extra)
2902{
2903 v_U32_t status = 0;
2904 hdd_wext_state_t *pWextState;
2905 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2906 v_U32_t roamId;
2907 tCsrRoamProfile *pRoamProfile;
2908 eMib_dot11DesiredBssType connectedBssType;
2909 eCsrAuthType RSNAuthType;
2910 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2911 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002912
2913 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2914
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 ENTER();
2916
2917 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2918 {
2919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2920 "%s:LOGP in Progress. Ignore!!!",__func__);
2921 return 0;
2922 }
2923
2924 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
2925 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
2926 return -EBUSY;
2927 }
2928 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
2929 return -EINVAL;
2930 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002931 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 {
2933 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
2934 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
2935 {
2936 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002937 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2939 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
2940
2941 if(VOS_STATUS_SUCCESS == vosStatus)
2942 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
2943 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2944 }
2945 }
2946 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002947 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 {
2949 return -EINVAL;
2950 }
2951 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002952 /** when cfg80211 defined, wpa_supplicant wext driver uses
2953 zero-length, null-string ssid for force disconnection.
2954 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 driver MUST return success */
2956 if ( 0 == wrqu->essid.length ) {
2957 return 0;
2958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002959
2960 status = hdd_wmm_get_uapsd_mask(pAdapter,
2961 &pWextState->roamProfile.uapsd_mask);
2962 if (VOS_STATUS_SUCCESS != status)
2963 {
2964 pWextState->roamProfile.uapsd_mask = 0;
2965 }
2966 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002967
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002969
2970 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
2972 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
2973 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002974
Jeff Johnson295189b2012-06-20 16:38:30 -07002975 //set gen ie
2976 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
2977
2978 //set auth
2979 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
2980 }
2981#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002982 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 if (pAdapter->wapi_info.nWapiMode)
2984 {
2985 switch (pAdapter->wapi_info.wapiAuthMode)
2986 {
2987 case WAPI_AUTH_MODE_PSK:
2988 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002989 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 pRoamProfile->AuthType.numEntries = 1;
2991 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
2992 break;
2993 }
2994 case WAPI_AUTH_MODE_CERT:
2995 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002996 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 pRoamProfile->AuthType.numEntries = 1;
2998 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
2999 break;
3000 }
3001 } // End of switch
3002 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3003 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3004 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003005 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 pRoamProfile->EncryptionType.numEntries = 1;
3007 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3008 pRoamProfile->mcEncryptionType.numEntries = 1;
3009 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3010 }
3011 }
3012#endif /* FEATURE_WLAN_WAPI */
3013 /* if previous genIE is not NULL, update AssocIE */
3014 if (0 != pWextState->genIE.length)
3015 {
3016 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3017 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3018 pWextState->genIE.length);
3019 pWextState->assocAddIE.length = pWextState->genIE.length;
3020 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3021 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3022
3023 /* clear previous genIE after use it */
3024 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3025 }
3026
3027 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3028 pWextState->roamProfile.bWPSAssociation = FALSE;
3029
3030 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3031 pWextState->roamProfile.nAddIEAssocLength))
3032 pWextState->roamProfile.bWPSAssociation = TRUE;
3033
3034
3035 // Disable auto BMPS entry by PMC until DHCP is done
3036 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3037
Shailender Karmuchia734f332013-04-19 14:02:48 -07003038 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
3040 status = sme_RoamConnect( hHal,pAdapter->sessionId, &(pWextState->roamProfile),&roamId);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003041 pRoamProfile->ChannelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 pRoamProfile->ChannelInfo.numOfChannels = 0;
3043
3044 EXIT();
3045 return status;
3046}
3047/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003048
3049 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003051
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 \param - dev - Pointer to the net device.
3053 - info - Pointer to the iw_request_info.
3054 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003055 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003057
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003059int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 struct iw_request_info *info,
3061 struct iw_point *dwrq, char *extra)
3062{
3063 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003064 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3066 ENTER();
3067
3068 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3069 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3070 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3071 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3072 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3073 {
3074 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3075 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3076 dwrq->flags = 1;
3077 } else {
3078 memset(extra, 0, dwrq->length);
3079 dwrq->length = 0;
3080 dwrq->flags = 0;
3081 }
3082 EXIT();
3083 return 0;
3084}
3085/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003086
3087 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003089
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 \param - dev - Pointer to the net device.
3091 - info - Pointer to the iw_request_info.
3092 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003093 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003095
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 --------------------------------------------------------------------------*/
3097int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3098 union iwreq_data *wrqu,char *extra)
3099{
3100 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003101 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3103 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003104 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003106
Jeff Johnson295189b2012-06-20 16:38:30 -07003107 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003108
3109 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3110 {
3111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3112 "%s:LOGP in Progress. Ignore!!!", __func__);
3113 return -EBUSY;
3114 }
3115
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 switch(wrqu->param.flags & IW_AUTH_INDEX)
3117 {
3118 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003119
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003121
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003123
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 case IW_AUTH_CIPHER_PAIRWISE:
3125 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003126 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3130 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3133 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003134 }
3135
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003137
3138 if( (IW_AUTH_KEY_MGMT_802_1X
3139 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3141 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003142 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 else
3144 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003145 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003148
3149 if( ( IW_AUTH_KEY_MGMT_802_1X
3150 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3152 /*Dynamic WEP key*/
3153 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3154 else
3155 /*Static WEP key*/
3156 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003157
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 }
3159 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003160
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003162 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 return -EINVAL;
3164 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003165
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 pRoamProfile->EncryptionType.numEntries = 1;
3167 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 break;
3170 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003171 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003172 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3173 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3174 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003175
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3177 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3178 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003179
3180 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003181 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3182 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003183
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003185
3186 if( ( IW_AUTH_KEY_MGMT_802_1X
3187 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3188 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3189
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003191
3192 else
3193 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003195
3196 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3197 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003199 if( ( IW_AUTH_KEY_MGMT_802_1X
3200 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3202 {
3203 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3204 }
3205 else
3206 {
3207 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3208 }
3209 }
3210 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003211
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003213 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 return -EINVAL;
3215 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003216
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 pRoamProfile->mcEncryptionType.numEntries = 1;
3218 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3219 }
3220 break;
3221
3222 case IW_AUTH_80211_AUTH_ALG:
3223 {
3224 /*Save the auth algo here and set auth type to SME Roam profile
3225 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003226 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003228
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3230 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3231
3232 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3233 /*Not supported*/
3234 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3235 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3236 }
3237 break;
3238
3239 case IW_AUTH_KEY_MGMT:
3240 {
3241#ifdef FEATURE_WLAN_CCX
3242#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3243 /*Check for CCKM AKM type */
3244 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003245 //hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
3246 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003247 /* Set the CCKM bit in authKeyMgmt */
3248 /* Right now, this breaks all ref to authKeyMgmt because our
3249 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 */
3251 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3252 /*Set the key management to 802.1X*/
3253 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
3254 pWextState->isCCXConnection = eANI_BOOLEAN_TRUE;
3255 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3256 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3257 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3258 /*Save the key management*/
3259 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3260 //pWextState->authKeyMgmt = wrqu->param.value;
3261 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3262 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3263 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3264 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3265 /*Save the key management anyway*/
3266 pWextState->authKeyMgmt = wrqu->param.value;
3267 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3268 /*Save the key management*/
3269 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3270 //pWextState->authKeyMgmt = wrqu->param.value;
3271 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3272 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3273 }
3274#else
3275 /*Save the key management*/
3276 pWextState->authKeyMgmt = wrqu->param.value;
3277#endif /* FEATURE_WLAN_CCX */
3278 }
3279 break;
3280
3281 case IW_AUTH_TKIP_COUNTERMEASURES:
3282 {
3283 if(wrqu->param.value) {
3284 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3285 "Counter Measure started %d", wrqu->param.value);
3286 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3287 }
3288 else {
3289 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3290 "Counter Measure stopped=%d", wrqu->param.value);
3291 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3292 }
3293 }
3294 break;
3295 case IW_AUTH_DROP_UNENCRYPTED:
3296 case IW_AUTH_WPA_ENABLED:
3297 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3298 case IW_AUTH_ROAMING_CONTROL:
3299 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003300
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003302
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003303 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 wrqu->param.flags & IW_AUTH_INDEX);
3305 break;
3306 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003307
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 EXIT();
3309 return 0;
3310}
3311/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003312
3313 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003315
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 \param - dev - Pointer to the net device.
3317 - info - Pointer to the iw_request_info.
3318 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003319 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003321
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 --------------------------------------------------------------------------*/
3323int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3324 union iwreq_data *wrqu,char *extra)
3325{
3326 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003327 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3329 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003330
3331 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3332 {
3333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3334 "%s:LOGP in Progress. Ignore!!!", __func__);
3335 return -EBUSY;
3336 }
3337
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 switch(pRoamProfile->negotiatedAuthType)
3339 {
3340 case eCSR_AUTH_TYPE_WPA_NONE:
3341 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3342 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3343 break;
3344 case eCSR_AUTH_TYPE_WPA:
3345 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3346 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3347 break;
3348#ifdef WLAN_FEATURE_VOWIFI_11R
3349 case eCSR_AUTH_TYPE_FT_RSN:
3350#endif
3351 case eCSR_AUTH_TYPE_RSN:
3352 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3353 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3354 break;
3355 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3356 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3357 break;
3358 case eCSR_AUTH_TYPE_SHARED_KEY:
3359 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3360 break;
3361 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003362 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3364 break;
3365 case eCSR_AUTH_TYPE_AUTOSWITCH:
3366 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3367 break;
3368 case eCSR_AUTH_TYPE_WPA_PSK:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003369 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3371 return -EIO;
3372#ifdef WLAN_FEATURE_VOWIFI_11R
3373 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3374#endif
3375 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07003376#ifdef WLAN_FEATURE_11W
3377 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3378#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003379 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3381 return -EIO;
3382 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003383 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3385 return -EIO;
3386 }
3387 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3388 {
3389 switch(pRoamProfile->negotiatedUCEncryptionType)
3390 {
3391 case eCSR_ENCRYPT_TYPE_NONE:
3392 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3393 break;
3394 case eCSR_ENCRYPT_TYPE_WEP40:
3395 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3396 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3397 break;
3398 case eCSR_ENCRYPT_TYPE_TKIP:
3399 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3400 break;
3401 case eCSR_ENCRYPT_TYPE_WEP104:
3402 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3403 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3404 break;
3405 case eCSR_ENCRYPT_TYPE_AES:
3406 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3407 break;
3408 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003409 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 return -EIO;
3411 }
3412 }
3413
Shailender Karmuchia734f332013-04-19 14:02:48 -07003414 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 {
3416 switch(pRoamProfile->negotiatedMCEncryptionType)
3417 {
3418 case eCSR_ENCRYPT_TYPE_NONE:
3419 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3420 break;
3421 case eCSR_ENCRYPT_TYPE_WEP40:
3422 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3423 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3424 break;
3425 case eCSR_ENCRYPT_TYPE_TKIP:
3426 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3427 break;
3428 case eCSR_ENCRYPT_TYPE_WEP104:
3429 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3430 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3431 break;
3432 case eCSR_ENCRYPT_TYPE_AES:
3433 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3434 break;
3435 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003436 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 return -EIO;
3438 }
3439 }
3440
3441 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003442 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 EXIT();
3444 return 0;
3445}
3446/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003447
3448 \brief iw_set_ap_address() -
3449 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003451
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 \param - dev - Pointer to the net device.
3453 - info - Pointer to the iw_request_info.
3454 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003455 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003457
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 --------------------------------------------------------------------------*/
3459int iw_set_ap_address(struct net_device *dev,
3460 struct iw_request_info *info,
3461 union iwreq_data *wrqu, char *extra)
3462{
3463 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3464 v_U8_t *pMacAddress=NULL;
3465 ENTER();
3466 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
3467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%02x:%02x:%02x:%02x:%02x:%02x",pMacAddress[0],pMacAddress[1],
3468 pMacAddress[2],pMacAddress[3],pMacAddress[4],pMacAddress[5]);
3469 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3470 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003471
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 return 0;
3473}
3474/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003475
3476 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 This function returns the BSSID to the wpa_supplicant
3478 \param - dev - Pointer to the net device.
3479 - info - Pointer to the iw_request_info.
3480 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003481 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003483
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 --------------------------------------------------------------------------*/
3485int iw_get_ap_address(struct net_device *dev,
3486 struct iw_request_info *info,
3487 union iwreq_data *wrqu, char *extra)
3488{
3489 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3490 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3491
3492 ENTER();
3493
3494 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3495 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3496 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003497 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 }
3499 else
3500 {
3501 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
3502 }
3503 EXIT();
3504 return 0;
3505}
Jeff Johnsond13512a2012-07-17 11:42:19 -07003506
3507
3508/**---------------------------------------------------------------------------
3509
3510 \brief hdd_ResetCountryCodeAfterDisAssoc -
3511 This function reset the country code to default
Jeff Johnsona8a1a482012-12-12 16:49:33 -08003512 \param - pAdapter - Pointer to HDD adapter
Jeff Johnsond13512a2012-07-17 11:42:19 -07003513 \return - nothing
3514
3515 --------------------------------------------------------------------------*/
3516void hdd_ResetCountryCodeAfterDisAssoc(hdd_adapter_t *pAdapter)
3517{
3518 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3519 tSmeConfigParams smeConfig;
3520 eHalStatus status = eHAL_STATUS_SUCCESS;
3521 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
3522 tANI_U8 currentCountryCode[3] = SME_INVALID_COUNTRY_CODE;
3523
3524 sme_GetConfigParam(pHddCtx->hHal, &smeConfig);
3525
3526 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3527 "%s: 11d is %s\n",__func__,
3528 smeConfig.csrConfig.Is11dSupportEnabled ? "Enabled" : "Disabled");
3529 /* Reset country code only when 11d is enabled
3530 */
3531 if (smeConfig.csrConfig.Is11dSupportEnabled)
3532 {
3533 sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, &defaultCountryCode[0]);
3534 sme_GetCurrentCountryCode(pHddCtx->hHal, &currentCountryCode[0]);
3535
Kiran Kumar Lokere439bfb12013-05-07 19:21:01 -07003536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnsond13512a2012-07-17 11:42:19 -07003537 "%s: Default country code: %c%c%c, Current Country code: %c%c%c \n",
3538 __func__,
3539 defaultCountryCode[0], defaultCountryCode[1], defaultCountryCode[2],
3540 currentCountryCode[0], currentCountryCode[1], currentCountryCode[2]);
3541 /* Reset country code only when there is a mismatch
3542 * between current country code and default country code
3543 */
3544 if ((defaultCountryCode[0] != currentCountryCode[0]) ||
Kiran Kumar Lokere439bfb12013-05-07 19:21:01 -07003545 (defaultCountryCode[1] != currentCountryCode[1]))
Jeff Johnsond13512a2012-07-17 11:42:19 -07003546 {
Kiran Kumar Lokere439bfb12013-05-07 19:21:01 -07003547 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnsond13512a2012-07-17 11:42:19 -07003548 "%s: Disconnected from the AP/Assoc failed and "
3549 "resetting the country code to default\n",__func__);
3550 /*reset the country code of previous connection*/
3551 status = (int)sme_ChangeCountryCode(pHddCtx->hHal, NULL,
3552 &defaultCountryCode[0], pAdapter,
3553 pHddCtx->pvosContext
3554 );
3555 if( 0 != status )
3556 {
3557 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3558 "%s: failed to Reset the Country Code\n",__func__);
3559 }
3560 }
3561 }
Kiran4a17ebe2013-01-31 10:43:43 -08003562 else if (smeConfig.csrConfig.Is11hSupportEnabled)
3563 {
Kiran Kumar Lokere439bfb12013-05-07 19:21:01 -07003564 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Kiran4a17ebe2013-01-31 10:43:43 -08003565 "%s: Disconnected from the AP/Assoc failed and "
3566 "resetting the 5G power values to default", __func__);
3567 sme_ResetPowerValuesFor5G (pHddCtx->hHal);
3568 }
Jeff Johnsond13512a2012-07-17 11:42:19 -07003569}
3570
Chet Lanctot186b5732013-03-18 10:26:30 -07003571#ifdef WLAN_FEATURE_11W
3572/**---------------------------------------------------------------------------
3573
3574 \brief hdd_indicateUnprotMgmtFrame -
3575 This function forwards the unprotected management frame to the supplicant
3576 \param - pAdapter - Pointer to HDD adapter
3577 - nFrameLength - Length of the unprotected frame being passed
3578 - pbFrames - Pointer to the frame buffer
3579 - frameType - 802.11 frame type
3580 \return - nothing
3581
3582 --------------------------------------------------------------------------*/
3583void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
3584 tANI_U32 nFrameLength,
3585 tANI_U8* pbFrames,
3586 tANI_U8 frameType )
3587{
3588 tANI_U8 type = 0;
3589 tANI_U8 subType = 0;
3590
3591 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
3592 __func__, frameType, nFrameLength);
3593
3594 /* Sanity Checks */
3595 if (NULL == pAdapter)
3596 {
3597 hddLog( LOGE, FL("pAdapter is NULL"));
3598 return;
3599 }
3600
3601 if (NULL == pAdapter->dev)
3602 {
3603 hddLog( LOGE, FL("pAdapter->dev is NULL"));
3604 return;
3605 }
3606
3607 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
3608 {
3609 hddLog( LOGE, FL("pAdapter has invalid magic"));
3610 return;
3611 }
3612
3613 if( !nFrameLength )
3614 {
3615 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
3616 return;
3617 }
3618
3619 if (NULL == pbFrames) {
3620 hddLog( LOGE, FL("pbFrames is NULL"));
3621 return;
3622 }
3623
3624 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
3625 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
3626
3627 /* Get pAdapter from Destination mac address of the frame */
3628 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
3629 {
3630 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
3631 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
3632 }
3633 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
3634 {
3635 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
3636 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
3637 }
3638 else
3639 {
3640 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
3641 return;
3642 }
3643}
3644#endif