blob: b9e1a6f07466d631234f165e3c5f3430d4801dbe [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
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530130static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
131 tCsrRoamInfo *pRoamInfo,
132 tANI_U32 roamId,
133 eRoamCmdStatus roamStatus,
134 eCsrRoamResult roamResult );
135
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530136v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
137 eConnectionState connState )
138{
139 // save the new connection state
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 pHddStaCtx->conn_info.connState = connState;
141}
142
143// returns FALSE if not connected.
144// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
145// returns the connection state. Can specify NULL if you dont' want to get the actual state.
146
Shailender Karmuchia734f332013-04-19 14:02:48 -0700147static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
148 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700149{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700150 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700152
Jeff Johnson295189b2012-06-20 16:38:30 -0700153 // get the connection state.
154 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700155 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 if ( eConnectionState_Associated == connState ||
157 eConnectionState_IbssConnected == connState )
158 {
159 fConnected = VOS_TRUE;
160 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700161 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 {
163 fConnected = VOS_FALSE;
164 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700165
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 if ( pConnState )
167 {
168 *pConnState = connState;
169 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700170
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 return( fConnected );
172}
173
174v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
175{
176 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700177}
Jeff Johnson295189b2012-06-20 16:38:30 -0700178
179//TODO - Not used anyhwere. Can be removed.
180#if 0
181//
182v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
183{
184 v_BOOL_t fConnectedInfra = FALSE;
185 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700186
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700188 {
189 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700190 {
191 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700192 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700194
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 return( fConnectedInfra );
196}
197#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700198
Jeff Johnson295189b2012-06-20 16:38:30 -0700199static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
200{
201 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700202
Jeff Johnson295189b2012-06-20 16:38:30 -0700203 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700204
205 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 {
207 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
208 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700209
Jeff Johnson295189b2012-06-20 16:38:30 -0700210 return( fConnected );
211}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700212
Jeff Johnson295189b2012-06-20 16:38:30 -0700213inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
214{
215 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700218
219 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700220 {
221 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
222 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700223
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 return( fConnected );
225}
226
227static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
228{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700229 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700230 {
231 case eCSR_BSS_TYPE_INFRASTRUCTURE:
232 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
233 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700234
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 case eCSR_BSS_TYPE_IBSS:
236 case eCSR_BSS_TYPE_START_IBSS:
237 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
238 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700239
240 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700241 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700242 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700243 default:
244 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700245 break;
246 }
247
Jeff Johnson295189b2012-06-20 16:38:30 -0700248}
249
250void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
251{
252 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
253 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700254
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700256
257 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700258 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700259 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700260 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
261 {
262 VOS_ASSERT( pRoamInfo->pBssDesc );
263 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
264
265 // Save the Station ID for this station from the 'Roam Info'.
266 //For IBSS mode, staId is assigned in NEW_PEER_IND
267 //For reassoc, the staID doesn't change and it may be invalid in this structure
268 //so no change here.
269 if( !pRoamInfo->fReassocReq )
270 {
271 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
272 }
273 }
274 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700275 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700277 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 else
279 {
280 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
281 // or we can't function.
282 VOS_ASSERT( 0 );
283 }
284
285 // notify WMM
286 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
287
288 if( !pRoamInfo->u.pConnectedProfile )
289 {
290 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
291 }
292 else
293 {
294 // Get Multicast Encryption Type
295 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
296 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
297 // Get Unicast Encrytion Type
298 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
299 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
300
301 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
302
303 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
304
305 // Save the ssid for the connection
306 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530307
308 // Save dot11mode in which STA associated to AP
309 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700311 }
312
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700314 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
315
Jeff Johnson295189b2012-06-20 16:38:30 -0700316}
317
318#if defined(WLAN_FEATURE_VOWIFI_11R)
319/*
320 * Send the 11R key information to the supplicant.
321 * Only then can the supplicant generate the PMK-R1.
322 * (BTW, the CCX supplicant also needs the Assoc Resp IEs
323 * for the same purpose.)
324 *
325 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
326 * this contains the R1KHID, R0KHID and the MDID.
327 * For FT, this consists of the Reassoc Rsp FTIEs.
328 * This is the Assoc Response.
329 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700330static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 tCsrRoamInfo *pCsrRoamInfo)
332{
333 union iwreq_data wrqu;
334 char *buff;
335 unsigned int len = 0;
336 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700337
338 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 {
340 hddLog(LOGE,
341 "%s: pCsrRoamInfo->nAssocRspLength=%d",
342 __func__, (int)pCsrRoamInfo->nAssocRspLength);
343 return;
344 }
345
Shailender Karmuchia734f332013-04-19 14:02:48 -0700346 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700348 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700350 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 return;
352 }
353
354 // pFTAssocRsp needs to point to the IEs
355 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
356 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
357 (unsigned int)pFTAssocRsp[0],
358 (unsigned int)pFTAssocRsp[1]);
359
360 // We need to send the IEs to the supplicant.
361 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700362 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700364 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 return;
366 }
367
368 // Send the Assoc Resp, the supplicant needs this for initial Auth.
369 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700370 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700371 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700372 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
374
375 kfree(buff);
376}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700377#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700378
379#ifdef WLAN_FEATURE_VOWIFI_11R
380
381/*---------------------------------------------------
382 *
383 * Send the FTIEs, RIC IEs during FT. This is eventually
384 * used to send the FT events to the supplicant
385 *
386 * At the reception of Auth2 we send the RIC followed
387 * by the auth response IEs to the supplicant.
388 * Once both are received in the supplicant, an FT
389 * event is generated to the supplicant.
390 *
391 *---------------------------------------------------
392 */
393void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
394{
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 tANI_U16 auth_resp_len = 0;
396 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700397 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
398
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530399#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700400 struct cfg80211_ft_event_params ftEvent;
401 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
402 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
403 struct net_device *dev = pAdapter->dev;
404#else
405 char *buff;
406 union iwreq_data wrqu;
407 tANI_U16 str_len;
408#endif
409
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530410#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530411 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
412 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700413
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530414 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800415 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530416 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700417 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530418 hddLog(LOGW,
419 "%s: RIC IEs is of length 0 not sending RIC Information for now",
420 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700421 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700422
423 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530424 ftEvent.ric_ies_len = ric_ies_length;
425 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700426
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530427 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800428 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700429
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530430 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700431 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530432 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700433 return;
434 }
435
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530436 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530437
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530438 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700439
440 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
441 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
442
443 hddLog(LOG1, "%s ftEvent.ies_len %d",__FUNCTION__, ftEvent.ies_len);
444 hddLog(LOG1, "%s ftEvent.ric_ies_len %d",__FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530445 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800446 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
447 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
448 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700449
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530450 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700451
452#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530453 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700454 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530455 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530457 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700458 return;
459 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530460 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700461
Shailender Karmuchia734f332013-04-19 14:02:48 -0700462 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700463 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530464 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800465 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530466 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530468 hddLog(LOGW,
469 "%s: RIC IEs is of length 0 not sending RIC Information for now",
470 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 }
472 else
473 {
474 wrqu.data.length = str_len + ric_ies_length;
475 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
476 }
477
478 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530479 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530481 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
482 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700483
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530484 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530486 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 return;
488 }
489
490 wrqu.data.length = str_len + auth_resp_len;
491 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
492
493 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700494#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700495}
496
497#endif /* WLAN_FEATURE_VOWIFI_11R */
498
499#ifdef FEATURE_WLAN_CCX
500
501/*
502 * Send the CCX required "new AP Channel info" to the supplicant.
503 * (This keeps the supplicant "up to date" on the current channel.)
504 *
505 * The current (new AP) channel information is passed in.
506 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700507static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 tCsrRoamInfo *pCsrRoamInfo)
509{
510 union iwreq_data wrqu;
511 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700512
Shailender Karmuchia734f332013-04-19 14:02:48 -0700513
514 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 {
516 hddLog(LOGE,
517 "%s: pCsrRoamInfo->pBssDesc=%p\n",
518 __func__, descriptor);
519 return;
520 }
521
522 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
523 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d\n", __func__, descriptor->channelId);
524 memset(&wrqu, '\0', sizeof(wrqu));
525 wrqu.freq.m = descriptor->channelId;
526 wrqu.freq.e = 0;
527 wrqu.freq.i = 0;
528 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
529}
530
531#endif /* FEATURE_WLAN_CCX */
532
533void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
534{
535 union iwreq_data wrqu;
536 u8 *pBeaconIes;
537 u8 currentLen = 0;
538 char *buff;
539 int totalIeLen = 0, currentOffset = 0, strLen;
540
541 memset(&wrqu, '\0', sizeof(wrqu));
542
543 if (0 == pCsrRoamInfo->nBeaconLength)
544 {
545 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
546 return;
547 }
548 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700549 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700551 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 return;
553 }
554
555 // pBeaconIes needs to point to the IEs
556 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
557 (unsigned int)pBeaconIes[0],
558 (unsigned int)pBeaconIes[1]);
559 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700560
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 // We need to send the IEs to the supplicant.
562 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700563 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700565 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 return;
567 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700568 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700569
570 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
571 currentLen = strLen + 1;
572
573 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
574 do
575 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700576 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 * max size and send it to supplicant. Changes are done in supplicant to handle this */
578 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
579 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
580 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
581 currentOffset += currentLen;
582 totalIeLen -= currentLen;
583 wrqu.data.length = strLen + 1 + currentLen;
584 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700585 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 else
587 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
588
589 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
590 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
591 } while (totalIeLen > 0);
592
593 kfree(buff);
594}
595
596static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
597{
598 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
599 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
600 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
601 union iwreq_data wrqu;
602 int we_event;
603 char *msg;
604 int type = -1;
605
Shailender Karmuchia734f332013-04-19 14:02:48 -0700606#if defined (WLAN_FEATURE_VOWIFI_11R)
607 // Added to find the auth type on the fly at run time
608 // rather than with cfg to see if FT is enabled
609 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
611#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700612
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700614 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700615 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700616
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
618 {
619 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
620 type = WLAN_STA_ASSOC_DONE_IND;
621
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700622#ifdef WLAN_FEATURE_P2P_DEBUG
623 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
624 {
625 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
626 {
627 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
628 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
629 "Connecting state to Connected State for 8-way "
630 "Handshake");
631 }
632 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
633 {
634 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
635 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
636 "Connecting state to P2P Client Connection Completed");
637 }
638 }
639#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 pr_info("wlan: connected to %02x:%02x:%02x:%02x:%02x:%02x\n",
641 wrqu.ap_addr.sa_data[0],
642 wrqu.ap_addr.sa_data[1],
643 wrqu.ap_addr.sa_data[2],
644 wrqu.ap_addr.sa_data[3],
645 wrqu.ap_addr.sa_data[4],
646 wrqu.ap_addr.sa_data[5]);
647 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
648
649 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
650 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
651 * and fFTEnable is TRUE */
652#ifdef WLAN_FEATURE_VOWIFI_11R
653 // Send FT Keys to the supplicant when FT is enabled
654 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700655 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Jeff Johnson295189b2012-06-20 16:38:30 -0700656#ifdef FEATURE_WLAN_CCX
657 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
658 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
659#endif
660 )
661 {
662 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
663 }
664#endif
665 }
666 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
667 {
Jeff Johnson4416a782013-03-25 14:17:50 -0700668 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 type = WLAN_STA_ASSOC_DONE_IND;
670 pr_info("wlan: new IBSS connection to %02x:%02x:%02x:%02x:%02x:%02x",
671 pHddStaCtx->conn_info.bssId[0],
672 pHddStaCtx->conn_info.bssId[1],
673 pHddStaCtx->conn_info.bssId[2],
674 pHddStaCtx->conn_info.bssId[3],
675 pHddStaCtx->conn_info.bssId[4],
676 pHddStaCtx->conn_info.bssId[5]);
677 }
678 else /* Not Associated */
679 {
680 pr_info("wlan: disconnected\n");
681 type = WLAN_STA_DISASSOC_DONE_IND;
682 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
683 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700684 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700685
686 msg = NULL;
687 /*During the WLAN uninitialization,supplicant is stopped before the
688 driver so not sending the status of the connection to supplicant*/
689 if(pHddCtx->isLoadUnloadInProgress != TRUE)
690 {
691 wireless_send_event(dev, we_event, &wrqu, msg);
692#ifdef FEATURE_WLAN_CCX
693 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700694 {
695 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
696 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
698 }
699#endif
700 }
701 send_btc_nlink_msg(type, 0);
702}
703
704void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
705{
706 // Remove staId, bssId and peerMacAddress
707 pHddStaCtx->conn_info.staId [ 0 ] = 0;
708 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
709 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
710
711 // Clear all security settings
712 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
713 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
714 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
715
716 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
717
718 // Set not-connected state
719 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700720 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Jeff Johnson295189b2012-06-20 16:38:30 -0700721
722 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
723}
724/* TODO Revist this function. and data path */
725static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
726{
727 VOS_STATUS vosStatus;
728 hdd_disconnect_tx_rx(pAdapter);
729 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
730 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
731 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
734 "Status= %d [0x%08lX]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700735 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 }
737 return( vosStatus );
738}
739
740
741static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
742 tANI_U32 roamId, eRoamCmdStatus roamStatus,
743 eCsrRoamResult roamResult )
744{
745 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700746 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 struct net_device *dev = pAdapter->dev;
748 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
749 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700750
751 // Sanity check
752 if(dev == NULL)
753 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700754 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700755 "%s: net_dev is released return", __func__);
756 return eHAL_STATUS_FAILURE;
757 }
758
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 // notify apps that we can't pass traffic anymore
760 netif_tx_disable(dev);
761 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700762
Jeff Johnsone7245742012-09-05 17:12:55 -0700763 INIT_COMPLETION(pAdapter->disconnect_comp_var);
764 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 /* If only STA mode is on */
766 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
767 {
768 pHddCtx->isAmpAllowed = VOS_TRUE;
769 }
770 hdd_clearRoamProfileIe( pAdapter );
771
772 // indicate 'disconnect' status to wpa_supplicant...
773 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 /* indicate disconnected event to nl80211 */
775 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
776 {
777 /*During the WLAN uninitialization,supplicant is stopped before the
778 driver so not sending the status of the connection to supplicant*/
779 if(pHddCtx->isLoadUnloadInProgress != TRUE)
780 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700781 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
782 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700784#ifdef WLAN_FEATURE_P2P_DEBUG
785 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
786 {
787 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
788 {
789 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
790 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
791 "and moved to disconnected state");
792 }
793 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
794 {
795 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
796 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
797 "and moved to inactive state");
798 }
799 }
800#endif
801
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
803 if( eCSR_ROAM_LOSTLINK == roamStatus )
804 {
Mohit Khanna99d5fd02012-09-11 14:51:20 -0700805 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 }
807 else
808 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700809 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 }
811
812 //If the Device Mode is Station
813 // and the P2P Client is Connected
814 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700815
816 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700817 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -0700818 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
819 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 (vos_concurrent_sessions_running()))
821 {
822 //Enable BMPS only of other Session is P2P Client
823 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700824 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700825
826 if (NULL != pVosContext)
827 {
828 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
829
830 if(NULL != pHddCtx)
831 {
832 //Only P2P Client is there Enable Bmps back
833 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700834 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 {
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -0800836 if (pHddCtx->hdd_wlan_suspended)
837 {
838 if(WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
839 {
840 hdd_reset_pwrparams(pHddCtx);
841 }
842 else
843 {
844 hdd_set_pwrparams(pHddCtx);
845 }
846 }
847
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 hdd_enable_bmps_imps(pHddCtx);
849 }
850 }
851 }
852 }
853 }
854 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700855
Jeff Johnson295189b2012-06-20 16:38:30 -0700856
857 //We should clear all sta register with TL, for now, only one.
Jeff Johnson43971f52012-07-17 12:26:56 -0700858 vstatus = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
859 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 "hdd_roamDeregisterSTA() failed to for staID %d. "
863 "Status= %d [0x%x]",
864 pHddStaCtx->conn_info.staId[0], status, status );
865
866 status = eHAL_STATUS_FAILURE;
867 }
868
869 pHddCtx->sta_to_adapter[pHddStaCtx->conn_info.staId[0]] = NULL;
870 // Clear saved connection information in HDD
871 hdd_connRemoveConnectInfo( pHddStaCtx );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530872#ifdef WLAN_FEATURE_GTK_OFFLOAD
873 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
874 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
875 {
876 pHddStaCtx->gtkOffloadRequestParams.requested = FALSE;
877 memset(&pHddStaCtx->gtkOffloadRequestParams.gtkOffloadReqParams,
878 0, sizeof (tSirGtkOffloadParams));
879 }
880#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700881
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800882#ifdef FEATURE_WLAN_TDLS
883 wlan_hdd_tdls_disconnection_callback(pAdapter);
884#endif
885
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 //Unblock anyone waiting for disconnect to complete
887 complete(&pAdapter->disconnect_comp_var);
888 return( status );
889}
890static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
891 tCsrRoamInfo *pRoamInfo,
892 v_U8_t staId,
893 v_MACADDR_t *pPeerMacAddress,
894 tSirBssDescription *pBssDesc )
895{
896 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
897 WLAN_STADescType staDesc = {0};
898 eCsrEncryptionType connectedCipherAlgo;
899 v_BOOL_t fConnected;
900 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
901 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700902
903 if ( NULL == pBssDesc)
904 {
905 return VOS_STATUS_E_FAILURE;
906 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 // Get the Station ID from the one saved during the assocation.
908 staDesc.ucSTAId = staId;
909
910 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700912 staDesc.wSTAType = WLAN_STA_INFRA;
913
914 // grab the bssid from the connection info in the adapter structure and hand that
915 // over to TL when registering.
916 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
917 }
918 else
919 {
920 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700922
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
924 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
925 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
926 // pass when making an Infrastructure connection.
927 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
928 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
929 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700930
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
932
933 // set the QoS field appropriately
934 if (hdd_wmm_is_active(pAdapter))
935 {
936 staDesc.ucQosEnabled = 1;
937 }
938 else
939 {
940 staDesc.ucQosEnabled = 0;
941 }
942
943 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
944 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
945 {
946 staDesc.ucProtectedFrame = 1;
947 }
948 else
949 {
950 staDesc.ucProtectedFrame = 0;
951
952 }
953
954#ifdef FEATURE_WLAN_CCX
955 staDesc.ucIsCcxSta = pRoamInfo->isCCXAssoc;
956#endif //FEATURE_WLAN_CCX
957
958#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
959 /* check whether replay check is valid for the station or not */
960 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
961 {
962 /* Encryption mode is either TKIP or AES
963 and replay check is valid for only these
964 two encryption modes */
965 staDesc.ucIsReplayCheckValid = VOS_TRUE;
966 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
967 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
968 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700969
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 else
971 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700972 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700974 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
976 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
977 }
978#endif
979
980#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700981 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 if (pAdapter->wapi_info.fIsWapiSta)
983 {
984 staDesc.ucIsWapiSta = 1;
985 }
986 else
987 {
988 staDesc.ucIsWapiSta = 0;
989 }
990#endif /* FEATURE_WLAN_WAPI */
991
992 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
993 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
994
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 // UMA is Not ready yet, Xlation will be done by TL
996 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700997 staDesc.ucSwFrameRXXlation = 1;
998 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700999 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 staDesc.ucQosEnabled );
1001 // Initialize signatures and state
1002 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1003 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1004 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1005 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001006 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001007 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 -07001008 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1009 hdd_rx_packet_cbk,
1010 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 hdd_tx_fetch_packet_cbk, &staDesc,
1012 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001013
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1015 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001016 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08lX]",
1018 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001019 return vosStatus;
1020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001021
Shailender Karmuchia734f332013-04-19 14:02:48 -07001022 // if ( WPA ), tell TL to go to 'connected' and after keys come to the driver,
Shailender Karmuchia734f332013-04-19 14:02:48 -07001023
1024 if (staDesc.wSTAType != WLAN_STA_IBSS)
1025 VOS_ASSERT( fConnected );
1026
Gopichand Nakkala29149562013-05-10 21:43:41 +05301027 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1028 "ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
1029 pHddStaCtx->conn_info.staId[0] );
1030 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1031 WLANTL_STA_CONNECTED );
1032 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001033
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 return( vosStatus );
1035}
1036
Jeff Johnson295189b2012-06-20 16:38:30 -07001037static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1038 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1039{
1040 unsigned int len = 0;
1041 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001042 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 tANI_U32 rspRsnLength = 0;
1044 struct ieee80211_channel *chan;
1045
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001046 if (!rspRsnIe)
1047 {
1048 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001049 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001050 }
1051
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 if (pCsrRoamInfo == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001053 {
1054 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1055 goto done;
1056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001057
1058 if (pCsrRoamInfo->nAssocRspLength == 0)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001059 {
1060 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1061 goto done;
1062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001063
1064 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1065 pCsrRoamInfo->nAssocReqLength);
1066 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001067 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001068
1069 //pFTAssocRsp needs to point to the IEs
1070 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1071 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x\n", __func__,
1072 (unsigned int)pFTAssocRsp[0],
1073 (unsigned int)pFTAssocRsp[1]);
1074
1075 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001076 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001079 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001080
1081 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1082 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1083 reqRsnIe, reqRsnLength,
1084 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001085
1086done:
1087 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001088}
Jeff Johnson295189b2012-06-20 16:38:30 -07001089
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301090void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1091{
1092 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1093 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1094 tCsrRoamInfo roamInfo;
1095 roamInfo.fAuthRequired = FALSE;
1096 vos_mem_copy(roamInfo.bssid,
1097 pHddStaCtx->roam_info.bssid,
1098 WNI_CFG_BSSID_LEN);
1099 vos_mem_copy(roamInfo.peerMac,
1100 pHddStaCtx->roam_info.peerMac,
1101 WNI_CFG_BSSID_LEN);
1102
1103 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1104 &roamInfo,
1105 pHddStaCtx->roam_info.roamId,
1106 pHddStaCtx->roam_info.roamStatus,
1107 eCSR_ROAM_RESULT_AUTHENTICATED);
1108 if (halStatus != eHAL_STATUS_SUCCESS)
1109 {
1110 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1111 }
1112 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1113}
1114
Shailender Karmuchia734f332013-04-19 14:02:48 -07001115static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1116 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001117 eCsrRoamResult roamResult )
1118{
1119 struct net_device *dev = pAdapter->dev;
1120 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1121 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1122 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001123 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1124 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001125#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 int ft_carrier_on = FALSE;
1127#endif
1128 int status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001129
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1131 {
1132 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1133
1134 // Save the connection info from CSR...
1135 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1136#ifdef FEATURE_WLAN_WAPI
1137 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1138 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1139 {
1140 pAdapter->wapi_info.fIsWapiSta = 1;
1141 }
1142 else
1143 {
1144 pAdapter->wapi_info.fIsWapiSta = 0;
1145 }
1146#endif /* FEATURE_WLAN_WAPI */
1147
1148 // indicate 'connect' status to userspace
1149 hdd_SendAssociationEvent(dev,pRoamInfo);
1150
1151
Shailender Karmuchia734f332013-04-19 14:02:48 -07001152 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001153 INIT_COMPLETION(pAdapter->linkup_event_var);
1154
1155 /*
1156 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1157 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 -07001158 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001159 know that the device is getting activated properly.
1160 */
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001161#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001162 if (pHddStaCtx->ft_carrier_on == FALSE)
1163 {
1164#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001165 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 pAdapter->isLinkUpSvcNeeded = TRUE;
1167
Shailender Karmuchia734f332013-04-19 14:02:48 -07001168 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 pAdapter->isLinkUpSvcNeeded = TRUE;
1170
1171 // Switch on the Carrier to activate the device
1172 netif_carrier_on(dev);
1173
1174 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1175 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1176 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001177 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 {
1179 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1180 }
1181
1182 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1183 pAdapter->isLinkUpSvcNeeded = FALSE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001184#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001185 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001186 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 }
1190#endif
1191 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1192
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001193#ifdef FEATURE_WLAN_TDLS
1194 wlan_hdd_tdls_connection_callback(pAdapter);
1195#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 //For reassoc, the station is already registered, all we need is to change the state
1197 //of the STA in TL.
1198 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1199 if( !pRoamInfo->fReassocReq )
1200 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001201 struct cfg80211_bss *bss;
1202#ifdef WLAN_FEATURE_VOWIFI_11R
1203 u8 *pFTAssocRsp = NULL;
1204 unsigned int assocRsplen = 0;
1205 u8 *pFTAssocReq = NULL;
1206 unsigned int assocReqlen = 0;
1207 struct ieee80211_channel *chan;
1208#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001209 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001210 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001211
1212 /* add bss_id to cfg80211 data base */
1213 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1214 if (NULL == bss)
1215 {
1216 pr_err("wlan: Not able to create BSS entry\n");
1217 return eHAL_STATUS_FAILURE;
1218 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001219#ifdef WLAN_FEATURE_VOWIFI_11R
1220 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001221 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001223
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001224 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001225 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001226 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001227 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001228 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001229 // pFTAssocRsp needs to point to the IEs
1230 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1231 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1232 (unsigned int)pFTAssocRsp[0],
1233 (unsigned int)pFTAssocRsp[1]);
1234 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001235 }
1236 else
1237 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001238 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1239 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001240 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001241
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001242 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001243 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001244 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001245 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001246 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001247 if(!ft_carrier_on)
1248 {
1249 // pFTAssocReq needs to point to the IEs
1250 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1251 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1252 (unsigned int)pFTAssocReq[0],
1253 (unsigned int)pFTAssocReq[1]);
1254 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1255 }
1256 else
1257 {
1258 /* This should contain only the FTIEs */
1259 assocReqlen = pRoamInfo->nAssocReqLength;
1260 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001261 }
1262 else
1263 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001264 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1265 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001266 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001267
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001268 if(ft_carrier_on)
1269 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001270 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
1271 "indication\n", __FUNCTION__, ft_carrier_on);
1272 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1273 (int)pRoamInfo->pBssDesc->channelId);
1274 hddLog(LOG1, "assocReqlen %d assocRsplen %d\n", assocReqlen,
1275 assocRsplen);
1276 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
1277 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1278 GFP_KERNEL);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301279 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1280 {
1281 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1282 pRoamInfo->fAuthRequired = FALSE;
1283
1284 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1285 pRoamInfo->bssid,
1286 HDD_MAC_ADDR_LEN);
1287 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1288 pRoamInfo->peerMac,
1289 HDD_MAC_ADDR_LEN);
1290 pHddStaCtx->roam_info.roamId = roamId;
1291 pHddStaCtx->roam_info.roamStatus = roamStatus;
1292 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1293 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001294 }
1295 else
1296 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001297 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
1298 "indication\n", __FUNCTION__, ft_carrier_on);
1299 cfg80211_connect_result(dev, pRoamInfo->bssid,
1300 pFTAssocReq, assocReqlen,
1301 pFTAssocRsp, assocRsplen,
1302 WLAN_STATUS_SUCCESS,
1303 GFP_KERNEL);
1304 cfg80211_put_bss(bss);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001305 }
1306 }
1307 else
1308#endif
1309 {
1310 /* wpa supplicant expecting WPA/RSN IE in connect result */
1311 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1312 pAdapter->sessionId,
1313 &reqRsnLength,
1314 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001315
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001316 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1317 pAdapter->sessionId,
1318 &rspRsnLength,
1319 rspRsnIe);
1320#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1321 if(ft_carrier_on)
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001322 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001323 else
1324#endif /* FEATURE_WLAN_CCX */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001325
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001326 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001327 /* inform connect result to nl80211 */
1328 cfg80211_connect_result(dev, pRoamInfo->bssid,
1329 reqRsnIe, reqRsnLength,
1330 rspRsnIe, rspRsnLength,
1331 WLAN_STATUS_SUCCESS,
1332 GFP_KERNEL);
1333
1334 cfg80211_put_bss(bss);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 // Register the Station with TL after associated...
1338 vosStatus = hdd_roamRegisterSTA( pAdapter,
1339 pRoamInfo,
1340 pHddStaCtx->conn_info.staId[ 0 ],
1341 NULL,
1342 pRoamInfo->pBssDesc );
1343 }
1344 else
1345 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001346 /* wpa supplicant expecting WPA/RSN IE in connect result */
1347 /* in case of reassociation also need to indicate it to supplicant */
1348 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1349 pAdapter->sessionId,
1350 &reqRsnLength,
1351 reqRsnIe);
1352
1353 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 //Reassoc successfully
Gopichand Nakkala29149562013-05-10 21:43:41 +05301355 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
1356 WLANTL_STA_CONNECTED );
1357 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1358 "%s: staId: %d Changing TL state to CONNECTED",
1359 __func__, pHddStaCtx->conn_info.staId[0]);
1360 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 }
1362
1363 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1364 {
1365 // perform any WMM-related association processing
1366 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1367 }
1368 else
1369 {
1370 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1371 "Cannot register STA with TL. Failed with vosStatus = %d [%08lX]",
1372 vosStatus, vosStatus );
1373 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001374#ifdef WLAN_FEATURE_11W
1375 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1376 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1377#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 // Start the Queue
1379 netif_tx_wake_all_queues(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001380 }
1381 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1384
1385 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001386 if (pRoamInfo)
1387 pr_info("wlan: connection failed with %02x:%02x:%02x:%02x:%02x:%02x"
1388 " reason:%d and Status:%d\n", pRoamInfo->bssid[0],
1389 pRoamInfo->bssid[1], pRoamInfo->bssid[2],
1390 pRoamInfo->bssid[3], pRoamInfo->bssid[4],
1391 pRoamInfo->bssid[5], roamResult, roamStatus);
1392 else
1393 pr_info("wlan: connection failed with %02x:%02x:%02x:%02x:%02x:%02x"
Jeff Johnson32d95a32012-09-10 13:15:23 -07001394 " reason:%d and Status:%d\n", pWextState->req_bssId[0],
1395 pWextState->req_bssId[1], pWextState->req_bssId[2],
1396 pWextState->req_bssId[3], pWextState->req_bssId[4],
1397 pWextState->req_bssId[5], roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001398
1399 /*Handle all failure conditions*/
1400 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1401 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
1402 {
1403 pHddCtx->isAmpAllowed = VOS_TRUE;
1404 }
1405
1406 //If the Device Mode is Station
1407 // and the P2P Client is Connected
1408 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001409
1410 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001411 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001412 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1413 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 (vos_concurrent_sessions_running()))
1415 {
1416 //Enable BMPS only of other Session is P2P Client
1417 hdd_context_t *pHddCtx = NULL;
1418 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1419
1420 if (NULL != pVosContext)
1421 {
1422 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1423
1424 if(NULL != pHddCtx)
1425 {
1426 //Only P2P Client is there Enable Bmps back
1427 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001428 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 {
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001430 if (pHddCtx->hdd_wlan_suspended)
1431 {
1432 if(WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
1433 {
1434 hdd_reset_pwrparams(pHddCtx);
1435 }
1436 else
1437 {
1438 hdd_set_pwrparams(pHddCtx);
1439 }
1440 }
1441
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 hdd_enable_bmps_imps(pHddCtx);
1443 }
1444 }
1445 }
1446 }
1447
James Zmudafbf5ffc2013-03-25 12:45:35 -07001448 /* CR465478: Only send up a connection failure result when CSR has
1449 * completed operation - with a ASSOCIATION_FAILURE status. */
1450 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus )
Jeff Johnsone7245742012-09-05 17:12:55 -07001451 {
James Zmudafbf5ffc2013-03-25 12:45:35 -07001452 /* inform association failure event to nl80211 */
1453 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1454 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001455 if (pRoamInfo)
1456 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1457 NULL, 0, NULL, 0,
1458 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1459 GFP_KERNEL );
1460 else
1461 cfg80211_connect_result ( dev, pWextState->req_bssId,
1462 NULL, 0, NULL, 0,
1463 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1464 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001465 }
1466 else
1467 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001468 if (pRoamInfo)
1469 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1470 NULL, 0, NULL, 0,
1471 WLAN_STATUS_UNSPECIFIED_FAILURE,
1472 GFP_KERNEL );
1473 else
1474 cfg80211_connect_result ( dev, pWextState->req_bssId,
1475 NULL, 0, NULL, 0,
1476 WLAN_STATUS_UNSPECIFIED_FAILURE,
1477 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001478 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001480
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001481 /*Clear the roam profile*/
1482 hdd_clearRoamProfileIe( pAdapter );
1483
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 netif_tx_disable(dev);
1485 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001486
Jeff Johnsone7245742012-09-05 17:12:55 -07001487 if (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode)
1488 {
1489 /* Association failed; Reset the country code information
1490 * so that it re-initialize the valid channel list*/
1491 hdd_ResetCountryCodeAfterDisAssoc(pAdapter);
1492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 }
1494
1495 return eHAL_STATUS_SUCCESS;
1496}
1497
1498/**============================================================================
1499 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001500 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001502
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001504static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1505 tCsrRoamInfo *pRoamInfo,
1506 tANI_U32 roamId,
1507 eRoamCmdStatus roamStatus,
1508 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001509{
Jeff Johnson81c17882013-05-03 09:53:35 -07001510 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1511 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1512
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 switch( roamResult )
1514 {
1515 // both IBSS Started and IBSS Join should come in here.
1516 case eCSR_ROAM_RESULT_IBSS_STARTED:
1517 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
1518 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001519 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1520 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001521
Jeff Johnson81c17882013-05-03 09:53:35 -07001522 if (NULL == pRoamInfo)
1523 {
1524 VOS_ASSERT(0);
1525 return;
1526 }
1527
1528 /* When IBSS Started comes from CSR, we need to move
1529 * connection state to IBSS Disconnected (meaning no peers
1530 * are in the IBSS).
1531 */
1532 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1533 eConnectionState_IbssDisconnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001534 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1535 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1536 IBSS_BROADCAST_STAID,
1537 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001538
Jeff Johnson81c17882013-05-03 09:53:35 -07001539 if (pRoamInfo->pBssDesc)
1540 {
1541 struct cfg80211_bss *bss;
1542
1543 /* we created the IBSS, notify supplicant */
1544 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1545 MAC_ADDRESS_STR,
1546 __func__, pAdapter->dev->name,
1547 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1548
1549 /* we must first give cfg80211 the BSS information */
1550 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1551 if (NULL == bss)
1552 {
1553 hddLog(VOS_TRACE_LEVEL_ERROR,
1554 "%s: %s: unable to create IBSS entry",
1555 __func__, pAdapter->dev->name);
1556 return;
1557 }
1558
1559 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
1560 cfg80211_put_bss(bss);
1561 }
1562
Shailender Karmuchia734f332013-04-19 14:02:48 -07001563 netif_carrier_on(pAdapter->dev);
1564 netif_tx_start_all_queues(pAdapter->dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 break;
1566 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001567
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1569 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001570 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1571 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 break;
1573 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001574
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001576 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1577 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001579 }
1580
Jeff Johnson81c17882013-05-03 09:53:35 -07001581 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001582}
1583
1584/**============================================================================
1585 *
1586 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1587 This information is passed to iwconfig later. The peer that joined
1588 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001589 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001591
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 ===========================================================================*/
1593static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1594{
1595 int fSuccess = FALSE;
1596 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001597
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1599 {
1600 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1601 {
1602 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001603
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001605
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 fSuccess = TRUE;
1607 break;
1608 }
1609 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001610
1611 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001612}
1613/**============================================================================
1614 *
1615 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001616 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001618
Jeff Johnson295189b2012-06-20 16:38:30 -07001619 ===========================================================================*/
1620static int roamRemoveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId )
1621{
1622 int fSuccess = FALSE;
1623 int idx = 0;
1624 v_U8_t valid_idx = 0;
1625 v_U8_t del_idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001626
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1628 {
1629 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1630 {
1631 pHddStaCtx->conn_info.staId[ idx ] = 0;
1632
1633 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1634
1635 fSuccess = TRUE;
1636 // Note the deleted Index, if its 0 we need special handling
1637 del_idx = idx;
1638 }
1639 else
1640 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001641 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 {
1643 valid_idx = idx;
1644 }
1645 }
1646 }
1647
1648 // Find next active staId, to have a valid sta trigger for TL.
1649 if (fSuccess == TRUE)
1650 {
1651 if (del_idx == 0)
1652 {
1653 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1654 {
1655 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1656 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1657 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1658
1659 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1660 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1661 }
1662 }
1663 }
1664 return( fSuccess );
1665}
1666
1667/**============================================================================
1668 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001669 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001671
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 ===========================================================================*/
1673static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1674{
1675 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "IBSS Connect Indication from SME!!!" );
1676 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1677 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1678
1679 // Save the connection info from CSR...
1680 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1681
1682 // Send the bssid address to the wext.
1683 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 /* add bss_id to cfg80211 data base */
1685 wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1686 /* send ibss join indication to nl80211 */
1687 cfg80211_ibss_joined(pAdapter->dev, &pRoamInfo->bssid[0], GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001688
1689 return( eHAL_STATUS_SUCCESS );
1690}
1691/**============================================================================
1692 *
1693 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001694
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001696static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1697 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 eCsrRoamResult roamResult )
1699{
1700 eCsrEncryptionType connectedCipherAlgo;
1701 v_BOOL_t fConnected = FALSE;
1702 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1703 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1704 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1705 ENTER();
1706 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001707 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 // not require upper layer authentication) we can put TL directly into 'authenticated'
1709 // state.
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001710
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1712 if( fConnected )
1713 {
1714 // TODO: Considering getting a state machine in HDD later.
Gopichand Nakkala29149562013-05-10 21:43:41 +05301715 // This routuine is invoked twice. 1)set PTK 2)set GTK.
1716 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1717 pHddStaCtx->conn_info.staId[ 0 ]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1719 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001720
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 EXIT();
1722 return( eHAL_STATUS_SUCCESS );
1723}
1724/**============================================================================
1725 *
1726 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
1727 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001728static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07001730{
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1732
1733 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
1734 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
1735 {
1736 struct iw_michaelmicfailure msg;
1737 union iwreq_data wreq;
1738 memset(&msg, '\0', sizeof(msg));
1739 msg.src_addr.sa_family = ARPHRD_ETHER;
1740 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
1741 hddLog(LOG1, "MIC MAC %02x:%02x:%02x:%02x:%02x:%02x",
1742 msg.src_addr.sa_data[0],
1743 msg.src_addr.sa_data[1],
1744 msg.src_addr.sa_data[2],
1745 msg.src_addr.sa_data[3],
1746 msg.src_addr.sa_data[4],
1747 msg.src_addr.sa_data[5]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001748
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
1750 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001751 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 msg.flags = IW_MICFAILURE_PAIRWISE;
1753 memset(&wreq, 0, sizeof(wreq));
1754 wreq.data.length = sizeof(msg);
1755 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001757 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 pRoamInfo->u.pMICFailureInfo->taMacAddr,
1759 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
1760 NL80211_KEYTYPE_GROUP :
1761 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07001762 pRoamInfo->u.pMICFailureInfo->keyId,
1763 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001765
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001767
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 return( eHAL_STATUS_SUCCESS );
1769}
1770
1771/**============================================================================
1772 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001773 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07001774 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001775
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001777static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1778 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 eCsrRoamResult roamResult )
1780{
1781 VOS_STATUS vosStatus;
1782
1783 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1784 switch( roamResult )
1785 {
1786 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
1787 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001788 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1789
1790 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07001792 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
1793 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
1794 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07001795 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001796
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
1798 {
1799 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1800 "New IBSS peer but we already have the max we can handle. Can't register this one" );
1801 break;
1802 }
1803
1804 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1805
Shailender Karmuchia734f332013-04-19 14:02:48 -07001806 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1807 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
1808 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
1809
1810 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 vosStatus = hdd_roamRegisterSTA( pAdapter,
1812 pRoamInfo,
1813 pRoamInfo->staId,
1814 (v_MACADDR_t *)pRoamInfo->peerMac,
1815 pRoamInfo->pBssDesc );
1816 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1817 {
1818 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1819 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08lX]",
1820 vosStatus, vosStatus );
1821 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001822
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 netif_carrier_on(pAdapter->dev);
1824 netif_tx_start_all_queues(pAdapter->dev);
1825 break;
1826 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001827
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 case eCSR_ROAM_RESULT_IBSS_CONNECT:
1829 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001830
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001832
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
1836 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001837 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001838
Shailender Karmuchia734f332013-04-19 14:02:48 -07001839 if ( !roamRemoveIbssStation( pHddStaCtx, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 {
1841 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1842 "IBSS peer departed by cannot find peer in our registration table with TL" );
1843 }
1844
Shailender Karmuchia734f332013-04-19 14:02:48 -07001845 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1846 "IBSS Peer Departed from SME "
1847 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
1848 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
1849 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
1850 pRoamInfo->staId );
1851
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
1853
1854 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
1855
1856 break;
1857 }
1858 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
1859 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001860 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1861 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07001862 // Stop only when we are inactive
1863 netif_tx_disable(pAdapter->dev);
1864 netif_carrier_off(pAdapter->dev);
1865 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001866
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 // Send the bssid address to the wext.
1868 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
1869 // clean up data path
1870 hdd_disconnect_tx_rx(pAdapter);
1871 break;
1872 }
1873 default:
1874 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001875
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001877
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 return( eHAL_STATUS_SUCCESS );
1879}
1880
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001881#ifdef FEATURE_WLAN_TDLS
1882/**============================================================================
1883 *
1884 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
1885 TL the new STA. This is called as part of ADD_STA in the TDLS setup
1886 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07001887
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001888 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001889VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
1890 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001891{
1892 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001893 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001894 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1895 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001896 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
1897 v_BOOL_t fConnected = FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001898
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001899 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1900 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001901 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001902 "%s not connected. ignored", __func__);
1903 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001904 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001905
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001906 /*
1907 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
1908 * be peer MAC, here we are wokrking on direct Link
1909 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001910 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001911
1912 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001913
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001914 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001915 sizeof(tSirMacAddr) );
1916
1917 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
1918 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1919
1920 /* set the QoS field appropriately ..*/
1921 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
1922 : (staDesc.ucQosEnabled = 0) ;
1923
1924 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
1925 TL QoS_enabled=%d\n", staDesc.ucQosEnabled );
1926
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001927 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001928
1929 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1930 "HDD register TL Sec_enabled= %d.\n", staDesc.ucProtectedFrame );
1931
Shailender Karmuchia734f332013-04-19 14:02:48 -07001932 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001933 * UMA is ready we inform TL to do frame translation.
1934 */
1935 staDesc.ucSwFrameTXXlation = 1;
1936 staDesc.ucSwFrameRXXlation = 1;
1937 staDesc.ucAddRmvLLC = 1;
1938
1939 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001940 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001941
1942 /* tdls Direct Link do not need bcastSig */
1943 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001944
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001945#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1946 if(staDesc.ucProtectedFrame)
1947 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1948 else
1949 staDesc.ucIsReplayCheckValid = VOS_FALSE;
1950#endif
1951
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001952 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001953
Shailender Karmuchia734f332013-04-19 14:02:48 -07001954 /* Register the Station with TL... */
1955 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
1956 hdd_rx_packet_cbk,
1957 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001958 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001959
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001960 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1961 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001962 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07001963 "%s: WLANTL_RegisterSTAClient() failed to register. \
1964 Status= %d [0x%08lX]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001965 return vosStatus;
1966 }
1967
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001968 return( vosStatus );
1969}
1970
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08001971static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1972{
1973 VOS_STATUS vosStatus;
1974 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1975 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1976 {
1977 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1978 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
1979 "Status= %d [0x%08lX]",
1980 __func__, staId, vosStatus, vosStatus );
1981 }
1982 return( vosStatus );
1983}
1984
1985
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001986/*
1987 * HDD interface between SME and TL to ensure TDLS client registration with
1988 * TL in case of new TDLS client is added and deregistration at the time
1989 * TDLS client is deleted.
1990 */
1991
Shailender Karmuchia734f332013-04-19 14:02:48 -07001992eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
1993 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001994 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07001995 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001996 eCsrRoamResult roamResult)
1997{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001998 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001999 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002000 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002001
2002#ifdef WLAN_FEATURE_TDLS_DEBUG
2003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Leee6bfe942013-02-05 15:01:19 -08002004 ("hdd_tdlsStatusUpdate: %s staIdx %d %02x:%02x:%02x:%02x:%02x:%02x \n"),
2005 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" :
2006 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
2007 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND" :
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002008 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND? "DEL_ALL_TDLS_PEER_IND" :
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002009 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER? "UPDATE_TDLS_PEER" :
Hoonki Leee6bfe942013-02-05 15:01:19 -08002010 "UNKNOWN",
2011 pRoamInfo->staId,
2012 pRoamInfo->peerMac[0],
2013 pRoamInfo->peerMac[1],
2014 pRoamInfo->peerMac[2],
2015 pRoamInfo->peerMac[3],
2016 pRoamInfo->peerMac[4],
2017 pRoamInfo->peerMac[5]) ;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002018#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002019 switch( roamResult )
2020 {
2021 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2022 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002023 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2024 {
2025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002026 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002027 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002028 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002029 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002030
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002031 /* check if there is available index for this new TDLS STA */
2032 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2033 {
2034 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2035 {
2036 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2037 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2038
2039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002040 ("TDLS: STA IDX at %d is %d "
2041 "of mac %02x:%02x:%02x:%02x:%02x:%02x"),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002042 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
2043 pRoamInfo->peerMac[0],
2044 pRoamInfo->peerMac[1],
2045 pRoamInfo->peerMac[2],
2046 pRoamInfo->peerMac[3],
2047 pRoamInfo->peerMac[4],
2048 pRoamInfo->peerMac[5]) ;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002049
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002050 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002051 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2052 status = eHAL_STATUS_SUCCESS ;
2053 break ;
2054 }
2055 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002056 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002057 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002058 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002059 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2060 "wlan_hdd_tdls_set_sta_id() failed");
2061 return VOS_FALSE;
2062 }
2063
2064 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2065 /* store the ucast signature which will be used later when
2066 registering to TL
2067 */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002068 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002069 }
2070 else
2071 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002072 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002074 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002075 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002076 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002077 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002078 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002079 break ;
2080 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002081 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2082 {
2083 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2084 {
2085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2086 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2087 }
2088 /* store the ucast signature which will be used later when
2089 * registering to TL
2090 */
2091 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2092 complete(&pAdapter->tdls_add_station_comp);
2093 break;
2094 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002095 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002096 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002097 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002098 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002099 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002100 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2101 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002102 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002104 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2105
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002106 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac);
2107 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2108 {
2109 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2110 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2111 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002112 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002113 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = NULL;
2114
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002115 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2116 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2117 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002118 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002119 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002120 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002121 break ;
2122 }
2123 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002124 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002125 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002126 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002127 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2128 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002129 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002130 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2131 "%s: Sending teardown to supplicant with reason code %u",
2132 __func__, pRoamInfo->reasonCode);
2133
2134#ifdef CONFIG_TDLS_IMPLICIT
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002135 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac);
2136 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002137#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002138 status = eHAL_STATUS_SUCCESS ;
2139 break ;
2140 }
2141 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2142 {
2143 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002144 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002145 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002146 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2147 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002148 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002150 ("hdd_tdlsStatusUpdate: staIdx %d %02x:%02x:%02x:%02x:%02x:%02x"),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002151 pHddCtx->tdlsConnInfo[staIdx].staId,
2152 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[0],
2153 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[1],
2154 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[2],
2155 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[3],
2156 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[4],
2157 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[5]) ;
2158 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2159 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2160 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002161
2162 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[staIdx] = NULL;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002163 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002164 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002165 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2166 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002167
2168 status = eHAL_STATUS_SUCCESS ;
2169 }
2170 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302171 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002172 break ;
2173 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002174 default:
2175 {
2176 break ;
2177 }
2178 }
2179
2180 return status ;
2181}
2182#endif
2183
Shailender Karmuchia734f332013-04-19 14:02:48 -07002184eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2186{
2187 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2188 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302189 hdd_wext_state_t *pWextState = NULL;
2190 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002191 VOS_STATUS status = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002192
2193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002194 "CSR Callback: status= %d result= %d roamID=%ld",
2195 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002196
2197 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302198 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002199 {
2200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302201 "invalid adapter or adapter has invalid magic");
2202 return eHAL_STATUS_FAILURE;
2203 }
2204
2205 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2206 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2207
2208 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2209 {
2210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2211 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002212 return eHAL_STATUS_FAILURE;
2213 }
2214
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 switch( roamStatus )
2216 {
2217 case eCSR_ROAM_SESSION_OPENED:
2218 if(pAdapter != NULL)
2219 {
2220 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2221 complete(&pAdapter->session_open_comp_var);
2222 }
2223 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002224
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002225#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 /* We did pre-auth,then we attempted a 11r or ccx reassoc.
2227 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002228 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 * interface down */
2230 case eCSR_ROAM_FT_REASSOC_FAILED:
2231 hddLog(LOG1, FL("Reassoc Failed\n"));
2232 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2233 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2234 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2236 }
2237 pHddStaCtx->ft_carrier_on = FALSE;
2238 break;
2239
2240 case eCSR_ROAM_FT_START:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002241 // When we roam for CCX and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002243 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 // eCSR_ROAM_SHOULD_ROAM will be received.
2245 // Where in we will not mark the link down
2246 // Also we want to stop tx at this point when we will be
2247 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002248 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 {
2250 struct net_device *dev = pAdapter->dev;
2251 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002252 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002253 * Deregister for this STA with TL with the objective to flush
2254 * all the packets for this STA from wmm_tx_queue. If not done here,
2255 * we would run into a race condition (CR390567) wherein TX
2256 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2257 * been deleted. And, these packets get assigned with a STA idx of
2258 * self-sta (since the peer STA has been deleted) and get transmitted
2259 * on the new channel before the reassoc request. Since there will be
2260 * no ACK on the new channel, each packet gets retransmitted which
2261 * takes several seconds before the transmission of reassoc request.
2262 * This leads to reassoc-timeout and roam failure.
2263 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002264 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2265 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2266 {
2267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2268 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2269 pHddStaCtx->conn_info.staId[0], status, status );
2270 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 }
2273 pHddStaCtx->ft_carrier_on = TRUE;
2274 break;
2275#endif
2276
2277 case eCSR_ROAM_SHOULD_ROAM:
2278 // Dont need to do anything
2279 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 struct net_device *dev = pAdapter->dev;
2281 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2282 // notify apps that we can't pass traffic anymore
2283 netif_tx_disable(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002284#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 if (pHddStaCtx->ft_carrier_on == FALSE)
2286 {
2287#endif
2288 netif_carrier_off(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 }
2291#endif
2292
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002293#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 //We should clear all sta register with TL, for now, only one.
2295 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2296 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2297 {
2298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2299 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2300 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002301 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002303#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 // Clear saved connection information in HDD
2305 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
2306 }
2307 break;
2308 case eCSR_ROAM_LOSTLINK:
2309 case eCSR_ROAM_DISASSOCIATED:
2310 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2313 "****eCSR_ROAM_DISASSOCIATED****");
2314 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2315 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2316 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
2317 hdd_conf_mcastbcast_filter((WLAN_HDD_GET_CTX(pAdapter)), FALSE);
2318 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2319 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002320#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07002321 if (pHddCtx->cfg_ini->isMcAddrListFilter)
2322 {
2323 /*Multicast addr filtering is enabled*/
Gopichand Nakkala0f276812013-02-24 14:45:51 +05302324 if (pAdapter->mc_addr_list.isFilterApplied)
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 {
2326 /*Filter applied during suspend mode*/
2327 /*Clear it here*/
Gopichand Nakkala0f276812013-02-24 14:45:51 +05302328 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 }
2330 }
2331#endif
2332
Jeff Johnsone7245742012-09-05 17:12:55 -07002333 if (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode)
2334 {
2335 /* Disconnected from current AP. Reset the country code information
2336 * so that it re-initialize the valid channel list*/
2337 hdd_ResetCountryCodeAfterDisAssoc(pAdapter);
2338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002339 }
2340 break;
2341 case eCSR_ROAM_IBSS_LEAVE:
2342 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2343 "****eCSR_ROAM_IBSS_LEAVE****");
2344 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2345 break;
2346 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2348 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Gopichand Nakkala29149562013-05-10 21:43:41 +05302349 if ( (roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
2350 ( (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2351 eCSR_ENCRYPT_TYPE_WEP40) ||
2352 (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2353 eCSR_ENCRYPT_TYPE_WEP104)
2354 ) &&
2355 (eCSR_AUTH_TYPE_SHARED_KEY != pWextState->roamProfile.AuthType.authType[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 )
2357 {
2358 v_U32_t roamId = 0;
2359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2360 "****WEP open authentication failed, trying with shared authentication****");
2361 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
2362 pWextState->roamProfile.AuthType.authType[0] = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2363 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2364 halStatus = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &(pWextState->roamProfile), &roamId);
2365 }
2366 else
2367 {
2368 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2369 }
2370
2371 break;
2372 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002373 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 pRoamInfo, roamId, roamStatus, roamResult );
2375 break;
2376 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002377 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2378 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 break;
2380
2381 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2382 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002383 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002384
2385 case eCSR_ROAM_MIC_ERROR_IND:
2386 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2387 break;
2388
2389 case eCSR_ROAM_SET_KEY_COMPLETE:
2390 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2391 break;
2392#ifdef WLAN_FEATURE_VOWIFI_11R
2393 case eCSR_ROAM_FT_RESPONSE:
2394 hdd_SendFTEvent(pAdapter);
2395 break;
2396#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002397#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002398 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002399 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002400 {
2401 /* Notify the supplicant of a new candidate */
2402 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2403 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002404 break;
2405#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002406
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2408 hdd_indicateMgmtFrame( pAdapter,
2409 pRoamInfo->nFrameLength,
2410 pRoamInfo->pbFrames,
2411 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302412 pRoamInfo->rxChan,
2413 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 break;
2415 case eCSR_ROAM_REMAIN_CHAN_READY:
2416 hdd_remainChanReadyHandler( pAdapter );
2417 break;
2418 case eCSR_ROAM_SEND_ACTION_CNF:
2419 hdd_sendActionCnf( pAdapter,
2420 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2421 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002422#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002423 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002424 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002425 roamId, roamStatus, roamResult );
2426 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002427 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2428 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2429 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002430#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002431#ifdef WLAN_FEATURE_11W
2432 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2433 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2434 pRoamInfo->pbFrames,
2435 pRoamInfo->frameType);
2436 break;
2437#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 default:
2439 break;
2440 }
2441 return( halStatus );
2442}
Shailender Karmuchia734f332013-04-19 14:02:48 -07002443eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002444{
2445 eCsrAuthType auth_type;
2446 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002447 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 {
2449 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002450 } else
2451 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 {
2453 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002454 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002455#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07002456 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 {
2458 // Check for 11r FT Authentication with PSK
2459 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002460 } else
2461 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002462 {
2463 // Check for 11R FT Authentication with 802.1X
2464 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002465 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002466#endif
2467#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002468 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 {
2470 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2471 } else
2472#endif /* FEATURE_WLAN_CCX */
Chet Lanctot186b5732013-03-18 10:26:30 -07002473#ifdef WLAN_FEATURE_11W
2474 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
2475 {
2476 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
2477 } else
2478#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002479 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2481 }
2482 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002483}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002484
Shailender Karmuchia734f332013-04-19 14:02:48 -07002485eCsrAuthType
2486hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002487{
2488 eCsrAuthType auth_type;
2489 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002490 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 {
2492 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002493 } else
2494 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002495 {
2496 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002497 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002498#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002499 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 {
2501 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002502 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002503#endif /* FEATURE_WLAN_CCX */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002504 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2506 }
2507 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2508 return auth_type;
2509}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002510
Shailender Karmuchia734f332013-04-19 14:02:48 -07002511eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002512hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002513{
2514 eCsrEncryptionType cipher_type;
2515 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002516 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 {
2518 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002519 }
2520 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 {
2522 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002523 }
2524 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 {
2526 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002527 }
2528 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002529 {
2530 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002531 }
2532 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2533 {
2534 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2535 }
2536 else
2537 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2539 }
2540 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2541 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002542}
Jeff Johnson295189b2012-06-20 16:38:30 -07002543/* To find if the MAC address is NULL */
2544static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
2545{
2546 int i;
2547 for (i = 0; i < length; i++)
2548 {
2549 if (0x00 != (macAddr[i]))
2550 {
2551 return FALSE;
2552 }
2553 }
2554 return TRUE;
2555} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08002556
Shailender Karmuchia734f332013-04-19 14:02:48 -07002557eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002558hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002559{
2560 eCsrEncryptionType cipher_type;
2561 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002562 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 {
2564 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002565 } else
2566 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 {
2568 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002569 } else
2570 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 {
2572 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002573 } else
2574 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 {
2576 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002577 } else
2578 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002580 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2581 } else
2582 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2584 }
2585 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2586 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002587}
Jeff Johnson295189b2012-06-20 16:38:30 -07002588
Shailender Karmuchia734f332013-04-19 14:02:48 -07002589static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
2590 struct ether_addr *pBssid,
2591 eCsrEncryptionType *pEncryptType,
2592 eCsrEncryptionType *mcEncryptType,
2593 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07002594#ifdef WLAN_FEATURE_11W
2595 u_int8_t *pMfpRequired,
2596 u_int8_t *pMfpCapable,
2597#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002598 u_int16_t gen_ie_len,
2599 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07002600{
2601 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002602 eHalStatus result;
2603 tDot11fIERSN dot11RSNIE;
2604 tDot11fIEWPA dot11WPAIE;
2605 tANI_U32 i;
2606 tANI_U8 *pRsnIe;
2607 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
2609
2610 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
2611 flag to 0 */
2612 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
2613 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
2614
2615 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002616 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
2617 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 return -EINVAL;
2619 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07002620 if ( gen_ie[0] == DOT11F_EID_RSN)
2621 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002623 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
2625 {
2626 return -EINVAL;
2627 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002628 // Skip past the EID byte and length byte
2629 pRsnIe = gen_ie + 2;
2630 RSNIeLen = gen_ie_len - 2;
2631 // Unpack the RSN IE
2632 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
2633 pRsnIe,
2634 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002636 // Copy out the encryption and authentication types
2637 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002638 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002639 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002640 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002641 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 but probably I suspect we can do something different*/
2643 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07002644 // Just translate the FIRST one
2645 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
2646 //dot11RSNIE.pwise_cipher_suite_count
2647 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
2648 //dot11RSNIE.gp_cipher_suite_count
2649 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07002650#ifdef WLAN_FEATURE_11W
2651 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
2652 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
2653#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07002655 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002657 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 {
2659 break;
2660 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002661 if ( hdd_IsMACAddrNULL( (u_char *) pBssid , sizeof( (char *) pBssid)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 {
2663 break;
2664 }
2665 // For right now, I assume setASSOCIATE() has passed in the bssid.
2666 vos_mem_copy(PMKIDCache[i].BSSID,
2667 pBssid, ETHER_ADDR_LEN);
2668 vos_mem_copy(PMKIDCache[i].PMKID,
2669 dot11RSNIE.pmkid[i],
2670 CSR_RSN_PMKID_SIZE);
2671 }
2672 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Shailender Karmuchia734f332013-04-19 14:02:48 -07002673 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %ld."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002674 __func__, i );
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 // Finally set the PMKSA ID Cache in CSR
2676 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002677 PMKIDCache,
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 dot11RSNIE.pmkid_count );
2679 }
2680 else if (gen_ie[0] == DOT11F_EID_WPA)
2681 {
2682 // Validity checks
2683 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
2684 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
2685 {
2686 return -EINVAL;
2687 }
2688 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07002689 pRsnIe = gen_ie + 2 + 4;
2690 RSNIeLen = gen_ie_len - (2 + 4);
2691 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
2693 pRsnIe,
2694 RSNIeLen,
2695 &dot11WPAIE);
2696 // Copy out the encryption and authentication types
2697 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002698 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002700 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 //dot11WPAIE.auth_suite_count
2702 // Just translate the FIRST one
2703 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
2704 //dot11WPAIE.unicast_cipher_count
2705 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
2706 //dot11WPAIE.unicast_cipher_count
2707 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
2708 }
2709 else
2710 {
2711 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002712 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 }
2714 return 0;
2715}
2716int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
2717{
2718 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2719 v_U32_t status = 0;
2720 eCsrEncryptionType RSNEncryptType;
2721 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07002722#ifdef WLAN_FEATURE_11W
2723 u_int8_t RSNMfpRequired;
2724 u_int8_t RSNMfpCapable;
2725#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 struct ether_addr bSsid; // MAC address of assoc peer
2727 // MAC address of assoc peer
2728 // But, this routine is only called when we are NOT associated.
2729 vos_mem_copy(bSsid.ether_addr_octet,
2730 pWextState->roamProfile.BSSIDs.bssid,
2731 sizeof(bSsid.ether_addr_octet));
2732 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
2733 {
2734 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07002735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 else
2737 {
2738 return 0;
2739 }
2740 // The actual processing may eventually be more extensive than this.
2741 // Right now, just consume any PMKIDs that are sent in by the app.
2742 status = hdd_ProcessGENIE(pAdapter,
2743 &bSsid, // MAC address of assoc peer
2744 &RSNEncryptType,
2745 &mcRSNEncryptType,
2746 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07002747#ifdef WLAN_FEATURE_11W
2748 &RSNMfpRequired,
2749 &RSNMfpCapable,
2750#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 pWextState->WPARSNIE[1]+2,
2752 pWextState->WPARSNIE);
2753 if (status == 0)
2754 {
2755 // Now copy over all the security attributes you have parsed out
2756 pWextState->roamProfile.EncryptionType.numEntries = 1;
2757 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002758
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
2760 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07002761
2762#ifdef WLAN_FEATURE_11W
2763 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
2764 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
2765#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002766 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 }
2768 return 0;
2769}
2770int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
2771{
2772 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2773 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
2774 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2775 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07002776
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 pRoamProfile->AuthType.numEntries = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002778 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d\n", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002779
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 switch( pHddStaCtx->conn_info.authType)
2781 {
2782 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2783#ifdef FEATURE_WLAN_CCX
2784 case eCSR_AUTH_TYPE_CCKM_WPA:
2785 case eCSR_AUTH_TYPE_CCKM_RSN:
2786#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002787 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
2788
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002790 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002792
Jeff Johnson295189b2012-06-20 16:38:30 -07002793#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002794 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
2795 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2796 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002797 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002798 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
2799 } else
2800 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002801 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002802 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 } else
2804#endif
2805 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2806 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002807 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
2808 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2810 == IW_AUTH_KEY_MGMT_PSK) {
2811 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002812 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 }
2816 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
2817#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002818 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
2819 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
2820 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002821 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002822 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002823 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07002824 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002825 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002826 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 } else
2828#endif
2829
2830#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07002831 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
2832 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002834 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07002835 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07002836 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2838 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002839 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 } else
2841#endif
2842
Chet Lanctot186b5732013-03-18 10:26:30 -07002843#ifdef WLAN_FEATURE_11W
2844 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
2845 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
2846 } else
2847#endif
2848
Shailender Karmuchia734f332013-04-19 14:02:48 -07002849 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002851 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
2852 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
2854 == IW_AUTH_KEY_MGMT_PSK) {
2855 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002856 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002860 break;
2861
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002863
2864 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 break;
2866 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002867
Jeff Johnson295189b2012-06-20 16:38:30 -07002868#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002869 hddLog( LOG1, "%s: In default, unknown auth type.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002870#endif /* FEATURE_WLAN_CCX */
2871 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
2872 break;
2873 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002874
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002876 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002877
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 EXIT();
2879 return 0;
2880}
2881
2882/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07002883
2884 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07002886 to the CSR roam profile.
2887
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 \param - dev - Pointer to the net device.
2889 - info - Pointer to the iw_request_info.
2890 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002891 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07002893
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 --------------------------------------------------------------------------*/
2895
Shailender Karmuchia734f332013-04-19 14:02:48 -07002896int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 struct iw_request_info *info,
2898 union iwreq_data *wrqu, char *extra)
2899{
2900 v_U32_t status = 0;
2901 hdd_wext_state_t *pWextState;
2902 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2903 v_U32_t roamId;
2904 tCsrRoamProfile *pRoamProfile;
2905 eMib_dot11DesiredBssType connectedBssType;
2906 eCsrAuthType RSNAuthType;
2907 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2908 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002909
2910 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2911
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 ENTER();
2913
2914 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2915 {
2916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2917 "%s:LOGP in Progress. Ignore!!!",__func__);
2918 return 0;
2919 }
2920
2921 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
2922 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
2923 return -EBUSY;
2924 }
2925 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
2926 return -EINVAL;
2927 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002928 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 {
2930 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
2931 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
2932 {
2933 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002934 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2936 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
2937
2938 if(VOS_STATUS_SUCCESS == vosStatus)
2939 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
2940 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2941 }
2942 }
2943 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002944 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 {
2946 return -EINVAL;
2947 }
2948 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002949 /** when cfg80211 defined, wpa_supplicant wext driver uses
2950 zero-length, null-string ssid for force disconnection.
2951 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 driver MUST return success */
2953 if ( 0 == wrqu->essid.length ) {
2954 return 0;
2955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002956
2957 status = hdd_wmm_get_uapsd_mask(pAdapter,
2958 &pWextState->roamProfile.uapsd_mask);
2959 if (VOS_STATUS_SUCCESS != status)
2960 {
2961 pWextState->roamProfile.uapsd_mask = 0;
2962 }
2963 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002964
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002966
2967 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
2969 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
2970 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002971
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 //set gen ie
2973 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
2974
2975 //set auth
2976 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
2977 }
2978#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002979 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 if (pAdapter->wapi_info.nWapiMode)
2981 {
2982 switch (pAdapter->wapi_info.wapiAuthMode)
2983 {
2984 case WAPI_AUTH_MODE_PSK:
2985 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002986 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 pRoamProfile->AuthType.numEntries = 1;
2988 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
2989 break;
2990 }
2991 case WAPI_AUTH_MODE_CERT:
2992 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002993 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 pRoamProfile->AuthType.numEntries = 1;
2995 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
2996 break;
2997 }
2998 } // End of switch
2999 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3000 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3001 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003002 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003003 pRoamProfile->EncryptionType.numEntries = 1;
3004 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3005 pRoamProfile->mcEncryptionType.numEntries = 1;
3006 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3007 }
3008 }
3009#endif /* FEATURE_WLAN_WAPI */
3010 /* if previous genIE is not NULL, update AssocIE */
3011 if (0 != pWextState->genIE.length)
3012 {
3013 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3014 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3015 pWextState->genIE.length);
3016 pWextState->assocAddIE.length = pWextState->genIE.length;
3017 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3018 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3019
3020 /* clear previous genIE after use it */
3021 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3022 }
3023
3024 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3025 pWextState->roamProfile.bWPSAssociation = FALSE;
3026
3027 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3028 pWextState->roamProfile.nAddIEAssocLength))
3029 pWextState->roamProfile.bWPSAssociation = TRUE;
3030
3031
3032 // Disable auto BMPS entry by PMC until DHCP is done
3033 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3034
Shailender Karmuchia734f332013-04-19 14:02:48 -07003035 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003037
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003038 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3039 {
3040 v_U8_t iniDot11Mode = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
3041 eHddDot11Mode hddDot11Mode = iniDot11Mode;
3042
3043 switch ( iniDot11Mode )
3044 {
3045 case eHDD_DOT11_MODE_AUTO:
3046 case eHDD_DOT11_MODE_11ac:
3047 case eHDD_DOT11_MODE_11ac_ONLY:
3048#ifdef WLAN_FEATURE_11AC
3049 hddDot11Mode = eHDD_DOT11_MODE_11ac;
3050#else
3051 hddDot11Mode = eHDD_DOT11_MODE_11n;
3052#endif
3053 break;
3054 case eHDD_DOT11_MODE_11n:
3055 case eHDD_DOT11_MODE_11n_ONLY:
3056 hddDot11Mode = eHDD_DOT11_MODE_11n;
3057 break;
3058 default:
3059 hddDot11Mode = iniDot11Mode;
3060 break;
3061 }
3062
3063 /* This call decides required channel bonding mode */
3064 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
3065 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
3066 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3067 }
3068 status = sme_RoamConnect( hHal,pAdapter->sessionId, &(pWextState->roamProfile),&roamId);
3069 pRoamProfile->ChannelInfo.ChannelList = NULL;
3070 pRoamProfile->ChannelInfo.numOfChannels = 0;
3071
3072 EXIT();
3073 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003074}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003075
Jeff Johnson295189b2012-06-20 16:38:30 -07003076/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003077
3078 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003080
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 \param - dev - Pointer to the net device.
3082 - info - Pointer to the iw_request_info.
3083 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003084 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003086
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003088int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 struct iw_request_info *info,
3090 struct iw_point *dwrq, char *extra)
3091{
3092 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003093 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3095 ENTER();
3096
3097 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3098 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3099 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3100 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3101 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3102 {
3103 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3104 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3105 dwrq->flags = 1;
3106 } else {
3107 memset(extra, 0, dwrq->length);
3108 dwrq->length = 0;
3109 dwrq->flags = 0;
3110 }
3111 EXIT();
3112 return 0;
3113}
3114/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003115
3116 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003118
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 \param - dev - Pointer to the net device.
3120 - info - Pointer to the iw_request_info.
3121 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003122 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003124
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 --------------------------------------------------------------------------*/
3126int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3127 union iwreq_data *wrqu,char *extra)
3128{
3129 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003130 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3132 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003133 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003135
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003137
3138 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3139 {
3140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3141 "%s:LOGP in Progress. Ignore!!!", __func__);
3142 return -EBUSY;
3143 }
3144
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 switch(wrqu->param.flags & IW_AUTH_INDEX)
3146 {
3147 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003148
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003150
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003152
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 case IW_AUTH_CIPHER_PAIRWISE:
3154 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003155 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003157 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3159 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3162 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003163 }
3164
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003166
3167 if( (IW_AUTH_KEY_MGMT_802_1X
3168 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3170 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003171 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003172 else
3173 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003174 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003177
3178 if( ( IW_AUTH_KEY_MGMT_802_1X
3179 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3181 /*Dynamic WEP key*/
3182 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3183 else
3184 /*Static WEP key*/
3185 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003186
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 }
3188 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003189
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003191 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 return -EINVAL;
3193 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003194
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 pRoamProfile->EncryptionType.numEntries = 1;
3196 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 break;
3199 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003200 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3202 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3203 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003204
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3206 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3207 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003208
3209 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3211 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003212
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003214
3215 if( ( IW_AUTH_KEY_MGMT_802_1X
3216 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3217 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3218
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003220
3221 else
3222 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003224
3225 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3226 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003228 if( ( IW_AUTH_KEY_MGMT_802_1X
3229 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3231 {
3232 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3233 }
3234 else
3235 {
3236 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3237 }
3238 }
3239 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003240
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003242 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 return -EINVAL;
3244 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003245
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 pRoamProfile->mcEncryptionType.numEntries = 1;
3247 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3248 }
3249 break;
3250
3251 case IW_AUTH_80211_AUTH_ALG:
3252 {
3253 /*Save the auth algo here and set auth type to SME Roam profile
3254 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003255 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003257
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3259 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3260
3261 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3262 /*Not supported*/
3263 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3264 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3265 }
3266 break;
3267
3268 case IW_AUTH_KEY_MGMT:
3269 {
3270#ifdef FEATURE_WLAN_CCX
3271#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3272 /*Check for CCKM AKM type */
3273 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003274 //hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
3275 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003276 /* Set the CCKM bit in authKeyMgmt */
3277 /* Right now, this breaks all ref to authKeyMgmt because our
3278 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 */
3280 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3281 /*Set the key management to 802.1X*/
3282 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
3283 pWextState->isCCXConnection = eANI_BOOLEAN_TRUE;
3284 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3285 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3286 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3287 /*Save the key management*/
3288 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3289 //pWextState->authKeyMgmt = wrqu->param.value;
3290 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3291 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3292 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3293 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3294 /*Save the key management anyway*/
3295 pWextState->authKeyMgmt = wrqu->param.value;
3296 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3297 /*Save the key management*/
3298 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3299 //pWextState->authKeyMgmt = wrqu->param.value;
3300 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3301 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3302 }
3303#else
3304 /*Save the key management*/
3305 pWextState->authKeyMgmt = wrqu->param.value;
3306#endif /* FEATURE_WLAN_CCX */
3307 }
3308 break;
3309
3310 case IW_AUTH_TKIP_COUNTERMEASURES:
3311 {
3312 if(wrqu->param.value) {
3313 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3314 "Counter Measure started %d", wrqu->param.value);
3315 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3316 }
3317 else {
3318 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3319 "Counter Measure stopped=%d", wrqu->param.value);
3320 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3321 }
3322 }
3323 break;
3324 case IW_AUTH_DROP_UNENCRYPTED:
3325 case IW_AUTH_WPA_ENABLED:
3326 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3327 case IW_AUTH_ROAMING_CONTROL:
3328 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003329
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003331
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003332 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 wrqu->param.flags & IW_AUTH_INDEX);
3334 break;
3335 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003336
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 EXIT();
3338 return 0;
3339}
3340/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003341
3342 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003344
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 \param - dev - Pointer to the net device.
3346 - info - Pointer to the iw_request_info.
3347 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003348 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003350
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 --------------------------------------------------------------------------*/
3352int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3353 union iwreq_data *wrqu,char *extra)
3354{
3355 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003356 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3358 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003359
3360 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3361 {
3362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3363 "%s:LOGP in Progress. Ignore!!!", __func__);
3364 return -EBUSY;
3365 }
3366
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 switch(pRoamProfile->negotiatedAuthType)
3368 {
3369 case eCSR_AUTH_TYPE_WPA_NONE:
3370 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3371 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3372 break;
3373 case eCSR_AUTH_TYPE_WPA:
3374 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3375 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3376 break;
3377#ifdef WLAN_FEATURE_VOWIFI_11R
3378 case eCSR_AUTH_TYPE_FT_RSN:
3379#endif
3380 case eCSR_AUTH_TYPE_RSN:
3381 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3382 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3383 break;
3384 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3385 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3386 break;
3387 case eCSR_AUTH_TYPE_SHARED_KEY:
3388 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3389 break;
3390 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003391 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3393 break;
3394 case eCSR_AUTH_TYPE_AUTOSWITCH:
3395 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3396 break;
3397 case eCSR_AUTH_TYPE_WPA_PSK:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003398 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3400 return -EIO;
3401#ifdef WLAN_FEATURE_VOWIFI_11R
3402 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3403#endif
3404 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07003405#ifdef WLAN_FEATURE_11W
3406 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3407#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003408 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3410 return -EIO;
3411 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003412 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3414 return -EIO;
3415 }
3416 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3417 {
3418 switch(pRoamProfile->negotiatedUCEncryptionType)
3419 {
3420 case eCSR_ENCRYPT_TYPE_NONE:
3421 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3422 break;
3423 case eCSR_ENCRYPT_TYPE_WEP40:
3424 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3425 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3426 break;
3427 case eCSR_ENCRYPT_TYPE_TKIP:
3428 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3429 break;
3430 case eCSR_ENCRYPT_TYPE_WEP104:
3431 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3432 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3433 break;
3434 case eCSR_ENCRYPT_TYPE_AES:
3435 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3436 break;
3437 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003438 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 return -EIO;
3440 }
3441 }
3442
Shailender Karmuchia734f332013-04-19 14:02:48 -07003443 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 {
3445 switch(pRoamProfile->negotiatedMCEncryptionType)
3446 {
3447 case eCSR_ENCRYPT_TYPE_NONE:
3448 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3449 break;
3450 case eCSR_ENCRYPT_TYPE_WEP40:
3451 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3452 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3453 break;
3454 case eCSR_ENCRYPT_TYPE_TKIP:
3455 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3456 break;
3457 case eCSR_ENCRYPT_TYPE_WEP104:
3458 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3459 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3460 break;
3461 case eCSR_ENCRYPT_TYPE_AES:
3462 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3463 break;
3464 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003465 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 return -EIO;
3467 }
3468 }
3469
3470 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003471 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 EXIT();
3473 return 0;
3474}
3475/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003476
3477 \brief iw_set_ap_address() -
3478 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003480
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 \param - dev - Pointer to the net device.
3482 - info - Pointer to the iw_request_info.
3483 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003484 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003486
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 --------------------------------------------------------------------------*/
3488int iw_set_ap_address(struct net_device *dev,
3489 struct iw_request_info *info,
3490 union iwreq_data *wrqu, char *extra)
3491{
3492 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3493 v_U8_t *pMacAddress=NULL;
3494 ENTER();
3495 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
3496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%02x:%02x:%02x:%02x:%02x:%02x",pMacAddress[0],pMacAddress[1],
3497 pMacAddress[2],pMacAddress[3],pMacAddress[4],pMacAddress[5]);
3498 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3499 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003500
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 return 0;
3502}
3503/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003504
3505 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 This function returns the BSSID to the wpa_supplicant
3507 \param - dev - Pointer to the net device.
3508 - info - Pointer to the iw_request_info.
3509 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003510 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003512
Jeff Johnson295189b2012-06-20 16:38:30 -07003513 --------------------------------------------------------------------------*/
3514int iw_get_ap_address(struct net_device *dev,
3515 struct iw_request_info *info,
3516 union iwreq_data *wrqu, char *extra)
3517{
3518 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3519 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3520
3521 ENTER();
3522
3523 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3524 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3525 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003526 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003527 }
3528 else
3529 {
3530 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
3531 }
3532 EXIT();
3533 return 0;
3534}
Jeff Johnsond13512a2012-07-17 11:42:19 -07003535
3536
3537/**---------------------------------------------------------------------------
3538
3539 \brief hdd_ResetCountryCodeAfterDisAssoc -
3540 This function reset the country code to default
Jeff Johnsona8a1a482012-12-12 16:49:33 -08003541 \param - pAdapter - Pointer to HDD adapter
Jeff Johnsond13512a2012-07-17 11:42:19 -07003542 \return - nothing
3543
3544 --------------------------------------------------------------------------*/
3545void hdd_ResetCountryCodeAfterDisAssoc(hdd_adapter_t *pAdapter)
3546{
3547 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3548 tSmeConfigParams smeConfig;
3549 eHalStatus status = eHAL_STATUS_SUCCESS;
3550 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
3551 tANI_U8 currentCountryCode[3] = SME_INVALID_COUNTRY_CODE;
3552
3553 sme_GetConfigParam(pHddCtx->hHal, &smeConfig);
3554
3555 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
3556 "%s: 11d is %s\n",__func__,
3557 smeConfig.csrConfig.Is11dSupportEnabled ? "Enabled" : "Disabled");
3558 /* Reset country code only when 11d is enabled
3559 */
3560 if (smeConfig.csrConfig.Is11dSupportEnabled)
3561 {
3562 sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, &defaultCountryCode[0]);
3563 sme_GetCurrentCountryCode(pHddCtx->hHal, &currentCountryCode[0]);
3564
Kiran Kumar Lokere439bfb12013-05-07 19:21:01 -07003565 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnsond13512a2012-07-17 11:42:19 -07003566 "%s: Default country code: %c%c%c, Current Country code: %c%c%c \n",
3567 __func__,
3568 defaultCountryCode[0], defaultCountryCode[1], defaultCountryCode[2],
3569 currentCountryCode[0], currentCountryCode[1], currentCountryCode[2]);
3570 /* Reset country code only when there is a mismatch
3571 * between current country code and default country code
3572 */
3573 if ((defaultCountryCode[0] != currentCountryCode[0]) ||
Kiran Kumar Lokere439bfb12013-05-07 19:21:01 -07003574 (defaultCountryCode[1] != currentCountryCode[1]))
Jeff Johnsond13512a2012-07-17 11:42:19 -07003575 {
Kiran Kumar Lokere439bfb12013-05-07 19:21:01 -07003576 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnsond13512a2012-07-17 11:42:19 -07003577 "%s: Disconnected from the AP/Assoc failed and "
3578 "resetting the country code to default\n",__func__);
3579 /*reset the country code of previous connection*/
3580 status = (int)sme_ChangeCountryCode(pHddCtx->hHal, NULL,
3581 &defaultCountryCode[0], pAdapter,
3582 pHddCtx->pvosContext
3583 );
3584 if( 0 != status )
3585 {
3586 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3587 "%s: failed to Reset the Country Code\n",__func__);
3588 }
3589 }
3590 }
Kiran4a17ebe2013-01-31 10:43:43 -08003591 else if (smeConfig.csrConfig.Is11hSupportEnabled)
3592 {
Kiran Kumar Lokere439bfb12013-05-07 19:21:01 -07003593 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Kiran4a17ebe2013-01-31 10:43:43 -08003594 "%s: Disconnected from the AP/Assoc failed and "
3595 "resetting the 5G power values to default", __func__);
3596 sme_ResetPowerValuesFor5G (pHddCtx->hHal);
3597 }
Jeff Johnsond13512a2012-07-17 11:42:19 -07003598}
3599
Chet Lanctot186b5732013-03-18 10:26:30 -07003600#ifdef WLAN_FEATURE_11W
3601/**---------------------------------------------------------------------------
3602
3603 \brief hdd_indicateUnprotMgmtFrame -
3604 This function forwards the unprotected management frame to the supplicant
3605 \param - pAdapter - Pointer to HDD adapter
3606 - nFrameLength - Length of the unprotected frame being passed
3607 - pbFrames - Pointer to the frame buffer
3608 - frameType - 802.11 frame type
3609 \return - nothing
3610
3611 --------------------------------------------------------------------------*/
3612void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
3613 tANI_U32 nFrameLength,
3614 tANI_U8* pbFrames,
3615 tANI_U8 frameType )
3616{
3617 tANI_U8 type = 0;
3618 tANI_U8 subType = 0;
3619
3620 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
3621 __func__, frameType, nFrameLength);
3622
3623 /* Sanity Checks */
3624 if (NULL == pAdapter)
3625 {
3626 hddLog( LOGE, FL("pAdapter is NULL"));
3627 return;
3628 }
3629
3630 if (NULL == pAdapter->dev)
3631 {
3632 hddLog( LOGE, FL("pAdapter->dev is NULL"));
3633 return;
3634 }
3635
3636 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
3637 {
3638 hddLog( LOGE, FL("pAdapter has invalid magic"));
3639 return;
3640 }
3641
3642 if( !nFrameLength )
3643 {
3644 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
3645 return;
3646 }
3647
3648 if (NULL == pbFrames) {
3649 hddLog( LOGE, FL("pbFrames is NULL"));
3650 return;
3651 }
3652
3653 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
3654 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
3655
3656 /* Get pAdapter from Destination mac address of the frame */
3657 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
3658 {
3659 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
3660 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
3661 }
3662 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
3663 {
3664 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
3665 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
3666 }
3667 else
3668 {
3669 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
3670 return;
3671 }
3672}
3673#endif