Exemple #1
0
/** 
 * \fn     smeSm_DisconnectDone
 * \brief  Finish a disconnect process
 * 
 * Finish a disconnect process by sending the appropriate event and restarting the state-machine
 * 
 * \param  hSme - handle to the SME object
 * \return None
 * \sa     smeSm_Disconnect
 */ 
void smeSm_DisconnectDone (TI_HANDLE hSme)
{
    TSme        *pSme = (TSme*)hSme;
    OS_802_11_DISASSOCIATE_REASON_T	    tEventReason;

    if (TI_FALSE == pSme->bReselect)
    {
        /* send an event notifying the disassocation */
        if (TI_TRUE == pSme->bAuthSent)
        {
            tEventReason.eDisAssocType = SME_CONVERT_DISASSOC_CODES (pSme->tDisAssoc.eMgmtStatus);
            tEventReason.uStatusCode = pSme->tDisAssoc.uStatusCode;
            EvHandlerSendEvent (pSme->hEvHandler, IPC_EVENT_DISASSOCIATED, (TI_UINT8*)&tEventReason,
                                sizeof(OS_802_11_DISASSOCIATE_REASON_T));
        }
        else if (CONNECT_MODE_AUTO != pSme->eLastConnectMode)
        {
            EvHandlerSendEvent (pSme->hEvHandler, IPC_EVENT_NOT_ASSOCIATED, NULL, 0);
        }
    }

    siteMgr_disSelectSite (pSme->hSiteMgr);


    /* try to reconnect */
    smeSm_Start (hSme);
}
/**
 * \author Ronen Kalish\n
 * \date 30-Jan-2005\n
 * \brief Scan result callback for application scan.\n
 *
 * Function Scope \e Public.\n
 * \param hScanCncn - handle to the scan concentrator object.\n
 * \param status - the scan result status (scan complete, result received etc.).\n
 * \param frameInfo - a pointer to the structure holding all frame related info (in case a frame was received).\n
 * \prama SPSStatus - a bitmap indicating on which channels scan was attempted (valid for SPS scan only!).\n
 */
void scanConcentrator_appScanResultCB( TI_HANDLE hScanCncn, scan_cncnResultStatus_e status,
                                       scan_frameInfo_t* frameInfo, UINT16 SPSStatus )
{
    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;

    switch ( status )
	{
	case SCAN_CRS_RECEIVED_FRAME:
        /* forward scan results to site manager, like in the good old days... */
        siteMgr_updateSite( pScanConcentrator->hSiteManager, frameInfo->bssId, 
                            frameInfo->parsedIEs, frameInfo->channel, frameInfo->band, FALSE );
        if ( BEACON == frameInfo->parsedIEs->subType )
        {
            siteMgr_saveBeaconBuffer( pScanConcentrator->hSiteManager, frameInfo->bssId, 
                                      frameInfo->buffer, frameInfo->bufferLength );
        }
        else
        {
            siteMgr_saveProbeRespBuffer( pScanConcentrator->hSiteManager, frameInfo->bssId,
                                         frameInfo->buffer, frameInfo->bufferLength );
        }		
		break;

	case SCAN_CRS_SCAN_COMPLETE_OK:
		siteMgr_removeNotReceivedSites( pScanConcentrator->hSiteManager );

	/* There's no break on purpose! */
		/* if the current running app scan is an OID scan, send a scan complete event to its state machine */
		if ( TRUE == pScanConcentrator->bOidScanRunning )
		{
			scanConcentratorOidSM_SMEvent(hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_COMPLETE );
		}
		else
		{
			/* send a scan complete event to the user */
			EvHandlerSendEvent( pScanConcentrator->hEventSrv, IPC_EVENT_SCAN_COMPLETE, NULL, 0 );
		}
		break;
	case SCAN_CRS_TSF_ERROR:
	case SCAN_CRS_SCAN_STOPPED:
	case SCAN_CRS_SCAN_RUNNING:
	case SCAN_CRS_SCAN_FAILED:
	case SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY:
	case SCAN_CRS_SCAN_ABORTED_FW_RESET:
	case SCAN_CRS_NUM_OF_RES_STATUS:
	default:
        /* The scan was finished, send a scan complete event to the user
		   (regardless of why the scan was completed) */
		if ( TRUE == pScanConcentrator->bOidScanRunning )
		{
			scanConcentratorOidSM_SMEvent(hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_FAILED );
		}
		else
		{
        EvHandlerSendEvent( pScanConcentrator->hEventSrv, IPC_EVENT_SCAN_COMPLETE, NULL, 0 );
		}
		break;
	}
}
Exemple #3
0
/* SET_DATA_PORT_EAPOL, START_RSN */
static TI_STATUS mlmeWait_to_rsnWait(void *pData)
{
    TI_STATUS status;
    paramInfo_t *pParam;
    conn_t *pConn = (conn_t *)pData;

    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 = OPEN_EAPOL;
    status = rxData_setParam(pConn->hRxData, pParam);    
    os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    if (status != TI_OK)
        return status;

    /* Update TxMgmtQueue SM to enable EAPOL packets. */
    txMgmtQ_SetConnState (((conn_t *)pData)->hTxMgmtQ, TX_CONN_STATE_EAPOL);

    /*
     *  Notify that the driver is associated to the supplicant\IP stack. 
     */
    EvHandlerSendEvent(pConn->hEvHandler, IPC_EVENT_ASSOCIATED, NULL,0);

    status = rsn_start(pConn->hRsn);
    return status;
}
/***********************************************************************
 *                        idle_to_selfWait
 ***********************************************************************
DESCRIPTION: 


INPUT:   

OUTPUT:

RETURN:     TI_OK on success, TI_NOK otherwise

************************************************************************/
static TI_STATUS idle_to_selfWait (void *pData)
{
	conn_t    *pConn = (conn_t *)pData;
    TI_UINT16  randomTime;

    siteMgr_join (pConn->hSiteMgr);

    /* get a randomTime that is constructed of the lower 13 bits ot the system time to 
       get a MS random time of ~8000 ms */
    randomTime = os_timeStampMs (pConn->hOs) & 0x1FFF;

    /* Update current BSS connection type and mode */
    currBSS_updateConnectedState (pConn->hCurrBss, TI_TRUE, BSS_INDEPENDENT);

    tmr_StartTimer (pConn->hConnTimer,
                    conn_timeout,
                    (TI_HANDLE)pConn,
                    pConn->timeout + randomTime,
                    TI_FALSE);

	/*  Notify that the driver is associated to the supplicant\IP stack. */
    EvHandlerSendEvent (pConn->hEvHandler, IPC_EVENT_ASSOCIATED, NULL, 0);

    return TI_OK;
}
/**
*
* mainKeySmLogMessage
*
* \b Description: 
*
* Prints Log messge.\n
* Start session timer.
*
* \b ARGS:
*
*  I   - pData - station control block  \n
*
* \b RETURNS:
*
*  OK on success, NOK otherwise.
*/
TI_STATUS mainKeys_smTimeOut(void* data)
{
	OS_802_11_AUTHENTICATION_REQUEST   *request;
	UINT8                   AuthBuf[sizeof(UINT32) + sizeof(OS_802_11_AUTHENTICATION_REQUEST)];
	paramInfo_t				param;
	TI_STATUS				status;
	struct _mainKeys_t 		*pMainKeys = (struct _mainKeys_t *)data;


	WLAN_REPORT_INFORMATION(pMainKeys->hReport, RSN_MODULE_LOG,
				  ("MAIN_KEY_SM: TRAP: Session Timeout for station , mainKeysTimeoutCounter=%d\n",
                   pMainKeys->mainKeysTimeoutCounter));

	request = (OS_802_11_AUTHENTICATION_REQUEST *)(AuthBuf + sizeof(UINT32));
	request->Length = sizeof(OS_802_11_AUTHENTICATION_REQUEST);

	param.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
	status = ctrlData_getParam(pMainKeys->hCtrlData, &param);
	if (status != OK)
	{		
		return NOK;
	}

    WLAN_REPORT_INFORMATION(pMainKeys->hReport, RSN_MODULE_LOG,
			  ("current station is banned from the roaming candidates list for %d Ms\n",
               RSN_MAIN_KEYS_SESSION_TIMEOUT));

    rsn_banSite(pMainKeys->hRsn, param.content.ctrlDataCurrentBSSID, RSN_SITE_BAN_LEVEL_FULL, RSN_MAIN_KEYS_SESSION_TIMEOUT);
	

	/* mainKeysTimeoutCounter is a boolean variable, With states:	*/
	/* TRUE - It is a Timeout Association Event						*/ 
	/* FALSE - It is a Media specific Event							*/

	if (!pMainKeys->mainKeysTimeoutCounter)
	{
		/* Fill Media specific indication fields and send to OS/User    */ 
		os_memoryCopy(pMainKeys->hOs, request->BSSID, (void *)param.content.ctrlDataCurrentBSSID.addr, MAC_ADDR_LEN);
	
		request->Flags = OS_802_11_REQUEST_REAUTH;
	
		*(UINT32*)AuthBuf = os802_11StatusType_Authentication;
	
		WLAN_REPORT_INFORMATION(pMainKeys->hReport, RSN_MODULE_LOG,
			  (" %d Ms\n",RSN_MAIN_KEYS_SESSION_TIMEOUT));
	
		EvHandlerSendEvent(pMainKeys->hEvHandler, IPC_EVENT_MEDIA_SPECIFIC, (UINT8*)AuthBuf,
							sizeof(UINT32) + sizeof(OS_802_11_AUTHENTICATION_REQUEST));
	
		os_timerStart(pMainKeys->hOs, pMainKeys->timer, pMainKeys->keysTimeout, FALSE);
		pMainKeys->mainKeysTimeoutCounter = TRUE;
	}
	else
	{
        pMainKeys->mainKeysTimeoutCounter = FALSE;
        rsn_reportAuthFailure(pMainKeys->hRsn, RSN_AUTH_STATUS_TIMEOUT);
        conn_reportRsnStatus(pMainKeys->hConn, (mgmtStatus_e)STATUS_SECURITY_FAILURE);
	}
	return OK;
}
static TI_STATUS selfw_merge_rsnw(void *pData)
{
	conn_t *pConn=(conn_t *)pData;
	paramInfo_t param;

	os_printf("IBSS selfw_merge_rsnw!!!!!!!!!!\n");

	tmr_StopTimer (pConn->hConnTimer);
	siteMgr_join(pConn->hSiteMgr);

	param.paramType = RX_DATA_PORT_STATUS_PARAM;
	param.content.rxDataPortStatus = OPEN_EAPOL;
	rxData_setParam (pConn->hRxData, &param);

	/* Update TxMgmtQueue SM to enable EAPOL packets. */
	txMgmtQ_SetConnState (pConn->hTxMgmtQ, TX_CONN_STATE_EAPOL);

	/*
	 *  Notify that the driver is associated to the supplicant\IP stack.
	 */
	EvHandlerSendEvent (pConn->hEvHandler, IPC_EVENT_ASSOCIATED, NULL, 0);

	return rsn_start (pConn->hRsn);

}
/* SET_DATA_PORT_EAPOL, START_RSN */
static TI_STATUS mlmeWait_to_rsnWait(void *pData)
{
    TI_STATUS status;
    paramInfo_t param;
    conn_t *pConn = (conn_t *)pData;

    param.paramType = RX_DATA_PORT_STATUS_PARAM;
    param.content.rxDataPortStatus = OPEN_EAPOL;
    status = rxData_setParam(pConn->hRxData, &param);
    if (status != OK)
        return status;

    param.paramType = TX_DATA_PORT_STATUS_PARAM;
    param.content.txDataPortStatus = OPEN_EAPOL;
    status = txData_setParam(pConn->hTxData, &param);
    if (status != OK)
        return status;

    /*
     *  Notify that the driver is associated to the supplicant\IP stack. 
     */
    EvHandlerSendEvent(pConn->hEvHandler, IPC_EVENT_ASSOCIATED, NULL,0);

    return rsn_start(pConn->hRsn);
}
Exemple #8
0
/****************************************************************************************
 *                        								*
 *					OS Report API					*
 *											*
 ****************************************************************************************/
static void SendLoggerData (TI_HANDLE OsContext, TI_UINT8 *pMsg, TI_UINT16 len)
{
	TWlanDrvIfObj *drv = (TWlanDrvIfObj *)OsContext;

	if (len > 0) {
		EvHandlerSendEvent(drv->tCommon.hEvHandler, IPC_EVENT_LOGGER, pMsg, len);
	}
}
/*-----------------------------------------------------------------------------
Routine Name: admCtrl_notifyPreAuthStatus
Routine Description: This routine is used to notify higher level application of the pre-authentication status
Arguments: newStatus - pre authentication status
Return Value:
-----------------------------------------------------------------------------*/
void admCtrl_notifyPreAuthStatus (admCtrl_t *pAdmCtrl, preAuthStatusEvent_e newStatus)
{
    TI_UINT32 memBuff;

    memBuff = (TI_UINT32) newStatus;

    EvHandlerSendEvent(pAdmCtrl->hEvHandler, IPC_EVENT_WPA2_PREAUTHENTICATION,
                            (TI_UINT8*)&memBuff, sizeof(TI_UINT32));

}
static void roamingMngr_SendReassocEvent(TI_HANDLE hRoamingMngr, reassociationResp_e ReassResp)
{
	roamingMngr_t  *pRoamingMngr = (roamingMngr_t*) hRoamingMngr;

	TRACE1(pRoamingMngr->hReport, REPORT_SEVERITY_INFORMATION, "roamingMngr_SendReassocEvent(): %d \n", ReassResp);
	EvHandlerSendEvent(pRoamingMngr->hEvHandler,
	                   IPC_EVENT_REASSOCIATION_RESP,
	                   (TI_UINT8*)(&ReassResp),
	                   sizeof(reassociationResp_e));
}
Exemple #11
0
/**
*
* mainKeySmLogMessage
*
* \b Description:
*
* Prints Log messge.\n
* Start session timer.
*
* \b ARGS:
*
*  I   - pData - station control block  \n
*
* \b RETURNS:
*
*  TI_OK on success, TI_NOK otherwise.
*/
TI_STATUS mainKeys_smTimeOut(void* data)
{
	OS_802_11_AUTHENTICATION_REQUEST   *request;
	TI_UINT8                   AuthBuf[sizeof(TI_UINT32) + sizeof(OS_802_11_AUTHENTICATION_REQUEST)];
	paramInfo_t				param;
	TI_STATUS				status;
	struct _mainKeys_t 		*pMainKeys = (struct _mainKeys_t *)data;


	request = (OS_802_11_AUTHENTICATION_REQUEST *)(AuthBuf + sizeof(TI_UINT32));
	request->Length = sizeof(OS_802_11_AUTHENTICATION_REQUEST);

	param.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
	status = ctrlData_getParam(pMainKeys->hCtrlData, &param);
	if (status != TI_OK)
	{
		return TI_NOK;
	}

    rsn_banSite(pMainKeys->hRsn, param.content.ctrlDataCurrentBSSID, RSN_SITE_BAN_LEVEL_FULL, RSN_MAIN_KEYS_SESSION_TIMEOUT);


	/* mainKeysTimeoutCounter is a boolean variable, With states:	*/
	/* TI_TRUE - It is a Timeout Association Event						*/
	/* TI_FALSE - It is a Media specific Event							*/

	if (!pMainKeys->mainKeysTimeoutCounter)
	{
		/* Fill Media specific indication fields and send to OS/User    */
		MAC_COPY (request->BSSID, param.content.ctrlDataCurrentBSSID);

		request->Flags = OS_802_11_REQUEST_REAUTH;

		*(TI_UINT32*)AuthBuf = os802_11StatusType_Authentication;

		EvHandlerSendEvent(pMainKeys->hEvHandler, IPC_EVENT_MEDIA_SPECIFIC, (TI_UINT8*)AuthBuf,
							sizeof(TI_UINT32) + sizeof(OS_802_11_AUTHENTICATION_REQUEST));

        tmr_StartTimer (pMainKeys->hSessionTimer,
                        mainKeys_sessionTimeout,
                        (TI_HANDLE)pMainKeys,
                        pMainKeys->keysTimeout,
                        TI_FALSE);

		pMainKeys->mainKeysTimeoutCounter = TI_TRUE;
	}
	else
	{
        pMainKeys->mainKeysTimeoutCounter = TI_FALSE;
        rsn_reportAuthFailure(pMainKeys->hRsn, RSN_AUTH_STATUS_TIMEOUT);
        conn_reportRsnStatus(pMainKeys->hConn, (mgmtStatus_e)STATUS_SECURITY_FAILURE);
	}
	return TI_OK;
}
Exemple #12
0
/***********************************************************************
 *                        idle_to_rsnWait
 ***********************************************************************
DESCRIPTION: 


INPUT:   

OUTPUT:

RETURN:     TI_OK on success, TI_NOK otherwise

************************************************************************/
static TI_STATUS idle_to_rsnWait(void *pData)
{
    paramInfo_t param;

    siteMgr_join(((conn_t *)pData)->hSiteMgr);

    param.paramType = RX_DATA_PORT_STATUS_PARAM;
    param.content.rxDataPortStatus = OPEN_EAPOL;
    rxData_setParam(((conn_t *)pData)->hRxData, &param);

	/* Update TxMgmtQueue SM to enable EAPOL packets. */
	txMgmtQ_SetConnState (((conn_t *)pData)->hTxMgmtQ, TX_CONN_STATE_EAPOL);
    
    /*
     *  Notify that the driver is associated to the supplicant\IP stack. 
     */
    EvHandlerSendEvent(((conn_t *)pData)->hEvHandler, IPC_EVENT_ASSOCIATED, NULL,0);

    /* Update current BSS connection type and mode */
    currBSS_updateConnectedState(((conn_t *)pData)->hCurrBss, TI_TRUE, BSS_INDEPENDENT);
    
    return rsn_start(((conn_t *)pData)->hRsn);
}
/** 
 * \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;
}
/***********************************************************************
 *                        calcCreditFromTimer
 ***********************************************************************
DESCRIPTION:    This function is called when credit calculation timer
				is expired. it calculate the credit for the admission ctrl
				credit algorithm


INPUT:	    hTxCtrl         - handle to the ts data object
            bTwdInitOccured - Indicates if TWDriver recovery occured since timer started 

OUTPUT:     None

RETURN:     void
************************************************************************/
static void calcCreditFromTimer(TI_HANDLE hTxCtrl, TI_BOOL bTwdInitOccured)
{
	OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS	mediumTimeCross;
	txCtrl_t	*pTxCtrl = (txCtrl_t *)hTxCtrl;
	TI_UINT32		ac;
	TI_INT32		prevCredit;
	TI_INT32		highCreditThreshold;
	TI_INT32		lowCreditThreshold;
	TI_INT32		usageRatio;
	TI_INT32		currUsage;
	TI_INT32		prevUsage;
	TI_UINT32		currentTimeStamp = os_timeStampMs(pTxCtrl->hOs);  /* get current time stamp */
	
	/* 
	 *  For each AC under admission control calculate the new usage and credit time,
	 *     and send events if a threshold is crossed. 
	 */
	for(ac = 0 ; ac < MAX_NUM_OF_AC ; ac++)
	{
		/* check if this queue is under admission ctrl operation */
		if(pTxCtrl->mediumTime[ac] == 0)
		{
TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, ": ac = %d mediumTime = 0 \n", ac);
			
			continue;
		}

		/* in case of wraparound */
		if(currentTimeStamp < pTxCtrl->lastCreditCalcTimeStamp[ac])
			pTxCtrl->lastCreditCalcTimeStamp[ac] = 0;
		
		/* store prev credit */
		prevCredit = pTxCtrl->credit[ac];

		/* Calculate the medium usage ratio:    totalUsedTime / mediumTime * 1000
		   Note that since the totalUsedTime is in usec and not msec we don't multiply by 1000.	 */
		usageRatio = pTxCtrl->totalUsedTime[ac] / pTxCtrl->mediumTime[ac];

		/* calculate credit */
		pTxCtrl->credit[ac] += (currentTimeStamp - pTxCtrl->lastCreditCalcTimeStamp[ac]) - usageRatio;
		
		/* update last time stamp */
		pTxCtrl->lastCreditCalcTimeStamp[ac] = currentTimeStamp;

		/* in case credit is bigger than mediumTime -> set credit to medium time */
		if (pTxCtrl->credit[ac] > (TI_INT32)(pTxCtrl->mediumTime[ac]) )
			pTxCtrl->credit[ac] = pTxCtrl->mediumTime[ac];

       TRACE2(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "credit = %d  | TotalUsedTime = %d\n", pTxCtrl->credit[ac], pTxCtrl->totalUsedTime[ac]/1000);

		/* Check medium-usage threshold cross events */
		/*********************************************/
		/*
		 * The medium-usage events are defined as follows:
		 * The high threshold triggers event only when crossed upward (traffic increased above threshold).
		 * The low threshold triggers event only when crossed downward (traffic decreased below threshold).
		 * Thus, the two thresholds provide hysteresis and prevent multiple triggering.
		 * The high threshold should be greater than the low threshold. 
		 * 
		 *   Note:	The driver doesn't delay traffic even if violating the usage limit!
		 *			It only indicates the user application about the thresholds crossing.
		 */

		highCreditThreshold = (TI_INT32)((pTxCtrl->mediumTime[ac])*(pTxCtrl->highMediumUsageThreshold[ac])/100); 
		lowCreditThreshold  = (TI_INT32)((pTxCtrl->mediumTime[ac])*(pTxCtrl->lowMediumUsageThreshold[ac])/100);

		/* The credit is getting more negative as we get closer to the medium usage limit, so we invert
		     it before comparing to the thresholds (lower credit means higher usage). */
		currUsage = -pTxCtrl->credit[ac];
		prevUsage = -prevCredit;

		/* crossing below the low threshold */
		if ( (currUsage < lowCreditThreshold) && (prevUsage >= lowCreditThreshold) )
		{
			/* send event */
			mediumTimeCross.uAC = ac;
			mediumTimeCross.uHighOrLowThresholdFlag = (TI_UINT32)LOW_THRESHOLD_CROSS;
			mediumTimeCross.uAboveOrBelowFlag = (TI_UINT32)CROSS_BELOW;

			EvHandlerSendEvent(pTxCtrl->hEvHandler, IPC_EVENT_MEDIUM_TIME_CROSS, 
				(TI_UINT8 *)&mediumTimeCross, sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));

            TRACE3(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "crossed below low threshold !!! prevUsage = %d, currUsage = %d, lowCreditThreshold = %d\n",				prevUsage, currUsage, lowCreditThreshold);
		}
		
		/* crossing above the high threshold */
		else if ( (currUsage > highCreditThreshold) && (prevUsage <= highCreditThreshold) )
		{
			/* send event */
			mediumTimeCross.uAC = ac;
			mediumTimeCross.uHighOrLowThresholdFlag = (TI_UINT32)HIGH_THRESHOLD_CROSS;
			mediumTimeCross.uAboveOrBelowFlag = (TI_UINT32)CROSS_ABOVE;

			EvHandlerSendEvent(pTxCtrl->hEvHandler, IPC_EVENT_MEDIUM_TIME_CROSS, 
				(TI_UINT8 *)&mediumTimeCross, sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));

            TRACE3(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "crossed above high threshold !!! prevUsage = %d, currUsage = %d, highCreditThreshold = %d\n",				prevUsage, currUsage, highCreditThreshold);
		}

		/* reset totalUsedTime */
		pTxCtrl->totalUsedTime[ac] = 0;
	}
}
Exemple #15
0
/** 
 * \fn     scanCncnApp_ScanResultCB
 * \brief  Scan result callback for application scan
 * 
 * Scan result callback for application scan
 * 
 * \param  hScanCncn - handle to the scan concentrator object
 * \param  status - the scan result status (scan complete, result received etc.)
 * \param  frameInfo - a pointer to the structure holding all frame related info (in case a frame was received)
 * \param  SPSStatus - a bitmap indicating on which channels scan was attempted (valid for SPS scan only!)
 * \param  eScanClient - Client id of the scan initiator which will be sent back to the application
 * \return None
 */ 
void scanCncnApp_ScanResultCB (TI_HANDLE hScanCncn, EScanCncnResultStatus status,
                               TScanFrameInfo* frameInfo, TI_UINT16 SPSStatus, 
                               EScanClient eExternalScanClient,
                               EScanCncnClient eScanCncnClient)
{
    TScanCncn       *pScanCncn = (TScanCncn*)hScanCncn;
	TScanCncnClient* pClient = NULL;

    /* Since in Manual Mode the app and the SME use the same table
     * there is no need to forward data to SME */

    switch (status)
    {
    case SCAN_CRS_RECEIVED_FRAME:
        /* Save the result in the app scan result table */
        if (TI_OK != scanResultTable_UpdateEntry (pScanCncn->hScanResultTable, frameInfo->bssId, frameInfo))
		{
	        TRACE0(pScanCncn->hReport, REPORT_SEVERITY_WARNING , "scanCncn_AppScanResultCB, scanResultTable_UpdateEntry() failed\n");
		}
		break;

    case SCAN_CRS_SCAN_COMPLETE_OK:

        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncn_AppScanResultCB, received scan complete with status :%d\n", status);

        /* if OS scan is running and scan complete is upon one shot */
        if (TI_TRUE == pScanCncn->bOSScanRunning && eScanCncnClient == SCAN_SCC_APP_ONE_SHOT)
        {
            /* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
             genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
        }
        else
        {
        	TScanCncnClient* pClient = NULL;

        	if (pScanCncn->pScanClients[eScanCncnClient]->bCurrentlyRunning)
        	{
        		pClient = pScanCncn->pScanClients[eScanCncnClient];
        	}

            /* move the scan result table to stable state */
            scanResultTable_SetStableState (pScanCncn->hScanResultTable);

            /* mark that scan is no longer running */
            pScanCncn->pScanClients[eScanCncnClient]->bCurrentlyRunning = TI_FALSE;
            /* 
             * The scan was finished, send a scan complete event to the user
             * (regardless of why the scan was completed)
             */
			EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&eExternalScanClient, sizeof(TI_UINT32));

			if (pClient)
			{
				scanCncn_ClientStopped(pScanCncn, pClient);
			}
        }
        break;

    case SCAN_CRS_SCAN_STOPPED:

        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncn_AppScanResultCB, received scan complete with status :%d\n", status);
        /* if OS scan is running and scan complete is upon one shot*/
        if (TI_TRUE == pScanCncn->bOSScanRunning && eScanCncnClient == SCAN_SCC_APP_ONE_SHOT)
        {
            /* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
			genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_STOP_SCAN, hScanCncn);
			pClient = pScanCncn->pScanClients[eScanCncnClient];
			if (pClient)
			{
				scanCncn_ClientStopped(pScanCncn, pClient);
			}
        }
        else
        {

        	if (pScanCncn->pScanClients[eScanCncnClient]->bCurrentlyRunning)
        	{
        		pClient = pScanCncn->pScanClients[eScanCncnClient];
        	}

            /* move the scan result table to stable state */
            scanResultTable_SetStableState (pScanCncn->hScanResultTable);

            /* mark that scan is no longer running */
            pScanCncn->pScanClients[eScanCncnClient]->bCurrentlyRunning = TI_FALSE;
            /* 
             * The scan was finished, send a scan complete event to the user
             * (regardless of why the scan was completed)
             */
            EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&eExternalScanClient, sizeof(TI_UINT32));

			if (pClient)
			{
				scanCncn_ClientStopped(pScanCncn, pClient);
			}
        }
        break;

    case SCAN_CRS_TSF_ERROR:
    case SCAN_CRS_SCAN_RUNNING:
    case SCAN_CRS_SCAN_FAILED:
    case SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY:
    case SCAN_CRS_SCAN_ABORTED_FW_RESET:

        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncn_AppScanResultCB, received scan complete with status :%d\n", status);

        /* if OS scan is running and scan complete is upon one shot */
        if (TI_TRUE == pScanCncn->bOSScanRunning && eScanCncnClient == SCAN_SCC_APP_ONE_SHOT)
        {
            /* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
            genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
            pClient = pScanCncn->pScanClients[eScanCncnClient];
            if (pClient)
            {
                scanCncn_ClientStopped(pScanCncn, pClient);
            }
        }
        else
        {
        	TScanCncnClient* pClient = NULL;

        	if (pScanCncn->pScanClients[eScanCncnClient]->bCurrentlyRunning)
        	{
        		pClient = pScanCncn->pScanClients[eScanCncnClient];
        	}

            /* move the scan result table to stable state */
            scanResultTable_SetStableState (pScanCncn->hScanResultTable);

            /* mark that scan is no longer running */
            pScanCncn->pScanClients[eScanCncnClient]->bCurrentlyRunning = TI_FALSE;
            /* 
             * The scan was finished, send a scan complete event to the user
             * (regardless of why the scan was completed)
             */
            EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&eExternalScanClient, sizeof(TI_UINT32));

			if (pClient)
			{
				scanCncn_ClientStopped(pScanCncn, pClient);
			}
        }
        break;

    case SCAN_CRS_NUM_OF_RES_STATUS:
    default:
        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncn_AppScanResultCB, received erroneuos scan result with status :%d\n", status);
        break;
    }
}
/** 
 * \fn     scanCncn_AppScanResultCB
 * \brief  Scan result callback for application scan
 * 
 * Scan result callback for application scan
 * 
 * \param  hScanCncn - handle to the scan concentrator object
 * \param  status - the scan result status (scan complete, result received etc.)
 * \param  frameInfo - a pointer to the structure holding all frame related info (in case a frame was received)
 * \param  SPSStatus - a bitmap indicating on which channels scan was attempted (valid for SPS scan only!)
 * \return None
 */ 
void scanCncn_AppScanResultCB (TI_HANDLE hScanCncn, EScanCncnResultStatus status,
                               TScanFrameInfo* frameInfo, TI_UINT16 SPSStatus)
{
    TScanCncn   *pScanCncn = (TScanCncn*)hScanCncn;
    TI_UINT32	statusData;

    /* forward all data to SME */
    sme_AppScanResult (pScanCncn->hSme, status, frameInfo);

    switch (status)
    {
    case SCAN_CRS_RECEIVED_FRAME:
        /* Save the result in the app scan result table */
        if (TI_OK != scanResultTable_UpdateEntry (pScanCncn->hScanResultTable, frameInfo->bssId, frameInfo))
		{
	        TRACE0(pScanCncn->hReport, REPORT_SEVERITY_WARNING , "scanCncn_AppScanResultCB, scanResultTable_UpdateEntry() failed\n");
		}
		break;

    case SCAN_CRS_SCAN_COMPLETE_OK:

        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncn_AppScanResultCB, received scan complete with status :%d\n", status);

        /* if OS scan is running */
        if (TI_TRUE == pScanCncn->bOSScanRunning)
        {
            /* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
            genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
        }
        else
        {
            /* move the scan result table to stable state, clear it if no results were received */
            scanResultTable_SetStableState (pScanCncn->hScanResultTable);

            /* mark that no app scan is running */
            pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
            /*
             * The scan was finished, send a scan complete event to the user
             * (regardless of why the scan was completed)
             */
            statusData = SCAN_STATUS_COMPLETE;	/* Completed status */
			EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&statusData, sizeof(TI_UINT32));
        }
        break;

    case SCAN_CRS_SCAN_STOPPED:

        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncn_AppScanResultCB, received scan complete with status :%d\n", status);

        /* if OS scan is running */
        if (TI_TRUE == pScanCncn->bOSScanRunning)
        {
            /* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
            genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
        }
        else
        {
            /* move the scan result table to stable state, clear it if no results were received */
            scanResultTable_SetStableState (pScanCncn->hScanResultTable);

            /* mark that no app scan is running */
            pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
            /*
             * The scan was finished, send a scan complete event to the user
             * (regardless of why the scan was completed)
             */
            statusData = SCAN_STATUS_STOPPED;	/* Stopped status */
            EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&statusData, sizeof(TI_UINT32));
        }
        break;

    case SCAN_CRS_TSF_ERROR:
    case SCAN_CRS_SCAN_RUNNING:
    case SCAN_CRS_SCAN_FAILED:
    case SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY:
    case SCAN_CRS_SCAN_ABORTED_FW_RESET:

        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncn_AppScanResultCB, received scan complete with status :%d\n", status);

        /* if OS scan is running */
        if (TI_TRUE == pScanCncn->bOSScanRunning)
        {
            /* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
            genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
        }
        else
        {
            /* move the scan result table to stable state, clear it if no results were received */
            scanResultTable_SetStableState (pScanCncn->hScanResultTable);

            /* mark that no app scan is running */
            pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
            /* 
             * The scan was finished, send a scan complete event to the user
             * (regardless of why the scan was completed)
             */
            statusData = SCAN_STATUS_FAILED;		/* Failed status */
            EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&statusData, sizeof(TI_UINT32));
        }
        break;

    case SCAN_CRS_NUM_OF_RES_STATUS:
    default:
        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncn_AppScanResultCB, received erroneuos scan result with status :%d\n", status);
        break;
    }
}
/**
*
* roamingMngr_triggerRoamingCb
*
* \b Description:
*
* This procedure is called when Roaming should be triggered
 * due to one of apConn_roamingTrigger_e Roaming Reasons.
 * Save the trigger and process it only if there's no other Roaming trigger
 * in process.
*
* \b ARGS:
*
*  I   - hRoamingMngr - roamingMngr SM context  \n
*  I   - pData - pointer to roaming trigger
*
* \b RETURNS:
*
*  TI_OK if successful, TI_NOK otherwise.
*
*
*/
TI_STATUS roamingMngr_triggerRoamingCb(TI_HANDLE hRoamingMngr, void *pData, TI_UINT16 reasonCode)
{
	roamingMngr_t       *pRoamingMngr;
	apConn_roamingTrigger_e     roamingTrigger;
	TI_UINT32                   curTimestamp;
	TI_UINT16                   disConnReasonCode;


	pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
	if ((pRoamingMngr == NULL) || (pData == NULL)) {
		return TI_NOK;
	}

	roamingTrigger = *(apConn_roamingTrigger_e *)pData;

	if ((ROAMING_OPERATIONAL_MODE_MANUAL == pRoamingMngr->RoamingOperationalMode) &&
	        (roamingTrigger == ROAMING_TRIGGER_AP_DISCONNECT)) {
		disConnReasonCode = reasonCode;
		EvHandlerSendEvent(pRoamingMngr->hEvHandler, IPC_EVENT_AP_DISCONNECT, (TI_UINT8*)&disConnReasonCode, sizeof(disConnReasonCode));
	}


	if (roamingTrigger >= ROAMING_TRIGGER_LAST) {
		TRACE1(pRoamingMngr->hReport, REPORT_SEVERITY_ERROR, "roamingMngr_triggerRoamingCb, bad roaming trigger = %d\n", roamingTrigger);
		return TI_NOK;
	}
#ifdef TI_DBG
	/* save parameters for debug*/
	pRoamingMngr->roamingTriggerEvents[pRoamingMngr->roamingTrigger]++;
#endif
	if (roamingTrigger <= ROAMING_TRIGGER_BG_SCAN_GROUP) {
		ERssiQuality    rssiQuality = ROAMING_QUALITY_NORMAL;
		if (roamingTrigger == ROAMING_TRIGGER_LOW_QUALITY_FOR_BG_SCAN) {
			rssiQuality = ROAMING_QUALITY_LOW;
		} else if (roamingTrigger == ROAMING_TRIGGER_HIGH_QUALITY_FOR_BG_SCAN) {
			rssiQuality = ROAMING_QUALITY_HIGH;
		}

		TRACE1(pRoamingMngr->hReport, REPORT_SEVERITY_INFORMATION, "roamingMngr_triggerRoamingCb, rssiQuality = %d \n", rssiQuality);
		scanMngr_notifyChangeTrigger(pRoamingMngr->hScanMngr, rssiQuality);
	} else {
		if (roamingTrigger > pRoamingMngr->roamingTrigger) {  /* Save the highest priority roaming trigger */
			pRoamingMngr->roamingTrigger = roamingTrigger;
			TRACE1(pRoamingMngr->hReport, REPORT_SEVERITY_INFORMATION, "roamingMngr_triggerRoamingCb, higher trigger = %d \n", roamingTrigger);

		}

		curTimestamp = os_timeStampMs(pRoamingMngr->hOs);

		/* If "No BSS" trigger received, disable count of low pass filter timer */
		if (roamingTrigger > ROAMING_TRIGGER_LOW_QUALITY_GROUP) {
			pRoamingMngr->lowQualityTriggerTimestamp = 0;
		}

		/* Do not invoke a new Roaming Trigger when a previous one is in process */
		if (pRoamingMngr->maskRoamingEvents == TI_FALSE) {  /* No Roaming trigger is in process */
			/* If the trigger is low quality check the low pass filter */
			TRACE1(pRoamingMngr->hReport, REPORT_SEVERITY_INFORMATION, "roamingMngr_triggerRoamingCb, trigger = %d \n", roamingTrigger);
			if (roamingTrigger <= ROAMING_TRIGGER_LOW_QUALITY_GROUP) {
				TI_UINT32 deltaTs = curTimestamp-pRoamingMngr->lowQualityTriggerTimestamp;

				if ((pRoamingMngr->lowQualityTriggerTimestamp != 0) &&
				        (deltaTs < pRoamingMngr->lowPassFilterRoamingAttemptInMsec)) { /* Ignore the low quality events. till the low pass time elapses */
					TRACE5(pRoamingMngr->hReport, REPORT_SEVERITY_INFORMATION, "roamingMngr_triggerRoamingCb, trigger = %d Ignored!!,deltaTs=%d, curTimestamp = %d, lowQualityTriggerTimestamp = %d, lowPassFilterRoamingAttempt=%d\n", roamingTrigger, deltaTs, curTimestamp, pRoamingMngr->lowQualityTriggerTimestamp, pRoamingMngr->lowPassFilterRoamingAttemptInMsec);
					return TI_OK;
				}
				pRoamingMngr->lowQualityTriggerTimestamp = curTimestamp;
			}

			/* Mask all future roaming events */
			pRoamingMngr->maskRoamingEvents = TI_TRUE;

#ifdef TI_DBG
			/* For debug */
			pRoamingMngr->roamingTriggerTimestamp = curTimestamp;
#endif
			return (roamingMngr_smEvent(ROAMING_EVENT_ROAM_TRIGGER, pRoamingMngr));
		} else if (roamingTrigger > ROAMING_TRIGGER_FAST_CONNECT_GROUP) {  /* If the trigger is from the Full Connect group, then stop the connection. */
			return (roamingMngr_smEvent(ROAMING_EVENT_ROAM_TRIGGER, pRoamingMngr));

		}
	}

	return TI_OK;
}
/**
 * \author Ronen Kalish\n
 * \date 30-Jan-2005\n
 * \brief Parses and executes a set param command.\n
 *
 * Function Scope \e Public.\n
 * \param hScanCncn - handle to the scan concentrator object.\n
 * \param pParam - the param to set.\n
 * \return OK if the scan started successfully, NOK otherwise.\n
 */
TI_STATUS scanConcentrator_setParam( TI_HANDLE hScanCncn, paramInfo_t *pParam )
{
    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t *)hScanCncn;
	scan_Params_t* pScanParam; 
	UINT32 currentTimeStamp;

    switch ( pParam->paramType )
    {
	case SCAN_CNCN_START_APP_SCAN:
		pScanParam = pParam->content.pScanParams;
		/*
		 * Prepare scan complete's aging, by increasing the scanned sites 
		 * scan attemps counter. The counter will be checked upon scan complete,  
		 * and the sites with no update scan results will be dropped.   
		 */
		siteMgr_setNotReceivedParameter( pScanConcentrator->hSiteManager, &(pScanParam->desiredSsid), pScanParam->band );
        
		if ( SCAN_CRS_SCAN_RUNNING != 
                scanConcentrator_scan( hScanCncn, SCAN_SCC_APP, pScanParam ) )
        {
            /* Scan was not started successfully, send a scan complete event to the user */
            EvHandlerSendEvent( pScanConcentrator->hEventSrv, IPC_EVENT_SCAN_COMPLETE, NULL, 0 );
            return NOK;
        }
        break;

    case SCAN_CNCN_STOP_APP_SCAN:
        scanConcentrator_stopScan( hScanCncn, SCAN_SCC_APP );
        break;
	case SCAN_CNCN_BSSID_LIST_SCAN_PARAM:
		/* check if OID scans are enabled in the registry */
		if ( 0 == pScanConcentrator->initParams.minimumDurationBetweenOidScans )
		{
			WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
									 ("Received OID scan request when OID scans are disabled, quitting...\n") );
			return OK; /* TODO ronen: return correct Windows value */
		}

		/* check if the last OID scan didn't start at a shorter duration than the configured minimum */
		currentTimeStamp = os_timeStampMs( pScanConcentrator->hOS );
		if ( (currentTimeStamp - pScanConcentrator->oidScanLastTimeStamp) < 
			 (pScanConcentrator->initParams.minimumDurationBetweenOidScans * 1000) ) /*converted to ms */
		{
			WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
									 ("Last OID scan performed at:%d, now is:%d, min duration is %d, too early for another scan!\n", \
									  pScanConcentrator->oidScanLastTimeStamp, currentTimeStamp, pScanConcentrator->initParams.minimumDurationBetweenOidScans) );
			return OK; /* TODO ronen: return correct Windows value */
		}

		/* mark that an OID scan process has started */
		pScanConcentrator->bOidScanRunning = TRUE;
		pScanConcentrator->oidScanLastTimeStamp = currentTimeStamp;
		WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
   								 ("Starting OID scan process...\n") );

		/* and actually start the scan */
		scanConcentratorOidSM_SMEvent( hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_START_SCAN );
		break;
        
    default:
	    WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
                           ("Set param, Params is not supported:%d\n\n", pParam->paramType) );
	    return PARAM_NOT_SUPPORTED;
    }

    return OK;
}
Exemple #19
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;
}
Exemple #20
0
/**
 * \fn     scanCncn_AppScanResultCB
 * \brief  Scan result callback for application scan
 *
 * Scan result callback for application scan
 *
 * \param  hScanCncn - handle to the scan concentrator object
 * \param  status - the scan result status (scan complete, result received etc.)
 * \param  frameInfo - a pointer to the structure holding all frame related info (in case a frame was received)
 * \param  SPSStatus - a bitmap indicating on which channels scan was attempted (valid for SPS scan only!)
 * \return None
 */
void scanCncn_AppScanResultCB (TI_HANDLE hScanCncn, EScanCncnResultStatus status,
                               TScanFrameInfo* frameInfo, TI_UINT16 SPSStatus)
{
	TScanCncn   *pScanCncn = (TScanCncn*)hScanCncn;
	TI_UINT32	statusData;

	/* Since in Manual Mode the app and the SME use the same table
	 * there is no need to forward data to SME */

	switch (status) {
	case SCAN_CRS_RECEIVED_FRAME:
		/* Save the result in the app scan result table */
		if (TI_OK != scanResultTable_UpdateEntry (pScanCncn->hScanResultTable, frameInfo->bssId, frameInfo)) {
		}
		break;

	case SCAN_CRS_SCAN_COMPLETE_OK:


		/* if OS scan is running */
		if (TI_TRUE == pScanCncn->bOSScanRunning) {
			/* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
			genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
		} else {
			/* move the scan result table to stable state */
			scanResultTable_SetStableState (pScanCncn->hScanResultTable);

			/* mark that no app scan is running */
			pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
			/*
			 * The scan was finished, send a scan complete event to the user
			 * (regardless of why the scan was completed)
			 */
			statusData = SCAN_STATUS_COMPLETE;	/* Completed status */
			EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&statusData, sizeof(TI_UINT32));
		}
		break;

	case SCAN_CRS_SCAN_STOPPED:


		/* if OS scan is running */
		if (TI_TRUE == pScanCncn->bOSScanRunning) {
			/* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
			genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
		} else {
			/* move the scan result table to stable state */
			scanResultTable_SetStableState (pScanCncn->hScanResultTable);

			/* mark that no app scan is running */
			pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
			/*
			 * The scan was finished, send a scan complete event to the user
			 * (regardless of why the scan was completed)
			 */
			statusData = SCAN_STATUS_STOPPED;	/* Stopped status */
			EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&statusData, sizeof(TI_UINT32));
		}
		break;

	case SCAN_CRS_TSF_ERROR:
	case SCAN_CRS_SCAN_RUNNING:
	case SCAN_CRS_SCAN_FAILED:
	case SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY:
	case SCAN_CRS_SCAN_ABORTED_FW_RESET:


		/* if OS scan is running */
		if (TI_TRUE == pScanCncn->bOSScanRunning) {
			/* send a scan complete event to the OS scan SM. It will stabliza the table when needed */
			genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_SCAN_COMPLETE, hScanCncn);
		} else {
			/* move the scan result table to stable state */
			scanResultTable_SetStableState (pScanCncn->hScanResultTable);

			/* mark that no app scan is running */
			pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
			/*
			 * The scan was finished, send a scan complete event to the user
			 * (regardless of why the scan was completed)
			 */
			statusData = SCAN_STATUS_FAILED;		/* Failed status */
			EvHandlerSendEvent (pScanCncn->hEvHandler, IPC_EVENT_SCAN_COMPLETE, (TI_UINT8 *)&statusData, sizeof(TI_UINT32));
		}
		break;

	case SCAN_CRS_NUM_OF_RES_STATUS:
	default:
		break;
	}
}