Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 22 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 23 | * |
| 24 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 25 | * |
| 26 | * |
| 27 | * Permission to use, copy, modify, and/or distribute this software for |
| 28 | * any purpose with or without fee is hereby granted, provided that the |
| 29 | * above copyright notice and this permission notice appear in all |
| 30 | * copies. |
| 31 | * |
| 32 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 33 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 35 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 36 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 37 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 38 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 39 | * PERFORMANCE OF THIS SOFTWARE. |
| 40 | */ |
| 41 | |
| 42 | /**======================================================================== |
| 43 | |
| 44 | \file wlan_hdd_hostapd.c |
| 45 | \brief WLAN Host Device Driver implementation |
| 46 | |
| 47 | Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved. |
| 48 | |
| 49 | Qualcomm Confidential and Proprietary. |
| 50 | |
| 51 | ========================================================================*/ |
| 52 | /**========================================================================= |
| 53 | EDIT HISTORY FOR FILE |
| 54 | |
| 55 | |
| 56 | This section contains comments describing changes made to the module. |
| 57 | Notice that changes are listed in reverse chronological order. |
| 58 | |
| 59 | $Header:$ $DateTime: $ $Author: $ |
| 60 | |
| 61 | |
| 62 | when who what, where, why |
| 63 | -------- --- -------------------------------------------------------- |
| 64 | 04/5/09 Shailender Created module. |
| 65 | 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure |
| 66 | ==========================================================================*/ |
| 67 | /*-------------------------------------------------------------------------- |
| 68 | Include Files |
| 69 | ------------------------------------------------------------------------*/ |
| 70 | |
| 71 | #include <linux/version.h> |
| 72 | #include <linux/module.h> |
| 73 | #include <linux/kernel.h> |
| 74 | #include <linux/init.h> |
| 75 | #include <linux/wireless.h> |
| 76 | #include <linux/semaphore.h> |
| 77 | #include <vos_api.h> |
| 78 | #include <vos_sched.h> |
| 79 | #include <linux/etherdevice.h> |
| 80 | #include <wlan_hdd_includes.h> |
| 81 | #include <qc_sap_ioctl.h> |
| 82 | #include <wlan_hdd_hostapd.h> |
| 83 | #include <sapApi.h> |
| 84 | #include <sapInternal.h> |
| 85 | #include <wlan_qct_tl.h> |
| 86 | #include <wlan_hdd_softap_tx_rx.h> |
| 87 | #include <wlan_hdd_main.h> |
| 88 | #include <linux/netdevice.h> |
| 89 | #include <linux/mmc/sdio_func.h> |
| 90 | #include "wlan_nlink_common.h" |
| 91 | #include "wlan_btc_svc.h" |
| 92 | #include <bap_hdd_main.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 93 | #include "wlan_hdd_p2p.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 94 | |
| 95 | #define IS_UP(_dev) \ |
| 96 | (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP)) |
| 97 | #define IS_UP_AUTO(_ic) \ |
| 98 | (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO) |
| 99 | #define WE_WLAN_VERSION 1 |
| 100 | #define STATS_CONTEXT_MAGIC 0x53544154 |
Yathish Hanumapuradoddi Shivanna | 7b65940 | 2013-03-25 14:12:32 -0700 | [diff] [blame] | 101 | #define WE_GET_STA_INFO_SIZE 30 |
| 102 | /* WEXT limition: MAX allowed buf len for any * |
| 103 | * IW_PRIV_TYPE_CHAR is 2Kbytes * |
| 104 | */ |
| 105 | #define WE_SAP_MAX_STA_INFO 0x7FF |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 106 | |
| 107 | struct statsContext |
| 108 | { |
| 109 | struct completion completion; |
| 110 | hdd_adapter_t *pAdapter; |
| 111 | unsigned int magic; |
| 112 | }; |
| 113 | #define SAP_24GHZ_CH_COUNT (14) |
| 114 | /*--------------------------------------------------------------------------- |
| 115 | * Function definitions |
| 116 | *-------------------------------------------------------------------------*/ |
| 117 | /**--------------------------------------------------------------------------- |
| 118 | |
| 119 | \brief hdd_hostapd_open() - HDD Open function for hostapd interface |
| 120 | |
| 121 | This is called in response to ifconfig up |
| 122 | |
| 123 | \param - dev Pointer to net_device structure |
| 124 | |
| 125 | \return - 0 for success non-zero for failure |
| 126 | |
| 127 | --------------------------------------------------------------------------*/ |
| 128 | int hdd_hostapd_open (struct net_device *dev) |
| 129 | { |
| 130 | ENTER(); |
| 131 | |
| 132 | //Turn ON carrier state |
| 133 | netif_carrier_on(dev); |
| 134 | //Enable all Tx queues |
| 135 | netif_tx_start_all_queues(dev); |
| 136 | |
| 137 | EXIT(); |
| 138 | return 0; |
| 139 | } |
| 140 | /**--------------------------------------------------------------------------- |
| 141 | |
| 142 | \brief hdd_hostapd_stop() - HDD stop function for hostapd interface |
| 143 | |
| 144 | This is called in response to ifconfig down |
| 145 | |
| 146 | \param - dev Pointer to net_device structure |
| 147 | |
| 148 | \return - 0 for success non-zero for failure |
| 149 | |
| 150 | --------------------------------------------------------------------------*/ |
| 151 | int hdd_hostapd_stop (struct net_device *dev) |
| 152 | { |
| 153 | ENTER(); |
| 154 | |
| 155 | //Stop all tx queues |
| 156 | netif_tx_disable(dev); |
| 157 | |
| 158 | //Turn OFF carrier state |
| 159 | netif_carrier_off(dev); |
| 160 | |
| 161 | EXIT(); |
| 162 | return 0; |
| 163 | } |
| 164 | /**--------------------------------------------------------------------------- |
| 165 | |
| 166 | \brief hdd_hostapd_uninit() - HDD uninit function |
| 167 | |
| 168 | This is called during the netdev unregister to uninitialize all data |
| 169 | associated with the device |
| 170 | |
| 171 | \param - dev Pointer to net_device structure |
| 172 | |
| 173 | \return - void |
| 174 | |
| 175 | --------------------------------------------------------------------------*/ |
| 176 | static void hdd_hostapd_uninit (struct net_device *dev) |
| 177 | { |
| 178 | hdd_adapter_t *pHostapdAdapter = netdev_priv(dev); |
| 179 | |
| 180 | ENTER(); |
| 181 | |
| 182 | if (pHostapdAdapter && pHostapdAdapter->pHddCtx) |
| 183 | { |
| 184 | hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter); |
| 185 | |
| 186 | /* after uninit our adapter structure will no longer be valid */ |
| 187 | pHostapdAdapter->dev = NULL; |
| 188 | } |
| 189 | |
| 190 | EXIT(); |
| 191 | } |
| 192 | |
| 193 | |
| 194 | /**============================================================================ |
| 195 | @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for |
| 196 | transmitting packets. There are 2 versions of this function. One that uses |
| 197 | locked queue and other that uses lockless queues. Both have been retained to |
| 198 | do some performance testing |
| 199 | @param skb : [in] pointer to OS packet (sk_buff) |
| 200 | @param dev : [in] pointer to Libra network device |
| 201 | |
| 202 | @return : NET_XMIT_DROP if packets are dropped |
| 203 | : NET_XMIT_SUCCESS if packet is enqueued succesfully |
| 204 | ===========================================================================*/ |
| 205 | int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 206 | { |
| 207 | return 0; |
| 208 | } |
| 209 | int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu) |
| 210 | { |
| 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | int hdd_hostapd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 215 | { |
| 216 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 217 | hdd_priv_data_t priv_data; |
| 218 | tANI_U8 *command = NULL; |
| 219 | int ret = 0; |
| 220 | |
| 221 | if (NULL == pAdapter) |
| 222 | { |
| 223 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 224 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 225 | ret = -ENODEV; |
| 226 | goto exit; |
| 227 | } |
| 228 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 229 | if ((!ifr) || (!ifr->ifr_data)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 230 | { |
| 231 | ret = -EINVAL; |
| 232 | goto exit; |
| 233 | } |
| 234 | |
| 235 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(hdd_priv_data_t))) |
| 236 | { |
| 237 | ret = -EFAULT; |
| 238 | goto exit; |
| 239 | } |
| 240 | |
| 241 | command = kmalloc(priv_data.total_len, GFP_KERNEL); |
| 242 | if (!command) |
| 243 | { |
| 244 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 245 | "%s: failed to allocate memory\n", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 246 | ret = -ENOMEM; |
| 247 | goto exit; |
| 248 | } |
| 249 | |
| 250 | if (copy_from_user(command, priv_data.buf, priv_data.total_len)) |
| 251 | { |
| 252 | ret = -EFAULT; |
| 253 | goto exit; |
| 254 | } |
| 255 | |
| 256 | if ((SIOCDEVPRIVATE + 1) == cmd) |
| 257 | { |
| 258 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 259 | "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command); |
| 260 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 261 | if(strncmp(command, "P2P_SET_NOA", 11) == 0 ) |
| 262 | { |
| 263 | hdd_setP2pNoa(dev, command); |
| 264 | } |
| 265 | else if( strncmp(command, "P2P_SET_PS", 10) == 0 ) |
| 266 | { |
| 267 | hdd_setP2pOpps(dev, command); |
| 268 | } |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 269 | |
| 270 | /* |
| 271 | command should be a string having format |
| 272 | SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces> |
| 273 | */ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 274 | if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 275 | { |
| 276 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 277 | " Received Command to Set Preferred Channels for SAP in %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 278 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 279 | ret = sapSetPreferredChannel(command); |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 280 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 281 | } |
| 282 | exit: |
| 283 | if (command) |
| 284 | { |
| 285 | kfree(command); |
| 286 | } |
| 287 | return ret; |
| 288 | } |
| 289 | |
| 290 | /**--------------------------------------------------------------------------- |
| 291 | |
| 292 | \brief hdd_hostapd_set_mac_address() - |
| 293 | This function sets the user specified mac address using |
| 294 | the command ifconfig wlanX hw ether <mac adress>. |
| 295 | |
| 296 | \param - dev - Pointer to the net device. |
| 297 | - addr - Pointer to the sockaddr. |
| 298 | \return - 0 for success, non zero for failure |
| 299 | |
| 300 | --------------------------------------------------------------------------*/ |
| 301 | |
| 302 | static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr) |
| 303 | { |
| 304 | struct sockaddr *psta_mac_addr = addr; |
| 305 | ENTER(); |
| 306 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 307 | EXIT(); |
| 308 | return 0; |
| 309 | } |
| 310 | void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback) |
| 311 | { |
| 312 | struct net_device *dev = (struct net_device *)usrDataForCallback; |
| 313 | v_BYTE_t we_custom_event[64]; |
| 314 | union iwreq_data wrqu; |
| 315 | #ifdef DISABLE_CONCURRENCY_AUTOSAVE |
| 316 | VOS_STATUS vos_status; |
| 317 | hdd_adapter_t *pHostapdAdapter; |
| 318 | hdd_ap_ctx_t *pHddApCtx; |
| 319 | #endif /*DISABLE_CONCURRENCY_AUTOSAVE */ |
| 320 | |
| 321 | /* event_name space-delimiter driver_module_name */ |
| 322 | /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */ |
| 323 | char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME; |
| 324 | int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */ |
| 325 | |
| 326 | ENTER(); |
| 327 | |
| 328 | #ifdef DISABLE_CONCURRENCY_AUTOSAVE |
| 329 | if (vos_concurrent_sessions_running()) |
| 330 | { |
| 331 | /* |
| 332 | This timer routine is going to be called only when AP |
| 333 | persona is up. |
| 334 | If there are concurrent sessions running we do not want |
| 335 | to shut down the Bss.Instead we run the timer again so |
| 336 | that if Autosave is enabled next time and other session |
| 337 | was down only then we bring down AP |
| 338 | */ |
| 339 | pHostapdAdapter = netdev_priv(dev); |
| 340 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter); |
| 341 | vos_status = vos_timer_start( |
| 342 | &pHddApCtx->hdd_ap_inactivity_timer, |
| 343 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff |
| 344 | * 1000); |
| 345 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 346 | { |
| 347 | hddLog(LOGE, FL("Failed to init AP inactivity timer")); |
| 348 | } |
| 349 | EXIT(); |
| 350 | return; |
| 351 | } |
| 352 | #endif /*DISABLE_CONCURRENCY_AUTOSAVE */ |
| 353 | memset(&we_custom_event, '\0', sizeof(we_custom_event)); |
| 354 | memcpy(&we_custom_event, autoShutEvent, event_len); |
| 355 | |
| 356 | memset(&wrqu, 0, sizeof(wrqu)); |
| 357 | wrqu.data.length = event_len; |
| 358 | |
| 359 | hddLog(LOG1, FL("Shutting down AP interface due to inactivity")); |
| 360 | wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event); |
| 361 | |
| 362 | EXIT(); |
| 363 | } |
| 364 | |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 365 | VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter) |
| 366 | { |
| 367 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 368 | ptSapContext pSapCtx = NULL; |
| 369 | eHalStatus halStatus = eHAL_STATUS_FAILURE; |
| 370 | v_PVOID_t hHal = NULL; |
| 371 | |
| 372 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 373 | "%s: UPDATE Beacon Params", __func__); |
| 374 | |
| 375 | if(VOS_STA_SAP_MODE == vos_get_conparam ( )){ |
| 376 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 377 | if ( NULL == pSapCtx ) |
| 378 | { |
| 379 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 380 | "%s: Invalid SAP pointer from pvosGCtx", __func__); |
| 381 | return VOS_STATUS_E_FAULT; |
| 382 | } |
| 383 | |
| 384 | hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx); |
| 385 | if ( NULL == hHal ){ |
| 386 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 387 | "%s: Invalid HAL pointer from pvosGCtx", __func__); |
| 388 | return VOS_STATUS_E_FAULT; |
| 389 | } |
| 390 | halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId); |
| 391 | if(halStatus == eHAL_STATUS_FAILURE ){ |
| 392 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 393 | "%s: Failed to update Beacon Params", __func__); |
| 394 | return VOS_STATUS_E_FAILURE; |
| 395 | } |
| 396 | } |
| 397 | return VOS_STATUS_SUCCESS; |
| 398 | } |
| 399 | |
| 400 | void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback) |
| 401 | { |
| 402 | v_U8_t staId = 0; |
| 403 | struct net_device *dev; |
| 404 | dev = (struct net_device *)usrDataForCallback; |
| 405 | |
| 406 | hddLog(LOGE, FL("Clearing all the STA entry....\n")); |
| 407 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 408 | { |
| 409 | if ( pHostapdAdapter->aStaInfo[staId].isUsed && |
| 410 | ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)) |
| 411 | { |
| 412 | //Disconnect all the stations |
| 413 | hdd_softap_sta_disassoc(pHostapdAdapter, &pHostapdAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 414 | } |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | static int hdd_stop_p2p_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback) |
| 419 | { |
| 420 | struct net_device *dev; |
| 421 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 422 | dev = (struct net_device *)usrDataForCallback; |
| 423 | ENTER(); |
| 424 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
| 425 | { |
| 426 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) ) |
| 427 | { |
| 428 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting P2P link!!!!!!")); |
| 429 | } |
| 430 | clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 431 | } |
| 432 | EXIT(); |
| 433 | return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY; |
| 434 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 435 | |
| 436 | VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback) |
| 437 | { |
| 438 | hdd_adapter_t *pHostapdAdapter; |
| 439 | hdd_ap_ctx_t *pHddApCtx; |
| 440 | hdd_hostapd_state_t *pHostapdState; |
| 441 | struct net_device *dev; |
| 442 | eSapHddEvent sapEvent; |
| 443 | union iwreq_data wrqu; |
| 444 | v_BYTE_t *we_custom_event_generic = NULL; |
| 445 | int we_event = 0; |
| 446 | int i = 0; |
| 447 | v_U8_t staId; |
| 448 | VOS_STATUS vos_status; |
| 449 | v_BOOL_t bWPSState; |
| 450 | v_BOOL_t bApActive = FALSE; |
| 451 | v_BOOL_t bAuthRequired = TRUE; |
| 452 | tpSap_AssocMacAddr pAssocStasArray = NULL; |
| 453 | char unknownSTAEvent[IW_CUSTOM_MAX+1]; |
| 454 | char maxAssocExceededEvent[IW_CUSTOM_MAX+1]; |
| 455 | v_BYTE_t we_custom_start_event[64]; |
| 456 | char *startBssEvent; |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 457 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 458 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 5f12e90 | 2013-04-03 10:21:46 -0700 | [diff] [blame] | 459 | struct iw_michaelmicfailure msg; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 460 | |
| 461 | dev = (struct net_device *)usrDataForCallback; |
| 462 | pHostapdAdapter = netdev_priv(dev); |
| 463 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 464 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter); |
| 465 | sapEvent = pSapEvent->sapHddEventCode; |
| 466 | memset(&wrqu, '\0', sizeof(wrqu)); |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 467 | pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 468 | |
| 469 | switch(sapEvent) |
| 470 | { |
| 471 | case eSAP_START_BSS_EVENT : |
| 472 | hddLog(LOG1, FL("BSS configured status = %s, channel = %lu, bc sta Id = %d\n"), |
| 473 | pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS", |
| 474 | pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel, |
| 475 | pSapEvent->sapevt.sapStartBssCompleteEvent.staId); |
| 476 | |
| 477 | pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status; |
| 478 | vos_status = vos_event_set(&pHostapdState->vosEvent); |
| 479 | |
| 480 | if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus) |
| 481 | { |
| 482 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!\n")); |
| 483 | goto stopbss; |
| 484 | } |
| 485 | else |
| 486 | { |
| 487 | pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId; |
| 488 | //@@@ need wep logic here to set privacy bit |
| 489 | hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy); |
| 490 | } |
| 491 | |
| 492 | if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff) |
| 493 | { |
| 494 | // AP Inactivity timer init and start |
| 495 | vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW, |
| 496 | hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev ); |
| 497 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 498 | hddLog(LOGE, FL("Failed to init AP inactivity timer\n")); |
| 499 | |
| 500 | vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000); |
| 501 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 502 | hddLog(LOGE, FL("Failed to init AP inactivity timer\n")); |
| 503 | |
| 504 | } |
| 505 | pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel; |
| 506 | pHostapdState->bssState = BSS_START; |
| 507 | |
| 508 | // Send current operating channel of SoftAP to BTC-ES |
| 509 | send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0); |
| 510 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 511 | //Check if there is any group key pending to set. |
| 512 | if( pHddApCtx->groupKey.keyLength ) |
| 513 | { |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 514 | if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 515 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, |
| 516 | &pHddApCtx->groupKey ) ) |
| 517 | { |
| 518 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 519 | "%s: WLANSAP_SetKeySta failed", __func__); |
| 520 | } |
| 521 | pHddApCtx->groupKey.keyLength = 0; |
| 522 | } |
| 523 | else if ( pHddApCtx->wepKey[0].keyLength ) |
| 524 | { |
| 525 | int i=0; |
| 526 | for ( i = 0; i < CSR_MAX_NUM_KEY; i++ ) |
| 527 | { |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 528 | if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 529 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, |
| 530 | &pHddApCtx->wepKey[i] ) ) |
| 531 | { |
| 532 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 533 | "%s: WLANSAP_SetKeySta failed idx %d", __func__, i); |
| 534 | } |
| 535 | pHddApCtx->wepKey[i].keyLength = 0; |
| 536 | } |
| 537 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 538 | //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled |
| 539 | startBssEvent = "SOFTAP.enabled"; |
| 540 | memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event)); |
| 541 | memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent)); |
| 542 | memset(&wrqu, 0, sizeof(wrqu)); |
| 543 | wrqu.data.length = strlen(startBssEvent); |
| 544 | we_event = IWEVCUSTOM; |
| 545 | we_custom_event_generic = we_custom_start_event; |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 546 | hdd_dump_concurrency_info(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 547 | break; //Event will be sent after Switch-Case stmt |
| 548 | |
| 549 | case eSAP_STOP_BSS_EVENT: |
| 550 | hddLog(LOG1, FL("BSS stop status = %s\n"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ? |
| 551 | "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS"); |
| 552 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 553 | //Free up Channel List incase if it is set |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 554 | sapCleanupChannelList(); |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 555 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 556 | pHddApCtx->operatingChannel = 0; //Invalidate the channel info. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 557 | goto stopbss; |
| 558 | case eSAP_STA_SET_KEY_EVENT: |
| 559 | //TODO: forward the message to hostapd once implementtation is done for now just print |
| 560 | hddLog(LOG1, FL("SET Key: configured status = %s\n"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ? |
| 561 | "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS"); |
| 562 | return VOS_STATUS_SUCCESS; |
| 563 | case eSAP_STA_DEL_KEY_EVENT: |
| 564 | //TODO: forward the message to hostapd once implementtation is done for now just print |
| 565 | hddLog(LOG1, FL("Event received %s\n"),"eSAP_STA_DEL_KEY_EVENT"); |
| 566 | return VOS_STATUS_SUCCESS; |
| 567 | case eSAP_STA_MIC_FAILURE_EVENT: |
| 568 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 569 | memset(&msg, '\0', sizeof(msg)); |
| 570 | msg.src_addr.sa_family = ARPHRD_ETHER; |
Kumar Pavan | 0cf0cf2 | 2012-12-13 15:13:41 -0800 | [diff] [blame] | 571 | memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 572 | hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(msg.src_addr.sa_data)); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 573 | if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 574 | msg.flags = IW_MICFAILURE_GROUP; |
| 575 | else |
| 576 | msg.flags = IW_MICFAILURE_PAIRWISE; |
| 577 | memset(&wrqu, 0, sizeof(wrqu)); |
| 578 | wrqu.data.length = sizeof(msg); |
| 579 | we_event = IWEVMICHAELMICFAILURE; |
| 580 | we_custom_event_generic = (v_BYTE_t *)&msg; |
| 581 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 582 | /* inform mic failure to nl80211 */ |
| 583 | cfg80211_michael_mic_failure(dev, |
| 584 | pSapEvent->sapevt. |
| 585 | sapStationMICFailureEvent.staMac.bytes, |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 586 | ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 587 | NL80211_KEYTYPE_GROUP : |
| 588 | NL80211_KEYTYPE_PAIRWISE), |
| 589 | pSapEvent->sapevt.sapStationMICFailureEvent.keyId, |
| 590 | pSapEvent->sapevt.sapStationMICFailureEvent.TSC, |
| 591 | GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 592 | break; |
| 593 | |
| 594 | case eSAP_STA_ASSOC_EVENT: |
| 595 | case eSAP_STA_REASSOC_EVENT: |
| 596 | wrqu.addr.sa_family = ARPHRD_ETHER; |
| 597 | memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac, |
Kumar Pavan | 0cf0cf2 | 2012-12-13 15:13:41 -0800 | [diff] [blame] | 598 | sizeof(v_MACADDR_t)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 599 | hddLog(LOG1, " associated "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(wrqu.addr.sa_data)); |
| 600 | we_event = IWEVREGISTERED; |
| 601 | |
| 602 | WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState); |
| 603 | |
| 604 | if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) || |
| 605 | ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) || |
| 606 | ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) ) |
| 607 | { |
| 608 | bAuthRequired = FALSE; |
| 609 | } |
| 610 | |
| 611 | if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE ) |
| 612 | { |
| 613 | hdd_softap_RegisterSTA( pHostapdAdapter, |
| 614 | TRUE, |
| 615 | pHddApCtx->uPrivacy, |
| 616 | pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId, |
| 617 | 0, |
| 618 | 0, |
| 619 | (v_MACADDR_t *)wrqu.addr.sa_data, |
| 620 | pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled); |
| 621 | } |
| 622 | else |
| 623 | { |
| 624 | hdd_softap_RegisterSTA( pHostapdAdapter, |
| 625 | FALSE, |
| 626 | pHddApCtx->uPrivacy, |
| 627 | pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId, |
| 628 | 0, |
| 629 | 0, |
| 630 | (v_MACADDR_t *)wrqu.addr.sa_data, |
| 631 | pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled); |
| 632 | } |
| 633 | |
| 634 | // Stop AP inactivity timer |
| 635 | if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING) |
| 636 | { |
| 637 | vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer); |
| 638 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 639 | hddLog(LOGE, FL("Failed to start AP inactivity timer\n")); |
| 640 | } |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 641 | #ifdef WLAN_OPEN_SOURCE |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 642 | if (wake_lock_active(&pHddCtx->sap_wake_lock)) |
| 643 | { |
| 644 | wake_unlock(&pHddCtx->sap_wake_lock); |
| 645 | } |
| 646 | wake_lock_timeout(&pHddCtx->sap_wake_lock, HDD_SAP_WAKE_LOCK_DURATION); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 647 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 648 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 649 | { |
| 650 | struct station_info staInfo; |
| 651 | v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen; |
| 652 | |
| 653 | memset(&staInfo, 0, sizeof(staInfo)); |
| 654 | if (iesLen <= MAX_ASSOC_IND_IE_LEN ) |
| 655 | { |
| 656 | staInfo.assoc_req_ies = |
| 657 | (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0]; |
| 658 | staInfo.assoc_req_ies_len = iesLen; |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 659 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31)) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 660 | staInfo.filled |= STATION_INFO_ASSOC_REQ_IES; |
| 661 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 662 | cfg80211_new_sta(dev, |
| 663 | (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0], |
| 664 | &staInfo, GFP_KERNEL); |
| 665 | } |
| 666 | else |
| 667 | { |
| 668 | hddLog(LOGE, FL(" Assoc Ie length is too long \n")); |
| 669 | } |
| 670 | } |
| 671 | #endif |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 672 | pScanInfo = &pHddCtx->scan_info; |
| 673 | // Lets do abort scan to ensure smooth authentication for client |
| 674 | if ((pScanInfo != NULL) && pScanInfo->mScanPending) |
| 675 | { |
| 676 | hdd_abort_mac_scan(pHddCtx); |
| 677 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 678 | |
| 679 | break; |
| 680 | case eSAP_STA_DISASSOC_EVENT: |
| 681 | memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, |
Kumar Pavan | 0cf0cf2 | 2012-12-13 15:13:41 -0800 | [diff] [blame] | 682 | sizeof(v_MACADDR_t)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 683 | hddLog(LOG1, " disassociated "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(wrqu.addr.sa_data)); |
| 684 | if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC) |
| 685 | hddLog(LOG1," User initiated disassociation"); |
| 686 | else |
| 687 | hddLog(LOG1," MAC initiated disassociation"); |
| 688 | we_event = IWEVEXPIRED; |
| 689 | vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId); |
| 690 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 691 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 692 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 693 | return VOS_STATUS_E_FAILURE; |
| 694 | } |
| 695 | hdd_softap_DeregisterSTA(pHostapdAdapter, staId); |
| 696 | |
| 697 | if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff) |
| 698 | { |
| 699 | spin_lock_bh( &pHostapdAdapter->staInfo_lock ); |
| 700 | // Start AP inactivity timer if no stations associated with it |
| 701 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 702 | { |
| 703 | if (pHostapdAdapter->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId) |
| 704 | { |
| 705 | bApActive = TRUE; |
| 706 | break; |
| 707 | } |
| 708 | } |
| 709 | spin_unlock_bh( &pHostapdAdapter->staInfo_lock ); |
| 710 | |
| 711 | if (bApActive == FALSE) |
| 712 | { |
| 713 | if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED) |
| 714 | { |
| 715 | vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000); |
| 716 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 717 | hddLog(LOGE, FL("Failed to init AP inactivity timer\n")); |
| 718 | } |
| 719 | else |
| 720 | VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED); |
| 721 | } |
| 722 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 723 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 724 | cfg80211_del_sta(dev, |
| 725 | (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0], |
| 726 | GFP_KERNEL); |
| 727 | #endif |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 728 | //Update the beacon Interval if it is P2P GO |
| 729 | hdd_change_mcc_go_beacon_interval(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 730 | break; |
| 731 | case eSAP_WPS_PBC_PROBE_REQ_EVENT: |
| 732 | { |
| 733 | static const char * message ="MLMEWPSPBCPROBEREQ.indication"; |
| 734 | union iwreq_data wreq; |
| 735 | |
| 736 | down(&pHddApCtx->semWpsPBCOverlapInd); |
| 737 | pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen; |
| 738 | |
| 739 | vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE, |
| 740 | pHddApCtx->WPSPBCProbeReq.probeReqIELen); |
| 741 | |
| 742 | vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t)); |
| 743 | hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr)); |
| 744 | memset(&wreq, 0, sizeof(wreq)); |
| 745 | wreq.data.length = strlen(message); // This is length of message |
| 746 | wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message); |
| 747 | |
| 748 | return VOS_STATUS_SUCCESS; |
| 749 | } |
| 750 | case eSAP_ASSOC_STA_CALLBACK_EVENT: |
| 751 | pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas; |
| 752 | if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0) |
| 753 | { // List of associated stations |
| 754 | for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++) |
| 755 | { |
| 756 | hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR, |
| 757 | i+1, |
| 758 | pAssocStasArray->assocId, |
| 759 | pAssocStasArray->staId, |
| 760 | MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes)); |
| 761 | pAssocStasArray++; |
| 762 | } |
| 763 | } |
| 764 | vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here |
| 765 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 766 | case eSAP_INDICATE_MGMT_FRAME: |
| 767 | hdd_indicateMgmtFrame( pHostapdAdapter, |
| 768 | pSapEvent->sapevt.sapManagementFrameInfo.nFrameLength, |
| 769 | pSapEvent->sapevt.sapManagementFrameInfo.pbFrames, |
| 770 | pSapEvent->sapevt.sapManagementFrameInfo.frameType, |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 771 | pSapEvent->sapevt.sapManagementFrameInfo.rxChan, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 772 | return VOS_STATUS_SUCCESS; |
| 773 | case eSAP_REMAIN_CHAN_READY: |
| 774 | hdd_remainChanReadyHandler( pHostapdAdapter ); |
| 775 | return VOS_STATUS_SUCCESS; |
| 776 | case eSAP_SEND_ACTION_CNF: |
| 777 | hdd_sendActionCnf( pHostapdAdapter, |
| 778 | ( eSAP_STATUS_SUCCESS == |
| 779 | pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ? |
| 780 | TRUE : FALSE ); |
| 781 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 782 | case eSAP_UNKNOWN_STA_JOIN: |
| 783 | snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x", |
| 784 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0], |
| 785 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1], |
| 786 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2], |
| 787 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3], |
| 788 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4], |
| 789 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]); |
| 790 | we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */ |
| 791 | wrqu.data.pointer = unknownSTAEvent; |
| 792 | wrqu.data.length = strlen(unknownSTAEvent); |
| 793 | we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent; |
| 794 | hddLog(LOG1,"%s\n", unknownSTAEvent); |
| 795 | break; |
| 796 | |
| 797 | case eSAP_MAX_ASSOC_EXCEEDED: |
| 798 | snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied" |
| 799 | " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect" |
| 800 | " one or more devices to enable the new device connection", |
| 801 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0], |
| 802 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1], |
| 803 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2], |
| 804 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3], |
| 805 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4], |
| 806 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]); |
| 807 | we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */ |
| 808 | wrqu.data.pointer = maxAssocExceededEvent; |
| 809 | wrqu.data.length = strlen(maxAssocExceededEvent); |
| 810 | we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent; |
| 811 | hddLog(LOG1,"%s\n", maxAssocExceededEvent); |
| 812 | break; |
| 813 | case eSAP_STA_ASSOC_IND: |
| 814 | return VOS_STATUS_SUCCESS; |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 815 | |
| 816 | case eSAP_DISCONNECT_ALL_P2P_CLIENT: |
| 817 | hddLog(LOG1, FL(" Disconnecting all the P2P Clients....\n")); |
| 818 | hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback); |
| 819 | return VOS_STATUS_SUCCESS; |
| 820 | |
| 821 | case eSAP_MAC_TRIG_STOP_BSS_EVENT : |
| 822 | hdd_stop_p2p_link(pHostapdAdapter, usrDataForCallback); |
| 823 | return VOS_STATUS_SUCCESS; |
| 824 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 825 | default: |
| 826 | hddLog(LOG1,"SAP message is not handled\n"); |
| 827 | goto stopbss; |
| 828 | return VOS_STATUS_SUCCESS; |
| 829 | } |
| 830 | wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic); |
| 831 | return VOS_STATUS_SUCCESS; |
| 832 | |
| 833 | stopbss : |
| 834 | { |
| 835 | v_BYTE_t we_custom_event[64]; |
| 836 | char *stopBssEvent = "STOP-BSS.response";//17 |
| 837 | int event_len = strlen(stopBssEvent); |
| 838 | |
| 839 | hddLog(LOG1, FL("BSS stop status = %s"), |
| 840 | pSapEvent->sapevt.sapStopBssCompleteEvent.status ? |
| 841 | "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS"); |
| 842 | |
| 843 | /* Change the BSS state now since, as we are shutting things down, |
| 844 | * we don't want interfaces to become re-enabled */ |
| 845 | pHostapdState->bssState = BSS_STOP; |
| 846 | |
| 847 | /* Stop the pkts from n/w stack as we are going to free all of |
| 848 | * the TX WMM queues for all STAID's */ |
| 849 | hdd_hostapd_stop(dev); |
| 850 | |
| 851 | /* reclaim all resources allocated to the BSS */ |
| 852 | hdd_softap_stop_bss(pHostapdAdapter); |
| 853 | |
Amar Singhal | 37e6f05 | 2013-03-05 16:16:54 -0800 | [diff] [blame] | 854 | /* once the event is set, structure dev/pHostapdAdapter should |
| 855 | * not be touched since they are now subject to being deleted |
| 856 | * by another thread */ |
| 857 | if (eSAP_STOP_BSS_EVENT == sapEvent) |
| 858 | vos_event_set(&pHostapdState->vosEvent); |
| 859 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 860 | /* notify userspace that the BSS has stopped */ |
| 861 | memset(&we_custom_event, '\0', sizeof(we_custom_event)); |
| 862 | memcpy(&we_custom_event, stopBssEvent, event_len); |
| 863 | memset(&wrqu, 0, sizeof(wrqu)); |
| 864 | wrqu.data.length = event_len; |
| 865 | we_event = IWEVCUSTOM; |
| 866 | we_custom_event_generic = we_custom_event; |
| 867 | wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic); |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 868 | hdd_dump_concurrency_info(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 869 | } |
| 870 | return VOS_STATUS_SUCCESS; |
| 871 | } |
| 872 | int hdd_softap_unpackIE( |
| 873 | tHalHandle halHandle, |
| 874 | eCsrEncryptionType *pEncryptType, |
| 875 | eCsrEncryptionType *mcEncryptType, |
| 876 | eCsrAuthType *pAuthType, |
| 877 | u_int16_t gen_ie_len, |
| 878 | u_int8_t *gen_ie ) |
| 879 | { |
| 880 | tDot11fIERSN dot11RSNIE; |
| 881 | tDot11fIEWPA dot11WPAIE; |
| 882 | |
| 883 | tANI_U8 *pRsnIe; |
| 884 | tANI_U16 RSNIeLen; |
| 885 | |
| 886 | if (NULL == halHandle) |
| 887 | { |
| 888 | hddLog(LOGE, FL("Error haHandle returned NULL\n")); |
| 889 | return -EINVAL; |
| 890 | } |
| 891 | |
| 892 | // Validity checks |
| 893 | if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) || |
| 894 | (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) ) |
| 895 | return -EINVAL; |
| 896 | // Type check |
| 897 | if ( gen_ie[0] == DOT11F_EID_RSN) |
| 898 | { |
| 899 | // Validity checks |
| 900 | if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) || |
| 901 | (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) ) |
| 902 | { |
| 903 | return VOS_STATUS_E_FAILURE; |
| 904 | } |
| 905 | // Skip past the EID byte and length byte |
| 906 | pRsnIe = gen_ie + 2; |
| 907 | RSNIeLen = gen_ie_len - 2; |
| 908 | // Unpack the RSN IE |
| 909 | memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN)); |
| 910 | dot11fUnpackIeRSN((tpAniSirGlobal) halHandle, |
| 911 | pRsnIe, |
| 912 | RSNIeLen, |
| 913 | &dot11RSNIE); |
| 914 | // Copy out the encryption and authentication types |
| 915 | hddLog(LOG1, FL("%s: pairwise cipher suite count: %d\n"), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 916 | __func__, dot11RSNIE.pwise_cipher_suite_count ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 917 | hddLog(LOG1, FL("%s: authentication suite count: %d\n"), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 918 | __func__, dot11RSNIE.akm_suite_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 919 | /*Here we have followed the apple base code, |
| 920 | but probably I suspect we can do something different*/ |
| 921 | //dot11RSNIE.akm_suite_count |
| 922 | // Just translate the FIRST one |
| 923 | *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]); |
| 924 | //dot11RSNIE.pwise_cipher_suite_count |
| 925 | *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]); |
| 926 | //dot11RSNIE.gp_cipher_suite_count |
| 927 | *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite); |
| 928 | // Set the PMKSA ID Cache for this interface |
| 929 | |
| 930 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
| 931 | } else |
| 932 | if (gen_ie[0] == DOT11F_EID_WPA) |
| 933 | { |
| 934 | // Validity checks |
| 935 | if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) || |
| 936 | (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) |
| 937 | { |
| 938 | return VOS_STATUS_E_FAILURE; |
| 939 | } |
| 940 | // Skip past the EID byte and length byte - and four byte WiFi OUI |
| 941 | pRsnIe = gen_ie + 2 + 4; |
| 942 | RSNIeLen = gen_ie_len - (2 + 4); |
| 943 | // Unpack the WPA IE |
| 944 | memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA)); |
| 945 | dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 946 | pRsnIe, |
| 947 | RSNIeLen, |
| 948 | &dot11WPAIE); |
| 949 | // Copy out the encryption and authentication types |
| 950 | hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d\n"), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 951 | __func__, dot11WPAIE.unicast_cipher_count ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 952 | hddLog(LOG1, FL("%s: WPA authentication suite count: %d\n"), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 953 | __func__, dot11WPAIE.auth_suite_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 954 | //dot11WPAIE.auth_suite_count |
| 955 | // Just translate the FIRST one |
| 956 | *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]); |
| 957 | //dot11WPAIE.unicast_cipher_count |
| 958 | *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]); |
| 959 | //dot11WPAIE.unicast_cipher_count |
| 960 | *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
| 961 | } |
| 962 | else |
| 963 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 964 | hddLog(LOGW, FL("%s: gen_ie[0]: %d\n"), __func__, gen_ie[0]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 965 | return VOS_STATUS_E_FAILURE; |
| 966 | } |
| 967 | return VOS_STATUS_SUCCESS; |
| 968 | } |
| 969 | int |
| 970 | static iw_softap_setparam(struct net_device *dev, |
| 971 | struct iw_request_info *info, |
| 972 | union iwreq_data *wrqu, char *extra) |
| 973 | { |
| 974 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 975 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 976 | int *value = (int *)extra; |
| 977 | int sub_cmd = value[0]; |
| 978 | int set_value = value[1]; |
| 979 | eHalStatus status; |
| 980 | int ret = 0; /* success */ |
| 981 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 982 | |
| 983 | switch(sub_cmd) |
| 984 | { |
| 985 | |
| 986 | case QCSAP_PARAM_CLR_ACL: |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 987 | if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 988 | { |
| 989 | ret = -EIO; |
| 990 | } |
| 991 | break; |
| 992 | |
| 993 | case QCSAP_PARAM_ACL_MODE: |
| 994 | if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) || |
| 995 | (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value)) |
| 996 | { |
| 997 | hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value); |
| 998 | ret = -EINVAL; |
| 999 | } |
| 1000 | else |
| 1001 | { |
| 1002 | WLANSAP_SetMode(pVosContext, set_value); |
| 1003 | } |
| 1004 | break; |
| 1005 | case QCSAP_PARAM_MAX_ASSOC: |
| 1006 | if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) |
| 1007 | { |
| 1008 | hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value); |
| 1009 | ret = -EINVAL; |
| 1010 | } |
| 1011 | else |
| 1012 | { |
| 1013 | if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) |
| 1014 | { |
| 1015 | hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d." |
| 1016 | "Setting it to max allowed and continuing"), |
| 1017 | set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX); |
| 1018 | set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX; |
| 1019 | } |
| 1020 | status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, |
| 1021 | set_value, NULL, eANI_BOOLEAN_FALSE); |
| 1022 | if ( status != eHAL_STATUS_SUCCESS ) |
| 1023 | { |
| 1024 | hddLog(LOGE, FL("setMaxAssoc failure, status %d"), |
| 1025 | status); |
| 1026 | ret = -EIO; |
| 1027 | } |
| 1028 | } |
| 1029 | break; |
| 1030 | |
| 1031 | case QCSAP_PARAM_HIDE_SSID: |
| 1032 | { |
| 1033 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1034 | status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value); |
| 1035 | if(eHAL_STATUS_SUCCESS != status) |
| 1036 | { |
| 1037 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1038 | "%s: QCSAP_PARAM_HIDE_SSID failed", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1039 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1040 | return status; |
| 1041 | } |
| 1042 | break; |
| 1043 | } |
| 1044 | |
| 1045 | default: |
| 1046 | hddLog(LOGE, FL("Invalid setparam command %d value %d"), |
| 1047 | sub_cmd, set_value); |
| 1048 | ret = -EINVAL; |
| 1049 | break; |
| 1050 | } |
| 1051 | |
| 1052 | return ret; |
| 1053 | } |
| 1054 | |
| 1055 | |
| 1056 | int |
| 1057 | static iw_softap_getparam(struct net_device *dev, |
| 1058 | struct iw_request_info *info, |
| 1059 | union iwreq_data *wrqu, char *extra) |
| 1060 | { |
| 1061 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1062 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 1063 | int *value = (int *)extra; |
| 1064 | int sub_cmd = value[0]; |
| 1065 | eHalStatus status; |
| 1066 | int ret = 0; /* success */ |
| 1067 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 1068 | |
| 1069 | switch (sub_cmd) |
| 1070 | { |
| 1071 | case QCSAP_PARAM_MAX_ASSOC: |
| 1072 | status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value); |
| 1073 | if (eHAL_STATUS_SUCCESS != status) |
| 1074 | { |
| 1075 | ret = -EIO; |
| 1076 | } |
| 1077 | break; |
| 1078 | |
| 1079 | case QCSAP_PARAM_CLR_ACL: |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1080 | if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1081 | { |
| 1082 | ret = -EIO; |
| 1083 | } |
| 1084 | *value = 0; |
| 1085 | break; |
| 1086 | |
| 1087 | case QCSAP_PARAM_MODULE_DOWN_IND: |
| 1088 | { |
| 1089 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1090 | "%s: sending WLAN_MODULE_DOWN_IND", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1091 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
| 1092 | #ifdef WLAN_BTAMP_FEATURE |
| 1093 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1094 | "%s: Take down AMP PAL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1095 | BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL)); |
| 1096 | #endif |
| 1097 | *value = 0; |
| 1098 | break; |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1099 | } |
| 1100 | |
| 1101 | case QCSAP_PARAM_GET_WLAN_DBG: |
| 1102 | { |
| 1103 | vos_trace_display(); |
| 1104 | *value = 0; |
| 1105 | break; |
| 1106 | } |
| 1107 | |
| 1108 | case QCSAP_PARAM_AUTO_CHANNEL: |
| 1109 | { |
| 1110 | *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection; |
| 1111 | break; |
| 1112 | } |
| 1113 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1114 | default: |
| 1115 | hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd); |
| 1116 | ret = -EINVAL; |
| 1117 | break; |
| 1118 | |
| 1119 | } |
| 1120 | |
| 1121 | return ret; |
| 1122 | } |
| 1123 | |
| 1124 | /* Usage: |
| 1125 | BLACK_LIST = 0 |
| 1126 | WHITE_LIST = 1 |
| 1127 | ADD MAC = 0 |
| 1128 | REMOVE MAC = 1 |
| 1129 | |
| 1130 | mac addr will be accepted as a 6 octet mac address with each octet inputted in hex |
| 1131 | for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33 |
| 1132 | while using this ioctl |
| 1133 | |
| 1134 | Syntax: |
| 1135 | iwpriv softap.0 modify_acl |
| 1136 | <6 octet mac addr> <list type> <cmd type> |
| 1137 | |
| 1138 | Examples: |
| 1139 | eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list |
| 1140 | iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0 |
| 1141 | eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list |
| 1142 | iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1 |
| 1143 | */ |
| 1144 | int iw_softap_modify_acl(struct net_device *dev, struct iw_request_info *info, |
| 1145 | union iwreq_data *wrqu, char *extra) |
| 1146 | { |
| 1147 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1148 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 1149 | v_BYTE_t *value = (v_BYTE_t*)extra; |
| 1150 | v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE]; |
| 1151 | int listType, cmd, i; |
| 1152 | int ret = 0; /* success */ |
| 1153 | |
| 1154 | ENTER(); |
| 1155 | for (i=0; i<VOS_MAC_ADDR_SIZE; i++) |
| 1156 | { |
| 1157 | pPeerStaMac[i] = *(value+i); |
| 1158 | } |
| 1159 | listType = (int)(*(value+i)); |
| 1160 | i++; |
| 1161 | cmd = (int)(*(value+i)); |
| 1162 | |
| 1163 | hddLog(LOG1, "%s: SAP Modify ACL arg0 %02x:%02x:%02x:%02x:%02x:%02x arg1 %d arg2 %d\n", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1164 | __func__, pPeerStaMac[0], pPeerStaMac[1], pPeerStaMac[2], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1165 | pPeerStaMac[3], pPeerStaMac[4], pPeerStaMac[5], listType, cmd); |
| 1166 | |
| 1167 | if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd) |
| 1168 | != VOS_STATUS_SUCCESS) |
| 1169 | { |
| 1170 | hddLog(LOGE, FL("Modify ACL failed\n")); |
| 1171 | ret = -EIO; |
| 1172 | } |
| 1173 | EXIT(); |
| 1174 | return ret; |
| 1175 | } |
| 1176 | |
| 1177 | int |
| 1178 | static iw_softap_getchannel(struct net_device *dev, |
| 1179 | struct iw_request_info *info, |
| 1180 | union iwreq_data *wrqu, char *extra) |
| 1181 | { |
| 1182 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1183 | |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1184 | int *value = (int *)extra; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1185 | |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1186 | *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1187 | return 0; |
| 1188 | } |
| 1189 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1190 | int |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 1191 | static iw_softap_set_max_tx_power(struct net_device *dev, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1192 | struct iw_request_info *info, |
| 1193 | union iwreq_data *wrqu, char *extra) |
| 1194 | { |
| 1195 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1196 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 1197 | int *value = (int *)extra; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1198 | int set_value; |
| 1199 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 1200 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 1201 | |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 1202 | if (NULL == value) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1203 | return -ENOMEM; |
| 1204 | |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 1205 | set_value = value[0]; |
| 1206 | if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value)) |
| 1207 | { |
| 1208 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1209 | __func__); |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 1210 | return -EIO; |
| 1211 | } |
| 1212 | |
| 1213 | return 0; |
| 1214 | } |
| 1215 | |
| 1216 | int |
| 1217 | static iw_softap_set_tx_power(struct net_device *dev, |
| 1218 | struct iw_request_info *info, |
| 1219 | union iwreq_data *wrqu, char *extra) |
| 1220 | { |
| 1221 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1222 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 1223 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 1224 | int *value = (int *)extra; |
| 1225 | int set_value; |
| 1226 | ptSapContext pSapCtx = NULL; |
| 1227 | |
| 1228 | if (NULL == value) |
| 1229 | return -ENOMEM; |
| 1230 | |
| 1231 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 1232 | if (NULL == pSapCtx) |
| 1233 | { |
| 1234 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 1235 | "%s: Invalid SAP pointer from pvosGCtx", __func__); |
| 1236 | return VOS_STATUS_E_FAULT; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1237 | } |
| 1238 | |
| 1239 | set_value = value[0]; |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 1240 | if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value)) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1241 | { |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 1242 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed", |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1243 | __func__); |
| 1244 | return -EIO; |
| 1245 | } |
| 1246 | |
| 1247 | return 0; |
| 1248 | } |
| 1249 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1250 | #define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0) |
| 1251 | |
| 1252 | int |
| 1253 | static iw_softap_getassoc_stamacaddr(struct net_device *dev, |
| 1254 | struct iw_request_info *info, |
| 1255 | union iwreq_data *wrqu, char *extra) |
| 1256 | { |
| 1257 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1258 | unsigned char *pmaclist; |
| 1259 | hdd_station_info_t *pStaInfo = pHostapdAdapter->aStaInfo; |
| 1260 | int cnt = 0, len; |
| 1261 | |
| 1262 | |
| 1263 | pmaclist = wrqu->data.pointer + sizeof(unsigned long int); |
| 1264 | len = wrqu->data.length; |
| 1265 | |
| 1266 | spin_lock_bh( &pHostapdAdapter->staInfo_lock ); |
| 1267 | while((cnt < WLAN_MAX_STA_COUNT) && (len > (sizeof(v_MACADDR_t)+1))) { |
| 1268 | if (TRUE == pStaInfo[cnt].isUsed) { |
| 1269 | |
| 1270 | if(!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes)) { |
| 1271 | memcpy((void *)pmaclist, (void *)&(pStaInfo[cnt].macAddrSTA), sizeof(v_MACADDR_t)); |
| 1272 | pmaclist += sizeof(v_MACADDR_t); |
| 1273 | len -= sizeof(v_MACADDR_t); |
| 1274 | } |
| 1275 | } |
| 1276 | cnt++; |
| 1277 | } |
| 1278 | spin_unlock_bh( &pHostapdAdapter->staInfo_lock ); |
| 1279 | |
| 1280 | *pmaclist = '\0'; |
| 1281 | |
| 1282 | wrqu->data.length -= len; |
| 1283 | |
| 1284 | *(unsigned long int *)(wrqu->data.pointer) = wrqu->data.length; |
| 1285 | |
| 1286 | return 0; |
| 1287 | } |
| 1288 | |
| 1289 | /* Usage: |
| 1290 | mac addr will be accepted as a 6 octet mac address with each octet inputted in hex |
| 1291 | for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33 |
| 1292 | while using this ioctl |
| 1293 | |
| 1294 | Syntax: |
| 1295 | iwpriv softap.0 disassoc_sta <6 octet mac address> |
| 1296 | |
| 1297 | e.g. |
| 1298 | disassociate sta with mac addr 00:0a:f5:11:22:33 from softap |
| 1299 | iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33 |
| 1300 | */ |
| 1301 | |
| 1302 | int |
| 1303 | static iw_softap_disassoc_sta(struct net_device *dev, |
| 1304 | struct iw_request_info *info, |
| 1305 | union iwreq_data *wrqu, char *extra) |
| 1306 | { |
| 1307 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1308 | v_U8_t *peerMacAddr; |
| 1309 | |
| 1310 | ENTER(); |
Gopichand Nakkala | 252c9ef | 2013-02-27 17:01:23 +0530 | [diff] [blame] | 1311 | /* iwpriv tool or framework calls this ioctl with |
| 1312 | * data passed in extra (less than 16 octets); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1313 | */ |
Gopichand Nakkala | 252c9ef | 2013-02-27 17:01:23 +0530 | [diff] [blame] | 1314 | peerMacAddr = (v_U8_t *)(extra); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1315 | |
| 1316 | hddLog(LOG1, "data %02x:%02x:%02x:%02x:%02x:%02x", |
| 1317 | peerMacAddr[0], peerMacAddr[1], peerMacAddr[2], |
| 1318 | peerMacAddr[3], peerMacAddr[4], peerMacAddr[5]); |
| 1319 | hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr); |
| 1320 | EXIT(); |
| 1321 | return 0; |
| 1322 | } |
| 1323 | |
| 1324 | int |
| 1325 | static iw_softap_ap_stats(struct net_device *dev, |
| 1326 | struct iw_request_info *info, |
| 1327 | union iwreq_data *wrqu, char *extra) |
| 1328 | { |
| 1329 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1330 | WLANTL_TRANSFER_STA_TYPE statBuffer; |
| 1331 | char *pstatbuf; |
| 1332 | int len = wrqu->data.length; |
| 1333 | pstatbuf = wrqu->data.pointer; |
| 1334 | |
| 1335 | WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &statBuffer, (v_BOOL_t)wrqu->data.flags); |
| 1336 | |
| 1337 | len = snprintf(pstatbuf, len, |
| 1338 | "RUF=%d RMF=%d RBF=%d " |
| 1339 | "RUB=%d RMB=%d RBB=%d " |
| 1340 | "TUF=%d TMF=%d TBF=%d " |
| 1341 | "TUB=%d TMB=%d TBB=%d", |
| 1342 | (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt, (int)statBuffer.rxBCFcnt, |
| 1343 | (int)statBuffer.rxUCBcnt, (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt, |
| 1344 | (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt, (int)statBuffer.txBCFcnt, |
| 1345 | (int)statBuffer.txUCBcnt, (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt |
| 1346 | ); |
| 1347 | |
| 1348 | wrqu->data.length -= len; |
| 1349 | return 0; |
| 1350 | } |
| 1351 | |
| 1352 | int |
| 1353 | static iw_softap_commit(struct net_device *dev, |
| 1354 | struct iw_request_info *info, |
| 1355 | union iwreq_data *wrqu, char *extra) |
| 1356 | { |
| 1357 | VOS_STATUS vos_status = VOS_STATUS_SUCCESS; |
| 1358 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1359 | hdd_hostapd_state_t *pHostapdState; |
| 1360 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 1361 | tpWLAN_SAPEventCB pSapEventCallback; |
| 1362 | tsap_Config_t *pConfig; |
| 1363 | s_CommitConfig_t *pCommitConfig; |
| 1364 | struct qc_mac_acl_entry *acl_entry = NULL; |
| 1365 | v_SINT_t i = 0, num_mac = 0; |
| 1366 | v_U32_t status = 0; |
| 1367 | eCsrAuthType RSNAuthType; |
| 1368 | eCsrEncryptionType RSNEncryptType; |
| 1369 | eCsrEncryptionType mcRSNEncryptType; |
| 1370 | |
| 1371 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 1372 | pCommitConfig = (s_CommitConfig_t *)extra; |
| 1373 | |
| 1374 | pConfig = kmalloc(sizeof(tsap_Config_t), GFP_KERNEL); |
| 1375 | if(NULL == pConfig) { |
| 1376 | hddLog(LOG1, "VOS unable to allocate memory\n"); |
| 1377 | return -ENOMEM; |
| 1378 | } |
| 1379 | pConfig->beacon_int = pCommitConfig->beacon_int; |
| 1380 | pConfig->channel = pCommitConfig->channel; |
| 1381 | |
| 1382 | /*Protection parameter to enable or disable*/ |
| 1383 | pConfig->protEnabled = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 1384 | pConfig->dtim_period = pCommitConfig->dtim_period; |
| 1385 | switch(pCommitConfig->hw_mode ) |
| 1386 | { |
| 1387 | case eQC_DOT11_MODE_11A: |
| 1388 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11a; |
| 1389 | break; |
| 1390 | case eQC_DOT11_MODE_11B: |
| 1391 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11b; |
| 1392 | break; |
| 1393 | case eQC_DOT11_MODE_11G: |
| 1394 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11g; |
| 1395 | break; |
| 1396 | |
| 1397 | case eQC_DOT11_MODE_11N: |
| 1398 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n; |
| 1399 | break; |
| 1400 | case eQC_DOT11_MODE_11G_ONLY: |
| 1401 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 1402 | break; |
| 1403 | case eQC_DOT11_MODE_11N_ONLY: |
| 1404 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n_ONLY; |
| 1405 | break; |
| 1406 | default: |
| 1407 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n; |
| 1408 | break; |
| 1409 | |
| 1410 | } |
| 1411 | |
| 1412 | pConfig->ieee80211d = pCommitConfig->qcsap80211d; |
| 1413 | vos_mem_copy(pConfig->countryCode, pCommitConfig->countryCode, 3); |
| 1414 | if(pCommitConfig->authType == eQC_AUTH_TYPE_SHARED_KEY) |
| 1415 | pConfig->authType = eSAP_SHARED_KEY; |
| 1416 | else if(pCommitConfig->authType == eQC_AUTH_TYPE_OPEN_SYSTEM) |
| 1417 | pConfig->authType = eSAP_OPEN_SYSTEM; |
| 1418 | else |
| 1419 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 1420 | |
| 1421 | pConfig->privacy = pCommitConfig->privacy; |
| 1422 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pCommitConfig->privacy; |
| 1423 | pConfig->wps_state = pCommitConfig->wps_state; |
| 1424 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
| 1425 | pConfig->RSNWPAReqIELength = pCommitConfig->RSNWPAReqIELength; |
| 1426 | if(pConfig->RSNWPAReqIELength){ |
| 1427 | pConfig->pRSNWPAReqIE = &pCommitConfig->RSNWPAReqIE[0]; |
| 1428 | if ((pConfig->pRSNWPAReqIE[0] == DOT11F_EID_RSN) || (pConfig->pRSNWPAReqIE[0] == DOT11F_EID_WPA)){ |
| 1429 | // The actual processing may eventually be more extensive than this. |
| 1430 | // Right now, just consume any PMKIDs that are sent in by the app. |
| 1431 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1432 | vos_get_context( VOS_MODULE_ID_PE, pVosContext), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1433 | &RSNEncryptType, |
| 1434 | &mcRSNEncryptType, |
| 1435 | &RSNAuthType, |
| 1436 | pConfig->pRSNWPAReqIE[1]+2, |
| 1437 | pConfig->pRSNWPAReqIE ); |
| 1438 | |
| 1439 | if( VOS_STATUS_SUCCESS == status ) |
| 1440 | { |
| 1441 | // Now copy over all the security attributes you have parsed out |
| 1442 | //TODO: Need to handle mixed mode |
| 1443 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1444 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1445 | hddLog( LOG1, FL("%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d\n"), |
| 1446 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1447 | } |
| 1448 | } |
| 1449 | } |
| 1450 | else |
| 1451 | { |
| 1452 | /* If no RSNIE, set encrypt type to NONE*/ |
| 1453 | pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE; |
| 1454 | pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE; |
| 1455 | hddLog( LOG1, FL("EncryptionType = %d mcEncryptionType = %d\n"), |
| 1456 | pConfig->RSNEncryptType, pConfig->mcRSNEncryptType); |
| 1457 | } |
| 1458 | |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 1459 | if (pConfig->RSNWPAReqIELength > QCSAP_MAX_OPT_IE) { |
| 1460 | hddLog(LOGE, FL("RSNWPAReqIELength: %d too large"), pConfig->RSNWPAReqIELength); |
| 1461 | kfree(pConfig); |
| 1462 | return -EIO; |
| 1463 | } |
| 1464 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1465 | pConfig->SSIDinfo.ssidHidden = pCommitConfig->SSIDinfo.ssidHidden; |
| 1466 | pConfig->SSIDinfo.ssid.length = pCommitConfig->SSIDinfo.ssid.length; |
| 1467 | vos_mem_copy(pConfig->SSIDinfo.ssid.ssId, pCommitConfig->SSIDinfo.ssid.ssId, pConfig->SSIDinfo.ssid.length); |
| 1468 | vos_mem_copy(pConfig->self_macaddr.bytes, pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
| 1469 | |
| 1470 | pConfig->SapMacaddr_acl = pCommitConfig->qc_macaddr_acl; |
| 1471 | |
| 1472 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 1473 | pConfig->ht_capab = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 1474 | |
| 1475 | if (pCommitConfig->num_accept_mac > MAX_MAC_ADDRESS_ACCEPTED) |
| 1476 | num_mac = pConfig->num_accept_mac = MAX_MAC_ADDRESS_ACCEPTED; |
| 1477 | else |
| 1478 | num_mac = pConfig->num_accept_mac = pCommitConfig->num_accept_mac; |
| 1479 | acl_entry = pCommitConfig->accept_mac; |
| 1480 | for (i = 0; i < num_mac; i++) |
| 1481 | { |
| 1482 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(v_MACADDR_t)); |
| 1483 | acl_entry++; |
| 1484 | } |
| 1485 | if (pCommitConfig->num_deny_mac > MAX_MAC_ADDRESS_DENIED) |
| 1486 | num_mac = pConfig->num_deny_mac = MAX_MAC_ADDRESS_DENIED; |
| 1487 | else |
| 1488 | num_mac = pConfig->num_deny_mac = pCommitConfig->num_deny_mac; |
| 1489 | acl_entry = pCommitConfig->deny_mac; |
| 1490 | for (i = 0; i < num_mac; i++) |
| 1491 | { |
| 1492 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(v_MACADDR_t)); |
| 1493 | acl_entry++; |
| 1494 | } |
| 1495 | //Uapsd Enabled Bit |
| 1496 | pConfig->UapsdEnable = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 1497 | //Enable OBSS protection |
| 1498 | pConfig->obssProtEnabled = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
| 1499 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->apDisableIntraBssFwd = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apDisableIntraBssFwd; |
| 1500 | |
| 1501 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"), MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
| 1502 | hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId); |
| 1503 | hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int, (int)pConfig->channel); |
| 1504 | hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode); |
| 1505 | hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy, pConfig->authType); |
| 1506 | hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength); |
| 1507 | hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable); |
| 1508 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),pConfig->protEnabled, pConfig->obssProtEnabled); |
| 1509 | hddLog(LOGW,FL("DisableIntraBssFwd = %d\n"),(WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->apDisableIntraBssFwd); |
| 1510 | |
| 1511 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 1512 | pConfig->persona = pHostapdAdapter->device_mode; |
| 1513 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,(v_PVOID_t)dev) != VOS_STATUS_SUCCESS) |
| 1514 | { |
| 1515 | hddLog(LOGE,FL("SAP Start Bss fail\n")); |
| 1516 | } |
| 1517 | |
| 1518 | kfree(pConfig); |
| 1519 | |
| 1520 | hddLog(LOG1, FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 1521 | vos_status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 1522 | |
| 1523 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 1524 | { |
| 1525 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 1526 | VOS_ASSERT(0); |
| 1527 | } |
| 1528 | |
| 1529 | pHostapdState->bCommit = TRUE; |
| 1530 | if(pHostapdState->vosStatus) |
| 1531 | { |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 1532 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1533 | } |
| 1534 | else |
| 1535 | { |
| 1536 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 1537 | WLANSAP_Update_WpsIe ( pVosContext ); |
| 1538 | return 0; |
| 1539 | } |
| 1540 | } |
| 1541 | static |
| 1542 | int iw_softap_setmlme(struct net_device *dev, |
| 1543 | struct iw_request_info *info, |
| 1544 | union iwreq_data *wrqu, char *extra) |
| 1545 | { |
| 1546 | struct sQcSapreq_mlme *pmlme; |
| 1547 | hdd_adapter_t *pHostapdAdapter = (hdd_adapter_t*)(netdev_priv(dev)); |
| 1548 | v_MACADDR_t destAddress; |
| 1549 | pmlme = (struct sQcSapreq_mlme *)(wrqu->name); |
| 1550 | /* NOTE: this address is not valid incase of TKIP failure, since not filled */ |
| 1551 | vos_mem_copy(&destAddress.bytes, pmlme->im_macaddr, sizeof(v_MACADDR_t)); |
| 1552 | switch(pmlme->im_op) |
| 1553 | { |
| 1554 | case QCSAP_MLME_AUTHORIZE: |
| 1555 | hdd_softap_change_STA_state( pHostapdAdapter, &destAddress, WLANTL_STA_AUTHENTICATED); |
| 1556 | break; |
| 1557 | case QCSAP_MLME_ASSOC: |
| 1558 | //TODO:inform to TL after associating (not needed as we do in sapCallback) |
| 1559 | break; |
| 1560 | case QCSAP_MLME_UNAUTHORIZE: |
| 1561 | //TODO: send the disassoc to station |
| 1562 | //hdd_softap_change_STA_state( pHostapdAdapter, pmlme->im_macaddr, WLANTL_STA_AUTHENTICATED); |
| 1563 | break; |
| 1564 | case QCSAP_MLME_DISASSOC: |
| 1565 | hdd_softap_sta_disassoc(pHostapdAdapter,pmlme->im_macaddr); |
| 1566 | break; |
| 1567 | case QCSAP_MLME_DEAUTH: |
| 1568 | hdd_softap_sta_deauth(pHostapdAdapter,pmlme->im_macaddr); |
| 1569 | break; |
| 1570 | case QCSAP_MLME_MICFAILURE: |
| 1571 | hdd_softap_tkip_mic_fail_counter_measure(pHostapdAdapter,pmlme->im_reason); |
| 1572 | break; |
| 1573 | default: |
| 1574 | break; |
| 1575 | } |
| 1576 | return 0; |
| 1577 | } |
| 1578 | |
| 1579 | static int iw_softap_set_channel_range(struct net_device *dev, |
| 1580 | struct iw_request_info *info, |
| 1581 | union iwreq_data *wrqu, char *extra) |
| 1582 | { |
| 1583 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1584 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 1585 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1586 | |
| 1587 | int *value = (int *)extra; |
| 1588 | int startChannel = value[0]; |
| 1589 | int endChannel = value[1]; |
| 1590 | int band = value[2]; |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1591 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1592 | int ret = 0; /* success */ |
| 1593 | |
| 1594 | status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band); |
| 1595 | if(status != VOS_STATUS_SUCCESS) |
| 1596 | { |
| 1597 | hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d\n"), |
| 1598 | startChannel,endChannel, band); |
| 1599 | ret = -EINVAL; |
| 1600 | } |
Gopichand Nakkala | f7e53c5 | 2013-01-07 14:52:52 -0800 | [diff] [blame] | 1601 | |
| 1602 | pHddCtx->is_dynamic_channel_range_set = 1; |
| 1603 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1604 | return ret; |
| 1605 | } |
| 1606 | |
| 1607 | int iw_softap_get_channel_list(struct net_device *dev, |
| 1608 | struct iw_request_info *info, |
| 1609 | union iwreq_data *wrqu, char *extra) |
| 1610 | { |
| 1611 | v_U32_t num_channels = 0; |
| 1612 | v_U8_t i = 0; |
| 1613 | v_U8_t bandStartChannel = RF_CHAN_1; |
| 1614 | v_U8_t bandEndChannel = RF_CHAN_165; |
| 1615 | v_U32_t temp_num_channels = 0; |
| 1616 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
Madan Mohan Koyyalamudi | bb7b43a | 2012-10-11 14:55:09 -0700 | [diff] [blame] | 1617 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1618 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 1619 | v_REGDOMAIN_t domainIdCurrentSoftap; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1620 | tpChannelListInfo channel_list = (tpChannelListInfo) extra; |
Madan Mohan Koyyalamudi | bb7b43a | 2012-10-11 14:55:09 -0700 | [diff] [blame] | 1621 | eCsrBand curBand = eCSR_BAND_ALL; |
| 1622 | |
| 1623 | if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand)) |
| 1624 | { |
| 1625 | hddLog(LOGE,FL("not able get the current frequency band\n")); |
| 1626 | return -EIO; |
| 1627 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1628 | wrqu->data.length = sizeof(tChannelListInfo); |
| 1629 | ENTER(); |
| 1630 | |
Madan Mohan Koyyalamudi | bb7b43a | 2012-10-11 14:55:09 -0700 | [diff] [blame] | 1631 | if (eCSR_BAND_24 == curBand) |
| 1632 | { |
| 1633 | bandStartChannel = RF_CHAN_1; |
| 1634 | bandEndChannel = RF_CHAN_14; |
| 1635 | } |
| 1636 | else if (eCSR_BAND_5G == curBand) |
| 1637 | { |
| 1638 | bandStartChannel = RF_CHAN_36; |
| 1639 | bandEndChannel = RF_CHAN_165; |
| 1640 | } |
| 1641 | |
| 1642 | hddLog(LOG1, FL("\n nBandCapability = %d, bandStartChannel = %hu, " |
| 1643 | "bandEndChannel = %hu \n"), pHddCtx->cfg_ini->nBandCapability, |
| 1644 | bandStartChannel, bandEndChannel ); |
| 1645 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1646 | for( i = bandStartChannel; i <= bandEndChannel; i++ ) |
| 1647 | { |
| 1648 | if( NV_CHANNEL_ENABLE == regChannels[i].enabled ) |
| 1649 | { |
| 1650 | channel_list->channels[num_channels] = rfChannels[i].channelNum; |
| 1651 | num_channels++; |
| 1652 | } |
| 1653 | } |
| 1654 | |
| 1655 | /* remove indoor channels if the domain is FCC, channels 36 - 48 */ |
| 1656 | |
| 1657 | temp_num_channels = num_channels; |
| 1658 | |
| 1659 | if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap)) |
| 1660 | { |
| 1661 | hddLog(LOG1,FL("Failed to get Domain ID, %d \n"),domainIdCurrentSoftap); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 1662 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1663 | } |
| 1664 | |
| 1665 | if(REGDOMAIN_FCC == domainIdCurrentSoftap) |
| 1666 | { |
| 1667 | for(i = 0; i < temp_num_channels; i++) |
| 1668 | { |
| 1669 | |
| 1670 | if((channel_list->channels[i] > 35) && |
| 1671 | (channel_list->channels[i] < 49)) |
| 1672 | { |
| 1673 | vos_mem_move(&channel_list->channels[i], |
| 1674 | &channel_list->channels[i+1], |
| 1675 | temp_num_channels - (i-1)); |
| 1676 | num_channels--; |
| 1677 | temp_num_channels--; |
| 1678 | i--; |
| 1679 | } |
| 1680 | } |
| 1681 | } |
| 1682 | |
| 1683 | hddLog(LOG1,FL(" number of channels %d\n"), num_channels); |
| 1684 | |
| 1685 | if (num_channels > IW_MAX_FREQUENCIES) |
| 1686 | { |
| 1687 | num_channels = IW_MAX_FREQUENCIES; |
| 1688 | } |
| 1689 | |
| 1690 | channel_list->num_channels = num_channels; |
| 1691 | EXIT(); |
| 1692 | |
| 1693 | return 0; |
| 1694 | } |
| 1695 | |
| 1696 | static |
| 1697 | int iw_get_genie(struct net_device *dev, |
| 1698 | struct iw_request_info *info, |
| 1699 | union iwreq_data *wrqu, char *extra) |
| 1700 | { |
| 1701 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1702 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 1703 | eHalStatus status; |
| 1704 | v_U32_t length = DOT11F_IE_RSN_MAX_LEN; |
| 1705 | v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN]; |
| 1706 | ENTER(); |
| 1707 | hddLog(LOG1,FL("getGEN_IE ioctl\n")); |
| 1708 | // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.) |
| 1709 | status = WLANSap_getstationIE_information(pVosContext, |
| 1710 | &length, |
| 1711 | genIeBytes); |
| 1712 | wrqu->data.length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN); |
| 1713 | vos_mem_copy( wrqu->data.pointer, (v_VOID_t*)genIeBytes, wrqu->data.length); |
| 1714 | |
| 1715 | hddLog(LOG1,FL(" RSN IE of %d bytes returned\n"), wrqu->data.length ); |
| 1716 | |
| 1717 | |
| 1718 | EXIT(); |
| 1719 | return 0; |
| 1720 | } |
| 1721 | static |
| 1722 | int iw_get_WPSPBCProbeReqIEs(struct net_device *dev, |
| 1723 | struct iw_request_info *info, |
| 1724 | union iwreq_data *wrqu, char *extra) |
| 1725 | { |
| 1726 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1727 | sQcSapreq_WPSPBCProbeReqIES_t *pWPSPBCProbeReqIEs; |
| 1728 | hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter); |
| 1729 | ENTER(); |
| 1730 | |
| 1731 | hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl\n")); |
| 1732 | |
| 1733 | pWPSPBCProbeReqIEs = (sQcSapreq_WPSPBCProbeReqIES_t *)(wrqu->data.pointer); |
| 1734 | pWPSPBCProbeReqIEs->probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen; |
| 1735 | vos_mem_copy(pWPSPBCProbeReqIEs->probeReqIE, pHddApCtx->WPSPBCProbeReq.probeReqIE, pWPSPBCProbeReqIEs->probeReqIELen); |
| 1736 | vos_mem_copy(pWPSPBCProbeReqIEs->macaddr, pHddApCtx->WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t)); |
| 1737 | wrqu->data.length = 12 + pWPSPBCProbeReqIEs->probeReqIELen; |
| 1738 | hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR"\n"), MAC_ADDR_ARRAY(pWPSPBCProbeReqIEs->macaddr)); |
| 1739 | up(&pHddApCtx->semWpsPBCOverlapInd); |
| 1740 | EXIT(); |
| 1741 | return 0; |
| 1742 | } |
| 1743 | |
| 1744 | /**--------------------------------------------------------------------------- |
| 1745 | |
| 1746 | \brief iw_set_auth_hostap() - |
| 1747 | This function sets the auth type received from the wpa_supplicant. |
| 1748 | |
| 1749 | \param - dev - Pointer to the net device. |
| 1750 | - info - Pointer to the iw_request_info. |
| 1751 | - wrqu - Pointer to the iwreq_data. |
| 1752 | - extra - Pointer to the data. |
| 1753 | \return - 0 for success, non zero for failure |
| 1754 | |
| 1755 | --------------------------------------------------------------------------*/ |
| 1756 | int iw_set_auth_hostap(struct net_device *dev,struct iw_request_info *info, |
| 1757 | union iwreq_data *wrqu,char *extra) |
| 1758 | { |
| 1759 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1760 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1761 | |
| 1762 | ENTER(); |
| 1763 | switch(wrqu->param.flags & IW_AUTH_INDEX) |
| 1764 | { |
| 1765 | case IW_AUTH_TKIP_COUNTERMEASURES: |
| 1766 | { |
| 1767 | if(wrqu->param.value) { |
| 1768 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1769 | "Counter Measure started %d", wrqu->param.value); |
| 1770 | pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED; |
| 1771 | } |
| 1772 | else { |
| 1773 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1774 | "Counter Measure stopped=%d", wrqu->param.value); |
| 1775 | pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED; |
| 1776 | } |
| 1777 | |
| 1778 | hdd_softap_tkip_mic_fail_counter_measure(pAdapter, |
| 1779 | wrqu->param.value); |
| 1780 | } |
| 1781 | break; |
| 1782 | |
| 1783 | default: |
| 1784 | |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1785 | hddLog(LOGW, "%s called with unsupported auth type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1786 | wrqu->param.flags & IW_AUTH_INDEX); |
| 1787 | break; |
| 1788 | } |
| 1789 | |
| 1790 | EXIT(); |
| 1791 | return 0; |
| 1792 | } |
| 1793 | |
| 1794 | static int iw_set_ap_encodeext(struct net_device *dev, |
| 1795 | struct iw_request_info *info, |
| 1796 | union iwreq_data *wrqu, char *extra) |
| 1797 | { |
| 1798 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 1799 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 1800 | hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1801 | int retval = 0; |
| 1802 | VOS_STATUS vstatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1803 | struct iw_encode_ext *ext = (struct iw_encode_ext*)extra; |
| 1804 | v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 1805 | int key_index; |
| 1806 | struct iw_point *encoding = &wrqu->encoding; |
| 1807 | tCsrRoamSetKey setKey; |
| 1808 | // tCsrRoamRemoveKey RemoveKey; |
| 1809 | int i; |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1810 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1811 | ENTER(); |
| 1812 | |
| 1813 | key_index = encoding->flags & IW_ENCODE_INDEX; |
| 1814 | |
| 1815 | if(key_index > 0) { |
| 1816 | |
| 1817 | /*Convert from 1-based to 0-based keying*/ |
| 1818 | key_index--; |
| 1819 | } |
| 1820 | if(!ext->key_len) { |
| 1821 | #if 0 |
| 1822 | /*Set the encrytion type to NONE*/ |
| 1823 | #if 0 |
| 1824 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 1825 | #endif |
| 1826 | |
| 1827 | RemoveKey.keyId = key_index; |
| 1828 | if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { |
| 1829 | /*Key direction for group is RX only*/ |
| 1830 | vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 1831 | } |
| 1832 | else { |
| 1833 | vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN); |
| 1834 | } |
| 1835 | switch(ext->alg) |
| 1836 | { |
| 1837 | case IW_ENCODE_ALG_NONE: |
| 1838 | RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 1839 | break; |
| 1840 | case IW_ENCODE_ALG_WEP: |
| 1841 | RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104; |
| 1842 | break; |
| 1843 | case IW_ENCODE_ALG_TKIP: |
| 1844 | RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1845 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1846 | case IW_ENCODE_ALG_CCMP: |
| 1847 | RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 1848 | break; |
| 1849 | default: |
| 1850 | RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 1851 | break; |
| 1852 | } |
| 1853 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Remove key cipher_alg:%d key_len%d *pEncryptionType :%d \n", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1854 | __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1855 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR"\n", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1856 | __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1857 | ); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1858 | vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey); |
| 1859 | if ( vstatus != VOS_STATUS_SUCCESS ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1860 | { |
| 1861 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d", |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1862 | __LINE__, vstatus ); |
| 1863 | retval = -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1864 | } |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1865 | #endif |
| 1866 | return retval; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1867 | |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1868 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1869 | |
| 1870 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 1871 | |
| 1872 | setKey.keyId = key_index; |
| 1873 | setKey.keyLength = ext->key_len; |
| 1874 | |
| 1875 | if(ext->key_len <= CSR_MAX_KEY_LEN) { |
| 1876 | vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len); |
| 1877 | } |
| 1878 | |
| 1879 | if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { |
| 1880 | /*Key direction for group is RX only*/ |
| 1881 | setKey.keyDirection = eSIR_RX_ONLY; |
| 1882 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 1883 | } |
| 1884 | else { |
| 1885 | |
| 1886 | setKey.keyDirection = eSIR_TX_RX; |
| 1887 | vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN); |
| 1888 | } |
| 1889 | if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) |
| 1890 | { |
| 1891 | setKey.keyDirection = eSIR_TX_DEFAULT; |
| 1892 | vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN); |
| 1893 | } |
| 1894 | |
| 1895 | /*For supplicant pae role is zero*/ |
| 1896 | setKey.paeRole = 0; |
| 1897 | |
| 1898 | switch(ext->alg) |
| 1899 | { |
| 1900 | case IW_ENCODE_ALG_NONE: |
| 1901 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 1902 | break; |
| 1903 | |
| 1904 | case IW_ENCODE_ALG_WEP: |
| 1905 | setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104; |
| 1906 | pHddApCtx->uPrivacy = 1; |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1907 | hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1908 | break; |
| 1909 | |
| 1910 | case IW_ENCODE_ALG_TKIP: |
| 1911 | { |
| 1912 | v_U8_t *pKey = &setKey.Key[0]; |
| 1913 | |
| 1914 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 1915 | |
| 1916 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 1917 | |
| 1918 | /*Supplicant sends the 32bytes key in this order |
| 1919 | |
| 1920 | |--------------|----------|----------| |
| 1921 | | Tk1 |TX-MIC | RX Mic | |
| 1922 | |--------------|----------|----------| |
| 1923 | <---16bytes---><--8bytes--><--8bytes--> |
| 1924 | |
| 1925 | */ |
| 1926 | /*Sme expects the 32 bytes key to be in the below order |
| 1927 | |
| 1928 | |--------------|----------|----------| |
| 1929 | | Tk1 |RX-MIC | TX Mic | |
| 1930 | |--------------|----------|----------| |
| 1931 | <---16bytes---><--8bytes--><--8bytes--> |
| 1932 | */ |
| 1933 | /* Copy the Temporal Key 1 (TK1) */ |
| 1934 | vos_mem_copy(pKey,ext->key,16); |
| 1935 | |
| 1936 | /*Copy the rx mic first*/ |
| 1937 | vos_mem_copy(&pKey[16],&ext->key[24],8); |
| 1938 | |
| 1939 | /*Copy the tx mic */ |
| 1940 | vos_mem_copy(&pKey[24],&ext->key[16],8); |
| 1941 | |
| 1942 | } |
| 1943 | break; |
| 1944 | |
| 1945 | case IW_ENCODE_ALG_CCMP: |
| 1946 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 1947 | break; |
| 1948 | |
| 1949 | default: |
| 1950 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 1951 | break; |
| 1952 | } |
| 1953 | |
| 1954 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1955 | ("%s:EncryptionType:%d key_len:%d, :%d, KeyId:%d \n"),__func__, setKey.encType, setKey.keyLength, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1956 | setKey.keyId); |
| 1957 | for(i=0; i< ext->key_len; i++) |
| 1958 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1959 | ("%02x"), setKey.Key[i]); |
| 1960 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1961 | ("\n")); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1962 | |
| 1963 | vstatus = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 1964 | if ( vstatus != VOS_STATUS_SUCCESS ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1965 | { |
| 1966 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1967 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus ); |
| 1968 | retval = -EINVAL; |
| 1969 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1970 | |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1971 | return retval; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1972 | } |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1973 | |
| 1974 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1975 | static int iw_set_ap_mlme(struct net_device *dev, |
| 1976 | struct iw_request_info *info, |
| 1977 | union iwreq_data *wrqu, |
| 1978 | char *extra) |
| 1979 | { |
| 1980 | #if 0 |
| 1981 | hdd_adapter_t *pAdapter = (netdev_priv(dev)); |
| 1982 | struct iw_mlme *mlme = (struct iw_mlme *)extra; |
| 1983 | |
| 1984 | ENTER(); |
| 1985 | |
| 1986 | //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED |
| 1987 | switch (mlme->cmd) { |
| 1988 | case IW_MLME_DISASSOC: |
| 1989 | case IW_MLME_DEAUTH: |
| 1990 | hddLog(LOG1, "Station disassociate"); |
| 1991 | if( pAdapter->conn_info.connState == eConnectionState_Associated ) |
| 1992 | { |
| 1993 | eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 1994 | |
| 1995 | if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE ) |
| 1996 | reason = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 1997 | |
| 1998 | status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason); |
| 1999 | |
| 2000 | //clear all the reason codes |
| 2001 | if (status != 0) |
| 2002 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2003 | hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d \n", __func__, (int)mlme->cmd, (int)status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2004 | } |
| 2005 | |
| 2006 | netif_stop_queue(dev); |
| 2007 | netif_carrier_off(dev); |
| 2008 | } |
| 2009 | else |
| 2010 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2011 | hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state \n", __func__, (int)mlme->cmd ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2012 | } |
| 2013 | default: |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2014 | hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate \n", __func__, (int)mlme->cmd ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2015 | return -EINVAL; |
| 2016 | }//end of switch |
| 2017 | EXIT(); |
| 2018 | #endif |
| 2019 | return 0; |
| 2020 | // return status; |
| 2021 | } |
| 2022 | |
| 2023 | static int iw_get_ap_rts_threshold(struct net_device *dev, |
| 2024 | struct iw_request_info *info, |
| 2025 | union iwreq_data *wrqu, char *extra) |
| 2026 | { |
| 2027 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 2028 | v_U32_t status = 0; |
| 2029 | |
| 2030 | status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu); |
| 2031 | |
| 2032 | return status; |
| 2033 | } |
| 2034 | |
| 2035 | static int iw_get_ap_frag_threshold(struct net_device *dev, |
| 2036 | struct iw_request_info *info, |
| 2037 | union iwreq_data *wrqu, char *extra) |
| 2038 | { |
| 2039 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 2040 | v_U32_t status = 0; |
| 2041 | |
| 2042 | status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu); |
| 2043 | |
| 2044 | return status; |
| 2045 | } |
| 2046 | |
| 2047 | static int iw_get_ap_freq(struct net_device *dev, struct iw_request_info *info, |
| 2048 | struct iw_freq *fwrq, char *extra) |
| 2049 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2050 | v_U32_t status = FALSE, channel = 0, freq = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2051 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 2052 | tHalHandle hHal; |
| 2053 | hdd_hostapd_state_t *pHostapdState; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2054 | hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2055 | |
| 2056 | ENTER(); |
| 2057 | |
| 2058 | if ((WLAN_HDD_GET_CTX(pHostapdAdapter))->isLogpInProgress) { |
| 2059 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2060 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2061 | return status; |
| 2062 | } |
| 2063 | |
| 2064 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 2065 | hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 2066 | |
| 2067 | if(pHostapdState->bssState == BSS_STOP ) |
| 2068 | { |
| 2069 | if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel) |
| 2070 | != eHAL_STATUS_SUCCESS) |
| 2071 | { |
| 2072 | return -EIO; |
| 2073 | } |
| 2074 | else |
| 2075 | { |
| 2076 | status = hdd_wlan_get_freq(channel, &freq); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2077 | if( TRUE == status) |
| 2078 | { |
| 2079 | /* Set Exponent parameter as 6 (MHZ) in struct iw_freq |
| 2080 | * iwlist & iwconfig command shows frequency into proper |
| 2081 | * format (2.412 GHz instead of 246.2 MHz)*/ |
| 2082 | fwrq->m = freq; |
| 2083 | fwrq->e = MHZ; |
| 2084 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2085 | } |
| 2086 | } |
| 2087 | else |
| 2088 | { |
| 2089 | channel = pHddApCtx->operatingChannel; |
| 2090 | status = hdd_wlan_get_freq(channel, &freq); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2091 | if( TRUE == status) |
| 2092 | { |
| 2093 | /* Set Exponent parameter as 6 (MHZ) in struct iw_freq |
| 2094 | * iwlist & iwconfig command shows frequency into proper |
| 2095 | * format (2.412 GHz instead of 246.2 MHz)*/ |
| 2096 | fwrq->m = freq; |
| 2097 | fwrq->e = MHZ; |
| 2098 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2099 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2100 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2101 | } |
| 2102 | |
| 2103 | static int iw_softap_setwpsie(struct net_device *dev, |
| 2104 | struct iw_request_info *info, |
| 2105 | union iwreq_data *wrqu, |
| 2106 | char *extra) |
| 2107 | { |
| 2108 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 2109 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 2110 | hdd_hostapd_state_t *pHostapdState; |
| 2111 | eHalStatus halStatus= eHAL_STATUS_SUCCESS; |
| 2112 | u_int8_t *wps_genie = wrqu->data.pointer; |
| 2113 | u_int8_t *pos; |
| 2114 | tpSap_WPSIE pSap_WPSIe; |
| 2115 | u_int8_t WPSIeType; |
| 2116 | u_int16_t length; |
| 2117 | ENTER(); |
| 2118 | |
| 2119 | if(!wrqu->data.length) |
| 2120 | return 0; |
| 2121 | |
| 2122 | pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE)); |
| 2123 | if (NULL == pSap_WPSIe) |
| 2124 | { |
| 2125 | hddLog(LOGE, "VOS unable to allocate memory\n"); |
| 2126 | return -ENOMEM; |
| 2127 | } |
| 2128 | vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE)); |
| 2129 | |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2130 | hddLog(LOG1,"%s WPS IE type[0x%X] IE[0x%X], LEN[%d]\n", __func__, wps_genie[0], wps_genie[1], wps_genie[2]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2131 | WPSIeType = wps_genie[0]; |
| 2132 | if ( wps_genie[0] == eQC_WPS_BEACON_IE) |
| 2133 | { |
| 2134 | pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE; |
| 2135 | wps_genie = wps_genie + 1; |
| 2136 | switch ( wps_genie[0] ) |
| 2137 | { |
| 2138 | case DOT11F_EID_WPA: |
| 2139 | if (wps_genie[1] < 2 + 4) |
| 2140 | { |
| 2141 | vos_mem_free(pSap_WPSIe); |
| 2142 | return -EINVAL; |
| 2143 | } |
| 2144 | else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0) |
| 2145 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2146 | hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2147 | pos = &wps_genie[6]; |
| 2148 | while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) ) |
| 2149 | { |
| 2150 | switch((u_int16_t)(*pos<<8) | *(pos+1)) |
| 2151 | { |
| 2152 | case HDD_WPS_ELEM_VERSION: |
| 2153 | pos += 4; |
| 2154 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos; |
| 2155 | hddLog(LOG1, "WPS version %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version); |
| 2156 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT; |
| 2157 | pos += 1; |
| 2158 | break; |
| 2159 | |
| 2160 | case HDD_WPS_ELEM_WPS_STATE: |
| 2161 | pos +=4; |
| 2162 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos; |
| 2163 | hddLog(LOG1, "WPS State %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState); |
| 2164 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT; |
| 2165 | pos += 1; |
| 2166 | break; |
| 2167 | case HDD_WPS_ELEM_APSETUPLOCK: |
| 2168 | pos += 4; |
| 2169 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos; |
| 2170 | hddLog(LOG1, "AP setup lock %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked); |
| 2171 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT; |
| 2172 | pos += 1; |
| 2173 | break; |
| 2174 | case HDD_WPS_ELEM_SELECTEDREGISTRA: |
| 2175 | pos += 4; |
| 2176 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos; |
| 2177 | hddLog(LOG1, "Selected Registra %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra); |
| 2178 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT; |
| 2179 | pos += 1; |
| 2180 | break; |
| 2181 | case HDD_WPS_ELEM_DEVICE_PASSWORD_ID: |
| 2182 | pos += 4; |
| 2183 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1); |
| 2184 | hddLog(LOG1, "Password ID: %x\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID); |
| 2185 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT; |
| 2186 | pos += 2; |
| 2187 | break; |
| 2188 | case HDD_WPS_ELEM_REGISTRA_CONF_METHODS: |
| 2189 | pos += 4; |
| 2190 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1); |
| 2191 | hddLog(LOG1, "Select Registra Config Methods: %x\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod); |
| 2192 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT; |
| 2193 | pos += 2; |
| 2194 | break; |
| 2195 | |
| 2196 | case HDD_WPS_ELEM_UUID_E: |
| 2197 | pos += 2; |
| 2198 | length = *pos<<8 | *(pos+1); |
| 2199 | pos += 2; |
| 2200 | vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length); |
| 2201 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT; |
| 2202 | pos += length; |
| 2203 | break; |
| 2204 | case HDD_WPS_ELEM_RF_BANDS: |
| 2205 | pos += 4; |
| 2206 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos; |
| 2207 | hddLog(LOG1, "RF band: %d\n", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand); |
| 2208 | pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT; |
| 2209 | pos += 1; |
| 2210 | break; |
| 2211 | |
| 2212 | default: |
| 2213 | hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)\n", (*pos<<8 | *(pos+1))); |
| 2214 | vos_mem_free(pSap_WPSIe); |
| 2215 | return -EINVAL; |
| 2216 | } |
| 2217 | } |
| 2218 | } |
| 2219 | else { |
| 2220 | hddLog (LOGE, "%s WPS IE Mismatch %X", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2221 | __func__, wps_genie[0]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2222 | } |
| 2223 | break; |
| 2224 | |
| 2225 | default: |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2226 | hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2227 | vos_mem_free(pSap_WPSIe); |
| 2228 | return 0; |
| 2229 | } |
| 2230 | } |
| 2231 | else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE) |
| 2232 | { |
| 2233 | pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE; |
| 2234 | wps_genie = wps_genie + 1; |
| 2235 | switch ( wps_genie[0] ) |
| 2236 | { |
| 2237 | case DOT11F_EID_WPA: |
| 2238 | if (wps_genie[1] < 2 + 4) |
| 2239 | { |
| 2240 | vos_mem_free(pSap_WPSIe); |
| 2241 | return -EINVAL; |
| 2242 | } |
| 2243 | else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0) |
| 2244 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2245 | hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2246 | pos = &wps_genie[6]; |
| 2247 | while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) ) |
| 2248 | { |
| 2249 | switch((u_int16_t)(*pos<<8) | *(pos+1)) |
| 2250 | { |
| 2251 | case HDD_WPS_ELEM_VERSION: |
| 2252 | pos += 4; |
| 2253 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos; |
| 2254 | hddLog(LOG1, "WPS version %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version); |
| 2255 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT; |
| 2256 | pos += 1; |
| 2257 | break; |
| 2258 | |
| 2259 | case HDD_WPS_ELEM_WPS_STATE: |
| 2260 | pos +=4; |
| 2261 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos; |
| 2262 | hddLog(LOG1, "WPS State %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState); |
| 2263 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT; |
| 2264 | pos += 1; |
| 2265 | break; |
| 2266 | case HDD_WPS_ELEM_APSETUPLOCK: |
| 2267 | pos += 4; |
| 2268 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos; |
| 2269 | hddLog(LOG1, "AP setup lock %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked); |
| 2270 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT; |
| 2271 | pos += 1; |
| 2272 | break; |
| 2273 | case HDD_WPS_ELEM_SELECTEDREGISTRA: |
| 2274 | pos += 4; |
| 2275 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos; |
| 2276 | hddLog(LOG1, "Selected Registra %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra); |
| 2277 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT; |
| 2278 | pos += 1; |
| 2279 | break; |
| 2280 | case HDD_WPS_ELEM_DEVICE_PASSWORD_ID: |
| 2281 | pos += 4; |
| 2282 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1); |
| 2283 | hddLog(LOG1, "Password ID: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID); |
| 2284 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT; |
| 2285 | pos += 2; |
| 2286 | break; |
| 2287 | case HDD_WPS_ELEM_REGISTRA_CONF_METHODS: |
| 2288 | pos += 4; |
| 2289 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1); |
| 2290 | hddLog(LOG1, "Select Registra Config Methods: %x\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod); |
| 2291 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT; |
| 2292 | pos += 2; |
| 2293 | break; |
| 2294 | case HDD_WPS_ELEM_RSP_TYPE: |
| 2295 | pos += 4; |
| 2296 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos; |
| 2297 | hddLog(LOG1, "Config Methods: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType); |
| 2298 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT; |
| 2299 | pos += 1; |
| 2300 | break; |
| 2301 | case HDD_WPS_ELEM_UUID_E: |
| 2302 | pos += 2; |
| 2303 | length = *pos<<8 | *(pos+1); |
| 2304 | pos += 2; |
| 2305 | vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length); |
| 2306 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT; |
| 2307 | pos += length; |
| 2308 | break; |
| 2309 | |
| 2310 | case HDD_WPS_ELEM_MANUFACTURER: |
| 2311 | pos += 2; |
| 2312 | length = *pos<<8 | *(pos+1); |
| 2313 | pos += 2; |
| 2314 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length; |
| 2315 | vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length); |
| 2316 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT; |
| 2317 | pos += length; |
| 2318 | break; |
| 2319 | |
| 2320 | case HDD_WPS_ELEM_MODEL_NAME: |
| 2321 | pos += 2; |
| 2322 | length = *pos<<8 | *(pos+1); |
| 2323 | pos += 2; |
| 2324 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length; |
| 2325 | vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length); |
| 2326 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT; |
| 2327 | pos += length; |
| 2328 | break; |
| 2329 | case HDD_WPS_ELEM_MODEL_NUM: |
| 2330 | pos += 2; |
| 2331 | length = *pos<<8 | *(pos+1); |
| 2332 | pos += 2; |
| 2333 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length; |
| 2334 | vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length); |
| 2335 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT; |
| 2336 | pos += length; |
| 2337 | break; |
| 2338 | case HDD_WPS_ELEM_SERIAL_NUM: |
| 2339 | pos += 2; |
| 2340 | length = *pos<<8 | *(pos+1); |
| 2341 | pos += 2; |
| 2342 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length; |
| 2343 | vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length); |
| 2344 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT; |
| 2345 | pos += length; |
| 2346 | break; |
| 2347 | case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE: |
| 2348 | pos += 4; |
| 2349 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1)); |
| 2350 | hddLog(LOG1, "primary dev category: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory); |
| 2351 | pos += 2; |
| 2352 | |
| 2353 | vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN); |
| 2354 | hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x\n", pos[0], pos[1], pos[2], pos[3]); |
| 2355 | pos += 4; |
| 2356 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1)); |
| 2357 | hddLog(LOG1, "primary dev sub category: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory); |
| 2358 | pos += 2; |
| 2359 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT; |
| 2360 | break; |
| 2361 | case HDD_WPS_ELEM_DEVICE_NAME: |
| 2362 | pos += 2; |
| 2363 | length = *pos<<8 | *(pos+1); |
| 2364 | pos += 2; |
| 2365 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length; |
| 2366 | vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length); |
| 2367 | pos += length; |
| 2368 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT; |
| 2369 | break; |
| 2370 | case HDD_WPS_ELEM_CONFIG_METHODS: |
| 2371 | pos += 4; |
| 2372 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1); |
| 2373 | hddLog(LOG1, "Config Methods: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod); |
| 2374 | pos += 2; |
| 2375 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT; |
| 2376 | break; |
| 2377 | |
| 2378 | case HDD_WPS_ELEM_RF_BANDS: |
| 2379 | pos += 4; |
| 2380 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos; |
| 2381 | hddLog(LOG1, "RF band: %d\n", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand); |
| 2382 | pos += 1; |
| 2383 | pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT; |
| 2384 | break; |
| 2385 | } // switch |
| 2386 | } |
| 2387 | } |
| 2388 | else |
| 2389 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2390 | hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2391 | } |
| 2392 | |
| 2393 | } // switch |
| 2394 | } |
| 2395 | halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe); |
| 2396 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 2397 | if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE) |
| 2398 | { |
| 2399 | //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 2400 | //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext; |
| 2401 | WLANSAP_Update_WpsIe ( pVosContext ); |
| 2402 | } |
| 2403 | |
| 2404 | vos_mem_free(pSap_WPSIe); |
| 2405 | EXIT(); |
| 2406 | return halStatus; |
| 2407 | } |
| 2408 | |
| 2409 | static int iw_softap_stopbss(struct net_device *dev, |
| 2410 | struct iw_request_info *info, |
| 2411 | union iwreq_data *wrqu, |
| 2412 | char *extra) |
| 2413 | { |
| 2414 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 2415 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 2416 | ENTER(); |
| 2417 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
| 2418 | { |
| 2419 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) ) |
| 2420 | { |
| 2421 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 2422 | |
| 2423 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 2424 | |
| 2425 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2426 | { |
| 2427 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2428 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2429 | VOS_ASSERT(0); |
| 2430 | } |
| 2431 | } |
| 2432 | clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 2433 | } |
| 2434 | EXIT(); |
| 2435 | return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY; |
| 2436 | } |
| 2437 | |
| 2438 | static int iw_softap_version(struct net_device *dev, |
| 2439 | struct iw_request_info *info, |
Jeff Johnson | 4824d4c | 2013-02-12 14:23:57 -0800 | [diff] [blame] | 2440 | union iwreq_data *wrqu, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2441 | char *extra) |
| 2442 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2443 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
Jeff Johnson | 4824d4c | 2013-02-12 14:23:57 -0800 | [diff] [blame] | 2444 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2445 | ENTER(); |
Jeff Johnson | 4824d4c | 2013-02-12 14:23:57 -0800 | [diff] [blame] | 2446 | hdd_wlan_get_version(pHostapdAdapter, wrqu, extra); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2447 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2448 | return 0; |
| 2449 | } |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 2450 | |
Yathish Hanumapuradoddi Shivanna | 7b65940 | 2013-03-25 14:12:32 -0700 | [diff] [blame] | 2451 | VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len) |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 2452 | { |
| 2453 | v_U8_t i; |
Yathish Hanumapuradoddi Shivanna | 7b65940 | 2013-03-25 14:12:32 -0700 | [diff] [blame] | 2454 | int len = 0; |
| 2455 | const char sta_info_header[] = "staId staAddress\n"; |
| 2456 | |
| 2457 | len = snprintf(pBuf, buf_len, sta_info_header); |
| 2458 | pBuf += len; |
| 2459 | buf_len -= len; |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 2460 | |
| 2461 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 2462 | { |
| 2463 | if(pAdapter->aStaInfo[i].isUsed) |
| 2464 | { |
Yathish Hanumapuradoddi Shivanna | 7b65940 | 2013-03-25 14:12:32 -0700 | [diff] [blame] | 2465 | len = snprintf(pBuf, buf_len, "%*d .%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 2466 | strlen("staId"), |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 2467 | pAdapter->aStaInfo[i].ucSTAId, |
| 2468 | pAdapter->aStaInfo[i].macAddrSTA.bytes[0], |
| 2469 | pAdapter->aStaInfo[i].macAddrSTA.bytes[1], |
| 2470 | pAdapter->aStaInfo[i].macAddrSTA.bytes[2], |
| 2471 | pAdapter->aStaInfo[i].macAddrSTA.bytes[3], |
| 2472 | pAdapter->aStaInfo[i].macAddrSTA.bytes[4], |
| 2473 | pAdapter->aStaInfo[i].macAddrSTA.bytes[5]); |
Yathish Hanumapuradoddi Shivanna | 7b65940 | 2013-03-25 14:12:32 -0700 | [diff] [blame] | 2474 | pBuf += len; |
| 2475 | buf_len -= len; |
| 2476 | } |
| 2477 | if(WE_GET_STA_INFO_SIZE > buf_len) |
| 2478 | { |
| 2479 | break; |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 2480 | } |
| 2481 | } |
| 2482 | return VOS_STATUS_SUCCESS; |
| 2483 | } |
| 2484 | |
| 2485 | static int iw_softap_get_sta_info(struct net_device *dev, |
| 2486 | struct iw_request_info *info, |
| 2487 | union iwreq_data *wrqu, |
| 2488 | char *extra) |
| 2489 | { |
| 2490 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 2491 | VOS_STATUS status; |
| 2492 | ENTER(); |
Yathish Hanumapuradoddi Shivanna | 4171f7d | 2013-04-08 20:05:56 -0700 | [diff] [blame^] | 2493 | status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO); |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 2494 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) { |
| 2495 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!\n",__func__); |
| 2496 | return -EINVAL; |
| 2497 | } |
| 2498 | wrqu->data.length = strlen(extra); |
| 2499 | EXIT(); |
| 2500 | return 0; |
| 2501 | } |
| 2502 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2503 | static int iw_set_ap_genie(struct net_device *dev, |
| 2504 | struct iw_request_info *info, |
| 2505 | union iwreq_data *wrqu, |
| 2506 | char *extra) |
| 2507 | { |
| 2508 | |
| 2509 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 2510 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 2511 | eHalStatus halStatus= eHAL_STATUS_SUCCESS; |
| 2512 | u_int8_t *genie = wrqu->data.pointer; |
| 2513 | |
| 2514 | ENTER(); |
| 2515 | |
| 2516 | if(!wrqu->data.length) |
| 2517 | { |
| 2518 | EXIT(); |
| 2519 | return 0; |
| 2520 | } |
| 2521 | |
| 2522 | switch (genie[0]) |
| 2523 | { |
| 2524 | case DOT11F_EID_WPA: |
| 2525 | case DOT11F_EID_RSN: |
| 2526 | if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0) |
| 2527 | { |
| 2528 | hdd_softap_Deregister_BC_STA(pHostapdAdapter); |
| 2529 | hdd_softap_Register_BC_STA(pHostapdAdapter, 1); |
| 2530 | } |
| 2531 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1; |
| 2532 | halStatus = WLANSAP_Set_WPARSNIes(pVosContext, wrqu->data.pointer, wrqu->data.length); |
| 2533 | break; |
| 2534 | |
| 2535 | default: |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2536 | hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2537 | halStatus = 0; |
| 2538 | } |
| 2539 | |
| 2540 | EXIT(); |
| 2541 | return halStatus; |
| 2542 | } |
| 2543 | |
| 2544 | static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid) |
| 2545 | { |
| 2546 | eHalStatus hstatus; |
| 2547 | long lrc; |
| 2548 | struct statsContext context; |
| 2549 | |
| 2550 | if (NULL == pAdapter) |
| 2551 | { |
| 2552 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Padapter is NULL", __func__); |
| 2553 | return VOS_STATUS_E_FAULT; |
| 2554 | } |
| 2555 | |
| 2556 | init_completion(&context.completion); |
| 2557 | context.pAdapter = pAdapter; |
| 2558 | context.magic = STATS_CONTEXT_MAGIC; |
| 2559 | hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2560 | eCSR_HDD, |
| 2561 | SME_GLOBAL_CLASSA_STATS, |
| 2562 | hdd_GetClassA_statisticsCB, |
| 2563 | 0, // not periodic |
| 2564 | FALSE, //non-cached results |
| 2565 | staid, |
| 2566 | &context); |
| 2567 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 2568 | { |
| 2569 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2570 | "%s: Unable to retrieve statistics for link speed", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2571 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2572 | } |
| 2573 | else |
| 2574 | { |
| 2575 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 2576 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
| 2577 | context.magic = 0; |
| 2578 | if (lrc <= 0) |
| 2579 | { |
| 2580 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2581 | "%s: SME %s while retrieving link speed", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2582 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2583 | msleep(50); |
| 2584 | } |
| 2585 | } |
| 2586 | return VOS_STATUS_SUCCESS; |
| 2587 | } |
| 2588 | |
| 2589 | int iw_get_softap_linkspeed(struct net_device *dev, |
| 2590 | struct iw_request_info *info, |
| 2591 | union iwreq_data *wrqu, |
| 2592 | char *extra) |
| 2593 | |
| 2594 | { |
| 2595 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 2596 | char *pLinkSpeed = (char*)extra; |
| 2597 | v_U16_t link_speed; |
| 2598 | unsigned short staId; |
| 2599 | int len = sizeof(v_U16_t)+1; |
| 2600 | v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE]; |
| 2601 | VOS_STATUS status; |
| 2602 | int rc; |
| 2603 | |
| 2604 | if ( hdd_string_to_hex ((char *)wrqu->data.pointer, wrqu->data.length, macAddress ) ) |
| 2605 | { |
| 2606 | hddLog(VOS_TRACE_LEVEL_FATAL, "ERROR: Command not found"); |
| 2607 | return -EINVAL; |
| 2608 | } |
| 2609 | |
| 2610 | status = hdd_softap_GetStaId(pHostapdAdapter, (v_MACADDR_t *)macAddress, (void *)(&staId)); |
| 2611 | |
| 2612 | if (!VOS_IS_STATUS_SUCCESS(status )) |
| 2613 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 2614 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2615 | link_speed = 0; |
| 2616 | } |
| 2617 | else |
| 2618 | { |
| 2619 | status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId); |
| 2620 | if (!VOS_IS_STATUS_SUCCESS(status )) |
| 2621 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2622 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve SME statistics", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2623 | return -EINVAL; |
| 2624 | } |
| 2625 | link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2; |
| 2626 | } |
| 2627 | |
| 2628 | wrqu->data.length = len; |
| 2629 | rc = snprintf(pLinkSpeed, len, "%u", link_speed); |
| 2630 | if ((rc < 0) || (rc >= len)) |
| 2631 | { |
| 2632 | // encoding or length error? |
| 2633 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2634 | "%s: Unable to encode link speed, got [%s]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2635 | __func__, pLinkSpeed); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2636 | return -EIO; |
| 2637 | } |
| 2638 | |
| 2639 | return 0; |
| 2640 | } |
| 2641 | |
| 2642 | static const iw_handler hostapd_handler[] = |
| 2643 | { |
| 2644 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ |
| 2645 | (iw_handler) NULL, /* SIOCGIWNAME */ |
| 2646 | (iw_handler) NULL, /* SIOCSIWNWID */ |
| 2647 | (iw_handler) NULL, /* SIOCGIWNWID */ |
| 2648 | (iw_handler) NULL, /* SIOCSIWFREQ */ |
| 2649 | (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */ |
| 2650 | (iw_handler) NULL, /* SIOCSIWMODE */ |
| 2651 | (iw_handler) NULL, /* SIOCGIWMODE */ |
| 2652 | (iw_handler) NULL, /* SIOCSIWSENS */ |
| 2653 | (iw_handler) NULL, /* SIOCGIWSENS */ |
| 2654 | (iw_handler) NULL, /* SIOCSIWRANGE */ |
| 2655 | (iw_handler) NULL, /* SIOCGIWRANGE */ |
| 2656 | (iw_handler) NULL, /* SIOCSIWPRIV */ |
| 2657 | (iw_handler) NULL, /* SIOCGIWPRIV */ |
| 2658 | (iw_handler) NULL, /* SIOCSIWSTATS */ |
| 2659 | (iw_handler) NULL, /* SIOCGIWSTATS */ |
| 2660 | (iw_handler) NULL, /* SIOCSIWSPY */ |
| 2661 | (iw_handler) NULL, /* SIOCGIWSPY */ |
| 2662 | (iw_handler) NULL, /* SIOCSIWTHRSPY */ |
| 2663 | (iw_handler) NULL, /* SIOCGIWTHRSPY */ |
| 2664 | (iw_handler) NULL, /* SIOCSIWAP */ |
| 2665 | (iw_handler) NULL, /* SIOCGIWAP */ |
| 2666 | (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */ |
| 2667 | (iw_handler) NULL, /* SIOCGIWAPLIST */ |
| 2668 | (iw_handler) NULL, /* SIOCSIWSCAN */ |
| 2669 | (iw_handler) NULL, /* SIOCGIWSCAN */ |
| 2670 | (iw_handler) NULL, /* SIOCSIWESSID */ |
| 2671 | (iw_handler) NULL, /* SIOCGIWESSID */ |
| 2672 | (iw_handler) NULL, /* SIOCSIWNICKN */ |
| 2673 | (iw_handler) NULL, /* SIOCGIWNICKN */ |
| 2674 | (iw_handler) NULL, /* -- hole -- */ |
| 2675 | (iw_handler) NULL, /* -- hole -- */ |
| 2676 | (iw_handler) NULL, /* SIOCSIWRATE */ |
| 2677 | (iw_handler) NULL, /* SIOCGIWRATE */ |
| 2678 | (iw_handler) NULL, /* SIOCSIWRTS */ |
| 2679 | (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */ |
| 2680 | (iw_handler) NULL, /* SIOCSIWFRAG */ |
| 2681 | (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */ |
| 2682 | (iw_handler) NULL, /* SIOCSIWTXPOW */ |
| 2683 | (iw_handler) NULL, /* SIOCGIWTXPOW */ |
| 2684 | (iw_handler) NULL, /* SIOCSIWRETRY */ |
| 2685 | (iw_handler) NULL, /* SIOCGIWRETRY */ |
| 2686 | (iw_handler) NULL, /* SIOCSIWENCODE */ |
| 2687 | (iw_handler) NULL, /* SIOCGIWENCODE */ |
| 2688 | (iw_handler) NULL, /* SIOCSIWPOWER */ |
| 2689 | (iw_handler) NULL, /* SIOCGIWPOWER */ |
| 2690 | (iw_handler) NULL, /* -- hole -- */ |
| 2691 | (iw_handler) NULL, /* -- hole -- */ |
| 2692 | (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */ |
| 2693 | (iw_handler) NULL, /* SIOCGIWGENIE */ |
| 2694 | (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */ |
| 2695 | (iw_handler) NULL, /* SIOCGIWAUTH */ |
| 2696 | (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */ |
| 2697 | (iw_handler) NULL, /* SIOCGIWENCODEEXT */ |
| 2698 | (iw_handler) NULL, /* SIOCSIWPMKSA */ |
| 2699 | }; |
| 2700 | |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 2701 | #define IW_PRIV_TYPE_OPTIE (IW_PRIV_TYPE_BYTE | QCSAP_MAX_OPT_IE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2702 | #define IW_PRIV_TYPE_MLME \ |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 2703 | (IW_PRIV_TYPE_BYTE | sizeof(struct ieee80211req_mlme)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2704 | |
| 2705 | static const struct iw_priv_args hostapd_private_args[] = { |
| 2706 | { QCSAP_IOCTL_SETPARAM, |
| 2707 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" }, |
| 2708 | { QCSAP_IOCTL_SETPARAM, |
| 2709 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" }, |
| 2710 | { QCSAP_PARAM_MAX_ASSOC, |
| 2711 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" }, |
| 2712 | { QCSAP_PARAM_HIDE_SSID, |
| 2713 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" }, |
| 2714 | { QCSAP_IOCTL_GETPARAM, |
| 2715 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 2716 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" }, |
| 2717 | { QCSAP_IOCTL_GETPARAM, 0, |
| 2718 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" }, |
| 2719 | { QCSAP_PARAM_MAX_ASSOC, 0, |
| 2720 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" }, |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 2721 | { QCSAP_PARAM_GET_WLAN_DBG, 0, |
| 2722 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" }, |
| 2723 | { QCSAP_PARAM_AUTO_CHANNEL, 0, |
| 2724 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2725 | { QCSAP_PARAM_MODULE_DOWN_IND, 0, |
| 2726 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "moduleDownInd" }, |
| 2727 | { QCSAP_PARAM_CLR_ACL, 0, |
| 2728 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" }, |
| 2729 | { QCSAP_PARAM_ACL_MODE, |
| 2730 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" }, |
| 2731 | { QCSAP_IOCTL_COMMIT, |
| 2732 | IW_PRIV_TYPE_BYTE | sizeof(struct s_CommitConfig) | IW_PRIV_SIZE_FIXED, 0, "commit" }, |
| 2733 | { QCSAP_IOCTL_SETMLME, |
| 2734 | IW_PRIV_TYPE_BYTE | sizeof(struct sQcSapreq_mlme)| IW_PRIV_SIZE_FIXED, 0, "setmlme" }, |
| 2735 | { QCSAP_IOCTL_GET_STAWPAIE, |
| 2736 | IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" }, |
| 2737 | { QCSAP_IOCTL_SETWPAIE, |
| 2738 | IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" }, |
| 2739 | { QCSAP_IOCTL_STOPBSS, |
| 2740 | IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" }, |
| 2741 | { QCSAP_IOCTL_VERSION, 0, |
| 2742 | IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" }, |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 2743 | { QCSAP_IOCTL_GET_STA_INFO, 0, |
| 2744 | IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2745 | { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES, |
| 2746 | IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED | 1, 0, "getProbeReqIEs" }, |
| 2747 | { QCSAP_IOCTL_GET_CHANNEL, 0, |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 2748 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2749 | { QCSAP_IOCTL_ASSOC_STA_MACADDR, 0, |
| 2750 | IW_PRIV_TYPE_BYTE | /*((WLAN_MAX_STA_COUNT*6)+100)*/1 , "get_assoc_stamac" }, |
| 2751 | { QCSAP_IOCTL_DISASSOC_STA, |
| 2752 | IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" }, |
| 2753 | { QCSAP_IOCTL_AP_STATS, |
| 2754 | IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE, 0, "ap_stats" }, |
| 2755 | { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED, |
| 2756 | IW_PRIV_TYPE_CHAR | 18, |
| 2757 | IW_PRIV_TYPE_CHAR | 3, "getLinkSpeed" }, |
| 2758 | |
| 2759 | { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE, |
| 2760 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" }, |
| 2761 | /* handlers for sub-ioctl */ |
| 2762 | { WE_SET_WLAN_DBG, |
| 2763 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, |
| 2764 | 0, |
| 2765 | "setwlandbg" }, |
| 2766 | |
| 2767 | /* handlers for main ioctl */ |
| 2768 | { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE, |
| 2769 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 2770 | 0, |
| 2771 | "" }, |
| 2772 | |
| 2773 | /* handlers for sub-ioctl */ |
| 2774 | { WE_LOG_DUMP_CMD, |
| 2775 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 2776 | 0, |
| 2777 | "dump" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2778 | { WE_P2P_NOA_CMD, |
| 2779 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 2780 | 0, |
| 2781 | "SetP2pPs" }, |
Madan Mohan Koyyalamudi | d5f04ca | 2012-11-06 15:51:26 -0800 | [diff] [blame] | 2782 | /* handlers for sub ioctl */ |
| 2783 | { |
| 2784 | WE_MCC_CONFIG_CREDENTIAL, |
| 2785 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 2786 | 0, |
| 2787 | "setMccCrdnl" }, |
| 2788 | |
| 2789 | /* handlers for sub ioctl */ |
| 2790 | { |
| 2791 | WE_MCC_CONFIG_PARAMS, |
| 2792 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 2793 | 0, |
| 2794 | "setMccConfig" }, |
| 2795 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2796 | /* handlers for main ioctl */ |
| 2797 | { QCSAP_IOCTL_MODIFY_ACL, |
| 2798 | IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8, |
| 2799 | 0, |
| 2800 | "modify_acl" }, |
| 2801 | |
| 2802 | /* handlers for main ioctl */ |
| 2803 | { QCSAP_IOCTL_GET_CHANNEL_LIST, |
| 2804 | 0, |
| 2805 | IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo), |
| 2806 | "getChannelList" }, |
| 2807 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2808 | /* handlers for main ioctl */ |
| 2809 | { QCSAP_IOCTL_SET_TX_POWER, |
| 2810 | IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1, |
| 2811 | 0, |
Madan Mohan Koyyalamudi | d12bf05 | 2012-11-27 19:07:55 +0530 | [diff] [blame] | 2812 | "setTxPower" }, |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 2813 | |
| 2814 | /* handlers for main ioctl */ |
| 2815 | { QCSAP_IOCTL_SET_MAX_TX_POWER, |
| 2816 | IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1, |
| 2817 | 0, |
| 2818 | "setTxMaxPower" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2819 | }; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2820 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2821 | static const iw_handler hostapd_private[] = { |
| 2822 | [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl |
| 2823 | [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl |
| 2824 | [QCSAP_IOCTL_COMMIT - SIOCIWFIRSTPRIV] = iw_softap_commit, //get priv ioctl |
| 2825 | [QCSAP_IOCTL_SETMLME - SIOCIWFIRSTPRIV] = iw_softap_setmlme, |
| 2826 | [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE |
| 2827 | [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie, |
| 2828 | [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss |
| 2829 | [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version |
| 2830 | [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs, |
| 2831 | [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel, |
| 2832 | [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr, |
| 2833 | [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta, |
| 2834 | [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats, |
| 2835 | [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone, |
| 2836 | [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone, |
| 2837 | [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range, |
| 2838 | [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl, |
| 2839 | [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list, |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 2840 | [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2841 | [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed, |
| 2842 | [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power, |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 2843 | [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2844 | }; |
| 2845 | const struct iw_handler_def hostapd_handler_def = { |
| 2846 | .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]), |
| 2847 | .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]), |
| 2848 | .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]), |
| 2849 | .standard = (iw_handler *)hostapd_handler, |
| 2850 | .private = (iw_handler *)hostapd_private, |
| 2851 | .private_args = hostapd_private_args, |
| 2852 | .get_wireless_stats = NULL, |
| 2853 | }; |
| 2854 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 2855 | struct net_device_ops net_ops_struct = { |
| 2856 | .ndo_open = hdd_hostapd_open, |
| 2857 | .ndo_stop = hdd_hostapd_stop, |
| 2858 | .ndo_uninit = hdd_hostapd_uninit, |
| 2859 | .ndo_start_xmit = hdd_softap_hard_start_xmit, |
| 2860 | .ndo_tx_timeout = hdd_softap_tx_timeout, |
| 2861 | .ndo_get_stats = hdd_softap_stats, |
| 2862 | .ndo_set_mac_address = hdd_hostapd_set_mac_address, |
| 2863 | .ndo_do_ioctl = hdd_hostapd_ioctl, |
| 2864 | .ndo_change_mtu = hdd_hostapd_change_mtu, |
| 2865 | .ndo_select_queue = hdd_hostapd_select_queue, |
| 2866 | }; |
| 2867 | #endif |
| 2868 | |
| 2869 | int hdd_set_hostapd(hdd_adapter_t *pAdapter) |
| 2870 | { |
| 2871 | return VOS_STATUS_SUCCESS; |
| 2872 | } |
| 2873 | |
| 2874 | void hdd_set_ap_ops( struct net_device *pWlanHostapdDev ) |
| 2875 | { |
| 2876 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 2877 | pWlanHostapdDev->netdev_ops = &net_ops_struct; |
| 2878 | #else |
| 2879 | pWlanHostapdDev->open = hdd_hostapd_open; |
| 2880 | pWlanHostapdDev->stop = hdd_hostapd_stop; |
| 2881 | pWlanHostapdDev->uninit = hdd_hostapd_uninit; |
| 2882 | pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit; |
| 2883 | pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout; |
| 2884 | pWlanHostapdDev->get_stats = hdd_softap_stats; |
| 2885 | pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address; |
| 2886 | pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl; |
| 2887 | #endif |
| 2888 | } |
| 2889 | |
| 2890 | VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter ) |
| 2891 | { |
| 2892 | hdd_hostapd_state_t * phostapdBuf; |
| 2893 | struct net_device *dev = pAdapter->dev; |
| 2894 | VOS_STATUS status; |
| 2895 | ENTER(); |
| 2896 | // Allocate the Wireless Extensions state structure |
| 2897 | phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter ); |
| 2898 | |
| 2899 | // Zero the memory. This zeros the profile structure. |
| 2900 | memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t)); |
| 2901 | |
| 2902 | // Set up the pointer to the Wireless Extensions state structure |
| 2903 | // NOP |
| 2904 | status = hdd_set_hostapd(pAdapter); |
| 2905 | if(!VOS_IS_STATUS_SUCCESS(status)) { |
| 2906 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!\n")); |
| 2907 | return status; |
| 2908 | } |
| 2909 | |
| 2910 | status = vos_event_init(&phostapdBuf->vosEvent); |
| 2911 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2912 | { |
| 2913 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!\n")); |
| 2914 | return status; |
| 2915 | } |
| 2916 | |
| 2917 | init_completion(&pAdapter->session_close_comp_var); |
| 2918 | init_completion(&pAdapter->session_open_comp_var); |
| 2919 | |
| 2920 | sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1); |
| 2921 | |
| 2922 | // Register as a wireless device |
| 2923 | dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def; |
| 2924 | |
| 2925 | //Initialize the data path module |
| 2926 | status = hdd_softap_init_tx_rx(pAdapter); |
| 2927 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 2928 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2929 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2930 | } |
| 2931 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2932 | wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2933 | EXIT(); |
| 2934 | return status; |
| 2935 | } |
| 2936 | |
| 2937 | hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name ) |
| 2938 | { |
| 2939 | struct net_device *pWlanHostapdDev = NULL; |
| 2940 | hdd_adapter_t *pHostapdAdapter = NULL; |
| 2941 | v_CONTEXT_t pVosContext= NULL; |
| 2942 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2943 | pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name, ether_setup, NUM_TX_QUEUES); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2944 | |
| 2945 | if (pWlanHostapdDev != NULL) |
| 2946 | { |
| 2947 | pHostapdAdapter = netdev_priv(pWlanHostapdDev); |
| 2948 | |
| 2949 | //Init the net_device structure |
| 2950 | ether_setup(pWlanHostapdDev); |
| 2951 | |
| 2952 | //Initialize the adapter context to zeros. |
| 2953 | vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t )); |
| 2954 | pHostapdAdapter->dev = pWlanHostapdDev; |
| 2955 | pHostapdAdapter->pHddCtx = pHddCtx; |
| 2956 | pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
| 2957 | |
| 2958 | //Get the Global VOSS context. |
| 2959 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 2960 | //Save the adapter context in global context for future. |
| 2961 | ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter; |
| 2962 | |
| 2963 | //Init the net_device structure |
| 2964 | strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ); |
| 2965 | |
| 2966 | hdd_set_ap_ops( pHostapdAdapter->dev ); |
| 2967 | |
| 2968 | pWlanHostapdDev->tx_queue_len = NET_DEV_TX_QUEUE_LEN; |
| 2969 | pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 2970 | pWlanHostapdDev->mtu = HDD_DEFAULT_MTU; |
| 2971 | |
| 2972 | vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr)); |
| 2973 | vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr)); |
| 2974 | |
| 2975 | pWlanHostapdDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2976 | pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ; |
| 2977 | pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 2978 | pHostapdAdapter->wdev.netdev = pWlanHostapdDev; |
| 2979 | init_completion(&pHostapdAdapter->tx_action_cnf_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2980 | init_completion(&pHostapdAdapter->cancel_rem_on_chan_var); |
| 2981 | init_completion(&pHostapdAdapter->rem_on_chan_ready_event); |
| 2982 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 2983 | init_completion(&pHostapdAdapter->offchannel_tx_event); |
| 2984 | #endif |
| 2985 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2986 | SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev); |
| 2987 | } |
| 2988 | return pHostapdAdapter; |
| 2989 | } |
| 2990 | |
| 2991 | VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 2992 | { |
| 2993 | struct net_device *dev = pAdapter->dev; |
| 2994 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 2995 | |
| 2996 | ENTER(); |
| 2997 | |
| 2998 | if( rtnl_lock_held ) |
| 2999 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 3000 | if (strnchr(dev->name, strlen(dev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3001 | if( dev_alloc_name(dev, dev->name) < 0 ) |
| 3002 | { |
| 3003 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__); |
| 3004 | return VOS_STATUS_E_FAILURE; |
| 3005 | } |
| 3006 | } |
| 3007 | if (register_netdevice(dev)) |
| 3008 | { |
| 3009 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 3010 | "%s:Failed:register_netdevice", __func__); |
| 3011 | return VOS_STATUS_E_FAILURE; |
| 3012 | } |
| 3013 | } |
| 3014 | else |
| 3015 | { |
| 3016 | if (register_netdev(dev)) |
| 3017 | { |
| 3018 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__); |
| 3019 | return VOS_STATUS_E_FAILURE; |
| 3020 | } |
| 3021 | } |
| 3022 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 3023 | |
| 3024 | EXIT(); |
| 3025 | return status; |
| 3026 | } |
| 3027 | |
| 3028 | VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter) |
| 3029 | { |
| 3030 | ENTER(); |
| 3031 | |
| 3032 | hdd_softap_deinit_tx_rx(pAdapter); |
| 3033 | |
| 3034 | /* if we are being called during driver unload, then the dev has already |
| 3035 | been invalidated. if we are being called at other times, then we can |
| 3036 | detatch the wireless device handlers */ |
| 3037 | if (pAdapter->dev) |
| 3038 | { |
| 3039 | pAdapter->dev->wireless_handlers = NULL; |
| 3040 | } |
| 3041 | EXIT(); |
| 3042 | return 0; |
| 3043 | } |