blob: 0218433cf6bd6e7421b472d9aac75a31d25d64ab [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 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
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
Jeff Johnson295189b2012-06-20 16:38:30 -070027
28/**========================================================================
29
30 \file wlan_hdd_hostapd.c
31 \brief WLAN Host Device Driver implementation
32
33 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
34
35 Qualcomm Confidential and Proprietary.
36
37 ========================================================================*/
38/**=========================================================================
39 EDIT HISTORY FOR FILE
40
41
42 This section contains comments describing changes made to the module.
43 Notice that changes are listed in reverse chronological order.
44
45 $Header:$ $DateTime: $ $Author: $
46
47
48 when who what, where, why
49 -------- --- --------------------------------------------------------
50 04/5/09 Shailender Created module.
51 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
52 ==========================================================================*/
53/*--------------------------------------------------------------------------
54 Include Files
55 ------------------------------------------------------------------------*/
56
57#include <linux/version.h>
58#include <linux/module.h>
59#include <linux/kernel.h>
60#include <linux/init.h>
61#include <linux/wireless.h>
62#include <linux/semaphore.h>
63#include <vos_api.h>
64#include <vos_sched.h>
65#include <linux/etherdevice.h>
66#include <wlan_hdd_includes.h>
67#include <qc_sap_ioctl.h>
68#include <wlan_hdd_hostapd.h>
69#include <sapApi.h>
70#include <sapInternal.h>
71#include <wlan_qct_tl.h>
72#include <wlan_hdd_softap_tx_rx.h>
73#include <wlan_hdd_main.h>
74#include <linux/netdevice.h>
75#include <linux/mmc/sdio_func.h>
76#include "wlan_nlink_common.h"
77#include "wlan_btc_svc.h"
78#include <bap_hdd_main.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070079#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070080#include "cfgApi.h"
81#include "wniCfgAp.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070082
Leo Chang0b0e45a2013-12-15 15:18:55 -080083#ifdef FEATURE_WLAN_CH_AVOID
84#include "wcnss_wlan.h"
85#endif /* FEATURE_WLAN_CH_AVOID */
86
Jeff Johnson295189b2012-06-20 16:38:30 -070087#define IS_UP(_dev) \
88 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
89#define IS_UP_AUTO(_ic) \
90 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
91#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070092#define WE_GET_STA_INFO_SIZE 30
93/* WEXT limition: MAX allowed buf len for any *
94 * IW_PRIV_TYPE_CHAR is 2Kbytes *
95 */
96#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -070097
Jeff Johnson295189b2012-06-20 16:38:30 -070098#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -070099
Leo Chang0b0e45a2013-12-15 15:18:55 -0800100#ifdef FEATURE_WLAN_CH_AVOID
101/* Channle/Freqency table */
102extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
103safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
104{
105 /*CH , SAFE, default safe */
106 {1 , VOS_TRUE}, //RF_CHAN_1,
107 {2 , VOS_TRUE}, //RF_CHAN_2,
108 {3 , VOS_TRUE}, //RF_CHAN_3,
109 {4 , VOS_TRUE}, //RF_CHAN_4,
110 {5 , VOS_TRUE}, //RF_CHAN_5,
111 {6 , VOS_TRUE}, //RF_CHAN_6,
112 {7 , VOS_TRUE}, //RF_CHAN_7,
113 {8 , VOS_TRUE}, //RF_CHAN_8,
114 {9 , VOS_TRUE}, //RF_CHAN_9,
115 {10 , VOS_TRUE}, //RF_CHAN_10,
116 {11 , VOS_TRUE}, //RF_CHAN_11,
117 {12 , VOS_TRUE}, //RF_CHAN_12,
118 {13 , VOS_TRUE}, //RF_CHAN_13,
119 {14 , VOS_TRUE}, //RF_CHAN_14,
120 {240, VOS_TRUE}, //RF_CHAN_240,
121 {244, VOS_TRUE}, //RF_CHAN_244,
122 {248, VOS_TRUE}, //RF_CHAN_248,
123 {252, VOS_TRUE}, //RF_CHAN_252,
124 {208, VOS_TRUE}, //RF_CHAN_208,
125 {212, VOS_TRUE}, //RF_CHAN_212,
126 {216, VOS_TRUE}, //RF_CHAN_216,
127 {36 , VOS_TRUE}, //RF_CHAN_36,
128 {40 , VOS_TRUE}, //RF_CHAN_40,
129 {44 , VOS_TRUE}, //RF_CHAN_44,
130 {48 , VOS_TRUE}, //RF_CHAN_48,
131 {52 , VOS_TRUE}, //RF_CHAN_52,
132 {56 , VOS_TRUE}, //RF_CHAN_56,
133 {60 , VOS_TRUE}, //RF_CHAN_60,
134 {64 , VOS_TRUE}, //RF_CHAN_64,
135 {100, VOS_TRUE}, //RF_CHAN_100,
136 {104, VOS_TRUE}, //RF_CHAN_104,
137 {108, VOS_TRUE}, //RF_CHAN_108,
138 {112, VOS_TRUE}, //RF_CHAN_112,
139 {116, VOS_TRUE}, //RF_CHAN_116,
140 {120, VOS_TRUE}, //RF_CHAN_120,
141 {124, VOS_TRUE}, //RF_CHAN_124,
142 {128, VOS_TRUE}, //RF_CHAN_128,
143 {132, VOS_TRUE}, //RF_CHAN_132,
144 {136, VOS_TRUE}, //RF_CHAN_136,
145 {140, VOS_TRUE}, //RF_CHAN_140,
146 {149, VOS_TRUE}, //RF_CHAN_149,
147 {153, VOS_TRUE}, //RF_CHAN_153,
148 {157, VOS_TRUE}, //RF_CHAN_157,
149 {161, VOS_TRUE}, //RF_CHAN_161,
150 {165, VOS_TRUE}, //RF_CHAN_165,
151};
152#endif /* FEATURE_WLAN_CH_AVOID */
153
Jeff Johnson295189b2012-06-20 16:38:30 -0700154/*---------------------------------------------------------------------------
155 * Function definitions
156 *-------------------------------------------------------------------------*/
157/**---------------------------------------------------------------------------
158
159 \brief hdd_hostapd_open() - HDD Open function for hostapd interface
160
161 This is called in response to ifconfig up
162
163 \param - dev Pointer to net_device structure
164
165 \return - 0 for success non-zero for failure
166
167 --------------------------------------------------------------------------*/
168int hdd_hostapd_open (struct net_device *dev)
169{
170 ENTER();
171
172 //Turn ON carrier state
173 netif_carrier_on(dev);
174 //Enable all Tx queues
175 netif_tx_start_all_queues(dev);
176
177 EXIT();
178 return 0;
179}
180/**---------------------------------------------------------------------------
181
182 \brief hdd_hostapd_stop() - HDD stop function for hostapd interface
183
184 This is called in response to ifconfig down
185
186 \param - dev Pointer to net_device structure
187
188 \return - 0 for success non-zero for failure
189
190 --------------------------------------------------------------------------*/
191int hdd_hostapd_stop (struct net_device *dev)
192{
193 ENTER();
194
195 //Stop all tx queues
196 netif_tx_disable(dev);
197
198 //Turn OFF carrier state
199 netif_carrier_off(dev);
200
201 EXIT();
202 return 0;
203}
204/**---------------------------------------------------------------------------
205
206 \brief hdd_hostapd_uninit() - HDD uninit function
207
208 This is called during the netdev unregister to uninitialize all data
209associated with the device
210
211 \param - dev Pointer to net_device structure
212
213 \return - void
214
215 --------------------------------------------------------------------------*/
216static void hdd_hostapd_uninit (struct net_device *dev)
217{
218 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
219
220 ENTER();
221
222 if (pHostapdAdapter && pHostapdAdapter->pHddCtx)
223 {
224 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter);
225
226 /* after uninit our adapter structure will no longer be valid */
227 pHostapdAdapter->dev = NULL;
228 }
229
230 EXIT();
231}
232
233
234/**============================================================================
235 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
236 transmitting packets. There are 2 versions of this function. One that uses
237 locked queue and other that uses lockless queues. Both have been retained to
238 do some performance testing
239 @param skb : [in] pointer to OS packet (sk_buff)
240 @param dev : [in] pointer to Libra network device
241
242 @return : NET_XMIT_DROP if packets are dropped
243 : NET_XMIT_SUCCESS if packet is enqueued succesfully
244 ===========================================================================*/
245int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
246{
247 return 0;
248}
249int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
250{
251 return 0;
252}
253
254int hdd_hostapd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
255{
256 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
257 hdd_priv_data_t priv_data;
258 tANI_U8 *command = NULL;
259 int ret = 0;
260
261 if (NULL == pAdapter)
262 {
263 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Agarwal Ashish971c2882013-10-30 20:11:12 +0530264 "%s: pAdapter is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700265 ret = -ENODEV;
266 goto exit;
267 }
268
Jeff Johnsone7245742012-09-05 17:12:55 -0700269 if ((!ifr) || (!ifr->ifr_data))
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 {
c_hpothuffdb5272013-10-02 16:42:35 +0530271 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
272 FL("ifr or ifr->ifr_data is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 ret = -EINVAL;
274 goto exit;
275 }
276
277 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(hdd_priv_data_t)))
278 {
c_hpothuffdb5272013-10-02 16:42:35 +0530279 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
280 FL("failed to copy data from user space"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 ret = -EFAULT;
282 goto exit;
283 }
284
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800285 if (priv_data.total_len <= 0 ||
Rajesh Chauhana0516c62014-01-30 16:11:18 -0800286 priv_data.total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800287 {
288 /* below we allocate one more byte for command buffer.
289 * To avoid addition overflow total_len should be
290 * smaller than INT_MAX. */
291 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800292 "%s: integer out of range", __func__);
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800293 ret = -EFAULT;
294 goto exit;
295 }
296
297 command = kmalloc((priv_data.total_len + 1), GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 if (!command)
299 {
300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800301 "%s: failed to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 ret = -ENOMEM;
303 goto exit;
304 }
305
306 if (copy_from_user(command, priv_data.buf, priv_data.total_len))
307 {
c_hpothuffdb5272013-10-02 16:42:35 +0530308 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
309 FL("failed to copy data from user space"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 ret = -EFAULT;
311 goto exit;
312 }
313
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800314 command[priv_data.total_len] = '\0';
315
Jeff Johnson295189b2012-06-20 16:38:30 -0700316 if ((SIOCDEVPRIVATE + 1) == cmd)
317 {
Agarwal Ashish8518d5d2013-12-05 20:16:44 +0530318 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
320
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 if(strncmp(command, "P2P_SET_NOA", 11) == 0 )
322 {
323 hdd_setP2pNoa(dev, command);
324 }
325 else if( strncmp(command, "P2P_SET_PS", 10) == 0 )
326 {
327 hdd_setP2pOpps(dev, command);
328 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700329
Rajeev Kumar8b373292014-01-08 20:36:55 -0800330#ifdef FEATURE_WLAN_BATCH_SCAN
331 else if( strncmp(command, "WLS_BATCHING", 12) == 0 )
332 {
333 ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command);
334 }
335#endif
336
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700337 /*
338 command should be a string having format
339 SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces>
340 */
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700341 if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700342 {
343 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700344 " Received Command to Set Preferred Channels for SAP in %s", __func__);
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700345
Mahesh Kumar Kalikot Veetil2aad8d82013-02-07 12:31:28 -0800346 ret = sapSetPreferredChannel(command);
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700347 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700348 }
349exit:
350 if (command)
351 {
352 kfree(command);
353 }
354 return ret;
355}
356
357/**---------------------------------------------------------------------------
358
359 \brief hdd_hostapd_set_mac_address() -
360 This function sets the user specified mac address using
361 the command ifconfig wlanX hw ether <mac adress>.
362
363 \param - dev - Pointer to the net device.
364 - addr - Pointer to the sockaddr.
365 \return - 0 for success, non zero for failure
366
367 --------------------------------------------------------------------------*/
368
369static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
370{
371 struct sockaddr *psta_mac_addr = addr;
372 ENTER();
373 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
374 EXIT();
375 return 0;
376}
377void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
378{
379 struct net_device *dev = (struct net_device *)usrDataForCallback;
380 v_BYTE_t we_custom_event[64];
381 union iwreq_data wrqu;
382#ifdef DISABLE_CONCURRENCY_AUTOSAVE
383 VOS_STATUS vos_status;
384 hdd_adapter_t *pHostapdAdapter;
385 hdd_ap_ctx_t *pHddApCtx;
386#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
387
388 /* event_name space-delimiter driver_module_name */
389 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
390 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
391 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
392
393 ENTER();
394
395#ifdef DISABLE_CONCURRENCY_AUTOSAVE
396 if (vos_concurrent_sessions_running())
397 {
398 /*
399 This timer routine is going to be called only when AP
400 persona is up.
401 If there are concurrent sessions running we do not want
402 to shut down the Bss.Instead we run the timer again so
403 that if Autosave is enabled next time and other session
404 was down only then we bring down AP
405 */
406 pHostapdAdapter = netdev_priv(dev);
407 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
408 vos_status = vos_timer_start(
409 &pHddApCtx->hdd_ap_inactivity_timer,
410 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
411 * 1000);
412 if (!VOS_IS_STATUS_SUCCESS(vos_status))
413 {
414 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
415 }
416 EXIT();
417 return;
418 }
419#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
420 memset(&we_custom_event, '\0', sizeof(we_custom_event));
421 memcpy(&we_custom_event, autoShutEvent, event_len);
422
423 memset(&wrqu, 0, sizeof(wrqu));
424 wrqu.data.length = event_len;
425
426 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
427 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
428
429 EXIT();
430}
431
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800432VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
433{
434 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
435 ptSapContext pSapCtx = NULL;
436 eHalStatus halStatus = eHAL_STATUS_FAILURE;
437 v_PVOID_t hHal = NULL;
438
439 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
440 "%s: UPDATE Beacon Params", __func__);
441
442 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
443 pSapCtx = VOS_GET_SAP_CB(pVosContext);
444 if ( NULL == pSapCtx )
445 {
446 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
447 "%s: Invalid SAP pointer from pvosGCtx", __func__);
448 return VOS_STATUS_E_FAULT;
449 }
450
451 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
452 if ( NULL == hHal ){
453 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
454 "%s: Invalid HAL pointer from pvosGCtx", __func__);
455 return VOS_STATUS_E_FAULT;
456 }
457 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
458 if(halStatus == eHAL_STATUS_FAILURE ){
459 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
460 "%s: Failed to update Beacon Params", __func__);
461 return VOS_STATUS_E_FAILURE;
462 }
463 }
464 return VOS_STATUS_SUCCESS;
465}
466
467void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
468{
469 v_U8_t staId = 0;
470 struct net_device *dev;
471 dev = (struct net_device *)usrDataForCallback;
472
Arif Hussain6d2a3322013-11-17 19:50:10 -0800473 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800474 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
475 {
476 if ( pHostapdAdapter->aStaInfo[staId].isUsed &&
477 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
478 {
479 //Disconnect all the stations
480 hdd_softap_sta_disassoc(pHostapdAdapter, &pHostapdAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
481 }
482 }
483}
484
485static int hdd_stop_p2p_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
486{
487 struct net_device *dev;
488 VOS_STATUS status = VOS_STATUS_SUCCESS;
489 dev = (struct net_device *)usrDataForCallback;
490 ENTER();
491 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
492 {
493 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
494 {
495 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting P2P link!!!!!!"));
496 }
497 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
498 }
499 EXIT();
500 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
501}
Jeff Johnson295189b2012-06-20 16:38:30 -0700502
503VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
504{
505 hdd_adapter_t *pHostapdAdapter;
506 hdd_ap_ctx_t *pHddApCtx;
507 hdd_hostapd_state_t *pHostapdState;
508 struct net_device *dev;
509 eSapHddEvent sapEvent;
510 union iwreq_data wrqu;
511 v_BYTE_t *we_custom_event_generic = NULL;
512 int we_event = 0;
513 int i = 0;
514 v_U8_t staId;
515 VOS_STATUS vos_status;
516 v_BOOL_t bWPSState;
517 v_BOOL_t bApActive = FALSE;
518 v_BOOL_t bAuthRequired = TRUE;
519 tpSap_AssocMacAddr pAssocStasArray = NULL;
520 char unknownSTAEvent[IW_CUSTOM_MAX+1];
521 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
522 v_BYTE_t we_custom_start_event[64];
523 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800524 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800525 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700526 struct iw_michaelmicfailure msg;
Jeff Johnson295189b2012-06-20 16:38:30 -0700527
528 dev = (struct net_device *)usrDataForCallback;
529 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530530
531 if ((NULL == pHostapdAdapter) ||
532 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
533 {
534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
535 "invalid adapter or adapter has invalid magic");
536 return eHAL_STATUS_FAILURE;
537 }
538
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
540 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
541 sapEvent = pSapEvent->sapHddEventCode;
542 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800543 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700544
545 switch(sapEvent)
546 {
547 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800548 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
550 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
551 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
552
553 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
554 vos_status = vos_event_set(&pHostapdState->vosEvent);
555
556 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
557 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 goto stopbss;
560 }
561 else
562 {
563 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
564 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +0530565 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
566 if (!VOS_IS_STATUS_SUCCESS(vos_status))
567 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700568 }
569
570 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
571 {
572 // AP Inactivity timer init and start
573 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
574 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
575 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800576 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700577
578 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
579 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800580 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700581
582 }
583 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
584 pHostapdState->bssState = BSS_START;
585
586 // Send current operating channel of SoftAP to BTC-ES
587 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
588
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 //Check if there is any group key pending to set.
590 if( pHddApCtx->groupKey.keyLength )
591 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700592 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
594 &pHddApCtx->groupKey ) )
595 {
596 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
597 "%s: WLANSAP_SetKeySta failed", __func__);
598 }
599 pHddApCtx->groupKey.keyLength = 0;
600 }
601 else if ( pHddApCtx->wepKey[0].keyLength )
602 {
603 int i=0;
604 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
605 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700606 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
608 &pHddApCtx->wepKey[i] ) )
609 {
610 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
611 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
612 }
613 pHddApCtx->wepKey[i].keyLength = 0;
614 }
615 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700616 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
617 startBssEvent = "SOFTAP.enabled";
618 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
619 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
620 memset(&wrqu, 0, sizeof(wrqu));
621 wrqu.data.length = strlen(startBssEvent);
622 we_event = IWEVCUSTOM;
623 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700624 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 break; //Event will be sent after Switch-Case stmt
626
627 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800628 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
630
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700631 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700632 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700633
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 goto stopbss;
636 case eSAP_STA_SET_KEY_EVENT:
637 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800638 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
640 return VOS_STATUS_SUCCESS;
641 case eSAP_STA_DEL_KEY_EVENT:
642 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800643 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 return VOS_STATUS_SUCCESS;
645 case eSAP_STA_MIC_FAILURE_EVENT:
646 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 memset(&msg, '\0', sizeof(msg));
648 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800649 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800650 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -0700651 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700652 msg.flags = IW_MICFAILURE_GROUP;
653 else
654 msg.flags = IW_MICFAILURE_PAIRWISE;
655 memset(&wrqu, 0, sizeof(wrqu));
656 wrqu.data.length = sizeof(msg);
657 we_event = IWEVMICHAELMICFAILURE;
658 we_custom_event_generic = (v_BYTE_t *)&msg;
659 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 /* inform mic failure to nl80211 */
661 cfg80211_michael_mic_failure(dev,
662 pSapEvent->sapevt.
663 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -0700664 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 NL80211_KEYTYPE_GROUP :
666 NL80211_KEYTYPE_PAIRWISE),
667 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
668 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
669 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 break;
671
672 case eSAP_STA_ASSOC_EVENT:
673 case eSAP_STA_REASSOC_EVENT:
674 wrqu.addr.sa_family = ARPHRD_ETHER;
675 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800676 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800677 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 we_event = IWEVREGISTERED;
679
680 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
681
682 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
683 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
684 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
685 {
686 bAuthRequired = FALSE;
687 }
688
689 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
690 {
c_hpothuffdb5272013-10-02 16:42:35 +0530691 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 TRUE,
693 pHddApCtx->uPrivacy,
694 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
695 0,
696 0,
697 (v_MACADDR_t *)wrqu.addr.sa_data,
698 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +0530699
700 if (!VOS_IS_STATUS_SUCCESS(vos_status))
701 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
702 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 }
704 else
705 {
c_hpothuffdb5272013-10-02 16:42:35 +0530706 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 FALSE,
708 pHddApCtx->uPrivacy,
709 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
710 0,
711 0,
712 (v_MACADDR_t *)wrqu.addr.sa_data,
713 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +0530714 if (!VOS_IS_STATUS_SUCCESS(vos_status))
715 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
716 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -0700717 }
718
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 // Stop AP inactivity timer
720 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
721 {
722 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
723 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800724 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -0800726#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800727 if (wake_lock_active(&pHddCtx->sap_wake_lock))
728 {
729 wake_unlock(&pHddCtx->sap_wake_lock);
730 }
Amar Singhal6144c002013-05-03 16:11:42 -0700731 wake_lock_timeout(&pHddCtx->sap_wake_lock, msecs_to_jiffies(HDD_SAP_WAKE_LOCK_DURATION));
Sameer Thalappil50dc0092013-02-19 17:23:33 -0800732#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700733#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
734 {
735 struct station_info staInfo;
736 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
737
738 memset(&staInfo, 0, sizeof(staInfo));
739 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
740 {
741 staInfo.assoc_req_ies =
742 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
743 staInfo.assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700744#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700745 staInfo.filled |= STATION_INFO_ASSOC_REQ_IES;
746#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 cfg80211_new_sta(dev,
748 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
749 &staInfo, GFP_KERNEL);
750 }
751 else
752 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800753 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 }
755 }
756#endif
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800757 pScanInfo = &pHddCtx->scan_info;
758 // Lets do abort scan to ensure smooth authentication for client
759 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
760 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +0530761 hdd_abort_mac_scan(pHddCtx, pHostapdAdapter->sessionId,
762 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800763 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700764
765 break;
766 case eSAP_STA_DISASSOC_EVENT:
767 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800768 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800769 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
771 hddLog(LOG1," User initiated disassociation");
772 else
773 hddLog(LOG1," MAC initiated disassociation");
774 we_event = IWEVEXPIRED;
775 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
776 if (!VOS_IS_STATUS_SUCCESS(vos_status))
777 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 return VOS_STATUS_E_FAILURE;
780 }
781 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
782
783 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
784 {
785 spin_lock_bh( &pHostapdAdapter->staInfo_lock );
786 // Start AP inactivity timer if no stations associated with it
787 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
788 {
789 if (pHostapdAdapter->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
790 {
791 bApActive = TRUE;
792 break;
793 }
794 }
795 spin_unlock_bh( &pHostapdAdapter->staInfo_lock );
796
797 if (bApActive == FALSE)
798 {
799 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
800 {
801 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
802 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800803 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 }
805 else
806 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
807 }
808 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700809#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
810 cfg80211_del_sta(dev,
811 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
812 GFP_KERNEL);
813#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800814 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +0530815 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
816 if (VOS_STATUS_SUCCESS != vos_status)
817 {
818 hddLog(LOGE, "%s: failed to update Beacon interval %d",
819 __func__, vos_status);
820 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 break;
822 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
823 {
824 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
825 union iwreq_data wreq;
826
827 down(&pHddApCtx->semWpsPBCOverlapInd);
828 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
829
830 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
831 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
832
833 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800834 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 memset(&wreq, 0, sizeof(wreq));
836 wreq.data.length = strlen(message); // This is length of message
837 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
838
839 return VOS_STATUS_SUCCESS;
840 }
841 case eSAP_ASSOC_STA_CALLBACK_EVENT:
842 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
843 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
844 { // List of associated stations
845 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
846 {
847 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
848 i+1,
849 pAssocStasArray->assocId,
850 pAssocStasArray->staId,
851 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
852 pAssocStasArray++;
853 }
854 }
855 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -0800856 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700858 case eSAP_INDICATE_MGMT_FRAME:
859 hdd_indicateMgmtFrame( pHostapdAdapter,
860 pSapEvent->sapevt.sapManagementFrameInfo.nFrameLength,
861 pSapEvent->sapevt.sapManagementFrameInfo.pbFrames,
862 pSapEvent->sapevt.sapManagementFrameInfo.frameType,
Chilam NG571c65a2013-01-19 12:27:36 +0530863 pSapEvent->sapevt.sapManagementFrameInfo.rxChan, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 return VOS_STATUS_SUCCESS;
865 case eSAP_REMAIN_CHAN_READY:
866 hdd_remainChanReadyHandler( pHostapdAdapter );
867 return VOS_STATUS_SUCCESS;
868 case eSAP_SEND_ACTION_CNF:
869 hdd_sendActionCnf( pHostapdAdapter,
870 ( eSAP_STATUS_SUCCESS ==
871 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
872 TRUE : FALSE );
873 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 case eSAP_UNKNOWN_STA_JOIN:
875 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
876 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
877 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
878 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
879 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
880 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
881 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
882 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
883 wrqu.data.pointer = unknownSTAEvent;
884 wrqu.data.length = strlen(unknownSTAEvent);
885 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +0530886 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 break;
888
889 case eSAP_MAX_ASSOC_EXCEEDED:
890 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
891 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
892 " one or more devices to enable the new device connection",
893 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
894 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
895 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
896 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
897 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
898 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
899 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
900 wrqu.data.pointer = maxAssocExceededEvent;
901 wrqu.data.length = strlen(maxAssocExceededEvent);
902 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -0800903 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 break;
905 case eSAP_STA_ASSOC_IND:
906 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800907
908 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800909 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800910 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
911 return VOS_STATUS_SUCCESS;
912
913 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
c_hpothuffdb5272013-10-02 16:42:35 +0530914 vos_status = hdd_stop_p2p_link(pHostapdAdapter, usrDataForCallback);
915 if (!VOS_IS_STATUS_SUCCESS(vos_status))
916 {
917 hddLog(LOGW, FL("hdd_stop_p2p_link failed %d"), vos_status);
918 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800919 return VOS_STATUS_SUCCESS;
920
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800922 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 goto stopbss;
924 return VOS_STATUS_SUCCESS;
925 }
926 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
927 return VOS_STATUS_SUCCESS;
928
929stopbss :
930 {
931 v_BYTE_t we_custom_event[64];
932 char *stopBssEvent = "STOP-BSS.response";//17
933 int event_len = strlen(stopBssEvent);
934
935 hddLog(LOG1, FL("BSS stop status = %s"),
936 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
937 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
938
939 /* Change the BSS state now since, as we are shutting things down,
940 * we don't want interfaces to become re-enabled */
941 pHostapdState->bssState = BSS_STOP;
942
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +0530943 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
944 {
945 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
946 {
947 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
948 if (!VOS_IS_STATUS_SUCCESS(vos_status))
949 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
950 }
951
952 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
953 if (!VOS_IS_STATUS_SUCCESS(vos_status))
954 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
955 }
956
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 /* Stop the pkts from n/w stack as we are going to free all of
958 * the TX WMM queues for all STAID's */
959 hdd_hostapd_stop(dev);
960
961 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +0530962 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
963 if (!VOS_IS_STATUS_SUCCESS(vos_status))
964 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700965
Amar Singhal37e6f052013-03-05 16:16:54 -0800966 /* once the event is set, structure dev/pHostapdAdapter should
967 * not be touched since they are now subject to being deleted
968 * by another thread */
969 if (eSAP_STOP_BSS_EVENT == sapEvent)
970 vos_event_set(&pHostapdState->vosEvent);
971
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 /* notify userspace that the BSS has stopped */
973 memset(&we_custom_event, '\0', sizeof(we_custom_event));
974 memcpy(&we_custom_event, stopBssEvent, event_len);
975 memset(&wrqu, 0, sizeof(wrqu));
976 wrqu.data.length = event_len;
977 we_event = IWEVCUSTOM;
978 we_custom_event_generic = we_custom_event;
979 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700980 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 }
982 return VOS_STATUS_SUCCESS;
983}
Chet Lanctot8cecea22014-02-11 19:09:36 -0800984
985int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -0800987 eCsrEncryptionType *pEncryptType,
988 eCsrEncryptionType *mcEncryptType,
989 eCsrAuthType *pAuthType,
990 v_BOOL_t *pMFPCapable,
991 v_BOOL_t *pMFPRequired,
992 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -0700993 u_int8_t *gen_ie )
994{
995 tDot11fIERSN dot11RSNIE;
996 tDot11fIEWPA dot11WPAIE;
997
998 tANI_U8 *pRsnIe;
999 tANI_U16 RSNIeLen;
1000
1001 if (NULL == halHandle)
1002 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001003 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 return -EINVAL;
1005 }
1006
1007 // Validity checks
1008 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1009 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1010 return -EINVAL;
1011 // Type check
1012 if ( gen_ie[0] == DOT11F_EID_RSN)
1013 {
1014 // Validity checks
1015 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1016 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1017 {
1018 return VOS_STATUS_E_FAILURE;
1019 }
1020 // Skip past the EID byte and length byte
1021 pRsnIe = gen_ie + 2;
1022 RSNIeLen = gen_ie_len - 2;
1023 // Unpack the RSN IE
1024 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1025 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1026 pRsnIe,
1027 RSNIeLen,
1028 &dot11RSNIE);
1029 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001030 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001031 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001032 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001033 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 /*Here we have followed the apple base code,
1035 but probably I suspect we can do something different*/
1036 //dot11RSNIE.akm_suite_count
1037 // Just translate the FIRST one
1038 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1039 //dot11RSNIE.pwise_cipher_suite_count
1040 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1041 //dot11RSNIE.gp_cipher_suite_count
1042 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1043 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001044 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1045 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001046
1047 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1048 } else
1049 if (gen_ie[0] == DOT11F_EID_WPA)
1050 {
1051 // Validity checks
1052 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1053 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1054 {
1055 return VOS_STATUS_E_FAILURE;
1056 }
1057 // Skip past the EID byte and length byte - and four byte WiFi OUI
1058 pRsnIe = gen_ie + 2 + 4;
1059 RSNIeLen = gen_ie_len - (2 + 4);
1060 // Unpack the WPA IE
1061 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1062 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1063 pRsnIe,
1064 RSNIeLen,
1065 &dot11WPAIE);
1066 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001067 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001068 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001069 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001070 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 //dot11WPAIE.auth_suite_count
1072 // Just translate the FIRST one
1073 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1074 //dot11WPAIE.unicast_cipher_count
1075 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1076 //dot11WPAIE.unicast_cipher_count
1077 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001078 *pMFPCapable = VOS_FALSE;
1079 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 }
1081 else
1082 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001083 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001084 return VOS_STATUS_E_FAILURE;
1085 }
1086 return VOS_STATUS_SUCCESS;
1087}
Leo Chang614d2072013-08-22 14:59:44 -07001088
Leo Chang0b0e45a2013-12-15 15:18:55 -08001089#ifdef FEATURE_WLAN_CH_AVOID
1090/**---------------------------------------------------------------------------
1091
1092 \brief hdd_hostapd_freq_to_chn() -
1093
1094 Input frequency translated into channel number
1095
1096 \param - freq input frequency with order of kHz
1097
1098 \return - corresponding channel number.
1099 incannot find correct channel number, return 0
1100
1101 --------------------------------------------------------------------------*/
1102v_U16_t hdd_hostapd_freq_to_chn
1103(
1104 v_U16_t freq
1105)
1106{
1107 int loop;
1108
1109 for (loop = 0; loop < NUM_20MHZ_RF_CHANNELS; loop++)
1110 {
1111 if (rfChannels[loop].targetFreq == freq)
1112 {
1113 return rfChannels[loop].channelNum;
1114 }
1115 }
1116
1117 return (0);
1118}
1119
1120/*==========================================================================
1121 FUNCTION sapUpdateUnsafeChannelList
1122
1123 DESCRIPTION
1124 Function Undate unsafe channel list table
1125
1126 DEPENDENCIES
1127 NA.
1128
1129 PARAMETERS
1130
1131 IN
1132 pSapCtx : SAP context pointer, include unsafe channel list
1133
1134 RETURN VALUE
1135 NONE
1136============================================================================*/
1137void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1138 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1139{
1140 v_U16_t i, j;
1141
1142 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1143 sizeof(pHddCtx->unsafeChannelList));
1144 if (0 == unsafeChannelCount)
1145 {
1146 pHddCtx->unsafeChannelCount = 0;
1147 }
1148 else
1149 {
1150 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1151 unsafeChannelList,
1152 unsafeChannelCount * sizeof(tANI_U16));
1153 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1154 }
1155
1156 /* Flush, default set all channel safe */
1157 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1158 {
1159 safeChannels[i].isSafe = VOS_TRUE;
1160 }
1161
1162 /* Try to find unsafe channel */
1163 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1164 {
1165 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1166 {
1167 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1168 {
1169 /* Found unsafe channel, update it */
1170 safeChannels[j].isSafe = VOS_FALSE;
1171 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1172 "%s : CH %d is not safe",
1173 __func__, pHddCtx->unsafeChannelList[i]);
1174 break;
1175 }
1176 }
1177 }
1178
1179 return;
1180}
1181
1182/**---------------------------------------------------------------------------
1183
1184 \brief hdd_hostapd_ch_avoid_cb() -
1185
1186 Avoid channel notification from FW handler.
1187 FW will send un-safe channle list to avoid overwrapping.
1188 hostapd should not use notified channel
1189
1190 \param - pAdapter HDD adapter pointer
1191 indParam channel avoid notification parameter
1192
1193 \return - None
1194
1195 --------------------------------------------------------------------------*/
1196void hdd_hostapd_ch_avoid_cb
1197(
1198 void *pAdapter,
1199 void *indParam
1200)
1201{
1202 hdd_adapter_t *pHostapdAdapter = NULL;
1203 hdd_context_t *hddCtxt;
1204 tSirChAvoidIndType *chAvoidInd;
1205 v_U8_t rangeLoop;
1206 v_U16_t channelLoop;
1207 v_U16_t dupCheck;
1208 v_U16_t startChannel;
1209 v_U16_t endChannel;
1210 v_U16_t unsafeChannelCount = 0;
1211 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1212 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001213 tHddAvoidFreqList hddAvoidFreqList;
1214 tANI_U32 i;
Leo Chang0b0e45a2013-12-15 15:18:55 -08001215
1216 /* Basic sanity */
1217 if ((NULL == pAdapter) || (NULL == indParam))
1218 {
1219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1220 "%s : Invalid arguments", __func__);
1221 return;
1222 }
1223
1224 hddCtxt = (hdd_context_t *)pAdapter;
1225 chAvoidInd = (tSirChAvoidIndType *)indParam;
1226 pVosContext = hddCtxt->pvosContext;
1227
1228 /* Make unsafe channel list */
1229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1230 "%s : band count %d",
1231 __func__, chAvoidInd->avoidRangeCount);
1232 vos_mem_zero((void *)unsafeChannelList,
1233 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1234 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1235 {
1236 startChannel = hdd_hostapd_freq_to_chn(
1237 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
1238 endChannel = hdd_hostapd_freq_to_chn(
1239 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1241 "%s : start %d : %d, end %d : %d",
1242 __func__,
1243 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1244 startChannel,
1245 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1246 endChannel);
1247 for (channelLoop = startChannel;
1248 channelLoop < (endChannel + 1);
1249 channelLoop++)
1250 {
1251 /* Channel duplicate check routine */
1252 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1253 {
1254 if (unsafeChannelList[dupCheck] == channelLoop)
1255 {
1256 /* This channel is duplicated */
1257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1258 "%s : found duplicated channel %d",
1259 __func__, channelLoop);
1260 break;
1261 }
1262 }
1263 if (dupCheck == unsafeChannelCount)
1264 {
1265 unsafeChannelList[unsafeChannelCount] = channelLoop;
1266 unsafeChannelCount++;
1267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1268 "%s : unsafe channel %d, count %d",
1269 __func__,
1270 channelLoop, unsafeChannelCount);
1271 }
1272 else
1273 {
1274 /* DUP, do nothing */
1275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1276 "%s : duplicated channel %d",
1277 __func__, channelLoop);
1278 }
1279 }
1280 }
1281 /* Update unsafe channel cache
1282 * WCN Platform Driver cache */
1283 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1284 unsafeChannelCount);
1285
1286 /* Store into local cache
1287 * Start with STA and later start SAP
1288 * in this scenario, local cache will be used */
1289 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1290 unsafeChannelList,
1291 unsafeChannelCount);
1292
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001293 /* generate vendor specific event */
1294 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1295 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1296 {
1297 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1298 chAvoidInd->avoidFreqRange[i].startFreq;
1299 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1300 chAvoidInd->avoidFreqRange[i].endFreq;
1301 }
1302 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1303
1304 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1305
Leo Chang0b0e45a2013-12-15 15:18:55 -08001306 /* Get SAP context first
1307 * SAP and P2PGO would not concurrent */
1308 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
1309 if ((pHostapdAdapter) && (unsafeChannelCount))
1310 {
1311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1312 "%s : Current operation channel %d",
1313 __func__,
1314 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1315 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1316 {
1317 if (((unsafeChannelList[channelLoop] ==
1318 pHostapdAdapter->sessionCtx.ap.operatingChannel)) &&
1319 (AUTO_CHANNEL_SELECT ==
1320 pHostapdAdapter->sessionCtx.ap.sapConfig.channel))
1321 {
1322 /* current operating channel is un-safe channel
1323 * restart driver */
1324 hdd_hostapd_stop(pHostapdAdapter->dev);
1325 break;
1326 }
1327 }
1328 }
1329
1330 return;
1331}
1332
1333#endif /* FEATURE_WLAN_CH_AVOID */
1334
Jeff Johnson295189b2012-06-20 16:38:30 -07001335int
1336static iw_softap_setparam(struct net_device *dev,
1337 struct iw_request_info *info,
1338 union iwreq_data *wrqu, char *extra)
1339{
1340 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001341 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 int *value = (int *)extra;
1343 int sub_cmd = value[0];
1344 int set_value = value[1];
1345 eHalStatus status;
1346 int ret = 0; /* success */
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001347 v_CONTEXT_t pVosContext;
1348
1349 if (!pHostapdAdapter || !pHostapdAdapter->pHddCtx)
1350 {
1351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1352 "%s: either hostapd Adapter is null or HDD ctx is null",
1353 __func__);
1354 return -1;
1355 }
1356
1357 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1358 if (!hHal)
1359 {
1360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1361 "%s: Hal ctx is null", __func__);
1362 return -1;
1363 }
1364
1365 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1366 if (!pVosContext)
1367 {
1368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1369 "%s: Vos ctx is null", __func__);
1370 return -1;
1371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001372
1373 switch(sub_cmd)
1374 {
1375
1376 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001377 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 {
1379 ret = -EIO;
1380 }
1381 break;
1382
1383 case QCSAP_PARAM_ACL_MODE:
1384 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
1385 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1386 {
1387 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1388 ret = -EINVAL;
1389 }
1390 else
1391 {
1392 WLANSAP_SetMode(pVosContext, set_value);
1393 }
1394 break;
1395 case QCSAP_PARAM_MAX_ASSOC:
1396 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1397 {
1398 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1399 ret = -EINVAL;
1400 }
1401 else
1402 {
1403 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
1404 {
1405 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
1406 "Setting it to max allowed and continuing"),
1407 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
1408 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
1409 }
1410 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
1411 set_value, NULL, eANI_BOOLEAN_FALSE);
1412 if ( status != eHAL_STATUS_SUCCESS )
1413 {
1414 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
1415 status);
1416 ret = -EIO;
1417 }
1418 }
1419 break;
1420
1421 case QCSAP_PARAM_HIDE_SSID:
1422 {
1423 eHalStatus status = eHAL_STATUS_SUCCESS;
1424 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
1425 if(eHAL_STATUS_SUCCESS != status)
1426 {
1427 hddLog(VOS_TRACE_LEVEL_ERROR,
1428 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001429 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 return status;
1431 }
1432 break;
1433 }
1434
Leo Chang614d2072013-08-22 14:59:44 -07001435 case QCSAP_PARAM_SET_MC_RATE:
1436 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07001437 tSirRateUpdateInd *rateUpdate;
1438
1439 rateUpdate = (tSirRateUpdateInd *)
1440 vos_mem_malloc(sizeof(tSirRateUpdateInd));
1441 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07001442 {
1443 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07001444 "%s: SET_MC_RATE indication alloc fail", __func__);
1445 ret = -1;
1446 break;
1447 }
1448 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
1449
1450 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
1451 /* Ignore unicast */
1452 rateUpdate->ucastDataRate = -1;
1453 rateUpdate->mcastDataRate24GHz = set_value;
1454 rateUpdate->mcastDataRate5GHz = set_value;
1455 rateUpdate->mcastDataRate24GHzTxFlag = 0;
1456 rateUpdate->mcastDataRate5GHzTxFlag = 0;
1457 status = sme_SendRateUpdateInd(hHal, rateUpdate);
1458 if (eHAL_STATUS_SUCCESS != status)
1459 {
1460 hddLog(VOS_TRACE_LEVEL_ERROR,
1461 "%s: SET_MC_RATE failed", __func__);
1462 vos_mem_free(rateUpdate);
1463 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07001464 }
1465 break;
1466 }
1467
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 default:
1469 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
1470 sub_cmd, set_value);
1471 ret = -EINVAL;
1472 break;
1473 }
1474
1475 return ret;
1476}
1477
1478
1479int
1480static iw_softap_getparam(struct net_device *dev,
1481 struct iw_request_info *info,
1482 union iwreq_data *wrqu, char *extra)
1483{
1484 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1485 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1486 int *value = (int *)extra;
1487 int sub_cmd = value[0];
1488 eHalStatus status;
1489 int ret = 0; /* success */
1490 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1491
1492 switch (sub_cmd)
1493 {
1494 case QCSAP_PARAM_MAX_ASSOC:
1495 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
1496 if (eHAL_STATUS_SUCCESS != status)
1497 {
c_hpothuffdb5272013-10-02 16:42:35 +05301498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1499 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 ret = -EIO;
1501 }
1502 break;
1503
1504 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001505 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 {
c_hpothuffdb5272013-10-02 16:42:35 +05301507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1508 FL("WLANSAP_ClearACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 ret = -EIO;
1510 }
1511 *value = 0;
1512 break;
1513
1514 case QCSAP_PARAM_MODULE_DOWN_IND:
1515 {
1516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001517 "%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
1519#ifdef WLAN_BTAMP_FEATURE
1520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001521 "%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
1523#endif
1524 *value = 0;
1525 break;
Jeff Johnson43971f52012-07-17 12:26:56 -07001526 }
1527
1528 case QCSAP_PARAM_GET_WLAN_DBG:
1529 {
1530 vos_trace_display();
1531 *value = 0;
1532 break;
1533 }
1534
1535 case QCSAP_PARAM_AUTO_CHANNEL:
1536 {
1537 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
1538 break;
1539 }
1540
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 default:
1542 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
1543 ret = -EINVAL;
1544 break;
1545
1546 }
1547
1548 return ret;
1549}
1550
1551/* Usage:
1552 BLACK_LIST = 0
1553 WHITE_LIST = 1
1554 ADD MAC = 0
1555 REMOVE MAC = 1
1556
1557 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
1558 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
1559 while using this ioctl
1560
1561 Syntax:
1562 iwpriv softap.0 modify_acl
1563 <6 octet mac addr> <list type> <cmd type>
1564
1565 Examples:
1566 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
1567 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
1568 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
1569 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
1570*/
1571int iw_softap_modify_acl(struct net_device *dev, struct iw_request_info *info,
1572 union iwreq_data *wrqu, char *extra)
1573{
1574 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1575 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1576 v_BYTE_t *value = (v_BYTE_t*)extra;
1577 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
1578 int listType, cmd, i;
1579 int ret = 0; /* success */
1580
1581 ENTER();
1582 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
1583 {
1584 pPeerStaMac[i] = *(value+i);
1585 }
1586 listType = (int)(*(value+i));
1587 i++;
1588 cmd = (int)(*(value+i));
1589
Arif Hussain24bafea2013-11-15 15:10:03 -08001590 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
1591 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07001592
1593 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
1594 != VOS_STATUS_SUCCESS)
1595 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001596 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 ret = -EIO;
1598 }
1599 EXIT();
1600 return ret;
1601}
1602
1603int
1604static iw_softap_getchannel(struct net_device *dev,
1605 struct iw_request_info *info,
1606 union iwreq_data *wrqu, char *extra)
1607{
1608 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1609
Jeff Johnson43971f52012-07-17 12:26:56 -07001610 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07001611
Jeff Johnson43971f52012-07-17 12:26:56 -07001612 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 return 0;
1614}
1615
Jeff Johnsone7245742012-09-05 17:12:55 -07001616int
schang86c22c42013-03-13 18:41:24 -07001617static iw_softap_set_max_tx_power(struct net_device *dev,
Jeff Johnsone7245742012-09-05 17:12:55 -07001618 struct iw_request_info *info,
1619 union iwreq_data *wrqu, char *extra)
1620{
1621 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1622 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
schang86c22c42013-03-13 18:41:24 -07001623 int *value = (int *)extra;
Jeff Johnsone7245742012-09-05 17:12:55 -07001624 int set_value;
1625 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
1626 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
1627
schang86c22c42013-03-13 18:41:24 -07001628 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07001629 return -ENOMEM;
1630
Leo Changd37675a2013-08-01 13:19:45 -07001631 /* Assign correct slef MAC address */
1632 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
1633 VOS_MAC_ADDR_SIZE);
1634 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
1635 VOS_MAC_ADDR_SIZE);
1636
schang86c22c42013-03-13 18:41:24 -07001637 set_value = value[0];
1638 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
1639 {
1640 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001641 __func__);
schang86c22c42013-03-13 18:41:24 -07001642 return -EIO;
1643 }
1644
1645 return 0;
1646}
1647
1648int
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05301649static iw_display_data_path_snapshot(struct net_device *dev,
1650 struct iw_request_info *info,
1651 union iwreq_data *wrqu, char *extra)
1652{
1653
1654 /* Function intitiating dumping states of
1655 * HDD(WMM Tx Queues)
1656 * TL State (with Per Client infor)
1657 * DXE Snapshot (Called at the end of TL Snapshot)
1658 */
1659 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1660 hddLog(LOGE, "%s: called for SAP",__func__);
1661 hdd_wmm_tx_snapshot(pHostapdAdapter);
1662 WLANTL_TLDebugMessage(VOS_TRUE);
1663 return 0;
1664}
1665
1666int
schang86c22c42013-03-13 18:41:24 -07001667static iw_softap_set_tx_power(struct net_device *dev,
1668 struct iw_request_info *info,
1669 union iwreq_data *wrqu, char *extra)
1670{
1671 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1672 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1673 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1674 int *value = (int *)extra;
1675 int set_value;
1676 ptSapContext pSapCtx = NULL;
1677
1678 if (NULL == value)
1679 return -ENOMEM;
1680
1681 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1682 if (NULL == pSapCtx)
1683 {
1684 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1685 "%s: Invalid SAP pointer from pvosGCtx", __func__);
1686 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07001687 }
1688
1689 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07001690 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07001691 {
schang86c22c42013-03-13 18:41:24 -07001692 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07001693 __func__);
1694 return -EIO;
1695 }
1696
1697 return 0;
1698}
1699
Kiet Lambcf38522013-10-26 18:28:27 +05301700/**---------------------------------------------------------------------------
1701
1702 \brief iw_softap_set_trafficmonitor() -
1703 This function dynamically enable/disable traffic monitor functonality
1704 the command iwpriv wlanX setTrafficMon <value>.
1705
1706 \param - dev - Pointer to the net device.
1707 - addr - Pointer to the sockaddr.
1708 \return - 0 for success, non zero for failure
1709
1710 --------------------------------------------------------------------------*/
1711
1712static int iw_softap_set_trafficmonitor(struct net_device *dev,
1713 struct iw_request_info *info,
1714 union iwreq_data *wrqu, char *extra)
1715{
1716 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1717 int *isSetTrafficMon = (int *)wrqu->data.pointer;
1718 hdd_context_t *pHddCtx;
1719 int status;
1720
1721 if (NULL == pAdapter)
1722 {
1723 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1724 "%s: HDD adapter is Null", __func__);
1725 return -ENODEV;
1726 }
1727
1728 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1729
1730 status = wlan_hdd_validate_context(pHddCtx);
1731
1732 if (0 != status)
1733 {
1734 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1735 "%s: HDD context is not valid", __func__);
1736 return status;
1737 }
1738
1739 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
1740
1741 if (NULL == isSetTrafficMon)
1742 {
1743 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1744 "%s: Invalid SAP pointer from extra", __func__);
1745 return -ENOMEM;
1746 }
1747
1748 if (TRUE == *isSetTrafficMon)
1749 {
1750 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
1751 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
1752 {
1753 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
1754 "%s: failed to Start Traffic Monitor timer ", __func__ );
1755 return -EIO;
1756 }
1757 }
1758 else if (FALSE == *isSetTrafficMon)
1759 {
1760 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
1761 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
1762 {
1763 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
1764 "%s: failed to Stop Traffic Monitor timer ", __func__ );
1765 return -EIO;
1766 }
1767
1768 }
1769 return 0;
1770}
1771
Jeff Johnson295189b2012-06-20 16:38:30 -07001772#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
1773
1774int
1775static iw_softap_getassoc_stamacaddr(struct net_device *dev,
1776 struct iw_request_info *info,
1777 union iwreq_data *wrqu, char *extra)
1778{
1779 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07001780 unsigned int maclist_index;
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 hdd_station_info_t *pStaInfo = pHostapdAdapter->aStaInfo;
Arif Hussained667642013-10-27 23:01:14 -07001782 char maclist_null = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 int cnt = 0, len;
1784
1785
Arif Hussained667642013-10-27 23:01:14 -07001786 maclist_index = sizeof(unsigned long int);
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 len = wrqu->data.length;
1788
1789 spin_lock_bh( &pHostapdAdapter->staInfo_lock );
1790 while((cnt < WLAN_MAX_STA_COUNT) && (len > (sizeof(v_MACADDR_t)+1))) {
1791 if (TRUE == pStaInfo[cnt].isUsed) {
1792
1793 if(!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes)) {
Arif Hussained667642013-10-27 23:01:14 -07001794 if (copy_to_user((void *)wrqu->data.pointer + maclist_index,
1795 (void *)&(pStaInfo[cnt].macAddrSTA), sizeof(v_MACADDR_t)))
1796 {
1797 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1798 return -EFAULT;
1799 }
1800 maclist_index += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -07001801 len -= sizeof(v_MACADDR_t);
1802 }
1803 }
1804 cnt++;
1805 }
1806 spin_unlock_bh( &pHostapdAdapter->staInfo_lock );
1807
Mahesh A Saptasagar1953afe2014-02-13 15:05:02 +05301808 wrqu->data.length -= len;
Arif Hussained667642013-10-27 23:01:14 -07001809 if (copy_to_user((void *)wrqu->data.pointer + maclist_index,
1810 (void *)&maclist_null, sizeof(maclist_null)) ||
1811 copy_to_user((void *)wrqu->data.pointer,
Mahesh A Saptasagar1953afe2014-02-13 15:05:02 +05301812 (void *)&wrqu->data.length, sizeof(unsigned long int)))
Arif Hussained667642013-10-27 23:01:14 -07001813 {
1814 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1815 return -EFAULT;
1816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001817
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 return 0;
1819}
1820
1821/* Usage:
1822 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
1823 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
1824 while using this ioctl
1825
1826 Syntax:
1827 iwpriv softap.0 disassoc_sta <6 octet mac address>
1828
1829 e.g.
1830 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
1831 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
1832*/
1833
1834int
1835static iw_softap_disassoc_sta(struct net_device *dev,
1836 struct iw_request_info *info,
1837 union iwreq_data *wrqu, char *extra)
1838{
1839 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1840 v_U8_t *peerMacAddr;
1841
1842 ENTER();
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05301843 /* iwpriv tool or framework calls this ioctl with
1844 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05301846 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07001847
Arif Hussain24bafea2013-11-15 15:10:03 -08001848 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
1849 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
1851 EXIT();
1852 return 0;
1853}
1854
1855int
1856static iw_softap_ap_stats(struct net_device *dev,
1857 struct iw_request_info *info,
1858 union iwreq_data *wrqu, char *extra)
1859{
1860 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1861 WLANTL_TRANSFER_STA_TYPE statBuffer;
1862 char *pstatbuf;
1863 int len = wrqu->data.length;
1864 pstatbuf = wrqu->data.pointer;
1865
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001866 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07001867 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1868 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07001869
Arif Hussained667642013-10-27 23:01:14 -07001870 pstatbuf = kmalloc(wrqu->data.length, GFP_KERNEL);
1871 if(NULL == pstatbuf) {
1872 hddLog(LOG1, "unable to allocate memory");
1873 return -ENOMEM;
1874 }
1875 len = scnprintf(pstatbuf, wrqu->data.length,
1876 "RUF=%d RMF=%d RBF=%d "
1877 "RUB=%d RMB=%d RBB=%d "
1878 "TUF=%d TMF=%d TBF=%d "
1879 "TUB=%d TMB=%d TBB=%d",
1880 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
1881 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
1882 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
1883 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
1884 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
1885 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07001886
Arif Hussained667642013-10-27 23:01:14 -07001887 if (len > wrqu->data.length ||
1888 copy_to_user((void *)wrqu->data.pointer, (void *)pstatbuf, len))
1889 {
1890 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1891 kfree(pstatbuf);
1892 return -EFAULT;
1893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 wrqu->data.length -= len;
Arif Hussained667642013-10-27 23:01:14 -07001895 kfree(pstatbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 return 0;
1897}
1898
1899int
1900static iw_softap_commit(struct net_device *dev,
1901 struct iw_request_info *info,
1902 union iwreq_data *wrqu, char *extra)
1903{
1904 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1905 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1906 hdd_hostapd_state_t *pHostapdState;
1907 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1908 tpWLAN_SAPEventCB pSapEventCallback;
1909 tsap_Config_t *pConfig;
1910 s_CommitConfig_t *pCommitConfig;
1911 struct qc_mac_acl_entry *acl_entry = NULL;
1912 v_SINT_t i = 0, num_mac = 0;
1913 v_U32_t status = 0;
1914 eCsrAuthType RSNAuthType;
1915 eCsrEncryptionType RSNEncryptType;
1916 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot8cecea22014-02-11 19:09:36 -08001917 v_BOOL_t MFPCapable;
1918 v_BOOL_t MFPRequired;
Jeff Johnson295189b2012-06-20 16:38:30 -07001919
1920 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1921 pCommitConfig = (s_CommitConfig_t *)extra;
1922
c_hpothuffdb5272013-10-02 16:42:35 +05301923 pConfig = (tsap_Config_t *)vos_mem_malloc(sizeof(tsap_Config_t));
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 if(NULL == pConfig) {
c_hpothuffdb5272013-10-02 16:42:35 +05301925 hddLog(LOGE, FL("VOS unable to allocate memory"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 return -ENOMEM;
1927 }
1928 pConfig->beacon_int = pCommitConfig->beacon_int;
1929 pConfig->channel = pCommitConfig->channel;
1930
1931 /*Protection parameter to enable or disable*/
1932 pConfig->protEnabled = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1933 pConfig->dtim_period = pCommitConfig->dtim_period;
1934 switch(pCommitConfig->hw_mode )
1935 {
1936 case eQC_DOT11_MODE_11A:
1937 pConfig->SapHw_mode = eSAP_DOT11_MODE_11a;
1938 break;
1939 case eQC_DOT11_MODE_11B:
1940 pConfig->SapHw_mode = eSAP_DOT11_MODE_11b;
1941 break;
1942 case eQC_DOT11_MODE_11G:
1943 pConfig->SapHw_mode = eSAP_DOT11_MODE_11g;
1944 break;
1945
1946 case eQC_DOT11_MODE_11N:
1947 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
1948 break;
1949 case eQC_DOT11_MODE_11G_ONLY:
1950 pConfig->SapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1951 break;
1952 case eQC_DOT11_MODE_11N_ONLY:
1953 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n_ONLY;
1954 break;
1955 default:
1956 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
1957 break;
1958
1959 }
1960
1961 pConfig->ieee80211d = pCommitConfig->qcsap80211d;
1962 vos_mem_copy(pConfig->countryCode, pCommitConfig->countryCode, 3);
1963 if(pCommitConfig->authType == eQC_AUTH_TYPE_SHARED_KEY)
1964 pConfig->authType = eSAP_SHARED_KEY;
1965 else if(pCommitConfig->authType == eQC_AUTH_TYPE_OPEN_SYSTEM)
1966 pConfig->authType = eSAP_OPEN_SYSTEM;
1967 else
1968 pConfig->authType = eSAP_AUTO_SWITCH;
1969
1970 pConfig->privacy = pCommitConfig->privacy;
1971 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pCommitConfig->privacy;
1972 pConfig->wps_state = pCommitConfig->wps_state;
1973 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
1974 pConfig->RSNWPAReqIELength = pCommitConfig->RSNWPAReqIELength;
1975 if(pConfig->RSNWPAReqIELength){
1976 pConfig->pRSNWPAReqIE = &pCommitConfig->RSNWPAReqIE[0];
1977 if ((pConfig->pRSNWPAReqIE[0] == DOT11F_EID_RSN) || (pConfig->pRSNWPAReqIE[0] == DOT11F_EID_WPA)){
1978 // The actual processing may eventually be more extensive than this.
1979 // Right now, just consume any PMKIDs that are sent in by the app.
1980 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 vos_get_context( VOS_MODULE_ID_PE, pVosContext),
Jeff Johnson295189b2012-06-20 16:38:30 -07001982 &RSNEncryptType,
1983 &mcRSNEncryptType,
1984 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001985 &MFPCapable,
1986 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 pConfig->pRSNWPAReqIE[1]+2,
1988 pConfig->pRSNWPAReqIE );
1989
1990 if( VOS_STATUS_SUCCESS == status )
1991 {
1992 // Now copy over all the security attributes you have parsed out
1993 //TODO: Need to handle mixed mode
1994 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1995 pConfig->mcRSNEncryptType = mcRSNEncryptType;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001996 hddLog( LOG1, FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1998 }
1999 }
2000 }
2001 else
2002 {
2003 /* If no RSNIE, set encrypt type to NONE*/
2004 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
2005 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002006 hddLog( LOG1, FL("EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 pConfig->RSNEncryptType, pConfig->mcRSNEncryptType);
2008 }
2009
Chilam Ngc4244af2013-04-01 15:37:32 -07002010 if (pConfig->RSNWPAReqIELength > QCSAP_MAX_OPT_IE) {
2011 hddLog(LOGE, FL("RSNWPAReqIELength: %d too large"), pConfig->RSNWPAReqIELength);
2012 kfree(pConfig);
2013 return -EIO;
2014 }
2015
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 pConfig->SSIDinfo.ssidHidden = pCommitConfig->SSIDinfo.ssidHidden;
2017 pConfig->SSIDinfo.ssid.length = pCommitConfig->SSIDinfo.ssid.length;
2018 vos_mem_copy(pConfig->SSIDinfo.ssid.ssId, pCommitConfig->SSIDinfo.ssid.ssId, pConfig->SSIDinfo.ssid.length);
2019 vos_mem_copy(pConfig->self_macaddr.bytes, pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
2020
2021 pConfig->SapMacaddr_acl = pCommitConfig->qc_macaddr_acl;
2022
2023 // ht_capab is not what the name conveys,this is used for protection bitmap
2024 pConfig->ht_capab = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2025
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302026 if (pCommitConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2027 num_mac = pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 else
2029 num_mac = pConfig->num_accept_mac = pCommitConfig->num_accept_mac;
2030 acl_entry = pCommitConfig->accept_mac;
2031 for (i = 0; i < num_mac; i++)
2032 {
2033 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(v_MACADDR_t));
2034 acl_entry++;
2035 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302036 if (pCommitConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2037 num_mac = pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 else
2039 num_mac = pConfig->num_deny_mac = pCommitConfig->num_deny_mac;
2040 acl_entry = pCommitConfig->deny_mac;
2041 for (i = 0; i < num_mac; i++)
2042 {
2043 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(v_MACADDR_t));
2044 acl_entry++;
2045 }
2046 //Uapsd Enabled Bit
2047 pConfig->UapsdEnable = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2048 //Enable OBSS protection
2049 pConfig->obssProtEnabled = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
2050 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->apDisableIntraBssFwd = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apDisableIntraBssFwd;
2051
Arif Hussain6d2a3322013-11-17 19:50:10 -08002052 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
2053 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
2054 pConfig->SSIDinfo.ssid.ssId,
2055 (int)pConfig->beacon_int, (int)pConfig->channel);
2056 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
2057 pConfig->SapHw_mode, pConfig->privacy, pConfig->authType);
2058 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
2059 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
2060 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d, DisableIntraBssFwd = %d"),
2061 pConfig->protEnabled, pConfig->obssProtEnabled,
2062 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->apDisableIntraBssFwd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002063
2064 pSapEventCallback = hdd_hostapd_SAPEventCB;
2065 pConfig->persona = pHostapdAdapter->device_mode;
2066 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,(v_PVOID_t)dev) != VOS_STATUS_SUCCESS)
2067 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002068 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 }
2070
2071 kfree(pConfig);
2072
2073 hddLog(LOG1, FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2074 vos_status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2075
2076 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2077 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 VOS_ASSERT(0);
2080 }
2081
2082 pHostapdState->bCommit = TRUE;
2083 if(pHostapdState->vosStatus)
2084 {
c_hpothuffdb5272013-10-02 16:42:35 +05302085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2086 FL("pHostapdState->vosStatus: %d"), pHostapdState->vosStatus);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08002087 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 }
2089 else
2090 {
2091 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2092 WLANSAP_Update_WpsIe ( pVosContext );
2093 return 0;
2094 }
2095}
2096static
2097int iw_softap_setmlme(struct net_device *dev,
2098 struct iw_request_info *info,
2099 union iwreq_data *wrqu, char *extra)
2100{
2101 struct sQcSapreq_mlme *pmlme;
2102 hdd_adapter_t *pHostapdAdapter = (hdd_adapter_t*)(netdev_priv(dev));
2103 v_MACADDR_t destAddress;
2104 pmlme = (struct sQcSapreq_mlme *)(wrqu->name);
2105 /* NOTE: this address is not valid incase of TKIP failure, since not filled */
2106 vos_mem_copy(&destAddress.bytes, pmlme->im_macaddr, sizeof(v_MACADDR_t));
2107 switch(pmlme->im_op)
2108 {
2109 case QCSAP_MLME_AUTHORIZE:
2110 hdd_softap_change_STA_state( pHostapdAdapter, &destAddress, WLANTL_STA_AUTHENTICATED);
2111 break;
2112 case QCSAP_MLME_ASSOC:
2113 //TODO:inform to TL after associating (not needed as we do in sapCallback)
2114 break;
2115 case QCSAP_MLME_UNAUTHORIZE:
2116 //TODO: send the disassoc to station
2117 //hdd_softap_change_STA_state( pHostapdAdapter, pmlme->im_macaddr, WLANTL_STA_AUTHENTICATED);
2118 break;
2119 case QCSAP_MLME_DISASSOC:
2120 hdd_softap_sta_disassoc(pHostapdAdapter,pmlme->im_macaddr);
2121 break;
2122 case QCSAP_MLME_DEAUTH:
2123 hdd_softap_sta_deauth(pHostapdAdapter,pmlme->im_macaddr);
2124 break;
2125 case QCSAP_MLME_MICFAILURE:
2126 hdd_softap_tkip_mic_fail_counter_measure(pHostapdAdapter,pmlme->im_reason);
2127 break;
2128 default:
2129 break;
2130 }
2131 return 0;
2132}
2133
2134static int iw_softap_set_channel_range(struct net_device *dev,
2135 struct iw_request_info *info,
2136 union iwreq_data *wrqu, char *extra)
2137{
2138 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2139 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002140 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002141
2142 int *value = (int *)extra;
2143 int startChannel = value[0];
2144 int endChannel = value[1];
2145 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002146 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 int ret = 0; /* success */
2148
2149 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
2150 if(status != VOS_STATUS_SUCCESS)
2151 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002152 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 startChannel,endChannel, band);
2154 ret = -EINVAL;
2155 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08002156
2157 pHddCtx->is_dynamic_channel_range_set = 1;
2158
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 return ret;
2160}
2161
2162int iw_softap_get_channel_list(struct net_device *dev,
2163 struct iw_request_info *info,
2164 union iwreq_data *wrqu, char *extra)
2165{
2166 v_U32_t num_channels = 0;
2167 v_U8_t i = 0;
2168 v_U8_t bandStartChannel = RF_CHAN_1;
2169 v_U8_t bandEndChannel = RF_CHAN_165;
2170 v_U32_t temp_num_channels = 0;
2171 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2172 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2173 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002175 eCsrBand curBand = eCSR_BAND_ALL;
2176
2177 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
2178 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002179 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002180 return -EIO;
2181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 wrqu->data.length = sizeof(tChannelListInfo);
2183 ENTER();
2184
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002185 if (eCSR_BAND_24 == curBand)
2186 {
2187 bandStartChannel = RF_CHAN_1;
2188 bandEndChannel = RF_CHAN_14;
2189 }
2190 else if (eCSR_BAND_5G == curBand)
2191 {
2192 bandStartChannel = RF_CHAN_36;
2193 bandEndChannel = RF_CHAN_165;
2194 }
2195
Arif Hussain6d2a3322013-11-17 19:50:10 -08002196 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05302197 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002198 bandStartChannel, bandEndChannel );
2199
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 for( i = bandStartChannel; i <= bandEndChannel; i++ )
2201 {
2202 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
2203 {
2204 channel_list->channels[num_channels] = rfChannels[i].channelNum;
2205 num_channels++;
2206 }
2207 }
2208
2209 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
2210
2211 temp_num_channels = num_channels;
2212
2213 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
2214 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302215 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08002216 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 }
2218
2219 if(REGDOMAIN_FCC == domainIdCurrentSoftap)
2220 {
2221 for(i = 0; i < temp_num_channels; i++)
2222 {
2223
2224 if((channel_list->channels[i] > 35) &&
2225 (channel_list->channels[i] < 49))
2226 {
2227 vos_mem_move(&channel_list->channels[i],
2228 &channel_list->channels[i+1],
2229 temp_num_channels - (i-1));
2230 num_channels--;
2231 temp_num_channels--;
2232 i--;
2233 }
2234 }
2235 }
2236
Arif Hussain6d2a3322013-11-17 19:50:10 -08002237 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002238
2239 if (num_channels > IW_MAX_FREQUENCIES)
2240 {
2241 num_channels = IW_MAX_FREQUENCIES;
2242 }
2243
2244 channel_list->num_channels = num_channels;
2245 EXIT();
2246
2247 return 0;
2248}
2249
2250static
2251int iw_get_genie(struct net_device *dev,
2252 struct iw_request_info *info,
2253 union iwreq_data *wrqu, char *extra)
2254{
2255 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2256 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2257 eHalStatus status;
2258 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2259 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2260 ENTER();
Arif Hussain6d2a3322013-11-17 19:50:10 -08002261 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2263 status = WLANSap_getstationIE_information(pVosContext,
2264 &length,
2265 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07002266 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2267 if (wrqu->data.length < length ||
2268 copy_to_user(wrqu->data.pointer,
2269 (v_VOID_t*)genIeBytes, length))
2270 {
2271 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2272 return -EFAULT;
2273 }
2274 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002275
Arif Hussain6d2a3322013-11-17 19:50:10 -08002276 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002277
2278
2279 EXIT();
2280 return 0;
2281}
2282static
2283int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
2284 struct iw_request_info *info,
2285 union iwreq_data *wrqu, char *extra)
2286{
2287 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07002288 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
2290 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07002291
Arif Hussain6d2a3322013-11-17 19:50:10 -08002292 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07002293 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
2294
2295 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
2296 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
2297 pHddApCtx->WPSPBCProbeReq.probeReqIE,
2298 WPSPBCProbeReqIEs.probeReqIELen);
2299 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
2300 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
2301 sizeof(v_MACADDR_t));
2302 if (copy_to_user(wrqu->data.pointer,
2303 (void *)&WPSPBCProbeReqIEs,
2304 sizeof(WPSPBCProbeReqIEs)))
2305 {
2306 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2307 return -EFAULT;
2308 }
2309 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002310 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07002311 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 up(&pHddApCtx->semWpsPBCOverlapInd);
2313 EXIT();
2314 return 0;
2315}
2316
2317/**---------------------------------------------------------------------------
2318
2319 \brief iw_set_auth_hostap() -
2320 This function sets the auth type received from the wpa_supplicant.
2321
2322 \param - dev - Pointer to the net device.
2323 - info - Pointer to the iw_request_info.
2324 - wrqu - Pointer to the iwreq_data.
2325 - extra - Pointer to the data.
2326 \return - 0 for success, non zero for failure
2327
2328 --------------------------------------------------------------------------*/
2329int iw_set_auth_hostap(struct net_device *dev,struct iw_request_info *info,
2330 union iwreq_data *wrqu,char *extra)
2331{
2332 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2333 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2334
2335 ENTER();
2336 switch(wrqu->param.flags & IW_AUTH_INDEX)
2337 {
2338 case IW_AUTH_TKIP_COUNTERMEASURES:
2339 {
2340 if(wrqu->param.value) {
2341 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2342 "Counter Measure started %d", wrqu->param.value);
2343 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
2344 }
2345 else {
2346 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2347 "Counter Measure stopped=%d", wrqu->param.value);
2348 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
2349 }
2350
2351 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
2352 wrqu->param.value);
2353 }
2354 break;
2355
2356 default:
2357
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002358 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 wrqu->param.flags & IW_AUTH_INDEX);
2360 break;
2361 }
2362
2363 EXIT();
2364 return 0;
2365}
2366
2367static int iw_set_ap_encodeext(struct net_device *dev,
2368 struct iw_request_info *info,
2369 union iwreq_data *wrqu, char *extra)
2370{
2371 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2372 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2373 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
Jeff Johnson43971f52012-07-17 12:26:56 -07002374 int retval = 0;
2375 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
2377 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2378 int key_index;
2379 struct iw_point *encoding = &wrqu->encoding;
2380 tCsrRoamSetKey setKey;
2381// tCsrRoamRemoveKey RemoveKey;
2382 int i;
Jeff Johnson43971f52012-07-17 12:26:56 -07002383
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 ENTER();
2385
2386 key_index = encoding->flags & IW_ENCODE_INDEX;
2387
2388 if(key_index > 0) {
2389
2390 /*Convert from 1-based to 0-based keying*/
2391 key_index--;
2392 }
2393 if(!ext->key_len) {
2394#if 0
2395 /*Set the encrytion type to NONE*/
2396#if 0
2397 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
2398#endif
2399
2400 RemoveKey.keyId = key_index;
2401 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2402 /*Key direction for group is RX only*/
2403 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2404 }
2405 else {
2406 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2407 }
2408 switch(ext->alg)
2409 {
2410 case IW_ENCODE_ALG_NONE:
2411 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2412 break;
2413 case IW_ENCODE_ALG_WEP:
2414 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
2415 break;
2416 case IW_ENCODE_ALG_TKIP:
2417 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07002418 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 case IW_ENCODE_ALG_CCMP:
2420 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
2421 break;
2422 default:
2423 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2424 break;
2425 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08002426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Remove key cipher_alg:%d key_len%d *pEncryptionType :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002427 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002429 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 );
Jeff Johnson43971f52012-07-17 12:26:56 -07002431 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
2432 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 {
2434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07002435 __LINE__, vstatus );
2436 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002438#endif
2439 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002440
Jeff Johnson43971f52012-07-17 12:26:56 -07002441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002442
2443 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
2444
2445 setKey.keyId = key_index;
2446 setKey.keyLength = ext->key_len;
2447
2448 if(ext->key_len <= CSR_MAX_KEY_LEN) {
2449 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
2450 }
2451
2452 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2453 /*Key direction for group is RX only*/
2454 setKey.keyDirection = eSIR_RX_ONLY;
2455 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2456 }
2457 else {
2458
2459 setKey.keyDirection = eSIR_TX_RX;
2460 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2461 }
2462 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2463 {
2464 setKey.keyDirection = eSIR_TX_DEFAULT;
2465 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2466 }
2467
2468 /*For supplicant pae role is zero*/
2469 setKey.paeRole = 0;
2470
2471 switch(ext->alg)
2472 {
2473 case IW_ENCODE_ALG_NONE:
2474 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2475 break;
2476
2477 case IW_ENCODE_ALG_WEP:
2478 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
2479 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002480 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 break;
2482
2483 case IW_ENCODE_ALG_TKIP:
2484 {
2485 v_U8_t *pKey = &setKey.Key[0];
2486
2487 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
2488
2489 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
2490
2491 /*Supplicant sends the 32bytes key in this order
2492
2493 |--------------|----------|----------|
2494 | Tk1 |TX-MIC | RX Mic |
2495 |--------------|----------|----------|
2496 <---16bytes---><--8bytes--><--8bytes-->
2497
2498 */
2499 /*Sme expects the 32 bytes key to be in the below order
2500
2501 |--------------|----------|----------|
2502 | Tk1 |RX-MIC | TX Mic |
2503 |--------------|----------|----------|
2504 <---16bytes---><--8bytes--><--8bytes-->
2505 */
2506 /* Copy the Temporal Key 1 (TK1) */
2507 vos_mem_copy(pKey,ext->key,16);
2508
2509 /*Copy the rx mic first*/
2510 vos_mem_copy(&pKey[16],&ext->key[24],8);
2511
2512 /*Copy the tx mic */
2513 vos_mem_copy(&pKey[24],&ext->key[16],8);
2514
2515 }
2516 break;
2517
2518 case IW_ENCODE_ALG_CCMP:
2519 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
2520 break;
2521
2522 default:
2523 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2524 break;
2525 }
2526
2527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302528 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07002529 setKey.keyId);
2530 for(i=0; i< ext->key_len; i++)
2531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2532 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07002533
2534 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
2535 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 {
2537 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07002538 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
2539 retval = -EINVAL;
2540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002541
Jeff Johnson43971f52012-07-17 12:26:56 -07002542 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002543}
Jeff Johnson43971f52012-07-17 12:26:56 -07002544
2545
Jeff Johnson295189b2012-06-20 16:38:30 -07002546static int iw_set_ap_mlme(struct net_device *dev,
2547 struct iw_request_info *info,
2548 union iwreq_data *wrqu,
2549 char *extra)
2550{
2551#if 0
2552 hdd_adapter_t *pAdapter = (netdev_priv(dev));
2553 struct iw_mlme *mlme = (struct iw_mlme *)extra;
2554
2555 ENTER();
2556
2557 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
2558 switch (mlme->cmd) {
2559 case IW_MLME_DISASSOC:
2560 case IW_MLME_DEAUTH:
2561 hddLog(LOG1, "Station disassociate");
2562 if( pAdapter->conn_info.connState == eConnectionState_Associated )
2563 {
2564 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
2565
2566 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
2567 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
2568
2569 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
2570
2571 //clear all the reason codes
2572 if (status != 0)
2573 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002574 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 }
2576
2577 netif_stop_queue(dev);
2578 netif_carrier_off(dev);
2579 }
2580 else
2581 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002582 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 }
2584 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08002585 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 return -EINVAL;
2587 }//end of switch
2588 EXIT();
2589#endif
2590 return 0;
2591// return status;
2592}
2593
2594static int iw_get_ap_rts_threshold(struct net_device *dev,
2595 struct iw_request_info *info,
2596 union iwreq_data *wrqu, char *extra)
2597{
2598 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2599 v_U32_t status = 0;
2600
2601 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
2602
2603 return status;
2604}
2605
2606static int iw_get_ap_frag_threshold(struct net_device *dev,
2607 struct iw_request_info *info,
2608 union iwreq_data *wrqu, char *extra)
2609{
2610 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2611 v_U32_t status = 0;
2612
2613 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
2614
2615 return status;
2616}
2617
2618static int iw_get_ap_freq(struct net_device *dev, struct iw_request_info *info,
2619 struct iw_freq *fwrq, char *extra)
2620{
Jeff Johnsone7245742012-09-05 17:12:55 -07002621 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2623 tHalHandle hHal;
2624 hdd_hostapd_state_t *pHostapdState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002625 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002626
2627 ENTER();
2628
2629 if ((WLAN_HDD_GET_CTX(pHostapdAdapter))->isLogpInProgress) {
2630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2631 "%s:LOGP in Progress. Ignore!!!",__func__);
2632 return status;
2633 }
2634
2635 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
2636 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2637
2638 if(pHostapdState->bssState == BSS_STOP )
2639 {
2640 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
2641 != eHAL_STATUS_SUCCESS)
2642 {
c_hpothuffdb5272013-10-02 16:42:35 +05302643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2644 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 return -EIO;
2646 }
2647 else
2648 {
2649 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07002650 if( TRUE == status)
2651 {
2652 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2653 * iwlist & iwconfig command shows frequency into proper
2654 * format (2.412 GHz instead of 246.2 MHz)*/
2655 fwrq->m = freq;
2656 fwrq->e = MHZ;
2657 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 }
2659 }
2660 else
2661 {
2662 channel = pHddApCtx->operatingChannel;
2663 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07002664 if( TRUE == status)
2665 {
2666 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2667 * iwlist & iwconfig command shows frequency into proper
2668 * format (2.412 GHz instead of 246.2 MHz)*/
2669 fwrq->m = freq;
2670 fwrq->e = MHZ;
2671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002673 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002674}
2675
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05302676static int iw_get_mode(struct net_device *dev,
2677 struct iw_request_info *info,
2678 union iwreq_data *wrqu,
2679 char *extra)
2680{
2681 int status = 0;
2682
2683 wrqu->mode = IW_MODE_MASTER;
2684
2685 return status;
2686}
2687
Jeff Johnson295189b2012-06-20 16:38:30 -07002688static int iw_softap_setwpsie(struct net_device *dev,
2689 struct iw_request_info *info,
2690 union iwreq_data *wrqu,
2691 char *extra)
2692{
2693 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2694 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2695 hdd_hostapd_state_t *pHostapdState;
2696 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07002697 u_int8_t *wps_genie;
2698 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 u_int8_t *pos;
2700 tpSap_WPSIE pSap_WPSIe;
2701 u_int8_t WPSIeType;
2702 u_int16_t length;
2703 ENTER();
2704
Arif Hussained667642013-10-27 23:01:14 -07002705 if(!wrqu->data.length || wrqu->data.length <= QCSAP_MAX_WSC_IE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002706 return 0;
2707
Arif Hussained667642013-10-27 23:01:14 -07002708 wps_genie = kmalloc(wrqu->data.length, GFP_KERNEL);
2709
2710 if(NULL == wps_genie) {
2711 hddLog(LOG1, "unable to allocate memory");
2712 return -ENOMEM;
2713 }
2714 fwps_genie = wps_genie;
2715 if (copy_from_user((void *)wps_genie,
2716 wrqu->data.pointer, wrqu->data.length))
2717 {
2718 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2719 kfree(fwps_genie);
2720 return -EFAULT;
2721 }
2722
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
2724 if (NULL == pSap_WPSIe)
2725 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002726 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07002727 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 return -ENOMEM;
2729 }
2730 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
2731
Arif Hussain6d2a3322013-11-17 19:50:10 -08002732 hddLog(LOG1,"%s WPS IE type[0x%X] IE[0x%X], LEN[%d]", __func__, wps_genie[0], wps_genie[1], wps_genie[2]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 WPSIeType = wps_genie[0];
2734 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
2735 {
2736 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
2737 wps_genie = wps_genie + 1;
2738 switch ( wps_genie[0] )
2739 {
2740 case DOT11F_EID_WPA:
2741 if (wps_genie[1] < 2 + 4)
2742 {
2743 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07002744 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 return -EINVAL;
2746 }
2747 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
2748 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002749 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 pos = &wps_genie[6];
2751 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
2752 {
2753 switch((u_int16_t)(*pos<<8) | *(pos+1))
2754 {
2755 case HDD_WPS_ELEM_VERSION:
2756 pos += 4;
2757 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002758 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
2760 pos += 1;
2761 break;
2762
2763 case HDD_WPS_ELEM_WPS_STATE:
2764 pos +=4;
2765 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002766 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
2768 pos += 1;
2769 break;
2770 case HDD_WPS_ELEM_APSETUPLOCK:
2771 pos += 4;
2772 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002773 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
2775 pos += 1;
2776 break;
2777 case HDD_WPS_ELEM_SELECTEDREGISTRA:
2778 pos += 4;
2779 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002780 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
2782 pos += 1;
2783 break;
2784 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
2785 pos += 4;
2786 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002787 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
2789 pos += 2;
2790 break;
2791 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
2792 pos += 4;
2793 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002794 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
2796 pos += 2;
2797 break;
2798
2799 case HDD_WPS_ELEM_UUID_E:
2800 pos += 2;
2801 length = *pos<<8 | *(pos+1);
2802 pos += 2;
2803 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
2804 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
2805 pos += length;
2806 break;
2807 case HDD_WPS_ELEM_RF_BANDS:
2808 pos += 4;
2809 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002810 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
2812 pos += 1;
2813 break;
2814
2815 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08002816 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07002818 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 return -EINVAL;
2820 }
2821 }
2822 }
2823 else {
2824 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002825 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 }
2827 break;
2828
2829 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002830 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07002832 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 return 0;
2834 }
2835 }
2836 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
2837 {
2838 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
2839 wps_genie = wps_genie + 1;
2840 switch ( wps_genie[0] )
2841 {
2842 case DOT11F_EID_WPA:
2843 if (wps_genie[1] < 2 + 4)
2844 {
2845 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07002846 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 return -EINVAL;
2848 }
2849 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
2850 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002851 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 pos = &wps_genie[6];
2853 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
2854 {
2855 switch((u_int16_t)(*pos<<8) | *(pos+1))
2856 {
2857 case HDD_WPS_ELEM_VERSION:
2858 pos += 4;
2859 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002860 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
2862 pos += 1;
2863 break;
2864
2865 case HDD_WPS_ELEM_WPS_STATE:
2866 pos +=4;
2867 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002868 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
2870 pos += 1;
2871 break;
2872 case HDD_WPS_ELEM_APSETUPLOCK:
2873 pos += 4;
2874 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002875 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
2877 pos += 1;
2878 break;
2879 case HDD_WPS_ELEM_SELECTEDREGISTRA:
2880 pos += 4;
2881 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002882 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
2884 pos += 1;
2885 break;
2886 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
2887 pos += 4;
2888 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002889 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
2891 pos += 2;
2892 break;
2893 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
2894 pos += 4;
2895 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002896 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
2898 pos += 2;
2899 break;
2900 case HDD_WPS_ELEM_RSP_TYPE:
2901 pos += 4;
2902 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002903 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
2905 pos += 1;
2906 break;
2907 case HDD_WPS_ELEM_UUID_E:
2908 pos += 2;
2909 length = *pos<<8 | *(pos+1);
2910 pos += 2;
2911 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
2912 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
2913 pos += length;
2914 break;
2915
2916 case HDD_WPS_ELEM_MANUFACTURER:
2917 pos += 2;
2918 length = *pos<<8 | *(pos+1);
2919 pos += 2;
2920 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
2921 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
2922 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
2923 pos += length;
2924 break;
2925
2926 case HDD_WPS_ELEM_MODEL_NAME:
2927 pos += 2;
2928 length = *pos<<8 | *(pos+1);
2929 pos += 2;
2930 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
2931 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
2932 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
2933 pos += length;
2934 break;
2935 case HDD_WPS_ELEM_MODEL_NUM:
2936 pos += 2;
2937 length = *pos<<8 | *(pos+1);
2938 pos += 2;
2939 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
2940 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
2941 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
2942 pos += length;
2943 break;
2944 case HDD_WPS_ELEM_SERIAL_NUM:
2945 pos += 2;
2946 length = *pos<<8 | *(pos+1);
2947 pos += 2;
2948 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
2949 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
2950 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
2951 pos += length;
2952 break;
2953 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
2954 pos += 4;
2955 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002956 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07002957 pos += 2;
2958
2959 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002960 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 pos += 4;
2962 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002963 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 pos += 2;
2965 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
2966 break;
2967 case HDD_WPS_ELEM_DEVICE_NAME:
2968 pos += 2;
2969 length = *pos<<8 | *(pos+1);
2970 pos += 2;
2971 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
2972 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
2973 pos += length;
2974 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
2975 break;
2976 case HDD_WPS_ELEM_CONFIG_METHODS:
2977 pos += 4;
2978 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002979 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 pos += 2;
2981 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
2982 break;
2983
2984 case HDD_WPS_ELEM_RF_BANDS:
2985 pos += 4;
2986 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002987 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 pos += 1;
2989 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
2990 break;
2991 } // switch
2992 }
2993 }
2994 else
2995 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002996 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 }
2998
2999 } // switch
3000 }
3001 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
3002 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3003 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
3004 {
3005 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3006 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
3007 WLANSAP_Update_WpsIe ( pVosContext );
3008 }
3009
3010 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003011 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 EXIT();
3013 return halStatus;
3014}
3015
3016static int iw_softap_stopbss(struct net_device *dev,
3017 struct iw_request_info *info,
3018 union iwreq_data *wrqu,
3019 char *extra)
3020{
3021 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3022 VOS_STATUS status = VOS_STATUS_SUCCESS;
3023 ENTER();
3024 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
3025 {
3026 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
3027 {
3028 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3029
3030 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
3031
3032 if (!VOS_IS_STATUS_SUCCESS(status))
3033 {
3034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003035 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 VOS_ASSERT(0);
3037 }
3038 }
3039 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
3040 }
3041 EXIT();
3042 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
3043}
3044
3045static int iw_softap_version(struct net_device *dev,
3046 struct iw_request_info *info,
Jeff Johnson4824d4c2013-02-12 14:23:57 -08003047 union iwreq_data *wrqu,
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 char *extra)
3049{
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Jeff Johnson4824d4c2013-02-12 14:23:57 -08003051
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 ENTER();
Jeff Johnson4824d4c2013-02-12 14:23:57 -08003053 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003055 return 0;
3056}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003057
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003058VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003059{
3060 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003061 int len = 0;
3062 const char sta_info_header[] = "staId staAddress\n";
3063
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003064 len = scnprintf(pBuf, buf_len, sta_info_header);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003065 pBuf += len;
3066 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003067
3068 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
3069 {
3070 if(pAdapter->aStaInfo[i].isUsed)
3071 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08003072 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003073 pAdapter->aStaInfo[i].ucSTAId,
3074 pAdapter->aStaInfo[i].macAddrSTA.bytes[0],
3075 pAdapter->aStaInfo[i].macAddrSTA.bytes[1],
3076 pAdapter->aStaInfo[i].macAddrSTA.bytes[2],
3077 pAdapter->aStaInfo[i].macAddrSTA.bytes[3],
3078 pAdapter->aStaInfo[i].macAddrSTA.bytes[4],
3079 pAdapter->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003080 pBuf += len;
3081 buf_len -= len;
3082 }
3083 if(WE_GET_STA_INFO_SIZE > buf_len)
3084 {
3085 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003086 }
3087 }
3088 return VOS_STATUS_SUCCESS;
3089}
3090
3091static int iw_softap_get_sta_info(struct net_device *dev,
3092 struct iw_request_info *info,
3093 union iwreq_data *wrqu,
3094 char *extra)
3095{
3096 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3097 VOS_STATUS status;
3098 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07003099 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003100 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003101 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003102 return -EINVAL;
3103 }
3104 wrqu->data.length = strlen(extra);
3105 EXIT();
3106 return 0;
3107}
3108
Jeff Johnson295189b2012-06-20 16:38:30 -07003109static int iw_set_ap_genie(struct net_device *dev,
3110 struct iw_request_info *info,
3111 union iwreq_data *wrqu,
3112 char *extra)
3113{
3114
3115 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3116 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3117 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003118 u_int8_t *genie = (u_int8_t *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003119
3120 ENTER();
3121
3122 if(!wrqu->data.length)
3123 {
3124 EXIT();
3125 return 0;
3126 }
Arif Hussained667642013-10-27 23:01:14 -07003127
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 switch (genie[0])
3129 {
3130 case DOT11F_EID_WPA:
3131 case DOT11F_EID_RSN:
3132 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
3133 {
3134 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
3135 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
3136 }
3137 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07003138 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 break;
3140
3141 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003142 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 halStatus = 0;
3144 }
3145
3146 EXIT();
3147 return halStatus;
3148}
3149
3150static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
3151{
3152 eHalStatus hstatus;
3153 long lrc;
3154 struct statsContext context;
3155
3156 if (NULL == pAdapter)
3157 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303158 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 return VOS_STATUS_E_FAULT;
3160 }
3161
3162 init_completion(&context.completion);
3163 context.pAdapter = pAdapter;
3164 context.magic = STATS_CONTEXT_MAGIC;
3165 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3166 eCSR_HDD,
3167 SME_GLOBAL_CLASSA_STATS,
3168 hdd_GetClassA_statisticsCB,
3169 0, // not periodic
3170 FALSE, //non-cached results
3171 staid,
3172 &context);
3173 if (eHAL_STATUS_SUCCESS != hstatus)
3174 {
3175 hddLog(VOS_TRACE_LEVEL_ERROR,
3176 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003177 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 }
3179 else
3180 {
3181 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3182 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003183 if (lrc <= 0)
3184 {
3185 hddLog(VOS_TRACE_LEVEL_ERROR,
3186 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003187 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 }
3189 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003190
3191 /* either we never sent a request, we sent a request and received a
3192 response or we sent a request and timed out. if we never sent a
3193 request or if we sent a request and got a response, we want to
3194 clear the magic out of paranoia. if we timed out there is a
3195 race condition such that the callback function could be
3196 executing at the same time we are. of primary concern is if the
3197 callback function had already verified the "magic" but had not
3198 yet set the completion variable when a timeout occurred. we
3199 serialize these activities by invalidating the magic while
3200 holding a shared spinlock which will cause us to block if the
3201 callback is currently executing */
3202 spin_lock(&hdd_context_lock);
3203 context.magic = 0;
3204 spin_unlock(&hdd_context_lock);
3205
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 return VOS_STATUS_SUCCESS;
3207}
3208
3209int iw_get_softap_linkspeed(struct net_device *dev,
3210 struct iw_request_info *info,
3211 union iwreq_data *wrqu,
3212 char *extra)
3213
3214{
3215 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303216 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07003218 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303219 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303221 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08003223 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303224 int rc, valid;
3225
3226 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3227
3228 valid = wlan_hdd_validate_context(pHddCtx);
3229
3230 if (0 != valid)
3231 {
3232 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context not valid"));
3233 return valid;
3234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003235
Arif Hussain6d2a3322013-11-17 19:50:10 -08003236 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08003237
3238 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07003239 {
Arif Hussaina9571842014-01-15 16:43:41 -08003240 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
3241 if (NULL == pmacAddress) {
3242 hddLog(LOG1, "unable to allocate memory");
3243 return -ENOMEM;
3244 }
3245 if (copy_from_user((void *)pmacAddress,
3246 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
3247 {
3248 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3249 kfree(pmacAddress);
3250 return -EFAULT;
3251 }
3252 pmacAddress[MAC_ADDRESS_STR_LEN] = '\0';
3253
3254 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07003255 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08003256
3257 if (!VOS_IS_STATUS_SUCCESS(status ))
3258 {
3259 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
3260 }
Arif Hussained667642013-10-27 23:01:14 -07003261 }
Kiet Lam61589852013-09-19 17:10:58 +05303262 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05303263 * link speed for first connected client will be returned.
3264 */
Arif Hussaina9571842014-01-15 16:43:41 -08003265 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05303266 {
3267 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
3268 }
3269 else
3270 {
3271 status = hdd_softap_GetStaId(pHostapdAdapter,
3272 (v_MACADDR_t *)macAddress, (void *)(&staId));
3273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003274
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303275 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303277 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 link_speed = 0;
3279 }
3280 else
3281 {
3282 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303283
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 if (!VOS_IS_STATUS_SUCCESS(status ))
3285 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303286 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 return -EINVAL;
3288 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303289
3290 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
3291 staId, &link_speed);
3292
3293 link_speed = link_speed / 10;
3294
3295 if (0 == link_speed)
3296 {
3297 /* The linkspeed returned by HAL is in units of 500kbps.
3298 * converting it to mbps.
3299 * This is required to support legacy firmware which does
3300 * not return link capacity.
3301 */
3302 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 }
3305
3306 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07003307 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303308
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 if ((rc < 0) || (rc >= len))
3310 {
3311 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303312 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 return -EIO;
3314 }
3315
3316 return 0;
3317}
3318
3319static const iw_handler hostapd_handler[] =
3320{
3321 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3322 (iw_handler) NULL, /* SIOCGIWNAME */
3323 (iw_handler) NULL, /* SIOCSIWNWID */
3324 (iw_handler) NULL, /* SIOCGIWNWID */
3325 (iw_handler) NULL, /* SIOCSIWFREQ */
3326 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
3327 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303328 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 (iw_handler) NULL, /* SIOCSIWSENS */
3330 (iw_handler) NULL, /* SIOCGIWSENS */
3331 (iw_handler) NULL, /* SIOCSIWRANGE */
3332 (iw_handler) NULL, /* SIOCGIWRANGE */
3333 (iw_handler) NULL, /* SIOCSIWPRIV */
3334 (iw_handler) NULL, /* SIOCGIWPRIV */
3335 (iw_handler) NULL, /* SIOCSIWSTATS */
3336 (iw_handler) NULL, /* SIOCGIWSTATS */
3337 (iw_handler) NULL, /* SIOCSIWSPY */
3338 (iw_handler) NULL, /* SIOCGIWSPY */
3339 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3340 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3341 (iw_handler) NULL, /* SIOCSIWAP */
3342 (iw_handler) NULL, /* SIOCGIWAP */
3343 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
3344 (iw_handler) NULL, /* SIOCGIWAPLIST */
3345 (iw_handler) NULL, /* SIOCSIWSCAN */
3346 (iw_handler) NULL, /* SIOCGIWSCAN */
3347 (iw_handler) NULL, /* SIOCSIWESSID */
3348 (iw_handler) NULL, /* SIOCGIWESSID */
3349 (iw_handler) NULL, /* SIOCSIWNICKN */
3350 (iw_handler) NULL, /* SIOCGIWNICKN */
3351 (iw_handler) NULL, /* -- hole -- */
3352 (iw_handler) NULL, /* -- hole -- */
3353 (iw_handler) NULL, /* SIOCSIWRATE */
3354 (iw_handler) NULL, /* SIOCGIWRATE */
3355 (iw_handler) NULL, /* SIOCSIWRTS */
3356 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
3357 (iw_handler) NULL, /* SIOCSIWFRAG */
3358 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
3359 (iw_handler) NULL, /* SIOCSIWTXPOW */
3360 (iw_handler) NULL, /* SIOCGIWTXPOW */
3361 (iw_handler) NULL, /* SIOCSIWRETRY */
3362 (iw_handler) NULL, /* SIOCGIWRETRY */
3363 (iw_handler) NULL, /* SIOCSIWENCODE */
3364 (iw_handler) NULL, /* SIOCGIWENCODE */
3365 (iw_handler) NULL, /* SIOCSIWPOWER */
3366 (iw_handler) NULL, /* SIOCGIWPOWER */
3367 (iw_handler) NULL, /* -- hole -- */
3368 (iw_handler) NULL, /* -- hole -- */
3369 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
3370 (iw_handler) NULL, /* SIOCGIWGENIE */
3371 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
3372 (iw_handler) NULL, /* SIOCGIWAUTH */
3373 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
3374 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
3375 (iw_handler) NULL, /* SIOCSIWPMKSA */
3376};
3377
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -08003378#define IW_PRIV_TYPE_OPTIE (IW_PRIV_TYPE_BYTE | QCSAP_MAX_OPT_IE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003379#define IW_PRIV_TYPE_MLME \
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -08003380 (IW_PRIV_TYPE_BYTE | sizeof(struct ieee80211req_mlme))
Jeff Johnson295189b2012-06-20 16:38:30 -07003381
3382static const struct iw_priv_args hostapd_private_args[] = {
3383 { QCSAP_IOCTL_SETPARAM,
3384 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
3385 { QCSAP_IOCTL_SETPARAM,
3386 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
3387 { QCSAP_PARAM_MAX_ASSOC,
3388 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
3389 { QCSAP_PARAM_HIDE_SSID,
3390 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07003391 { QCSAP_PARAM_SET_MC_RATE,
3392 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 { QCSAP_IOCTL_GETPARAM,
3394 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3395 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
3396 { QCSAP_IOCTL_GETPARAM, 0,
3397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
3398 { QCSAP_PARAM_MAX_ASSOC, 0,
3399 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07003400 { QCSAP_PARAM_GET_WLAN_DBG, 0,
3401 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
3402 { QCSAP_PARAM_AUTO_CHANNEL, 0,
3403 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 { QCSAP_PARAM_MODULE_DOWN_IND, 0,
3405 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "moduleDownInd" },
3406 { QCSAP_PARAM_CLR_ACL, 0,
3407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
3408 { QCSAP_PARAM_ACL_MODE,
3409 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
3410 { QCSAP_IOCTL_COMMIT,
3411 IW_PRIV_TYPE_BYTE | sizeof(struct s_CommitConfig) | IW_PRIV_SIZE_FIXED, 0, "commit" },
3412 { QCSAP_IOCTL_SETMLME,
3413 IW_PRIV_TYPE_BYTE | sizeof(struct sQcSapreq_mlme)| IW_PRIV_SIZE_FIXED, 0, "setmlme" },
3414 { QCSAP_IOCTL_GET_STAWPAIE,
3415 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
3416 { QCSAP_IOCTL_SETWPAIE,
3417 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
3418 { QCSAP_IOCTL_STOPBSS,
3419 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
3420 { QCSAP_IOCTL_VERSION, 0,
3421 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003422 { QCSAP_IOCTL_GET_STA_INFO, 0,
3423 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08003425 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07003427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 { QCSAP_IOCTL_ASSOC_STA_MACADDR, 0,
3429 IW_PRIV_TYPE_BYTE | /*((WLAN_MAX_STA_COUNT*6)+100)*/1 , "get_assoc_stamac" },
3430 { QCSAP_IOCTL_DISASSOC_STA,
3431 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
3432 { QCSAP_IOCTL_AP_STATS,
3433 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE, 0, "ap_stats" },
3434 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
3435 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303436 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003437
3438 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
3439 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
3440 /* handlers for sub-ioctl */
3441 { WE_SET_WLAN_DBG,
3442 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
3443 0,
3444 "setwlandbg" },
3445
3446 /* handlers for main ioctl */
3447 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
3448 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3449 0,
3450 "" },
3451
3452 /* handlers for sub-ioctl */
3453 { WE_LOG_DUMP_CMD,
3454 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3455 0,
3456 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 { WE_P2P_NOA_CMD,
3458 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3459 0,
3460 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08003461 /* handlers for sub ioctl */
3462 {
3463 WE_MCC_CONFIG_CREDENTIAL,
3464 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3465 0,
3466 "setMccCrdnl" },
3467
3468 /* handlers for sub ioctl */
3469 {
3470 WE_MCC_CONFIG_PARAMS,
3471 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3472 0,
3473 "setMccConfig" },
3474
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 /* handlers for main ioctl */
3476 { QCSAP_IOCTL_MODIFY_ACL,
3477 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
3478 0,
3479 "modify_acl" },
3480
3481 /* handlers for main ioctl */
3482 { QCSAP_IOCTL_GET_CHANNEL_LIST,
3483 0,
3484 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
3485 "getChannelList" },
3486
Jeff Johnsone7245742012-09-05 17:12:55 -07003487 /* handlers for main ioctl */
3488 { QCSAP_IOCTL_SET_TX_POWER,
3489 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3490 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05303491 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07003492
3493 /* handlers for main ioctl */
3494 { QCSAP_IOCTL_SET_MAX_TX_POWER,
3495 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3496 0,
3497 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05303498
3499 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
3500 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
3501 0,
3502 "dataSnapshot" },
3503
3504 /* handlers for main ioctl */
3505 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
3506 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3507 0,
3508 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003509};
Jeff Johnsone7245742012-09-05 17:12:55 -07003510
Jeff Johnson295189b2012-06-20 16:38:30 -07003511static const iw_handler hostapd_private[] = {
3512 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
3513 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
3514 [QCSAP_IOCTL_COMMIT - SIOCIWFIRSTPRIV] = iw_softap_commit, //get priv ioctl
3515 [QCSAP_IOCTL_SETMLME - SIOCIWFIRSTPRIV] = iw_softap_setmlme,
3516 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
3517 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
3518 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
3519 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
3520 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
3521 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
3522 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
3523 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
3524 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
3525 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
3526 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
3527 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
3528 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
3529 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003530 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07003531 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
3532 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07003533 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303534 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05303535 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Jeff Johnson295189b2012-06-20 16:38:30 -07003536};
3537const struct iw_handler_def hostapd_handler_def = {
3538 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
3539 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
3540 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
3541 .standard = (iw_handler *)hostapd_handler,
3542 .private = (iw_handler *)hostapd_private,
3543 .private_args = hostapd_private_args,
3544 .get_wireless_stats = NULL,
3545};
3546#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
3547struct net_device_ops net_ops_struct = {
3548 .ndo_open = hdd_hostapd_open,
3549 .ndo_stop = hdd_hostapd_stop,
3550 .ndo_uninit = hdd_hostapd_uninit,
3551 .ndo_start_xmit = hdd_softap_hard_start_xmit,
3552 .ndo_tx_timeout = hdd_softap_tx_timeout,
3553 .ndo_get_stats = hdd_softap_stats,
3554 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
3555 .ndo_do_ioctl = hdd_hostapd_ioctl,
3556 .ndo_change_mtu = hdd_hostapd_change_mtu,
3557 .ndo_select_queue = hdd_hostapd_select_queue,
3558 };
3559#endif
3560
3561int hdd_set_hostapd(hdd_adapter_t *pAdapter)
3562{
3563 return VOS_STATUS_SUCCESS;
3564}
3565
3566void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
3567{
3568#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
3569 pWlanHostapdDev->netdev_ops = &net_ops_struct;
3570#else
3571 pWlanHostapdDev->open = hdd_hostapd_open;
3572 pWlanHostapdDev->stop = hdd_hostapd_stop;
3573 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
3574 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
3575 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
3576 pWlanHostapdDev->get_stats = hdd_softap_stats;
3577 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
3578 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
3579#endif
3580}
3581
3582VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
3583{
3584 hdd_hostapd_state_t * phostapdBuf;
3585 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07003586 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08003588#ifdef FEATURE_WLAN_CH_AVOID
3589 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
3590 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
3591 v_U16_t unsafeChannelCount;
3592#endif /* FEATURE_WLAN_CH_AVOID */
3593
Jeff Johnson295189b2012-06-20 16:38:30 -07003594 ENTER();
3595 // Allocate the Wireless Extensions state structure
3596 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
3597
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07003598 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
3599
Leo Chang0b0e45a2013-12-15 15:18:55 -08003600#ifdef FEATURE_WLAN_CH_AVOID
3601 /* Get unsafe cahnnel list from cached location */
3602 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
3603 sizeof(unsafeChannelList),
3604 &unsafeChannelCount);
3605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3606 "%s : Unsafe Channel count %d",
3607 __func__, unsafeChannelCount);
3608 hdd_hostapd_update_unsafe_channel_list(pVosContext,
3609 unsafeChannelList,
3610 unsafeChannelCount);
3611#endif /* FEATURE_WLAN_CH_AVOID */
3612
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 // Zero the memory. This zeros the profile structure.
3614 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
3615
3616 // Set up the pointer to the Wireless Extensions state structure
3617 // NOP
3618 status = hdd_set_hostapd(pAdapter);
3619 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 return status;
3622 }
3623
3624 status = vos_event_init(&phostapdBuf->vosEvent);
3625 if (!VOS_IS_STATUS_SUCCESS(status))
3626 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 return status;
3629 }
3630
3631 init_completion(&pAdapter->session_close_comp_var);
3632 init_completion(&pAdapter->session_open_comp_var);
3633
3634 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
3635
3636 // Register as a wireless device
3637 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
3638
3639 //Initialize the data path module
3640 status = hdd_softap_init_tx_rx(pAdapter);
3641 if ( !VOS_IS_STATUS_SUCCESS( status ))
3642 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003643 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05303645
3646 status = hdd_wmm_adapter_init( pAdapter );
3647 if (!VOS_IS_STATUS_SUCCESS(status))
3648 {
3649 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003650 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05303651 status, status );
3652 goto error_wmm_init;
3653 }
3654
3655 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
3656
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), pAdapter );
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05303658
3659 return status;
3660
3661error_wmm_init:
3662 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 EXIT();
3664 return status;
3665}
3666
3667hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
3668{
3669 struct net_device *pWlanHostapdDev = NULL;
3670 hdd_adapter_t *pHostapdAdapter = NULL;
3671 v_CONTEXT_t pVosContext= NULL;
3672
Jeff Johnson295189b2012-06-20 16:38:30 -07003673 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name, ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07003674
3675 if (pWlanHostapdDev != NULL)
3676 {
3677 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
3678
3679 //Init the net_device structure
3680 ether_setup(pWlanHostapdDev);
3681
3682 //Initialize the adapter context to zeros.
3683 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
3684 pHostapdAdapter->dev = pWlanHostapdDev;
3685 pHostapdAdapter->pHddCtx = pHddCtx;
3686 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
3687
3688 //Get the Global VOSS context.
3689 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3690 //Save the adapter context in global context for future.
3691 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
3692
3693 //Init the net_device structure
3694 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
3695
3696 hdd_set_ap_ops( pHostapdAdapter->dev );
3697
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
3699 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
3700
3701 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
3702 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
3703
3704 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
3706 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
3707 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
3708 init_completion(&pHostapdAdapter->tx_action_cnf_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 init_completion(&pHostapdAdapter->cancel_rem_on_chan_var);
3710 init_completion(&pHostapdAdapter->rem_on_chan_ready_event);
3711#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3712 init_completion(&pHostapdAdapter->offchannel_tx_event);
3713#endif
3714
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
3716 }
3717 return pHostapdAdapter;
3718}
3719
3720VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
3721{
3722 struct net_device *dev = pAdapter->dev;
3723 VOS_STATUS status = VOS_STATUS_SUCCESS;
3724
3725 ENTER();
3726
3727 if( rtnl_lock_held )
3728 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08003729 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 if( dev_alloc_name(dev, dev->name) < 0 )
3731 {
3732 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
3733 return VOS_STATUS_E_FAILURE;
3734 }
3735 }
3736 if (register_netdevice(dev))
3737 {
3738 hddLog(VOS_TRACE_LEVEL_FATAL,
3739 "%s:Failed:register_netdevice", __func__);
3740 return VOS_STATUS_E_FAILURE;
3741 }
3742 }
3743 else
3744 {
3745 if (register_netdev(dev))
3746 {
3747 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
3748 return VOS_STATUS_E_FAILURE;
3749 }
3750 }
3751 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
3752
3753 EXIT();
3754 return status;
3755}
3756
3757VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter)
3758{
3759 ENTER();
3760
3761 hdd_softap_deinit_tx_rx(pAdapter);
3762
3763 /* if we are being called during driver unload, then the dev has already
3764 been invalidated. if we are being called at other times, then we can
3765 detatch the wireless device handlers */
3766 if (pAdapter->dev)
3767 {
3768 pAdapter->dev->wireless_handlers = NULL;
3769 }
3770 EXIT();
3771 return 0;
3772}