summaryrefslogtreecommitdiff
path: root/wl1271/stad/src/Sta_Management/ScanCncnOsSm.c
blob: 7a0c768549be86d1012943375740cdebb02338dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
/*
 * ScanCncnOsSm.c
 *
 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.      
 * All rights reserved.                                                  
 *                                                                       
 * Redistribution and use in source and binary forms, with or without    
 * modification, are permitted provided that the following conditions    
 * are met:                                                              
 *                                                                       
 *  * Redistributions of source code must retain the above copyright     
 *    notice, this list of conditions and the following disclaimer.      
 *  * Redistributions in binary form must reproduce the above copyright  
 *    notice, this list of conditions and the following disclaimer in    
 *    the documentation and/or other materials provided with the         
 *    distribution.                                                      
 *  * Neither the name Texas Instruments nor the names of its            
 *    contributors may be used to endorse or promote products derived    
 *    from this software without specific prior written permission.      
 *                                                                       
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/** \file  ScanCncnOsSm.c
 *  \brief Scan concentrator OS scan state machine implementation
 *
 *  \see   ScanCncnApp.c
 */


#define __FILE_ID__  FILE_ID_78
#include "osTIType.h"
#include "GenSM.h"
#include "ScanCncnOsSm.h"
#include "ScanCncn.h"
#include "ScanCncnPrivate.h"
#include "report.h"
#include "osApi.h"
#include "siteMgrApi.h"
#include "regulatoryDomainApi.h"
#include "scanResultTable.h"

#define SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_G                       RATE_MASK_UNSPECIFIED  /* Let the FW select */
#define SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_A                       RATE_MASK_UNSPECIFIED  /* Let the FW select */
#define SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_G                     3
#define SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_A                     3
#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_G                   100000
#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_A                   100000
#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_G                    30000
#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_A                    30000
#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_G                   100000
#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_A                   100000
#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_G                    15000
#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_A                    15000
#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_G          SCAN_ET_COND_BEACON
#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_A          SCAN_ET_COND_BEACON
#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_G           SCAN_ET_COND_ANY_FRAME
#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_A           SCAN_ET_COND_ANY_FRAME

/* For WiFi  WPA OOB scenario, 4 APs need to be configure on the same channel */
#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_G          4 
#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_A          4
#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_G           4
#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_A           4

static void scanCncnOsSm_ActionStartGScan (TI_HANDLE hScanCncn);
static void scanCncnOsSm_ActionStartAScan (TI_HANDLE hScanCncn);
static void scanCncnOsSm_ActionCompleteScan (TI_HANDLE hScanCncn);
static void scanCncnOsSm_ActionUnexpected (TI_HANDLE hScanCncn);
TI_UINT32   scanCncnOsSm_FillAllAvailableChannels (TI_HANDLE hScanCncn, ERadioBand eBand, EScanType eScanType,
                                                   TScanChannelEntry *pChannelArray, TI_UINT32 uMaxDwellTime,
                                                   TI_UINT32 uMinChannelTime, EScanEtCondition eETCondition,
                                                   TI_UINT8 uETFrameNumber);


static TGenSM_actionCell tSmMatrix[ SCAN_CNCN_OS_SM_NUMBER_OF_STATES ][ SCAN_CNCN_OS_SM_NUMBER_OF_EVENTS ] = 
    {
        { /* SCAN_CNCN_OS_SM_STATE_IDLE */
            { SCAN_CNCN_OS_SM_STATE_SCAN_ON_G,  scanCncnOsSm_ActionStartGScan },    /* SCAN_CNCN_OS_SM_EVENT_START_SCAN */
            { SCAN_CNCN_OS_SM_STATE_IDLE,       scanCncnOsSm_ActionUnexpected },    /* SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE */
        },
        { /* SCAN_CNCN_OS_SM_STATE_SCAN_ON_G */
            { SCAN_CNCN_OS_SM_STATE_SCAN_ON_G,  scanCncnOsSm_ActionUnexpected },    /* SCAN_CNCN_OS_SM_EVENT_START_SCAN */
            { SCAN_CNCN_OS_SM_STATE_SCAN_ON_A,  scanCncnOsSm_ActionStartAScan },    /* SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE */
        },
        { /* SCAN_CNCN_OS_SM_STATE_SCAN_ON_A */
            { SCAN_CNCN_OS_SM_STATE_SCAN_ON_A,  scanCncnOsSm_ActionUnexpected },    /* SCAN_CNCN_OS_SM_EVENT_START_SCAN */
            { SCAN_CNCN_OS_SM_STATE_IDLE,       scanCncnOsSm_ActionCompleteScan },  /* SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE */
        }
    };

static TI_INT8  *uStateDescription[] = 
    {
        "IDLE",
        "SCAN_ON_G",
        "SCAN_ON_A"
    };

static TI_INT8  *uEventDescription[] = 
    {
        "START",
        "SCAN_COMPLETE"
    };

/** 
 * \fn     scanCncnOsSm_Create
 * \brief  Creates the OS scan state-machine
 * 
 * creates the OS scan state-machine
 * 
 * \param  hScanCncn - handle to the scan concentrator object
 * \return Handle to the newly created OS san SM, NULL if an error occured
 * \sa     scanCncnOsSm_Create, scanCncnOsSm_Destroy
 */
TI_HANDLE scanCncnOsSm_Create (TI_HANDLE hScanCncn)
{
    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;

    return genSM_Create (pScanCncn->hOS);
}

/** 
 * \fn     scanCncnOsSm_Init
 * \brief  Initialize the OS scan state-machine
 * 
 * Initialize the OS scan state-machine
 * 
 * \param  hScanCncn - handle to the scan concentrator object
 * \return None
 * \sa     scanCncnOsSm_Create
 */
void scanCncnOsSm_Init (TI_HANDLE hScanCncn)
{
    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;

    /* initialize the state-machine */
    genSM_Init (pScanCncn->hOSScanSm, pScanCncn->hReport);
    genSM_SetDefaults (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_NUMBER_OF_STATES, SCAN_CNCN_OS_SM_NUMBER_OF_EVENTS,
                       (TGenSM_matrix)tSmMatrix, SCAN_CNCN_OS_SM_STATE_IDLE, "OS scan SM", uStateDescription, 
                       uEventDescription, __FILE_ID__);
}

/** 
 * \fn     scanCncnOsSm_Destroy
 * \brief  Destroys the OS scan state-machine
 * 
 * Destroys the OS scan state-machine
 * 
 * \param  hScanCncn - handle to the scan concentrator object
 * \return None
 * \sa     scanCncnOsSm_Create
 */
void scanCncnOsSm_Destroy (TI_HANDLE hScanCncn)
{
    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;

    genSM_Unload (pScanCncn->hOSScanSm);
}

/** 
 * \fn     scanCncnOsSm_ActionStartGScan
 * \brief  Scan concentartor OS state machine start scan on G action function
 * 
 * Scan concentartor OS state machine start scan on G action function.
 * Starts a sacn on G using all allowed channels
 * 
 * \param  hScanCncn - handle to the scan concentartor object
 * \return None
 */ 
void scanCncnOsSm_ActionStartGScan (TI_HANDLE hScanCncn)
{
    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
    paramInfo_t     tParam;
    TI_UINT32       uValidChannelsCount;
    TI_BOOL         bRegulatoryDomainEnabled;

    /* if the STA is not configured for G band or dual band, send a scan complete event to the SM */
    tParam.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
    siteMgr_getParam (pScanCncn->hSiteManager, &tParam);
    if ((DOT11_G_MODE != tParam.content.siteMgrDot11Mode) && (DOT11_DUAL_MODE != tParam.content.siteMgrDot11Mode))
    {
        TRACE0(pScanCncn->hReport , REPORT_SEVERITY_INFORMATION , "scanCncnOsSm_ActionStartGScan: STA does not work on 2.4 GHz, continuing to 5.0 GHz scan\n");
        genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
        return;
    }

    /* build scan command header */
    pScanCncn->tOsScanParams.band = RADIO_BAND_2_4_GHZ;
    pScanCncn->tOsScanParams.Tid = 255;

    /* query the regulatory domain if 802.11d is in use */
    tParam.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
    regulatoryDomain_getParam (pScanCncn->hRegulatoryDomain, &tParam );
    bRegulatoryDomainEnabled = tParam.content.regulatoryDomainEnabled;

    /* Get country code status */
    tParam.paramType          = REGULATORY_DOMAIN_IS_COUNTRY_FOUND;
    tParam.content.eRadioBand = RADIO_BAND_2_4_GHZ;
    regulatoryDomain_getParam (pScanCncn->hRegulatoryDomain, &tParam);

    /* scan type is passive if 802.11d is enabled and country IE was not yet found, active otherwise */
    if (((TI_TRUE == bRegulatoryDomainEnabled) && (TI_FALSE == tParam.content.bIsCountryFound)) || SCAN_TYPE_TRIGGERED_PASSIVE == pScanCncn->tOsScanParams.scanType)
    {
		pScanCncn->tOsScanParams.scanType = SCAN_TYPE_TRIGGERED_PASSIVE;
    }
	/* All paramters in the func are hard coded, due to that we set to active if not passive */
    else
    {
        pScanCncn->tOsScanParams.scanType = SCAN_TYPE_TRIGGERED_ACTIVE;
        /* also set number and rate of probe requests */
        pScanCncn->tOsScanParams.probeReqNumber = SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_G;
        pScanCncn->tOsScanParams.probeRequestRate = SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_G;
    }
    
    /* add supported channels on G */
    if (SCAN_TYPE_NORMAL_PASSIVE == pScanCncn->tOsScanParams.scanType )
    {
        uValidChannelsCount = scanCncnOsSm_FillAllAvailableChannels (hScanCncn, RADIO_BAND_2_4_GHZ, 
                                       SCAN_TYPE_NORMAL_PASSIVE, &(pScanCncn->tOsScanParams.channelEntry[0]),
                                       SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_G,
                                       SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_G,
                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_G,
                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_G);
    }
    else
    {
        uValidChannelsCount = scanCncnOsSm_FillAllAvailableChannels (hScanCncn, RADIO_BAND_2_4_GHZ, 
                                       SCAN_TYPE_NORMAL_ACTIVE, &(pScanCncn->tOsScanParams.channelEntry[0]),
                                       SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_G,
                                       SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_G,
                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_G,
                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_G);
    }
    pScanCncn->tOsScanParams.numOfChannels = uValidChannelsCount;

    /* check that some channels are available */
    if ( uValidChannelsCount > 0 )
    {
        EScanCncnResultStatus   eResult;
        
        /* send command to scan concentrator APP SM */
        eResult = scanCncn_Start1ShotScan (hScanCncn, SCAN_SCC_APP_ONE_SHOT, &(pScanCncn->tOsScanParams));

        /* if scan failed, send scan complete event to the SM */
        if (SCAN_CRS_SCAN_RUNNING != eResult)
        {
            TRACE0(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnOsSm_ActionStartGScan: scan failed on 2.4 GHz, continuing to 5.0 GHz scan\n");
            genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
        }
    }
    else
    {
        TRACE0(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnOsSm_ActionStartGScan: no valid cahnnels on 2.4 GHz, continuing to 5.0 GHz scan\n");
        /* no channels to scan, send a scan complete event */
        genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
    }
}

/** 
 * \fn     scanCncnOsSm_ActionStartAScan
 * \brief  Scan concentartor OS state machine start scan on A action function
 * 
 * Scan concentartor OS state machine start scan on A action function.
 * Starts a sacn on A using all allowed channels
 * 
 * \param  hScanCncn - handle to the scan concentartor object
 * \return None
 */ 
void scanCncnOsSm_ActionStartAScan (TI_HANDLE hScanCncn)
{
    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
    paramInfo_t     tParam;
    TI_UINT32       uValidChannelsCount;
    TI_BOOL         bRegulatoryDomainEnabled;

    /* if the STA is not configured for G band or dual band, send a scan complete event to the SM */
    tParam.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
    siteMgr_getParam (pScanCncn->hSiteManager, &tParam);
    if ((DOT11_A_MODE != tParam.content.siteMgrDot11Mode) && (DOT11_DUAL_MODE != tParam.content.siteMgrDot11Mode))
    {
        TRACE0(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnOsSm_ActionStartAScan: STA does not work on 5.0 GHz, quitting\n");
        genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
        return;
    }

    /* build scan command header */
    pScanCncn->tOsScanParams.band = RADIO_BAND_5_0_GHZ;
    pScanCncn->tOsScanParams.Tid = 0;

    /* query the regulatory domain if 802.11d is in use */
    tParam.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
    regulatoryDomain_getParam (pScanCncn->hRegulatoryDomain, &tParam );
    bRegulatoryDomainEnabled = tParam.content.regulatoryDomainEnabled;

    /* Get country code status */
    tParam.paramType          = REGULATORY_DOMAIN_IS_COUNTRY_FOUND;
    tParam.content.eRadioBand = RADIO_BAND_5_0_GHZ;
    regulatoryDomain_getParam (pScanCncn->hRegulatoryDomain, &tParam);

    /* scan type is passive if 802.11d is enabled and country IE was not yet found, active otherwise */
    if (((TI_TRUE == bRegulatoryDomainEnabled) && (TI_FALSE == tParam.content.bIsCountryFound)) || SCAN_TYPE_TRIGGERED_PASSIVE == pScanCncn->tOsScanParams.scanType)
    {
        pScanCncn->tOsScanParams.scanType = SCAN_TYPE_TRIGGERED_PASSIVE;
    }
    /* All paramters in the func are hard coded, due to that we set to active if not passive */
	else
    {
        pScanCncn->tOsScanParams.scanType = SCAN_TYPE_TRIGGERED_ACTIVE;
        /* also set number and rate of probe requests */
        pScanCncn->tOsScanParams.probeReqNumber = SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_A;
        pScanCncn->tOsScanParams.probeRequestRate = SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_A;
    }
    
    /* add supported channels on G */
    if (SCAN_TYPE_NORMAL_PASSIVE == pScanCncn->tOsScanParams.scanType )
    {
        uValidChannelsCount = scanCncnOsSm_FillAllAvailableChannels (hScanCncn, RADIO_BAND_5_0_GHZ, 
                                       SCAN_TYPE_NORMAL_PASSIVE, &(pScanCncn->tOsScanParams.channelEntry[0]),
                                       SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_A,
                                       SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_A,
                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_A,
                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_A );
    }
    else
    {
        uValidChannelsCount = scanCncnOsSm_FillAllAvailableChannels (hScanCncn, RADIO_BAND_5_0_GHZ,
                                       SCAN_TYPE_NORMAL_ACTIVE, &(pScanCncn->tOsScanParams.channelEntry[0]),
                                       SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_A,
                                       SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_A,
                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_A,
                                       SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_A );
    }
    pScanCncn->tOsScanParams.numOfChannels = uValidChannelsCount;

    /* check that some channels are available */
    if ( uValidChannelsCount > 0 )
    {
        EScanCncnResultStatus   eResult;

       /* send command to scan concentrator APP SM */
        eResult = scanCncn_Start1ShotScan (hScanCncn, SCAN_SCC_APP_ONE_SHOT, &(pScanCncn->tOsScanParams));

        /* if scan failed, send scan complete event to the SM */
        if (SCAN_CRS_SCAN_RUNNING != eResult)
        {
            TRACE0(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnOsSm_ActionStartAScan: scan failed on 5.0 GHz, quitting\n");
            genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
        }
    }
    else
    {
        TRACE0(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnOsSm_ActionStartGScan: no valid cahnnels on 5.0 GHz, quitting\n");
        /* no channels to scan, send a scan complete event */
        genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
    }
}

/** 
 * \fn     scanCncnOsSm_ActionCompleteScan
 * \brief  Scan concentartor OS state machine complete scan action function
 * 
 * Scan concentartor OS state machine complete scan action function.
 * Cleans up after an OS scan cycle - stabilize the scan result table
 * 
 * \param  hScanCncn - handle to the scan concentartor object
 * \return None
 */ 
void scanCncnOsSm_ActionCompleteScan (TI_HANDLE hScanCncn)
{
    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;


	 /*Update the table only if scan was not rejected*/
	 if ( !pScanCncn->pScanClients[ pScanCncn->eCurrentRunningAppScanClient ]->bScanRejectedOn2_4)
	 {
    /* 
     * set the result table to stable state. Note: OID scans are always done for the application, so the
     * results will always be sent to the scan concentartor app scan result table, regardless of the
     * SME connection mode. However, it is expected that the SME will NOT attempt to connect when an OID
     * scan request will be received
     */
    scanResultTable_SetStableState (pScanCncn->hScanResultTable);
	 }
	 else
	 {
		  pScanCncn->pScanClients[ pScanCncn->eCurrentRunningAppScanClient ]->bScanRejectedOn2_4 = TI_FALSE;
	 }

    /* mark that OID scan process is no longer running */
    pScanCncn->bOSScanRunning = TI_FALSE;
    /* also mark that no app scan client is running */
    pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
 

    /* no need to send scan complete event - WZC (or equivalent other OS apps) will query for the results */
}

/** 
 * \fn     scanCncnOsSm_FillAllAvailableChannels
 * \brief  Fills a chhanel array with valid channels (and their params) according to band and scan type
 * 
 * Fills a chhanel array with valid channels (and their params) according to band and scan type
 * 
 * \param  hScanCncn - handle to the scan concentrator object
 * \param  eBand - band to extract channels for
 * \param  eScanType - scan type tp ectract channels for
 * \param  pChannelArray - where to store allowed channels information
 * \param  uMaxDwellTime - maximum dwell time value to be used for each channel
 * \param  uMinDwellTime - minimum dwell time value to be used for each channel
 * \param  eETCondition - early termination condition value to be used for each channel
 * \param  uETFrameNumber - early termination frame number value to be used for each channel
 * \return Number of allowed channels (that were placed in the given channels array)
 */ 
TI_UINT32 scanCncnOsSm_FillAllAvailableChannels (TI_HANDLE hScanCncn, ERadioBand eBand, EScanType eScanType,
                                                 TScanChannelEntry *pChannelArray, TI_UINT32 uMaxDwellTime,
                                                 TI_UINT32 uMinChannelTime, EScanEtCondition eETCondition,
                                                 TI_UINT8 uETFrameNumber)
{
    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
    TI_UINT32       i, j, uAllowedChannelsCount, uValidChannelsCnt = 0;
    paramInfo_t     tParam;
    TI_UINT8        uTempChannelList[ SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND ];
 
    /* get the numnber of supported channels for this band */
    tParam.paramType = REGULATORY_DOMAIN_ALL_SUPPORTED_CHANNELS;
    tParam.content.siteMgrRadioBand = eBand;
    regulatoryDomain_getParam (pScanCncn->hRegulatoryDomain, &tParam);
    uAllowedChannelsCount = tParam.content.supportedChannels.sizeOfList;

    /* for the time being don't scan more channels than fit in one command */
    if (uAllowedChannelsCount > SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND)
    {
        uAllowedChannelsCount = SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND;
    }

    /* Copy allowed channels to reuse param var */
    os_memoryCopy (pScanCncn->hOS, uTempChannelList,
            tParam.content.supportedChannels.listOfChannels, uAllowedChannelsCount );

    /* preapre the param var to request channel allowance for the requested scan type */
    tParam.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
    tParam.content.channelCapabilityReq.band = eBand;

    /* add default values to channels allowed for the requested scan type and band */
    for (i = 0; i < uAllowedChannelsCount; i++)
    {
        /* get specific channel allowance for scan type */
        if ((eScanType == SCAN_TYPE_NORMAL_PASSIVE) ||
            (eScanType == SCAN_TYPE_TRIGGERED_PASSIVE) ||
            (eScanType == SCAN_TYPE_SPS))
        {
            tParam.content.channelCapabilityReq.scanOption = PASSIVE_SCANNING;
        }
        else
        {
            tParam.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
        }
        tParam.content.channelCapabilityReq.channelNum = uTempChannelList[ i ];

        regulatoryDomain_getParam( pScanCncn->hRegulatoryDomain, &tParam );
        if (TI_TRUE == tParam.content.channelCapabilityRet.channelValidity)
        {
            /* add the channel ID */
            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.channel = uTempChannelList[ i ];

            /* add other default parameters */
            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.minChannelDwellTime = uMinChannelTime;
            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.maxChannelDwellTime = uMaxDwellTime;
            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.earlyTerminationEvent = eETCondition;
            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.ETMaxNumOfAPframes = uETFrameNumber;
            pChannelArray[ uValidChannelsCnt ].normalChannelEntry.txPowerDbm  = 
                tParam.content.channelCapabilityRet.maxTxPowerDbm;

            /* Fill broadcast BSSID */
            for (j = 0; j < 6; j++)
            {
                pChannelArray[ uValidChannelsCnt ].normalChannelEntry.bssId[ j ] = 0xff;
            }
            uValidChannelsCnt++;
        }
    }

    /* return the number of channels that are actually allowed for the requested scan type on the requested band */
    return uValidChannelsCnt;
}

/** 
 * \fn     Function declaration 
 * \brief  Function brief description goes here 
 * 
 * Function detailed description goes here 
 * 
 * \note   Note is indicated here 
 * \param  Parameter name - parameter description
 * \param  … 
 * \return Return code is detailed here 
 * \sa     Reference to other relevant functions 
 */ 
/**
 * \\n
 * \date 11-Jan-2005\n
 * \brief Handles an unexpected event.\n

 *
 * Function Scope \e Private.\n
 * \param hScanCncn - handle to the scan concentrator object.\n
 * \return always OK.\n
 */
void scanCncnOsSm_ActionUnexpected (TI_HANDLE hScanCncn) 
{
    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;

    TRACE0(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnOsSm_ActionUnexpected: Unexpeted action for current state\n");
}