1/*
2 * ScanCncnOsSm.c
3 *
4 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 *  * Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *  * Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in
15 *    the documentation and/or other materials provided with the
16 *    distribution.
17 *  * Neither the name Texas Instruments nor the names of its
18 *    contributors may be used to endorse or promote products derived
19 *    from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file  ScanCncnOsSm.c
35 *  \brief Scan concentrator OS scan state machine implementation
36 *
37 *  \see   ScanCncnApp.c
38 */
39
40
41#define __FILE_ID__  FILE_ID_78
42#include "osTIType.h"
43#include "GenSM.h"
44#include "ScanCncnOsSm.h"
45#include "ScanCncn.h"
46#include "ScanCncnPrivate.h"
47#include "report.h"
48#include "osApi.h"
49#include "siteMgrApi.h"
50#include "regulatoryDomainApi.h"
51#include "scanResultTable.h"
52
53#define SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_G                       RATE_MASK_UNSPECIFIED  /* Let the FW select */
54#define SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_A                       RATE_MASK_UNSPECIFIED  /* Let the FW select */
55#define SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_G                     3
56#define SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_A                     3
57#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_G                   100000
58#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_A                   100000
59#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_G                    30000
60#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_A                    30000
61#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_G                   100000
62#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_A                   100000
63#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_G                    15000
64#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_A                    15000
65#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_G          SCAN_ET_COND_BEACON
66#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_A          SCAN_ET_COND_BEACON
67#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_G           SCAN_ET_COND_ANY_FRAME
68#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_A           SCAN_ET_COND_ANY_FRAME
69
70/* For WiFi  WPA OOB scenario, 4 APs need to be configure on the same channel */
71#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_G          4
72#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_A          4
73#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_G           4
74#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_A           4
75
76static void scanCncnOsSm_ActionStartGScan (TI_HANDLE hScanCncn);
77static void scanCncnOsSm_ActionStartAScan (TI_HANDLE hScanCncn);
78static void scanCncnOsSm_ActionCompleteScan (TI_HANDLE hScanCncn);
79static void scanCncnOsSm_ActionUnexpected (TI_HANDLE hScanCncn);
80TI_UINT32   scanCncnOsSm_FillAllAvailableChannels (TI_HANDLE hScanCncn, ERadioBand eBand, EScanType eScanType,
81                                                   TScanChannelEntry *pChannelArray, TI_UINT32 uMaxDwellTime,
82                                                   TI_UINT32 uMinChannelTime, EScanEtCondition eETCondition,
83                                                   TI_UINT8 uETFrameNumber);
84
85
86static TGenSM_actionCell tSmMatrix[ SCAN_CNCN_OS_SM_NUMBER_OF_STATES ][ SCAN_CNCN_OS_SM_NUMBER_OF_EVENTS ] =
87    {
88        { /* SCAN_CNCN_OS_SM_STATE_IDLE */
89            { SCAN_CNCN_OS_SM_STATE_SCAN_ON_G,  scanCncnOsSm_ActionStartGScan },    /* SCAN_CNCN_OS_SM_EVENT_START_SCAN */
90            { SCAN_CNCN_OS_SM_STATE_IDLE,       scanCncnOsSm_ActionUnexpected },    /* SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE */
91        },
92        { /* SCAN_CNCN_OS_SM_STATE_SCAN_ON_G */
93            { SCAN_CNCN_OS_SM_STATE_SCAN_ON_G,  scanCncnOsSm_ActionUnexpected },    /* SCAN_CNCN_OS_SM_EVENT_START_SCAN */
94            { SCAN_CNCN_OS_SM_STATE_SCAN_ON_A,  scanCncnOsSm_ActionStartAScan },    /* SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE */
95        },
96        { /* SCAN_CNCN_OS_SM_STATE_SCAN_ON_A */
97            { SCAN_CNCN_OS_SM_STATE_SCAN_ON_A,  scanCncnOsSm_ActionUnexpected },    /* SCAN_CNCN_OS_SM_EVENT_START_SCAN */
98            { SCAN_CNCN_OS_SM_STATE_IDLE,       scanCncnOsSm_ActionCompleteScan },  /* SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE */
99        }
100    };
101
102static TI_INT8  *uStateDescription[] =
103    {
104        "IDLE",
105        "SCAN_ON_G",
106        "SCAN_ON_A"
107    };
108
109static TI_INT8  *uEventDescription[] =
110    {
111        "START",
112        "SCAN_COMPLETE"
113    };
114
115/**
116 * \fn     scanCncnOsSm_Create
117 * \brief  Creates the OS scan state-machine
118 *
119 * creates the OS scan state-machine
120 *
121 * \param  hScanCncn - handle to the scan concentrator object
122 * \return Handle to the newly created OS san SM, NULL if an error occured
123 * \sa     scanCncnOsSm_Create, scanCncnOsSm_Destroy
124 */
125TI_HANDLE scanCncnOsSm_Create (TI_HANDLE hScanCncn)
126{
127    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
128
129    return genSM_Create (pScanCncn->hOS);
130}
131
132/**
133 * \fn     scanCncnOsSm_Init
134 * \brief  Initialize the OS scan state-machine
135 *
136 * Initialize the OS scan state-machine
137 *
138 * \param  hScanCncn - handle to the scan concentrator object
139 * \return None
140 * \sa     scanCncnOsSm_Create
141 */
142void scanCncnOsSm_Init (TI_HANDLE hScanCncn)
143{
144    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
145
146    /* initialize the state-machine */
147    genSM_Init (pScanCncn->hOSScanSm, pScanCncn->hReport);
148    genSM_SetDefaults (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_NUMBER_OF_STATES, SCAN_CNCN_OS_SM_NUMBER_OF_EVENTS,
149                       (TGenSM_matrix)tSmMatrix, SCAN_CNCN_OS_SM_STATE_IDLE, "OS scan SM", uStateDescription,
150                       uEventDescription, __FILE_ID__);
151}
152
153/**
154 * \fn     scanCncnOsSm_Destroy
155 * \brief  Destroys the OS scan state-machine
156 *
157 * Destroys the OS scan state-machine
158 *
159 * \param  hScanCncn - handle to the scan concentrator object
160 * \return None
161 * \sa     scanCncnOsSm_Create
162 */
163void scanCncnOsSm_Destroy (TI_HANDLE hScanCncn)
164{
165    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
166
167    genSM_Unload (pScanCncn->hOSScanSm);
168}
169
170/**
171 * \fn     scanCncnOsSm_ActionStartGScan
172 * \brief  Scan concentartor OS state machine start scan on G action function
173 *
174 * Scan concentartor OS state machine start scan on G action function.
175 * Starts a sacn on G using all allowed channels
176 *
177 * \param  hScanCncn - handle to the scan concentartor object
178 * \return None
179 */
180void scanCncnOsSm_ActionStartGScan (TI_HANDLE hScanCncn)
181{
182    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
183    paramInfo_t     tParam;
184    TI_UINT32       uValidChannelsCount;
185    TI_BOOL         bRegulatoryDomainEnabled;
186
187    /* if the STA is not configured for G band or dual band, send a scan complete event to the SM */
188    tParam.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
189    siteMgr_getParam (pScanCncn->hSiteManager, &tParam);
190    if ((DOT11_G_MODE != tParam.content.siteMgrDot11Mode) && (DOT11_DUAL_MODE != tParam.content.siteMgrDot11Mode))
191    {
192        TRACE0(pScanCncn->hReport , REPORT_SEVERITY_INFORMATION , "scanCncnOsSm_ActionStartGScan: STA does not work on 2.4 GHz, continuing to 5.0 GHz scan\n");
193        genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
194        return;
195    }
196
197    /* build scan command header */
198    pScanCncn->tOsScanParams.band = RADIO_BAND_2_4_GHZ;
199    pScanCncn->tOsScanParams.Tid = 255;
200
201    /* query the regulatory domain if 802.11d is in use */
202    tParam.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
203    regulatoryDomain_getParam (pScanCncn->hRegulatoryDomain, &tParam );
204    bRegulatoryDomainEnabled = tParam.content.regulatoryDomainEnabled;
205
206    /* Get country code status */
207    tParam.paramType          = REGULATORY_DOMAIN_IS_COUNTRY_FOUND;
208    tParam.content.eRadioBand = RADIO_BAND_2_4_GHZ;
209    regulatoryDomain_getParam (pScanCncn->hRegulatoryDomain, &tParam);
210
211    /* scan type is passive if 802.11d is enabled and country IE was not yet found, active otherwise */
212    if ((TI_TRUE == bRegulatoryDomainEnabled) && (TI_FALSE == tParam.content.bIsCountryFound) )
213    {
214		pScanCncn->tOsScanParams.scanType = SCAN_TYPE_TRIGGERED_PASSIVE;
215    }
216	/* All paramters in the func are hard coded, due to that we set to active if not passive */
217    else
218    {
219        pScanCncn->tOsScanParams.scanType = SCAN_TYPE_TRIGGERED_ACTIVE;
220        /* also set number and rate of probe requests */
221        pScanCncn->tOsScanParams.probeReqNumber = SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_G;
222        pScanCncn->tOsScanParams.probeRequestRate = SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_G;
223    }
224
225    /* add supported channels on G */
226    if (SCAN_TYPE_NORMAL_PASSIVE == pScanCncn->tOsScanParams.scanType )
227    {
228        uValidChannelsCount = scanCncnOsSm_FillAllAvailableChannels (hScanCncn, RADIO_BAND_2_4_GHZ,
229                                       SCAN_TYPE_NORMAL_PASSIVE, &(pScanCncn->tOsScanParams.channelEntry[0]),
230                                       SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_G,
231                                       SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_G,
232                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_G,
233                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_G);
234    }
235    else
236    {
237        uValidChannelsCount = scanCncnOsSm_FillAllAvailableChannels (hScanCncn, RADIO_BAND_2_4_GHZ,
238                                       SCAN_TYPE_NORMAL_ACTIVE, &(pScanCncn->tOsScanParams.channelEntry[0]),
239                                       SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_G,
240                                       SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_G,
241                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_G,
242                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_G);
243    }
244    pScanCncn->tOsScanParams.numOfChannels = uValidChannelsCount;
245
246    /* check that some channels are available */
247    if ( uValidChannelsCount > 0 )
248    {
249        EScanCncnResultStatus   eResult;
250
251        /* send command to scan concentrator APP SM */
252        eResult = scanCncn_Start1ShotScan (hScanCncn, SCAN_SCC_APP_ONE_SHOT, &(pScanCncn->tOsScanParams));
253
254        /* if scan failed, send scan complete event to the SM */
255        if (SCAN_CRS_SCAN_RUNNING != eResult)
256        {
257            TRACE0(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnOsSm_ActionStartGScan: scan failed on 2.4 GHz, continuing to 5.0 GHz scan\n");
258            genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
259        }
260    }
261    else
262    {
263        TRACE0(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnOsSm_ActionStartGScan: no valid cahnnels on 2.4 GHz, continuing to 5.0 GHz scan\n");
264        /* no channels to scan, send a scan complete event */
265        genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
266    }
267}
268
269/**
270 * \fn     scanCncnOsSm_ActionStartAScan
271 * \brief  Scan concentartor OS state machine start scan on A action function
272 *
273 * Scan concentartor OS state machine start scan on A action function.
274 * Starts a sacn on A using all allowed channels
275 *
276 * \param  hScanCncn - handle to the scan concentartor object
277 * \return None
278 */
279void scanCncnOsSm_ActionStartAScan (TI_HANDLE hScanCncn)
280{
281    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
282    paramInfo_t     tParam;
283    TI_UINT32       uValidChannelsCount;
284    TI_BOOL         bRegulatoryDomainEnabled;
285
286    /* if the STA is not configured for G band or dual band, send a scan complete event to the SM */
287    tParam.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
288    siteMgr_getParam (pScanCncn->hSiteManager, &tParam);
289    if ((DOT11_A_MODE != tParam.content.siteMgrDot11Mode) && (DOT11_DUAL_MODE != tParam.content.siteMgrDot11Mode))
290    {
291        TRACE0(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnOsSm_ActionStartAScan: STA does not work on 5.0 GHz, quitting\n");
292        genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
293        return;
294    }
295
296    /* build scan command header */
297    pScanCncn->tOsScanParams.band = RADIO_BAND_5_0_GHZ;
298    pScanCncn->tOsScanParams.Tid = 0;
299
300    /* query the regulatory domain if 802.11d is in use */
301    tParam.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
302    regulatoryDomain_getParam (pScanCncn->hRegulatoryDomain, &tParam );
303    bRegulatoryDomainEnabled = tParam.content.regulatoryDomainEnabled;
304
305    /* Get country code status */
306    tParam.paramType          = REGULATORY_DOMAIN_IS_COUNTRY_FOUND;
307    tParam.content.eRadioBand = RADIO_BAND_5_0_GHZ;
308    regulatoryDomain_getParam (pScanCncn->hRegulatoryDomain, &tParam);
309
310    /* scan type is passive if 802.11d is enabled and country IE was not yet found, active otherwise */
311    if ( (TI_TRUE == bRegulatoryDomainEnabled) && (TI_FALSE == tParam.content.bIsCountryFound) )
312    {
313        pScanCncn->tOsScanParams.scanType = SCAN_TYPE_NORMAL_PASSIVE;
314    }
315    /* All paramters in the func are hard coded, due to that we set to active if not passive */
316	else
317    {
318        pScanCncn->tOsScanParams.scanType = SCAN_TYPE_NORMAL_ACTIVE;
319        /* also set number and rate of probe requests */
320        pScanCncn->tOsScanParams.probeReqNumber = SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_A;
321        pScanCncn->tOsScanParams.probeRequestRate = SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_A;
322    }
323
324    /* add supported channels on G */
325    if (SCAN_TYPE_NORMAL_PASSIVE == pScanCncn->tOsScanParams.scanType )
326    {
327        uValidChannelsCount = scanCncnOsSm_FillAllAvailableChannels (hScanCncn, RADIO_BAND_5_0_GHZ,
328                                       SCAN_TYPE_NORMAL_PASSIVE, &(pScanCncn->tOsScanParams.channelEntry[0]),
329                                       SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_A,
330                                       SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_A,
331                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_A,
332                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_A );
333    }
334    else
335    {
336        uValidChannelsCount = scanCncnOsSm_FillAllAvailableChannels (hScanCncn, RADIO_BAND_5_0_GHZ,
337                                       SCAN_TYPE_NORMAL_ACTIVE, &(pScanCncn->tOsScanParams.channelEntry[0]),
338                                       SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_A,
339                                       SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_A,
340                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_A,
341                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_A );
342    }
343    pScanCncn->tOsScanParams.numOfChannels = uValidChannelsCount;
344
345    /* check that some channels are available */
346    if ( uValidChannelsCount > 0 )
347    {
348        EScanCncnResultStatus   eResult;
349
350       /* send command to scan concentrator APP SM */
351        eResult = scanCncn_Start1ShotScan (hScanCncn, SCAN_SCC_APP_ONE_SHOT, &(pScanCncn->tOsScanParams));
352
353        /* if scan failed, send scan complete event to the SM */
354        if (SCAN_CRS_SCAN_RUNNING != eResult)
355        {
356            TRACE0(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnOsSm_ActionStartAScan: scan failed on 5.0 GHz, quitting\n");
357            genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
358        }
359    }
360    else
361    {
362        TRACE0(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnOsSm_ActionStartGScan: no valid cahnnels on 5.0 GHz, quitting\n");
363        /* no channels to scan, send a scan complete event */
364        genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
365    }
366}
367
368/**
369 * \fn     scanCncnOsSm_ActionCompleteScan
370 * \brief  Scan concentartor OS state machine complete scan action function
371 *
372 * Scan concentartor OS state machine complete scan action function.
373 * Cleans up after an OS scan cycle - stabilize the scan result table
374 *
375 * \param  hScanCncn - handle to the scan concentartor object
376 * \return None
377 */
378void scanCncnOsSm_ActionCompleteScan (TI_HANDLE hScanCncn)
379{
380    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
381
382    /* mark that OID scan process is no longer running */
383    pScanCncn->bOSScanRunning = TI_FALSE;
384    /* also mark that no app scan client is running */
385    pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
386
387    /*
388     * set the result table to stable state. Note: OID scans are always done for the application, so the
389     * results will always be sent to the scan concentartor app scan result table, regardless of the
390     * SME connection mode. However, it is expected that the SME will NOT attempt to connect when an OID
391     * scan request will be received
392     */
393    scanResultTable_SetStableState (pScanCncn->hScanResultTable);
394
395    /* no need to send scan complete event - WZC (or equivalent other OS apps) will query for the results */
396}
397
398/**
399 * \fn     scanCncnOsSm_FillAllAvailableChannels
400 * \brief  Fills a chhanel array with valid channels (and their params) according to band and scan type
401 *
402 * Fills a chhanel array with valid channels (and their params) according to band and scan type
403 *
404 * \param  hScanCncn - handle to the scan concentrator object
405 * \param  eBand - band to extract channels for
406 * \param  eScanType - scan type tp ectract channels for
407 * \param  pChannelArray - where to store allowed channels information
408 * \param  uMaxDwellTime - maximum dwell time value to be used for each channel
409 * \param  uMinDwellTime - minimum dwell time value to be used for each channel
410 * \param  eETCondition - early termination condition value to be used for each channel
411 * \param  uETFrameNumber - early termination frame number value to be used for each channel
412 * \return Number of allowed channels (that were placed in the given channels array)
413 */
414TI_UINT32 scanCncnOsSm_FillAllAvailableChannels (TI_HANDLE hScanCncn, ERadioBand eBand, EScanType eScanType,
415                                                 TScanChannelEntry *pChannelArray, TI_UINT32 uMaxDwellTime,
416                                                 TI_UINT32 uMinChannelTime, EScanEtCondition eETCondition,
417                                                 TI_UINT8 uETFrameNumber)
418{
419    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
420    TI_UINT32       i, j, uAllowedChannelsCount, uValidChannelsCnt = 0;
421    paramInfo_t     tParam;
422    TI_UINT8        uTempChannelList[ SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND ];
423
424    /* get the numnber of supported channels for this band */
425    tParam.paramType = REGULATORY_DOMAIN_ALL_SUPPORTED_CHANNELS;
426    tParam.content.siteMgrRadioBand = eBand;
427    regulatoryDomain_getParam (pScanCncn->hRegulatoryDomain, &tParam);
428    uAllowedChannelsCount = tParam.content.supportedChannels.sizeOfList;
429
430    /* for the time being don't scan more channels than fit in one command */
431    if (uAllowedChannelsCount > SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND)
432    {
433        uAllowedChannelsCount = SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND;
434    }
435
436    /* Copy allowed channels to reuse param var */
437    os_memoryCopy (pScanCncn->hOS, uTempChannelList,
438            tParam.content.supportedChannels.listOfChannels, uAllowedChannelsCount );
439
440    /* preapre the param var to request channel allowance for the requested scan type */
441    tParam.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
442    tParam.content.channelCapabilityReq.band = eBand;
443
444    /* add default values to channels allowed for the requested scan type and band */
445    for (i = 0; i < uAllowedChannelsCount; i++)
446    {
447        /* get specific channel allowance for scan type */
448        if ((eScanType == SCAN_TYPE_NORMAL_PASSIVE) ||
449            (eScanType == SCAN_TYPE_TRIGGERED_PASSIVE) ||
450            (eScanType == SCAN_TYPE_SPS))
451        {
452            tParam.content.channelCapabilityReq.scanOption = PASSIVE_SCANNING;
453        }
454        else
455        {
456            tParam.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
457        }
458        tParam.content.channelCapabilityReq.channelNum = uTempChannelList[ i ];
459
460        regulatoryDomain_getParam( pScanCncn->hRegulatoryDomain, &tParam );
461        if (TI_TRUE == tParam.content.channelCapabilityRet.channelValidity)
462        {
463            /* add the channel ID */
464            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.channel = uTempChannelList[ i ];
465
466            /* add other default parameters */
467            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.minChannelDwellTime = uMinChannelTime;
468            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.maxChannelDwellTime = uMaxDwellTime;
469            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.earlyTerminationEvent = eETCondition;
470            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.ETMaxNumOfAPframes = uETFrameNumber;
471            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.txPowerDbm  =
472                tParam.content.channelCapabilityRet.maxTxPowerDbm;
473
474            /* Fill broadcast BSSID */
475            for (j = 0; j < 6; j++)
476            {
477                pChannelArray[ uValidChannelsCnt ].normalChannelEntry.bssId[ j ] = 0xff;
478            }
479            uValidChannelsCnt++;
480        }
481    }
482
483    /* return the number of channels that are actually allowed for the requested scan type on the requested band */
484    return uValidChannelsCnt;
485}
486
487/**
488 * \fn     Function declaration
489 * \brief  Function brief description goes here
490 *
491 * Function detailed description goes here
492 *
493 * \note   Note is indicated here
494 * \param  Parameter name - parameter description
495 * \param  
496 * \return Return code is detailed here
497 * \sa     Reference to other relevant functions
498 */
499/**
500 * \\n
501 * \date 11-Jan-2005\n
502 * \brief Handles an unexpected event.\n
503
504 *
505 * Function Scope \e Private.\n
506 * \param hScanCncn - handle to the scan concentrator object.\n
507 * \return always OK.\n
508 */
509void scanCncnOsSm_ActionUnexpected (TI_HANDLE hScanCncn)
510{
511    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
512
513    TRACE0(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnOsSm_ActionUnexpected: Unexpeted action for current state\n");
514}
515
516