1981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
2981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * scanResultTable.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  scanResultTable.c
35981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \brief implements a table holding scan results, by BSSID
36981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
37981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \see   scanResultTable.h
38981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
39981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
40981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
41981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define __FILE_ID__  FILE_ID_81
42981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "osApi.h"
43981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "report.h"
44981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "scanResultTable.h"
45981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "siteMgrApi.h"
46981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "freq.h"
47981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
48981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
49653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#define TABLE_ENTRIES_NUMBER    32
50981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
51981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_BSSID(pSite, pFrame)                     MAC_COPY((pSite)->bssid, *((pFrame)->bssId))
52981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_BAND(pSite, pFrame)                      (pSite)->eBand = (pFrame)->band
53981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_BEACON_INTERVAL(pSite, pFrame)           pSite->beaconInterval = (pFrame)->parsedIEs->content.iePacket.beaconInerval
54981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_CAPABILITIES(pSite, pFrame)              pSite->capabilities = (pFrame)->parsedIEs->content.iePacket.capabilities
55981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_PRIVACY(pSite, pFrame)                   pSite->privacy = (((pFrame)->parsedIEs->content.iePacket.capabilities >> CAP_PRIVACY_SHIFT) & CAP_PRIVACY_MASK) ? TI_TRUE : TI_FALSE
56981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_AGILITY(pSite, pFrame)                   pSite->agility = (((pFrame)->parsedIEs->content.iePacket.capabilities >> CAP_AGILE_SHIFT) & CAP_AGILE_MASK) ? TI_TRUE : TI_FALSE
57981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_SLOT_TIME(pSite, pFrame)                 pSite->newSlotTime = (((pFrame)->parsedIEs->content.iePacket.capabilities >> CAP_SLOT_TIME_SHIFT) & CAP_SLOT_TIME_MASK) ? PHY_SLOT_TIME_SHORT : PHY_SLOT_TIME_LONG
58981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_PROTECTION(pSite, pFrame)                pSite->useProtection = ((pFrame)->parsedIEs->content.iePacket.useProtection)
593f2824312a75dcb53eccc70ee2cbf5356cc1c0bbDmitry Shmidt
60981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_SSID(pScanResultTable, pSite, pFrame)    if ((pFrame)->parsedIEs->content.iePacket.pSsid != NULL) { \
61981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            pSite->ssid.len = (pFrame)->parsedIEs->content.iePacket.pSsid->hdr[1]; \
62981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            os_memoryCopy(pScanResultTable->hOS, \
63981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                                (void *)pSite->ssid.str, \
64981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                                (void *)(pFrame)->parsedIEs->content.iePacket.pSsid->serviceSetId, \
65981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                                (pFrame)->parsedIEs->content.iePacket.pSsid->hdr[1]); \
663f2824312a75dcb53eccc70ee2cbf5356cc1c0bbDmitry Shmidt                                                            if (pSite->ssid.len < MAX_SSID_LEN) \
673f2824312a75dcb53eccc70ee2cbf5356cc1c0bbDmitry Shmidt                                                                pSite->ssid.str[pSite->ssid.len] = '\0';}
683f2824312a75dcb53eccc70ee2cbf5356cc1c0bbDmitry Shmidt
69981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_CHANNEL(pSite, pFrame, rxChannel)        if ((pFrame)->parsedIEs->content.iePacket.pDSParamsSet == NULL) \
70981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            pSite->channel = rxChannel; \
71981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                        else \
72981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            pSite->channel = (pFrame)->parsedIEs->content.iePacket.pDSParamsSet->currChannel;
73981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_DTIM_PERIOD(pSite, pFrame)               if ((pFrame)->parsedIEs->content.iePacket.pTIM != NULL) \
74981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            pSite->dtimPeriod = (pFrame)->parsedIEs->content.iePacket.pTIM->dtimPeriod
75981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_ATIM_WINDOW(pSite, pFrame)               if ((pFrame)->parsedIEs->content.iePacket.pIBSSParamsSet != NULL) \
76981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            pSite->atimWindow = (pFrame)->parsedIEs->content.iePacket.pIBSSParamsSet->atimWindow
77981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_AP_TX_POWER(pSite, pFrame)               if ((pFrame)->parsedIEs->content.iePacket.TPCReport != NULL) \
78981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            pSite->APTxPower = (pFrame)->parsedIEs->content.iePacket.TPCReport->transmitPower
79981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_BSS_TYPE(pSite, pFrame)                  pSite->bssType = (((pFrame)->parsedIEs->content.iePacket.capabilities >> CAP_ESS_SHIFT) & CAP_ESS_MASK) ? BSS_INFRASTRUCTURE : BSS_INDEPENDENT
80981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_RSN_IE(pScanResultTable, pSite, pNewRsnIe, newRsnIeLen) if ((pNewRsnIe) != NULL) { \
81981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            TI_UINT8 length=0, index=0;\
82981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            dot11_RSN_t *pTempRsnIe = (pNewRsnIe); \
83981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            (pSite)->rsnIeLen = (newRsnIeLen);\
84981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            while ((length < (pSite)->rsnIeLen) && (index < MAX_RSN_IE)) {\
85981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                                (pSite)->pRsnIe[index].hdr[0] = pTempRsnIe->hdr[0];\
86981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                                (pSite)->pRsnIe[index].hdr[1] = pTempRsnIe->hdr[1];\
87981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                                os_memoryCopy(pScanResultTable->hOS, (void *)(pSite)->pRsnIe[index].rsnIeData, (void *)pTempRsnIe->rsnIeData, pTempRsnIe->hdr[1]);\
88981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                                length += (pTempRsnIe->hdr[1]+2); \
89981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                                pTempRsnIe += 1; \
90981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                                index++;}\
91981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                        } \
92981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                        else {pSite->rsnIeLen = 0;}
93981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_BEACON_TIMESTAMP(pScanResultTable, pSite, pFrame)    os_memoryCopy(pScanResultTable->hOS, pSite->tsfTimeStamp, (void *)(pFrame)->parsedIEs->content.iePacket.timestamp, TIME_STAMP_LEN)
94981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
95981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Updated from beacons */
96981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_BEACON_MODULATION(pSite, pFrame)         pSite->beaconModulation = (((pFrame)->parsedIEs->content.iePacket.capabilities >> CAP_PBCC_SHIFT) & CAP_PBCC_MASK) ? DRV_MODULATION_PBCC : DRV_MODULATION_CCK
97981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_BEACON_RECV(pSite)                       pSite->beaconRecv = TI_TRUE
98981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
99981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Updated from probes */
100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_PROBE_MODULATION(pSite, pFrame)          pSite->probeModulation = (((pFrame)->parsedIEs->content.iePacket.capabilities >> CAP_PBCC_SHIFT) & CAP_PBCC_MASK) ? DRV_MODULATION_PBCC : DRV_MODULATION_CCK
101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_PROBE_RECV(pSite)                        pSite->probeRecv = TI_TRUE
102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_APSD(pSite, pFrame)                      if ((pFrame)->parsedIEs->content.iePacket.WMEParams == NULL) \
103981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                                (pSite)->APSDSupport = ((((pFrame)->parsedIEs->content.iePacket.capabilities >> CAP_APSD_SHIFT) & CAP_APSD_MASK) ? TI_TRUE : TI_FALSE); \
104981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                        else \
105981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            pSite->APSDSupport = (((((pFrame)->parsedIEs->content.iePacket.capabilities >> CAP_APSD_SHIFT) & CAP_APSD_MASK) ? TI_TRUE : TI_FALSE) || \
106981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                                                  ((((pFrame)->parsedIEs->content.iePacket.WMEParams->ACInfoField >> AP_QOS_INFO_UAPSD_SHIFT) & AP_QOS_INFO_UAPSD_MASK) ? TI_TRUE : TI_FALSE));
107981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_PREAMBLE(pSite, pFrame)                  { (pSite)->currentPreambleType = (((pFrame)->parsedIEs->content.iePacket.capabilities >> CAP_PREAMBLE_SHIFT) & CAP_PREAMBLE_MASK) ? PREAMBLE_SHORT : PREAMBLE_LONG; \
108981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                          (pSite)->barkerPreambleType = (pFrame)->parsedIEs->content.iePacket.barkerPreambleMode; }
109981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_QOS(pSite, pFrame)                       if ( ((pFrame)->parsedIEs->content.iePacket.WMEParams  != NULL) && \
110981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                             (((((pFrame)->parsedIEs->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK) != pSite->lastWMEParameterCnt) || (!pSite->WMESupported)) ) \
111981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            pSite->WMESupported = TI_TRUE; \
112981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                        else \
113981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            pSite->WMESupported = TI_FALSE;
114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_FRAME_BUFFER(pScanResultTable, pBuffer, uLength, pFrame)  if (pFrame->bufferLength < MAX_BEACON_BODY_LENGTH) \
115981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                        { \
116981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                           os_memoryCopy (pScanResultTable->hOS, pBuffer, pFrame->buffer, pFrame->bufferLength); \
117981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                           uLength = pFrame->bufferLength; \
118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                        }
119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_RSSI(pSite, pFrame)                      (pSite)->rssi = (pFrame)->rssi;
120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_SNR(pSite, pFrame)                       (pSite)->snr = (pFrame)->snr;
121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define UPDATE_RATE(pSite, pFrame)                      if ((DRV_RATE_1M <= (pFrame)->rate) && (DRV_RATE_54M <= (pFrame)->rate)) \
122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                            (pSite)->rxRate = (pFrame)->rate;
123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef struct
126981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE       hOS;                    /**< Handle to the OS object */
128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE       hReport;                /**< handle to the report object */
129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE       hSiteMgr;               /**< Handle to the site manager object */
130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TSiteEntry      *pTable;                /**< site table */
131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32       uCurrentSiteNumber;     /**< number of sites currently in the table */
132981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32       uIterator;              /**< table iterator used for getFirst / getNext */
133981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL         bStable;                /**< table status (updating / stable) */
134981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} TScanResultTable;
135981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
136981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TSiteEntry  *scanResultTbale_AllocateNewEntry (TI_HANDLE hScanResultTable);
137981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void         scanResultTable_UpdateSiteData (TI_HANDLE hScanResultTable, TSiteEntry *pSite, TScanFrameInfo *pFrame);
138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void         scanResultTable_updateRates(TI_HANDLE hScanResultTable, TSiteEntry *pSite, TScanFrameInfo *pFrame);
139981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void         scanResultTable_UpdateWSCParams (TSiteEntry *pSite, TScanFrameInfo *pFrame);
140981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS scanResultTable_CheckRxSignalValidity(TScanResultTable *pScanResultTable, siteEntry_t *pSite, TI_INT8 rxLevel, TI_UINT8 channel);
141981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
142981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
144981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_Create
145981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Create a scan result table object.
146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Create a scan result table object. Allocate system resources.
148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
149981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
150981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hOS - handle to the OS object
151981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return Handle to the newly created scan result table object, NULL if an error occured.
152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanResultTable_Init, scanResultTable_Destroy
153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
154981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_HANDLE scanResultTable_Create (TI_HANDLE hOS)
155981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = NULL;
157981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
158981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Allocate object storage */
159981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable = (TScanResultTable*)os_memoryAlloc (hOS, sizeof(TScanResultTable));
160981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (NULL != pScanResultTable)
161981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
162981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pScanResultTable->hOS = hOS;
163981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
164981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
165981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* allocate memory for sites' data */
166981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->pTable =
167981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        (TSiteEntry *)os_memoryAlloc (pScanResultTable->hOS, sizeof (TSiteEntry) * TABLE_ENTRIES_NUMBER);
168981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (NULL == pScanResultTable->pTable)
169981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
170653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        TRACE2(pScanResultTable->hReport, REPORT_SEVERITY_ERROR ,
171653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt			   "scanResultTable_Create: Unable to allocate memory for %d entries of %d bytes\n",
172653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt			   TABLE_ENTRIES_NUMBER, sizeof (TSiteEntry));
173981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return NULL;
174981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
175981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
176981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return (TI_HANDLE)pScanResultTable;
177981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
178981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
179981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
180981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_Init
181981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Initializes the scan result table object
182981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
183981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Initializes the scan result table object. Set handles to other objects.
184981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
185981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
186981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pStadHandles - modules handles table
187981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return None
188981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanResultTable_Create
189981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
190981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid        scanResultTable_Init (TI_HANDLE hScanResultTable, TStadHandlesList *pStadHandles)
191981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
192981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = (TScanResultTable*)hScanResultTable;
193981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
194981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* set handles to other modules */
195981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->hReport = pStadHandles->hReport;
196981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->hSiteMgr = pStadHandles->hSiteMgr;
197981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
198981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* initialize other parameters */
199981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->uCurrentSiteNumber = 0;
200981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->bStable = TI_TRUE;
201981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->uIterator = 0;
202981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
203981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
204981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
205981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
206981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_Destroy
207981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Destroys the scan result table object
208981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
209981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Destroys the scan result table object. Release system resources
210981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
211981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
212981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return None
213981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanResultTable_Create
214981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
215981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid        scanResultTable_Destroy (TI_HANDLE hScanResultTable)
216981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
217981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = (TScanResultTable*)hScanResultTable;
218981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
219981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* if the table memory has already been allocated */
220981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (NULL != pScanResultTable->pTable)
221981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
222981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* free table memory */
223981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_memoryFree (pScanResultTable->hOS, (void*)pScanResultTable->pTable,
224981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                       sizeof (TSiteEntry) * TABLE_ENTRIES_NUMBER);
225981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
226981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
227981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* free scan result table object memeory */
228981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_memoryFree (pScanResultTable->hOS, (void*)hScanResultTable, sizeof (TScanResultTable));
229981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
230981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
231981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
232981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_UpdateEntry
233981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Update or insert a site data.
234981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
235981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Update a site's data in the table if it already exists, or create an antry if the site doesn't exist.
236981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * If the table is in stable state, will move it to updating state and clear its contents.
237981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
238981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
239981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pBssid - a pointer to the site BSSID
240981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pframe - a pointer to the received frame data
241981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return TI_OK if entry was inseretd or updated successfuly, TI_NOK if table is full
242981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanResultTable_SetStableState
243981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
244981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS scanResultTable_UpdateEntry (TI_HANDLE hScanResultTable, TMacAddr *pBssid, TScanFrameInfo* pFrame)
245981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
246981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = (TScanResultTable*)hScanResultTable;
247981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TSiteEntry          *pSite;
248981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TSsid               tTempSsid;
249981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
250981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE6(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_UpdateEntry: Adding or updating BBSID: %02x:%02x:%02x:%02x:%02x:%02x\n", (*pBssid)[ 0 ], (*pBssid)[ 1 ], (*pBssid)[ 2 ], (*pBssid)[ 3 ], (*pBssid)[ 4 ], (*pBssid)[ 5 ]);
251981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
252981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* check if the table is in stable state */
253981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (TI_TRUE == pScanResultTable->bStable)
254981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
255981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_UpdateEntry: table is stable, clearing table and moving to updating state\n");
256981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* move the table to updating state */
257981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pScanResultTable->bStable = TI_FALSE;
258981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* and clear its contents */
259981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pScanResultTable->uCurrentSiteNumber = 0;
260981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
261981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
262981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* use temporary SSID structure */
2639901d87070be00226f95663cb6c2727f496fab2fDmitry Shmidt    if (NULL == pFrame->parsedIEs->content.iePacket.pSsid)
2649901d87070be00226f95663cb6c2727f496fab2fDmitry Shmidt        return TI_NOK;
265981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    tTempSsid.len = pFrame->parsedIEs->content.iePacket.pSsid->hdr[1];
266981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_memoryCopy(pScanResultTable->hOS, (void *)&(tTempSsid.str[ 0 ]),
267981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                  (void *)&(pFrame->parsedIEs->content.iePacket.pSsid->serviceSetId[ 0 ]),
268981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                  tTempSsid.len);
269981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (MAX_SSID_LEN > tTempSsid.len)
270981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
271981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        tTempSsid.str[ tTempSsid.len ] ='\0';
272981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
273981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
274981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* check if the SSID:BSSID pair already exists in the table */
275981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pSite = scanResultTable_GetBySsidBssidPair (hScanResultTable, &tTempSsid ,pBssid);
276981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (NULL != pSite)
277981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
278981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (TI_NOK != scanResultTable_CheckRxSignalValidity(pScanResultTable, pSite, pFrame->rssi, pFrame->channel))
279981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
280981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE0(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_UpdateEntry: entry already exists, updating\n");
281981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* BSSID exists: update its data */
282981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            scanResultTable_UpdateSiteData (hScanResultTable, pSite, pFrame);
283981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
284981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
285981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
286981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
287981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_UpdateEntry: entry doesn't exist, allocating a new entry\n");
288981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* BSSID doesn't exist: allocate a new entry for it */
289981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pSite = scanResultTbale_AllocateNewEntry (hScanResultTable);
290981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (NULL == pSite)
291981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
292981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE6(pScanResultTable->hReport, REPORT_SEVERITY_WARNING , "scanResultTable_UpdateEntry: can't add site %02d:%02d:%02d:%02d:%02d:%02d"                                  " because table is full\n", pBssid[ 0 ], pBssid[ 1 ], pBssid[ 2 ], pBssid[ 3 ], pBssid[ 4 ], pBssid[ 5 ]);
293981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return TI_NOK;
294981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
295981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
296981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* and update its data */
297981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        scanResultTable_UpdateSiteData (hScanResultTable,
298981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                        pSite,
299981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                        pFrame);
300981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
301981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
302981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
303981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
304981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
305981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
306981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_SetStableState
307981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Moves the table to stable state
308981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
309981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Moves the table to stable state. Also clears the tabel contents if required.
310981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
311981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
312981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return None
313981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanResultTable_UpdateEntry
314981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
315981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid        scanResultTable_SetStableState (TI_HANDLE hScanResultTable)
316981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
317981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = (TScanResultTable*)hScanResultTable;
318981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
319981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE0(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_SetStableState: setting stable state\n");
320981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
321981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* if also asked to clear the table, if it is at Stable mode means that no results were received, clear it! */
322981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (TI_TRUE == pScanResultTable->bStable)
323981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
324981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_SetStableState: also clearing table contents\n");
325981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
326981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pScanResultTable->uCurrentSiteNumber = 0;
327981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
328981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
329981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* set stable state */
330981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->bStable = TI_TRUE;
331981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
332981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
333981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
334981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
335981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_GetFirst
336981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Retrieves the first entry in the table
337981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
338981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Retrieves the first entry in the table
339981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
340981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
341981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return A pointer to the first entry in the table, NULL if the table is empty
342981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanResultTable_GetNext
343981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
344981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTSiteEntry  *scanResultTable_GetFirst (TI_HANDLE hScanResultTable)
345981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
346981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = (TScanResultTable*)hScanResultTable;
347981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
348981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* initialize the iterator to point at the first site */
349981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->uIterator = 0;
350981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
351981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* and return the next entry... */
352981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return scanResultTable_GetNext (hScanResultTable);
353981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
354981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
355981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
356981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_GetNext
357981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Retreives the next entry in the table
358981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
359981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Retreives the next entry in the table, until table is exhusted. A call to scanResultTable_GetFirst
360981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * must preceed a sequence of calls to this function.
361981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
362981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
363981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return A pointer to the next entry in the table, NULL if the table is exhsuted
364981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanResultTable_GetFirst
365981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
366981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTSiteEntry  *scanResultTable_GetNext (TI_HANDLE hScanResultTable)
367981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
368981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = (TScanResultTable*)hScanResultTable;
369981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
370981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* if the iterator points to a site behind current table storage, return error */
371981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pScanResultTable->uCurrentSiteNumber <= pScanResultTable->uIterator)
372981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
373981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return NULL;
374981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
375981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
376981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return &(pScanResultTable->pTable[ pScanResultTable->uIterator++ ]);
377981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
378981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
379981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
380981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_GetByBssid
381981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  retreives an entry according to its SSID and BSSID
382981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
383981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * retreives an entry according to its BSSID
384981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
385981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
386981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pSsid - SSID to search for
387981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pBssid - BSSID to search for
388981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return A pointer to the entry with macthing BSSID, NULL if no such entry was found.
389981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
390981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTSiteEntry  *scanResultTable_GetBySsidBssidPair (TI_HANDLE hScanResultTable, TSsid *pSsid, TMacAddr *pBssid)
391981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
392981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = (TScanResultTable*)hScanResultTable;
393981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32           uIndex;
394981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
395981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE6(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_GetBySsidBssidPair: Searching for SSID  BSSID %02x:%02x:%02x:%02x:%02x:%02x\n", (*pBssid)[ 0 ], (*pBssid)[ 1 ], (*pBssid)[ 2 ], (*pBssid)[ 3 ], (*pBssid)[ 4 ], (*pBssid)[ 5 ]);
396981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
397981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* check all entries in the table */
398981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    for (uIndex = 0; uIndex < pScanResultTable->uCurrentSiteNumber; uIndex++)
399981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
400981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* if the BSSID and SSID match */
401981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (MAC_EQUAL (*pBssid, pScanResultTable->pTable[ uIndex ].bssid) &&
402981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            ((pSsid->len == pScanResultTable->pTable[ uIndex ].ssid.len) &&
403981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt             (0 == os_memoryCompare (pScanResultTable->hOS, &(pSsid->str[ 0 ]),
404981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                     &(pScanResultTable->pTable[ uIndex ].ssid.str[ 0 ]),
405981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                     pSsid->len))))
406981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
407981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE1(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "Entry found at index %d\n", uIndex);
408981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return &(pScanResultTable->pTable[ uIndex ]);
409981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
410981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
411981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
412981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* site wasn't found: return NULL */
413981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE0(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_GetBySsidBssidPair: Entry was not found\n");
414981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return NULL;
415981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
416981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
417981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
418981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanresultTbale_AllocateNewEntry
419981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Allocates an empty entry for a new site
420981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
421981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Function Allocates an empty entry for a new site (and nullfiies required entry fields)
422981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
423981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
424981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return Pointer to the site entry (NULL if the table is full)
425981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
426981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTSiteEntry *scanResultTbale_AllocateNewEntry (TI_HANDLE hScanResultTable)
427981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
428981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = (TScanResultTable*)hScanResultTable;
429981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32           uRsnIndex;
430981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
431981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* if the table is full */
432981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pScanResultTable->uCurrentSiteNumber >= TABLE_ENTRIES_NUMBER)
433981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
434981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTbale_AllocateNewEntry: Table is full, can't allocate new entry\n");
435981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return NULL;
436981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
437981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
438981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE1(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTbale_AllocateNewEntry: New entry allocated at index %d\n", pScanResultTable->uCurrentSiteNumber);
439981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
440981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Nullify new site data */
441981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->pTable[ pScanResultTable->uCurrentSiteNumber ].ssid.len = 0;
442653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pScanResultTable->pTable[ pScanResultTable->uCurrentSiteNumber ].tHtCapabilities.tHdr[0] = 0;
443653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pScanResultTable->pTable[ pScanResultTable->uCurrentSiteNumber ].tHtInformation.tHdr[0] = 0;
444981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    for (uRsnIndex = 0; uRsnIndex < MAX_RSN_IE; uRsnIndex++)
445981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
446981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pScanResultTable->pTable[ pScanResultTable->uCurrentSiteNumber ].pRsnIe[ uRsnIndex ].hdr[ 1 ] = 0;
447981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
448981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
449981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->pTable[ pScanResultTable->uCurrentSiteNumber ].bConsideredForSelect = TI_FALSE;
450981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->pTable[ pScanResultTable->uCurrentSiteNumber ].probeRecv = TI_FALSE;
451981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->pTable[ pScanResultTable->uCurrentSiteNumber ].beaconRecv = TI_FALSE;
452981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
453981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* return the site (and update site count) */
454981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pScanResultTable->uCurrentSiteNumber++;
455981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return &(pScanResultTable->pTable[ pScanResultTable->uCurrentSiteNumber - 1 ]);
456981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
457981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
458981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
459981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_UpdateSiteData
460981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Update a site entry data from a received frame (beacon or probe response)
461981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
462981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Update a site entry data from a received frame (beacon or probe response)
463981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
464981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
465981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pSite - the site entry to update
466981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pFrame - the received frame information
467981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return None
468981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
469981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid scanResultTable_UpdateSiteData (TI_HANDLE hScanResultTable, TSiteEntry *pSite, TScanFrameInfo *pFrame)
470981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
471981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = (TScanResultTable*)hScanResultTable;
472981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    paramInfo_t         param;
473981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
474981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_BSSID (pSite, pFrame);
475981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_BAND (pSite, pFrame);
476981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_BEACON_INTERVAL (pSite, pFrame);
477981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_CAPABILITIES (pSite, pFrame);
478981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_SSID (pScanResultTable, pSite, pFrame);
479981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_PRIVACY (pSite, pFrame);
480981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_RSN_IE (pScanResultTable, pSite, pFrame->parsedIEs->content.iePacket.pRsnIe, pFrame->parsedIEs->content.iePacket.rsnIeLen);
481981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_APSD (pSite, pFrame);
482981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_PREAMBLE (pSite, pFrame);
483981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_AGILITY (pSite, pFrame);
484981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_RSSI (pSite, pFrame);
485981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_SNR (pSite, pFrame);
486981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_RATE (pSite, pFrame);
487981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
488981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    param.paramType = SITE_MGR_OPERATIONAL_MODE_PARAM;
489981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    siteMgr_getParam (pScanResultTable->hSiteMgr, &param);
490981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (param.content.siteMgrDot11OperationalMode == DOT11_G_MODE)
491981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
492981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        UPDATE_SLOT_TIME (pSite, pFrame);
493981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        UPDATE_PROTECTION (pSite, pFrame);
494981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
495981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
496981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    scanResultTable_updateRates (hScanResultTable, pSite, pFrame);
497981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
498981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if ((pFrame->parsedIEs->content.iePacket.pDSParamsSet != NULL)  &&
499981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        (pFrame->parsedIEs->content.iePacket.pDSParamsSet->currChannel != pFrame->channel))
500981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
501acd89e8f547322db23ab0f7c3775082654c4b13bDmitry Shmidt        TRACE2(pScanResultTable->hReport, REPORT_SEVERITY_WARNING, "scanResultTable_UpdateSiteData: wrong channels, radio channel=%d, frame channel=%d\n", pFrame->channel, pFrame->parsedIEs->content.iePacket.pDSParamsSet->currChannel);
502981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
503981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
504981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        UPDATE_CHANNEL (pSite, pFrame , pFrame->channel);
505981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
506981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_BSS_TYPE (pSite, pFrame);
507981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_ATIM_WINDOW (pSite, pFrame);
508981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_AP_TX_POWER (pSite, pFrame);
509981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_QOS (pSite, pFrame);
510981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    UPDATE_BEACON_TIMESTAMP (pScanResultTable, pSite, pFrame);
511981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    scanResultTable_UpdateWSCParams (pSite, pFrame);
512981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
513981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (BEACON == pFrame->parsedIEs->subType)
514981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
515981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* DTIM is only available in beacons */
516981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pSite->bssType == BSS_INFRASTRUCTURE)
517981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
518981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            UPDATE_DTIM_PERIOD (pSite, pFrame);
519981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
520981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
521981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        UPDATE_BEACON_MODULATION (pSite, pFrame);
522981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
523981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* If the BSS type is independent, the beacon & probe modulation are equal,
524981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            It is important to update this field here for dynamic PBCC algorithm compatibility */
525981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pSite->bssType == BSS_INDEPENDENT)
526981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
527981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            UPDATE_PROBE_MODULATION (pSite, pFrame);
528981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
529981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
530981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        UPDATE_BEACON_RECV (pSite);
531981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        UPDATE_FRAME_BUFFER (pScanResultTable, (pSite->beaconBuffer), (pSite->beaconLength), pFrame);
532981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
533981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else if (PROBE_RESPONSE == pFrame->parsedIEs->subType)
534981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
535981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        UPDATE_PROBE_MODULATION (pSite, pFrame);
536981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
537981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* If the BSS type is independent, the beacon & probe modulation are equal,
538981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            It is important to update this field here for dynamic PBCC algorithm compatibility */
539981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pSite->bssType == BSS_INDEPENDENT)
540981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            UPDATE_BEACON_MODULATION (pSite, pFrame);
541981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
542981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        UPDATE_PROBE_RECV (pSite);
543981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        UPDATE_FRAME_BUFFER (pScanResultTable, (pSite->probeRespBuffer), (pSite->probeRespLength), pFrame);
544981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
545981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
546981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
547981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pScanResultTable->hReport, REPORT_SEVERITY_ERROR , "scanResultTable_UpdateSiteData: unknown frame sub type %d\n", pFrame->parsedIEs->subType);
548981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
549981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
550981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
551981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
552981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_updateRates
553981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Update a scan result table entry with rates information
554981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
555981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Called by the function 'updateSiteInfo()' in order to translate the rates received
556981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * in the beacon or probe response to rate used by the driver. Perfoms the following:
557981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    -   Check the rates. validity. If rates are invalid, return
558981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    -   Get the max active rate & max basic rate, if invalid, return
559981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    -   Translate the max active rate and max basic rate from network rates to host rates.
560981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *        The max active & max basic rate are used by the driver from now on in all the processes:
561981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *        (selection, join, transmission, etc....)
562981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
563981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
564981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pSite - a pointer to the site entry to update
565981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pFrame - a pointer to the received frame
566981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return None
567981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanResultTable_UpdateSiteData
568981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
569981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid scanResultTable_updateRates(TI_HANDLE hScanResultTable, TSiteEntry *pSite, TScanFrameInfo *pFrame)
570981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
571981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = (TScanResultTable*)hScanResultTable;
572981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8            maxBasicRate = 0, maxActiveRate = 0;
573981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32           bitMapExtSupp = 0;
574981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
575981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pFrame->parsedIEs->content.iePacket.pRates == NULL)
576981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
577981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pScanResultTable->hReport, REPORT_SEVERITY_ERROR, "scanResultTable_updateRates, pRates=NULL, beacon & probeResp are:\n");
578981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE_INFO_HEX(pScanResultTable->hReport, (TI_UINT8*)pFrame->parsedIEs->content.iePacket.pRates, pFrame->parsedIEs->content.iePacket.pRates->hdr[1]+2);
579981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE_INFO_HEX(pScanResultTable->hReport, (TI_UINT8*)pFrame->parsedIEs->content.iePacket.pRates, pFrame->parsedIEs->content.iePacket.pRates->hdr[1]+2);
580981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return;
581981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
582981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
583981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Update the rate elements */
584981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    maxBasicRate = rate_GetMaxBasicFromStr ((TI_UINT8 *)pFrame->parsedIEs->content.iePacket.pRates->rates,
585981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                            pFrame->parsedIEs->content.iePacket.pRates->hdr[1], maxBasicRate);
586981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    maxActiveRate = rate_GetMaxActiveFromStr ((TI_UINT8 *)pFrame->parsedIEs->content.iePacket.pRates->rates,
587981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                              pFrame->parsedIEs->content.iePacket.pRates->hdr[1], maxActiveRate);
588981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
589981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pFrame->parsedIEs->content.iePacket.pExtRates)
590981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
591981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        maxBasicRate = rate_GetMaxBasicFromStr ((TI_UINT8 *)pFrame->parsedIEs->content.iePacket.pExtRates->rates,
592981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                pFrame->parsedIEs->content.iePacket.pExtRates->hdr[1], maxBasicRate);
593981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        maxActiveRate = rate_GetMaxActiveFromStr ((TI_UINT8 *)pFrame->parsedIEs->content.iePacket.pExtRates->rates,
594981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                  pFrame->parsedIEs->content.iePacket.pExtRates->hdr[1], maxActiveRate);
595981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
596981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
597981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (maxActiveRate == 0)
598981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
599981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        maxActiveRate = maxBasicRate;
600981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
601981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
602981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Now update it from network to host rates */
603981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pSite->maxBasicRate = rate_NetToDrv (maxBasicRate);
604981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pSite->maxActiveRate = rate_NetToDrv (maxActiveRate);
605981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pSite->maxActiveRate == DRV_RATE_INVALID)
606981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE0(pScanResultTable->hReport, REPORT_SEVERITY_ERROR, "scanResultTable_updateRates: Network To Host Rate failure, no active network rate\n");
607981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
608981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pSite->maxBasicRate != DRV_RATE_INVALID)
609981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
610981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pSite->maxActiveRate != DRV_RATE_INVALID)
611981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
612981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pSite->maxActiveRate = TI_MAX (pSite->maxActiveRate, pSite->maxBasicRate);
613981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
614981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    } else { /* in case some vendors don't specify basic rates */
615981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pScanResultTable->hReport, REPORT_SEVERITY_WARNING, "scanResultTable_updateRates: Network To Host Rate failure, no basic network rate");
616981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pSite->maxBasicRate = pSite->maxActiveRate;
617981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
618981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
619981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* build rates bit map */
620981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rate_NetStrToDrvBitmap (&pSite->rateMask.supportedRateMask,
621981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                            pFrame->parsedIEs->content.iePacket.pRates->rates,
622981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                            pFrame->parsedIEs->content.iePacket.pRates->hdr[1]);
623981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rate_NetBasicStrToDrvBitmap (&pSite->rateMask.basicRateMask,
624981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                 pFrame->parsedIEs->content.iePacket.pRates->rates,
625981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                 pFrame->parsedIEs->content.iePacket.pRates->hdr[1]);
626981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
627981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pFrame->parsedIEs->content.iePacket.pExtRates)
628981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
629981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        rate_NetStrToDrvBitmap (&bitMapExtSupp,
630981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                pFrame->parsedIEs->content.iePacket.pExtRates->rates,
631981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                pFrame->parsedIEs->content.iePacket.pExtRates->hdr[1]);
632981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
633981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pSite->rateMask.supportedRateMask |= bitMapExtSupp;
634981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
635981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        rate_NetBasicStrToDrvBitmap (&bitMapExtSupp,
636981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                     pFrame->parsedIEs->content.iePacket.pExtRates->rates,
637981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                     pFrame->parsedIEs->content.iePacket.pExtRates->hdr[1]);
638981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
639981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pSite->rateMask.basicRateMask |= bitMapExtSupp;
640981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
641981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
642981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
643981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
644981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_UpdateWSCParams
645981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Update a scan result table entry with WSC information
646981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
647981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Update a scan result table entry with WSC information
648981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
649981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pSite - a pointer to the site entry to update
650981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pFrame - a pointer to the received frame
651981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return None
652981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanResultTable_UpdateSiteData
653981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
654981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid scanResultTable_UpdateWSCParams (TSiteEntry *pSite, TScanFrameInfo *pFrame)
655981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
656981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* if the IE is not null => the WSC is on - check which method is supported */
657981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pFrame->parsedIEs->content.iePacket.WSCParams != NULL)
658981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
659981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TI_UINT8    *tlvPtr,*endPtr;
660981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TI_UINT16   tlvPtrType,tlvPtrLen,selectedMethod=0;
661981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
662981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        tlvPtr = (TI_UINT8*)pFrame->parsedIEs->content.iePacket.WSCParams->WSCBeaconOrProbIE;
663981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        endPtr = tlvPtr + pFrame->parsedIEs->content.iePacket.WSCParams->hdr[1] - (DOT11_OUI_LEN + 1);
664981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
665981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        do
666981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
667981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            tlvPtrType = WLANTOHS (WLAN_WORD(tlvPtr));
668981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
669981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (tlvPtrType == DOT11_WSC_DEVICE_PASSWORD_ID)
670981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
671981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                tlvPtr+=2;
672981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                tlvPtr+=2;
673981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                selectedMethod = WLANTOHS (WLAN_WORD(tlvPtr));
674981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                break;
675981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
676981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
677981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
678981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                tlvPtr+=2;
679981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                tlvPtrLen = WLANTOHS (WLAN_WORD(tlvPtr));
680981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                tlvPtr+=tlvPtrLen+2;
681981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
682981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        } while ((tlvPtr < endPtr) && (selectedMethod == 0));
683981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
684981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (tlvPtr > endPtr)
685981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
686981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pSite->WSCSiteMode = TIWLN_SIMPLE_CONFIG_OFF;
687981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return;
688981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
689981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
690981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (selectedMethod == DOT11_WSC_DEVICE_PASSWORD_ID_PIN)
691981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pSite->WSCSiteMode = TIWLN_SIMPLE_CONFIG_PIN_METHOD;
692981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else if (selectedMethod == DOT11_WSC_DEVICE_PASSWORD_ID_PBC)
693981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pSite->WSCSiteMode = TIWLN_SIMPLE_CONFIG_PBC_METHOD;
694981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
695981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pSite->WSCSiteMode = TIWLN_SIMPLE_CONFIG_OFF;
696981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
697981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
698981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
699981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pSite->WSCSiteMode = TIWLN_SIMPLE_CONFIG_OFF;
700981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
701981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
702981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
703981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
704981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_CalculateBssidListSize
705981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Calculates the size required for BSSID list storage
706981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
707981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Calculates the size required for BSSID list storage
708981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
709981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
710981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  bAllVarIes - whether to include all variable size IEs
711981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return The total length required
712981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanResultTable_GetBssidList
713981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
714981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_UINT32 scanResultTable_CalculateBssidListSize (TI_HANDLE hScanResultTable, TI_BOOL bAllVarIes)
715981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
716981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable    *pScanResultTable = (TScanResultTable*)hScanResultTable;
717981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32           uSiteIndex, uSiteLength, uLength = 0;
718981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TSiteEntry          *pSiteEntry;
719981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
720981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* set the length of the list header (sites count) */
721981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    uLength = sizeof(OS_802_11_BSSID_LIST_EX) - sizeof(OS_802_11_BSSID_EX);
722981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
723981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* check lengthes of all sites in the table */
724981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    for (uSiteIndex = 0; uSiteIndex < pScanResultTable->uCurrentSiteNumber; uSiteIndex++)
725981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
726981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pSiteEntry = &(pScanResultTable->pTable[ uSiteIndex ]);
727981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* if full list is requested */
728981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (bAllVarIes)
729981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
730981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* set length of all IEs for this site */
731981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            uSiteLength = sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs);
732981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* and add beacon or probe response length */
733981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (TI_TRUE == pSiteEntry->probeRecv)
734981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
735981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                uSiteLength += pSiteEntry->probeRespLength;
736981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
737981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
738981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
739981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                uSiteLength += pSiteEntry->beaconLength;
740981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
741981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
742981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
743981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* partial list is requested */
744981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
745981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
746981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            uSiteLength = (sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs) +
747981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                           (pSiteEntry->ssid.len + 2) + (DOT11_MAX_SUPPORTED_RATES + 2) +
748981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                           + (DOT11_DS_PARAMS_ELE_LEN +2) + pSiteEntry->rsnIeLen);
749981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
750981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* QOS_WME information element */
751981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (pSiteEntry->WMESupported)
752981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
753981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* length of element + header */
754981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                uSiteLength += (DOT11_WME_PARAM_ELE_LEN + 2);
755981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
756981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
757981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
758981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* make sure length is 4 bytes aligned */
759981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (uSiteLength % 4)
760981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
761981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            uSiteLength += (4 - (uSiteLength % 4));
762981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
763981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
764981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* add this site length to the total length */
765981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        uLength += uSiteLength;
766981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
767981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE2(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_calculateBssidListSize: BSSID length=%d on site index %d\n", uSiteLength, uSiteIndex);
768981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
769981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
770981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE1(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_calculateBssidListSize: total length=%d \n", uLength);
771981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
772981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return uLength;
773981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
774981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
775981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
776981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_GetBssidList
777981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Retrieves the site table content
778981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
779981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Retrieves the site table content
780981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
781981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hScanResultTable - handle to the scan result table object
782981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pBssidList - pointer to a buffer large enough to hols the BSSID list
783981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  plength - length of the supplied buffer, will be overwritten with the actual list length
784981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  bAllVarIes - whether to include all variable size IEs
785981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return None
786981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     scanResultTable_CalculateBssidListSize
787981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
788981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS scanResultTable_GetBssidList (TI_HANDLE hScanResultTable,
789981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                        OS_802_11_BSSID_LIST_EX *pBssidList,
790981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                        TI_UINT32 *pLength,
791981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                        TI_BOOL bAllVarIes)
792981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
793981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TScanResultTable        *pScanResultTable = (TScanResultTable*)hScanResultTable;
794981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32                uLength, uSiteIndex, rsnIndex, rsnIeLength, len, firstOFDMloc = 0;
795981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TSiteEntry              *pSiteEntry;
796981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    OS_802_11_BSSID_EX      *pBssid;
797981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    OS_802_11_FIXED_IEs     *pFixedIes;
798981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    OS_802_11_VARIABLE_IEs  *pVarIes;
799981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8                *pData;
800981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
801981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE2(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_GetBssidList called, pBssidList= 0x%p, pLength=%d\n", pBssidList, *pLength);
802981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
803981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* verify the supplied length is enough */
804981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    uLength = scanResultTable_CalculateBssidListSize (hScanResultTable, bAllVarIes);
805981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (uLength > *pLength)
806981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
807981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE2(pScanResultTable->hReport, REPORT_SEVERITY_ERROR , "scanResultTable_GetBssidList: received length %d, insufficient to hold list of size %d\n", *pLength, uLength);
808981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        *pLength = uLength;
809981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
810981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
811981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef TI_DBG
812981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
813981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
814981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE2(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_GetBssidList: supplied length: %d, required length: %d\n", *pLength, uLength);
815981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
816981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
817981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
818981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Nullify number of items in the BSSID list */
819981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pBssidList->NumberOfItems = 0;
820981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
821981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* set length to list header size (only list count) */
822981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    uLength = sizeof(OS_802_11_BSSID_LIST_EX) - sizeof(OS_802_11_BSSID_EX);
823981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
824981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* set data pointer to first item in list */
825981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pData = (TI_UINT8*)&(pBssidList->Bssid[0]);
826981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
827981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    for (uSiteIndex = 0; uSiteIndex < pScanResultTable->uCurrentSiteNumber; uSiteIndex++)
828981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
829981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* set BSSID entry pointer to current location in buffer */
830981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid = (OS_802_11_BSSID_EX*)pData;
831981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
832981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* set pointer to site entry */
833981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pSiteEntry = &(pScanResultTable->pTable[ uSiteIndex ]);
834981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
835981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE7(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_GetBssidList: copying entry at index %d, BSSID %02x:%02x:%02x:%02x:%02x:%02x\n", uSiteIndex, pSiteEntry->bssid[ 0 ], pSiteEntry->bssid[ 1 ], pSiteEntry->bssid[ 2 ], pSiteEntry->bssid[ 3 ], pSiteEntry->bssid[ 4 ], pSiteEntry->bssid[ 5 ]);
836981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
837981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* start copy stuff: */
838981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* MacAddress */
839981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        MAC_COPY (pBssid->MacAddress, pSiteEntry->bssid);
840981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
841981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Capabilities */
842981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid->Capabilities = pSiteEntry->capabilities;
843981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
844981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* SSID */
845981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_memoryZero (pScanResultTable->hOS, &(pBssid->Ssid.Ssid), MAX_SSID_LEN);
846981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pSiteEntry->ssid.len > MAX_SSID_LEN)
847981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
848981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pSiteEntry->ssid.len = MAX_SSID_LEN;
849981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
850981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_memoryCopy (pScanResultTable->hOS,
851981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                       (void *)pBssid->Ssid.Ssid,
852981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                       (void *)pSiteEntry->ssid.str,
853981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                       pSiteEntry->ssid.len);
854981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid->Ssid.SsidLength = pSiteEntry->ssid.len;
855981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
856981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* privacy */
857981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid->Privacy = pSiteEntry->privacy;
858981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
859981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* RSSI */
860981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid->Rssi = pSiteEntry->rssi;
861981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
862981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid->Configuration.Length = sizeof(OS_802_11_CONFIGURATION);
863981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid->Configuration.BeaconPeriod = pSiteEntry->beaconInterval;
864981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid->Configuration.ATIMWindow = pSiteEntry->atimWindow;
865981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid->Configuration.Union.channel = Chan2Freq(pSiteEntry->channel);
866981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
867981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if  (pSiteEntry->bssType == BSS_INDEPENDENT)
868981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pBssid->InfrastructureMode = os802_11IBSS;
869981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
870981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pBssid->InfrastructureMode = os802_11Infrastructure;
871981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Supported Rates */
872981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_memoryZero (pScanResultTable->hOS, (void *)pBssid->SupportedRates, sizeof(OS_802_11_RATES_EX));
873981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        rate_DrvBitmapToNetStr (pSiteEntry->rateMask.supportedRateMask,
874981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                pSiteEntry->rateMask.basicRateMask,
875981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                (TI_UINT8*)pBssid->SupportedRates,
876981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                &len,
877981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                &firstOFDMloc);
878981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
879981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* set network type acording to band and rates */
880981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (RADIO_BAND_2_4_GHZ == pSiteEntry->eBand)
881981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
882981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (firstOFDMloc == len)
883981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
884981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pBssid->NetworkTypeInUse = os802_11DS;
885981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            } else {
886981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pBssid->NetworkTypeInUse = os802_11OFDM24;
887981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
888981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
889981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
890981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
891981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pBssid->NetworkTypeInUse = os802_11OFDM5;
892981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
893981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
894981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* start copy IE's: first nullify length */
895981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid->IELength = 0;
896981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
897981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* copy fixed IEs from site entry */
898981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pFixedIes = (OS_802_11_FIXED_IEs*)&(pBssid->IEs[ pBssid->IELength ]);
899981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_memoryCopy (pScanResultTable->hOS, (void*)pFixedIes->TimeStamp,
900981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                       &(pSiteEntry->tsfTimeStamp[ 0 ]), TIME_STAMP_LEN);
901981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pFixedIes->BeaconInterval = pSiteEntry->beaconInterval;
902981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pFixedIes->Capabilities = pSiteEntry->capabilities;
903981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid->IELength += sizeof(OS_802_11_FIXED_IEs);
904981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
905981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* set pointer for variable length IE's */
906981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pVarIes = (OS_802_11_VARIABLE_IEs*)&(pBssid->IEs[ pBssid->IELength ]);
907981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
908981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (!bAllVarIes)
909981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   /* copy only some variable IEs */
910981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
911981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* copy SSID */
912981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pVarIes->ElementID = SSID_IE_ID;
913981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pVarIes->Length = pSiteEntry->ssid.len;
914981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_memoryCopy (pScanResultTable->hOS,
915981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                           (void *)pVarIes->data,
916981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                           (void *)pSiteEntry->ssid.str,
917981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                           pSiteEntry->ssid.len);
918981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pBssid->IELength += (pVarIes->Length + 2);
919981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
920981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* copy RATES */
921981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pVarIes = (OS_802_11_VARIABLE_IEs*)&(pBssid->IEs[ pBssid->IELength ]);
922981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pVarIes->ElementID = SUPPORTED_RATES_IE_ID;
923981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            rate_DrvBitmapToNetStr (pSiteEntry->rateMask.supportedRateMask,
924981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                    pSiteEntry->rateMask.basicRateMask,
925981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                    (TI_UINT8 *)pVarIes->data,
926981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                    &len,
927981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                    &firstOFDMloc);
928981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pVarIes->Length = len;
929981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pBssid->IELength += (pVarIes->Length + 2);
930981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
931981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* copy DS */
932981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pVarIes = (OS_802_11_VARIABLE_IEs*)&(pBssid->IEs[ pBssid->IELength ]);
933981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pVarIes->ElementID = DS_PARAMETER_SET_IE_ID;
934981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pVarIes->Length = DOT11_DS_PARAMS_ELE_LEN;
935981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_memoryCopy (pScanResultTable->hOS, (void *)pVarIes->data,
936981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                           &(pSiteEntry->channel), DOT11_DS_PARAMS_ELE_LEN);
937981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pBssid->IELength += (pVarIes->Length + 2);
938981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
939981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* copy RSN information elements */
940981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (0 < pSiteEntry->rsnIeLen)
941981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
942981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                rsnIeLength = 0;
943981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                for (rsnIndex=0; rsnIndex < MAX_RSN_IE && pSiteEntry->pRsnIe[ rsnIndex ].hdr[1] > 0; rsnIndex++)
944981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                {
945981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    pVarIes = (OS_802_11_VARIABLE_IEs*)&(pBssid->IEs[ pBssid->IELength + rsnIeLength ]);
946981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    pVarIes->ElementID = pSiteEntry->pRsnIe[ rsnIndex ].hdr[0];
947981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    pVarIes->Length = pSiteEntry->pRsnIe[ rsnIndex ].hdr[1];
948981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    os_memoryCopy (pScanResultTable->hOS, (void *)pVarIes->data,
949981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                   (void *)pSiteEntry->pRsnIe[ rsnIndex ].rsnIeData,
950981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                   pSiteEntry->pRsnIe[ rsnIndex ].hdr[1]);
951981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    rsnIeLength += pSiteEntry->pRsnIe[ rsnIndex ].hdr[1] + 2;
952981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                }
953981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pBssid->IELength += pSiteEntry->rsnIeLen;
954981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
955981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
956981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* QOS_WME/XCC */
957981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (TI_TRUE == pSiteEntry->WMESupported)
958981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
959981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* oui */
960981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                TI_UINT8            ouiWME[3] = {0x50, 0xf2, 0x01};
961981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                dot11_WME_PARAM_t   *pWMEParams;
962981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
963981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* fill in the general element  parameters */
964981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pVarIes =  (OS_802_11_VARIABLE_IEs*)&(pBssid->IEs[ pBssid->IELength ]);
965981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pVarIes->ElementID = DOT11_WME_ELE_ID;
966981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pVarIes->Length = DOT11_WME_PARAM_ELE_LEN;
967981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
968981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* fill in the specific element  parameters */
969981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pWMEParams = (dot11_WME_PARAM_t*)pVarIes;
970981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memoryCopy (pScanResultTable->hOS, (void *)pWMEParams->OUI, ouiWME, 3);
971981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pWMEParams->OUIType = dot11_WME_OUI_TYPE;
972981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pWMEParams->OUISubType = dot11_WME_OUI_SUB_TYPE_PARAMS_IE;
973981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pWMEParams->version = dot11_WME_VERSION;
974981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pWMEParams->ACInfoField = dot11_WME_ACINFO_MASK & pSiteEntry->lastWMEParameterCnt;
975981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
976981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* fill in the data  */
977981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memoryCopy (pScanResultTable->hOS, &(pWMEParams->WME_ACParameteres),
978981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                               &(pSiteEntry->WMEParameters), sizeof(dot11_ACParameters_t));
979981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
980981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
981981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* update the general length */
982981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pBssid->IELength += (pVarIes->Length + 2);
983981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
984981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
985981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else
986981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {   /* Copy all variable IEs */
987981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (pSiteEntry->probeRecv)
988981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
989981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memoryCopy (pScanResultTable->hOS, pVarIes,
990981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                               pSiteEntry->probeRespBuffer, pSiteEntry->probeRespLength);
991981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pBssid->IELength += pSiteEntry->probeRespLength;
992981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
993981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
994981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
995981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_memoryCopy (pScanResultTable->hOS, pVarIes,
996981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                               pSiteEntry->beaconBuffer, pSiteEntry->beaconLength);
997981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pBssid->IELength += pSiteEntry->beaconLength;
998981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
999981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1000981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1001981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* -1 to remove the IEs[1] placeholder in OS_802_11_BSSID_EX which is taken into account in pBssid->IELength */
1002981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pBssid->Length = sizeof(OS_802_11_BSSID_EX) + pBssid->IELength - 1;
1003981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1004981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE2(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_GetBssidList: before alignment fix, IEs length: %d, BSSID length %d\n", pBssid->IELength, pBssid->Length);
1005981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1006981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* make sure length is 4 bytes aligned */
1007981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pBssid->Length % 4)
1008981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1009981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pBssid->Length += (4 - (pBssid->Length % 4));
1010981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1011981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1012981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE2(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_GetBssidList: after alignment fix, IEs length: %d, BSSID length %d\n", pBssid->IELength, pBssid->Length);
1013981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1014981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pData += pBssid->Length;
1015981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        uLength += pBssid->Length;
1016981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1017981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_GetBssidList: current length: %d\n", uLength);
1018981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1019981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1020981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pBssidList->NumberOfItems = pScanResultTable->uCurrentSiteNumber;
1021981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    *pLength = uLength;
1022981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1023981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE2(pScanResultTable->hReport, REPORT_SEVERITY_INFORMATION , "scanResultTable_GetBssidList: total length: %d, number of items: %d\n", uLength, pBssidList->NumberOfItems);
1024981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1025981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1026981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1027981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1028981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1029981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/***********************************************************************
1030981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *                        siteMgr_CheckRxSignalValidity
1031981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt ***********************************************************************
1032981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtDESCRIPTION: Called by the scanResultTable_UpdateEntry when receiving managment frame
1033981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                Find the ste in the site table and validate that the
1034981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                RSSI of that site signal is not lower then -80DB + not lower
1035981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                then the exising site RSSI
1036981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1037981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1038981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtINPUT:      hSiteMgr    -   site mgr handle.
1039981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            rxLevel     -   Rx level the frame received in
1040981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            bssid       -   BSSID of the frame
1041981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1042981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtOUTPUT:
1043981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1044981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtRETURN:     TI_OK / TI_NOK
1045981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1046981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt************************************************************************/
1047981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/**
1048981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     scanResultTable_CheckRxSignalValidity
1049981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  return the state of the table to its state after scan
1050981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1051981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Called by the scanResultTable_UpdateEntry when receiving managment frame
1052981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * validate that the RSSI of that site signal is not lower then then the exising site RSSI.
1053981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * validate that the channel in correct.
1054981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1055981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pScanResultTable - scan result table object
1056981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pSite - entry from the table
1057981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  rssi - RSSI level at which frame was received
1058981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  channel - channel on which the frame was received
1059981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return None
1060981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
1061981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1062981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS scanResultTable_CheckRxSignalValidity(TScanResultTable *pScanResultTable, TSiteEntry *pSite, TI_INT8 rxLevel, TI_UINT8 channel)
1063981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1064981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     if ((channel != pSite->channel) &&
1065981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         (rxLevel < pSite->rssi))
1066981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     {   /* Ignore wrong packets with lower RSSI that were detect as
1067981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         ripples from different channels */
1068981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         TRACE4(pScanResultTable->hReport, REPORT_SEVERITY_WARNING, "scanResultTable_CheckRxSignalValidity:Rx RSSI =%d, on channel=%d, is lower then given RSSI =%d on channel=%d, dropping it.\n", rxLevel, channel, pSite->rssi, pSite->channel);
1069981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         return TI_NOK;
1070981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     }
1071981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1072981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     return TI_OK;
1073981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1074981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1075981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1076981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1077