Exemplo n.º 1
0
/**
 * \fn     scanCncnApp_SetParam
 * \brief  Parses and executes a set param command
 *
 * Parses and executes a set param command (start/stop one-shot/periodic/OS scan)
 *
 * \param  hScanCncn - handle to the scan concentrator object
 * \param  pParam - the param to set
 * \return operation status (OK / NOK / PARAM_NOT_SUPPORTED)
 * \sa     scanCncnApp_GetParam
 */
TI_STATUS scanCncnApp_SetParam (TI_HANDLE hScanCncn, paramInfo_t *pParam)
{
	TScanCncn   *pScanCncn = (TScanCncn*)hScanCncn;
	TI_UINT32   uCurrentTimeStamp;


	switch (pParam->paramType) {
	case SCAN_CNCN_START_APP_SCAN:

		/* verify that scan is not currently running */
		if (pScanCncn->eCurrentRunningAppScanClient != SCAN_SCC_NO_CLIENT) {
			/* Scan was not started successfully, send a scan complete event to the user */
			return TI_NOK;
		}

		/* set one-shot scan as running app scan client */
		pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_APP_ONE_SHOT;

		/* Perform aging process before the scan */
		scanResultTable_PerformAging(pScanCncn->hScanResultTable);

		/* start the scan */
		if (SCAN_CRS_SCAN_RUNNING !=
		        scanCncn_Start1ShotScan (hScanCncn, SCAN_SCC_APP_ONE_SHOT, pParam->content.pScanParams)) {
			/* Scan was not started successfully, mark that no app scan is running */
			pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
			return TI_NOK;
		}
		break;

	case SCAN_CNCN_STOP_APP_SCAN:
		/* verify that scan is currently running */
		if (pScanCncn->eCurrentRunningAppScanClient != SCAN_SCC_NO_CLIENT) {
			scanCncn_StopScan (hScanCncn, SCAN_SCC_APP_ONE_SHOT);
		}
		break;

	case SCAN_CNCN_START_PERIODIC_SCAN:
		/* verify that scan is not currently running */
		if (SCAN_SCC_NO_CLIENT != pScanCncn->eCurrentRunningAppScanClient) {
			/* Scan was not started successfully, send a scan complete event to the user */
			return TI_NOK;
		}

		/* set one-shot scan as running app scan client */
		pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_APP_PERIODIC;

		/* Perform aging process before the scan */
		scanResultTable_PerformAging(pScanCncn->hScanResultTable);

		/* start the scan */
		if (SCAN_CRS_SCAN_RUNNING !=
		        scanCncn_StartPeriodicScan (hScanCncn, SCAN_SCC_APP_PERIODIC, pParam->content.pPeriodicScanParams)) {
			WLAN_OS_REPORT (("Scan was not started. Verify scan parametrs or SME mode\n"));

			/* Scan was not started successfully, mark that no app scan is running */
			pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_NO_CLIENT;
			return TI_NOK;
		}
		break;

	case SCAN_CNCN_STOP_PERIODIC_SCAN:
		/* verify that scan is currently running */
		if (pScanCncn->eCurrentRunningAppScanClient != SCAN_SCC_NO_CLIENT) {
			scanCncn_StopPeriodicScan (hScanCncn, SCAN_SCC_APP_PERIODIC);
		}
		break;

	case SCAN_CNCN_BSSID_LIST_SCAN_PARAM:
		/* check if OID scans are enabled in the registry */
		if (0 == pScanCncn->tInitParams.uMinimumDurationBetweenOsScans) {
			return TI_NOK;
		}

		/* check if the last OID scan didn't start at a shorter duration than the configured minimum */
		uCurrentTimeStamp = os_timeStampMs (pScanCncn->hOS);
		if ( (uCurrentTimeStamp - pScanCncn->uOSScanLastTimeStamp) <
		        (pScanCncn->tInitParams.uMinimumDurationBetweenOsScans * 1000) ) { /*converted to ms */
			return TI_NOK;
		}

		/* check that no other scan is currently running */
		if (SCAN_SCC_NO_CLIENT != pScanCncn->eCurrentRunningAppScanClient) {
			return TI_NOK;
		}

		/* set one-shot scan as running app scan client */
		pScanCncn->eCurrentRunningAppScanClient = SCAN_SCC_APP_ONE_SHOT;

		/* mark that an OID scan process has started */
		pScanCncn->bOSScanRunning = TI_TRUE;
		pScanCncn->uOSScanLastTimeStamp = uCurrentTimeStamp;

		if (0 != pParam->content.pScanParams->desiredSsid.len) {
			pScanCncn->tOsScanParams.desiredSsid.len = pParam->content.pScanParams->desiredSsid.len;
			os_memoryCopy(pScanCncn->hOS, pScanCncn->tOsScanParams.desiredSsid.str, pParam->content.pScanParams->desiredSsid.str, pParam->content.pScanParams->desiredSsid.len);
		} else {
			pScanCncn->tOsScanParams.desiredSsid.len = 0;
			pScanCncn->tOsScanParams.desiredSsid.str[ 0 ] = '\0'; /* broadcast scan */
		}

		pScanCncn->tOsScanParams.scanType = pParam->content.pScanParams->scanType;

		/* Perform aging process before the scan */
		scanResultTable_PerformAging(pScanCncn->hScanResultTable);

		/* and actually start the scan */
		genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_START_SCAN, hScanCncn);

		break;

	case SCAN_CNCN_SET_SRA:
		scanResultTable_SetSraThreshold(pScanCncn->hScanResultTable, pParam->content.uSraThreshold);
		break;

	case SCAN_CNCN_SET_RSSI:
		pScanCncn->tInitParams.nRssiThreshold = pParam->content.nRssiThreshold;
		break;

	default:
		return PARAM_NOT_SUPPORTED;
	}

	return TI_OK;
}
Exemplo n.º 2
0
/** 
 * \fn     scanCncnApp_SetParam
 * \brief  Parses and executes a set param command
 * 
 * Parses and executes a set param command (start/stop one-shot/periodic/OS scan)
 * 
 * \param  hScanCncn - handle to the scan concentrator object
 * \param  pParam - the param to set
 * \return operation status (OK / NOK / PARAM_NOT_SUPPORTED)
 * \sa     scanCncnApp_GetParam 
 */ 
TI_STATUS scanCncnApp_SetParam (TI_HANDLE hScanCncn, paramInfo_t *pParam)
{
    TScanCncn   *pScanCncn = (TScanCncn*)hScanCncn;
    TI_UINT32   uCurrentTimeStamp;

    TRACE1(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnApp_SetParam: recevived request of type 0x%x\n", pParam->paramType);

    switch (pParam->paramType)
    {
    case SCAN_CNCN_START_APP_SCAN:

        /* App scan can start only if there is a periodic scan running or no scan at all */
        if (pScanCncn->pScanClients[SCAN_SCC_APP_ONE_SHOT]->bCurrentlyRunning) 
        {
            TRACE0(pScanCncn->hReport, REPORT_SEVERITY_WARNING, "scanCncnApp_SetParam: trying to start app one-shot scan when SCAN_SCC_APP_ONE_SHOT is currently running!\n");
            /* Scan was not started successfully because driver is busy. 
            Send a scan complete event to the user */
            return TI_BUSY;
        }

        /* set one-shot scan as running app scan client */
        pScanCncn->pScanClients[SCAN_SCC_APP_ONE_SHOT]->bCurrentlyRunning = TI_TRUE;

        /* Perform aging process before the scan */
        scanResultTable_PerformAging(pScanCncn->hScanResultTable);


        /* start the scan */
        if (SCAN_CRS_SCAN_RUNNING != 
            scanCncn_Start1ShotScan (hScanCncn, SCAN_SCC_APP_ONE_SHOT, pParam->content.pScanParams))
        {
            /* Scan was not started successfully, mark that no app scan is running */
            pScanCncn->pScanClients[SCAN_SCC_APP_ONE_SHOT]->bCurrentlyRunning = TI_FALSE;
            return TI_ERROR;
        }
        break;

    case SCAN_CNCN_STOP_APP_SCAN:

        /* verify that scan is currently running */
        if (pScanCncn->pScanClients[SCAN_SCC_APP_ONE_SHOT]->bCurrentlyRunning) 
        {
            scanCncn_StopScan (hScanCncn, SCAN_SCC_APP_ONE_SHOT);
        }
        break;

    case SCAN_CNCN_START_PERIODIC_SCAN:

        /* Check if there is periodic scan running  */
        if (pScanCncn->pScanClients[SCAN_SCC_APP_PERIODIC]->bCurrentlyRunning) 
        {
            
            /* Check if the running scan was requested by the same slient as the new scan
               If yes - stop the running scan and start a new one with the new params.
               If not - return BUSY. */
            int currRunningScanClientId = 
                pScanCncn->pScanClients[SCAN_SCC_APP_PERIODIC]->uScanParams.tPeriodicScanParams.eScanClient;
            int newSanClientId = 
                pParam->content.pPeriodicScanParams->eScanClient;

            if (currRunningScanClientId == newSanClientId) 
            {
                TRACE0(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION, "Stopping running periodical scan"
                                                                        "in order to start a new one from the same client.\n");
                os_memoryCopy(pScanCncn->hOS, &pScanCncn->tPendingPeriodicScanParams, &pParam, 
                              sizeof(paramInfo_t));
                pScanCncn->bPendingPeriodicScan = TI_TRUE;
                scanCncn_StopPeriodicScan (hScanCncn, SCAN_SCC_APP_PERIODIC);
            }
            else
            {
                TRACE0(pScanCncn->hReport, REPORT_SEVERITY_WARNING, "scanCncnApp_SetParam: trying to start app periodic scan when there is one currently running!\n");
                /* Scan was not started successfully because driver is busy. 
                Send a scan complete event to the user */
                return TI_BUSY;
            }
        } 

        /* set periodic scan as running app scan client */
        pScanCncn->pScanClients[SCAN_SCC_APP_PERIODIC]->bCurrentlyRunning = TI_TRUE;

        /* Perform aging process before the scan */
        scanResultTable_PerformAging(pScanCncn->hScanResultTable);

        if (SCAN_CRS_SCAN_RUNNING !=
            scanCncn_StartPeriodicScan (hScanCncn, SCAN_SCC_APP_PERIODIC, pParam->content.pPeriodicScanParams))
        {
            TRACE0(pScanCncn->hReport, REPORT_SEVERITY_CONSOLE , "Scan was not started. Verify scan parametrs or SME mode.\n");
            WLAN_OS_REPORT (("Scan was not started. Verify scan parametrs or SME mode\n"));
                             
            /* Scan was not started successfully, mark that no app scan is running */
            pScanCncn->pScanClients[SCAN_SCC_APP_PERIODIC]->bCurrentlyRunning = TI_FALSE;
            return TI_ERROR;

        }

        break;

    case SCAN_CNCN_STOP_PERIODIC_SCAN:
        /* verify that scan is currently running */
        if (pScanCncn->pScanClients[SCAN_SCC_APP_PERIODIC]->bCurrentlyRunning)
        {
            scanCncn_StopPeriodicScan (hScanCncn, SCAN_SCC_APP_PERIODIC);
        }
        break;

    case SCAN_CNCN_BSSID_LIST_SCAN_PARAM:

        /* check if OID scans are enabled in the registry */
        if (0 == pScanCncn->tInitParams.uMinimumDurationBetweenOsScans)
        {
            TRACE0(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnApp_SetParam: received OS scan request when OS scans are disabled, quitting...\n");
            return TI_NOK;
        }

        /* check if the last OID scan didn't start at a shorter duration than the configured minimum */
        uCurrentTimeStamp = os_timeStampMs (pScanCncn->hOS);
        if ( (uCurrentTimeStamp - pScanCncn->uOSScanLastTimeStamp) < 
             (pScanCncn->tInitParams.uMinimumDurationBetweenOsScans * 1000) ) /*converted to ms */
        {
            TRACE3(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnApp_SetParam: last OID scan performed at: %d, now is: %d, min duration is: %d, too early for another scan!\n", pScanCncn->uOSScanLastTimeStamp, uCurrentTimeStamp, pScanCncn->tInitParams.uMinimumDurationBetweenOsScans);
            return TI_NOK;
        }

        /* App (os OS) scan can start only if there is a periodic scan running or no scan at all */
        if (pScanCncn->pScanClients[SCAN_SCC_APP_ONE_SHOT]->bCurrentlyRunning) 
        {
            TRACE0(pScanCncn->hReport, REPORT_SEVERITY_WARNING, "scanCncnApp_SetParam: trying to start app one-shot scan when SCAN_SCC_APP_ONE_SHOT is currently running!\n");
            /* Scan was not started successfully because driver is busy. 
            Send a scan complete event to the user */
            return TI_BUSY;
        }

        /* set one-shot scan as running app scan client */
        pScanCncn->pScanClients[SCAN_SCC_APP_ONE_SHOT]->bCurrentlyRunning = TI_TRUE;

        /* mark that an OID scan process has started */
        pScanCncn->bOSScanRunning = TI_TRUE;
        pScanCncn->uOSScanLastTimeStamp = uCurrentTimeStamp;
        TRACE0(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnApp_SetParam: starting OID scan process...\n");


		if(0 != pParam->content.pScanParams->desiredSsid.len)
        {
			pScanCncn->tOsScanParams.desiredSsid.len = pParam->content.pScanParams->desiredSsid.len;
            os_memoryCopy(pScanCncn->hOS, pScanCncn->tOsScanParams.desiredSsid.str, pParam->content.pScanParams->desiredSsid.str, pParam->content.pScanParams->desiredSsid.len);
        }
        else
        {
            pScanCncn->tOsScanParams.desiredSsid.len = 0;
            pScanCncn->tOsScanParams.desiredSsid.str[ 0 ] = '\0'; /* broadcast scan */
        }

		pScanCncn->tOsScanParams.scanType = pParam->content.pScanParams->scanType;
        pScanCncn->tOsScanParams.eScanClient = pParam->content.pScanParams->eScanClient;
		pScanCncn->tOsScanParams.numOfChannels = pParam->content.pScanParams->numOfChannels;

		TRACE2(pScanCncn->hReport, REPORT_SEVERITY_INFORMATION , "scanCncnApp_SetParam: scanType is %d and numOfChannels is %d\n", pParam->content.pScanParams->scanType, pParam->content.pScanParams->numOfChannels);


        /* Perform aging process before the scan */
        scanResultTable_PerformAging(pScanCncn->hScanResultTable);


        /* and actually start the scan */
        genSM_Event (pScanCncn->hOSScanSm, SCAN_CNCN_OS_SM_EVENT_START_SCAN, hScanCncn);


        break;

    case SCAN_CNCN_SET_SRA:
        scanResultTable_SetSraThreshold(pScanCncn->hScanResultTable, pParam->content.uSraThreshold);
        break;

    case SCAN_CNCN_SET_RSSI:
        pScanCncn->tInitParams.nRssiThreshold = pParam->content.nRssiThreshold;
        break;

    default:
        TRACE1(pScanCncn->hReport, REPORT_SEVERITY_ERROR , "scanCncnApp_SetParam: unrecognized param type :0x%x\n", pParam->paramType);
        return PARAM_NOT_SUPPORTED;
    }

    return TI_OK;
}