1981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
2981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * ScanCncnApp.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/** \file  ScanCncnApp.c
35981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \brief Scan concentrator application scan module implementation
36981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
37981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \see   ScanCncn.h, ScanCncn.c
38981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
39981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
40981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
41981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define __FILE_ID__  FILE_ID_77
42981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "ScanCncnPrivate.h"
43981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "ScanCncn.h"
44981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "ScanCncnOsSm.h"
45981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "EvHandler.h"
46981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "report.h"
47981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "GenSM.h"
48981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "scanResultTable.h"
49981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "sme.h"
50653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#include "smeApi.h"
51981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
52981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
53981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanCncnApp_SetParam
54981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Parses and executes a set param command
55981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
56981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Parses and executes a set param command (start/stop one-shot/periodic/OS scan)
57981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
58981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanCncn - handle to the scan concentrator object
59981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pParam - the param to set
60981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return operation status (OK / NOK / PARAM_NOT_SUPPORTED)
61981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanCncnApp_GetParam
62981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
63981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS scanCncnApp_SetParam (TI_HANDLE hScanCncn, paramInfo_t *pParam)
64981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
65981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanCncn   *pScanCncn = (TScanCncn*)hScanCncn;
66981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32   uCurrentTimeStamp;
67981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
68981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnApp_SetParam: recevived request of type 0x%x\n", pParam->paramType);
69981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
70981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (pParam->paramType)
71981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
72981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CNCN_START_APP_SCAN:
73981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
74981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* verify that scan is not currently running */
75981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pScanCncn->eCurrentRunningAppScanClient != SCAN_SCC_NO_CLIENT)
76981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
77acd89e8f547322db23ab0f7c3775082654c4b13bDmitry Shmidt            TRACE1(pScanCncn->hReport, REPORT_SEVERITY_WARNING, "scanCncnApp_SetParam: trying to start app one-shot scan when client %d is currently running!\n", pScanCncn->eCurrentRunningAppScanClient);
78981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Scan was not started successfully, send a scan complete event to the user */
79981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return TI_NOK;
80981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
81981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
82981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* set one-shot scan as running app scan client */
83981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_APP_ONE_SHOT;
84981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
85981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* start the scan */
86981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (SCAN_CRS_SCAN_RUNNING !=
87981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            scanCncn_Start1ShotScan (hScanCncn, SCAN_SCC_APP_ONE_SHOT, pParam->content.pScanParams))
88981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
89981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Scan was not started successfully, mark that no app scan is running */
90981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
91981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return TI_NOK;
92981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
93981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
94981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
95981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CNCN_STOP_APP_SCAN:
96981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* verify that scan is currently running */
97981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pScanCncn->eCurrentRunningAppScanClient != SCAN_SCC_NO_CLIENT)
98981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
99981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            scanCncn_StopScan (hScanCncn, SCAN_SCC_APP_ONE_SHOT);
100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
103981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CNCN_START_PERIODIC_SCAN:
104981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* verify that scan is not currently running */
105981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (SCAN_SCC_NO_CLIENT != pScanCncn->eCurrentRunningAppScanClient)
106981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
107acd89e8f547322db23ab0f7c3775082654c4b13bDmitry Shmidt            TRACE1(pScanCncn->hReport, REPORT_SEVERITY_WARNING, "scanCncnApp_SetParam: trying to start app periodic scan when client %d is currently running!\n", pScanCncn->eCurrentRunningAppScanClient);
108981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Scan was not started successfully, send a scan complete event to the user */
109981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return TI_NOK;
110981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
111981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
112981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* set one-shot scan as running app scan client */
113981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_APP_PERIODIC;
114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
115981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* start the scan */
116981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (SCAN_CRS_SCAN_RUNNING !=
117981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            scanCncn_StartPeriodicScan (hScanCncn, SCAN_SCC_APP_PERIODIC, pParam->content.pPeriodicScanParams))
118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE0(pScanCncn->hReport, REPORT_SEVERITY_CONSOLE , "Scan was not started. Verify scan parametrs or SME mode\n");
120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            WLAN_OS_REPORT (("Scan was not started. Verify scan parametrs or SME mode\n"));
121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Scan was not started successfully, mark that no app scan is running */
123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return TI_NOK;
125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
126981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CNCN_STOP_PERIODIC_SCAN:
129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* verify that scan is currently running */
130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pScanCncn->eCurrentRunningAppScanClient != SCAN_SCC_NO_CLIENT)
131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
132981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            scanCncn_StopPeriodicScan (hScanCncn, SCAN_SCC_APP_PERIODIC);
133981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
134981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
135981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
136981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CNCN_BSSID_LIST_SCAN_PARAM:
137981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* check if OID scans are enabled in the registry */
138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (0 == pScanCncn->tInitParams.uMinimumDurationBetweenOsScans)
139981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
140981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE0(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnApp_SetParam: received OS scan request when OS scans are disabled, quitting...\n");
141653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            return TI_NOK;
142981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
144981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* check if the last OID scan didn't start at a shorter duration than the configured minimum */
145981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        uCurrentTimeStamp = os_timeStampMs (pScanCncn->hOS);
146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if ( (uCurrentTimeStamp - pScanCncn->uOSScanLastTimeStamp) <
147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt             (pScanCncn->tInitParams.uMinimumDurationBetweenOsScans * 1000) ) /*converted to ms */
148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
149981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE3(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnApp_SetParam: last OID scan performed at: %d, now is: %d, min duration is: %d, too early for another scan!\n", pScanCncn->uOSScanLastTimeStamp, uCurrentTimeStamp, pScanCncn->tInitParams.uMinimumDurationBetweenOsScans);
150653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            return TI_NOK;
151981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* check that no other scan is currently running */
154981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (SCAN_SCC_NO_CLIENT != pScanCncn->eCurrentRunningAppScanClient)
155981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE1(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnApp_SetParam: received OS scan request when client %d is currently running!\n", pScanCncn->eCurrentRunningAppScanClient);
157653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            return TI_NOK;
158981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
159981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
160981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* set one-shot scan as running app scan client */
161981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_APP_ONE_SHOT;
162981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
163981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* mark that an OID scan process has started */
164981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pScanCncn->bOSScanRunning = TI_TRUE;
165981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pScanCncn->uOSScanLastTimeStamp = uCurrentTimeStamp;
166981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnApp_SetParam: starting OID scan process...\n");
167981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
168981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if(0 != pParam->content.tScanDesiredSSID.len)
169981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
170981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pScanCncn->tOsScanParams.desiredSsid.len = pParam->content.tScanDesiredSSID.len;
171981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_memoryCopy(pScanCncn->hOS, pScanCncn->tOsScanParams.desiredSsid.str, pParam->content.tScanDesiredSSID.str, pParam->content.tScanDesiredSSID.len);
172981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
173981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
174981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
175981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pScanCncn->tOsScanParams.desiredSsid.len = 0;
176981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pScanCncn->tOsScanParams.desiredSsid.str[ 0 ] = '\0'; /* broadcast scan */
177981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
178981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
179981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* and actually start the scan */
180981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_START_SCAN, hScanCncn);
181653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
182981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
183981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
184981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    default:
185981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnApp_SetParam: unrecognized param type :%d\n", pParam->paramType);
186981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return PARAM_NOT_SUPPORTED;
187981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
188981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
189981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
190981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
191981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
192981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
193981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanCncnApp_GetParam
194981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Parses and executes a get param command
195981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
196981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Parses and executes a get param command (get BSSID list)
197981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
198981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanCncn - handle to the scan concentrator object
199981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pParam - the param to get
200981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return operation status (OK / NOK / PARAM_NOT_SUPPORTED)
201981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanCncnApp_SetParam
202981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
203981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS scanCncnApp_GetParam (TI_HANDLE hScanCncn, paramInfo_t *pParam)
204981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
205981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanCncn   *pScanCncn = (TScanCncn*)hScanCncn;
206981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
207981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnApp_GetParam: received request of type %d\n", pParam->paramType);
208981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
209981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (pParam->paramType)
210981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
211981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CNCN_BSSID_LIST_SIZE_PARAM:
212981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* retrieves the size to allocate for the app scan result taBle BBSID list (see next code) */
213981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pParam->paramLength = sizeof(TI_UINT32);
214981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pParam->content.uBssidListSize =
215981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            scanResultTable_CalculateBssidListSize (pScanCncn->hScanResultTable, TI_FALSE);
216981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
217981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
218981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CNCN_BSSID_LIST_PARAM:
219981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* retrieve the app scan result table */
220981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return scanResultTable_GetBssidList (pScanCncn->hScanResultTable, pParam->content.pBssidList,
221981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                             &pParam->paramLength, TI_FALSE);
222981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
223981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
224981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    default:
225981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnApp_GetParam: unrecognized param type :%d\n", pParam->paramType);
226981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return PARAM_NOT_SUPPORTED;
227981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
228981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
229981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
230981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
231981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
232981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
233981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanCncn_AppScanResultCB
234981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Scan result callback for application scan
235981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
236981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Scan result callback for application scan
237981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
238981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanCncn - handle to the scan concentrator object
239981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  status - the scan result status (scan complete, result received etc.)
240981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  frameInfo - a pointer to the structure holding all frame related info (in case a frame was received)
241981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  SPSStatus - a bitmap indicating on which channels scan was attempted (valid for SPS scan only!)
242981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return None
243981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
244981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid scanCncn_AppScanResultCB (TI_HANDLE hScanCncn, EScanCncnResultStatus status,
245981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                               TScanFrameInfo* frameInfo, TI_UINT16 SPSStatus)
246981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
247981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanCncn   *pScanCncn = (TScanCncn*)hScanCncn;
248653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    TI_UINT32	statusData;
249981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
250981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* forward all data to SME */
251981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    sme_AppScanResult (pScanCncn->hSme, status, frameInfo);
252981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
253981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (status)
254981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
255981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CRS_RECEIVED_FRAME:
256981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Save the result in the app scan result table */
257653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        if (TI_OK != scanResultTable_UpdateEntry (pScanCncn->hScanResultTable, frameInfo->bssId, frameInfo))
258653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt		{
259653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt	        TRACE0(pScanCncn->hReport, REPORT_SEVERITY_WARNING , "scanCncn_AppScanResultCB, scanResultTable_UpdateEntry() failed\n");
260653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt		}
261653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt		break;
262981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
263981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CRS_SCAN_COMPLETE_OK:
264653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
265653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncn_AppScanResultCB, received scan complete with status :%d\n", status);
266653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
267653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        /* if OS scan is running */
268653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        if (TI_TRUE == pScanCncn->bOSScanRunning)
269653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        {
270653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
271653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
272653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        }
273653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        else
274653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        {
275653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /* move the scan result table to stable state, clear it if no results were received */
276653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            scanResultTable_SetStableState (pScanCncn->hScanResultTable);
277653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
278653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /* mark that no app scan is running */
279653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
280653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /*
281653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             * The scan was finished, send a scan complete event to the user
282653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             * (regardless of why the scan was completed)
283653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             */
284653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            statusData = SCAN_STATUS_COMPLETE;	/* Completed status */
285653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt			EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&statusData, sizeof(TI_UINT32));
286653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        }
287653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        break;
288653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
289981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CRS_SCAN_STOPPED:
290653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
291653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncn_AppScanResultCB, received scan complete with status :%d\n", status);
292653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
293653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        /* if OS scan is running */
294653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        if (TI_TRUE == pScanCncn->bOSScanRunning)
295653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        {
296653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
297653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
298653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        }
299653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        else
300653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        {
301653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /* move the scan result table to stable state, clear it if no results were received */
302653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            scanResultTable_SetStableState (pScanCncn->hScanResultTable);
303653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
304653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /* mark that no app scan is running */
305653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
306653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /*
307653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             * The scan was finished, send a scan complete event to the user
308653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             * (regardless of why the scan was completed)
309653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             */
310653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            statusData = SCAN_STATUS_STOPPED;	/* Stopped status */
311653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&statusData, sizeof(TI_UINT32));
312653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        }
313653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        break;
314653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
315653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    case SCAN_CRS_TSF_ERROR:
316981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CRS_SCAN_RUNNING:
317981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CRS_SCAN_FAILED:
318981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY:
319981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CRS_SCAN_ABORTED_FW_RESET:
320981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
321981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncn_AppScanResultCB, received scan complete with status :%d\n", status);
322981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
323981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* if OS scan is running */
324981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (TI_TRUE == pScanCncn->bOSScanRunning)
325981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
326981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
327981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
328981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
329981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
330981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
331981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* move the scan result table to stable state, clear it if no results were received */
332981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            scanResultTable_SetStableState (pScanCncn->hScanResultTable);
333981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
334981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* mark that no app scan is running */
335981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
336981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /*
337981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt             * The scan was finished, send a scan complete event to the user
338981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt             * (regardless of why the scan was completed)
339981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt             */
340653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            statusData = SCAN_STATUS_FAILED;		/* Failed status */
341653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&statusData, sizeof(TI_UINT32));
342981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
343981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
344981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
345981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SCAN_CRS_NUM_OF_RES_STATUS:
346981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    default:
347981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncn_AppScanResultCB, received erroneuos scan result with status :%d\n", status);
348981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
349981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
350981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
351981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
352