1981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
2981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * CmdInterpretWext.c
3981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
4981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * All rights reserved.
6981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
7981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Redistribution and use in source and binary forms, with or without
8981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * modification, are permitted provided that the following conditions
9981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * are met:
10981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
11981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Redistributions of source code must retain the above copyright
12981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    notice, this list of conditions and the following disclaimer.
13981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Redistributions in binary form must reproduce the above copyright
14981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    notice, this list of conditions and the following disclaimer in
15981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    the documentation and/or other materials provided with the
16981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    distribution.
17981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Neither the name Texas Instruments nor the names of its
18981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    contributors may be used to endorse or promote products derived
19981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    from this software without specific prior written permission.
20981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
21981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
33981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
34981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
35981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "tidef.h"
36981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "WlanDrvIf.h"
37981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "tiwlnif.h"
38981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "osDot11.h"
39981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "802_11Defs.h"
40981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "paramOut.h"
41981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "coreDefaultParams.h"
42981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "version.h"
43981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "osApi.h"
44981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "CmdHndlr.h"
45981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "CmdInterpret.h"
46981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "CmdInterpretWext.h"
47981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "TI_IPC_Api.h"
48981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "WlanDrvIf.h"
49981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include <linux/wireless.h>
50981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include <linux/if_arp.h>
51981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include <asm/uaccess.h>
52981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include <net/iw_handler.h>
53981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "privateCmd.h"
54981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "DrvMain.h"
55981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "CmdDispatcher.h"
56981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "EvHandler.h"
57981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "admCtrl.h"
58981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
59653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
60981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_INT32 cmdInterpret_Event(IPC_EV_DATA* pData);
61981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic int cmdInterpret_setSecurityParams (TI_HANDLE hCmdInterpret);
62981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic int cmdInterpret_initEvents(TI_HANDLE hCmdInterpret);
63981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic int cmdInterpret_unregisterEvents(TI_HANDLE hCmdInterpret, TI_HANDLE hEvHandler);
64981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
65023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt#define CHECK_PENDING_RESULT(x,y)     if (x == COMMAND_PENDING) { os_printf ("Unexpected COMMAND PENDING result (cmd = 0x%x)\n",y->paramType);  break; }
66981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
67981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic const char *ieee80211_modes[] = {
68981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    "?", "IEEE 802.11 B", "IEEE 802.11 A", "IEEE 802.11 BG", "IEEE 802.11 ABG"
69981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt};
70653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#ifdef XCC_MODULE_INCLUDED
71653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidttypedef struct
72653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt{
73981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
745e861de5ad899e72ec6582efb27da588b7583775Dmitry Shmidt    TI_UINT8        *assocRespBuffer;
75653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    TI_UINT32       assocRespLen;
76653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt} cckm_assocInformation_t;
77653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
78653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#define ASSOC_RESP_FIXED_DATA_LEN 6
79653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#define MAX_BEACON_BODY_LENGTH    350
80653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#define BEACON_HEADER_FIX_SIZE    12
81653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#define CCKM_START_EVENT_SIZE     23 /* cckm-start string + timestamp + bssid + null */
82653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#endif
83981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
84981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Initialize the CmdInterpreter module */
85981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_HANDLE cmdInterpret_Create (TI_HANDLE hOs)
86981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
87981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdInterpret_t *pCmdInterpret;
88981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
89981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Allocate memory for object */
90981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pCmdInterpret = os_memoryAlloc (hOs, sizeof(cmdInterpret_t));
91981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
92981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* In case of failure -> return NULL */
93981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (!pCmdInterpret)
94981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
95981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_printf ("cmdInterpret_init: failed to allocate memory...aborting\n");
96981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return NULL;
97981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
98981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
99981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Clear all fields in cmdInterpreter module object */
100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_memoryZero (hOs, pCmdInterpret, sizeof (cmdInterpret_t));
101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Save handlers */
103981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pCmdInterpret->hOs = hOs;
104981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
105981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Return pointer to object */
106981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return (TI_HANDLE)pCmdInterpret;
107981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
108981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
109981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
110981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Deinitialize the cmdInterpreter module */
111981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS cmdInterpret_Destroy (TI_HANDLE hCmdInterpret, TI_HANDLE hEvHandler)
112981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1135e861de5ad899e72ec6582efb27da588b7583775Dmitry Shmidt    cmdInterpret_t *pCmdInterpret = (cmdInterpret_t *)hCmdInterpret;
114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
115981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Unregister events */
116023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    cmdInterpret_unregisterEvents ((TI_HANDLE)pCmdInterpret, hEvHandler);
117981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Release allocated memory */
119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_memoryFree (pCmdInterpret->hOs, pCmdInterpret, sizeof(cmdInterpret_t));
120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid cmdInterpret_Init (TI_HANDLE hCmdInterpret, TStadHandlesList *pStadHandles)
126981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdInterpret_t *pCmdInterpret = (cmdInterpret_t *)hCmdInterpret;
128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pCmdInterpret->hCmdHndlr    = pStadHandles->hCmdHndlr;
130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pCmdInterpret->hEvHandler   = pStadHandles->hEvHandler;
131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pCmdInterpret->hCmdDispatch = pStadHandles->hCmdDispatch;
132981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
133981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Register to driver events */
134981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdInterpret_initEvents (hCmdInterpret);
135981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
136981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
137981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Handle a single command */
139981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtint cmdInterpret_convertAndExecute(TI_HANDLE hCmdInterpret, TConfigCommand *cmdObj)
140981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
141981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdInterpret_t *pCmdInterpret = (cmdInterpret_t *)hCmdInterpret;
142023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    paramInfo_t *pParam;
143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_STATUS res = TI_NOK;
144981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    int i,j;
145023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    union iwreq_data *wrqu = (union iwreq_data *)cmdObj->buffer1;
147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdObj->return_code = WEXT_NOT_SUPPORTED;
149023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    pParam = (paramInfo_t *)os_memoryAlloc(pCmdInterpret->hOs, sizeof(paramInfo_t));
150023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    if (!pParam)
151023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        return res;
152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Check user request */
153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (cmdObj->cmd)
154981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
155981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* get name == wireless protocol - used to verify the presence of Wireless Extensions*/
157981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWNAME:
158981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_memoryCopy(pCmdInterpret->hOs, cmdObj->buffer1, WLAN_PROTOCOL_NAME, IFNAMSIZ);
159981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        res = TI_OK;
160981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
161981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
162981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Set channel / frequency */
163981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWFREQ:
164981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
165981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* If there is a given channel */
166981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (wrqu->freq.m != 0)
167981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
168023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramType = SITE_MGR_DESIRED_CHANNEL_PARAM;
169023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramLength = sizeof(TI_UINT32);
170023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.siteMgrDesiredChannel = wrqu->freq.m;
171981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
172023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch, pParam);
173023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                CHECK_PENDING_RESULT(res,pParam)
174981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
175981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
176981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
177981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
178981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Get channel / frequency */
179981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWFREQ:
180981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
181023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
182023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramLength = sizeof(TI_UINT32);
183981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
184023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam (pCmdInterpret->hCmdDispatch, pParam);
185981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if(res == NO_SITE_SELECTED_YET)
186981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                res = TI_OK;
187023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
188023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
189981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
190981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (res == TI_OK)
191981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
192023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                wrqu->freq.m = pParam->content.siteMgrCurrentChannel;
1939615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt                wrqu->freq.e = 3;
194981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->freq.i = 0;
195981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
196981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
197981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
198981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
199981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Set Mode (Adhoc / infrastructure) */
200981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWMODE:
201981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
202023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SME_DESIRED_BSS_TYPE_PARAM;
203023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramLength = sizeof(ScanBssType_e);
204981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
205981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            switch (wrqu->mode)
206981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
207981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_MODE_AUTO:
208023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.smeDesiredBSSType = BSS_ANY;
209981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
210981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_MODE_ADHOC:
211023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.smeDesiredBSSType = BSS_INDEPENDENT;
212981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
213981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_MODE_INFRA:
214023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.smeDesiredBSSType = BSS_INFRASTRUCTURE;
215981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
216981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            default:
217023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = -EOPNOTSUPP;
218023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                goto cmd_end;
219981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
220981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
221023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam(pCmdInterpret->hCmdDispatch, pParam);
222023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
223981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
224981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* also set the site mgr desired mode */
225023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SITE_MGR_DESIRED_BSS_TYPE_PARAM;
226023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam(pCmdInterpret->hCmdDispatch, pParam);
227023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
228023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
229981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
230981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
231981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
232981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Get Mode (Adhoc / infrastructure) */
233981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWMODE:
234981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
235023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SME_DESIRED_BSS_TYPE_PARAM;
236023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramLength = sizeof(ScanBssType_e);
237023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam(pCmdInterpret->hCmdDispatch, pParam);
238023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
239981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
240023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            switch (pParam->content.smeDesiredBSSType)
241981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
242981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case BSS_ANY:
243981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->mode = IW_MODE_AUTO;
244981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
245981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case BSS_INDEPENDENT:
246981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->mode = IW_MODE_ADHOC;
247981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
248981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case BSS_INFRASTRUCTURE:
249981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->mode = IW_MODE_INFRA;
250981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
251981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            default:
252981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
253981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
254981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
255981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
256981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
257981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
258981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Set sensitivity (Rssi roaming threshold)*/
259981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWSENS:
260981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
261981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* First get the current roaming configuration as a whole */
262023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = ROAMING_MNGR_APPLICATION_CONFIGURATION;
263023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramLength = sizeof (roamingMngrConfigParams_t);
264023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam(pCmdInterpret->hCmdDispatch, pParam);
265981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
266023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
267981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
268981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Now change the low rssi threshold supplied by the user */
269023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.roamingConfigBuffer.roamingMngrThresholdsConfig.lowRssiThreshold = wrqu->param.value;
270981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
271981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* And set the parameters back to the roaming module */
272023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam(pCmdInterpret->hCmdDispatch, pParam);
273981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
274023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
275981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
276981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
277981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
278981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
279981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Get sensitivity (Rssi threshold OR CCA?)*/
280981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWSENS:
281981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
282023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = ROAMING_MNGR_APPLICATION_CONFIGURATION;
283023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramLength = sizeof (roamingMngrConfigParams_t);
284023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam(pCmdInterpret->hCmdDispatch, pParam);
285981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
286023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
287981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
288981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (res == TI_OK)
289981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
290023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                wrqu->param.value = pParam->content.roamingConfigBuffer.roamingMngrThresholdsConfig.lowRssiThreshold;
291981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->param.disabled = (wrqu->param.value == 0);
292981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->param.fixed = 1;
293981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
294981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
295981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
296981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
297981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
298981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Get a range of parameters regarding the device capabilities */
299981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWRANGE:
300981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
301981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            struct iw_point *data = (struct iw_point *) cmdObj->buffer1;
302981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            struct iw_range *range = (struct iw_range *) cmdObj->buffer2;
303981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            int i;
304981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
305981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Reset structure */
306981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            data->length = sizeof(struct iw_range);
307981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_memorySet(pCmdInterpret->hOs, range, 0, sizeof(struct iw_range));
308981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
309981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Wireless Extension version info */
310981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->we_version_compiled = WIRELESS_EXT;   /* Must be WIRELESS_EXT */
311981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->we_version_source = 19;               /* Last update of source */
312981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
313981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* estimated maximum TCP throughput values (bps) */
314981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->throughput = MAX_THROUGHPUT;
315981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
316981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* NWID (or domain id) */
317981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->min_nwid = 0; /* Minimal NWID we are able to set */
318981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->max_nwid = 0; /* Maximal NWID we are able to set */
319981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
320981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Old Frequency - no need to support this*/
321981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->old_num_channels = 0;
322981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->old_num_frequency = 0;
323981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
324981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Wireless event capability bitmasks */
325023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
326981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            IW_EVENT_CAPA_SET(range->event_capa, IWEVREGISTERED);
327981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            IW_EVENT_CAPA_SET(range->event_capa, IWEVEXPIRED);
328981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
329981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* signal level threshold range */
330981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->sensitivity = 0;
331981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
332981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Rates */
333023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM;
334023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam (pCmdInterpret->hCmdDispatch, pParam );
335981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
336023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
337981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
338981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Number of entries in the rates list */
339023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            range->num_bitrates = pParam->content.siteMgrDesiredSupportedRateSet.len;
340023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            for (i=0; i<pParam->content.siteMgrDesiredSupportedRateSet.len; i++)
341981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
342023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                range->bitrate[i] = ((pParam->content.siteMgrDesiredSupportedRateSet.ratesString[i] & 0x7F) * 500000);
343981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
344981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
345981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* RTS threshold */
346981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->min_rts = TWD_RTS_THRESHOLD_MIN; /* Minimal RTS threshold */
347981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->max_rts = TWD_RTS_THRESHOLD_DEF; /* Maximal RTS threshold */
348981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
349981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Frag threshold */
350981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->min_frag = TWD_FRAG_THRESHOLD_MIN;    /* Minimal frag threshold */
351981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->max_frag = TWD_FRAG_THRESHOLD_DEF;    /* Maximal frag threshold */
352981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
353981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Power Management duration & timeout */
354981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->min_pmp = 0;  /* Minimal PM period */
355981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->max_pmp = 0;  /* Maximal PM period */
356981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->min_pmt = 0;  /* Minimal PM timeout */
357981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->max_pmt = 0;  /* Maximal PM timeout */
358981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->pmp_flags = IW_POWER_ON;  /* How to decode max/min PM period */
359981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->pmt_flags = IW_POWER_ON; /* How to decode max/min PM timeout */
360981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
361981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* What Power Management options are supported */
362981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->pm_capa = IW_POWER_UNICAST_R |                /* Receive only unicast messages */
363981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                             IW_POWER_MULTICAST_R |              /* Receive only multicast messages */
364981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                             IW_POWER_ALL_R |                    /* Receive all messages though PM */
365981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                             IW_POWER_FORCE_S |                  /* Force PM procedure for sending unicast */
366981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                             IW_POWER_PERIOD |                   /* Value is a period/duration of */
367981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                             IW_POWER_TIMEOUT;                   /* Value is a timeout (to go asleep) */
368981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
369981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Transmit power */
370981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->txpower_capa = IW_TXPOW_RELATIVE | IW_TXPOW_RANGE;    /* What options are supported */
371981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->num_txpower = 5;  /* Number of entries in the list */
372981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->txpower[0] = 1;   /* list of values (maximum is IW_MAX_TXPOWER = 8) */
373981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->txpower[1] = 2;   /* list of values (maximum is IW_MAX_TXPOWER = 8) */
374981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->txpower[2] = 3;   /* list of values (maximum is IW_MAX_TXPOWER = 8) */
375981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->txpower[3] = 4;   /* list of values (maximum is IW_MAX_TXPOWER = 8) */
376981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->txpower[4] = 5;   /* list of values (maximum is IW_MAX_TXPOWER = 8) */
377981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
378981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Retry limits and lifetime */
379981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->retry_capa = 0;   /* What retry options are supported */
380981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->retry_flags = 0;  /* How to decode max/min retry limit */
381981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->r_time_flags = 0; /* How to decode max/min retry life */
382981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->min_retry = 0;    /* Minimal number of retries */
383981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->max_retry = 0;    /* Maximal number of retries */
384981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->min_r_time = 0;   /* Minimal retry lifetime */
385981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->max_r_time = 0;   /* Maximal retry lifetime */
386981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
387981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Get Supported channels */
388023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SITE_MGR_RADIO_BAND_PARAM;
389023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam( pCmdInterpret->hCmdDispatch, pParam );
390981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
391023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
392981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
393981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* pParam->content.siteMgrRadioBand contains the current band, now get list of supported channels */
394023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = REGULATORY_DOMAIN_ALL_SUPPORTED_CHANNELS;
395023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam( pCmdInterpret->hCmdDispatch, pParam );
396981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
397023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
398981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
399023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            range->num_channels = pParam->content.supportedChannels.sizeOfList;    /* Number of channels [0; num - 1] */
400023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            range->num_frequency = pParam->content.supportedChannels.sizeOfList;   /* Number of entry in the list */
401981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
402023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            for (i=0; i<pParam->content.supportedChannels.sizeOfList; i++)
403981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
404981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                range->freq[i].e = 0;
405981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                range->freq[i].m = i;
406023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                range->freq[i].i = pParam->content.supportedChannels.listOfChannels[i]+1;
407981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
408981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
409981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Encoder (Encryption) capabilities */
410981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->num_encoding_sizes = 4;
411981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* 64(40) bits WEP */
412981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->encoding_size[0] = WEP_KEY_LENGTH_40;
413981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* 128(104) bits WEP */
414981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->encoding_size[1] = WEP_KEY_LENGTH_104;
415981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* 256 bits for WPA-PSK */
416981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->encoding_size[2] = TKIP_KEY_LENGTH;
417981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* 128 bits for WPA2-PSK */
418981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->encoding_size[3] = AES_KEY_LENGTH;
419981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* 4 keys are allowed */
420981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->max_encoding_tokens = 4;
421981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
422981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            range->encoding_login_index = 0; /* token index for login token */
423981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
424981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Encryption capabilities */
425023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            range->enc_capa = IW_ENC_CAPA_WPA |
426023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                              IW_ENC_CAPA_WPA2 |
427023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                              IW_ENC_CAPA_CIPHER_TKIP |
428981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                              IW_ENC_CAPA_CIPHER_CCMP; /* IW_ENC_CAPA_* bit field */
429981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
430981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
431981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
432981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
433981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Set desired BSSID */
434981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWAP:
435981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
436981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
437981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* If MAC address is zeroes -> connect to "ANY" BSSID */
438981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (MAC_NULL (wrqu->ap_addr.sa_data))
439981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
440981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* Convert to "FF:FF:FF:FF:FF:FF" since this driver requires this value */
441023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                MAC_COPY (pParam->content.siteMgrDesiredBSSID, "\xff\xff\xff\xff\xff\xff");
442023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            }
443981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
444981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
445023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                MAC_COPY (pParam->content.siteMgrDesiredBSSID, wrqu->ap_addr.sa_data);
446981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
447981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
448023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SITE_MGR_DESIRED_BSSID_PARAM;
449023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam ( pCmdInterpret->hCmdDispatch, pParam );
450023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
451981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
452981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* also set it to the SME */
453023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SME_DESIRED_BSSID_PARAM;
454023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam ( pCmdInterpret->hCmdDispatch, pParam );
455023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
456981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
457981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
458981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
459981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
460981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
461981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Get current BSSID */
462981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWAP:
463981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
464981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Get current AP BSSID */
465023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SITE_MGR_CURRENT_BSSID_PARAM;
466023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam ( pCmdInterpret->hCmdDispatch, pParam );
467981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
468023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
469981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
470981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* In case we are not associated - copy zeroes into bssid */
471981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (res == NO_SITE_SELECTED_YET)
472981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
473981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                MAC_COPY (wrqu->ap_addr.sa_data, "\x00\x00\x00\x00\x00\x00");
474981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                cmdObj->return_code = WEXT_OK;
475023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            }
476981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else if (res == TI_OK)
477981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
478023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                MAC_COPY (wrqu->ap_addr.sa_data, pParam->content.siteMgrDesiredBSSID);
479981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
480981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
481981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
482981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
483981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
484981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
485981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* request MLME operation (Deauthenticate / Disassociate) */
486981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWMLME:
487981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
488981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            struct iw_mlme *mlme = (struct iw_mlme *)cmdObj->param3;
489981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
490023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SITE_MGR_DESIRED_SSID_PARAM;
491981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
492981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* In either case - we need to disconnect, so prepare "junk" SSID */
493981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            for (i = 0; i < MAX_SSID_LEN; i++)
494023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.siteMgrDesiredSSID.str[i] = (i+1);
495023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.siteMgrDesiredSSID.len = MAX_SSID_LEN;
496981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
497981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            switch (mlme->cmd)
498981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
499981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_MLME_DEAUTH:
500981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_MLME_DISASSOC:
501023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch, pParam );
502023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                CHECK_PENDING_RESULT(res,pParam)
503981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* now also set it to the SME */
504023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramType = SME_DESIRED_SSID_ACT_PARAM;
505023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch, pParam );
506023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                CHECK_PENDING_RESULT(res,pParam)
507981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
508981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            default:
509023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = -EOPNOTSUPP;
510023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                goto cmd_end;
511981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
512981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
513981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
514981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
515981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* trigger scanning (list cells) */
516981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWSCAN:
517981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
518023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            if (wrqu->data.flags & IW_SCAN_THIS_ESSID)
519981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
520653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                struct iw_scan_req scanReq;
521653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
522653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                if(copy_from_user(&scanReq, wrqu->data.pointer, sizeof(scanReq)))
523653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                {
524653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                    printk("CRITICAL: Could not copy data from user space!!!");
525023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    res = -EFAULT;
526023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    goto cmd_end;
527653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                }
528981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
529023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.tScanDesiredSSID.len = scanReq.essid_len;
530023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs, pParam->content.tScanDesiredSSID.str, scanReq.essid, scanReq.essid_len);
531981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
532981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
533981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
534023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.tScanDesiredSSID.len = 0;
535981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
536981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
537023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SCAN_CNCN_BSSID_LIST_SCAN_PARAM;
538023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramLength = sizeof(pParam->content.tScanDesiredSSID);
539023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch, pParam );
540023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
541981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
542981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
543981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
544981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* get scanning results */
545981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWSCAN:
546981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
547023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            unsigned char ies[256];
548023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            unsigned char buf[30];
549981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            char *event = (char *)cmdObj->buffer2;
550981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            struct iw_event iwe;
551023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            char *end_buf, *current_val;
552981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            int allocated_size;
553981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            OS_802_11_BSSID_LIST_EX *my_list;
554981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            OS_802_11_BSSID_EX *my_current;
555981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            int offset;
556023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            OS_802_11_VARIABLE_IEs *pRsnIes;
557023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            int ies_offset;
558653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            int i;
559981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
5609615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
561981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            struct iw_request_info info;
562023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            info.cmd = SIOCGIWSCAN;
563023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            info.flags = 0;
564981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
565981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            end_buf = (char *)(cmdObj->buffer2 + wrqu->data.length);
566981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
567981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* First get the amount of memory required to hold the entire BSSID list by setting the length to 0 */
568023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SCAN_CNCN_BSSID_LIST_SIZE_PARAM;
569023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramLength = 0;
570023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam (pCmdInterpret->hCmdDispatch, pParam );
571023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
572981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
573023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            allocated_size = pParam->content.uBssidListSize;
574981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
575981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Allocate required memory */
576981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            my_list = os_memoryAlloc (pCmdInterpret->hOs, allocated_size);
577023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            if (!my_list) {
578023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = -ENOMEM;
579023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                goto cmd_end;
580023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            }
581981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
582981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* And retrieve the list */
583023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SCAN_CNCN_BSSID_LIST_PARAM;
584023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.pBssidList = my_list;
585023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramLength = allocated_size;
586023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam (pCmdInterpret->hCmdDispatch, pParam );
587023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
588981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
589981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            my_current = &my_list->Bssid[0];
590981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            i=0;
591981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if(wrqu->data.flags)
592981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
593981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                for (i=0; i<wrqu->data.flags; i++)
594981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    my_current = (OS_802_11_BSSID_EX *) (((char *) my_current) + my_current->Length);
595981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
596981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Now send a wireless event per BSSID with "tokens" describing it */
597653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
598981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            for (; i<my_list->NumberOfItems; i++)
599981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
600981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
601981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                if (event + my_current->Length > end_buf)
602981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
603981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    break;
604981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                }
605023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
606981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* The first entry MUST be the AP BSSID */
607981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memorySet (pCmdInterpret->hOs, &iwe, 0, sizeof(iwe));
608981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.cmd = SIOCGIWAP;
609981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
610981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.len = IW_EV_ADDR_LEN;
611981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs, iwe.u.ap_addr.sa_data, &my_current->MacAddress, ETH_ALEN);
6129615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
613981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                event = iwe_stream_add_event(event, end_buf, &iwe, IW_EV_ADDR_LEN);
6149615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#else
6159615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt                event = iwe_stream_add_event(&info,event, end_buf, &iwe, IW_EV_ADDR_LEN);
616981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
617981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* Add SSID */
618981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.cmd = SIOCGIWESSID;
619981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.u.data.flags = 1;
620653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                iwe.u.data.length = min((TI_UINT8)my_current->Ssid.SsidLength, (TI_UINT8)32);
621023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
622981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                event = iwe_stream_add_point(event, end_buf, &iwe, my_current->Ssid.Ssid);
6239615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#else
6249615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt                event = iwe_stream_add_point(&info,event, end_buf, &iwe, my_current->Ssid.Ssid);
625981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
626981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* Add the protocol name (BSS support for A/B/G) */
627981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memorySet (pCmdInterpret->hOs, &iwe, 0, sizeof(iwe));
628981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.cmd = SIOCGIWNAME;
629981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs, (void*)iwe.u.name, (void*)ieee80211_modes[my_current->NetworkTypeInUse], IFNAMSIZ);
6309615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
631981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                event = iwe_stream_add_event(event, end_buf, &iwe, IW_EV_CHAR_LEN);
6329615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#else
633023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                event = iwe_stream_add_event(&info,event, end_buf, &iwe, IW_EV_CHAR_LEN);
634981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
635981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* add mode (infrastructure or Adhoc) */
636981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memorySet (pCmdInterpret->hOs, &iwe, 0, sizeof(iwe));
637981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.cmd = SIOCGIWMODE;
638981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                if (my_current->InfrastructureMode == os802_11IBSS)
639981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    iwe.u.mode = IW_MODE_ADHOC;
640981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                else if (my_current->InfrastructureMode == os802_11Infrastructure)
641981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    iwe.u.mode = IW_MODE_INFRA;
642981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                else
643981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    iwe.u.mode = IW_MODE_AUTO;
6449615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
645981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                event = iwe_stream_add_event(event, end_buf, &iwe, IW_EV_UINT_LEN);
6469615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#else
6479615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt                event = iwe_stream_add_event(&info,event, end_buf, &iwe, IW_EV_UINT_LEN);
648981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
649981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
650981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* add freq */
651981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memorySet (pCmdInterpret->hOs, &iwe, 0, sizeof(iwe));
652981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.cmd = SIOCGIWFREQ;
653981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.u.freq.m = my_current->Configuration.Union.channel;
6549615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt                iwe.u.freq.e = 3; /* Frequency divider */
655981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.u.freq.i = 0;
656981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.len = IW_EV_FREQ_LEN;
6579615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
658981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                event = iwe_stream_add_event(event, end_buf, &iwe, IW_EV_FREQ_LEN);
6599615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#else
6609615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt                event = iwe_stream_add_event(&info,event, end_buf, &iwe, IW_EV_FREQ_LEN);
661981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
662981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* Add quality statistics */
663981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.cmd = IWEVQUAL;
664981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED | IW_QUAL_QUAL_INVALID | IW_QUAL_NOISE_INVALID | IW_QUAL_DBM;
665981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.u.qual.qual = 0;
666981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.u.qual.level = my_current->Rssi;
667981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.u.qual.noise = 0;
6689615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
669981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                event = iwe_stream_add_event(event, end_buf, &iwe, IW_EV_QUAL_LEN);
6709615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#else
6719615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt                event = iwe_stream_add_event(&info,event, end_buf, &iwe, IW_EV_QUAL_LEN);
672981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
673981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* Add encryption capability */
674981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.cmd = SIOCGIWENCODE;
675981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                if ((my_current->Capabilities >> CAP_PRIVACY_SHIFT) & CAP_PRIVACY_MASK)
676981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
677981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                else
678981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    iwe.u.data.flags = IW_ENCODE_DISABLED;
679981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.u.data.length = 0;
6809615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
681981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                event = iwe_stream_add_point(event, end_buf, &iwe, NULL);
6829615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#else
6839615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt                event = iwe_stream_add_point(&info,event, end_buf, &iwe, NULL);
684981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
685981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
686981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* add rate */
687981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memorySet (pCmdInterpret->hOs, &iwe, 0, sizeof(iwe));
688981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.cmd = SIOCGIWRATE;
689981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                current_val = event + IW_EV_LCP_LEN;
690981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                for (j=0; j<16; j++)
691981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
692981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    if (my_current->SupportedRates[j])
693981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    {
694981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        iwe.u.bitrate.value = ((my_current->SupportedRates[j] & 0x7f) * 500000);
6959615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
696023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                        current_val = iwe_stream_add_value(event, current_val, end_buf, &iwe,IW_EV_PARAM_LEN);
697981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#else
6989615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt                        current_val = iwe_stream_add_value(&info,event, current_val,end_buf, &iwe,IW_EV_PARAM_LEN);
699981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
700981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    }
701981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                }
702981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
703981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                event = current_val;
704981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
705981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* CUSTOM - Add beacon interval */
706981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memorySet (pCmdInterpret->hOs, &iwe, 0, sizeof(iwe));
707981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.cmd = IWEVCUSTOM;
708981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                sprintf(buf, "Bcn int = %d ms ", my_current->Configuration.BeaconPeriod);
709981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.u.data.length = strlen(buf);
7109615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
711981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                event = iwe_stream_add_point(event, end_buf, &iwe, buf);
7129615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#else
7139615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt                event = iwe_stream_add_point(&info,event, end_buf, &iwe, buf);
714981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
715981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* add RSN IE */
716981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memorySet (pCmdInterpret->hOs, &iwe, 0, sizeof(iwe));
717023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memorySet (pCmdInterpret->hOs, ies, 0, 256);
718981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                iwe.cmd = IWEVGENIE;
719981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                offset = sizeof(OS_802_11_FIXED_IEs);
720023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                ies_offset = 0;
721653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
722023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                while(offset < my_current->IELength)
723981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
724981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    pRsnIes = (OS_802_11_VARIABLE_IEs*)&(my_current->IEs[offset]);
725023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    if((pRsnIes->ElementID == RSN_IE_ID) || (pRsnIes->ElementID == WPA_IE_ID))
726981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    {
727023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                        os_memoryCopy (pCmdInterpret->hOs, ies + ies_offset, (char *)&(my_current->IEs[offset]), pRsnIes->Length + 2);
728653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                        ies_offset += pRsnIes->Length + 2;
729653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                    }
730653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                    offset += pRsnIes->Length + 2;
731653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                }
732653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                if (ies_offset)
733023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                {
734653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                    iwe.u.data.flags = 1;
735653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                    iwe.u.data.length = ies_offset;
7369615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
737653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                     event = iwe_stream_add_point(event, end_buf, &iwe, (char *)ies);
7389615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt#else
7399615cc23eb6ffe3b882734aa06e2c386f5ad4446Dmitry Shmidt                     event = iwe_stream_add_point(&info, event, end_buf, &iwe, (char *)ies);
740981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
741023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                }
742981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
743981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                my_current = (OS_802_11_BSSID_EX *) (((char *) my_current) + my_current->Length);
744981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
745981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
746981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            wrqu->data.length = event - ((char *)cmdObj->buffer2);
747981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if(i == my_list->NumberOfItems)
748981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
749981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->data.flags = 0;
750981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
751981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
752981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
753981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->data.flags = i;
754981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
755981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
756981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_memoryFree (pCmdInterpret->hOs, my_list, allocated_size);
757981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            cmdObj->return_code = WEXT_OK;
758981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
759981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
760981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
761981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
762981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Set ESSID */
763981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWESSID:
764981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
765981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            char *extra = cmdObj->buffer2;
766981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            int length;
767981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
768981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (wrqu->essid.flags & SET_SSID_WITHOUT_SUPPL)
769981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->essid.flags &= ~SET_SSID_WITHOUT_SUPPL;
770981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
771981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                cmdInterpret_setSecurityParams (hCmdInterpret);
772981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
773023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            os_memoryZero (pCmdInterpret->hOs, &pParam->content.siteMgrDesiredSSID.str, MAX_SSID_LEN);
774653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
775023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.siteMgrCurrentSSID.len = 0;
776981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
777981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (wrqu->essid.flags == 0)
778981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
779981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* Connect to ANY ESSID - use empty */
780023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs, &pParam->content.siteMgrCurrentSSID.str, "\00", 1);
781023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.siteMgrCurrentSSID.len = 0;;
782981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            } else
783981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
784981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* Handle ESSID length issue in WEXT (backward compatibility with old/new versions) */
785981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                length = wrqu->essid.length - 1;
786981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                if (length > 0)
787981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    length--;
788981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                while (length < wrqu->essid.length && extra[length])
789981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    length++;
790981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
791023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs, &pParam->content.siteMgrCurrentSSID.str, cmdObj->buffer2, length);
792023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.siteMgrCurrentSSID.len = length;
793981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
794981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
795023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SITE_MGR_DESIRED_SSID_PARAM;
796023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramLength = sizeof (TSsid);
797023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch, pParam );
798023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
799981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* also set it to the SME */
800023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SME_DESIRED_SSID_ACT_PARAM;
801023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch, pParam );
802023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
803981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
804981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
805981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
806981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* get ESSID */
807981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWESSID:
808981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
809981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            char *extra = (char *)cmdObj->buffer2;
810981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
811023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SITE_MGR_CURRENT_SSID_PARAM;
812023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam ( pCmdInterpret->hCmdDispatch, pParam );
813981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if(res == NO_SITE_SELECTED_YET)
814981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                res = WEXT_OK;
815981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
816023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
817981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
818981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            wrqu->essid.flags  = 1;
819981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
820023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            os_memoryCopy(pCmdInterpret->hOs, cmdObj->buffer2, &pParam->content.siteMgrCurrentSSID.str, pParam->content.siteMgrCurrentSSID.len );
821981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
822023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            if (pParam->content.siteMgrCurrentSSID.len < MAX_SSID_LEN)
8233f2824312a75dcb53eccc70ee2cbf5356cc1c0bbDmitry Shmidt            {
824023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                extra[pParam->content.siteMgrCurrentSSID.len] = 0;
8253f2824312a75dcb53eccc70ee2cbf5356cc1c0bbDmitry Shmidt            }
826023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            wrqu->essid.length = pParam->content.siteMgrCurrentSSID.len;
827981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
828981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
829981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
830981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
831981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* set node name/nickname */
832981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWNICKN:
833981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
834023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            if (wrqu->data.length > IW_ESSID_MAX_SIZE) {
835023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = -EINVAL;
836023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                goto cmd_end;
837023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            }
838981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_memoryCopy(pCmdInterpret->hOs, pCmdInterpret->nickName, cmdObj->buffer2, wrqu->data.length);
839981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pCmdInterpret->nickName[IW_ESSID_MAX_SIZE] = 0;
840981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            res = TI_OK;
841981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
842981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
843981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
844981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
845981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* get node name/nickname */
846981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWNICKN:
847981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
848981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            struct iw_point *data = (struct iw_point *) cmdObj->buffer1;
849981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
850981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            data->length = strlen(pCmdInterpret->nickName);
851981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_memoryCopy(pCmdInterpret->hOs, cmdObj->buffer2, &pCmdInterpret->nickName, data->length);
852981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
853981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            res = TI_OK;
854981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
855981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
856981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
857981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Set RTS Threshold */
858981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWRTS:
859981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
860023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = TWD_RTS_THRESHOLD_PARAM;
861981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
862981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (wrqu->rts.disabled)
863023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.halCtrlRtsThreshold = TWD_RTS_THRESHOLD_DEF;
864981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
865023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.halCtrlRtsThreshold = wrqu->rts.value;
866981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
867023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch,pParam);
868023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
869981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
870981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
871023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
872981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Get RTS Threshold */
873981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWRTS:
874981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
875023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = TWD_RTS_THRESHOLD_PARAM;
876023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam (pCmdInterpret->hCmdDispatch,pParam);
877981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
878023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
879981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
880023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            wrqu->rts.value = pParam->content.halCtrlRtsThreshold;
881023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            wrqu->rts.fixed = 1;
882981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            cmdObj->return_code = WEXT_OK;
883981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
884981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
885981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
886981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Set Fragmentation threshold */
887981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWFRAG:
888981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
889023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = TWD_FRAG_THRESHOLD_PARAM;
890023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.halCtrlFragThreshold = ((wrqu->frag.value+1)>>1) << 1; /* make it always even */
891981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
892023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam(pCmdInterpret->hCmdDispatch, pParam);
893023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
894981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
895981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
896981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
897981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
898981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Get Fragmentation threshold */
899981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWFRAG:
900981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
901023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = TWD_FRAG_THRESHOLD_PARAM;
902023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam (pCmdInterpret->hCmdDispatch,pParam);
903981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
904023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
905981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
906023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            wrqu->rts.value = pParam->content.halCtrlFragThreshold;
907023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            wrqu->rts.fixed = 1;
908981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            cmdObj->return_code = WEXT_OK;
909981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
910981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
911981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
912981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Set TX power level */
913981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWTXPOW:
914981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (wrqu->txpower.disabled == 1)
915981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
916981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            cmdObj->return_code = WEXT_INVALID_PARAMETER;
917981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
918981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
919981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
920023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = REGULATORY_DOMAIN_CURRENT_TX_POWER_LEVEL_PARAM;
921023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.desiredTxPower = wrqu->txpower.value;
922023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch,pParam);
923023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
924981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
925981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
926981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
927981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Get TX power level */
928981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWTXPOW:
929981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
930023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM;
931023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam (pCmdInterpret->hCmdDispatch,pParam);
932981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
933023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
934981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
935981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            wrqu->txpower.flags = IW_TXPOW_RELATIVE | IW_TXPOW_RANGE;
936981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            wrqu->txpower.disabled = 0;
937981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            wrqu->txpower.fixed = 0;
938023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            wrqu->txpower.value = pParam->content.desiredTxPower;
939981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
940981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
941981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
942981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
943981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* set encoding token & mode - WEP only */
944981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWENCODE:
945981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
946981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            int index;
947981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
948981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            index = (wrqu->encoding.flags & IW_ENCODE_INDEX);
949981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
950981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* iwconfig gives index as 1 - N */
951981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (index > 0)
952981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                index--;
953981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
954981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
955023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramType = RSN_DEFAULT_KEY_ID;
956023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = cmdDispatch_GetParam (pCmdInterpret->hCmdDispatch,pParam);
957023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                CHECK_PENDING_RESULT(res,pParam)
958023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                index = pParam->content.rsnDefaultKeyID;
959981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
960023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
961023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = RSN_ADD_KEY_PARAM;
962981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* remove key if disabled */
963981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (wrqu->data.flags & IW_ENCODE_DISABLED)
964981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
965023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramType = RSN_REMOVE_KEY_PARAM;
966981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
967981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
968023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.rsnOsKey.KeyIndex = index;
969981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
970981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (wrqu->data.length)
971981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
972023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs, &pParam->content.rsnOsKey.KeyMaterial, cmdObj->buffer2, wrqu->data.length);
973023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.rsnOsKey.KeyLength = wrqu->data.length;
974981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            } else
975981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
976981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* No key material is provided, just set given index as default TX key */
977023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramType = RSN_DEFAULT_KEY_ID;
978023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.rsnDefaultKeyID = index;
979981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
980981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
981023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch, pParam);
982023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
983981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
984981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
985981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
986981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
987981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
988981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* get encoding token & mode */
989981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWENCODE:
990981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
991981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            int index, encr_mode;
992981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            char *extra = (char *)cmdObj->buffer2;
993981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TSecurityKeys myKeyInfo;
994981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
995981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            wrqu->data.length = 0;
996981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            extra[0] = 0;
997981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
998981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Get Index from user request */
999981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            index = (wrqu->encoding.flags & IW_ENCODE_INDEX);
1000981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (index > 0)
1001981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                index--;
1002981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
1003981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1004023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramType = RSN_DEFAULT_KEY_ID;
1005023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = cmdDispatch_GetParam (pCmdInterpret->hCmdDispatch,pParam);
1006023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                CHECK_PENDING_RESULT(res,pParam)
1007023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                index = pParam->content.rsnDefaultKeyID;
1008981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->data.flags = (index+1);
1009981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1010981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1011023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.pRsnKey = &myKeyInfo;
1012981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1013023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = RSN_KEY_PARAM;
1014023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.pRsnKey->keyIndex = index;
1015023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_GetParam (pCmdInterpret->hCmdDispatch,pParam);
1016023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
1017981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1018023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            if ((pParam->content.pRsnKey) && (pParam->content.pRsnKey->encLen))
1019981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1020981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->data.flags |= IW_ENCODE_ENABLED;
1021023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                wrqu->data.length = pParam->content.pRsnKey->encLen;
1022023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs,extra, &pParam->content.pRsnKey->encKey,wrqu->data.length);
1023981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1024981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1025981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Convert from driver (OID-like) authentication parameters to WEXT */
1026981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (pCmdInterpret->wai.iw_auth_cipher_pairwise & IW_AUTH_CIPHER_CCMP)
1027981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                encr_mode = os802_11Encryption3Enabled;
1028981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else if (pCmdInterpret->wai.iw_auth_cipher_pairwise & IW_AUTH_CIPHER_TKIP)
1029981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                encr_mode = os802_11Encryption2Enabled;
1030981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else if (pCmdInterpret->wai.iw_auth_cipher_pairwise & (IW_AUTH_CIPHER_WEP40 | IW_AUTH_CIPHER_WEP104))
1031981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                encr_mode = os802_11Encryption1Enabled;
1032981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else if (pCmdInterpret->wai.iw_auth_cipher_group & IW_AUTH_CIPHER_CCMP)
1033981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                encr_mode = os802_11Encryption3Enabled;
1034981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else if (pCmdInterpret->wai.iw_auth_cipher_group & IW_AUTH_CIPHER_TKIP)
1035981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                encr_mode = os802_11Encryption2Enabled;
1036981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
1037981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                encr_mode = os802_11EncryptionDisabled;
1038981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1039981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (encr_mode == os802_11EncryptionDisabled)
1040981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->data.flags |= IW_ENCODE_OPEN;
1041981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
1042981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->data.flags |= IW_ENCODE_RESTRICTED;
1043981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1044981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            cmdObj->return_code = WEXT_OK;
1045981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1046981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1047981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1048981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1049981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Set Authentication */
1050981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWAUTH:
1051023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        res = TI_OK;
1052981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        switch (wrqu->param.flags & IW_AUTH_INDEX)
1053981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1054981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case IW_AUTH_WPA_VERSION:
1055981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pCmdInterpret->wai.iw_auth_wpa_version = wrqu->param.value;
1056981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
1057981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case IW_AUTH_CIPHER_PAIRWISE:
1058981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pCmdInterpret->wai.iw_auth_cipher_pairwise = wrqu->param.value;
1059981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
1060981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case IW_AUTH_CIPHER_GROUP:
1061981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pCmdInterpret->wai.iw_auth_cipher_group = wrqu->param.value;
1062981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
1063981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case IW_AUTH_KEY_MGMT:
1064981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pCmdInterpret->wai.iw_auth_key_mgmt = wrqu->param.value;
1065981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
1066981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case IW_AUTH_80211_AUTH_ALG:
1067981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pCmdInterpret->wai.iw_auth_80211_auth_alg = wrqu->param.value;
1068981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
1069981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case IW_AUTH_WPA_ENABLED:
1070981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
1071981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case IW_AUTH_TKIP_COUNTERMEASURES:
1072981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
1073981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case IW_AUTH_DROP_UNENCRYPTED:
1074981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
1075981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1076981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
1077981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case IW_AUTH_PRIVACY_INVOKED:
1078981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            break;
1079981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        default:
1080023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = -EOPNOTSUPP;
1081981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1082981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1083981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1084981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Get Authentication */
1085981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCGIWAUTH:
1086023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        res = TI_OK;
1087981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1088981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            switch (wrqu->param.flags & IW_AUTH_INDEX)
1089981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1090981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_AUTH_WPA_VERSION:
1091981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->param.value = pCmdInterpret->wai.iw_auth_wpa_version;
1092981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
1093981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_AUTH_CIPHER_PAIRWISE:
1094981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->param.value = pCmdInterpret->wai.iw_auth_cipher_pairwise;
1095981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
1096981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_AUTH_CIPHER_GROUP:
1097981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->param.value = pCmdInterpret->wai.iw_auth_cipher_group;
1098981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
1099981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_AUTH_KEY_MGMT:
1100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->param.value = pCmdInterpret->wai.iw_auth_key_mgmt;
1101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
1102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_AUTH_80211_AUTH_ALG:
1103981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wrqu->param.value = pCmdInterpret->wai.iw_auth_80211_auth_alg;
1104981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
1105981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            default:
1106023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = -EOPNOTSUPP;
1107981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1108981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1109981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1110981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1111981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* set encoding token & mode */
1112981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWENCODEEXT:
1113981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            struct iw_encode_ext *ext = (struct iw_encode_ext *)cmdObj->buffer2;
1115653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            TI_UINT8 *addr;
1116981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TI_UINT8 temp[32];
1117981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            addr = ext->addr.sa_data;
1119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /*
1121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_printf ("\next->address = %02x:%02x:%02x:%02x:%02x:%02x \n",addr[0],addr[1],addr[2],addr[3],addr[4],addr[5]);
1122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_printf ("ext->alg = 0x%x\n",ext->alg);
1123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_printf ("ext->ext_flags = 0x%x\n",ext->ext_flags);
1124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_printf ("ext->key_len = 0x%x\n",ext->key_len);
1125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_printf ("ext->key_idx = 0x%x\n",(wrqu->encoding.flags & IW_ENCODE_INDEX));
1126023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
1127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_printf ("key = ");
1128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            for (i=0; i<ext->key_len; i++)
1129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_printf ("0x%02x:",ext->key[i]);
1131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1132023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            os_printf ("\n");
1133653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            */
1134981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1135023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            MAC_COPY (pParam->content.rsnOsKey.BSSID, addr);
1136981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1137023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.rsnOsKey.KeyLength = ext->key_len;
1138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1139023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.rsnOsKey.KeyIndex = wrqu->encoding.flags & IW_ENCODE_INDEX;
1140023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.rsnOsKey.KeyIndex -= 1;
1141981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1142981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
1143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1144023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.rsnOsKey.KeyIndex |= TIWLAN_KEY_FLAGS_TRANSMIT;
1145981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (addr[0]!=0xFF)
1148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1149023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.rsnOsKey.KeyIndex |= TIWLAN_KEY_FLAGS_PAIRWISE;
1150981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1151981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID)
1153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1154023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs, &pParam->content.rsnOsKey.KeyRSC, &ext->rx_seq, IW_ENCODE_SEQ_MAX_SIZE);
1155023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.rsnOsKey.KeyIndex |= TIWLAN_KEY_FLAGS_SET_KEY_RSC;
1156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1157981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1158981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* If key is TKIP - need to switch RX and TX MIC (to match driver API) */
1159981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (ext->alg == IW_ENCODE_ALG_TKIP)
1160981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1161981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs,(TI_UINT8*)(((TI_UINT8*)&temp)+24),(TI_UINT8*)(((TI_UINT8*)&ext->key)+16),8);
1162981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs,(TI_UINT8*)(((TI_UINT8*)&temp)+16),(TI_UINT8*)(((TI_UINT8*)&ext->key)+24),8);
1163981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs,&temp,&ext->key,16);
1164023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs, &pParam->content.rsnOsKey.KeyMaterial, &temp, ext->key_len);
1165981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            } else
1166981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1167023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs, &pParam->content.rsnOsKey.KeyMaterial, &ext->key, ext->key_len);
1168981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1169981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1170981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (ext->key_len == 0)
1171023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramType = RSN_REMOVE_KEY_PARAM;
1172981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
1173023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramType = RSN_ADD_KEY_PARAM;
1174981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1175023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch, pParam);
1176023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            CHECK_PENDING_RESULT(res,pParam)
1177981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1178981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1179981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1180981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1181981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* SIOCSIWPMKSA - PMKSA cache operation */
1182981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCSIWPMKSA:
1183981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1184981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            struct iw_pmksa *pmksa = (struct iw_pmksa *) cmdObj->buffer2;
1185981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1186981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            switch (pmksa->cmd)
1187981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1188981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_PMKSA_ADD:
1189023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramType = RSN_PMKID_LIST;
1190023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.rsnPMKIDList.BSSIDInfoCount = 1;
1191023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.rsnPMKIDList.Length = 2*sizeof(TI_UINT32) + MAC_ADDR_LEN + PMKID_VALUE_SIZE;
1192023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                MAC_COPY (pParam->content.rsnPMKIDList.osBSSIDInfo[0].BSSID, pmksa->bssid.sa_data);
1193023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memoryCopy(pCmdInterpret->hOs, &pParam->content.rsnPMKIDList.osBSSIDInfo[0].PMKID, pmksa->pmkid, IW_PMKID_LEN);
1194981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1195023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch, pParam);
1196023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                CHECK_PENDING_RESULT(res,pParam)
1197981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1198981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
1199981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_PMKSA_REMOVE:
1200981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* Not supported yet */
1201981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
1202981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            case IW_PMKSA_FLUSH:
1203023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramType = RSN_PMKID_LIST;
1204981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* By using info count=0, RSN knows to clear its tables */
1205981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* It's also possible to call rsn_resetPMKIDList directly, but cmdDispatcher should be the interface */
1206023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.rsnPMKIDList.BSSIDInfoCount = 0;
1207023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch, pParam);
1208023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                CHECK_PENDING_RESULT(res,pParam)
1209981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1210981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
1211981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            default:
1212981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                cmdObj->return_code = WEXT_NOT_SUPPORTED;
1213981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
1214981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1215981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1216981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1217981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1218981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1219981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SIOCIWFIRSTPRIV:
1220981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1221981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            ti_private_cmd_t *my_command = (ti_private_cmd_t *)cmdObj->param3;
1222981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1223981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /*
1224981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_printf ("cmd =  0x%x     flags = 0x%x\n",(unsigned int)my_command->cmd,(unsigned int)my_command->flags);
1225981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_printf ("in_buffer =  0x%x (len = %d)\n",my_command->in_buffer,(unsigned int)my_command->in_buffer_len);
1226981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_printf ("out_buffer =  0x%x (len = %d)\n",my_command->out_buffer,(unsigned int)my_command->out_buffer_len);
1227981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            */
1228023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
1229023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = my_command->cmd;
1230981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1231981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (IS_PARAM_ASYNC(my_command->cmd))
1232981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1233981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* os_printf ("Detected ASYNC command - setting CB \n"); */
1234023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.interogateCmdCBParams.hCb  =  (TI_HANDLE)pCmdInterpret;
1235023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.interogateCmdCBParams.fCb  =  (void*)cmdInterpret_ServiceCompleteCB;
1236023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->content.interogateCmdCBParams.pCb  =  my_command->out_buffer;
1237653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                if (my_command->out_buffer)
1238653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                {
1239653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                    /* the next copy is need for PLT commands */
1240653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                    os_memoryCopy(pCmdInterpret->hOs,  my_command->out_buffer, my_command->in_buffer, min(my_command->in_buffer_len,my_command->out_buffer_len));
1241653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                }
1242981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1243981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else if ((my_command->in_buffer) && (my_command->in_buffer_len))
1244981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1245981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /*
1246981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                this cmd doesnt have the structure allocated as part of the paramInfo_t structure.
1247981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                as a result we need to allocate the memory internally.
1248981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                */
1249981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                if(IS_ALLOC_NEEDED_PARAM(my_command->cmd))
1250981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
1251023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    *(void **)&pParam->content = os_memoryAlloc(pCmdInterpret->hOs, my_command->in_buffer_len);
1252023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    os_memoryCopy(pCmdInterpret->hOs, *(void **)&pParam->content, my_command->in_buffer, my_command->in_buffer_len);
1253981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                }
1254981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                else
1255023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    os_memoryCopy(pCmdInterpret->hOs,&pParam->content,my_command->in_buffer,my_command->in_buffer_len);
1256981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1257981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1258981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (my_command->flags & PRIVATE_CMD_SET_FLAG)
1259981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1260981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* os_printf ("Calling setParam\n"); */
1261023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramLength = my_command->in_buffer_len;
1262023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = cmdDispatch_SetParam (pCmdInterpret->hCmdDispatch,pParam);
1263023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            }
1264981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else if (my_command->flags & PRIVATE_CMD_GET_FLAG)
1265981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1266981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* os_printf ("Calling getParam\n"); */
1267023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramLength = my_command->out_buffer_len;
1268023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = cmdDispatch_GetParam (pCmdInterpret->hCmdDispatch,pParam);
1269981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                if(res == EXTERNAL_GET_PARAM_DENIED)
1270981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
1271981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    cmdObj->return_code  = WEXT_INVALID_PARAMETER;
1272023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    goto cmd_end;
1273981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                }
1274981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1275023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                /*
1276023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                this is for cmd that want to check the size of memory that they need to
1277981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                allocate for the actual data.
1278981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                */
1279023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                if(pParam->paramLength && (my_command->out_buffer_len == 0))
1280981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
1281023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    my_command->out_buffer_len = pParam->paramLength;
1282981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                }
1283981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1284981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
1285981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1286981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                res = TI_NOK;
1287981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1288981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1289981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (res == TI_OK)
1290981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1291981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                if(IS_PARAM_ASYNC(my_command->cmd))
1292981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
1293981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    pCmdInterpret->pAsyncCmd = cmdObj; /* Save command handle for completion CB */
1294981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    res = COMMAND_PENDING;
1295981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                }
1296981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                else
1297981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
1298981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    if ((my_command->out_buffer) && (my_command->out_buffer_len))
1299981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    {
1300981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        if(IS_ALLOC_NEEDED_PARAM(my_command->cmd))
1301981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        {
1302023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                            os_memoryCopy(pCmdInterpret->hOs,my_command->out_buffer,*(void **)&pParam->content,my_command->out_buffer_len);
1303981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        }
1304981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        else
1305981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        {
1306023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                            os_memoryCopy(pCmdInterpret->hOs,my_command->out_buffer,&pParam->content,my_command->out_buffer_len);
1307023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                        }
1308023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    }
1309981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                }
1310981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1311981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1312981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* need to free the allocated memory */
1313981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if(IS_ALLOC_NEEDED_PARAM(my_command->cmd))
1314981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1315023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memoryFree(pCmdInterpret->hOs, *(void **)&pParam->content, my_command->in_buffer_len);
1316981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1317981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1318981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1319981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1320981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1321981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    default:
1322981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1323981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1324981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1325981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1326981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (res == TI_OK)
1327981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1328981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        cmdObj->return_code = WEXT_OK;
1329981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1330023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidtcmd_end:
1331023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    os_memoryFree(pCmdInterpret->hOs, pParam, sizeof(paramInfo_t));
1332981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Return with return code */
1333981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return res;
1334981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1335981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1336981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1337981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1338981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1339981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* This routine is called by the command mailbox module to signal an ASYNC command has complete */
1340981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtint cmdInterpret_ServiceCompleteCB (TI_HANDLE hCmdInterpret, int status, void *buffer)
1341981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1342981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdInterpret_t *pCmdInterpret = (cmdInterpret_t *)hCmdInterpret;
1343981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1344981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pCmdInterpret->pAsyncCmd == NULL)
1345981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1346981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_printf ("cmdInterpret_ServiceCompleteCB: AsyncCmd is NULL!!\n");
1347981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
1348981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1349981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1350981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pCmdInterpret->pAsyncCmd->return_code = status;
1351981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1352981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pCmdInterpret->pAsyncCmd = NULL;
1353981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1354981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Call the Cmd module to complete command processing */
1355981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdHndlr_Complete (pCmdInterpret->hCmdHndlr);
1356981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1357981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Call commands handler to continue handling further commands if queued */
1358981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdHndlr_HandleCommands (pCmdInterpret->hCmdHndlr);
1359981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1360981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1361981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1362981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1363981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Register to receive events */
1364981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic int cmdInterpret_initEvents(TI_HANDLE hCmdInterpret)
1365981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1366981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdInterpret_t *pCmdInterpret = (cmdInterpret_t *)(hCmdInterpret);
1367981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    IPC_EVENT_PARAMS evParams;
1368981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    int i = 0;
1369981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1370981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    for (i=0; i<IPC_EVENT_MAX; i++)
1371981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
13725e861de5ad899e72ec6582efb27da588b7583775Dmitry Shmidt        evParams.uDeliveryType    = DELIVERY_PUSH;
13735e861de5ad899e72ec6582efb27da588b7583775Dmitry Shmidt        evParams.uProcessID       = 0;
13745e861de5ad899e72ec6582efb27da588b7583775Dmitry Shmidt        evParams.uEventID         = 0;
13755e861de5ad899e72ec6582efb27da588b7583775Dmitry Shmidt        evParams.hUserParam       = hCmdInterpret;
13765e861de5ad899e72ec6582efb27da588b7583775Dmitry Shmidt        evParams.pfEventCallback  = cmdInterpret_Event;
13775e861de5ad899e72ec6582efb27da588b7583775Dmitry Shmidt        evParams.uEventType       = i;
1378981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        EvHandlerRegisterEvent (pCmdInterpret->hEvHandler, (TI_UINT8*) &evParams, sizeof(IPC_EVENT_PARAMS));
13795e861de5ad899e72ec6582efb27da588b7583775Dmitry Shmidt        pCmdInterpret->hEvents[i] = evParams.uEventID;
1380981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1381981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1382981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1383981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1384981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1385981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1386981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Unregister events */
1387981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic int cmdInterpret_unregisterEvents(TI_HANDLE hCmdInterpret, TI_HANDLE hEvHandler)
1388981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1389981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdInterpret_t *pCmdInterpret = (cmdInterpret_t *)(hCmdInterpret);
1390981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    IPC_EVENT_PARAMS evParams;
1391981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    int i = 0;
1392981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_setDebugOutputToLogger(TI_FALSE);
1393981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1394981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    for (i=0; i<IPC_EVENT_MAX; i++)
1395981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1396981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        evParams.uEventType =  i;
1397981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        evParams.uEventID = pCmdInterpret->hEvents[i];
1398981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        EvHandlerUnRegisterEvent (pCmdInterpret->hEvHandler, &evParams);
1399981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1400981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1401981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1402981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1403981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1404981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1405981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Handle driver events and convert to WEXT format */
1406981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_INT32 cmdInterpret_Event(IPC_EV_DATA* pData)
1407981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1408981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    IPC_EVENT_PARAMS * pInParam =  (IPC_EVENT_PARAMS *)pData;
1409981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdInterpret_t *pCmdInterpret = (cmdInterpret_t *)(pInParam->hUserParam);
1410981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    OS_802_11_ASSOCIATION_INFORMATION  *assocInformation;
1411981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8 *requestIEs;
1412981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8 *responseIEs;
1413981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    union iwreq_data wrqu;
1414981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    char *memptr;
1415023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    int TotalLength, res = TI_OK;
1416653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#ifdef XCC_MODULE_INCLUDED
1417653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    cckm_assocInformation_t cckm_assoc;
1418653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    unsigned char beaconIE[MAX_BEACON_BODY_LENGTH];
1419653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    unsigned char Cckmstart[CCKM_START_EVENT_SIZE * 2];
1420653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    int i,len,n;
1421653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    OS_802_11_BSSID_EX *my_current;
1422653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#endif
1423981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* indicate to the OS */
1424981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_IndicateEvent (pCmdInterpret->hOs, pData);
1425981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1426023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
1427981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (pData->EvParams.uEventType)
1428981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1429981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case IPC_EVENT_ASSOCIATED:
1430981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1431023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            paramInfo_t *pParam;
1432023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
1433023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam = (paramInfo_t *)os_memoryAlloc(pCmdInterpret->hOs, sizeof(paramInfo_t));
1434023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            if (!pParam)
1435023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                return TI_NOK;
1436023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
1437981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Get Association information */
1438981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1439981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* first check if this is ADHOC or INFRA (to avoid retrieving ASSOC INFO for ADHOC)*/
1440981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1441023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = CTRL_DATA_CURRENT_BSS_TYPE_PARAM;
1442023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            cmdDispatch_GetParam(pCmdInterpret->hCmdDispatch, pParam);
1443023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            if (pParam->content.ctrlDataCurrentBssType == BSS_INFRASTRUCTURE)
1444981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1445981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1446981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* First get length of data */
1447023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramType   = ASSOC_ASSOCIATION_INFORMATION_PARAM;
1448023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                pParam->paramLength = 0;
1449023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = cmdDispatch_GetParam(pCmdInterpret->hCmdDispatch, pParam);
1450981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1451981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                if (res != TI_NOK)
1452981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
1453023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    TotalLength = sizeof(OS_802_11_ASSOCIATION_INFORMATION) + pParam->content.assocAssociationInformation.RequestIELength +
1454023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                                  pParam->content.assocAssociationInformation.ResponseIELength;
1455981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1456981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    memptr = os_memoryAlloc (pCmdInterpret->hOs, TotalLength);
1457981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1458981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    /* Get actual data */
1459981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1460023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    pParam->paramType   = ASSOC_ASSOCIATION_INFORMATION_PARAM;
1461023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    pParam->paramLength = TotalLength;
1462023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    cmdDispatch_GetParam(pCmdInterpret->hCmdDispatch, pParam);
1463981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1464023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    os_memoryCopy(pCmdInterpret->hOs, memptr, &pParam->content, TotalLength);
1465981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1466981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    assocInformation = (OS_802_11_ASSOCIATION_INFORMATION*)memptr;
1467981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    requestIEs = (TI_UINT8*)memptr + sizeof(OS_802_11_ASSOCIATION_INFORMATION);
1468981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1469981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    if (assocInformation->RequestIELength > 0)
1470981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    {
1471981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        os_memorySet (pCmdInterpret->hOs,&wrqu, 0, sizeof(wrqu));
1472981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        wrqu.data.length = assocInformation->RequestIELength;
1473981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        wireless_send_event(NETDEV(pCmdInterpret->hOs), IWEVASSOCREQIE, &wrqu, (char *)assocInformation->OffsetRequestIEs);
1474981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    }
1475981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1476981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    responseIEs = (char *)assocInformation->OffsetRequestIEs + assocInformation->RequestIELength;
1477981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1478981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    if (assocInformation->ResponseIELength > 0)
1479981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    {
1480981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        os_memorySet (pCmdInterpret->hOs,&wrqu, 0, sizeof(wrqu));
1481981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        wrqu.data.length = assocInformation->ResponseIELength;
1482981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        wireless_send_event(NETDEV(pCmdInterpret->hOs), IWEVASSOCRESPIE, &wrqu, (char *)responseIEs);
1483981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    }
1484981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1485981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    os_memoryFree (pCmdInterpret->hOs, memptr, TotalLength);
1486981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1487981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                }
1488981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1489981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1490653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#ifdef XCC_MODULE_INCLUDED
1491653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /*
1492653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt               the driver must provide BEACON IE for calculate MIC in case of fast roaming
1493653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt               the data is an ASCII NUL terminated string
1494653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            */
1495653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1496653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1497653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            my_current = os_memoryAlloc (pCmdInterpret->hOs,MAX_BEACON_BODY_LENGTH);
1498023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            if (!my_current) {
1499023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = TI_NOK;
1500023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                goto event_end;
1501023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            }
1502023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType   = SITE_MGR_GET_SELECTED_BSSID_INFO_EX;
1503023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->content.pSiteMgrSelectedSiteInfo = my_current;
1504023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramLength = MAX_BEACON_BODY_LENGTH;
1505023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            cmdDispatch_GetParam(pCmdInterpret->hCmdDispatch, pParam);
1506653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1507023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            len = pParam->content.pSiteMgrSelectedSiteInfo->IELength - BEACON_HEADER_FIX_SIZE;
1508653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1509653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            n = sprintf(beaconIE, "BEACONIE=");
1510653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            for (i = 0; i < len; i++)
1511653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            {
1512023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt              n += sprintf(beaconIE + n, "%02x", pParam->content.pSiteMgrSelectedSiteInfo->IEs[BEACON_HEADER_FIX_SIZE+i] & 0xff);
1513653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            }
1514653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1515653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            os_memorySet (pCmdInterpret->hOs,&wrqu, 0, sizeof(wrqu));
1516653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            wrqu.data.length = n;
1517653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            wireless_send_event(NETDEV(pCmdInterpret->hOs), IWEVCUSTOM, &wrqu, beaconIE);
1518653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            os_memoryFree(pCmdInterpret->hOs,my_current,MAX_BEACON_BODY_LENGTH);
1519653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1520653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1521653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /*
1522653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt              The driver should be sending the Association Resp IEs
1523653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt              This informs the supplicant of the IEs used in the association exchanged which are required to proceed with CCKM.
1524653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            */
1525653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1526653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1527023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType   = ASSOC_ASSOCIATION_RESP_PARAM;
1528023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramLength = sizeof(TAssocReqBuffer);
1529023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            cmdDispatch_GetParam(pCmdInterpret->hCmdDispatch, pParam);
1530653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1531653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            cckm_assoc.assocRespLen = Param.content.assocReqBuffer.bufferSize - ASSOC_RESP_FIXED_DATA_LEN ;
1532653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            cckm_assoc.assocRespBuffer = os_memoryAlloc (pCmdInterpret->hOs, cckm_assoc.assocRespLen);
1533023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            if (!cckm_assoc.assocRespBuffer) {
1534023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                res = TI_NOK;
1535023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                goto event_end;
1536023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            }
1537023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            memcpy(cckm_assoc.assocRespBuffer,(pParam->content.assocReqBuffer.buffer)+ASSOC_RESP_FIXED_DATA_LEN,cckm_assoc.assocRespLen);
1538653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            wrqu.data.length = cckm_assoc.assocRespLen;
1539653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            wireless_send_event(NETDEV(pCmdInterpret->hOs), IWEVASSOCRESPIE, &wrqu, (TI_UINT8*)cckm_assoc.assocRespBuffer);
1540653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            os_memoryFree(pCmdInterpret->hOs,cckm_assoc.assocRespBuffer,cckm_assoc.assocRespLen);
1541653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1542653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#endif
1543653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt           /* Send associated event (containing BSSID of AP) */
1544981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1545981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_memorySet (pCmdInterpret->hOs,&wrqu, 0, sizeof(wrqu));
1546023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            pParam->paramType = SITE_MGR_CURRENT_BSSID_PARAM;
1547023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            cmdDispatch_GetParam ( pCmdInterpret->hCmdDispatch, pParam );
1548023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            MAC_COPY (wrqu.ap_addr.sa_data, pParam->content.siteMgrDesiredBSSID);
1549981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1550981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            wireless_send_event(NETDEV(pCmdInterpret->hOs), SIOCGIWAP, &wrqu, NULL);
1551023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt#ifdef XCC_MODULE_INCLUDED
1552023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidtevent_end:
1553023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt#endif
1554023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            os_memoryFree(pCmdInterpret->hOs, pParam, sizeof(paramInfo_t));
1555981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1556981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1557981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case IPC_EVENT_DISASSOCIATED:
1558981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1559981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_memorySet (pCmdInterpret->hOs,wrqu.ap_addr.sa_data, 0, ETH_ALEN);
1560981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1561981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        wireless_send_event(NETDEV(pCmdInterpret->hOs), SIOCGIWAP, &wrqu, NULL);
1562981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1563981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_memorySet (pCmdInterpret->hOs,&wrqu, 0, sizeof(wrqu));
1564981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        wrqu.data.length = sizeof(IPC_EV_DATA);
1565653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        wireless_send_event(NETDEV(pCmdInterpret->hOs), IWEVCUSTOM, &wrqu, (TI_UINT8 *)pData);
1566981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1567981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1568981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1569981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case IPC_EVENT_SCAN_COMPLETE:
1570653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        {
1571023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            TI_UINT8 *buf;
1572023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            wrqu.data.length = 0;
1573023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            wrqu.data.flags = 0;
1574023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            buf = pData->uBuffer;
1575023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
1576023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            if (*(TI_UINT32*)buf == SCAN_STATUS_COMPLETE)
1577023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                wireless_send_event(NETDEV(pCmdInterpret->hOs), SIOCGIWSCAN, &wrqu, NULL);
1578023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            else
1579023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            {
1580653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                if (*(TI_UINT32*)buf == SCAN_STATUS_STOPPED)          // scan is stopped successfully
1581023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    pData->EvParams.uEventType = IPC_EVENT_SCAN_STOPPED;
1582653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                else if (*(TI_UINT32*)buf == SCAN_STATUS_FAILED)          // scan is stopped successfully
1583023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    pData->EvParams.uEventType = IPC_EVENT_SCAN_FAILED;
1584023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                else
1585023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                    break;
1586023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
1587023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                os_memorySet (pCmdInterpret->hOs,&wrqu, 0, sizeof(wrqu));
1588023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                wrqu.data.length = sizeof(IPC_EV_DATA);
1589023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt                wireless_send_event(NETDEV(pCmdInterpret->hOs), IWEVCUSTOM, &wrqu, (u8 *)pData);
1590023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt            }
1591023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        }
1592981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1593981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1594981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case IPC_EVENT_MEDIA_SPECIFIC:
1595981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1596981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TI_UINT8 *buf;
1597981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            OS_802_11_AUTHENTICATION_REQUEST *request;
1598981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            struct iw_michaelmicfailure ev;
1599981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            struct iw_pmkid_cand pcand;
1600981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1601981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            buf = pData->uBuffer;
1602981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1603981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (*(TI_UINT32*)buf == os802_11StatusType_Authentication)
1604981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1605981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                request = (OS_802_11_AUTHENTICATION_REQUEST *) (buf + sizeof(TI_UINT32));
1606981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                if ( request->Flags == OS_802_11_REQUEST_PAIRWISE_ERROR || request->Flags == OS_802_11_REQUEST_GROUP_ERROR)
1607981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
1608981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    os_printf ("MIC failure detected\n");
1609981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1610981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    os_memorySet (pCmdInterpret->hOs,&ev, 0, sizeof(ev));
1611981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1612981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    ev.flags = 0 & IW_MICFAILURE_KEY_ID;
1613981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1614981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    if (request->Flags == OS_802_11_REQUEST_GROUP_ERROR)
1615981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        ev.flags |= IW_MICFAILURE_GROUP;
1616981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    else
1617981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                        ev.flags |= IW_MICFAILURE_PAIRWISE;
1618981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1619981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    ev.src_addr.sa_family = ARPHRD_ETHER;
1620981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    MAC_COPY (ev.src_addr.sa_data, request->BSSID);
1621981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    os_memorySet (pCmdInterpret->hOs,&wrqu, 0, sizeof(wrqu));
1622981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    wrqu.data.length = sizeof(ev);
1623981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    wireless_send_event(NETDEV(pCmdInterpret->hOs), IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
1624981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                }
1625981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1626981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            } else if (*(TI_UINT32*)buf == os802_11StatusType_PMKID_CandidateList)
1627981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1628981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                OS_802_11_PMKID_CANDIDATELIST  *pCandList = (OS_802_11_PMKID_CANDIDATELIST *) (buf + sizeof(TI_UINT32));
1629981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                int i;
1630981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1631981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_printf ("Preauthentication list (%d entries)!\n",pCandList->NumCandidates);
1632981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1633981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                for (i=0; i<pCandList->NumCandidates; i++)
1634981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
1635981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    os_memorySet (pCmdInterpret->hOs,&pcand, 0, sizeof(pcand));
1636981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    pcand.flags |= IW_PMKID_CAND_PREAUTH;
1637981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1638981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    pcand.index = i;
1639981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1640981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    MAC_COPY (pcand.bssid.sa_data, pCandList->CandidateList[i].BSSID);
1641981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1642981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    os_memorySet (pCmdInterpret->hOs,&wrqu, 0, sizeof(wrqu));
1643981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1644981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    wrqu.data.length = sizeof(pcand);
1645981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1646981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    wireless_send_event(NETDEV(pCmdInterpret->hOs), IWEVPMKIDCAND,
1647653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                                        &wrqu, (TI_UINT8 *)&pcand);
1648981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                }
1649981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1650981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1651981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1652981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1653981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1654981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1655653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#ifdef XCC_MODULE_INCLUDED
1656653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    case IPC_EVENT_CCKM_START:
1657653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1658653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        n = sprintf(Cckmstart, "CCKM-Start=");
1659653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        for (i = 0; i < 14; i++)
1660653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        {
1661653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt          n += sprintf(Cckmstart + n, "%02x", pData->uBuffer[i] & 0xff);
1662653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        }
1663653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1664653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        os_memorySet (pCmdInterpret->hOs,&wrqu, 0, sizeof(wrqu));
1665653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        wrqu.data.length = n;
1666653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        wireless_send_event(NETDEV(pCmdInterpret->hOs), IWEVCUSTOM, &wrqu, Cckmstart);
1667653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1668653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        break;
1669653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#endif
1670981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1671981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    default:
1672981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Other event? probably private and does not need interface-specific conversion */
1673981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Send as "custom" event */
1674981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1675981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_memorySet (pCmdInterpret->hOs,&wrqu, 0, sizeof(wrqu));
1676981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            wrqu.data.length = sizeof(IPC_EV_DATA);
1677653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            wireless_send_event(NETDEV(pCmdInterpret->hOs), IWEVCUSTOM, &wrqu, (TI_UINT8 *)pData);
1678981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1679023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
1680981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1681981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1682981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1683023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    return res;
1684981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1685981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1686981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1687981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Configure driver authentication and security by converting from WEXT interface to driver (OID-like) settings */
1688981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic int cmdInterpret_setSecurityParams (TI_HANDLE hCmdInterpret)
1689981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1690981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdInterpret_t *pCmdInterpret = (cmdInterpret_t *)hCmdInterpret;
1691023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    paramInfo_t *pParam;
1692981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    int auth_mode, encr_mode;
1693023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt
1694981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*
1695981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        printk ("wpa_version=0x%x auth_alg=0x%x key_mgmt=0x%x "
1696981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt           "cipher_pairwise=0x%x cipher_group=0x%x\n",
1697981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt           pCmdInterpret->wai.iw_auth_wpa_version, pCmdInterpret->wai.iw_auth_80211_auth_alg,
1698981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt           pCmdInterpret->wai.iw_auth_key_mgmt, pCmdInterpret->wai.iw_auth_cipher_pairwise,
1699981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt           pCmdInterpret->wai.iw_auth_cipher_group);
1700981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    */
1701023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    pParam = (paramInfo_t *)os_memoryAlloc(pCmdInterpret->hOs, sizeof(paramInfo_t));
1702023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    if (!pParam)
1703023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt        return TI_NOK;
1704981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pCmdInterpret->wai.iw_auth_wpa_version & IW_AUTH_WPA_VERSION_WPA2)
1705981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1706981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pCmdInterpret->wai.iw_auth_key_mgmt & IW_AUTH_KEY_MGMT_802_1X)
1707981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            auth_mode = os802_11AuthModeWPA2;
1708981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
1709981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            auth_mode = os802_11AuthModeWPA2PSK;
1710981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    } else if (pCmdInterpret->wai.iw_auth_wpa_version & IW_AUTH_WPA_VERSION_WPA)
1711981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1712981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pCmdInterpret->wai.iw_auth_key_mgmt & IW_AUTH_KEY_MGMT_802_1X)
1713981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            auth_mode = os802_11AuthModeWPA;
1714981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else if (pCmdInterpret->wai.iw_auth_key_mgmt & IW_AUTH_KEY_MGMT_PSK)
1715981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            auth_mode = os802_11AuthModeWPAPSK;
1716981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
1717981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            auth_mode = os802_11AuthModeWPANone;
1718981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    } else if (pCmdInterpret->wai.iw_auth_80211_auth_alg & IW_AUTH_ALG_SHARED_KEY)
1719981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1720981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pCmdInterpret->wai.iw_auth_80211_auth_alg & IW_AUTH_ALG_OPEN_SYSTEM)
1721981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            auth_mode = os802_11AuthModeAutoSwitch;
1722981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
1723981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            auth_mode = os802_11AuthModeShared;
1724981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    } else
1725981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        auth_mode = os802_11AuthModeOpen;
1726981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1727981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pCmdInterpret->wai.iw_auth_cipher_pairwise & IW_AUTH_CIPHER_CCMP)
1728981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        encr_mode = os802_11Encryption3Enabled;
1729981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else if (pCmdInterpret->wai.iw_auth_cipher_pairwise & IW_AUTH_CIPHER_TKIP)
1730981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        encr_mode = os802_11Encryption2Enabled;
1731981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else if (pCmdInterpret->wai.iw_auth_cipher_pairwise &
1732981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt             (IW_AUTH_CIPHER_WEP40 | IW_AUTH_CIPHER_WEP104))
1733981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        encr_mode = os802_11Encryption1Enabled;
1734981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else if (pCmdInterpret->wai.iw_auth_cipher_group & IW_AUTH_CIPHER_CCMP)
1735981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        encr_mode = os802_11Encryption3Enabled;
1736981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else if (pCmdInterpret->wai.iw_auth_cipher_group & IW_AUTH_CIPHER_TKIP)
1737981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        encr_mode = os802_11Encryption2Enabled;
1738981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
1739981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        encr_mode = os802_11EncryptionDisabled;
1740981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1741981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (encr_mode)
1742981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1743981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case os802_11WEPDisabled:
1744981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        encr_mode = TWD_CIPHER_NONE;
1745981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1746981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case os802_11WEPEnabled:
1747981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        encr_mode = TWD_CIPHER_WEP;
1748981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1749981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case os802_11Encryption2Enabled:
1750981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        encr_mode = TWD_CIPHER_TKIP;
1751981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1752981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case os802_11Encryption3Enabled:
1753981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        encr_mode = TWD_CIPHER_AES_CCMP;
1754981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1755981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    default:
1756981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1757981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1758981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1759023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    pParam->paramType = RSN_EXT_AUTHENTICATION_MODE;
1760023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    pParam->content.rsnExtAuthneticationMode = auth_mode;
1761023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    cmdDispatch_SetParam ( pCmdInterpret->hCmdDispatch, pParam );
1762981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1763023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    pParam->paramType = RSN_ENCRYPTION_STATUS_PARAM;
1764023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    pParam->content.rsnEncryptionStatus = encr_mode;
1765023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    cmdDispatch_SetParam ( pCmdInterpret->hCmdDispatch, pParam );
1766023547f11f3d7c84ab64acaab9b9e821f8c528e7Dmitry Shmidt    os_memoryFree(pCmdInterpret->hOs, pParam, sizeof(paramInfo_t));
1767981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1768981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1769981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1770981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1771981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid *cmdInterpret_GetStat (TI_HANDLE hCmdInterpret)
1772981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1773981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdInterpret_t *pCmdInterpret = (cmdInterpret_t *)hCmdInterpret;
1774981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1775981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Check if driver is initialized - If not - return empty statistics */
1776981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (hCmdInterpret)
1777981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1778981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCmdInterpret->wstats.status = 0;
1779981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCmdInterpret->wstats.miss.beacon = 0;
1780981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCmdInterpret->wstats.discard.retries = 0;      /* Tx : Max MAC retries num reached */
1781981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCmdInterpret->wstats.discard.nwid = 0;         /* Rx : Wrong nwid/essid */
1782981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCmdInterpret->wstats.discard.code = 0;         /* Rx : Unable to code/decode (WEP) */
1783981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCmdInterpret->wstats.discard.fragment = 0;     /* Rx : Can't perform MAC reassembly */
1784981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCmdInterpret->wstats.discard.misc = 0;     /* Others cases */
1785981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1786981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCmdInterpret->wstats.qual.qual = 0;
1787981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCmdInterpret->wstats.qual.level = 0;
1788981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCmdInterpret->wstats.qual.noise = 0;
1789981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pCmdInterpret->wstats.qual.updated = IW_QUAL_NOISE_INVALID | IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
1790981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return &pCmdInterpret->wstats;
1791981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1792981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return (void *)NULL;
1793981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1794