Home | History | Annotate | Download | only in UtilityAdapter
      1 /*******************************************************************************
      2 **+--------------------------------------------------------------------------+**
      3 **|                                                                          |**
      4 **| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
      5 **|                                                                          |**
      6 **| Licensed under the Apache License, Version 2.0 (the "License");          |**
      7 **| you may not use this file except in compliance with the License.         |**
      8 **| You may obtain a copy of the License at                                  |**
      9 **|                                                                          |**
     10 **|     http://www.apache.org/licenses/LICENSE-2.0                           |**
     11 **|                                                                          |**
     12 **| Unless required by applicable law or agreed to in writing, software      |**
     13 **| distributed under the License is distributed on an "AS IS" BASIS,        |**
     14 **| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
     15 **| See the License for the specific language governing permissions and      |**
     16 **| limitations under the License.                                           |**
     17 **|                                                                          |**
     18 **+--------------------------------------------------------------------------+**
     19 *******************************************************************************/
     20 
     21 //--------------------------------------------------------------------------
     22 // Module:		CTI_Adapter.cpp
     23 //
     24 // Purpose:		implementation of the CTI_WLAN_AdapterAPI class.
     25 //
     26 //--------------------------------------------------------------------------
     27 
     28 #include <string.h>
     29 
     30 #include "CommonAdapter.h"
     31 #ifdef _WINDOWS
     32 #endif
     33 
     34 #ifndef _WINDOWS
     35 	#include "g_tester.h"
     36 #endif
     37 
     38 #include "paramOut.h"
     39 
     40 #ifdef _WINDOWS
     41 #endif
     42 TI_OSCriticalSection	m_csInitAdapter;
     43 
     44 #define TI_WLAN_API_VER   0x00400002
     45 
     46 
     47 
     48 _AdapterItem* CTI_WLAN_AdapterAPI::m_pAdaptersList = NULL;
     49 //////////////////////////////////////////////////////////////////////
     50 // Construction/Destruction
     51 //////////////////////////////////////////////////////////////////////
     52 
     53 CTI_WLAN_AdapterAPI::CTI_WLAN_AdapterAPI(tiCHAR* lpszAdapterName)
     54 {
     55 #ifdef TI_EMBEDDED_SUPPLICANT
     56     m_pSupplicant = NULL;
     57 #endif /* ifdef TI_EMBEDDED_SUPPLICANT */
     58     m_pszAdapterName = NULL;
     59     m_pOSLib = TI_OAL::GetInstance();
     60     m_pRegistry = new TI_OSRegistry; // temporary solution
     61 #ifdef _WINDOWS
     62 #else
     63     m_pIPCmod = new TI_IPC(/*lpszAdapterName*/);
     64 #endif
     65 
     66 #ifdef TI_EMBEDDED_SUPPLICANT
     67     m_bSupplicantInUse = FALSE;
     68 #endif /* ifdef TI_EMBEDDED_SUPPLICANT */
     69 
     70     if (lpszAdapterName)
     71     {
     72         tiUINT32 uSize = 0;
     73 #ifndef  _UNICODE
     74         uSize = strlen( lpszAdapterName );
     75 #else
     76         uSize = wcslen( lpszAdapterName );
     77 #endif
     78         tiUINT32 uBuffLength = sizeof(tiCHAR)*(uSize+1);
     79         m_pszAdapterName = new tiCHAR[uSize+1];
     80 
     81         if (!m_pszAdapterName)
     82             return ;
     83 
     84         memset(m_pszAdapterName, 0, uBuffLength);
     85         memcpy(m_pszAdapterName, lpszAdapterName, uBuffLength - sizeof(tiCHAR) );
     86 #ifndef _WINDOWS
     87         m_pIPCmod->IPC_DeviceOpen(m_pszAdapterName);
     88 #endif
     89     }
     90 }
     91 
     92 /********************************************************************/
     93 tiINT32
     94 CTI_WLAN_AdapterAPI::StartSM( )
     95 {
     96 #ifdef TI_EMBEDDED_SUPPLICANT
     97 	#ifndef _WINDOWS
     98 		m_bSupplicantInUse = TRUE;
     99 		if ( m_pSupplicant == NULL )
    100 			m_pSupplicant = new TI_IPC_Supplicant(m_pszAdapterName);
    101 		else
    102 			return TI_RESULT_FAILED;
    103 	#else
    104 	#endif
    105 #endif /* ifdef TI_EMBEDDED_SUPPLICANT */
    106 
    107     return TI_RESULT_OK;
    108 }
    109 /********************************************************************/
    110 tiINT32
    111 CTI_WLAN_AdapterAPI::StopSM( )
    112 {
    113 #ifdef TI_EMBEDDED_SUPPLICANT
    114 #ifndef _WINDOWS
    115     if (m_bSupplicantInUse && m_pSupplicant != NULL )
    116     {
    117         delete m_pSupplicant;
    118         m_pSupplicant = NULL;
    119         m_bSupplicantInUse = FALSE;
    120     }
    121     else
    122         return TI_RESULT_FAILED;
    123 #else
    124 #endif
    125 #endif
    126     return TI_RESULT_OK;
    127 }
    128 /********************************************************************/
    129 
    130 CTI_WLAN_AdapterAPI::~CTI_WLAN_AdapterAPI()
    131 {
    132 #ifndef _WINDOWS
    133     if ( m_pIPCmod )
    134     {
    135         m_pIPCmod->IPC_DeviceClose();
    136         delete m_pIPCmod;
    137         m_pIPCmod = NULL;
    138     }
    139 #else
    140 #endif
    141     if (m_pRegistry)
    142     {
    143         delete m_pRegistry;
    144         m_pRegistry = NULL;
    145     }
    146 
    147     if ( m_pOSLib )
    148     {
    149         m_pOSLib->FreeInstance();
    150         m_pOSLib = NULL;
    151     }
    152 
    153     if ( m_pszAdapterName )
    154     {
    155         delete [] m_pszAdapterName;
    156         m_pszAdapterName = NULL;
    157     }
    158 #ifdef TI_EMBEDDED_SUPPLICANT
    159 #ifndef _WINDOWS
    160     if (m_pSupplicant != NULL )
    161     {
    162         delete m_pSupplicant;
    163         m_pSupplicant = NULL;
    164     }
    165 #endif
    166 #endif
    167 }
    168 
    169 /********************************************************************/
    170 
    171 CTI_WLAN_AdapterAPI*
    172 CTI_WLAN_AdapterAPI::GetTIWLANAdapter(tiCHAR* lpszAdapterName, tiBOOL bForce)
    173 {
    174 
    175     m_csInitAdapter.Enter();
    176 
    177     if ( bForce )
    178     {
    179         CTI_WLAN_AdapterAPI* pAdapter = new CTI_WLAN_AdapterAPI(lpszAdapterName);
    180         m_csInitAdapter.Leave();
    181         return pAdapter;
    182     }
    183 
    184     _AdapterItem* pCurrentItem = m_pAdaptersList;
    185 
    186     BOOL  bNULL = FALSE;
    187     if (!lpszAdapterName)
    188     {
    189         bNULL = TRUE;
    190         m_csInitAdapter.Leave();
    191         return NULL;
    192     }
    193 
    194     while( pCurrentItem )
    195     {
    196         tiINT32 iResult = -1;
    197 
    198         if ( !bNULL )
    199 #ifndef  _UNICODE
    200             iResult = strcmp(pCurrentItem->m_pAdapterName, lpszAdapterName );
    201 #else
    202         iResult = wcscmp(pCurrentItem->m_pAdapterName, lpszAdapterName );
    203 #endif
    204         else
    205         {
    206             if ( !pCurrentItem->m_pAdapterName )
    207                 iResult = 0;
    208         }
    209 
    210         if (!iResult)
    211         {
    212             pCurrentItem->AddRef();
    213             m_csInitAdapter.Leave();
    214             return pCurrentItem->m_dwAdapterID;
    215         }
    216 
    217         pCurrentItem = pCurrentItem->m_pNextItem;
    218     }
    219 
    220     pCurrentItem = new _AdapterItem;
    221 
    222     pCurrentItem->m_pNextItem = m_pAdaptersList;
    223 
    224     if ( m_pAdaptersList )
    225         m_pAdaptersList->m_pPrevItem = pCurrentItem;
    226 
    227     m_pAdaptersList = pCurrentItem;
    228 
    229     if (lpszAdapterName)
    230     {
    231         tiUINT32 uSize = 0;
    232 #ifndef  _UNICODE
    233         uSize = strlen( lpszAdapterName );
    234 #else
    235         uSize = wcslen( lpszAdapterName );
    236 #endif
    237         tiUINT32 uBuffLenght = sizeof(tiCHAR)*(uSize+1);
    238         tiCHAR* pBuff = new tiCHAR[uSize+1];
    239 
    240         if (!pBuff)
    241         {
    242             m_csInitAdapter.Leave();
    243             return NULL;
    244         }
    245 
    246         memset(pBuff, 0, uBuffLenght);
    247         memcpy(pBuff, lpszAdapterName, uBuffLenght - sizeof(tiCHAR) );
    248         m_pAdaptersList->m_pAdapterName = pBuff;
    249     }
    250 
    251     pCurrentItem->m_dwAdapterID = new CTI_WLAN_AdapterAPI(lpszAdapterName);
    252 
    253     m_csInitAdapter.Leave();
    254     return m_pAdaptersList->m_dwAdapterID;
    255 }
    256 
    257 /********************************************************************/
    258 
    259 tiINT32
    260 CTI_WLAN_AdapterAPI::FreeTIWLANAdapter(CTI_WLAN_AdapterAPI* pAdapter, tiBOOL bForce )
    261 {
    262     m_csInitAdapter.Enter();
    263 
    264 #ifndef _WINDOWS
    265     if ( bForce && pAdapter)
    266     {
    267         delete pAdapter;
    268         pAdapter = NULL;
    269         m_csInitAdapter.Leave();
    270         return TI_RESULT_OK;
    271     }
    272 #else
    273 #endif
    274     if (
    275 #ifndef _WINDOWS
    276 		!pAdapter ||
    277 #endif
    278     // TRS:PGK -- If there is no adapter list, exit.  Nothing to free.
    279 		!m_pAdaptersList)
    280     {
    281         m_csInitAdapter.Leave();
    282         return TI_RESULT_FAILED;
    283     }
    284 
    285     _AdapterItem* pCurrentItem = m_pAdaptersList;
    286     while( pCurrentItem )
    287     {
    288 
    289         if (pCurrentItem->m_dwAdapterID == pAdapter )
    290         {
    291             pCurrentItem->DecRef();
    292             if ( !pCurrentItem->m_uRef )
    293             {
    294                 _AdapterItem* pPrev = pCurrentItem->m_pPrevItem;
    295                 if ( pPrev )
    296                     pPrev->m_pNextItem = pCurrentItem->m_pNextItem;
    297 
    298                 _AdapterItem* pNext = pCurrentItem->m_pNextItem;
    299                 if ( pNext )
    300                     pNext->m_pPrevItem = pCurrentItem->m_pPrevItem;
    301 
    302                 if ( !pNext && !pPrev )
    303                     m_pAdaptersList = NULL;
    304 
    305                 if ( pCurrentItem->m_pAdapterName )
    306                     delete [] pCurrentItem->m_pAdapterName;
    307 
    308                 delete pCurrentItem->m_dwAdapterID;
    309                 delete pCurrentItem;
    310 
    311             }
    312 
    313             m_csInitAdapter.Leave();
    314             return TI_RESULT_OK;
    315         }
    316 
    317         pCurrentItem = pCurrentItem->m_pNextItem;
    318     }
    319 
    320     if ( pAdapter )
    321         delete pAdapter;
    322 
    323     m_csInitAdapter.Leave();
    324     return TI_RESULT_FAILED;
    325 }
    326 
    327 /********************************************************************/
    328 
    329 tiINT32
    330 CTI_WLAN_AdapterAPI::CheckObjectMemory(tiVOID *pObj, tiUINT32 uSizeObj)
    331 {
    332     if ( !pObj || !uSizeObj )
    333         return FALSE;
    334 
    335     return !(m_pOSLib->TIIsBadWritePtr(pObj, uSizeObj));
    336 }
    337 /***************************************************************************************/
    338 tiINT32
    339 CTI_WLAN_AdapterAPI::tiMiniportSetInformation(tiUINT32 dwInfoCode,tiVOID* lpInfoBuffer, tiUINT32* lpdwCbInfoBuffer)
    340 {
    341     tiUINT32    dwRet       = 0;
    342     tiUINT32    dwLength    = *lpdwCbInfoBuffer + sizeof(dwInfoCode);
    343     tiUINT8*    lpBuffer    = new tiUINT8[dwLength];
    344     tiUINT32 dwRetSize;
    345 
    346     if ( !lpBuffer )
    347         return TI_RESULT_NOT_ENOUGH_MEMORY;
    348 
    349     memcpy(lpBuffer, &dwInfoCode, sizeof(dwInfoCode));
    350     memcpy((tiUINT8*)lpBuffer + sizeof(dwInfoCode), lpInfoBuffer, *lpdwCbInfoBuffer);
    351 
    352     dwRet = tiIoCtrl(TIWLN_IOCTL_OID_SET_INFORMATION,lpBuffer, dwLength,NULL,0,&dwRetSize);
    353 
    354     delete [] lpBuffer;
    355     return dwRet;
    356 }
    357 /********************************************************************/
    358 tiINT32
    359 CTI_WLAN_AdapterAPI::tiIoCtrl(tiUINT32 dwIoCtrl, tiVOID* pInBuffer, tiUINT32 uInBufferSize,
    360                               tiVOID* pOutBuffer, tiUINT32 dwOutBufferSize, tiUINT32* dwBytesReturned)
    361 {
    362 	#ifdef TI_EMBEDDED_SUPPLICANT
    363 		if ( m_bSupplicantInUse )
    364 		{
    365 			#ifdef _WINDOWS
    366 			#endif
    367 				switch (dwIoCtrl)
    368 				{
    369 					case TIWLN_802_11_SSID_SET:
    370 					case TIWLN_802_11_INFRASTRUCTURE_MODE_SET:
    371 					case TIWLN_802_11_AUTHENTICATION_MODE_SET:
    372 					case TIWLN_802_11_WEP_STATUS_SET:
    373 					case TIWLN_802_11_PSK_SET:
    374 					case TIWLN_802_11_EAP_TYPE_SET:
    375 					case TIWLN_802_11_USER_ID_SET:
    376 					case TIWLN_802_11_USER_PASSWORD_SET:
    377 					case TIWLN_802_11_CERT_PARAMS_SHA1_SET:
    378 					case TIWLN_802_11_CERT_PARAMS_FILE_NAME_SET:
    379 					case TIWLN_802_11_KEY_TYPE_SET:
    380 					case TIWLN_802_11_EXC_NETWORK_EAP_SET:
    381 					case TIWLN_802_11_EXC_CONFIGURATION_SET:
    382 					case TIWLN_802_11_ADD_WEP:
    383 					case TIWLN_802_11_WPA_OPTIONS_SET:
    384 					#ifdef _WINDOWS
    385 					#else
    386 						return m_pSupplicant->SendDataProxy(dwIoCtrl, pInBuffer, uInBufferSize);
    387 					#endif
    388 				}
    389 				#ifdef _WINDOWS
    390 				#endif
    391 				}
    392 	#endif /* ifdef TI_EMBEDDED_SUPPLICANT */
    393 #ifdef _WINDOWS
    394 #else
    395     tiUINT32 bRet = m_pIPCmod->IPC_DeviceIoControl( dwIoCtrl, pInBuffer, uInBufferSize,
    396         pOutBuffer, dwOutBufferSize, dwBytesReturned);
    397     return bRet;
    398 #endif
    399 }
    400 
    401 /********************************************************************/
    402 
    403 tiINT32
    404 CTI_WLAN_AdapterAPI::GetStatistics(TIWLN_STATISTICS* ptiStatistics)
    405 {
    406     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    407     tiUINT32 dwRetSize;
    408 
    409     if (CheckObjectMemory(ptiStatistics, sizeof(TIWLN_STATISTICS)))
    410     {
    411         dwRetValue = tiIoCtrl(TIWLN_802_11_STATISTICS, NULL, 0, ptiStatistics, sizeof(TIWLN_STATISTICS),&dwRetSize);
    412     }
    413     return dwRetValue;
    414 }
    415 
    416 /********************************************************************/
    417 
    418 tiINT32
    419 CTI_WLAN_AdapterAPI::GetTxStatistics(TIWLN_TX_STATISTICS* ptiTxStatistics, UINT32 clearStatsFlag)
    420 {
    421     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    422     tiUINT32 dwRetSize;
    423 
    424     if ( ptiTxStatistics )
    425     {
    426         dwRetValue = tiIoCtrl(TIWLN_802_11_TX_STATISTICS,
    427             &clearStatsFlag, sizeof(UINT32),
    428             ptiTxStatistics, sizeof(TIWLN_TX_STATISTICS),&dwRetSize);
    429     }
    430 
    431     return dwRetValue;
    432 }
    433 
    434 /********************************************************************/
    435 tiINT32
    436 CTI_WLAN_AdapterAPI::GetBSSIDList(OS_802_11_BSSID_LIST_EX** ppBSSIDlist)
    437 {
    438     tiUINT32    nSize = 0;
    439     if ( ppBSSIDlist == NULL)
    440         return TI_RESULT_FAILED;
    441 
    442     tiINT32 bRet = GetVariableLengthOID(TIWLN_802_11_BSSID_LIST, (tiVOID**)ppBSSIDlist, &nSize, 10000);
    443 
    444     return bRet;
    445 }
    446 
    447 /********************************************************************/
    448 tiINT32
    449 CTI_WLAN_AdapterAPI::GetFullBSSIDList(OS_802_11_BSSID_LIST_EX** ppBSSIDlist)
    450 {
    451     tiUINT32    nSize = 0;
    452     if ( ppBSSIDlist == NULL)
    453         return TI_RESULT_FAILED;
    454 
    455     tiINT32 bRet = GetVariableLengthOID(TIWLN_802_11_FULL_BSSID_LIST, (tiVOID**)ppBSSIDlist, &nSize, 10000);
    456 
    457     return bRet;
    458 }
    459 
    460 /********************************************************************/
    461 tiINT32
    462 CTI_WLAN_AdapterAPI::GetCurrentAddress( OS_802_11_MAC_ADDRESS*    pCurrentAddr)
    463 {
    464     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    465     tiUINT32 dwRetSize;
    466 
    467     if (CheckObjectMemory(pCurrentAddr, sizeof (OS_802_11_MAC_ADDRESS)) )
    468     {
    469         dwRetValue = tiIoCtrl(TIWLN_802_3_CURRENT_ADDRESS, NULL, 0, pCurrentAddr, sizeof( OS_802_11_MAC_ADDRESS ), &dwRetSize);
    470     }
    471     return dwRetValue;
    472 }
    473 /********************************************************************/
    474 tiINT32
    475 CTI_WLAN_AdapterAPI::GetDesiredSSID( OS_802_11_SSID*  pDesiredSSID )
    476 {
    477     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    478     tiUINT32 dwRetSize;
    479 
    480     if (CheckObjectMemory(pDesiredSSID, sizeof(OS_802_11_SSID)) )
    481     {
    482         dwRetValue = tiIoCtrl(TIWLN_802_11_SSID_GET, NULL, 0, pDesiredSSID, sizeof(OS_802_11_SSID),&dwRetSize);
    483     }
    484 
    485     return dwRetValue;
    486 }
    487 
    488 /********************************************************************/
    489 
    490 tiINT32
    491 CTI_WLAN_AdapterAPI::GetCurrentSSID( OS_802_11_SSID*  pCurrentSSID )
    492 {
    493     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    494     tiUINT32 dwRetSize;
    495 
    496     if (CheckObjectMemory(pCurrentSSID, sizeof(OS_802_11_SSID)) )
    497     {
    498         dwRetValue = tiIoCtrl(TIWLN_802_11_SSID_GET, NULL, 0, pCurrentSSID, sizeof(OS_802_11_SSID),&dwRetSize);
    499     }
    500 
    501     return dwRetValue;
    502 }
    503 
    504 /********************************************************************/
    505 
    506 tiINT32 CTI_WLAN_AdapterAPI::SetSSID( tiUINT8*  pszSSIDname )
    507 {
    508 #ifdef _WINDOWS     // TRS:WDK
    509 #endif
    510     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    511     tiUINT32 dwRetSize;
    512 
    513     if ( pszSSIDname && m_pRegistry )
    514     {
    515         tiUINT32    uSize = 0;
    516 
    517 #ifdef _WINDOWS
    518 #else  // __LINUX__
    519 #ifdef  _UNICODE
    520         uSize = wcslen( pszSSIDname );
    521 #else
    522         uSize = strlen((char *)pszSSIDname);
    523 #endif
    524         tiUINT32 dwNameSize = 0;
    525 
    526         if ( uSize <= MAX_SSID_LENGTH )
    527             dwNameSize = uSize * sizeof(tiUINT8);
    528         else
    529             dwNameSize = MAX_SSID_LENGTH * sizeof(tiUINT8);
    530 #endif
    531 
    532         if (pszSSIDname != NULL)
    533         {
    534 
    535             OS_802_11_SSID ssid;
    536             memset( &ssid, 0, sizeof(OS_802_11_SSID) );
    537 
    538 #ifdef _WINDOWS     // TRS:WDK
    539 #else // __LINUX__
    540 #ifdef  _UNICODE
    541             wcstombs((tiCHAR* )ssid.Ssid, pszSSIDname, MAX_SSID_LENGTH);
    542             ssid.SsidLength = MAX_SSID_LENGTH;
    543 #else
    544             memcpy((tiCHAR*)ssid.Ssid, pszSSIDname, dwNameSize );
    545             ssid.SsidLength = dwNameSize;
    546 #endif
    547 #endif
    548 
    549             dwRetValue = tiIoCtrl(TIWLN_802_11_SSID_SET, &ssid, sizeof(OS_802_11_SSID),NULL, 0,&dwRetSize);
    550 #ifdef _WINDOWS
    551 #endif
    552         }
    553     }
    554 
    555     return dwRetValue;
    556 }
    557 
    558 /********************************************************************/
    559 
    560 tiINT32
    561 CTI_WLAN_AdapterAPI::SetBSSType( OS_802_11_NETWORK_MODE   uBSSType )
    562 {
    563     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    564     tiUINT32 dwRetSize;
    565     dwRetValue = tiIoCtrl(TIWLN_802_11_INFRASTRUCTURE_MODE_SET, &uBSSType, sizeof(OS_802_11_NETWORK_MODE),NULL, 0,&dwRetSize);
    566 #ifdef _WINDOWS
    567 #endif
    568     return dwRetValue;
    569 }
    570 
    571 /********************************************************************/
    572 
    573 tiINT32
    574 CTI_WLAN_AdapterAPI::GetBSSType( OS_802_11_NETWORK_MODE*  puBSSType )
    575 {
    576     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    577     tiUINT32 dwRetSize;
    578     if (CheckObjectMemory( puBSSType, sizeof(OS_802_11_NETWORK_MODE)))
    579     {
    580         dwRetValue = tiIoCtrl(TIWLN_802_11_INFRASTRUCTURE_MODE_GET, NULL, 0, puBSSType, sizeof(OS_802_11_NETWORK_MODE),&dwRetSize);
    581     }
    582     return dwRetValue;
    583 }
    584 
    585 /********************************************************************/
    586 tiINT32
    587 CTI_WLAN_AdapterAPI::SetEAPType( OS_802_11_EAP_TYPES  uEAPType )
    588 {
    589     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    590     tiUINT32 dwRetSize;
    591     if (uEAPType)
    592     {
    593         dwRetValue = tiIoCtrl(TIWLN_802_11_EAP_TYPE_SET, &uEAPType, sizeof(OS_802_11_EAP_TYPES),NULL, 0,&dwRetSize);
    594     }
    595     return dwRetValue;
    596 }
    597 
    598 /********************************************************************/
    599 tiINT32
    600 CTI_WLAN_AdapterAPI::SetEAPTypeDriver( OS_802_11_EAP_TYPES  uEAPType )
    601 {
    602     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    603     tiUINT32 dwRetSize;
    604 
    605     dwRetValue = tiIoCtrl(TIWLN_802_11_EAP_TYPE_DRIVER_SET, &uEAPType, sizeof(OS_802_11_EAP_TYPES),NULL,0,&dwRetSize);
    606 
    607     return dwRetValue;
    608 }
    609 
    610 /********************************************************************/
    611 tiINT32
    612 CTI_WLAN_AdapterAPI::GetEAPType( OS_802_11_EAP_TYPES* puEAPType )
    613 {
    614     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    615     tiUINT32 dwRetSize;
    616 
    617     dwRetValue = tiIoCtrl(TIWLN_802_11_EAP_TYPE_GET, NULL, 0, puEAPType, sizeof(OS_802_11_ENCRYPTION_STATUS),&dwRetSize);
    618 
    619     return dwRetValue;
    620 }
    621 /********************************************************************/
    622 tiINT32
    623 CTI_WLAN_AdapterAPI::SetEncryptionType( OS_802_11_ENCRYPTION_TYPES uEncryptType )
    624 {
    625     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    626     tiUINT32 dwRetSize;
    627 
    628     OS_802_11_ENCRYPTION_STATUS uEncryptStatus = os802_11WEPDisabled;
    629 
    630     switch( uEncryptType )
    631     {
    632     case    OS_ENCRYPTION_TYPE_NONE:
    633         uEncryptStatus = os802_11WEPDisabled;
    634         break;
    635     case    OS_ENCRYPTION_TYPE_WEP:
    636         uEncryptStatus = os802_11Encryption1Enabled;
    637         break;
    638     case    OS_ENCRYPTION_TYPE_TKIP:
    639         uEncryptStatus = os802_11Encryption2Enabled;
    640         break;
    641     case    OS_ENCRYPTION_TYPE_AES:
    642         uEncryptStatus = os802_11Encryption3Enabled;
    643         break;
    644     default:
    645         uEncryptStatus = os802_11WEPDisabled;
    646     }
    647 
    648     dwRetValue = tiIoCtrl(TIWLN_802_11_WEP_STATUS_SET, &uEncryptStatus, sizeof(OS_802_11_ENCRYPTION_STATUS),NULL, 0,&dwRetSize);
    649 
    650     return dwRetValue;
    651 }
    652 
    653 /********************************************************************/
    654 
    655 tiINT32
    656 CTI_WLAN_AdapterAPI::GetEncryptionType( OS_802_11_ENCRYPTION_TYPES* puEncryptType )
    657 {
    658     tiUINT32 dwRetValue = TI_RESULT_INVALID_PARAMETER;
    659     tiUINT32 dwRetSize;
    660 
    661     if ( puEncryptType && CheckObjectMemory( puEncryptType, sizeof(OS_802_11_ENCRYPTION_TYPES)) )
    662     {
    663         OS_802_11_ENCRYPTION_STATUS uEncryptStatus;
    664         dwRetValue = tiIoCtrl(TIWLN_802_11_WEP_STATUS_GET, NULL, 0, &uEncryptStatus, sizeof(OS_802_11_ENCRYPTION_STATUS),&dwRetSize);
    665 
    666         if ( dwRetValue == TI_RESULT_OK )
    667         {
    668             switch( uEncryptStatus )
    669             {
    670             case    os802_11WEPDisabled:
    671                 *puEncryptType = OS_ENCRYPTION_TYPE_NONE;
    672                 break;
    673             case    os802_11Encryption1Enabled:
    674                 *puEncryptType =  OS_ENCRYPTION_TYPE_WEP;
    675                 break;
    676             case    os802_11Encryption2Enabled:
    677                 *puEncryptType = OS_ENCRYPTION_TYPE_TKIP;
    678                 break;
    679             case    os802_11Encryption3Enabled:
    680                 *puEncryptType =  OS_ENCRYPTION_TYPE_AES;
    681                 break;
    682             default:
    683                 dwRetValue = TI_RESULT_FAILED;
    684             } // switch
    685         }
    686     } // end of memory check
    687 
    688     return dwRetValue;
    689 }
    690 /********************************************************************/
    691 tiINT32
    692 CTI_WLAN_AdapterAPI::SetCredentials( tiCHAR* pszUserName, tiCHAR* pszPassword )
    693 {
    694     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    695     tiUINT32 dwRetSize;
    696 
    697     if ( pszUserName != NULL )
    698     {
    699         tiUINT32    uSize = 0;
    700 
    701 #ifdef  _UNICODE
    702         uSize = wcslen( pszUserName );
    703 #else
    704         uSize = strlen(pszUserName);
    705 #endif
    706         tiUINT32 dwNameSize = uSize * sizeof(tiCHAR);
    707 
    708         if ( CheckObjectMemory( pszUserName, dwNameSize ))
    709             dwRetValue = tiIoCtrl(TIWLN_802_11_USER_ID_SET, pszUserName, dwNameSize + sizeof(tiCHAR),NULL, 0,&dwRetSize);
    710     }
    711     else
    712         dwRetValue = tiIoCtrl(TIWLN_802_11_USER_ID_SET, NULL, 0l,NULL, 0,&dwRetSize);
    713 
    714 
    715     if ( pszPassword != NULL )
    716     {
    717         tiUINT32    uSize = 0;
    718 
    719 #ifdef  _UNICODE
    720         uSize = wcslen( pszPassword );
    721 #else
    722         uSize = strlen(pszPassword);
    723 #endif
    724         tiUINT32 dwNameSize = uSize * sizeof(tiCHAR);
    725 
    726         if ( CheckObjectMemory( pszPassword, dwNameSize ))
    727             dwRetValue = tiIoCtrl(TIWLN_802_11_USER_PASSWORD_SET, pszPassword, dwNameSize + sizeof(tiCHAR),NULL, 0,&dwRetSize);
    728     }
    729     else
    730         dwRetValue = tiIoCtrl(TIWLN_802_11_USER_PASSWORD_SET, NULL, 0l,NULL, 0,&dwRetSize);
    731 
    732     return dwRetValue;
    733 }
    734 /********************************************************************/
    735 tiINT32
    736 CTI_WLAN_AdapterAPI::SetPSK( tiCHAR* pszPSK )
    737 {
    738     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    739     tiUINT32 dwRetSize;
    740 
    741     if ( pszPSK != NULL )
    742     {
    743         tiUINT32    uSize = 0;
    744 
    745 #ifdef  _UNICODE
    746         uSize = wcslen( pszPSK );
    747 #else
    748         uSize = strlen(pszPSK);
    749 #endif
    750         tiUINT32 dwNameSize = uSize * sizeof(tiCHAR);
    751 
    752         if ( CheckObjectMemory( pszPSK, dwNameSize ))
    753             dwRetValue = tiIoCtrl(TIWLN_802_11_PSK_SET, pszPSK, dwNameSize + sizeof(tiCHAR),NULL, 0,&dwRetSize);
    754     }
    755     else
    756         dwRetValue = tiIoCtrl(TIWLN_802_11_PSK_SET, NULL, 0l,NULL, 0,&dwRetSize);
    757 
    758     return dwRetValue;
    759 }
    760 /********************************************************************/
    761 tiINT32
    762 CTI_WLAN_AdapterAPI::SetCertParamsSHA1( TI_SHA1_HASH* pSha1Hash, tiBOOL bValidateServerCert )
    763 {
    764     tiUINT32 dwRetValue = TI_RESULT_INVALID_PARAMETER;
    765     tiUINT32 dwRetSize;
    766 
    767     if ( pSha1Hash && CheckObjectMemory(pSha1Hash, sizeof(TI_SHA1_HASH)))
    768     {
    769         tiUINT32  uSize = sizeof(TI_SHA1_HASH) + sizeof(tiBOOL);
    770         tiUINT8*  pByte = new tiUINT8[uSize];
    771         if ( pByte == NULL )
    772             return TI_RESULT_NOT_ENOUGH_MEMORY;
    773 
    774         tiUINT8* pBufferTmp = pByte;
    775 
    776         memset(pByte, 0, uSize);
    777         memcpy(pBufferTmp, &bValidateServerCert, sizeof(tiBOOL));
    778         pBufferTmp += sizeof(tiBOOL);
    779         memcpy(pBufferTmp, pSha1Hash, sizeof(TI_SHA1_HASH));
    780 
    781         dwRetValue = tiIoCtrl(TIWLN_802_11_CERT_PARAMS_SHA1_SET, pByte, uSize,NULL, 0,&dwRetSize);
    782 
    783         delete [] pByte;
    784     }
    785     return dwRetValue;
    786 }
    787 /********************************************************************/
    788 tiINT32
    789 CTI_WLAN_AdapterAPI::SetCertParamsFileName( tiCHAR* pszFileName, tiBOOL bValidateServerCert )
    790 {
    791     tiUINT32 dwRetValue = TI_RESULT_INVALID_PARAMETER;
    792     tiUINT32 dwRetSize;
    793 
    794     if ( pszFileName != NULL )
    795     {
    796         tiUINT32    uSize = 0;
    797 
    798 #ifdef  _UNICODE
    799         uSize = wcslen( pszFileName );
    800 #else
    801         uSize = strlen(pszFileName);
    802 #endif
    803         tiUINT32 dwSize = (uSize + 1) * sizeof(tiCHAR) + sizeof(tiBOOL);
    804 
    805         tiUINT8*  pByte = new tiUINT8[dwSize];
    806 
    807         if ( pByte == NULL )
    808             return TI_RESULT_NOT_ENOUGH_MEMORY;
    809 
    810         tiUINT8* pBufferTmp = pByte;
    811 
    812         memset(pByte, 0, dwSize);
    813         memcpy(pBufferTmp, &bValidateServerCert, sizeof(tiBOOL));
    814         pBufferTmp += sizeof(tiBOOL);
    815         memcpy(pBufferTmp, pszFileName, uSize);
    816 
    817         dwRetValue = tiIoCtrl(TIWLN_802_11_CERT_PARAMS_FILE_NAME_SET, pByte, dwSize,NULL, 0,&dwRetSize);
    818 
    819         delete [] pByte;
    820     }
    821     return dwRetValue;
    822 }
    823 /********************************************************************/
    824 tiINT32
    825 CTI_WLAN_AdapterAPI::AddWEPKey( OS_802_11_WEP*    pWEP )
    826 {
    827     tiUINT32 dwRetValue = TI_RESULT_INVALID_PARAMETER;
    828     tiUINT32 dwRetSize;
    829 
    830     if (CheckObjectMemory(pWEP, sizeof(OS_802_11_WEP)))
    831     {
    832         dwRetValue = tiIoCtrl(TIWLN_802_11_ADD_WEP, pWEP, sizeof(OS_802_11_WEP),NULL, 0,&dwRetSize);
    833 
    834     }
    835     return dwRetValue;
    836 }
    837 /********************************************************************/
    838 tiINT32
    839 CTI_WLAN_AdapterAPI::RemoveWEPKey( tiUINT32 uKeyIndex )
    840 {
    841     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    842     tiUINT32 dwRetSize;
    843 
    844     dwRetValue = tiIoCtrl(TIWLN_802_11_REMOVE_WEP, &uKeyIndex, sizeof(tiUINT32),NULL, 0,&dwRetSize);
    845     return dwRetValue;
    846 }
    847 /********************************************************************/
    848 tiINT32
    849 CTI_WLAN_AdapterAPI::SetWPAOptions( tiUINT32 fWPA_options)
    850 {
    851     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    852     tiUINT32 dwRetSize;
    853 
    854     dwRetValue = tiIoCtrl(TIWLN_802_11_WPA_OPTIONS_SET, &fWPA_options, sizeof(tiUINT32),NULL, 0,&dwRetSize);
    855     return dwRetValue;
    856 }
    857 /********************************************************************/
    858 tiINT32 CTI_WLAN_AdapterAPI::GetWPAOptions( tiUINT32 * fWPA_options)
    859 {
    860     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    861     tiUINT32 dwRetSize;
    862 
    863     if (CheckObjectMemory(fWPA_options, sizeof(tiUINT32)))
    864     {
    865         dwRetValue = tiIoCtrl(TIWLN_802_11_WPA_OPTIONS_GET, NULL, 0, fWPA_options, sizeof(tiUINT32),&dwRetSize);
    866     }
    867     return dwRetValue;
    868 }
    869 
    870 /********************************************************************/
    871 tiINT32
    872 CTI_WLAN_AdapterAPI::SetPMKIDmap(OS_802_11_PMKID*  pPMKIDMap)
    873 {
    874     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    875     tiUINT32 dwRetSize;
    876 
    877     if (CheckObjectMemory(pPMKIDMap, pPMKIDMap->Length))
    878     {
    879         dwRetValue = tiIoCtrl(TIWLN_802_11_PMKID_SET, pPMKIDMap, pPMKIDMap->Length,NULL, 0,&dwRetSize);
    880     }
    881 
    882     return dwRetValue;
    883 }
    884 /********************************************************************/
    885 tiINT32
    886 CTI_WLAN_AdapterAPI::AddKey( OS_802_11_KEY*   pKey )
    887 {
    888     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    889     tiUINT32 dwRetSize;
    890 
    891     if (CheckObjectMemory(pKey, pKey->Length))
    892     {
    893         dwRetValue = tiIoCtrl(TIWLN_802_11_ADD_KEY, pKey, pKey->Length,NULL, 0,&dwRetSize);
    894     }
    895     return dwRetValue;
    896 }
    897 /********************************************************************/
    898 tiINT32
    899 CTI_WLAN_AdapterAPI::RemoveKey( OS_802_11_REMOVE_KEY* pRemoveKey  )
    900 {
    901     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    902     tiUINT32 dwRetSize;
    903 
    904     if (CheckObjectMemory(pRemoveKey, sizeof(OS_802_11_REMOVE_KEY)))
    905     {
    906         dwRetValue = tiIoCtrl(TIWLN_802_11_REMOVE_KEY, pRemoveKey, sizeof(OS_802_11_REMOVE_KEY),NULL, 0,&dwRetSize);
    907     }
    908 
    909     return dwRetValue;
    910 }
    911 /********************************************************************/
    912 tiINT32
    913 CTI_WLAN_AdapterAPI::RegisterEvent( IPC_EVENT_PARAMS* pEventParams )
    914 {
    915 #ifdef _WINDOWS     // TRS:WDK
    916 #else
    917     return m_pIPCmod->IPC_RegisterEvent(pEventParams);
    918 #endif
    919 }
    920 /********************************************************************/
    921 tiINT32
    922 CTI_WLAN_AdapterAPI::UnRegisterEvent( IPC_EVENT_PARAMS* pEventParams/*tiINT32 iRegisterID*/ )
    923 {
    924 #ifdef _WINDOWS     // TRS:WDK
    925 #else
    926     return m_pIPCmod->IPC_UnRegisterEvent(pEventParams);
    927 #endif
    928 }
    929 /********************************************************************/
    930 tiINT32
    931 CTI_WLAN_AdapterAPI::ConfigPowerManagement( OS_802_11_POWER_PROFILE thePowerMgrProfile )
    932 {
    933     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    934     tiUINT32 dwRetSize;
    935 
    936     dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_MGR_PROFILE, &thePowerMgrProfile, sizeof(OS_802_11_POWER_PROFILE),NULL,0,&dwRetSize);
    937 
    938     return dwRetValue;
    939 }
    940 /********************************************************************/
    941 tiINT32
    942 CTI_WLAN_AdapterAPI::GetAssociationInfo( OS_802_11_ASSOCIATION_INFORMATION** ppInfo )
    943 {
    944     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    945 
    946     tiUINT32 nSize = 0;
    947 
    948     if ( ppInfo == NULL)
    949         return TI_RESULT_FAILED;
    950 
    951     dwRetValue = GetVariableLengthOID(TIWLN_802_11_ASSOCIATION_INFORMATION, (tiVOID**)ppInfo, &nSize, 10000);
    952     if ( TI_SUCCEEDED (dwRetValue) )
    953     {
    954         if (nSize == 0 || nSize < sizeof(OS_802_11_ASSOCIATION_INFORMATION) || *ppInfo == NULL )
    955             dwRetValue = TI_RESULT_FAILED;
    956 
    957     }
    958     return dwRetValue;
    959 }
    960 
    961 /********************************************************************/
    962 ///////////////////////////////////////////////////////////////////////
    963 // Assorted utility functions
    964 
    965 // This function queries for a variable length OID. Starting from a
    966 // suggested size (nNextAllocation), it keeps querying until the size
    967 // requirement is met. It does this repeatedly rather than once because
    968 // the size requirement for an OID can vary from one call to the next, and
    969 // also because some adapters don't report the correct required size value.
    970 tiINT32
    971 CTI_WLAN_AdapterAPI::GetVariableLengthOID(tiUINT32 oid, tiVOID** pp, tiUINT32* pnSize, tiUINT32 nNextAllocation)
    972 {
    973     tiVOID*     p = NULL;
    974     tiUINT32    nSize;
    975     tiUINT32 dwRetValue = TI_RESULT_FAILED;
    976     tiUINT32 dwRetSize;
    977 
    978     // reset return values
    979     *pp = NULL;
    980     *pnSize = 0;
    981 
    982     // query until we have a big enough buffer or get an error
    983     for( ; ; )
    984     {
    985         // try next allocation
    986         nSize = nNextAllocation;
    987 
    988         if ( nSize )
    989         {
    990             p = malloc(nSize);
    991             if (!p)
    992                 return TI_RESULT_FAILED;
    993             memset(p,0,nSize);
    994         }
    995 
    996 
    997         // get OID
    998         dwRetValue = tiIoCtrl(oid, p, nSize, p, nSize, &dwRetSize);
    999 
   1000         if( dwRetSize && nNextAllocation <= nSize && nSize != 0 )
   1001             break;
   1002         else
   1003             nNextAllocation = dwRetSize;
   1004 
   1005         // failed: free buffer
   1006         if ( p )
   1007         {
   1008             free(p);
   1009             p = NULL;
   1010         }
   1011         // if buffer overflow but new size is less than we used, return error
   1012         // NOTE: this would be a NIC bug and we have to avoid an infinite loop
   1013         if( nNextAllocation <= nSize )
   1014             return TI_RESULT_FAILED;
   1015     }
   1016 
   1017     // return pointer, size
   1018     *pp = p;
   1019     *pnSize = nNextAllocation;
   1020 
   1021     // success
   1022     return TI_RESULT_OK;
   1023 }
   1024 /********************************************************************/
   1025 tiINT32
   1026 CTI_WLAN_AdapterAPI::StartScan( scan_Params_t *pScanParams )
   1027 {
   1028     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1029     tiUINT32 dwRetSize;
   1030 
   1031     dwRetValue = tiIoCtrl(TIWLN_802_11_START_APP_SCAN_SET, pScanParams, sizeof(scan_Params_t),NULL,0,&dwRetSize);
   1032 
   1033     return dwRetValue;
   1034 }
   1035 /********************************************************************/
   1036 tiINT32
   1037 CTI_WLAN_AdapterAPI::StopScan( )
   1038 {
   1039     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1040     tiUINT32 dwRetSize;
   1041 
   1042     dwRetValue = tiIoCtrl(TIWLN_802_11_STOP_APP_SCAN_SET, NULL, 0,NULL,0,&dwRetSize);
   1043 
   1044     return dwRetValue;
   1045 }
   1046 /********************************************************************/
   1047 tiINT32
   1048 CTI_WLAN_AdapterAPI::SetScanPolicy( UINT8* buffer, UINT16 bufferLength )
   1049 {
   1050     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1051     tiUINT32 dwRetSize;
   1052 
   1053     dwRetValue = tiIoCtrl(TIWLN_802_11_SCAN_POLICY_PARAM_SET, buffer, bufferLength,NULL,0,&dwRetSize);
   1054 
   1055     return dwRetValue;
   1056 }
   1057 /********************************************************************/
   1058 tiINT32
   1059 CTI_WLAN_AdapterAPI::GetScanBssList( bssList_t* bssList )
   1060 {
   1061     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1062     tiUINT32 dwRetSize;
   1063 
   1064     dwRetValue = tiIoCtrl(TIWLN_802_11_SCAN_BSS_LIST_GET, NULL, 0, bssList, sizeof(bssList_t),&dwRetSize);
   1065 
   1066     return dwRetValue;
   1067 }
   1068 /********************************************************************/
   1069 tiINT32
   1070 CTI_WLAN_AdapterAPI::PollApPackets( )
   1071 {
   1072     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1073     tiUINT32 dwRetSize;
   1074 
   1075     dwRetValue = tiIoCtrl(TIWLN_802_11_POLL_AP_PACKETS, NULL, 0, NULL, 0,&dwRetSize);
   1076     return dwRetValue;
   1077 }
   1078 /********************************************************************/
   1079 tiINT32
   1080 CTI_WLAN_AdapterAPI::PollApPacketsFromAC( tiUINT32 AC )
   1081 {
   1082     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1083     tiUINT32 dwRetSize;
   1084 
   1085     dwRetValue = tiIoCtrl(TIWLN_802_11_POLL_AP_PACKETS_FROM_AC, &AC, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   1086     return dwRetValue;
   1087 }
   1088 /********************************************************************/
   1089 tiINT32
   1090 CTI_WLAN_AdapterAPI::SetTrafficIntensityThresholds ( OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds )
   1091 {
   1092     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1093     tiUINT32 dwRetSize;
   1094 
   1095     if (CheckObjectMemory(pTrafficThresholds, sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS)))
   1096     {
   1097         dwRetValue = tiIoCtrl(TIWLN_802_11_SET_TRAFFIC_INTENSITY_THRESHOLDS, pTrafficThresholds , sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS),NULL, 0,&dwRetSize);
   1098     }
   1099     return dwRetValue;
   1100 }
   1101 /********************************************************************/
   1102 tiINT32
   1103 CTI_WLAN_AdapterAPI::GetTrafficIntensityThresholds ( OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds )
   1104 {
   1105     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1106     tiUINT32 dwRetSize;
   1107 
   1108     dwRetValue = tiIoCtrl(TIWLN_802_11_GET_TRAFFIC_INTENSITY_THRESHOLDS, pTrafficThresholds , sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS), pTrafficThresholds , sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS),&dwRetSize);
   1109 
   1110     return dwRetValue;
   1111 }
   1112 /********************************************************************/
   1113 tiINT32
   1114 CTI_WLAN_AdapterAPI::ToggleTrafficIntensityEvents ( tiUINT32 NewStatus )
   1115 {
   1116     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1117     tiUINT32 dwRetSize;
   1118     tiUINT32 localVal = NewStatus;
   1119 
   1120     dwRetValue = tiIoCtrl(TIWLN_802_11_TOGGLE_TRAFFIC_INTENSITY_EVENTS, &localVal , sizeof(tiUINT32),NULL, 0,&dwRetSize);
   1121     return dwRetValue;
   1122 }
   1123 
   1124 /********************************************************************/
   1125 tiINT32
   1126 CTI_WLAN_AdapterAPI::SetDTagToAcMappingTable( acTrfcType_e* pDtagToAcTable )
   1127 {
   1128     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1129     tiUINT32 dwRetSize;
   1130     txDataQosParams_t	txDataQosParams;
   1131 
   1132     if (CheckObjectMemory(pDtagToAcTable, sizeof(acTrfcType_e)))
   1133     {
   1134         for (int i=0; i<MAX_NUM_OF_802_1d_TAGS; i++)
   1135         {
   1136             if (pDtagToAcTable[i] < MAX_NUM_OF_AC)
   1137             {
   1138                 txDataQosParams.qosParams.tag_ToAcClsfrTable[i] = pDtagToAcTable[i];
   1139             }
   1140             else
   1141             {
   1142                 return dwRetValue;
   1143             }
   1144 	}
   1145 
   1146         dwRetValue = tiIoCtrl(TIWLN_802_11_SET_DTAG_TO_AC_MAPPING_TABLE, &txDataQosParams, sizeof(txDataQosParams_t), NULL, 0,&dwRetSize);
   1147     }
   1148     return dwRetValue;
   1149 }
   1150 
   1151 /********************************************************************/
   1152 tiINT32
   1153 CTI_WLAN_AdapterAPI::SetVAD( txDataVadTimerParams_t* pVadTimer )
   1154 {
   1155     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1156     tiUINT32 dwRetSize;
   1157 
   1158     if (CheckObjectMemory(pVadTimer, sizeof(txDataVadTimerParams_t)))
   1159     {
   1160         dwRetValue = tiIoCtrl(TIWLN_802_11_SET_VAD, pVadTimer, sizeof(txDataVadTimerParams_t), NULL, 0,&dwRetSize);
   1161     }
   1162     return dwRetValue;
   1163 }
   1164 
   1165 /********************************************************************/
   1166 tiINT32
   1167 CTI_WLAN_AdapterAPI::GetVAD( txDataVadTimerParams_t* pVadTimer )
   1168 {
   1169     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1170     tiUINT32 dwRetSize;
   1171 
   1172     if (CheckObjectMemory(pVadTimer, sizeof(txDataVadTimerParams_t)))
   1173     {
   1174         dwRetValue = tiIoCtrl(TIWLN_802_11_GET_VAD, pVadTimer, sizeof(txDataVadTimerParams_t), pVadTimer, sizeof(txDataVadTimerParams_t),&dwRetSize);
   1175     }
   1176     return dwRetValue;
   1177 }
   1178 
   1179 /********************************************************************/
   1180 tiINT32
   1181 CTI_WLAN_AdapterAPI::SetQosParameters( OS_802_11_QOS_PARAMS* pQosParams )
   1182 {
   1183     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1184     tiUINT32 dwRetSize;
   1185 
   1186     if (CheckObjectMemory(pQosParams, sizeof(OS_802_11_QOS_PARAMS)))
   1187     {
   1188         dwRetValue = tiIoCtrl(TIWLN_802_11_SET_QOS_PARAMS, pQosParams, sizeof(OS_802_11_QOS_PARAMS),NULL, 0,&dwRetSize);
   1189     }
   1190     return dwRetValue;
   1191 }
   1192 
   1193 /********************************************************************/
   1194 tiINT32
   1195 CTI_WLAN_AdapterAPI::SetRxTimeOut( OS_802_11_QOS_RX_TIMEOUT_PARAMS* pRxTimeOut )
   1196 {
   1197     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1198     tiUINT32 dwRetSize;
   1199 
   1200     if (CheckObjectMemory(pRxTimeOut, sizeof(OS_802_11_QOS_PARAMS)))
   1201     {
   1202         dwRetValue = tiIoCtrl(TIWLN_802_11_SET_RX_TIMEOUT, pRxTimeOut, sizeof(OS_802_11_QOS_RX_TIMEOUT_PARAMS),NULL, 0,&dwRetSize);
   1203     }
   1204     return dwRetValue;
   1205 }
   1206 /********************************************************************/
   1207 tiINT32
   1208 CTI_WLAN_AdapterAPI::GetAPQosParameters( OS_802_11_AC_QOS_PARAMS* pACQosParams)
   1209 {
   1210     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1211     tiUINT32 dwRetSize;
   1212 
   1213     if (CheckObjectMemory(pACQosParams, sizeof(OS_802_11_AC_QOS_PARAMS)))
   1214     {
   1215         dwRetValue = tiIoCtrl(TIWLN_802_11_GET_AP_QOS_PARAMS, pACQosParams, sizeof(OS_802_11_AC_QOS_PARAMS), pACQosParams, sizeof(OS_802_11_AC_QOS_PARAMS),&dwRetSize);
   1216     }
   1217     return dwRetValue;
   1218 }
   1219 /********************************************************************/
   1220 tiINT32
   1221 CTI_WLAN_AdapterAPI::GetUserPriorityOfStream( STREAM_TRAFFIC_PROPERTIES* streamProperties)
   1222 {
   1223     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1224     tiUINT32 dwRetSize;
   1225 
   1226     if (CheckObjectMemory(streamProperties, sizeof(STREAM_TRAFFIC_PROPERTIES)))
   1227     {
   1228         dwRetValue = tiIoCtrl(TIWLN_802_11_GET_USER_PRIORITY_OF_STREAM, streamProperties, sizeof(STREAM_TRAFFIC_PROPERTIES), streamProperties, sizeof(STREAM_TRAFFIC_PROPERTIES),&dwRetSize);
   1229     }
   1230     return dwRetValue;
   1231 }
   1232 /********************************************************************/
   1233 tiINT32
   1234 CTI_WLAN_AdapterAPI::GetAPQosCapabilitesParameters( OS_802_11_AP_QOS_CAPABILITIES_PARAMS* pAPQosCapabiltiesParams )
   1235 {
   1236     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1237     tiUINT32 dwRetSize;
   1238 
   1239     dwRetValue = tiIoCtrl(TIWLN_802_11_GET_AP_QOS_CAPABILITIES, NULL, 0, pAPQosCapabiltiesParams, sizeof(OS_802_11_AP_QOS_CAPABILITIES_PARAMS),&dwRetSize);
   1240     return dwRetValue;
   1241 }
   1242 
   1243 /********************************************************************/
   1244 tiINT32
   1245 CTI_WLAN_AdapterAPI::AddTspec ( OS_802_11_QOS_TSPEC_PARAMS* pTspecParams)
   1246 {
   1247     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1248     tiUINT32 dwRetSize;
   1249 
   1250     dwRetValue = tiIoCtrl(TIWLN_802_11_ADD_TSPEC, pTspecParams, sizeof(OS_802_11_QOS_TSPEC_PARAMS),NULL, 0,&dwRetSize);
   1251     return dwRetValue;
   1252 }
   1253 /********************************************************************/
   1254 tiINT32
   1255 CTI_WLAN_AdapterAPI::GetTspecParameters( OS_802_11_QOS_TSPEC_PARAMS* pTspecParams)
   1256 {
   1257     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1258     tiUINT32 dwRetSize;
   1259 
   1260     dwRetValue = tiIoCtrl(TIWLN_802_11_GET_TSPEC_PARAMS, pTspecParams, sizeof(OS_802_11_QOS_TSPEC_PARAMS), pTspecParams, sizeof(OS_802_11_QOS_TSPEC_PARAMS),&dwRetSize);
   1261     return dwRetValue;
   1262 }/********************************************************************/
   1263 tiINT32
   1264 CTI_WLAN_AdapterAPI::DeleteTspec( OS_802_11_QOS_DELETE_TSPEC_PARAMS* pDelTspecParams)
   1265 {
   1266     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1267     tiUINT32 dwRetSize;
   1268 
   1269     dwRetValue = tiIoCtrl(TIWLN_802_11_DELETE_TSPEC, pDelTspecParams, sizeof(OS_802_11_QOS_DELETE_TSPEC_PARAMS),NULL, 0,&dwRetSize);
   1270     return dwRetValue;
   1271 }/********************************************************************/
   1272 tiINT32
   1273 CTI_WLAN_AdapterAPI:: GetCurrentACStatus( OS_802_11_AC_UPSD_STATUS_PARAMS *pAcStatusParams)
   1274 {
   1275     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1276     tiUINT32 dwRetSize;
   1277 
   1278     dwRetValue = tiIoCtrl(TIWLN_802_11_GET_CURRENT_AC_STATUS, pAcStatusParams, sizeof(OS_802_11_AC_UPSD_STATUS_PARAMS), pAcStatusParams, sizeof(OS_802_11_AC_UPSD_STATUS_PARAMS),&dwRetSize);
   1279     return dwRetValue;
   1280 }/********************************************************************/
   1281 tiINT32
   1282 CTI_WLAN_AdapterAPI:: SetMediumUsageThreshold(OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
   1283 {
   1284     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1285     tiUINT32 dwRetSize;
   1286 
   1287     dwRetValue = tiIoCtrl(TIWLN_802_11_SET_MEDIUM_USAGE_THRESHOLD, pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS),NULL, 0,&dwRetSize);
   1288     return dwRetValue;
   1289 }/********************************************************************/
   1290 tiINT32
   1291 CTI_WLAN_AdapterAPI:: SetPhyRateThreshold(OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
   1292 {
   1293     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1294     tiUINT32 dwRetSize;
   1295 
   1296     dwRetValue = tiIoCtrl(TIWLN_802_11_SET_PHY_RATE_THRESHOLD, pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS),NULL, 0,&dwRetSize);
   1297     return dwRetValue;
   1298 }
   1299 /********************************************************************/
   1300 tiINT32
   1301 CTI_WLAN_AdapterAPI:: GetMediumUsageThreshold(OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
   1302 {
   1303     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1304     tiUINT32 dwRetSize;
   1305 
   1306     dwRetValue = tiIoCtrl(TIWLN_802_11_GET_MEDIUM_USAGE_THRESHOLD, pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS), pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS),&dwRetSize);
   1307     return dwRetValue;
   1308 }
   1309 /********************************************************************/
   1310 tiINT32
   1311 CTI_WLAN_AdapterAPI:: GetPhyRateThreshold(OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
   1312 {
   1313     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1314     tiUINT32 dwRetSize;
   1315 
   1316     dwRetValue = tiIoCtrl(TIWLN_802_11_GET_PHY_RATE_THRESHOLD, pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS), pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS),&dwRetSize);
   1317     return dwRetValue;
   1318 }
   1319 /********************************************************************/
   1320 tiINT32
   1321 CTI_WLAN_AdapterAPI:: GetDesiredPsMode(OS_802_11_QOS_DESIRED_PS_MODE* pDesiredPsMode)
   1322 {
   1323     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1324     tiUINT32 dwRetSize;
   1325 
   1326     dwRetValue = tiIoCtrl(TIWLN_802_11_GET_DESIRED_PS_MODE, NULL, 0, pDesiredPsMode, sizeof(OS_802_11_QOS_DESIRED_PS_MODE),&dwRetSize);
   1327 
   1328     return dwRetValue;
   1329 }
   1330 /********************************************************************/
   1331 tiINT32
   1332 CTI_WLAN_AdapterAPI::ConfigTxClassifier(tiUINT32 inParamsBuffLen, tiUINT8  *pInParamsBuff)
   1333 {
   1334     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1335     tiUINT32 dwRetSize;
   1336 
   1337     if ( pInParamsBuff && CheckObjectMemory(pInParamsBuff, inParamsBuffLen) )
   1338     {
   1339         dwRetValue = tiIoCtrl(TIWLN_802_11_CONFIG_TX_CLASS, pInParamsBuff, inParamsBuffLen,NULL, 0,&dwRetSize);
   1340     }
   1341 
   1342     return dwRetValue;
   1343 }
   1344 /********************************************************************/
   1345 tiINT32
   1346 CTI_WLAN_AdapterAPI::RemoveClassifierEntry(clsfr_tableEntry_t *pClsfrEntry)
   1347 {
   1348     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1349     tiUINT32 dwRetSize;
   1350 
   1351     if (pClsfrEntry)
   1352     {
   1353         dwRetValue = tiIoCtrl(TIWLN_802_11_REMOVE_CLSFR_ENTRY, pClsfrEntry, sizeof(clsfr_tableEntry_t),NULL, 0,&dwRetSize);
   1354     }
   1355 
   1356     return dwRetValue;
   1357 }
   1358 /**********************************************************************/
   1359 tiINT32
   1360 CTI_WLAN_AdapterAPI::GetClsfrType (clsfrTypeAndSupport *currClsfrType)
   1361 {
   1362     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1363     tiUINT32 dwRetSize;
   1364 
   1365     dwRetValue = tiIoCtrl(TIWLN_802_11_GET_CLSFR_TYPE, NULL, 0, currClsfrType, sizeof(clsfrTypeAndSupport),&dwRetSize);
   1366     return dwRetValue;
   1367 }
   1368 /********************************************************************/
   1369 tiINT32
   1370 CTI_WLAN_AdapterAPI::GetDriverCapabilities (OS_802_11_DRIVER_CAPABILITIES* pDriverCapabilities )
   1371 {
   1372     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1373     tiUINT32 dwRetSize;
   1374 
   1375     dwRetValue = tiIoCtrl(TIWLN_802_11_GET_DRIVERS_CAPABILITIES, pDriverCapabilities, sizeof(OS_802_11_DRIVER_CAPABILITIES), pDriverCapabilities, sizeof(OS_802_11_DRIVER_CAPABILITIES),&dwRetSize);
   1376     return dwRetValue;
   1377 }
   1378 
   1379 /********************************************************************/
   1380 tiINT32
   1381 CTI_WLAN_AdapterAPI::GetSelectedBSSIDInfo(OS_802_11_BSSID_EX  *pSelectedBSSIDInfo)
   1382 {
   1383     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1384     tiUINT32 dwRetSize;
   1385 
   1386     dwRetValue = tiIoCtrl(TIWLN_802_11_GET_SELECTED_BSSID_INFO, pSelectedBSSIDInfo, sizeof(OS_802_11_BSSID_EX), pSelectedBSSIDInfo, sizeof(OS_802_11_BSSID_EX),&dwRetSize);
   1387     return dwRetValue;
   1388 }
   1389 
   1390 /********************************************************************/
   1391 tiINT32
   1392 CTI_WLAN_AdapterAPI::GetPrimaryBSSIDInfo(OS_802_11_BSSID_EX  *pSelectedBSSIDInfo)
   1393 {
   1394 	tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1395 	tiUINT32 dwRetSize;
   1396     tiUINT32 outBufLen;
   1397 
   1398     outBufLen = pSelectedBSSIDInfo->Length; //sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs) + 300;
   1399 
   1400    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_PRIMARY_BSSID_INFO, pSelectedBSSIDInfo, outBufLen, pSelectedBSSIDInfo, outBufLen, &dwRetSize);
   1401    return dwRetValue;
   1402 }
   1403 
   1404 /********************************************************************/
   1405 
   1406 tiINT32
   1407 CTI_WLAN_AdapterAPI::EnableDisableRxDataFilters(tiBOOL enabled)
   1408 {
   1409     tiUINT32 dwRetSize;
   1410 
   1411     return tiIoCtrl(TIWLN_ENABLE_DISABLE_RX_DATA_FILTERS, &enabled, sizeof(enabled), NULL, 0, &dwRetSize);
   1412 }
   1413 
   1414 /********************************************************************/
   1415 
   1416 tiINT32
   1417 CTI_WLAN_AdapterAPI::GetRxDataFiltersStatistics(TIWLAN_DATA_FILTER_STATISTICS * pStatistics)
   1418 {
   1419     tiUINT32 dwRetSize;
   1420 
   1421     return tiIoCtrl(TIWLN_GET_RX_DATA_FILTERS_STATISTICS, NULL, 0, pStatistics, sizeof(TIWLAN_DATA_FILTER_STATISTICS), &dwRetSize);
   1422 }
   1423 
   1424 /********************************************************************/
   1425 
   1426 tiINT32
   1427 CTI_WLAN_AdapterAPI::GetPowerConsumptionStatistics(PowerConsumptionTimeStat_t * pStatistics)
   1428 {
   1429     tiUINT32 dwRetSize;
   1430 
   1431     return tiIoCtrl(TIWLN_GET_POWER_CONSUMPTION_STATISTICS, NULL, 0, pStatistics, sizeof(PowerConsumptionTimeStat_t), &dwRetSize);
   1432 }
   1433 
   1434 /********************************************************************/
   1435 
   1436 tiINT32
   1437 CTI_WLAN_AdapterAPI::AddRxDataFilter(TIWLAN_DATA_FILTER_REQUEST * pRequest)
   1438 {
   1439     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1440     tiUINT32 dwRetSize;
   1441 
   1442     if ( pRequest )
   1443     {
   1444         dwRetValue = tiIoCtrl(TIWLN_ADD_RX_DATA_FILTER, pRequest, sizeof(TIWLAN_DATA_FILTER_REQUEST), NULL, 0, &dwRetSize);
   1445     }
   1446 
   1447     return dwRetValue;
   1448 }
   1449 
   1450 /********************************************************************/
   1451 tiINT32
   1452 CTI_WLAN_AdapterAPI::RemoveRxDataFilter(TIWLAN_DATA_FILTER_REQUEST * pRequest)
   1453 {
   1454     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1455     tiUINT32 dwRetSize;
   1456 
   1457     if ( pRequest )
   1458     {
   1459         dwRetValue = tiIoCtrl(TIWLN_REMOVE_RX_DATA_FILTER, pRequest, sizeof(TIWLAN_DATA_FILTER_REQUEST), NULL, 0, &dwRetSize);
   1460     }
   1461 
   1462     return dwRetValue;
   1463 }
   1464 
   1465 /********************************************************************/
   1466 tiINT32
   1467 CTI_WLAN_AdapterAPI::SetTxPowerDbm(tiUINT8 uTxPower)
   1468 {
   1469     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1470     tiUINT32 dwRetSize;
   1471 
   1472     dwRetValue = tiIoCtrl(TIWLN_802_11_TX_POWER_DBM_SET, &uTxPower, sizeof(UINT8),NULL, 0,&dwRetSize);
   1473 
   1474     return dwRetValue;
   1475 }
   1476 /********************************************************************/
   1477 tiINT32
   1478 CTI_WLAN_AdapterAPI::SetPowerMode(OS_802_11_POWER_PROFILE uPower )
   1479 {
   1480     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1481     tiUINT32 dwRetSize;
   1482 
   1483     dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_MODE_SET, &uPower, sizeof(OS_802_11_POWER_PROFILE),NULL, 0,&dwRetSize);
   1484     return dwRetValue;
   1485 }
   1486 /********************************************************************/
   1487 tiINT32
   1488 CTI_WLAN_AdapterAPI::GetPowerMode(OS_802_11_POWER_PROFILE* puPower)
   1489 {
   1490     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1491     tiUINT32 dwRetSize;
   1492 
   1493     dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_MODE_GET, NULL, 0, puPower, sizeof(OS_802_11_POWER_PROFILE),&dwRetSize);
   1494     return dwRetValue;
   1495 }
   1496 /********************************************************************/
   1497 tiINT32
   1498 CTI_WLAN_AdapterAPI::SetPowerLevelPS(OS_802_11_POWER_LEVELS uPower )
   1499 {
   1500     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1501     tiUINT32 dwRetSize;
   1502 
   1503     dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_PS_SET, &uPower, sizeof(OS_802_11_POWER_LEVELS),NULL, 0,&dwRetSize);
   1504     return dwRetValue;
   1505 }
   1506 /********************************************************************/
   1507 tiINT32
   1508 CTI_WLAN_AdapterAPI::GetPowerLevelPS( OS_802_11_POWER_LEVELS* puPower)
   1509 {
   1510     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1511     tiUINT32 dwRetSize;
   1512 
   1513     dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_PS_GET, NULL, 0, puPower, sizeof(OS_802_11_POWER_LEVELS),&dwRetSize);
   1514     return dwRetValue;
   1515 }
   1516 
   1517 /********************************************************************/
   1518 tiINT32
   1519 CTI_WLAN_AdapterAPI::SetPowerLevelDefault(OS_802_11_POWER_LEVELS uPower )
   1520 {
   1521     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1522     tiUINT32 dwRetSize;
   1523 
   1524     dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_DEFAULT_SET, &uPower, sizeof(OS_802_11_POWER_LEVELS),NULL, 0,&dwRetSize);
   1525     return dwRetValue;
   1526 }
   1527 /********************************************************************/
   1528 tiINT32
   1529 CTI_WLAN_AdapterAPI::GetPowerLevelDefault( OS_802_11_POWER_LEVELS* puPower)
   1530 {
   1531     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1532     tiUINT32 dwRetSize;
   1533 
   1534     dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_DEFAULT_GET, NULL, 0, puPower, sizeof(OS_802_11_POWER_LEVELS),&dwRetSize);
   1535     return dwRetValue;
   1536 }
   1537 /********************************************************************/
   1538 tiINT32
   1539 CTI_WLAN_AdapterAPI::SetPowerLevelDozeMode(OS_802_11_POWER_PROFILE uPower )
   1540 {
   1541     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1542     tiUINT32 dwRetSize;
   1543 
   1544     dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_DOZE_MODE_SET, &uPower, sizeof(OS_802_11_POWER_PROFILE),NULL, 0,&dwRetSize);
   1545     return dwRetValue;
   1546 }
   1547 /********************************************************************/
   1548 tiINT32
   1549 CTI_WLAN_AdapterAPI::GetPowerLevelDozeMode( OS_802_11_POWER_PROFILE* puPower)
   1550 {
   1551     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1552     tiUINT32 dwRetSize;
   1553 
   1554     dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_DOZE_MODE_GET, NULL, 0, puPower, sizeof(OS_802_11_POWER_PROFILE),&dwRetSize);
   1555     return dwRetValue;
   1556 }
   1557 /********************************************************************/
   1558 tiINT32
   1559 CTI_WLAN_AdapterAPI::SetBeaconFilterDesiredState( OS_802_11_BEACON_FILTER_MODE   uBeaconFilterMode)
   1560 {
   1561     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1562     tiUINT32 dwRetSize;
   1563 
   1564     dwRetValue = tiIoCtrl(TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_SET, &uBeaconFilterMode, sizeof(OS_802_11_BEACON_FILTER_MODE),NULL, 0,&dwRetSize);
   1565     return dwRetValue;
   1566 }
   1567 /********************************************************************/
   1568 tiINT32
   1569 CTI_WLAN_AdapterAPI::GetBeaconFilterDesiredState( tiUINT8* pDesiredState)
   1570 {
   1571     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1572     tiUINT32 dwRetSize;
   1573 
   1574     dwRetValue = tiIoCtrl(TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_GET, NULL, 0, pDesiredState, sizeof(UINT8),&dwRetSize);
   1575     return dwRetValue;
   1576 }
   1577 
   1578 
   1579 /********************************************************************/
   1580 tiINT32
   1581 CTI_WLAN_AdapterAPI::GetTxPowerLevel(tiCHAR* puTxPower )
   1582 {
   1583     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1584     tiUINT32 dwRetSize;
   1585 
   1586     if ( puTxPower )
   1587     {
   1588 		dwRetValue = tiIoCtrl(TIWLN_802_11_TX_POWER_LEVEL_GET, NULL, 0, puTxPower, sizeof(TIWLAN_POWER_LEVEL_TABLE),&dwRetSize);
   1589     }
   1590 
   1591     return dwRetValue;
   1592 }
   1593 
   1594 
   1595 /********************************************************************/
   1596 tiINT32
   1597 CTI_WLAN_AdapterAPI::GetTxPowerDbm(tiCHAR* puTxPower )
   1598 {
   1599     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1600     tiUINT32 dwRetSize;
   1601 
   1602     if ( puTxPower )
   1603     {
   1604         dwRetValue = tiIoCtrl(TIWLN_802_11_TX_POWER_DBM_GET, NULL, 0, puTxPower, sizeof(UINT8),&dwRetSize);
   1605     }
   1606 
   1607     return dwRetValue;
   1608 }
   1609 
   1610 /********************************************************************/
   1611 
   1612 tiINT32
   1613 CTI_WLAN_AdapterAPI::Set4XState(tiBOOL bStatus)
   1614 {
   1615     tiUINT32 bRet = TI_RESULT_FAILED;
   1616 
   1617     bRet = m_pRegistry->PutDW(_T("Mode4x"), bStatus);
   1618 
   1619     return bRet;
   1620 }
   1621 
   1622 /********************************************************************/
   1623 
   1624 tiINT32
   1625 CTI_WLAN_AdapterAPI::Get4XState(tiBOOL* lpbStatus)
   1626 {
   1627     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1628     tiUINT32 dwRetSize;
   1629 
   1630     dwRetValue = tiIoCtrl(TIWLN_4XACTIVESTATE_GET, NULL, 0, lpbStatus, sizeof(tiBOOL),&dwRetSize);
   1631 
   1632     return dwRetValue;
   1633 }
   1634 
   1635 /********************************************************************/
   1636 tiINT32
   1637 CTI_WLAN_AdapterAPI::GetDesiredRate(tiUINT32* puDesiredRates)
   1638 {
   1639     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1640     tiUINT32 dwRetSize;
   1641 
   1642     if ( puDesiredRates )
   1643     {
   1644         dwRetValue = tiIoCtrl(TIWLN_802_11_DESIRED_RATES_GET, NULL, 0, puDesiredRates, sizeof(tiUINT32),&dwRetSize);
   1645     }
   1646     return dwRetValue;
   1647 }
   1648 
   1649 /********************************************************************/
   1650 tiINT32
   1651 CTI_WLAN_AdapterAPI::GetCurrentRate(tiUINT32* puCurrentRates)
   1652 {
   1653     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1654     tiUINT32 dwRetSize;
   1655 
   1656     if ( puCurrentRates )
   1657     {
   1658         dwRetValue = tiIoCtrl(TIWLN_802_11_CURRENT_RATES_GET, NULL, 0, puCurrentRates, sizeof(tiUINT32),&dwRetSize);
   1659     }
   1660     return dwRetValue;
   1661 }
   1662 
   1663 /********************************************************************/
   1664 tiINT32
   1665 CTI_WLAN_AdapterAPI::SetFragmentThreshold(tiUINT32 dwFragmentThreshold)
   1666 {
   1667     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1668     tiUINT32 dwRetSize;
   1669 
   1670     dwRetValue = tiIoCtrl(TIWLN_802_11_FRAGMENTATION_THRESHOLD_SET, &dwFragmentThreshold, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   1671 
   1672     return dwRetValue;
   1673 }
   1674 
   1675 /********************************************************************/
   1676 tiINT32
   1677 CTI_WLAN_AdapterAPI::GetFragmentThreshold(tiUINT32* lpdwFragmentThreshold)
   1678 {
   1679     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1680     tiUINT32 dwRetSize;
   1681 
   1682     if ( lpdwFragmentThreshold )
   1683     {
   1684         dwRetValue = tiIoCtrl( TIWLN_802_11_FRAGMENTATION_THRESHOLD_GET, NULL, 0,
   1685             lpdwFragmentThreshold, sizeof(tiUINT32),&dwRetSize);
   1686     }
   1687     return dwRetValue;
   1688 }
   1689 
   1690 /********************************************************************/
   1691 
   1692 tiINT32
   1693 CTI_WLAN_AdapterAPI::SetRTSThreshold(tiUINT32 uRTSThreshold)
   1694 {
   1695     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1696     tiUINT32 dwRetSize;
   1697 
   1698     dwRetValue = tiIoCtrl(TIWLN_802_11_RTS_THRESHOLD_SET, &uRTSThreshold, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   1699 
   1700     return dwRetValue;
   1701 }
   1702 
   1703 /********************************************************************/
   1704 
   1705 tiINT32
   1706 CTI_WLAN_AdapterAPI::GetRTSThreshold(tiUINT32* puRTSThreshold )
   1707 {
   1708     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1709     tiUINT32 dwRetSize;
   1710 
   1711     if ( puRTSThreshold )
   1712     {
   1713         dwRetValue = tiIoCtrl(TIWLN_802_11_RTS_THRESHOLD_GET, NULL, 0, puRTSThreshold, sizeof(tiUINT32),&dwRetSize);
   1714     }
   1715     return dwRetValue;
   1716 }
   1717 
   1718 /********************************************************************/
   1719 
   1720 tiINT32
   1721 CTI_WLAN_AdapterAPI::SetShortPreamble(tiUINT32 uShortPreamble)
   1722 {
   1723     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1724     tiUINT32 dwRetSize;
   1725 
   1726     dwRetValue = tiIoCtrl(TIWLN_802_11_SHORT_PREAMBLE_SET, &uShortPreamble, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   1727 
   1728     return dwRetValue;
   1729 }
   1730 
   1731 /********************************************************************/
   1732 
   1733 tiINT32
   1734 CTI_WLAN_AdapterAPI::GetShortPreamble(tiUINT32* puShortPreamble)
   1735 {
   1736     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1737     tiUINT32 dwRetSize;
   1738 
   1739     if ( puShortPreamble )
   1740     {
   1741         dwRetValue = tiIoCtrl(TIWLN_802_11_SHORT_PREAMBLE_GET, NULL, 0, puShortPreamble, sizeof(tiUINT32),&dwRetSize);
   1742 
   1743     }
   1744     return dwRetValue;
   1745 }
   1746 
   1747 /********************************************************************/
   1748 tiINT32
   1749 CTI_WLAN_AdapterAPI::SetShortRetry(tiUINT32 uShortRetry)
   1750 {
   1751     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1752     tiUINT32 dwRetSize;
   1753 
   1754     dwRetValue = tiIoCtrl(TIWLN_802_11_SHORT_RETRY_SET, &uShortRetry, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   1755 
   1756     return dwRetValue;
   1757 }
   1758 /********************************************************************/
   1759 
   1760 tiINT32
   1761 CTI_WLAN_AdapterAPI::GetShortRetry(tiUINT32* puShortRetry)
   1762 {
   1763     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1764     tiUINT32 dwRetSize;
   1765 
   1766     if ( puShortRetry )
   1767     {
   1768         dwRetValue = tiIoCtrl(TIWLN_802_11_SHORT_RETRY_GET, NULL, 0, puShortRetry, sizeof(tiUINT32),&dwRetSize);
   1769     }
   1770     return dwRetValue;
   1771 }
   1772 /********************************************************************/
   1773 
   1774 tiINT32
   1775 CTI_WLAN_AdapterAPI::SetLongRetry(tiUINT32 uLongRetry)
   1776 {
   1777     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1778     tiUINT32 dwRetSize;
   1779 
   1780     dwRetValue = tiIoCtrl(TIWLN_802_11_LONG_RETRY_SET, &uLongRetry, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   1781 
   1782     return dwRetValue;
   1783 }
   1784 /********************************************************************/
   1785 
   1786 tiINT32
   1787 CTI_WLAN_AdapterAPI::GetLongRetry(tiUINT32* puLongRetry)
   1788 {
   1789     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1790     tiUINT32 dwRetSize;
   1791 
   1792     if ( puLongRetry )
   1793     {
   1794         dwRetValue = tiIoCtrl(TIWLN_802_11_LONG_RETRY_GET, NULL, 0, puLongRetry, sizeof(tiUINT32),&dwRetSize);
   1795     }
   1796     return dwRetValue;
   1797 }
   1798 /********************************************************************/
   1799 
   1800 tiINT32
   1801 CTI_WLAN_AdapterAPI::GetSupportedNetworkTypes(OS_802_11_NETWORK_TYPE* pNetTypeLst, tiUINT32 uMaxNetTypes )
   1802 {
   1803     tiUINT32 dwRetValue = TI_RESULT_INVALID_PARAMETER;
   1804     tiUINT32 dwRetSize;
   1805     tiUINT32    uSizeList = sizeof(OS_802_11_NETWORK_TYPE)*uMaxNetTypes;
   1806 
   1807     if ( pNetTypeLst && CheckObjectMemory(pNetTypeLst, uSizeList) )
   1808     {
   1809         tiUINT32 dwNetTypesSize = sizeof(OS_802_11_NETWORK_TYPE_LIST) + (uMaxNetTypes - 1) * sizeof(OS_802_11_NETWORK_TYPE);
   1810 
   1811         OS_802_11_NETWORK_TYPE_LIST*    pNetworkTypeList = NULL;
   1812         pNetworkTypeList = (OS_802_11_NETWORK_TYPE_LIST*) new tiUINT8[dwNetTypesSize];
   1813 
   1814         if( !pNetworkTypeList )
   1815             return TI_RESULT_NOT_ENOUGH_MEMORY;
   1816 
   1817         memset(pNetworkTypeList, 0, dwNetTypesSize );
   1818 
   1819         pNetworkTypeList->NumberOfItems = uMaxNetTypes;
   1820 
   1821         dwRetValue = tiIoCtrl(TIWLN_802_11_NETWORK_TYPES_SUPPORTED, NULL, 0, pNetTypeLst, dwNetTypesSize,&dwRetSize);
   1822 
   1823         if ( dwRetSize )
   1824         {
   1825             dwRetValue = TI_RESULT_OK;
   1826             memcpy(pNetTypeLst, pNetworkTypeList, uSizeList);
   1827         }
   1828 
   1829         delete [] pNetworkTypeList;
   1830     }
   1831 
   1832     return dwRetValue;
   1833 }
   1834 /********************************************************************/
   1835 tiINT32
   1836 CTI_WLAN_AdapterAPI::SetNetworkTypeInUse( OS_802_11_NETWORK_TYPE uNetType )
   1837 {
   1838     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1839     tiUINT32 dwRetSize;
   1840 
   1841     dwRetValue = tiIoCtrl(TIWLN_802_11_NETWORK_TYPE_IN_USE_SET, &uNetType, sizeof(OS_802_11_NETWORK_TYPE),NULL, 0,&dwRetSize);
   1842 
   1843     return dwRetValue;
   1844 }
   1845 /********************************************************************/
   1846 
   1847 tiINT32
   1848 CTI_WLAN_AdapterAPI::GetNetworkTypeInUse( OS_802_11_NETWORK_TYPE*   puNetType )
   1849 {
   1850     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1851     tiUINT32 dwRetSize;
   1852 
   1853     if ( puNetType )
   1854     {
   1855         dwRetValue = tiIoCtrl(TIWLN_802_11_NETWORK_TYPE_IN_USE_GET, NULL, 0, puNetType, sizeof(OS_802_11_NETWORK_TYPE),&dwRetSize);
   1856     }
   1857     return dwRetValue;
   1858 }
   1859 /********************************************************************/
   1860 tiINT32
   1861 CTI_WLAN_AdapterAPI::GetBSSID( OS_802_11_MAC_ADDRESS* pAddrBSSID )
   1862 {
   1863     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1864     tiUINT32 dwRetSize;
   1865 
   1866     if ( pAddrBSSID && CheckObjectMemory(pAddrBSSID, sizeof(OS_802_11_MAC_ADDRESS)) )
   1867     {
   1868         dwRetValue = tiIoCtrl(TIWLN_802_11_BSSID_GET, NULL, 0, pAddrBSSID, sizeof( OS_802_11_MAC_ADDRESS ),&dwRetSize);
   1869     }
   1870     return dwRetValue;
   1871 }
   1872 
   1873 
   1874 /********************************************************************/
   1875 
   1876 tiINT32
   1877 CTI_WLAN_AdapterAPI::SetBSSID( OS_802_11_MAC_ADDRESS* lpAddrBSSID )
   1878 {
   1879     tiUINT32 dwRetValue;
   1880     tiUINT32 dwRetSize;
   1881 
   1882     dwRetValue = tiIoCtrl(TIWLN_802_11_BSSID_SET, lpAddrBSSID, sizeof( OS_802_11_MAC_ADDRESS ),NULL, 0,&dwRetSize);
   1883 
   1884     return dwRetValue;
   1885 }
   1886 
   1887 
   1888 
   1889 /********************************************************************/
   1890 tiINT32
   1891 CTI_WLAN_AdapterAPI::SetRSSITrigger( tiBOOL bRSSItr )
   1892 {
   1893     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1894     tiUINT32 dwRetSize;
   1895 
   1896     dwRetValue = tiIoCtrl(TIWLN_802_11_RSSI_TRIGGER_SET, &bRSSItr, sizeof(tiBOOL),NULL, 0,&dwRetSize);
   1897 
   1898     return dwRetValue;
   1899 }
   1900 /********************************************************************/
   1901 tiINT32
   1902 CTI_WLAN_AdapterAPI::GetRSSITrigger( tiBOOL* pbRSSItr )
   1903 {
   1904     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1905     tiUINT32 dwRetSize;
   1906 
   1907     dwRetValue = tiIoCtrl(TIWLN_802_11_RSSI_TRIGGER_GET, NULL, 0, pbRSSItr, sizeof( tiBOOL ),&dwRetSize);
   1908 
   1909     return dwRetValue;
   1910 }
   1911 /********************************************************************/
   1912 tiINT32
   1913 CTI_WLAN_AdapterAPI::SetAntennaDiversityParams( PTIWLAN_ANT_DIVERSITY pAntennaDiversityOptions )
   1914 {
   1915     tiINT32    bRet    = TI_RESULT_FAILED;
   1916     tiUINT32   dwRetSize;
   1917 
   1918     bRet = tiIoCtrl(TIWLAN_802_11_ANTENNA_DIVERSITY_PARAM_SET, pAntennaDiversityOptions, sizeof(TIWLAN_ANT_DIVERSITY), NULL, 0, &dwRetSize);
   1919 
   1920     return bRet;
   1921 }
   1922 
   1923 /********************************************************************/
   1924 tiINT32
   1925 CTI_WLAN_AdapterAPI::SetWEPStatus(tiUINT32 dwWEPStatus)
   1926 {
   1927     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1928     tiUINT32 dwRetSize;
   1929 
   1930     dwRetValue = tiIoCtrl(TIWLN_802_11_WEP_STATUS_SET, &dwWEPStatus, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   1931 
   1932     return dwRetValue;
   1933 }
   1934 
   1935 /********************************************************************/
   1936 tiINT32
   1937 CTI_WLAN_AdapterAPI::GetWEPStatus(tiUINT32*   lpdwWEPStatus)
   1938 {
   1939     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1940     tiUINT32 dwRetSize;
   1941 
   1942     if ( lpdwWEPStatus )
   1943     {
   1944         dwRetValue = tiIoCtrl(TIWLN_802_11_WEP_STATUS_GET, NULL, 0, lpdwWEPStatus, sizeof(tiUINT32),&dwRetSize);
   1945     }
   1946     return dwRetValue;
   1947 }
   1948 /********************************************************************/
   1949 
   1950 tiINT32
   1951 CTI_WLAN_AdapterAPI::SetDesiredChannel( tiUINT32 dwDesiredChannel )
   1952 {
   1953     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1954     tiUINT32 dwRetSize;
   1955 
   1956     dwRetValue = tiIoCtrl(TIWLN_802_11_DESIRED_CHANNEL_SET, &dwDesiredChannel, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   1957 
   1958     return dwRetValue;
   1959 }
   1960 /********************************************************************/
   1961 
   1962 tiINT32
   1963 CTI_WLAN_AdapterAPI::GetDesiredChannel( tiUINT32*   lpdwDesiredChannel )
   1964 {
   1965     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1966     tiUINT32 dwRetSize;
   1967 
   1968     if ( lpdwDesiredChannel )
   1969     {
   1970         dwRetValue = tiIoCtrl(TIWLN_802_11_DESIRED_CHANNEL_GET, NULL, 0, lpdwDesiredChannel, sizeof(tiUINT32),&dwRetSize);
   1971     }
   1972     return dwRetValue;
   1973 }
   1974 
   1975 /********************************************************************/
   1976 
   1977 tiINT32
   1978 CTI_WLAN_AdapterAPI::GetCurrentChannel( tiUINT32* puCurrentChannel )
   1979 {
   1980     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1981     tiUINT32 dwRetSize;
   1982 
   1983     if ( puCurrentChannel )
   1984     {
   1985         dwRetValue = tiIoCtrl(TIWLN_802_11_CHANNEL_GET, NULL, 0, puCurrentChannel, sizeof(tiUINT32),&dwRetSize);
   1986     }
   1987     return dwRetValue;
   1988 }
   1989 
   1990 /********************************************************************/
   1991 
   1992 tiINT32
   1993 CTI_WLAN_AdapterAPI::SetBtCoeEnable( tiUINT32 uModeEnable)
   1994 {
   1995     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   1996     tiUINT32 dwRetSize;
   1997 
   1998     dwRetValue = tiIoCtrl(BT_COEXSISTANCE_SET_ENABLE, &uModeEnable, sizeof(tiUINT32),NULL,0,&dwRetSize);
   1999 
   2000     return dwRetValue;
   2001 }
   2002 
   2003 /********************************************************************/
   2004 
   2005 tiINT32
   2006 CTI_WLAN_AdapterAPI::SetBtCoeRate( tiUINT8 *pRate )
   2007 {
   2008     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2009     tiUINT32 dwRetSize;
   2010 
   2011     dwRetValue = tiIoCtrl(BT_COEXSISTANCE_SET_RATE, pRate, sizeof(tiUINT8)*NUM_OF_RATES_IN_SG,NULL,0,&dwRetSize);
   2012 
   2013     return dwRetValue;
   2014 }
   2015 
   2016 /********************************************************************/
   2017 
   2018 
   2019 tiINT32
   2020 CTI_WLAN_AdapterAPI::SetBtCoeConfig( tiUINT32 *pConfig )
   2021 {
   2022     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2023 
   2024     dwRetValue = tiIoCtrl(BT_COEXSISTANCE_SET_CONFIG, pConfig, sizeof(tiUINT32) * NUM_OF_CONFIG_PARAMS_IN_SG,NULL,0,NULL);
   2025 
   2026     return dwRetValue;
   2027 }
   2028 
   2029 
   2030 tiINT32
   2031 CTI_WLAN_AdapterAPI::SetBtCoeGetStatus( tiUINT32 *pStatus )
   2032 {
   2033     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2034     tiUINT32 dwRetSize;
   2035 
   2036     dwRetValue = tiIoCtrl(BT_COEXSISTANCE_GET_STATUS, NULL, 0, pStatus, sizeof(tiUINT32) * NUM_OF_STATUS_PARAMS_IN_SG,&dwRetSize);
   2037 
   2038     return dwRetValue;
   2039 }
   2040 
   2041 
   2042 
   2043 #ifdef TI_DBG
   2044 
   2045 /********************************************************************/
   2046 tiINT32
   2047 CTI_WLAN_AdapterAPI::DisplayStats( tiUINT8*  puDbgBuffer, tiUINT32 uBuffSize)
   2048 {
   2049     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2050     tiUINT32 dwRetSize;
   2051 
   2052     if ( puDbgBuffer && CheckObjectMemory(puDbgBuffer, uBuffSize) )
   2053     {
   2054         dwRetValue = tiIoCtrl( TIWLN_DISPLAY_STATS, puDbgBuffer, uBuffSize,NULL, 0,&dwRetSize);
   2055     }
   2056 
   2057     return dwRetValue;
   2058 }
   2059 
   2060 /********************************************************************/
   2061 tiINT32
   2062 CTI_WLAN_AdapterAPI::SetReportModule( tiUINT8 *pData )
   2063 {
   2064     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2065     tiUINT32 dwRetSize = 0;
   2066 
   2067     if ( pData && CheckObjectMemory(pData, WLAN_MAX_LOG_MODULES) )
   2068     {
   2069         dwRetValue = tiIoCtrl( TIWLN_REPORT_MODULE_SET, pData, WLAN_MAX_LOG_MODULES, NULL, 0, &dwRetSize);
   2070     }
   2071 
   2072     return dwRetValue;
   2073 }
   2074 
   2075 
   2076 /********************************************************************/
   2077 
   2078 tiINT32
   2079 CTI_WLAN_AdapterAPI::GetReportModule( tiUINT8* pData )
   2080 {
   2081     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2082     tiUINT32 dwRetSize;
   2083 
   2084     if ( pData )
   2085     {
   2086         dwRetValue = tiIoCtrl(TIWLN_REPORT_MODULE_GET, NULL, 0, pData, WLAN_MAX_LOG_MODULES, &dwRetSize);
   2087     }
   2088 
   2089     return dwRetValue;
   2090 }
   2091 
   2092 /********************************************************************/
   2093 
   2094 tiINT32
   2095 CTI_WLAN_AdapterAPI::SetReportSeverity( tiUINT8  *pData )
   2096 {
   2097     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2098     tiUINT32 dwRetSize;
   2099 
   2100     if ( pData && CheckObjectMemory(pData, WLAN_MAX_SEVERITIES) )
   2101     {
   2102         dwRetValue = tiIoCtrl(TIWLN_REPORT_SEVERITY_SET, pData, WLAN_MAX_SEVERITIES, NULL, 0, &dwRetSize);
   2103     }
   2104 
   2105     return dwRetValue;
   2106 }
   2107 
   2108 /********************************************************************/
   2109 
   2110 tiINT32
   2111 CTI_WLAN_AdapterAPI::GetReportSeverity( tiUINT8* pData )
   2112 {
   2113     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2114     tiUINT32 dwRetSize;
   2115 
   2116     if ( pData )
   2117     {
   2118         dwRetValue = tiIoCtrl(TIWLN_REPORT_SEVERITY_GET, NULL, 0, pData, WLAN_MAX_SEVERITIES, &dwRetSize);
   2119     }
   2120 
   2121     return dwRetValue;
   2122 }
   2123 
   2124 /********************************************************************/
   2125 
   2126 tiINT32
   2127 CTI_WLAN_AdapterAPI::SetOsDbgState( tiUINT32 uData )
   2128 {
   2129     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2130     tiUINT32 dwRetSize;
   2131 
   2132     dwRetValue = tiIoCtrl(TIWLN_OS_DBG_STATE_SET, &uData, sizeof(tiUINT32), NULL, 0, &dwRetSize);
   2133 
   2134     return dwRetValue;
   2135 }
   2136 
   2137 /********************************************************************/
   2138 
   2139 tiINT32
   2140 CTI_WLAN_AdapterAPI::GetOsDbgState( tiUINT32* puData )
   2141 {
   2142     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2143     tiUINT32 dwRetSize;
   2144 
   2145     if ( puData )
   2146     {
   2147         dwRetValue = tiIoCtrl(TIWLN_OS_DBG_STATE_GET, NULL, 0, puData, sizeof(tiUINT32), &dwRetSize);
   2148     }
   2149 
   2150     return dwRetValue;
   2151 }
   2152 
   2153 /********************************************************************/
   2154 
   2155 tiINT32
   2156 CTI_WLAN_AdapterAPI::SetReportPPMode( tiUINT32  uData )
   2157 {
   2158     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2159     tiUINT32 dwRetSize;
   2160 
   2161     dwRetValue = tiIoCtrl(TIWLN_REPORT_PPMODE_SET, &uData, sizeof(tiUINT32), NULL, 0, &dwRetSize);
   2162 
   2163     return dwRetValue;
   2164 }
   2165 
   2166 /********************************************************************/
   2167 
   2168 tiINT32
   2169 CTI_WLAN_AdapterAPI::GetDebugBuffer( tiUINT8* pBuffer, tiUINT32  dwLenght)
   2170 {
   2171     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2172     tiUINT32 dwRetSize;
   2173 
   2174     if ( pBuffer && CheckObjectMemory(pBuffer, sizeof(tiUINT8)*dwLenght) )
   2175     {
   2176         dwRetValue = tiIoCtrl(TIWLN_GET_DBG_BUFFER, NULL, 0, pBuffer, sizeof(tiUINT8)*dwLenght,&dwRetSize);
   2177 
   2178     }
   2179     return dwRetValue;
   2180 }
   2181 
   2182 
   2183 #ifdef DRIVER_PROFILING
   2184 tiINT32
   2185 CTI_WLAN_AdapterAPI::ProfileReport()
   2186 {
   2187     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2188     tiUINT32 dwRetSize;
   2189 
   2190     dwRetValue =  tiIoCtrl(TIWLAN_PROFILING_REPORT,NULL, 0,NULL,0,&dwRetSize);
   2191 
   2192     return dwRetValue;
   2193 }
   2194 
   2195 tiINT32
   2196 CTI_WLAN_AdapterAPI::CpuEstimatorCommand(tiUINT8 uType, tiUINT32 uData)
   2197 {
   2198     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2199     tiUINT32 dwRetSize;
   2200     tiUINT32 dwCommandParam;
   2201 
   2202     /* set command param: type | (24 LSB) data */
   2203     dwCommandParam = (uData & 0xFFFFFF) | (((tiUINT32)uType) << 24);
   2204 
   2205     //printf("CpuEstimatorCommand: type=%d, data =%d, dwCommandParam = %x\n", uType, uData, dwCommandParam);
   2206     dwRetValue =  tiIoCtrl(TIWLAN_PROFILING_CPU_ESTIMATOR_CMD,&dwCommandParam, sizeof(dwCommandParam),NULL, 0,&dwRetSize);
   2207 
   2208     return dwRetValue;
   2209 }
   2210 #endif
   2211 
   2212 #endif //TI_DBG
   2213 /********************************************************************/
   2214 tiINT32
   2215 CTI_WLAN_AdapterAPI::SetSupportedRates( tiUINT8* pSupportedRatesLst, tiUINT32 uBufLength)
   2216 {
   2217     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2218     tiUINT32 dwRetSize;
   2219 
   2220     if ( pSupportedRatesLst && CheckObjectMemory(pSupportedRatesLst, uBufLength) )
   2221     {
   2222         dwRetValue = tiIoCtrl(TIWLN_802_11_SUPPORTED_RATES_SET, pSupportedRatesLst, uBufLength,NULL, 0,&dwRetSize);
   2223 
   2224     }
   2225     return dwRetValue;
   2226 }
   2227 /********************************************************************/
   2228 tiINT32
   2229 CTI_WLAN_AdapterAPI::GetSupportedRates( tiUINT8* pSupportedRatesLst, tiUINT32 uBufLength)
   2230 {
   2231     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2232     tiUINT32 dwRetSize;
   2233 
   2234     if ( pSupportedRatesLst && CheckObjectMemory(pSupportedRatesLst, uBufLength) )
   2235     {
   2236         dwRetValue = tiIoCtrl(TIWLN_802_11_SUPPORTED_RATES, NULL, 0, pSupportedRatesLst, uBufLength,&dwRetSize);
   2237     }
   2238     return dwRetValue;
   2239 }
   2240 /********************************************************************/
   2241 
   2242 tiINT32
   2243 CTI_WLAN_AdapterAPI::SetConfiguration( OS_802_11_CONFIGURATION*   pConfiguration )
   2244 {
   2245     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2246     tiUINT32 dwRetSize;
   2247 
   2248     if ( pConfiguration && CheckObjectMemory(pConfiguration, sizeof(OS_802_11_CONFIGURATION)) )
   2249     {
   2250         dwRetValue = tiIoCtrl(TIWLN_802_11_CONFIGURATION_SET, pConfiguration, sizeof(OS_802_11_CONFIGURATION),NULL, 0,&dwRetSize);
   2251 
   2252     }
   2253     return dwRetValue;
   2254 }
   2255 
   2256 /********************************************************************/
   2257 
   2258 tiINT32
   2259 CTI_WLAN_AdapterAPI::GetConfiguration( OS_802_11_CONFIGURATION*   pConfiguration )
   2260 {
   2261     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2262     tiUINT32 dwRetSize;
   2263 
   2264     if ( pConfiguration && CheckObjectMemory(pConfiguration, sizeof(OS_802_11_CONFIGURATION)) )
   2265     {
   2266         dwRetValue = tiIoCtrl(TIWLN_802_11_CONFIGURATION_GET, NULL, 0, pConfiguration, sizeof(OS_802_11_CONFIGURATION),&dwRetSize);
   2267     }
   2268     return dwRetValue;
   2269 }
   2270 
   2271 /********************************************************************/
   2272 tiINT32
   2273 CTI_WLAN_AdapterAPI::SetAuthenticationMode( OS_802_11_AUTHENTICATION_MODE uAuthenticationMode )
   2274 {
   2275     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2276     tiUINT32 dwRetSize;
   2277 
   2278     dwRetValue = tiIoCtrl(TIWLN_802_11_AUTHENTICATION_MODE_SET, &uAuthenticationMode, sizeof(OS_802_11_AUTHENTICATION_MODE),NULL, 0,&dwRetSize);
   2279     return dwRetValue;
   2280 }
   2281 /********************************************************************/
   2282 
   2283 tiINT32
   2284 CTI_WLAN_AdapterAPI::GetAuthenticationMode( OS_802_11_AUTHENTICATION_MODE* puAuthenticationMode )
   2285 {
   2286     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2287     tiUINT32 dwRetSize;
   2288 
   2289     if ( puAuthenticationMode )
   2290     {
   2291         dwRetValue = tiIoCtrl(TIWLN_802_11_AUTHENTICATION_MODE_GET, NULL, 0, puAuthenticationMode, sizeof(OS_802_11_AUTHENTICATION_MODE),&dwRetSize);
   2292 
   2293     }
   2294     return dwRetValue;
   2295 }
   2296 /********************************************************************/
   2297 tiINT32
   2298 CTI_WLAN_AdapterAPI::SetPrivacyFilter( tiUINT32 dwPrivacyFilter )
   2299 {
   2300     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2301     tiUINT32 dwRetSize;
   2302 
   2303     dwRetValue = tiIoCtrl(TIWLN_802_11_PRIVACY_FILTER_SET, &dwPrivacyFilter, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   2304     return dwRetValue;
   2305 }
   2306 /********************************************************************/
   2307 
   2308 tiINT32
   2309 CTI_WLAN_AdapterAPI::GetPrivacyFilter( tiUINT32* pdwPrivacyFilter )
   2310 {
   2311     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2312     tiUINT32 dwRetSize;
   2313 
   2314     if ( pdwPrivacyFilter )
   2315     {
   2316         dwRetValue = tiIoCtrl(TIWLN_802_11_PRIVACY_FILTER_GET, NULL, 0, pdwPrivacyFilter, sizeof(tiUINT32),&dwRetSize);
   2317     }
   2318     return dwRetValue;
   2319 }
   2320 /********************************************************************/
   2321 tiINT32
   2322 CTI_WLAN_AdapterAPI::SetKeyType( OS_802_11_KEY_TYPES uKeyType )
   2323 {
   2324     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2325     tiUINT32 dwRetSize;
   2326 
   2327     dwRetValue = tiIoCtrl(TIWLN_802_11_KEY_TYPE_SET, &uKeyType, sizeof(OS_802_11_KEY_TYPES),NULL, 0,&dwRetSize);
   2328 
   2329     return dwRetValue;
   2330 }
   2331 /********************************************************************/
   2332 tiINT32
   2333 CTI_WLAN_AdapterAPI::SetMixedMode( tiBOOL bStatus )
   2334 {
   2335     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2336     tiUINT32 dwRetSize;
   2337 
   2338     dwRetValue = tiIoCtrl(TIWLN_802_11_MIXED_MODE_SET, &bStatus, sizeof(tiBOOL),NULL, 0,&dwRetSize);
   2339 
   2340     return dwRetValue;
   2341 }
   2342 /********************************************************************/
   2343 tiINT32
   2344 CTI_WLAN_AdapterAPI::GetMixedMode( tiBOOL* pbStatus )
   2345 {
   2346     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2347     tiUINT32 dwRetSize;
   2348 
   2349     if ( pbStatus )
   2350     {
   2351         dwRetValue = tiIoCtrl(TIWLN_802_11_MIXED_MODE_GET, NULL, 0, pbStatus, sizeof( tiBOOL ),&dwRetSize);
   2352     }
   2353     return dwRetValue;
   2354 }
   2355 
   2356 
   2357 /********************************************************************/
   2358 tiINT32
   2359 CTI_WLAN_AdapterAPI::EnableDisable_802_11d( tiUINT8 enableDisable_802_11d)
   2360 {
   2361     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2362     tiUINT32 dwRetSize;
   2363 
   2364     dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11D, &enableDisable_802_11d, sizeof(tiUINT8), NULL, 0, &dwRetSize);
   2365 
   2366     return dwRetValue;
   2367 }
   2368 /********************************************************************/
   2369 tiINT32
   2370 CTI_WLAN_AdapterAPI::Get_802_11d( tiUINT8 *enableDisable_802_11d)
   2371 {
   2372     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2373     tiUINT32 dwRetSize;
   2374 
   2375     if ( enableDisable_802_11d )
   2376     {
   2377         dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_GET_802_11D, NULL, 0, enableDisable_802_11d, sizeof(tiUINT8),&dwRetSize);
   2378     }
   2379     return dwRetValue;
   2380 }
   2381 
   2382 /********************************************************************/
   2383 tiINT32
   2384 CTI_WLAN_AdapterAPI::EnableDisable_802_11h( tiUINT8 enableDisable_802_11h)
   2385 {
   2386     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2387     tiUINT32 dwRetSize;
   2388 
   2389     dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11H, &enableDisable_802_11h, sizeof(tiUINT8), NULL, 0, &dwRetSize);
   2390 
   2391     return dwRetValue;
   2392 }
   2393 /********************************************************************/
   2394 tiINT32
   2395 CTI_WLAN_AdapterAPI::Get_802_11h( tiUINT8 *enableDisable_802_11h)
   2396 {
   2397     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2398     tiUINT32 dwRetSize;
   2399 
   2400     if ( enableDisable_802_11h )
   2401     {
   2402         dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_GET_802_11H, NULL, 0, enableDisable_802_11h, sizeof(tiUINT8),&dwRetSize);
   2403     }
   2404     return dwRetValue;
   2405 }
   2406 
   2407 
   2408 /********************************************************************/
   2409 tiINT32
   2410 CTI_WLAN_AdapterAPI::Set_countryIeFor2_4_Ghz( country_t countryIe)
   2411 {
   2412     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2413     tiUINT32 dwRetSize;
   2414 
   2415     dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_SET_COUNTRY_2_4, &countryIe, sizeof(country_t), NULL, 0, &dwRetSize);
   2416 
   2417     return dwRetValue;
   2418 }
   2419 /********************************************************************/
   2420 tiINT32
   2421 CTI_WLAN_AdapterAPI::Get_countryIeFor2_4_Ghz( tiUINT8 **countryString)
   2422 {
   2423     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2424     tiUINT32 dwRetSize;
   2425 
   2426     if ( countryString )
   2427     {
   2428         dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_GET_COUNTRY_2_4, NULL, 0, countryString, COUNTRY_STRING_LEN,&dwRetSize);
   2429     }
   2430     return dwRetValue;
   2431 }
   2432 
   2433 /********************************************************************/
   2434 tiINT32
   2435 CTI_WLAN_AdapterAPI::Set_countryIeFor5_Ghz( country_t countryIe)
   2436 {
   2437     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2438     tiUINT32 dwRetSize;
   2439 
   2440     dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_SET_COUNTRY_5, &countryIe, sizeof(country_t), NULL, 0, &dwRetSize);
   2441 
   2442     return dwRetValue;
   2443 }
   2444 /********************************************************************/
   2445 tiINT32
   2446 CTI_WLAN_AdapterAPI::Get_countryIeFor5_Ghz( tiUINT8 **countryString)
   2447 {
   2448     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2449     tiUINT32 dwRetSize;
   2450 
   2451     if ( countryString )
   2452     {
   2453         dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_GET_COUNTRY_5, NULL, 0, countryString, COUNTRY_STRING_LEN,&dwRetSize);
   2454     }
   2455     return dwRetValue;
   2456 }
   2457 
   2458 
   2459 /********************************************************************/
   2460 tiINT32
   2461 CTI_WLAN_AdapterAPI::Set_minMaxDfsChannels( DFS_ChannelRange_t DFS_ChannelRange)
   2462 {
   2463 	tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2464 	tiUINT32 dwRetSize;
   2465 
   2466     dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_SET_DFS_RANGE, &DFS_ChannelRange, sizeof(DFS_ChannelRange_t), NULL, 0, &dwRetSize);
   2467 
   2468     return dwRetValue;
   2469 }
   2470 /********************************************************************/
   2471 tiINT32
   2472 CTI_WLAN_AdapterAPI::Get_minMaxDfsChannels( DFS_ChannelRange_t *DFS_ChannelRange)
   2473 {
   2474 	tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2475 	tiUINT32 dwRetSize;
   2476 
   2477     if ( DFS_ChannelRange )
   2478     {
   2479         dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_GET_DFS_RANGE, NULL, 0, DFS_ChannelRange, sizeof(DFS_ChannelRange_t), &dwRetSize);
   2480     }
   2481     return dwRetValue;
   2482 }
   2483 
   2484 /********************************************************************/
   2485 tiINT32
   2486 CTI_WLAN_AdapterAPI::SetIBSSProtection( tiUINT32 uProtection )
   2487 {
   2488     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2489     tiUINT32 dwRetSize;
   2490 
   2491     dwRetValue = tiIoCtrl(TIWLN_IBSS_PROTECTION_SET, &uProtection, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   2492 
   2493     return dwRetValue;
   2494 }
   2495 /********************************************************************/
   2496 tiINT32
   2497 CTI_WLAN_AdapterAPI::GetIBSSProtection ( tiUINT32* puProtection )
   2498 {
   2499     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2500     tiUINT32 dwRetSize;
   2501 
   2502     if ( puProtection )
   2503     {
   2504         dwRetValue = tiIoCtrl(TIWLN_IBSS_PROTECTION_GET, NULL, 0, puProtection, sizeof(tiUINT32),&dwRetSize);
   2505     }
   2506     return dwRetValue;
   2507 }
   2508 /********************************************************************/
   2509 tiINT32
   2510 CTI_WLAN_AdapterAPI::SetShortSlot( tiUINT32 dwShortSlot )
   2511 {
   2512     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2513     tiUINT32 dwRetSize;
   2514 
   2515     dwRetValue = tiIoCtrl(TIWLN_SHORT_SLOT_SET, &dwShortSlot, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   2516 
   2517     return dwRetValue;
   2518 }
   2519 /********************************************************************/
   2520 tiINT32
   2521 CTI_WLAN_AdapterAPI::GetShortSlot( tiUINT32* pdwShortSlot)
   2522 {
   2523     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2524     tiUINT32 dwRetSize;
   2525 
   2526     if ( pdwShortSlot )
   2527     {
   2528         dwRetValue = tiIoCtrl(TIWLN_SHORT_SLOT_GET, NULL, 0, pdwShortSlot, sizeof(tiUINT32),&dwRetSize);
   2529     }
   2530     return dwRetValue;
   2531 }
   2532 /********************************************************************/
   2533 tiINT32
   2534 CTI_WLAN_AdapterAPI::SetExtRatesIE( tiUINT32 dwExtRatesIE)
   2535 {
   2536     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2537     tiUINT32 dwRetSize;
   2538 
   2539     dwRetValue = tiIoCtrl(TIWLN_EXT_RATES_IE_SET, &dwExtRatesIE, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   2540 
   2541     return dwRetValue;
   2542 }
   2543 /********************************************************************/
   2544 tiINT32
   2545 CTI_WLAN_AdapterAPI::GetExtRatesIE( tiUINT32* pdwExtRatesIE)
   2546 {
   2547     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2548     tiUINT32 dwRetSize;
   2549 
   2550     if ( pdwExtRatesIE )
   2551     {
   2552         dwRetValue = tiIoCtrl(TIWLN_EXT_RATES_IE_GET, NULL, 0, pdwExtRatesIE, sizeof(tiUINT32),&dwRetSize);
   2553     }
   2554     return dwRetValue;
   2555 }
   2556 
   2557 /********************************************************************/
   2558 tiINT32
   2559 CTI_WLAN_AdapterAPI::SetEarlyWakeupMode( tiUINT8 dwEarlyWakeup)
   2560 {
   2561     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2562     tiUINT32 dwRetSize;
   2563 
   2564     dwRetValue = tiIoCtrl(TIWLN_EARLY_WAKEUP_IE_SET, &dwEarlyWakeup, sizeof(tiUINT8),NULL, 0,&dwRetSize);
   2565 
   2566     return dwRetValue;
   2567 }
   2568 
   2569 /********************************************************************/
   2570 tiINT32
   2571 CTI_WLAN_AdapterAPI::GetEarlyWakeupMode( tiUINT8* pdwEarlyWakeup)
   2572 {
   2573     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2574     tiUINT32 dwRetSize;
   2575 
   2576     if ( pdwEarlyWakeup )
   2577     {
   2578         dwRetValue = tiIoCtrl(TIWLN_EARLY_WAKEUP_IE_GET, NULL, 0, pdwEarlyWakeup, sizeof(tiUINT8),&dwRetSize);
   2579     }
   2580     return dwRetValue;
   2581 }
   2582 
   2583 /********************************************************************/
   2584 
   2585 tiINT32
   2586 CTI_WLAN_AdapterAPI::Open_EAPOL_Interface( )
   2587 {
   2588     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2589     tiUINT32 dwRetSize;
   2590 
   2591     dwRetValue = tiIoCtrl(TIWLN_OPEN_EAPOL_INTERFACE, NULL, 0, NULL, 0,&dwRetSize);
   2592 
   2593     return dwRetValue;
   2594 }
   2595 /********************************************************************/
   2596 tiINT32
   2597 CTI_WLAN_AdapterAPI::Close_EAPOL_Interface( )
   2598 {
   2599     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2600     tiUINT32 dwRetSize;
   2601 
   2602     dwRetValue = tiIoCtrl(TIWLN_CLOSE_EAPOL_INTERFACE, NULL, 0, NULL, 0,&dwRetSize);
   2603 
   2604     return dwRetValue;
   2605 }
   2606 /********************************************************************/
   2607 tiINT32
   2608 CTI_WLAN_AdapterAPI::Send_EAPOL_Packet( tiVOID* pData, tiUINT32 uSize )
   2609 {
   2610     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2611     tiUINT32 dwRetSize;
   2612 
   2613     if ( pData && CheckObjectMemory(pData, uSize) )
   2614     {
   2615         dwRetValue = tiIoCtrl(TIWLN_SEND_EAPOL_PACKET, pData, uSize,NULL, 0,&dwRetSize);
   2616     }
   2617 
   2618     return dwRetValue;
   2619 }
   2620 /********************************************************************/
   2621 tiINT32
   2622 CTI_WLAN_AdapterAPI::hwReadRegister( tiUINT32 dwRegisterAddr, tiUINT32* pdwValue )
   2623 {
   2624     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2625     tiUINT32 dwRetSize;
   2626     TIWLN_REG_RW sRegRead;
   2627 
   2628     if (!pdwValue )
   2629         return TI_RESULT_FAILED;
   2630 
   2631     sRegRead.regSize = 4;
   2632     sRegRead.regAddr = dwRegisterAddr;
   2633     sRegRead.regValue = 0;
   2634 
   2635     dwRetValue = tiIoCtrl(TIWLN_HW_READ_REGISTER, &sRegRead, sizeof(TIWLN_REG_RW), &sRegRead, sizeof(TIWLN_REG_RW),&dwRetSize);
   2636 
   2637     *pdwValue = sRegRead.regValue;
   2638     return dwRetValue;
   2639 }
   2640 /********************************************************************/
   2641 tiINT32
   2642 CTI_WLAN_AdapterAPI::hwWriteRegister( tiUINT32 dwRegisterAddr, tiUINT32 dwValue )
   2643 {
   2644     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2645     tiUINT32 dwRetSize;
   2646     TIWLN_REG_RW sRegRead;
   2647 
   2648     sRegRead.regSize     = 4;
   2649     sRegRead.regAddr     = dwRegisterAddr;
   2650     sRegRead.regValue    = dwValue;
   2651 
   2652     dwRetValue = tiIoCtrl(TIWLN_HW_WRITE_REGISTER, &sRegRead, sizeof(TIWLN_REG_RW),NULL, 0,&dwRetSize);
   2653 
   2654     return dwRetValue;
   2655 }
   2656 /********************************************************************/
   2657 tiINT32
   2658 CTI_WLAN_AdapterAPI::Disassociate( )
   2659 {
   2660     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2661     tiUINT32 dwRetSize;
   2662 
   2663     dwRetValue = tiIoCtrl(TIWLN_802_11_DISASSOCIATE, NULL, 0,NULL, 0,&dwRetSize);
   2664     return dwRetValue;
   2665 }
   2666 /********************************************************************/
   2667 tiINT32
   2668 CTI_WLAN_AdapterAPI::ReloadDefaults( )
   2669 {
   2670     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2671     tiUINT32 dwRetSize;
   2672 
   2673     dwRetValue = tiIoCtrl(TIWLN_802_11_RELOAD_DEFAULTS, NULL, 0,NULL, 0,&dwRetSize);
   2674 
   2675     return dwRetValue;
   2676 }
   2677 /********************************************************************/
   2678 
   2679 tiINT32
   2680 CTI_WLAN_AdapterAPI::IsDriverLoaded( )
   2681 {
   2682     tiUINT32 bRet = TI_RESULT_FAILED;
   2683 #ifndef _WINDOWS
   2684 
   2685     TI_HANDLE hDevice = m_pIPCmod->IPC_DeviceOpen(m_pszAdapterName);
   2686     if (hDevice)
   2687         bRet = TI_RESULT_OK;
   2688 
   2689     m_pIPCmod->IPC_DeviceClose();
   2690 #endif
   2691     return bRet;
   2692 }
   2693 
   2694 /********************************************************************/
   2695 tiINT32
   2696 CTI_WLAN_AdapterAPI::GetRSSI( tiINT32* pRssi )
   2697 {
   2698     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2699     tiUINT32 dwRetSize;
   2700 
   2701 
   2702     if (CheckObjectMemory(pRssi, sizeof(tiUINT32)))
   2703     {
   2704         dwRetValue = tiIoCtrl(TIWLN_802_11_RSSI,NULL,0,pRssi, sizeof(tiUINT32),&dwRetSize);
   2705     }
   2706     return dwRetValue;
   2707 }
   2708 
   2709 /********************************************************************/
   2710 tiINT32
   2711 CTI_WLAN_AdapterAPI::GetSNR( tiUINT32* pSnr )
   2712 {
   2713     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2714     tiUINT32 dwRetSize;
   2715 
   2716 
   2717     if (CheckObjectMemory(pSnr, sizeof(tiUINT32)))
   2718     {
   2719         dwRetValue = tiIoCtrl(TIWLN_802_11_SNR,NULL,0,pSnr, sizeof(tiUINT32),&dwRetSize);
   2720     }
   2721     return dwRetValue;
   2722 }
   2723 
   2724 /********************************************************************/
   2725 tiINT32
   2726 CTI_WLAN_AdapterAPI::GetNumberOfAntennas(tiUINT32* puNumberOfAntennas)
   2727 {
   2728     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2729     tiUINT32 dwRetSize;
   2730 
   2731     if ( puNumberOfAntennas )
   2732     {
   2733         dwRetValue = tiIoCtrl(TIWLN_802_11_NUMBER_OF_ANTENNAS, NULL, 0, puNumberOfAntennas, sizeof(tiUINT32),&dwRetSize);
   2734     }
   2735     return dwRetValue;
   2736 }
   2737 /********************************************************************/
   2738 tiINT32
   2739 CTI_WLAN_AdapterAPI::GetDriverVersion( TIWLN_VERSION_EX* pdrvVersion )
   2740 {
   2741     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2742     tiUINT32 dwRetSize;
   2743 
   2744     if ( pdrvVersion && CheckObjectMemory(pdrvVersion, sizeof(TIWLN_VERSION_EX)) )
   2745     {
   2746         dwRetValue = tiIoCtrl(TIWLN_GET_SW_VERSION, NULL, 0, pdrvVersion, sizeof(TIWLN_VERSION_EX),&dwRetSize);
   2747     }
   2748     return dwRetValue;
   2749 }
   2750 /********************************************************************/
   2751 tiINT32
   2752 CTI_WLAN_AdapterAPI::GetRegDomainTable( TIWLN_REGDOMAINS* pRegDomainTable )
   2753 {
   2754     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2755     tiUINT32 dwRetSize;
   2756 
   2757     if ( pRegDomainTable && CheckObjectMemory(pRegDomainTable, sizeof(TIWLN_REGDOMAINS)) )
   2758     {
   2759         dwRetValue = tiIoCtrl(TIWLN_REGDOMAIN_TABLE, NULL, 0, pRegDomainTable, sizeof(TIWLN_REGDOMAINS),&dwRetSize);
   2760     }
   2761     return dwRetValue;
   2762 }
   2763 /********************************************************************/
   2764 tiINT32
   2765 CTI_WLAN_AdapterAPI::GetMediumUsage( TIWLN_MEDIUM_USAGE* pMediumUsage )
   2766 {
   2767     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2768     tiUINT32 dwRetSize;
   2769 
   2770     if ( pMediumUsage && CheckObjectMemory(pMediumUsage, sizeof(TIWLN_MEDIUM_USAGE)) )
   2771     {
   2772         dwRetValue = tiIoCtrl(TIWLN_MEDIUMUSAGE, NULL, 0, pMediumUsage, sizeof(TIWLN_MEDIUM_USAGE),&dwRetSize);
   2773     }
   2774     return dwRetValue;
   2775 }
   2776 /********************************************************************/
   2777 tiINT32
   2778 CTI_WLAN_AdapterAPI::GetApiVersion( tiUINT32* pdwApiVersion )
   2779 {
   2780     *pdwApiVersion = TI_WLAN_API_VER;
   2781     return TI_RESULT_OK;
   2782 }
   2783 /********************************************************************/
   2784 tiINT32
   2785 CTI_WLAN_AdapterAPI::GetDriverState( driverState_e* puDriverState )
   2786 {
   2787     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2788     tiUINT32 dwRetSize;
   2789 
   2790     *puDriverState = (driverState_e)0;
   2791     dwRetValue = tiIoCtrl(TIWLN_802_11_GET_DRIVER_STATE, NULL, 0, puDriverState, sizeof(tiUINT32),&dwRetSize);
   2792 
   2793     switch (((driverState_e)*puDriverState) & 0xff)
   2794     {
   2795     case SM_STATE_IDLE:
   2796         *puDriverState = DRIVER_STATE_IDLE;
   2797         break;
   2798     case SM_STATE_SCANNING:
   2799         *puDriverState = DRIVER_STATE_SCANNING;
   2800         break;
   2801     case SM_STATE_SELECTING:
   2802         *puDriverState = DRIVER_STATE_SELECTING;
   2803         break;
   2804     case SM_STATE_CONNECTING:
   2805         *puDriverState = DRIVER_STATE_CONNECTING;
   2806         break;
   2807     case SM_STATE_CONNECTED:
   2808     case SM_STATE_QUIET_SCAN:
   2809     case SM_STATE_ROAMING_QUIET_SCAN:
   2810     case SM_STATE_MEASUREMENT:
   2811     case SM_STATE_POWER_MNGR_PENDS_QUIET_SCAN:
   2812         *puDriverState = DRIVER_STATE_CONNECTED;
   2813         break;
   2814     case SM_STATE_INTER_SCAN_TIMEOUT:
   2815         *puDriverState = DRIVER_STATE_DISCONNECTED;
   2816         break;
   2817     case SM_STATE_RADIO_STAND_BY:
   2818         *puDriverState = DRIVER_STATE_IDLE;
   2819         break;
   2820     default:
   2821         break;
   2822     }
   2823 
   2824     return dwRetValue;
   2825 }
   2826 /********************************************************************/
   2827 
   2828 tiINT32
   2829 CTI_WLAN_AdapterAPI::Start( )
   2830 {
   2831     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2832     tiUINT32 dwRetSize;
   2833     tiUINT32 Data = 1;
   2834 
   2835     dwRetValue = tiIoCtrl(TIWLN_DRIVER_STATUS_SET, &Data, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   2836     return dwRetValue;
   2837 }
   2838 /********************************************************************/
   2839 tiINT32
   2840 CTI_WLAN_AdapterAPI::Stop( )
   2841 {
   2842     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2843     tiUINT32 dwRetSize;
   2844     tiUINT32 Data = 0;
   2845     dwRetValue = tiIoCtrl(TIWLN_DRIVER_STATUS_SET, &Data, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   2846     return dwRetValue;
   2847 }
   2848 /********************************************************************/
   2849 tiINT32
   2850 CTI_WLAN_AdapterAPI::Suspend( )
   2851 {
   2852     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2853     tiUINT32 dwRetSize;
   2854     tiUINT32 Data = 0;
   2855 
   2856     dwRetValue = tiIoCtrl(TIWLN_DRIVER_SUSPEND, &Data, sizeof(tiUINT32),NULL, 0,&dwRetSize);
   2857 
   2858     return dwRetValue;
   2859 }
   2860 /********************************************************************/
   2861 tiINT32
   2862 CTI_WLAN_AdapterAPI::IsDriverRun( tiUINT32* pbStatus )
   2863 {
   2864     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   2865     tiUINT32 dwRetSize;
   2866 
   2867     if ( pbStatus && CheckObjectMemory(pbStatus, sizeof(tiUINT32)) )
   2868     {
   2869         dwRetValue = tiIoCtrl(TIWLN_DRIVER_STATUS_GET, NULL, 0, pbStatus, sizeof(tiUINT32),&dwRetSize);
   2870     }
   2871 
   2872     return dwRetValue;
   2873 }
   2874 #define GWSI_DISPACH_OPCODE(_p_gwsi_buffer)				((*((tiUINT8 *)_p_gwsi_buffer + 0) | (*((tiUINT8 *)_p_gwsi_buffer + 1) << 8)))
   2875 #define GWSI_DISPACH_CALC_BUFFER_SHORT_LEN(_p_gwsi_buffer)	((*((tiUINT8 *)_p_gwsi_buffer + 2) | (*((tiUINT8 *)_p_gwsi_buffer + 3) << 8)) + 4)
   2876 #define GWSI_DISPACH_CALC_BUFFER_LONG_LEN(_p_gwsi_buffer)	(*((tiUINT8 *)_p_gwsi_buffer + 2) | (*((tiUINT8 *)_p_gwsi_buffer + 3) << 8) | (*((tiUINT8 *)_p_gwsi_buffer + 4) << 16) | (*((tiUINT8 *)_p_gwsi_buffer + 5) << 24) + 4)
   2877 /********************************************************************/
   2878 tiINT32
   2879 CTI_WLAN_AdapterAPI::GWSICommand( tiUINT32* pGWSICommand )
   2880 {
   2881     tiUINT32 bRet = TI_RESULT_FAILED;
   2882     tiUINT32 dwRetSize;
   2883 
   2884     dwRetSize = tiIoCtrl(GWSI_DISPATCH_COMMAND, pGWSICommand, GWSI_DISPACH_CALC_BUFFER_SHORT_LEN(pGWSICommand));
   2885 
   2886     if ( dwRetSize  )
   2887         bRet = TI_RESULT_OK;
   2888 
   2889 
   2890     return bRet;
   2891 }
   2892 
   2893 /********************************************************************/
   2894 tiINT32
   2895 CTI_WLAN_AdapterAPI::GWSIInitialize( tiUINT32* pGWSICommand )
   2896 {
   2897     tiUINT32 bRet = TI_RESULT_FAILED;
   2898     tiUINT32 dwRetSize;
   2899 
   2900     /* This command requires size of 4 bytes */
   2901     dwRetSize = tiIoCtrl(GWSI_INITIALIZE_COMMAND, pGWSICommand, GWSI_DISPACH_CALC_BUFFER_LONG_LEN(pGWSICommand));
   2902 
   2903     if ( dwRetSize  )
   2904         bRet = TI_RESULT_OK;
   2905 
   2906 
   2907     return bRet;
   2908 }
   2909 
   2910 /********************************************************************/
   2911 tiINT32
   2912 CTI_WLAN_AdapterAPI::GWSIConfig( tiUINT32* pGWSICommand )
   2913 {
   2914     tiUINT32 bRet = TI_RESULT_FAILED;
   2915     tiUINT32 dwRetSize;
   2916 
   2917     dwRetSize = tiIoCtrl(GWSI_CONFIGURE_TABLE_COMMAND, pGWSICommand, GWSI_DISPACH_CALC_BUFFER_SHORT_LEN(pGWSICommand));
   2918 
   2919     if ( dwRetSize  )
   2920         bRet = TI_RESULT_OK;
   2921 
   2922 
   2923     return bRet;
   2924 }
   2925 
   2926 /********************************************************************/
   2927 tiINT32
   2928 CTI_WLAN_AdapterAPI::GWSIRelease( tiUINT32* pGWSICommand )
   2929 {
   2930     tiUINT32 bRet = TI_RESULT_FAILED;
   2931     tiUINT32 dwRetSize;
   2932 
   2933     dwRetSize = tiIoCtrl(GWSI_RELEASE_COMMAND, pGWSICommand, GWSI_DISPACH_CALC_BUFFER_SHORT_LEN(pGWSICommand));
   2934 
   2935     if ( dwRetSize  )
   2936         bRet = TI_RESULT_OK;
   2937 
   2938 
   2939     return bRet;
   2940 }
   2941 
   2942 /********************************************************************/
   2943 tiINT32
   2944 CTI_WLAN_AdapterAPI::GWSIGetInitTable (tiUINT32* pGWSICommand )
   2945 {
   2946     tiUINT32 bRet = TI_RESULT_FAILED;
   2947     tiUINT32 dwRetSize;
   2948 
   2949     dwRetSize = tiIoCtrl(GWSI_GET_INIT_TABLE_COMMAND, NULL, 0, pGWSICommand, (1024 * 5));
   2950 
   2951     if ( dwRetSize  )
   2952         bRet = TI_RESULT_OK;
   2953 
   2954 
   2955     return bRet;
   2956 }
   2957 
   2958 #ifndef _WINDOWS
   2959 	/********************************************************************/
   2960 	tiINT32
   2961 	TI_IPC::IPC_DeviceIoControl(tiUINT32 dwIoControlCode, tiVOID* lpInBuffer,
   2962 								tiUINT32 nInBufferSize, tiVOID* lpOutBuffer,
   2963 								tiUINT32 nOutBufferSize, tiUINT32* lpBytesReturned)
   2964 	{
   2965 		if (!m_hDevice)
   2966 			return TI_RESULT_INVALIDE_HANDLE;
   2967 
   2968 		return ::IPC_DeviceIoControl(m_hDevice, dwIoControlCode, lpInBuffer,
   2969 			nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned);
   2970 	}
   2971 
   2972 	TI_IPC::TI_IPC()
   2973 	{
   2974 		m_hDevice = NULL;
   2975 		IPC_Init();
   2976 	}
   2977 
   2978 	TI_IPC::~TI_IPC()
   2979 	{
   2980 		IPC_DeInit();
   2981 	}
   2982 
   2983 	TI_HANDLE
   2984 	TI_IPC::IPC_DeviceOpen (tiCHAR* pAdapterName)
   2985 	{
   2986 		m_hDevice = ::IPC_DeviceOpen(pAdapterName);
   2987 		return m_hDevice;
   2988 	}
   2989 
   2990 	tiVOID
   2991 	TI_IPC::IPC_DeviceClose()
   2992 	{
   2993 		::IPC_DeviceClose(m_hDevice);
   2994 		m_hDevice = NULL;
   2995 	}
   2996 
   2997 	tiINT32
   2998 	TI_IPC::IPC_RegisterEvent( IPC_EVENT_PARAMS* pEventParams )
   2999 	{
   3000 		return ::IPC_RegisterEvent(m_hDevice, pEventParams);
   3001 	}
   3002 
   3003 
   3004 	tiINT32
   3005 	TI_IPC::IPC_UnRegisterEvent( IPC_EVENT_PARAMS* pEventParams )
   3006 	{
   3007 		return ::IPC_UnRegisterEvent(m_hDevice, pEventParams);
   3008 	}
   3009 #endif
   3010 /********************************************************************/
   3011 tiINT32
   3012 CTI_WLAN_AdapterAPI::Set_RoamingConfParams( UINT8* buffer, UINT16 bufferLength)
   3013 {
   3014     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3015     tiUINT32 dwRetSize;
   3016 
   3017     dwRetValue = tiIoCtrl(TIWLN_802_11_ROAMING_CONFIG_PARAMS_SET, buffer, bufferLength,NULL,0,&dwRetSize);
   3018 
   3019     return dwRetValue;
   3020 }
   3021 /********************************************************************/
   3022 tiINT32
   3023 CTI_WLAN_AdapterAPI::Get_RoamingConfParams( UINT8* buffer, UINT16 bufferLength)
   3024 {
   3025     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3026     tiUINT32 dwRetSize;
   3027 
   3028     if (CheckObjectMemory(buffer, bufferLength))
   3029     {
   3030         dwRetValue = tiIoCtrl(TIWLN_802_11_ROAMING_CONFIG_PARAMS_GET, NULL, 0, buffer, bufferLength, &dwRetSize);
   3031     }
   3032 
   3033     return dwRetValue;
   3034 }
   3035 /********************************************************************/
   3036 
   3037 /****************************   PLT  ********************************/
   3038 
   3039 /********************************************************************/
   3040 tiINT32
   3041 CTI_WLAN_AdapterAPI::PLT_ReadRegister( UINT32 uRegisterAddr, PUINT32 puRegisterData )
   3042 {
   3043     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3044     tiUINT32 dwRetSize;
   3045 
   3046     if (CheckObjectMemory(puRegisterData, sizeof(UINT32)))
   3047     {
   3048         dwRetValue = tiIoCtrl(TIWLN_PLT_READ_REGISTER, &uRegisterAddr, sizeof(UINT32), puRegisterData, sizeof(UINT32), &dwRetSize);
   3049     }
   3050 
   3051     return dwRetValue;
   3052 }
   3053 
   3054 /********************************************************************/
   3055 
   3056 tiINT32
   3057 CTI_WLAN_AdapterAPI::PLT_WriteRegister( UINT32 uRegisterAddr, UINT32 uRegisterData )
   3058 {
   3059     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3060     tiUINT32 dwRetSize;
   3061 
   3062     TIWLN_REG_RW sRegWrite;
   3063 
   3064     sRegWrite.regSize     = 4;
   3065     sRegWrite.regAddr     = uRegisterAddr;
   3066     sRegWrite.regValue    = uRegisterData;
   3067 
   3068     dwRetValue = tiIoCtrl(TIWLN_PLT_WRITE_REGISTER, &sRegWrite, sizeof(TIWLN_REG_RW),NULL, 0,&dwRetSize);
   3069 
   3070 
   3071     return dwRetValue;
   3072 }
   3073 
   3074 
   3075 /********************************************************************/
   3076 
   3077 tiINT32
   3078 CTI_WLAN_AdapterAPI::PLT_RxPerStart()
   3079 {
   3080     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3081     tiUINT32 dwRetSize;
   3082 
   3083     dwRetValue = tiIoCtrl(TIWLN_PLT_RX_PER_START, NULL, 0, NULL, 0, &dwRetSize);
   3084 
   3085     return dwRetValue;
   3086 }
   3087 
   3088 /********************************************************************/
   3089 
   3090 tiINT32
   3091 CTI_WLAN_AdapterAPI::PLT_RxPerStop()
   3092 {
   3093     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3094     tiUINT32 dwRetSize;
   3095 
   3096     dwRetValue = tiIoCtrl(TIWLN_PLT_RX_PER_STOP, NULL, 0, NULL, 0, &dwRetSize);
   3097 
   3098     return dwRetValue;
   3099 }
   3100 
   3101 /********************************************************************/
   3102 
   3103 tiINT32
   3104 CTI_WLAN_AdapterAPI::PLT_RxPerClear()
   3105 {
   3106     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3107     tiUINT32 dwRetSize;
   3108 
   3109     dwRetValue = tiIoCtrl(TIWLN_PLT_RX_PER_CLEAR, NULL, 0, NULL, 0, &dwRetSize);
   3110 
   3111     return dwRetValue;
   3112 }
   3113 
   3114 /********************************************************************/
   3115 
   3116 tiINT32
   3117 CTI_WLAN_AdapterAPI::PLT_RxPerGetResults( PltRxPer_t* pPltRxPer )
   3118 {
   3119     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3120     tiUINT32 dwRetSize;
   3121 
   3122     if (CheckObjectMemory(pPltRxPer, sizeof(PltRxPer_t)))
   3123     {
   3124         dwRetValue = tiIoCtrl(TIWLN_PLT_RX_PER_GET_RESULTS, NULL, 0, pPltRxPer, sizeof(PltRxPer_t), &dwRetSize);
   3125     }
   3126 
   3127     return dwRetValue;
   3128 }
   3129 
   3130 
   3131 /********************************************************************/
   3132 
   3133 tiINT32
   3134 CTI_WLAN_AdapterAPI::PLT_TxCW(TestCmdChannelBand_t* pPltTxCW)
   3135 {
   3136     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3137     tiUINT32 dwRetSize;
   3138 
   3139     dwRetValue = tiIoCtrl(TIWLN_PLT_TX_CW, pPltTxCW, sizeof(*pPltTxCW), NULL, 0, &dwRetSize);
   3140 
   3141     return dwRetValue;
   3142 }
   3143 
   3144 /********************************************************************/
   3145 
   3146 tiINT32
   3147 CTI_WLAN_AdapterAPI::PLT_TxContiues(PltTxContinues_t* pPltTxContinues)
   3148 {
   3149     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3150     tiUINT32 dwRetSize;
   3151 
   3152     dwRetValue = tiIoCtrl(TIWLN_PLT_TX_CONTINUES, pPltTxContinues, sizeof(PltTxContinues_t), NULL, 0, &dwRetSize);
   3153 
   3154     return dwRetValue;
   3155 }
   3156 
   3157 /********************************************************************/
   3158 
   3159 tiINT32
   3160 CTI_WLAN_AdapterAPI::PLT_TxStop()
   3161 {
   3162     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3163     tiUINT32 dwRetSize;
   3164 
   3165     dwRetValue = tiIoCtrl(TIWLN_PLT_TX_STOP, NULL, 0, NULL, 0, &dwRetSize);
   3166 
   3167     return dwRetValue;
   3168 }
   3169 
   3170 /********************************************************************/
   3171 tiINT32
   3172 CTI_WLAN_AdapterAPI::PLT_ReadMIB ( PLT_MIB_t* pMib )
   3173 {
   3174     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3175     tiUINT32 dwRetSize;
   3176     if (CheckObjectMemory(pMib, sizeof(PLT_MIB_t)))
   3177     {
   3178       dwRetValue = tiIoCtrl(TIWLN_PLT_MIB_READ,
   3179 							  (tiVOID*)pMib,(tiUINT32)sizeof(PLT_MIB_t),
   3180 							  (tiVOID*)pMib,(tiUINT32)sizeof(PLT_MIB_t),
   3181 							  &dwRetSize);
   3182     }
   3183     return dwRetValue;
   3184 }
   3185 
   3186 /********************************************************************/
   3187 tiINT32
   3188 CTI_WLAN_AdapterAPI::PLT_WriteMIB( PLT_MIB_t* pMib )
   3189 {
   3190     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3191     tiUINT32 dwRetSize;
   3192     dwRetValue = tiIoCtrl(TIWLN_PLT_MIB_WRITE,
   3193 						  pMib, sizeof(PLT_MIB_t),
   3194 						  NULL, 0,
   3195 						  &dwRetSize);
   3196     return dwRetValue;
   3197 }
   3198 
   3199 
   3200 /********************************************************************/
   3201 tiINT32
   3202 CTI_WLAN_AdapterAPI::GetDefaultWepKey(  tiUINT32* puKeyIndex )
   3203 {
   3204     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3205     tiUINT32 dwRetSize;
   3206     UINT32 InfoCode = VAL_DEFAULT_KEY_ID;
   3207 
   3208     dwRetValue = tiIoCtrl(TIWLN_IOCTL_OID_QUERY_INFORMATION, &InfoCode, (tiUINT32)sizeof(InfoCode), puKeyIndex, sizeof(tiUINT32), &dwRetSize);
   3209     return dwRetValue;
   3210 }
   3211 
   3212 /********************************************************************/
   3213 tiINT32
   3214 CTI_WLAN_AdapterAPI::PLT_TxCalGainGet(PltGainGet_t* pPLTGainGet)
   3215 {
   3216     return PLT_RxTXCal((void*)pPLTGainGet, sizeof(PltGainGet_t), TEST_CMD_PLT_GAIN_GET);
   3217 }
   3218 
   3219 /********************************************************************/
   3220 tiINT32
   3221 CTI_WLAN_AdapterAPI::PLT_TxCalGainAdjust(tiINT32   uTxGainChange)
   3222 {
   3223     return PLT_RxTXCal(&uTxGainChange, sizeof(tiINT32), TEST_CMD_PLT_GAIN_ADJUST);
   3224 }
   3225 
   3226 /********************************************************************/
   3227 tiINT32
   3228 CTI_WLAN_AdapterAPI::PLT_TxCalStart(PltTxCalibrationRequest_t* pPLTTxCal)
   3229 {
   3230     return PLT_RxTXCal((void*)pPLTTxCal, sizeof(PltTxCalibrationRequest_t), TEST_CMD_PLT_TXPOWER_CAL_START);
   3231 }
   3232 
   3233 /********************************************************************/
   3234 tiINT32
   3235 CTI_WLAN_AdapterAPI::PLT_TxCalStop()
   3236 {
   3237     return PLT_RxTXCal(NULL, 0, TEST_CMD_PLT_TXPOWER_CAL_STOP);
   3238 }
   3239 
   3240 /********************************************************************/
   3241 tiINT32
   3242 CTI_WLAN_AdapterAPI::PLT_RxTxCalNVSUpdateBuffer(PltNvsResultsBuffer_t* pPLT_NVSUpdateBuffer)
   3243 {
   3244     return PLT_RxTXCal(pPLT_NVSUpdateBuffer, sizeof(PltNvsResultsBuffer_t), TEST_CMD_PLT_GET_NVS_UPDATE_BUFFER);
   3245 }
   3246 
   3247 /********************************************************************/
   3248 tiINT32
   3249 CTI_WLAN_AdapterAPI::PLT_RxCal(PltRxCalibrationRequest_t* pPltRxCalibration)
   3250 {
   3251     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3252     tiUINT32 dwRetSize;
   3253     TestCmd_t TestCmd;
   3254 
   3255     if ( CheckObjectMemory(pPltRxCalibration, sizeof(PltRxCalibrationRequest_t)) )
   3256     {
   3257         memset(&TestCmd, 0, sizeof(TestCmd));
   3258         memcpy(&TestCmd.testCmd_u, pPltRxCalibration, sizeof(PltRxCalibrationRequest_t));
   3259         TestCmd.testCmdId = TEST_CMD_PLT_RX_CALIBRATION;
   3260 
   3261         dwRetValue = tiIoCtrl(TIWLN_PLT_RX_CAL,
   3262                               (tiVOID*) &TestCmd, sizeof(TestCmd),
   3263                               (tiVOID*) &TestCmd, sizeof(TestCmd),
   3264                               &dwRetSize);
   3265     }
   3266     /*
   3267      * for RX calibration, we query the status on a polling loop until it is complete.
   3268      * This is done to avoid a WinMobile bug, where returning pending will make Win re-send
   3269      * the OID after a while
   3270      * This is a patch, and a unified a-synchronous method must be implemented
   3271      * for all IOCTLs
   3272      */
   3273     if (TI_RESULT_OK == dwRetValue)
   3274     {
   3275         TI_STATUS   TIStatus = PENDING;
   3276         while ( PENDING == TIStatus )
   3277         {
   3278             dwRetValue = PLT_RxCalStatus( &TIStatus );
   3279             m_pOSLib->TISleep(100);
   3280         }
   3281     }
   3282     return dwRetValue;
   3283 }
   3284 
   3285 /********************************************************************/
   3286 tiINT32
   3287 CTI_WLAN_AdapterAPI::PLT_RadioTune(TestCmdChannelBand_t* pChannelBand)
   3288 {
   3289     return PLT_RxTXCal(pChannelBand, sizeof(TestCmdChannelBand_t), TEST_CMD_RADIO_TUNE);
   3290 }
   3291 
   3292 /********************************************************************/
   3293 tiINT32
   3294 CTI_WLAN_AdapterAPI::PLT_RxTXCal(void* pTestCmdData, tiUINT32 Length, TestCmdID_e TestCmdID)
   3295 {
   3296     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3297     tiUINT32 dwRetSize;
   3298     TestCmd_t TestCmd;
   3299 
   3300 
   3301     if ((Length==0) ||
   3302         (CheckObjectMemory(pTestCmdData, Length)))
   3303     {
   3304         memset(&TestCmd, 0, sizeof(TestCmd));
   3305         memcpy(&TestCmd.testCmd_u, pTestCmdData, Length);
   3306         TestCmd.testCmdId = TestCmdID;
   3307 
   3308         dwRetValue = tiIoCtrl(TIWLN_PLT_RX_TX_CAL,
   3309                               (tiVOID*) &TestCmd, sizeof(TestCmd),
   3310                               (tiVOID*) &TestCmd, sizeof(TestCmd),
   3311                               &dwRetSize);
   3312     }
   3313     if (TI_RESULT_OK == dwRetValue)
   3314     {
   3315         memcpy(pTestCmdData, &TestCmd.testCmd_u, Length);
   3316     }
   3317     return dwRetValue;
   3318 }
   3319 
   3320 /********************************************************************/
   3321 tiINT32
   3322 CTI_WLAN_AdapterAPI::PLT_RxCalStatus(TI_STATUS* pStatus)
   3323 {
   3324     tiUINT32 dwRetValue = TI_RESULT_FAILED;
   3325     tiUINT32 dwRetSize;
   3326 
   3327     dwRetValue = tiIoCtrl(TIWLN_PLT_RX_CAL_RESULT,
   3328                           NULL, 0, (tiVOID*)pStatus, sizeof(*pStatus), &dwRetSize);
   3329 
   3330     return dwRetValue;
   3331 }
   3332 
   3333 /********************************************************************/
   3334 #ifdef _WINDOWS
   3335 #endif
   3336 
   3337