/** 
 * \fn     sme_Destroy
 * \brief  Destroys the SME object. De-allocates system resources
 * 
 * Destroys the SME object. De-allocates system resources
 * 
 * \param  hSme - handle to the SME object
 * \return None
 * \sa     sme_Create
 */ 
void sme_Destroy (TI_HANDLE hSme)
{
    TSme        *pSme = (TSme*)hSme;

    /* destroy the scan result table */
    if (NULL != pSme->hScanResultTable)
    {
        scanResultTable_Destroy (pSme->hScanResultTable);
    }

    /* destroy the SME generic state machine */
    if (NULL != pSme->hSmeSm)
    {
        genSM_Unload (pSme->hSmeSm);
    }

    /* free the SME object */
    os_memoryFree (pSme->hOS, hSme, sizeof (TSme));
}
/** 
 * \fn     cmdHndlr_Destroy
 * \brief  Destroy the module object
 * 
 * Destroy the module object.
 * 
 * \note   
 * \param  hCmdHndlr - The object                                          
 * \return TI_OK 
 * \sa     
 */ 
TI_STATUS cmdHndlr_Destroy (TI_HANDLE hCmdHndlr, TI_HANDLE hEvHandler)
{
    TCmdHndlrObj *pCmdHndlr = (TCmdHndlrObj *)hCmdHndlr;

	if (pCmdHndlr->hCmdInterpret)
	{
		cmdInterpret_Destroy (pCmdHndlr->hCmdInterpret, hEvHandler);
	}


	if (pCmdHndlr->hCmdQueue)
	{
		que_Destroy (pCmdHndlr->hCmdQueue);
	}

	os_memoryFree (pCmdHndlr->hOs, hCmdHndlr, sizeof(TCmdHndlrObj));

    return TI_OK;
}
Exemple #3
0
/***********************************************************************
 *                        release_module									
 ***********************************************************************
DESCRIPTION:	Release all module resources - FSMs, timer and object.
                                                                                                   
INPUT:      hConn	-	Connection handle.

OUTPUT:		

RETURN:     void

************************************************************************/
static void release_module(conn_t *pConn)
{
	if (pConn->ibss_pFsm)
    {
		fsm_Unload (pConn->hOs, pConn->ibss_pFsm);
    }

    if (pConn->infra_pFsm)
    {
		fsm_Unload (pConn->hOs, pConn->infra_pFsm);
    }

	if (pConn->hConnTimer)
    {
		tmr_DestroyTimer (pConn->hConnTimer);
    }

	os_memoryFree(pConn->hOs, pConn, sizeof(conn_t));
}
Exemple #4
0
/**
*
* mainSec_config
*
* \b Description: 
*
* Init main security state machine state machine
*
* \b ARGS:
*
*  none
*
* \b RETURNS:
*
*  TI_OK on success, TI_NOK otherwise.
*
* \sa 
*/
TI_STATUS mainSec_unload(mainSec_t *pMainSec)
{
    TI_STATUS   status;

    if (pMainSec == NULL)
    {
        return TI_NOK;
    }

    status = mainKeys_unload(pMainSec->pMainKeys);

    status = fsm_Unload(pMainSec->hOs, pMainSec->pMainSecSm);

    status = externalSec_Destroy (pMainSec->pExternalSec);

    os_memoryFree(pMainSec->hOs, pMainSec, sizeof(mainSec_t));

    return TI_OK;
}
Exemple #5
0
static TI_STATUS connInfra_ScrWaitDisconn_to_disconnect(void *pData)
{
    TI_STATUS status;
    paramInfo_t *pParam;
    conn_t *pConn = (conn_t *)pData;
    
    status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys);
    if (status != TI_OK)
        return status;

    pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t));
    if (!pParam)
    {
        return TI_NOK;
    }

    pParam->paramType = RX_DATA_PORT_STATUS_PARAM;
    pParam->content.rxDataPortStatus = CLOSE;
    status = rxData_setParam(pConn->hRxData, pParam);
    if (status == TI_OK) 
    {
        /* Update TxMgmtQueue SM to close Tx path for all except Mgmt packets. */
        txMgmtQ_SetConnState (pConn->hTxMgmtQ, TX_CONN_STATE_MGMT);

        pParam->paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM;
        regulatoryDomain_setParam(pConn->hRegulatoryDomain, pParam);

        status = mlme_stop( pConn->hMlme, DISCONNECT_IMMEDIATE, pConn->disConnReasonToAP );
        if (status == TI_OK) 
        {
            /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the
                supported rates, and stopModules clears all rates. */
            stopModules(pConn, TI_TRUE);
    
            /* send disconnect command to firmware */
            prepare_send_disconnect(pData);
        }
    }

    os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    return status;
}
Exemple #6
0
/**
*
* Function  - externalSec_Destroy.
*
* \b Description:
*
* Called by mainSecSM (mainSec_unload).
*
* \b ARGS:
*
*
* \b RETURNS:
*
*  TI_STATUS - 0 on success, any other value on failure.
*
*/
TI_STATUS externalSec_Destroy(struct externalSec_t * pExternalSec)
{
	TI_STATUS status;

	if (pExternalSec == NULL) {
		return TI_NOK;
	}

	status = fsm_Unload(pExternalSec->hOs, pExternalSec->pExternalSecSm);
	if (status != TI_OK) {
		/* report failure but don't stop... */
		TRACE0(pExternalSec->hReport, REPORT_SEVERITY_ERROR,
		       "EXTERNAL SECURITY: Error releasing FSM memory \n");
	}

	os_memoryFree(pExternalSec->hOs, pExternalSec,
		      sizeof(struct externalSec_t));

	return TI_OK;
}
Exemple #7
0
/**
 * \fn     RxQueue_Destroy()
 * \brief  Destroy the module.
 *
 * Free the module's queues and object.
 *
 * \param  hRxQueue - The module object
 * \return TI_OK on success or TI_NOK on failure
 * \sa     RxQueue_Create
 */
TI_STATUS RxQueue_Destroy (TI_HANDLE hRxQueue)
{
	TRxQueue *pRxQueue;

	if (hRxQueue) {
		pRxQueue = (TRxQueue *)hRxQueue;

		if (pRxQueue->hMissingPktTimer) {
			tmr_DestroyTimer (pRxQueue->hMissingPktTimer);
			pRxQueue->hMissingPktTimer = NULL;
		}

		/* free module object */
		os_memoryFree (pRxQueue->hOs, pRxQueue, sizeof(TRxQueue));

		return TI_OK;
	}

	return TI_NOK;
}
Exemple #8
0
/****************************************************************************************
 *                        MacServices_destroy                                                    *
 *****************************************************************************************
DESCRIPTION: destroys MacServices module
                                                                                                                               
INPUT:          hMacServices - handle to the Mac Services object.
OUTPUT:     
RETURN:     
****************************************************************************************/
void MacServices_destroy( TI_HANDLE hMacServices ) 
{
    MacServices_t *pMacServices = (MacServices_t*)hMacServices;
    
    /* destroy all SRV modules */
    if ( NULL != pMacServices->hScanSRV )
    {
        MacServices_scanSRV_destroy( pMacServices->hScanSRV );
    }
    if ( NULL != pMacServices->hMeasurementSRV )
    {
        MacServices_measurementSRV_destroy( pMacServices->hMeasurementSRV );
    }

    if(pMacServices->hPowerSrv)
    powerSrv_destroy(pMacServices->hPowerSrv);

    /* free the Mac services allocated context */
    os_memoryFree( pMacServices->hOS, (TI_HANDLE)pMacServices , sizeof(MacServices_t) );
}
Exemple #9
0
/****************************************************************************************
 *                        os_memoryFree()
 ****************************************************************************************
DESCRIPTION:    This function releases a block of memory previously allocated with the
                os_memoryAlloc function.


ARGUMENTS:      OsContext   -   our adapter context.
                pMemPtr     -   Pointer to the base virtual address of the allocated memory.
                                This address was returned by the os_memoryAlloc function.
                Size        -   Specifies the size, in bytes, of the memory block to be released.
                                This parameter must be identical to the Length that was passed to
                                os_memoryAlloc.

RETURN:         None

NOTES:
*****************************************************************************************/
void mem_Free (TI_HANDLE hMem, void* ptr, TI_UINT32 size)
{
	TMemMng *pMemMng = (TMemMng *)hMem;
	TMemBlock *pMemBlock = (TMemBlock *)((TI_UINT8 *)ptr - sizeof(TMemBlock));


	if (pMemBlock->signature == MEM_BLOCK_START) {
		*(TI_UINT8 *)(&pMemBlock->signature) = '~';
		if (*(TI_UINT32 *)((TI_UINT8 *)pMemBlock + pMemBlock->size + sizeof(TMemBlock)) != MEM_BLOCK_END) {
		}

		os_memoryFree (pMemMng->hOs, pMemBlock, pMemBlock->signature + sizeof(TMemBlock) + sizeof(TI_UINT32));

		pMemMng->uCurAllocated -= size + sizeof(TMemBlock) + sizeof(TI_UINT32);

		if ((int)pMemMng->uCurAllocated < 0) {
			pMemMng->uCurAllocated = 0;
		}
	}
}
Exemple #10
0
/** 
 * \fn     twIf_Destroy
 * \brief  Destroy the module. 
 * 
 * Unregister from TxnQ and free the TxnDone-queue and the module's object.
 * 
 * \note   
 * \param  The module's object
 * \return TI_OK on success or TI_NOK on failure 
 * \sa     twIf_Create
 */ 
TI_STATUS twIf_Destroy (TI_HANDLE hTwIf)
{
    TTwIfObj *pTwIf = (TTwIfObj*)hTwIf;

    if (pTwIf)
    {
        txnQ_Close (pTwIf->hTxnQ, TXN_FUNC_ID_WLAN);
        if (pTwIf->hTxnDoneQueue)
        {
            que_Destroy (pTwIf->hTxnDoneQueue);
        }
        if (pTwIf->hPendRestartTimer)
        {
            tmr_DestroyTimer (pTwIf->hPendRestartTimer);
        }
        os_memoryFree (pTwIf->hOs, pTwIf, sizeof(TTwIfObj));     
    }

    return TI_OK;
}
Exemple #11
0
/***********************************************************************
 *                        healthMonitor_unload
 ***********************************************************************
DESCRIPTION: 
           
INPUT:      

OUTPUT:

RETURN: 

************************************************************************/
TI_STATUS healthMonitor_unload (TI_HANDLE hHealthMonitor)
{
    THealthMonitor *pHealthMonitor;

    pHealthMonitor = (THealthMonitor*)hHealthMonitor;

    if (pHealthMonitor != NULL)
    {
        if (NULL != pHealthMonitor->hFailTimer)
        {
            /* Release the timer */
            tmr_DestroyTimer (pHealthMonitor->hFailTimer);
        }

        /* Freeing the object should be called last !!!!!!!!!!!! */
        os_memoryFree (pHealthMonitor->hOs, pHealthMonitor, sizeof(THealthMonitor));
    }

    return TI_OK;
}
Exemple #12
0
/**
 * Releases the module's allocated objects according to the given init vector.
 * 
 * @param pMeasurementMgr A handle to the Measurement Manager module.
 * @param initVec The init vector with a bit set for each allocated object.
 * 
 * @date 01-Jan-2006
 */
static void measurementMgr_releaseModule (measurementMgr_t * pMeasurementMgr)
{

    if (pMeasurementMgr->hActivationDelayTimer)
    {
        tmr_DestroyTimer (pMeasurementMgr->hActivationDelayTimer);
    }


    if (pMeasurementMgr->pMeasurementMgrSm)
    {
        fsm_Unload(pMeasurementMgr->hOs, pMeasurementMgr->pMeasurementMgrSm);
    }

    if (pMeasurementMgr->hRequestH)
    {
        requestHandler_destroy(pMeasurementMgr->hRequestH);
    }
    
    os_memoryFree(pMeasurementMgr->hOs, pMeasurementMgr, sizeof(measurementMgr_t));
}
/**
*
* assocunload - unload association SM from memory
*
* \b Description: 
*
* Unload association SM from memory
*
* \b ARGS:
*
*  I   - hAssoc - association SM context  \n
*
* \b RETURNS:
*
*  OK if successful, NOK otherwise.
*
* \sa rsn_mainSecSmKeysOnlyStop()
*/
TI_STATUS assoc_unload(TI_HANDLE hAssoc)
{
    TI_STATUS 		status;
	assoc_t		*pHandle;

	pHandle = (assoc_t*)hAssoc;

	status = fsm_Unload(pHandle->hOs, pHandle->pAssocSm);
    if (status != OK)
	{
		/* report failure but don't stop... */
		WLAN_REPORT_ERROR(pHandle->hReport, ASSOC_MODULE_LOG,
				  ("ASSOC_SM: Error releasing FSM memory \n"));
	}
	
	os_timerDestroy(pHandle->hOs, pHandle->timer);
	
	os_memoryFree(pHandle->hOs, hAssoc, sizeof(assoc_t));

	return OK;
}
Exemple #14
0
/** 
 * \fn     txDataQ_Destroy
 * \brief  Destroy the module and its queues
 * 
 * Clear and destroy the queues and then destroy the module object.
 * 
 * \note   
 * \param  hTxDataQ - The object                                          
 * \return TI_OK - Unload succesfull, TI_NOK - Unload unsuccesfull 
 * \sa     
 */ 
TI_STATUS txDataQ_Destroy (TI_HANDLE hTxDataQ)
{
    TTxDataQ  *pTxDataQ = (TTxDataQ *)hTxDataQ;
    TI_STATUS  status = TI_OK;
    TI_UINT32  uQueId;
    TDataLinkQ *pLinkQ;
    TI_UINT32  uHlid;

    /* Dequeue and free all queued packets */
    txDataQ_ClearQueues (hTxDataQ);

    /* 
     * init all queues in all links 
     */
    for (uHlid = 0; uHlid < WLANLINKS_MAX_LINKS; uHlid++)
    {
        pLinkQ = &pTxDataQ->aDataLinkQ[uHlid]; /* Link queues */

        /* Free Data queues */
        for (uQueId = 0 ; uQueId < pTxDataQ->uNumQueues ; uQueId++)
        {
            if (que_Destroy(pLinkQ->aQueues[uQueId]) != TI_OK)
            {
                TRACE1(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "txDataQueue_unLoad: fail to free Data Queue number: %d\n",uQueId);
    			status = TI_NOK;
            }
        }
    }

    /* free timer */
    if (pTxDataQ->hTxSendPaceTimer)
    {
        tmr_DestroyTimer (pTxDataQ->hTxSendPaceTimer);
    }

    /* Free Tx Data Queue Module */
    os_memoryFree (pTxDataQ->hOs, pTxDataQ, sizeof(TTxDataQ));

    return status;
}
TI_STATUS broadcastKey_unload(struct _broadcastKey_t *pBroadcastKey)
{
	TI_STATUS		status;

	status = keyDerive_unload(pBroadcastKey->pKeyDerive);

	if (status != TI_OK) {
		TRACE0(pBroadcastKey->hReport, REPORT_SEVERITY_CONSOLE, "BCAST_KEY_SM: Error in unloading key derivation module\n");
		WLAN_OS_REPORT(("BCAST_KEY_SM: Error in unloading key derivation module\n"));
	}

	status = fsm_Unload(pBroadcastKey->hOs, pBroadcastKey->pBcastKeySm);
	if (status != TI_OK) {
		TRACE0(pBroadcastKey->hReport, REPORT_SEVERITY_CONSOLE, "BCAST_KEY_SM: Error in unloading state machine\n");
		WLAN_OS_REPORT(("BCAST_KEY_SM: Error in unloading state machine\n"));
	}

	/* free key parser context memory */
	os_memoryFree(pBroadcastKey->hOs, pBroadcastKey, sizeof(broadcastKey_t));

	return TI_OK;
}
Exemple #16
0
/** 
 * \fn     tmr_DestroyTimer
 * \brief  Destroy the specified timer
 * 
 * Destroy the specified timer object, icluding the timer in the OS-API.  
 * 
 * \note   This timer destruction function should be used before tmr_Destroy() is executed!!
 * \param  hTimerInfo - The timer handle
 * \return TI_OK on success or TI_NOK on failure 
 * \sa     tmr_CreateTimer
 */ 
TI_STATUS tmr_DestroyTimer (TI_HANDLE hTimerInfo)
{
    TTimerInfo   *pTimerInfo   = (TTimerInfo *)hTimerInfo;                 /* The timer handle */     
    TTimerModule *pTimerModule;                  /* The timer module handle */
    if (!pTimerInfo)
    {
        return TI_NOK;
    }
    pTimerModule = (TTimerModule *)pTimerInfo->hTimerModule;
    if (!pTimerModule)
    {
        WLAN_OS_REPORT (("tmr_DestroyTimer(): ERROR - NULL timer!\n"));
        return TI_NOK;
    }

    /* Free the OS-API timer */
    if ((pTimerInfo->hOsTimerObj) &&  (pTimerModule->hOs))
    {
    	os_timerDestroy (pTimerModule->hOs, pTimerInfo->hOsTimerObj);
    	if (pTimerModule->uTimersCount>0)
    	{
			pTimerModule->uTimersCount--;  /* update created timers number */
    	}
    	else
    	{
    		WLAN_OS_REPORT (("tmr_DestroyTimer(): ERROR - timers count < 0!\n"));
    	}
    }
    else
    {
    	WLAN_OS_REPORT (("tmr_DestroyTimer(): ERROR - NULL pointers!\n"));
    }
    /* Free the timer object */
    os_memoryFree (pTimerModule->hOs, hTimerInfo, sizeof(TTimerInfo));
	

    return TI_OK;
}
/**
*
* assocunload - unload association SM from memory
*
* \b Description: 
*
* Unload association SM from memory
*
* \b ARGS:
*
*  I   - hAssoc - association SM context  \n
*
* \b RETURNS:
*
*  TI_OK if successful, TI_NOK otherwise.
*
* \sa rsn_mainSecSmKeysOnlyStop()
*/
TI_STATUS assoc_unload(TI_HANDLE hAssoc)
{
    TI_STATUS       status;
    assoc_t     *pHandle;

    pHandle = (assoc_t*)hAssoc;

    status = fsm_Unload(pHandle->hOs, pHandle->pAssocSm);
    if (status != TI_OK)
    {
        /* report failure but don't stop... */
        TRACE0(pHandle->hReport, REPORT_SEVERITY_ERROR, "ASSOC_SM: Error releasing FSM memory \n");
    }
    
	if (pHandle->hAssocSmTimer)
	{
		tmr_DestroyTimer (pHandle->hAssocSmTimer);
	}
    
    os_memoryFree(pHandle->hOs, hAssoc, sizeof(assoc_t));

    return TI_OK;
}
Exemple #18
0
/** 
 * \fn     txMgmtQ_Destroy
 * \brief  Destroy the module and its queues
 * 
 * Clear and destroy the queues and then destroy the module object.
 * 
 * \note   
 * \param  hTxMgmtQ - The module's object                                          
 * \return TI_OK - Unload succesfull, TI_NOK - Unload unsuccesfull 
 * \sa     
 */ 
TI_STATUS txMgmtQ_Destroy (TI_HANDLE hTxMgmtQ)
{
    TTxMgmtQ  *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ;
    TI_STATUS  eStatus = TI_OK;
    int        uQueId;


    /* free Mgmt queues */
    for (uQueId = 0 ; uQueId < NUM_OF_MGMT_QUEUES ; uQueId++)
    {
        if (que_Destroy(pTxMgmtQ->aQueues[uQueId]) != TI_OK)
		{
TRACE1(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, "txMgmtQueue_unLoad: fail to free Mgmt Queue number: %d\n",uQueId);

			eStatus = TI_NOK;
		}
    }

    /* free Tx Mgmt Queue Module */
    os_memoryFree (pTxMgmtQ->hOs, pTxMgmtQ, sizeof(TTxMgmtQ));

    return eStatus;
}
Exemple #19
0
/* STOP_MLME, SET_DATA_PORT_CLOSE, DIS_JOIN */
static TI_STATUS mlmeWait_to_WaitDisconnect(void *pData)
{
    TI_STATUS   status;
    paramInfo_t *pParam;
    conn_t      *pConn = (conn_t *)pData;

    status = mlme_stop( pConn->hMlmeSm, DISCONNECT_IMMEDIATE, pConn->disConnReasonToAP );
    if (status != TI_OK)
        return status;

    pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t));
    if (!pParam)
    {
        return TI_NOK;
    }

    pParam->paramType = RX_DATA_PORT_STATUS_PARAM;
    pParam->content.rxDataPortStatus = CLOSE;
    rxData_setParam(pConn->hRxData, pParam);


    /* Update TxMgmtQueue SM to close Tx path. */
    txMgmtQ_SetConnState (pConn->hTxMgmtQ, TX_CONN_STATE_CLOSE);

    /* Start the disconnect complete time out timer. 
       Disconect Complete event, which stops the timer. */
    tmr_StartTimer (pConn->hConnTimer, conn_timeout, (TI_HANDLE)pConn, DISCONNECT_TIMEOUT_MSEC, TI_FALSE);

    /* FW will send the disconn frame according to disConnType */ 
    TWD_CmdFwDisconnect (pConn->hTWD, pConn->disConnType, pConn->disConnReasonToAP); 

#ifdef XCC_MODULE_INCLUDED
    XCCMngr_updateIappInformation(pConn->hXCCMngr, XCC_DISASSOC);
#endif
    os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    return TI_OK;
}
Exemple #20
0
/**
 * \fn     smeSm_Connect
 * \brief  Starts a connection process with the selected network
 *
 * Starts a connection process with the selected network
 *
 * \param  hSme - handle to the SME object
 * \return None
 * \sa     smeSm_PreConnect, smeSm_ConnectSuccess
 */
void smeSm_Connect (TI_HANDLE hSme)
{
	TSme            *pSme = (TSme*)hSme;
	TI_STATUS       tStatus;
	paramInfo_t     *pParam;

	/* Sanity check - if no connection candidate was found so far */
	if (NULL == pSme->pCandidate) {
		sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);
	} else {
		pParam = (paramInfo_t *)os_memoryAlloc(pSme->hOS, sizeof(paramInfo_t));
		if (!pParam) {
			return;
		}

		/* set SCR group */
		if (BSS_INFRASTRUCTURE == pSme->pCandidate->bssType) {
			scr_setGroup (pSme->hScr, SCR_GID_CONNECT);
		}

		/***************** Config Connection *************************/
		pParam->paramType = CONN_TYPE_PARAM;
		if (BSS_INDEPENDENT == pSme->pCandidate->bssType)
			if (SITE_SELF == pSme->pCandidate->siteType) {
				pParam->content.connType = CONNECTION_SELF;
			} else {
				pParam->content.connType = CONNECTION_IBSS;
			}
		else
			pParam->content.connType = CONNECTION_INFRA;
		conn_setParam(pSme->hConn, pParam);
		os_memoryFree(pSme->hOS, pParam, sizeof(paramInfo_t));

		/* start the connection process */
		tStatus = conn_start (pSme->hConn, CONN_TYPE_FIRST_CONN, sme_ReportConnStatus, hSme, TI_FALSE, TI_FALSE);
	}
}
/** 
 * \fn     tmr_CreateTimer
 * \brief  Create a new timer
 * 
 * Create a new timer object, icluding creating a timer in the OS-API.  
 * 
 * \note   This timer creation may be used only after tmr_Create() and tmr_Init() were executed!!
 * \param  hTimerModule - The module handle
 * \return TI_HANDLE    - The created timer handle
 * \sa     tmr_DestroyTimer
 */ 
TI_HANDLE tmr_CreateTimer (TI_HANDLE hTimerModule)
{
    TTimerModule *pTimerModule = (TTimerModule *)hTimerModule; /* The timer module handle */
    TTimerInfo   *pTimerInfo;  /* The created timer handle */

    if (!pTimerModule)
    {
        WLAN_OS_REPORT (("tmr_CreateTimer(): ERROR - NULL timer!\n"));
        return NULL;
    }

    /* Allocate timer object */
    pTimerInfo = os_memoryAlloc (pTimerModule->hOs, sizeof(TTimerInfo));
    if (!pTimerInfo)
    {
        WLAN_OS_REPORT (("tmr_CreateTimer():  Timer allocation failed!!\n"));
        return NULL;
    }
    os_memoryZero (pTimerModule->hOs, pTimerInfo, (sizeof(TTimerInfo)));

    /* Allocate OS-API timer, providing the common expiry callback with the current timer handle */
    pTimerInfo->hOsTimerObj = os_timerCreate(pTimerModule->hOs, tmr_GetExpiry, (TI_HANDLE)pTimerInfo);
    if (!pTimerInfo->hOsTimerObj)
    {
        TRACE0(pTimerModule->hReport, REPORT_SEVERITY_CONSOLE ,"tmr_CreateTimer():  OS-API Timer allocation failed!!\n");
        os_memoryFree (pTimerModule->hOs, pTimerInfo, sizeof(TTimerInfo));
        WLAN_OS_REPORT (("tmr_CreateTimer():  OS-API Timer allocation failed!!\n"));
        return NULL;
    }

    /* Save the timer module handle in the created timer object (needed for the expiry callback) */
    pTimerInfo->hTimerModule = hTimerModule;
    pTimerModule->uTimersCount++;  /* count created timers */

    /* Return the created timer handle */
    return (TI_HANDLE)pTimerInfo;
}
Exemple #22
0
/**
*
* auth_create - allocate memory for authentication SM
*
* \b Description:
*
* Allocate memory for authentication SM. \n
* 		Allocates memory for Association context. \n
* 		Allocates memory for authentication timer. \n
* 		Allocates memory for authentication SM matrix. \n
*
* \b ARGS:
*
*  I   - hOs - OS context  \n
*
* \b RETURNS:
*
*  TI_OK if successful, TI_NOK otherwise.
*
* \sa rsn_mainSecSmKeysOnlyStop()
*/
TI_HANDLE auth_create(TI_HANDLE hOs)
{
	auth_t 	*pHandle;
	TI_STATUS		status;

	/* allocate authentication context memory */
	pHandle = (auth_t*)os_memoryAlloc(hOs, sizeof(auth_t));
	if (pHandle == NULL) {
		return NULL;
	}

	os_memoryZero(hOs, pHandle, sizeof(auth_t));

	pHandle->hOs = hOs;

	/* allocate memory for authentication state machine */
	status = fsm_Create(hOs, &pHandle->pAuthSm, AUTH_SM_MAX_NUM_STATES, AUTH_SM_MAX_NUM_EVENTS);
	if (status != TI_OK) {
		os_memoryFree(hOs, pHandle, sizeof(auth_t));
		return NULL;
	}

	return pHandle;
}
Exemple #23
0
/**
 * \fn     tmr_Destroy
 * \brief  Destroy the module.
 *
 * Free the module's queues and object.
 *
 * \note   This is NOT a specific timer destruction! (see tmr_DestroyTimer)
 * \param  hTimerModule - The module object
 * \return TI_OK on success or TI_NOK on failure
 * \sa     tmr_Create
 */
TI_STATUS tmr_Destroy (TI_HANDLE hTimerModule)
{
    TTimerModule *pTimerModule = (TTimerModule *)hTimerModule;

    /* Alert if there are still timers that were not destroyed */
    if (pTimerModule->uTimersCount)
    {
    }

    /* Clear queues (critical section is used inside these functions) */
//    tmr_ClearInitQueue (hTimerModule);
//    tmr_ClearOperQueue (hTimerModule);

    /* Destroy the module's queues (protect in critical section)) */
    context_EnterCriticalSection (pTimerModule->hContext);
    que_Destroy (pTimerModule->hInitQueue);
    que_Destroy (pTimerModule->hOperQueue);
    context_LeaveCriticalSection (pTimerModule->hContext);

    /* free module object */
    os_memoryFree (pTimerModule->hOs, pTimerModule, sizeof(TTimerModule));

    return TI_OK;
}
/**
 * \fn     scanResultTable_Create
 * \brief  Create a scan result table object.
 *
 * Create a scan result table object. Allocate system resources.
 *
 * \note
 * \param  hOS - handle to the OS object
 * \return Handle to the newly created scan result table object, NULL if an error occured.
 * \sa     scanResultTable_Init, scanResultTable_Destroy
 */
TI_HANDLE scanResultTable_Create (TI_HANDLE hOS)
{
    TScanResultTable    *pScanResultTable = NULL;

    /* Allocate object storage */
    pScanResultTable = (TScanResultTable*)os_memoryAlloc (hOS, sizeof(TScanResultTable));
    if (NULL == pScanResultTable)
    {
        /* because the malloc failure here the TRACEx can not be used (no pointer for the 1st parameter to TRACEx) */
        return NULL;  /* this is done similarly to the next error case */
    }

    pScanResultTable->hOS = hOS;
    /* allocate memory for sites' data */
    pScanResultTable->pTable =
        (TSiteEntry *)os_memoryAlloc (pScanResultTable->hOS, sizeof (TSiteEntry) * TABLE_ENTRIES_NUMBER);
    if (NULL == pScanResultTable->pTable)
    {
        os_memoryFree(pScanResultTable->hOS, pScanResultTable, sizeof(TScanResultTable));
        return NULL;
    }
    os_memoryZero(pScanResultTable->hOS, pScanResultTable->pTable, sizeof(TSiteEntry) * TABLE_ENTRIES_NUMBER);
    return (TI_HANDLE)pScanResultTable;
}
/**
*
* fsm_Init  - Initialize the FSM structure
*
* \b Description: 
*
* Init The FSM structure. If matrix argument is NULL, allocate memory for
* new matrix.
*
* \b ARGS:
*
*  O   - pFsm - the generated FSM module  \n
*  I   - noOfStates - Number of states in the module \n
*  I   - noOfStates - Number of events in the module \n
*  I/O - matrix - the state event matrix
*  I   - transFunc - Transition finction for the state machine \n
*
* \b RETURNS:
*
*  TI_OK on success, TI_NOK on failure 
*
* \sa fsm_Event
*/
TI_STATUS fsm_Create(TI_HANDLE				hOs,
				fsm_stateMachine_t		**pFsm,
				TI_UINT8					MaxNoOfStates,
				TI_UINT8					MaxNoOfEvents)
{
	/* check for perliminary conditions */
	if ((pFsm == NULL) || (MaxNoOfStates == 0) || (MaxNoOfEvents == 0))
	{
		return TI_NOK;
	}

	/* allocate memory for FSM context */
	*pFsm = (fsm_stateMachine_t *)os_memoryAlloc(hOs, sizeof(fsm_stateMachine_t));
	if (*pFsm == NULL)
	{
		return TI_NOK;
	}
	os_memoryZero(hOs, (*pFsm), sizeof(fsm_stateMachine_t));

	/* allocate memory for FSM matrix */
	(*pFsm)->stateEventMatrix = (fsm_Matrix_t)os_memoryAlloc(hOs, MaxNoOfStates * MaxNoOfEvents * sizeof(fsm_actionCell_t));
	if ((*pFsm)->stateEventMatrix == NULL)
	{
		os_memoryFree(hOs, *pFsm, sizeof(fsm_stateMachine_t));
		return TI_NOK;
	}

	os_memoryZero(hOs, (*pFsm)->stateEventMatrix, 
		(MaxNoOfStates * MaxNoOfEvents * sizeof(fsm_actionCell_t)));

	/* update pFsm structure with parameters */
	(*pFsm)->MaxNoOfStates = MaxNoOfStates;
	(*pFsm)->MaxNoOfEvents = MaxNoOfEvents;

	return(TI_OK);
}
Exemple #26
0
/* STOP_RSN, SET_DATA_PORT_CLOSE, STOP_MLME, DIS_JOIN */
static TI_STATUS rsnWait_to_disconnect(void *pData)
{
    TI_STATUS status;
    paramInfo_t *pParam;
    conn_t *pConn = (conn_t *)pData;

    status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys);
    if (status != TI_OK)
        return status;

    pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t));
    if (!pParam)
    {
        return TI_NOK;
    }

    pParam->paramType = RX_DATA_PORT_STATUS_PARAM;
    pParam->content.rxDataPortStatus = CLOSE;
    status = rxData_setParam(pConn->hRxData, pParam);
    os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    if (status != TI_OK)
        return status;

    /* Update TxMgmtQueue SM to close Tx path for all except Mgmt packets. */
    txMgmtQ_SetConnState (pConn->hTxMgmtQ, TX_CONN_STATE_MGMT);

    status = mlme_stop( pConn->hMlme, DISCONNECT_IMMEDIATE, pConn->disConnReasonToAP );

    if (status != TI_OK)
        return status;

    /* send disconnect command to firmware */
    prepare_send_disconnect(pData);

    return TI_OK;
}
Exemple #27
0
/** 
 * \fn     sme_Select
 * \brief  Select a connection candidate from the scan result table
 * 
 * Select a connection candidate from the scan result table.
 * 
 * Connection candidate must match SSID, BSSID, BSS type, RSN and WSC settings, has the best
 * RSSI level from all matching sites, and connection was not attempted to it in this SME cycle
 * (since last scan was completed)
 * 
 * \param  hSme - handle to the SME object
 * \return A pointer to the selected site, NULL if no site macthes the selection criteria
 */ 
TSiteEntry *sme_Select (TI_HANDLE hSme)
{
    TSme            *pSme = (TSme*)hSme;
    TSiteEntry      *pCurrentSite, *pSelectedSite = NULL;
    TI_INT8         iSelectedSiteRssi = -127; /* minimum RSSI */
    TI_BOOL         bWscPbAbort, pWscPbApFound = TI_FALSE;
    int             apFoundCtr =0;

    /* on SG avalanche, select is not needed, send connect event automatically */
    if (TI_TRUE == pSme->bReselect)
    {        
        paramInfo_t *pParam;

        pParam = (paramInfo_t *)os_memoryAlloc(pSme->hOS, sizeof(paramInfo_t));
        if (!pParam)
        {
            return NULL;
        }

        pSme->bReselect = TI_FALSE;

        /* Get Primary Site */
        pParam->paramType = SITE_MGR_GET_PRIMARY_SITE;
        siteMgr_getParam(pSme->hSiteMgr, pParam);
        pCurrentSite = pParam->content.pPrimarySite;
        os_memoryFree(pSme->hOS, pParam, sizeof(paramInfo_t));
        return pCurrentSite;

    }

    /* get the first site from the scan result table */
    pCurrentSite = scanResultTable_GetFirst (pSme->hScanResultTable);

    /* check all sites */
    while (NULL != pCurrentSite)
    {
        /* if this site was previously selected in the current SME connection attempt, and conn mode is auto */
        if ((TI_TRUE == pCurrentSite->bConsideredForSelect) && (CONNECT_MODE_AUTO == pSme->eConnectMode)) 
        {
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

        /* check if site matches */
        /* first check SSID match */
        if (TI_FALSE == sme_SelectSsidMatch (hSme, &(pCurrentSite->ssid), &(pSme->tSsid), pSme->eSsidType))
        /* site doesn't match */
        {
            pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

        /* Now check BSSID match */
        if (TI_FALSE == sme_SelectBssidMatch (&(pCurrentSite->bssid), &(pSme->tBssid)))
        /* site doesn't match */
        {
            pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

        /* and BSS type match */
        if (TI_FALSE == sme_SelectBssTypeMatch (pCurrentSite->bssType, pSme->eBssType))
        /* site doesn't match */
        {
            pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

         if (pCurrentSite->WSCSiteMode == TIWLN_SIMPLE_CONFIG_PBC_METHOD)
         {
           apFoundCtr++;
         }
         if (apFoundCtr > 1)
         {
           pWscPbApFound = TI_TRUE;
         }
         
        /* and simple config match */
        if (TI_FALSE == sme_SelectWscMatch (hSme, pCurrentSite, &bWscPbAbort, &pWscPbApFound))
        /* site doesn't match */
        {
            /* also check if abort was indicated */
            if (TI_TRUE == bWscPbAbort)
            {
                /* send event to user mode to indicate this */
                EvHandlerSendEvent (pSme->hEvHandler, IPC_EVENT_WPS_SESSION_OVERLAP, NULL, 0);
                /* select failed - will rescan in time */
                return NULL;
            }
            pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

        /* and security match */
        if (pCurrentSite->WSCSiteMode == TIWLN_SIMPLE_CONFIG_OFF) /* we don't need to check RSN match while WSC is active */
        {
            if (TI_FALSE == sme_SelectRsnMatch (hSme, pCurrentSite))
            /* site doesn't match */
            {
                pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
                /* get the next site and continue the loop */
                pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
                continue;
            }
        }

        /* and rate match */
        if (TI_FALSE == siteMgr_SelectRateMatch (pSme->hSiteMgr, pCurrentSite))
        /* site doesn't match */
        {
            pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }
        /* if this site RSSI is higher than current maximum, select it */
        if (pCurrentSite->rssi > iSelectedSiteRssi)
        {
            pSelectedSite = pCurrentSite;
            iSelectedSiteRssi = pCurrentSite->rssi;
        }

        /* and continue to the next site */
        pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
    }

    /* if a matching site was found */
    if (NULL != pSelectedSite)
    {
        /* mark that a connection to this site was (actually is) attempted */
        pSelectedSite->bConsideredForSelect = TI_TRUE;

        /* hope this is the correct place for siteMgr_changeBandParams */
        siteMgr_changeBandParams (pSme->hSiteMgr, pSelectedSite->eBand);

        /*
         * Coordinate between SME module site table and Site module site Table 
         * copy candidate AP to Site module site Table.
         */
        siteMgr_CopyToPrimarySite(pSme->hSiteMgr, pSelectedSite);
    }

    /* return the selected site (or NULL, if no site was selected) */
    return pSelectedSite;
}
/** 
 * \fn     sme_Select
 * \brief  Select a connection candidate from the scan result table
 * 
 * Select a connection candidate from the scan result table.
 * 
 * Connection candidate must match SSID, BSSID, BSS type, RSN and WSC settings, has the best
 * RSSI level from all matching sites, and connection was not attempted to it in this SME cycle
 * (since last scan was completed)
 * 
 * \param  hSme - handle to the SME object
 * \return A pointer to the selected site, NULL if no site macthes the selection criteria
 */ 
TSiteEntry *sme_Select (TI_HANDLE hSme)
{
    TSme            *pSme = (TSme*)hSme;
    TSiteEntry      *pCurrentSite, *pSelectedSite = NULL;
    TI_INT8         iSelectedSiteRssi = -127; /* minimum RSSI */
    TI_BOOL         bWscPbAbort, pWscPbApFound = TI_FALSE;
    int             apFoundCtr =0;
    TIWLN_SIMPLE_CONFIG_MODE eWscMode;

    TRACE0(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select called\n");

    /* on SG avalanche, select is not needed, send connect event automatically */
    if (TI_TRUE == pSme->bReselect)
    {        
        paramInfo_t *pParam;

        TRACE0(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: reselect flag is on, reselecting the current site\n");

        pParam = (paramInfo_t *)os_memoryAlloc(pSme->hOS, sizeof(paramInfo_t));
        if (!pParam)
        {
            return NULL;
        }

        pSme->bReselect = TI_FALSE;

        /* Get Primary Site */
        pParam->paramType = SITE_MGR_GET_PRIMARY_SITE;
        siteMgr_getParam(pSme->hSiteMgr, pParam);
        pCurrentSite = pParam->content.pPrimarySite;
        os_memoryFree(pSme->hOS, pParam, sizeof(paramInfo_t));
        return pCurrentSite;
    }

    /* get the first site from the scan result table */
    pCurrentSite = scanResultTable_GetFirst (pSme->hScanResultTable);

    /* check all sites */
    while (NULL != pCurrentSite)
    {
        TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: considering BSSID: %02x:%02x:%02x:%02x:%02x:%02x for selection\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]);

        /* if this site was previously selected in the current SME connection attempt, and conn mode is auto */
        if (TI_TRUE == pCurrentSite->bConsideredForSelect)
        {
            TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x was selected previously\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]);
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

        /* check if site matches */
        /* first check SSID match */
        if (TI_FALSE == sme_SelectSsidMatch (hSme, &(pCurrentSite->ssid), &(pSme->tSsid), pSme->eSsidType))
        /* site doesn't match */
        {
            TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match SSID\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]);
            pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

        /* Now check BSSID match */
        if (TI_FALSE == sme_SelectBssidMatch (&(pCurrentSite->bssid), &(pSme->tBssid)))
        /* site doesn't match */
        {
            TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match SSID\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]);
            pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

        /* and BSS type match */
        if (TI_FALSE == sme_SelectBssTypeMatch (pCurrentSite->bssType, pSme->eBssType))
        /* site doesn't match */
        {
            TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match BSS type\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]);
            pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

         if (pCurrentSite->WSCSiteMode == TIWLN_SIMPLE_CONFIG_PBC_METHOD)
         {
           apFoundCtr++;
         }
         if (apFoundCtr > 1)
         {
           pWscPbApFound = TI_TRUE;
         }

        /* and simple config match */
        if (TI_FALSE == sme_SelectWscMatch (hSme, pCurrentSite, &bWscPbAbort, &pWscPbApFound))
        /* site doesn't match */
        {
            /* also check if abort was indicated */
            if (TI_TRUE == bWscPbAbort)
            {
                /* send event to user mode to indicate this */
                EvHandlerSendEvent (pSme->hEvHandler, IPC_EVENT_WPS_SESSION_OVERLAP, NULL, 0);
                /* select failed - will rescan in time */
                return NULL;
            }
            TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match WSC\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]);
            pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

        /* and security match */
        siteMgr_getParamWSC(pSme->hSiteMgr, &eWscMode); 

        /* we don't need to check RSN match while WSC is active */
        if ((pCurrentSite->WSCSiteMode == TIWLN_SIMPLE_CONFIG_OFF) || (pCurrentSite->WSCSiteMode != eWscMode))
        {
            if (TI_FALSE == sme_SelectRsnMatch (hSme, pCurrentSite))
            /* site doesn't match */
            {
                TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match RSN\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]);
                pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
                /* get the next site and continue the loop */
                pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
                continue;
            }
        }

        /* and rate match */
        if (TI_FALSE == siteMgr_SelectRateMatch (pSme->hSiteMgr, pCurrentSite))
        /* site doesn't match */
        {
            TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match rates\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]);
            pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

        if (TI_TRUE == pCurrentSite->bChannelSwitchAnnoncIEFound)
        {
            TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x has channel switch IE so ignore it \n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]);
            pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */
            /* get the next site and continue the loop */
            pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
            continue;
        }

        /* if this site RSSI is higher than current maximum, select it */
        if (pCurrentSite->rssi > iSelectedSiteRssi)
        {
            TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x match and has highest RSSI so far!\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]);
            pSelectedSite = pCurrentSite;
            iSelectedSiteRssi = pCurrentSite->rssi;
        }

        /* and continue to the next site */
        pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable);
    }

    /* if a matching site was found */
    if (NULL != pSelectedSite)
    {
        /* mark that a connection to this site was (actually is) attempted */
        pSelectedSite->bConsideredForSelect = TI_TRUE;

        /* hope this is the correct place for siteMgr_changeBandParams */
        siteMgr_changeBandParams (pSme->hSiteMgr, pSelectedSite->eBand);

        /*
         * Coordinate between SME module site table and Site module site Table 
         * copy candidate AP to Site module site Table.
         */
        siteMgr_CopyToPrimarySite(pSme->hSiteMgr, pSelectedSite);

		/* copy the result, rather than returning a pointer to the entry in the scan result table.
		 * This is done since the table might change durring the connection process, and the pointer 
		 * will point to the wrong entry in the table, causing connection/disconnection problems */
		os_memoryCopy(pSme->hOS, &(pSme->tCandidate), pSelectedSite, sizeof(TSiteEntry));

		return &(pSme->tCandidate);
    }

    /* return NULL if no site was selected */
    return NULL;
}
/****************************************************************************************
 *                        os_timerDestroy()                                 
 ****************************************************************************************
DESCRIPTION:    This function destroys the OS timer object.

ARGUMENTS:		

RETURN:			

NOTES:         	
*****************************************************************************************/
void os_timerDestroy (TI_HANDLE OsContext, TI_HANDLE TimerHandle)
{
	os_timerStop (OsContext, TimerHandle);
	os_memoryFree (OsContext, TimerHandle, sizeof(TOsTimer));
}
/**
 * \fn     txDataQ_Init
 * \brief  Save required modules handles
 *
 * Save other modules handles.
 *
 * \note
 * \param  pStadHandles  - The driver modules handles
 * \return void
 * \sa
 */
void txDataQ_Init (TStadHandlesList *pStadHandles)
{
	TTxDataQ  *pTxDataQ = (TTxDataQ *)(pStadHandles->hTxDataQ);
	TI_UINT32  uNodeHeaderOffset = TI_FIELD_OFFSET(TTxnStruct, tTxnQNode);
	TI_UINT8   uQueId;

	/* save modules handles */
	pTxDataQ->hContext	= pStadHandles->hContext;
	pTxDataQ->hTxCtrl	= pStadHandles->hTxCtrl;
	pTxDataQ->hOs		= pStadHandles->hOs;
	pTxDataQ->hReport	= pStadHandles->hReport;
	pTxDataQ->hTxMgmtQ	= pStadHandles->hTxMgmtQ;
	pTxDataQ->hTWD	    = pStadHandles->hTWD;

	/* Configures the Port Default status to Close */
	pTxDataQ->bDataPortEnable = TI_FALSE;

	/* Configures the LastQueId to zero => scheduler will strart from Queue 1*/
	pTxDataQ->uLastQueId = 0;

	/* init the number of the Data queue to be used */
	pTxDataQ->uNumQueues = MAX_NUM_OF_AC;

	/* init the max size of the Data queues */
	pTxDataQ->aQueueMaxSize[QOS_AC_BE] = DATA_QUEUE_DEPTH_BE;
	pTxDataQ->aQueueMaxSize[QOS_AC_BK] = DATA_QUEUE_DEPTH_BK;
	pTxDataQ->aQueueMaxSize[QOS_AC_VI] = DATA_QUEUE_DEPTH_VI;
	pTxDataQ->aQueueMaxSize[QOS_AC_VO] = DATA_QUEUE_DEPTH_VO;

	/* Create the tx data queues */
	for (uQueId = 0; uQueId < pTxDataQ->uNumQueues; uQueId++) {
		pTxDataQ->aQueues[uQueId] = que_Create (pTxDataQ->hOs,
		                                        pTxDataQ->hReport,
		                                        pTxDataQ->aQueueMaxSize[uQueId],
		                                        uNodeHeaderOffset);

		/* If any Queues' allocation failed, print error, free TxDataQueue module and exit */
		if (pTxDataQ->aQueues[uQueId] == NULL) {
			TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_CONSOLE , "Failed to create queue\n");
			WLAN_OS_REPORT(("Failed to create queue\n"));
			os_memoryFree (pTxDataQ->hOs, pTxDataQ, sizeof(TTxDataQ));
			return;
		}

		/* Configure the Queues default values */
		pTxDataQ->aQueueBusy[uQueId] = TI_FALSE;
		pTxDataQ->aNetStackQueueStopped[uQueId] = TI_FALSE;
		pTxDataQ->aTxSendPaceThresh[uQueId] = 1;
	}

	pTxDataQ->hTxSendPaceTimer = tmr_CreateTimer (pStadHandles->hTimer);
	if (pTxDataQ->hTxSendPaceTimer == NULL) {
		TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "txDataQ_Init(): Failed to create hTxSendPaceTimer!\n");
		return;
	}

	/* Register to the context engine and get the client ID */
	pTxDataQ->uContextId = context_RegisterClient (pTxDataQ->hContext,
	                       txDataQ_RunScheduler,
	                       (TI_HANDLE)pTxDataQ,
	                       TI_TRUE,
	                       "TX_DATA",
	                       sizeof("TX_DATA"));

}