Exemplo n.º 1
0
/**
 * \fn     smeSm_PreConnect
 * \brief  Initiates the connection process
 *
 * Initiates the connection process - for automatic mode, start scan, for manual mode - triggers connection
 *
 * \param  hSme - handle to the SME object
 * \return None
 * \sa     smeSm_Connect, smeSm_ConnectSuccess
 */
void smeSm_PreConnect (TI_HANDLE hSme)
{
	TSme *pSme = (TSme *)hSme;
	paramInfo_t	*pParam;


	/* set the connection mode with which this connection attempt is starting */
	pSme->eLastConnectMode = pSme->eConnectMode;

	/* mark that no authentication/assocaition was yet sent */
	pSme->bAuthSent = TI_FALSE;

	/* try to find a connection candidate (manual mode have already performed scann */
	pSme->pCandidate = sme_Select (hSme);
	if (NULL != pSme->pCandidate) {
		/* candidate is available - attempt connection */
		sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT, hSme);
	}
	/* no candidate */
	else {
		if (CONNECT_MODE_AUTO == pSme->eConnectMode) {
			/* automatic mode - start scanning */
			if (TI_OK != sme_StartScan (hSme)) {
				pSme->bRadioOn = TI_FALSE;
				sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);
			}

			/* update scan count counter */
			if (pSme->uScanCount < PERIODIC_SCAN_MAX_INTERVAL_NUM) {
				pSme->uScanCount++;
			}

		} else {	/* Manual mode */
			/* for IBSS or any, if no entries where found, add the self site */
			if (pSme->eBssType == BSS_INFRASTRUCTURE) {
				/* makr whether we need to stop the attempt connection in manual mode */
				pSme->bConnectRequired = TI_FALSE;

				/* manual mode and no connection candidate is available - connection failed */
				sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);
			}

			else {	/* IBSS */
				TI_UINT8    uDesiredChannel;
				TI_BOOL     channelValidity;
				pSme->bConnectRequired = TI_FALSE;

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

				pParam->paramType = SITE_MGR_DESIRED_CHANNEL_PARAM;
				siteMgr_getParam(pSme->hSiteMgr, pParam);
				uDesiredChannel = pParam->content.siteMgrDesiredChannel;

				if (uDesiredChannel >= SITE_MGR_CHANNEL_A_MIN) {
					pParam->content.channelCapabilityReq.band = RADIO_BAND_5_0_GHZ;
				} else {
					pParam->content.channelCapabilityReq.band = RADIO_BAND_2_4_GHZ;
				}

				/*
				update the regulatory domain with the selected band
				*/
				/* Check if the selected channel is valid according to regDomain */
				pParam->paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
				pParam->content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
				pParam->content.channelCapabilityReq.channelNum = uDesiredChannel;

				regulatoryDomain_getParam (pSme->hRegDomain, pParam);
				channelValidity = pParam->content.channelCapabilityRet.channelValidity;
				os_memoryFree(pSme->hOS, pParam, sizeof(paramInfo_t));
				if (!channelValidity) {

					sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);

					return;
				}

				pSme->pCandidate = (TSiteEntry *)addSelfSite(pSme->hSiteMgr);

				if (pSme->pCandidate == NULL) {

					sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);

					return;
				}

				/* a connection candidate is available, send a connect event */
				sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT, hSme);
			}
		}
	}
}
Exemplo n.º 2
0
/** 
 * \fn     smeSm_PreConnect
 * \brief  Initiates the connection process
 * 
 * Initiates the connection process - for automatic mode, start scan, for manual mode - triggers connection
 * 
 * \param  hSme - handle to the SME object
 * \return None
 * \sa     smeSm_Connect, smeSm_ConnectSuccess
 */ 
void smeSm_PreConnect (TI_HANDLE hSme)
{
    TSme *pSme = (TSme *)hSme;
    paramInfo_t	*pParam;
//joetest
TRACE0(pSme->hReport, REPORT_SEVERITY_SM , "smeSm_PreConnect: !!!\n");
    /* set the connection mode with which this connection attempt is starting */
    pSme->eLastConnectMode = pSme->eConnectMode;
 
    /* mark that no authentication/assocaition was yet sent */
    pSme->bAuthSent = TI_FALSE;

    /* try to find a connection candidate (manual mode have already performed scann */
    pSme->pCandidate = sme_Select (hSme);
    if (NULL != pSme->pCandidate)
    {
        /* candidate is available - attempt connection */
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT, hSme);
    }
    /* no candidate */
    else
    {
        if (CONNECT_MODE_AUTO == pSme->eConnectMode)
        {
            /* automatic mode - start scanning */
            if (TI_OK != sme_StartScan (hSme))
            {
                TRACE0(pSme->hReport, REPORT_SEVERITY_ERROR , "smeSm_PreConnect: unable to start scan, stopping the SME\n");
                pSme->bRadioOn = TI_FALSE;
                sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);
            }

            /* update scan count counter */
            if(pSme->uScanCount < PERIODIC_SCAN_MAX_INTERVAL_NUM)
            {
                pSme->uScanCount++;
            }

        }
        else		/* Manual mode */ 
        { 
			/* for IBSS or any, if no entries where found, add the self site */
			if (pSme->eBssType == BSS_INFRASTRUCTURE)
            {
                /* makr whether we need to stop the attempt connection in manual mode */
                pSme->bConnectRequired = TI_FALSE;
    
                TRACE0(pSme->hReport, REPORT_SEVERITY_INFORMATION , "smeSm_PreConnect: No candidate available, sending connect failure\n");
                /* manual mode and no connection candidate is available - connection failed */
 //joetest
TRACE0(pSme->hReport, REPORT_SEVERITY_SM , "smeSm_PreConnect!!!\n");
			}

			else		/* IBSS */
			{
				TI_UINT8     uDesiredChannel;     
                TI_BOOL     channelValidity;
		        pSme->bConnectRequired = TI_FALSE;

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

				pParam->paramType = SITE_MGR_DESIRED_CHANNEL_PARAM;
				siteMgr_getParam(pSme->hSiteMgr, pParam);
				uDesiredChannel = pParam->content.siteMgrDesiredChannel;

				if (uDesiredChannel >= SITE_MGR_CHANNEL_A_MIN)
				{
				   pParam->content.channelCapabilityReq.band = RADIO_BAND_5_0_GHZ;
				} 
				else 
				{
				   pParam->content.channelCapabilityReq.band = RADIO_BAND_2_4_GHZ;
				}

				/*
				update the regulatory domain with the selected band
				*/
				/* Check if the selected channel is valid according to regDomain */
				pParam->paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
				pParam->content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
				pParam->content.channelCapabilityReq.channelNum = uDesiredChannel;

				regulatoryDomain_getParam (pSme->hRegDomain,pParam);
                channelValidity = pParam->content.channelCapabilityRet.channelValidity;
                os_memoryFree(pSme->hOS, pParam, sizeof(paramInfo_t));
				if (!channelValidity)
				{
				   TRACE0(pSme->hReport, REPORT_SEVERITY_INFORMATION , "IBSS SELECT FAILURE  - No channel !!!\n\n");

				   sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);

				   return;
				}

				pSme->pCandidate = (TSiteEntry *)addSelfSite(pSme->hSiteMgr);

				if (pSme->pCandidate == NULL)
				{
				   TRACE0(pSme->hReport, REPORT_SEVERITY_ERROR , "IBSS SELECT FAILURE  - could not open self site !!!\n\n");

				   sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);

				   return;
				}

#ifdef REPORT_LOG    
				TRACE6(pSme->hReport, REPORT_SEVERITY_CONSOLE,"%%%%%%%%%%%%%%	SELF SELECT SUCCESS, bssid: %X-%X-%X-%X-%X-%X	%%%%%%%%%%%%%%\n\n", pSme->pCandidate->bssid[0], pSme->pCandidate->bssid[1], pSme->pCandidate->bssid[2], pSme->pCandidate->bssid[3], pSme->pCandidate->bssid[4], pSme->pCandidate->bssid[5]);
                WLAN_OS_REPORT (("%%%%%%%%%%%%%%	SELF SELECT SUCCESS, bssid: %02x.%02x.%02x.%02x.%02x.%02x %%%%%%%%%%%%%%\n\n", pSme->pCandidate->bssid[0], pSme->pCandidate->bssid[1], pSme->pCandidate->bssid[2], pSme->pCandidate->bssid[3], pSme->pCandidate->bssid[4], pSme->pCandidate->bssid[5]));
#endif
				/* a connection candidate is available, send a connect event */
				sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT, hSme);
			}
        }
    }
}