Beispiel #1
0
/**
*
* mainKeys_config
*
* \b Description:
*
* Init main security state machine state machine
*
* \b ARGS:
*
*  none
*
* \b RETURNS:
*
*  TI_OK on success, TI_NOK otherwise.
*
* \sa
*/
TI_STATUS mainKeys_config (mainKeys_t    *pMainKeys,
                           TRsnPaeConfig *pPaeConfig,
                           void          *pParent,
                           TI_HANDLE      hReport,
                           TI_HANDLE      hOs,
                           TI_HANDLE      hCtrlData,
                           TI_HANDLE      hEvHandler,
                           TI_HANDLE      hConn,
                           TI_HANDLE      hRsn,
                           TI_HANDLE      hTimer)

{
    TI_STATUS      status;

	/** Main key State Machine matrix */
	fsm_actionCell_t    mainKeysSM_matrix[MAIN_KEYS_NUM_STATES][MAIN_KEYS_NUM_EVENTS] =
	{
		/* next state and actions for IDLE state */
		{	{MAIN_KEYS_STATE_START, (fsm_Action_t)mainKeys_startIdle},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmUnexpected}
		},

		/* next state and actions for START state */
		{	{MAIN_KEYS_STATE_START, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopStart},
			{MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_START, (fsm_Action_t)mainKeys_smTimeOut}
		},

		/* next state and actions for UNICAST COMPLETE state */
		{	{MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopUcastComplete},
			{MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeys_bcastCompleteUcastComplete},
			{MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeys_smTimeOut}
		},

		/* next state and actions for BROADCAST COMPLETE state */
		{	{MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopBcastComplete},
			{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeys_ucastCompleteBcastComplete},
			{MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeys_smTimeOut}
		},

		/* next state and actions for COMPLETE state */
		{	{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopComplete},
			{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmUnexpected}
		}
	};

	pMainKeys->hCtrlData = hCtrlData;
	pMainKeys->hOs = hOs;
	pMainKeys->hReport = hReport;
    pMainKeys->hEvHandler = hEvHandler;
    pMainKeys->hConn = hConn;
    pMainKeys->hRsn = hRsn;
    pMainKeys->hTimer = hTimer;

    pMainKeys->pParent = pParent;
	pMainKeys->keysTimeout = MAIN_KEYS_TIMEOUT;

	pMainKeys->start = mainKeys_start;
	pMainKeys->stop = mainKeys_stop;
	pMainKeys->reportUcastStatus = mainKeys_reportUcastStatus;
	pMainKeys->reportBcastStatus = mainKeys_reportBcastStatus;
	pMainKeys->setKey = mainKeys_setKey;
	pMainKeys->removeKey = mainKeys_removeKey;
	pMainKeys->setDefaultKeyId = mainKeys_setDefaultKeyId;
	pMainKeys->getSessionKey = mainKeys_getSessionKey;

	pMainKeys->currentState = MAIN_KEYS_STATE_IDLE;

	/* allocate OS timer memory */
    if (pMainKeys->hSessionTimer == NULL)
    {
        pMainKeys->hSessionTimer = tmr_CreateTimer (pMainKeys->hTimer);
        if (pMainKeys->hSessionTimer == NULL)
        {
            return TI_NOK;
        }
	}

    status = fsm_Config(pMainKeys->pMainKeysSm, &mainKeysSM_matrix[0][0],
						MAIN_KEYS_NUM_STATES, MAIN_KEYS_NUM_EVENTS, NULL, pMainKeys->hOs);
	if (status != TI_OK)
	{
		return status;
	}

	status = keyParser_config(pMainKeys->pKeyParser,
                              pPaeConfig,
                              pMainKeys->pUcastSm,
                              pMainKeys->pBcastSm,
                              pMainKeys,
                              hReport,
                              hOs,
                              hCtrlData);
	if (status != TI_OK)
	{
		return status;
	}

	status = broadcastKey_config(pMainKeys->pBcastSm, pPaeConfig, pMainKeys, hReport, hOs);
	if (status != TI_OK)
	{
		return status;
	}

	status = unicastKey_config(pMainKeys->pUcastSm, pPaeConfig, pMainKeys, hReport, hOs);
	if (status != TI_OK)
	{
		return status;
	}

	return TI_OK;
}
/**
*
* mainKeys_config
*
* \b Description: 
*
* Init main security state machine state machine
*
* \b ARGS:
*
*  none
*
* \b RETURNS:
*
*  OK on success, NOK otherwise.
*
* \sa 
*/
TI_STATUS mainKeys_config(mainKeys_t *pMainKeys, 
                      rsn_paeConfig_t *pPaeConfig, 
                      void *pParent,
					  TI_HANDLE		hReport,
					  TI_HANDLE		hOs,
                      TI_HANDLE     hCtrlData,
                      TI_HANDLE     hEvHandler,
                      TI_HANDLE     hConn,
                      TI_HANDLE     hRsn )

{
    TI_STATUS      status;

	/** Main key State Machine matrix */
	fsm_actionCell_t    mainKeysSM_matrix[MAIN_KEYS_NUM_STATES][MAIN_KEYS_NUM_EVENTS] =
	{
		/* next state and actions for IDLE state */
		{	{MAIN_KEYS_STATE_START, (fsm_Action_t)mainKeys_startIdle}, 
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmUnexpected}
		},

		/* next state and actions for START state */
		{	{MAIN_KEYS_STATE_START, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopStart}, 
			{MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_START, (fsm_Action_t)mainKeys_smTimeOut}
		},

		/* next state and actions for UNICAST COMPLETE state */
		{	{MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopUcastComplete}, 
			{MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeys_bcastCompleteUcastComplete},
			{MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeys_smTimeOut}
		},

		/* next state and actions for BROADCAST COMPLETE state */
		{	{MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopBcastComplete},
			{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeys_ucastCompleteBcastComplete},
			{MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeys_smTimeOut}
		},

		/* next state and actions for COMPLETE state */
		{	{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmUnexpected},
			{MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopComplete},
			{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmNop},
			{MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmUnexpected}
		}
	};

	pMainKeys->hCtrlData = hCtrlData;
	pMainKeys->hOs = hOs;
	pMainKeys->hReport = hReport;
    pMainKeys->hEvHandler = hEvHandler;
    pMainKeys->hConn = hConn;
    pMainKeys->hRsn = hRsn;

    pMainKeys->pParent = pParent;
	pMainKeys->keysTimeout = MAIN_KEYS_TIMEOUT;

	pMainKeys->start = mainKeys_start;
	pMainKeys->stop = mainKeys_stop;
	pMainKeys->reportUcastStatus = mainKeys_reportUcastStatus;
	pMainKeys->reportBcastStatus = mainKeys_reportBcastStatus;
	pMainKeys->setKey = mainKeys_setKey;
	pMainKeys->removeKey = mainKeys_removeKey;
	pMainKeys->setDefaultKeyId = mainKeys_setDefaultKeyId;
	pMainKeys->getSessionKey = mainKeys_getSessionKey;

	pMainKeys->currentState = MAIN_KEYS_STATE_IDLE;

    status = fsm_Config(pMainKeys->pMainKeysSm, &mainKeysSM_matrix[0][0], 
						MAIN_KEYS_NUM_STATES, MAIN_KEYS_NUM_EVENTS, NULL, pMainKeys->hOs);
	if (status != OK)
	{
		WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
							("MAIN_KEYS_SM: Error in configuring SM\n"));
		return status;
	}

	status = keyParser_config(pMainKeys->pKeyParser, 
                              pPaeConfig, 
                              pMainKeys->pUcastSm, 
                              pMainKeys->pBcastSm, 
                              pMainKeys, 
                              hReport, 
                              hOs,
                              hCtrlData);
	if (status != OK)
	{
		WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
							("MAIN_KEYS_SM: Error in configuring key parser\n"));
		return status;
	}

	status = broadcastKey_config(pMainKeys->pBcastSm, pPaeConfig, pMainKeys, hReport, hOs);
	if (status != OK)
	{
		WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
							("MAIN_KEYS_SM: Error in configuring broadcast key SM\n"));
		return status;
	}
    
	status = unicastKey_config(pMainKeys->pUcastSm, pPaeConfig, pMainKeys, hReport, hOs);
	if (status != OK)
	{
		WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
							("MAIN_KEYS_SM: Error in configuring unicast key SM\n"));
		return status;
	}
	
	return OK;
}