Esempio n. 1
0
/** 
 * \fn     smeSm_Start
 * \brief  Starts STA opeartion by moving SCR out of idle group and starting connection process
 * 
 * Starts STA opeartion by moving SCR out of idle group and starting connection process
 * 
 * \param  hSme - handle to the SME object
 * \return None
 * \sa     smeSm_Stop, sme_start 
 */ 
void smeSm_Start (TI_HANDLE hSme)
{
    TSme    *pSme = (TSme*)hSme;
//joetest
TRACE0(pSme->hReport, REPORT_SEVERITY_SM , "smeSm_Start!!!\n");
    /* set SCR group according to connection mode */
    if (CONNECT_MODE_AUTO == pSme->eConnectMode)
    {
        TRACE0(pSme->hReport, REPORT_SEVERITY_INFORMATION , "smeSm_Start: changing SCR group to DRV scan\n");
        scr_setGroup (pSme->hScr, SCR_GID_DRV_SCAN);
    }
    else
    {
        TRACE0(pSme->hReport, REPORT_SEVERITY_INFORMATION , "smeSm_Start: changing SCR group to APP scan\n");
        scr_setGroup (pSme->hScr, SCR_GID_APP_SCAN);
    }

    if ((TI_FALSE == pSme->bRadioOn) || (TI_FALSE == pSme->bRunning)) 
    {
        /* Radio is off so send stop event */
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_STOP, hSme);
    }
    else if (TI_TRUE == pSme->bConnectRequired)
    {
        /* if connection was required, start the process */
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT, hSme);
    }
}
Esempio n. 2
0
/** 
 * \fn     Function declaration 
 * \brief  Function brief description goes here 
 * 
 * Function detailed description goes here 
 * 
 * \note   Note is indicated here 
 * \param  Parameter name - parameter description
 * \param  … 
 * \return Return code is detailed here 
 * \sa     Reference to other relevant functions 
 */
void sme_ReportConnStatus (TI_HANDLE hSme, mgmtStatus_e eStatusType, TI_UINT32 uStatusCode)
{
    TSme                *pSme = (TSme*)hSme;

    TRACE2(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_ReportConnStatus: statusType = %d, uStatusCode = %d\n", eStatusType, uStatusCode);

    /* Act according to status */
    switch (eStatusType)
    {
    /* connection was successful */
    case STATUS_SUCCESSFUL:
        pSme->bAuthSent = TI_TRUE;
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_SUCCESS, hSme);
        break;

    case STATUS_ASSOC_REJECT:
    case STATUS_SECURITY_FAILURE:
    case STATUS_AP_DEAUTHENTICATE:
    case STATUS_AP_DISASSOCIATE:
    case STATUS_ROAMING_TRIGGER:
    case STATUS_AUTH_REJECT:
        /* Indicate the authentication and/or association was sent to the AP */
        pSme->bAuthSent = TI_TRUE;

        /* keep the disassociation status and code, for sending event to user-mode */
        pSme->tDisAssoc.eMgmtStatus = eStatusType;
        pSme->tDisAssoc.uStatusCode = uStatusCode;

        /* try to find the next connection candidate */
        pSme->pCandidate = sme_Select (hSme);
        /* if the next connection candidate exists */
        if (NULL != pSme->pCandidate)
        {
            sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT, hSme);
        }
        else
        {
            sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);
        }
        break;

        /* Note that in case of unspecified status we won't update the status. This is done since this function could be called twice */
        /* for example: apConn called this function and than SME called conn_stop and this function is called again                   */
        /* we use this status at SME, if != 0 means that assoc frame sent */
    case STATUS_UNSPECIFIED:
            pSme->bAuthSent = TI_TRUE;
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);
        break;

    default:
        TRACE1(pSme->hReport, REPORT_SEVERITY_ERROR , "sme_ReportConnStatus: unknown statusType = %d\n", eStatusType);
        break;
    }
}
Esempio n. 3
0
/** 
 * \fn     sme_ReportApConnStatus
 * \brief  Used by AP connection (and Soft-gemini) modules to report connection status
 * 
 * Used by AP connection (and Soft-gemini) modules to report connection status
 * 
 * \param  hSme - handle to the SME object
 * \param  eStatusType - connection status
 * \param  uStatus code - extended status information (if available)
 * \return None
 * \sa     sme_ReportConnStatus
 */
void sme_ReportApConnStatus (TI_HANDLE hSme, mgmtStatus_e eStatusType, TI_UINT32 uStatusCode)
{
    TSme                *pSme = (TSme*)hSme;

    TRACE2(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_ReportApConnStatus: statusType = %d, uStatusCode = %d\n", eStatusType, uStatusCode);

    /* Act according to status */
    switch (eStatusType)
    {

    /* SG re-select */
    case STATUS_SG_RESELECT:
        pSme->bReselect = TI_TRUE;
        pSme->bConnectRequired = TI_TRUE;
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);
        break;

    /* shouldn't happen (not from AP conn) */
    case STATUS_SUCCESSFUL:
        TRACE0(pSme->hReport, REPORT_SEVERITY_ERROR , "sme_ReportApConnStatus: received STATUS_SUCCESSFUL\n");
        break;

    case STATUS_UNSPECIFIED:
    case STATUS_AUTH_REJECT:
    case STATUS_ASSOC_REJECT:
    case STATUS_SECURITY_FAILURE:
    case STATUS_AP_DEAUTHENTICATE:
    case STATUS_AP_DISASSOCIATE:
    case STATUS_ROAMING_TRIGGER:
       
        /* keep the disassociation status and code, for sending event to user-mode */
        pSme->tDisAssoc.eMgmtStatus = eStatusType;
        pSme->tDisAssoc.uStatusCode = uStatusCode;
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);
        break;

    case STATUS_DISCONNECT_DURING_CONNECT:
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_DISCONNECT, hSme);
        break;

    default:
        TRACE1(pSme->hReport, REPORT_SEVERITY_ERROR , "sme_ReportApConnStatus: received unrecognized status: %d\n", eStatusType);

    }
}
Esempio n. 4
0
void smeSm_CheckStartConditions (TI_HANDLE hSme)
{
	TSme        *pSme = (TSme*)hSme;

	if ((TI_TRUE == pSme->bRunning) && (TI_TRUE == pSme->bRadioOn)) {
		/* send a start event */
		sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_START, hSme);
	}
}
Esempio n. 5
0
/**
 * \fn     smeSm_Start
 * \brief  Starts STA opeartion by moving SCR out of idle group and starting connection process
 *
 * Starts STA opeartion by moving SCR out of idle group and starting connection process
 *
 * \param  hSme - handle to the SME object
 * \return None
 * \sa     smeSm_Stop, sme_start
 */
void smeSm_Start (TI_HANDLE hSme)
{
	TSme    *pSme = (TSme*)hSme;

	/* set SCR group according to connection mode */
	if (CONNECT_MODE_AUTO == pSme->eConnectMode) {
		scr_setGroup (pSme->hScr, SCR_GID_DRV_SCAN);
	} else {
		scr_setGroup (pSme->hScr, SCR_GID_APP_SCAN);
	}

	if ((TI_FALSE == pSme->bRadioOn) || (TI_FALSE == pSme->bRunning)) {
		/* Radio is off so send stop event */
		sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_STOP, hSme);
	} else if (TI_TRUE == pSme->bConnectRequired) {
		/* if connection was required, start the process */
		sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT, hSme);
	}
}
Esempio n. 6
0
/** 
 * \fn     sme_Restart
 * \brief  Called due to a paramter value change in site mgr. Triggers a disconnect.
 * 
 * Called due to a paramter value change in site mgr. Triggers a disconnect.
 * 
 * \param  hSme - handle to the SME object
 * \param  eReason - the reason for restarting the SME
 * \return None
 */ 
void sme_Restart (TI_HANDLE hSme)
{
    TSme                *pSme = (TSme*)hSme;

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

    pSme->uScanCount = 0;

    sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_DISCONNECT, hSme);
}
Esempio n. 7
0
/** 
 * \fn     SME_ConnectRequired
 * \brief  start connection sequence by set the flag ConnectRequired and issue DISCONNECT event.
 *         called by CommandDispatcher in OSE OS.
 * 
 * \param  hSme - handle to the SME object
 * \return None
 * \sa     SME_Disconnect
 */
void SME_ConnectRequired (TI_HANDLE hSme)
{
    TSme *pSme = (TSme*)hSme;

    pSme->bRadioOn = TI_TRUE;
    pSme->uScanCount = 0;
    pSme->bConnectRequired = TI_TRUE;

    /* now send a disconnect event */
    sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_DISCONNECT, hSme);
}
Esempio n. 8
0
/** 
 * \fn     sme_Stop
 * \brief  Stops the driver (shuts-down the radio)
 * 
 * Stops the driver (shuts-down the radio)
 * 
 * \param  hSme - handle to the SME object
 * \param  pCBFunc - callback function to be called when stop operation is doen
 * \param  hCBHanlde - handle to supply to the callback function
 * \return None
 * \sa     sme_Start
 */ 
void sme_Stop (TI_HANDLE hSme)
{
    TSme                *pSme = (TSme*)hSme;

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

    pSme->bRunning = TI_FALSE;

    /* mark that running flag is send a stop event to the SM */
    sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_STOP, hSme);
}
Esempio n. 9
0
/** 
 * \fn     SME_Disconnect
 * \brief  perform disconnect by clear the flag ConnectRequired and issue DISCONNECT event.
 * 
 * \param  hSme - handle to the SME object
 * \return None
 * \sa     SME_ConnectRequired
 */
void SME_Disconnect (TI_HANDLE hSme)
{
    TSme *pSme = (TSme*)hSme;

    pSme->bConnectRequired = TI_FALSE;
    /* turn off WSC PB mode */
    pSme->bConstantScan = TI_FALSE;

    /* now send a disconnect event */
    sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_DISCONNECT, hSme);

}
Esempio n. 10
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;
//joetest
TRACE0(pSme->hReport, REPORT_SEVERITY_SM , "smeSm_Connect!!!\n");
    /* Sanity check - if no connection candidate was found so far */
    if (NULL == pSme->pCandidate)
    {
        TRACE0(pSme->hReport, REPORT_SEVERITY_ERROR , "smeSm_Connect: No candidate available, sending connect failure\n");
        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);
       if (TI_OK != tStatus)
       {
           TRACE1(pSme->hReport, REPORT_SEVERITY_ERROR , "smeSm_Connect: conn_start returned status %d\n", tStatus);
       }
    }
}
Esempio n. 11
0
/** 
 * \fn     sme_Start
 * \brief  Starts SME operation
 * 
 * Starts SME operation. Send probe request templates and send a start event to the SM.
 * Only the DrvMain module could & is call that function !!!
 * 
 * \param  hSme - handle to the SME object
 * \return None
 * \sa     sme_Stop
 */ 
void sme_Start (TI_HANDLE hSme)
{
    TSme                *pSme = (TSme*)hSme;

    TRACE1(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Start: called, bRadioOn = %d\n", pSme->bRadioOn);

    pSme->bRunning = TI_TRUE;

    /* 
     * call setDefaultProbeReqTemplate at sme_Start() due to the fact in order to set prob req template 
     * all moudules need to be set already 
     */
    setDefaultProbeReqTemplate (pSme->hSiteMgr);

    /* if radio is on, start the SM */
    if (TI_TRUE == pSme->bRadioOn)
    {
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_START, hSme);
    }
}
Esempio n. 12
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);
			}
		}
	}
}
Esempio n. 13
0
/** 
 * \fn     sme_ScanResultCB
 * \brief  Callback function from scan concentrator for results and scan complete indications
 * 
 * Callback function from scan concentrator for results and scan complete indications
 * 
 * \param  hSme - handle to the SME object
 * \param  eStatus - the reason for calling the CB  
 * \param  pFrameInfo - frame information (if the CB is called due to received frame)
 * \param  uSPSStatus - SPS attened channels (if the CB is called to inidcate an SPS scan complete)
 * \return None
 */ 
void sme_ScanResultCB (TI_HANDLE hSme, EScanCncnResultStatus eStatus,
                       TScanFrameInfo* pFrameInfo, TI_UINT16 uSPSStatus)
{
    TSme                *pSme = (TSme*)hSme;
    paramInfo_t	        param;

    switch (eStatus)
    {
    /* a frame was received - update the scan result table */
    case SCAN_CRS_RECEIVED_FRAME:

        TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_ScanResultCB: received frame from BSSID %02x:%02x:%02x:%02x:%02x:%02x\n", (*pFrameInfo->bssId)[ 0 ], (*pFrameInfo->bssId)[ 1 ], (*pFrameInfo->bssId)[ 2 ], (*pFrameInfo->bssId)[ 3 ], (*pFrameInfo->bssId)[ 4 ], (*pFrameInfo->bssId)[ 5 ]);

        /* 
         * in auto mode in order to find country IE only !!!
         * filter frames according to desired SSID, in case we are also trying to find 
         * country IE in passive scan, to avoid a table overflow (in manual mode, the SME table must be equal to the app
         * table, the app is responsible to decide which SSIDs to use for scan)
         */
        if (CONNECT_MODE_AUTO == pSme->eConnectMode)
        {
            if (SSID_TYPE_SPECIFIC == pSme->eSsidType)
            {
#ifndef XCC_MODULE_INCLUDED
                if ((pSme->tSsid.len == pFrameInfo->parsedIEs->content.iePacket.pSsid->hdr[ 1 ]) &&
                    (0 == os_memoryCompare (pSme->hOS, (TI_UINT8 *)&(pSme->tSsid.str[ 0 ]),
                                            (TI_UINT8 *)&(pFrameInfo->parsedIEs->content.iePacket.pSsid->serviceSetId[ 0 ]),
                                            pSme->tSsid.len)))
#endif
                {

                    if (TI_OK != scanResultTable_UpdateEntry (pSme->hScanResultTable, pFrameInfo->bssId, pFrameInfo))
                    {
                        TRACE6(pSme->hReport, REPORT_SEVERITY_ERROR , "sme_ScanResultCB: unable to update specific enrty for BSSID %02x:%02x:%02x:%02x:%02x:%02x\n", (*pFrameInfo->bssId)[ 0 ], (*pFrameInfo->bssId)[ 1 ], (*pFrameInfo->bssId)[ 2 ], (*pFrameInfo->bssId)[ 3 ], (*pFrameInfo->bssId)[ 4 ], (*pFrameInfo->bssId)[ 5 ]);
                    }
                }
            }
            else
            {

                if (TI_OK != scanResultTable_UpdateEntry (pSme->hScanResultTable, pFrameInfo->bssId, pFrameInfo))
                {
                    TRACE6(pSme->hReport, REPORT_SEVERITY_ERROR , "sme_ScanResultCB: unable to update enrty for BSSID %02x:%02x:%02x:%02x:%02x:%02x because table is full\n", (*pFrameInfo->bssId)[ 0 ], (*pFrameInfo->bssId)[ 1 ], (*pFrameInfo->bssId)[ 2 ], (*pFrameInfo->bssId)[ 3 ], (*pFrameInfo->bssId)[ 4 ], (*pFrameInfo->bssId)[ 5 ]);
                }
            }
        }
        else
        /* manual mode */
        {
            if (TI_OK != scanResultTable_UpdateEntry (pSme->hSmeScanResultTable, pFrameInfo->bssId, pFrameInfo))
            {
                TRACE6(pSme->hReport, REPORT_SEVERITY_ERROR , "sme_ScanResultCB: unable to update application scan enrty for BSSID %02x:%02x:%02x:%02x:%02x:%02x\n", (*pFrameInfo->bssId)[ 0 ], (*pFrameInfo->bssId)[ 1 ], (*pFrameInfo->bssId)[ 2 ], (*pFrameInfo->bssId)[ 3 ], (*pFrameInfo->bssId)[ 4 ], (*pFrameInfo->bssId)[ 5 ]);
            }
        }
        break;

    /* scan was completed successfully */
    case SCAN_CRS_SCAN_COMPLETE_OK:
    /* an error occured, try selecting a site anyway */
    case SCAN_CRS_SCAN_ABORTED_FW_RESET:
    case SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY:
    case SCAN_CRS_SCAN_FAILED:
    case SCAN_CRS_TSF_ERROR:
        TRACE1(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_ScanResultCB: received scan complete indication with status %d\n", eStatus);

        /* stablizie the scan result table - delete its contenst if no results were recived during last scan */
        scanResultTable_SetStableState (pSme->hScanResultTable);

        if (CONNECT_MODE_AUTO == pSme->eConnectMode)
        {
 
           /* try to select a site */
           pSme->pCandidate = sme_Select (hSme);

           /* if no matching site was found */
           if (NULL == pSme->pCandidate)
           {
               /* for IBSS or any, if no entries where found, add the self site */
               if (pSme->eBssType == BSS_INFRASTRUCTURE)
               {
                   TRACE0(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_ScanResultCB: No candidate available, sending connect failure\n");

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

               {
                   TI_UINT8     uDesiredChannel;

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

                   if (uDesiredChannel >= SITE_MGR_CHANNEL_A_MIN)
                   {
                       param.content.channelCapabilityReq.band = RADIO_BAND_5_0_GHZ;
                   } 
                   else 
                   {
                       param.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 */
                   param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
                   param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
                   param.content.channelCapabilityReq.channelNum = uDesiredChannel;

                   regulatoryDomain_getParam (pSme->hRegDomain,&param);
                   if (!param.content.channelCapabilityRet.channelValidity)
                   {
                       TRACE0(pSme->hReport, REPORT_SEVERITY_INFORMATION , "IBSS SELECT FAILURE  - No channel !!!\n\n");

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

                       break;
                   }

                   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);

                       break;
                   }

#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);
        }
        break;        

    /*
     * scan was stopped according to SME request (should happen when moving to disconnecting from scanning), send a 
     * connect failure event to move out of disconnecting
     */
    case SCAN_CRS_SCAN_STOPPED:
        TRACE0(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_ScanResultCB: received scan stopped indication\n");
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_CONNECT_FAILURE, hSme);
        break;

    default:
        TRACE1(pSme->hReport, REPORT_SEVERITY_ERROR , "sme_ScanResultCB: received unrecognized status %d\n", eStatus);
        break;
    }
}
Esempio n. 14
0
/** 
 * \fn     sme_SetParam
 * \brief  Set parameters values
 * 
 * Set parameters values
 * 
 * \note   Note is indicated here 
 * \param  hSme - handle to the SME object
 * \param  pParam - pointer to the param to set
 * \return PARAM_NOT_SUPPORTED for an unrecognized parameter, TI_OK if successfull.
 * \sa     sme_GetParam
 */ 
TI_STATUS sme_SetParam (TI_HANDLE hSme, paramInfo_t *pParam)
{
    TSme                *pSme = (TSme*)hSme;

    TRACE1(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_SetParam: param type is 0x%x\n", pParam->paramType);

    switch (pParam->paramType)
    {
    case SME_RADIO_ON_PARAM:
        /* if new value is different than current one */
        if (pSme->bRadioOn != pParam->content.smeRadioOn)
        {
            /* set new radio on value and send an event to the state-machine accordingly */
            pSme->bRadioOn = pParam->content.smeRadioOn;
            if (TI_TRUE == pSme->bRadioOn)
            {
                if(TI_TRUE == pSme->bRunning)
                {
                    sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_START, hSme);
                }
            }
            else
            {
                sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_STOP, hSme);
            }
        }
        break;

    case SME_DESIRED_SSID_PARAM:

        if (pParam->content.smeDesiredSSID.len > MAX_SSID_LEN)
        {
            return PARAM_VALUE_NOT_VALID;   /* SSID length is out of range */
        }

        /* if new value is different than current one */
        if ((pSme->tSsid.len != pParam->content.smeDesiredSSID.len) || 
            (0 != os_memoryCompare (pSme->hOS, (TI_UINT8 *)&(pSme->tSsid.str[ 0 ]),
                                    (TI_UINT8 *)&(pParam->content.smeDesiredSSID.str[ 0 ]), pSme->tSsid.len)))
        {
            /* set new desired SSID */
            os_memoryCopy (pSme->hOS, &(pSme->tSsid.str[ 0 ]), &(pParam->content.smeDesiredSSID.str[ 0 ]), pParam->content.smeDesiredSSID.len);
            pSme->tSsid.len = pParam->content.smeDesiredSSID.len;

            pSme->uScanCount = 0;

            /* now send a disconnect event */
            sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_DISCONNECT, hSme);
        }
        break;

    case SME_DESIRED_SSID_ACT_PARAM:

        if (pParam->content.smeDesiredSSID.len > MAX_SSID_LEN)
        {
            return PARAM_VALUE_NOT_VALID;   /* SSID length is out of range */
        }

        pSme->bRadioOn = TI_TRUE;

        /* if new value is different than current one */
        if ((pSme->tSsid.len != pParam->content.smeDesiredSSID.len) || 
            (0 != os_memoryCompare (pSme->hOS, (TI_UINT8 *)&(pSme->tSsid.str[ 0 ]),
                                    (TI_UINT8 *)&(pParam->content.smeDesiredSSID.str[ 0 ]), pSme->tSsid.len)))
        {
            /* set new desired SSID */
            os_memoryCopy (pSme->hOS, &(pSme->tSsid.str[ 0 ]), &(pParam->content.smeDesiredSSID.str[ 0 ]), pParam->content.smeDesiredSSID.len);
            pSme->tSsid.len = pParam->content.smeDesiredSSID.len;
        }
        /* also set SSID type and connect required flag */
        if (OS_802_11_SSID_JUNK (pSme->tSsid.str, pSme->tSsid.len))
        {
            pSme->eSsidType = SSID_TYPE_INVALID;
            pSme->bConnectRequired = TI_FALSE;
        }
        else if (0 == pSme->tSsid.len)
        {
            pSme->eSsidType = SSID_TYPE_ANY;
            pSme->bConnectRequired = TI_TRUE;
        }
        else
        {
            pSme->eSsidType = SSID_TYPE_SPECIFIC;
            pSme->bConnectRequired = TI_TRUE;
        }
        pSme->uScanCount = 0;

        /* if  junk SSID */
        if(TI_FALSE == pSme->bConnectRequired)
        {
            pSme->bConstantScan = TI_FALSE;
        }

        /* now send a disconnect event */
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_DISCONNECT, hSme);
        break;

    case SME_DESIRED_BSSID_PARAM:
        /* if new value is different than current one */
        if (TI_FALSE == MAC_EQUAL (pSme->tBssid, pParam->content.smeDesiredBSSID))
        {
            /* set new BSSID */
            MAC_COPY (pSme->tBssid, pParam->content.smeDesiredBSSID);
            pSme->uScanCount = 0;
            /* now send a disconnect event */
            sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_DISCONNECT, hSme);
  
        }
        break;

    case SME_CONNECTION_MODE_PARAM:
        /* if new value is different than current one */
        if (pSme->eConnectMode != pParam->content.smeConnectionMode)
        {
            /* set new connection mode */
            pSme->eConnectMode = pParam->content.smeConnectionMode;
            pSme->uScanCount = 0;
            if (CONNECT_MODE_AUTO == pSme->eConnectMode)
            {
                pSme->hScanResultTable = pSme->hSmeScanResultTable;
            }
            else if (CONNECT_MODE_MANUAL == pSme->eConnectMode) 
            {
                pSme->hScanResultTable = pSme->hScanCncnScanResulTable;
            }
        /* now send a disconnect event */
        sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_DISCONNECT, hSme);
        }
        break;

    case SME_DESIRED_BSS_TYPE_PARAM:
        /* if new value is different than current one */
        if (pSme->eBssType != pParam->content.smeDesiredBSSType)
        {
            /* set new BSS type */
            pSme->eBssType = pParam->content.smeDesiredBSSType;
            pSme->uScanCount = 0;
            /* now send a disconnect event */
            sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_DISCONNECT, hSme);
        }
        break;

    case SME_WSC_PB_MODE_PARAM:

        if (pParam->content.siteMgrWSCMode.WSCMode != TIWLN_SIMPLE_CONFIG_OFF)
        {
         pSme->bConstantScan = TI_TRUE;
         pSme->uScanCount = 0;
         /* now send a disconnect event */
         sme_SmEvent (pSme->hSmeSm, SME_SM_EVENT_DISCONNECT, hSme);
        }
        else
        {
         pSme->bConstantScan = TI_FALSE;
        }
        break;

    default:
        TRACE1(pSme->hReport, REPORT_SEVERITY_ERROR , "sme_SetParam: unrecognized param type %d\n", pParam->paramType);
        return PARAM_NOT_SUPPORTED;
        /* break;*/
    }

    return TI_OK;
}
Esempio n. 15
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);
			}
        }
    }
}