TI_STATUS sharedKey_Timeout(auth_t *pAuth)
{
	if (pAuth->retryCount >= pAuth->maxCount) {
		pAuth->authData.status = STATUS_PACKET_REJ_TIMEOUT;
		return auth_skSMEvent(&pAuth->currentState, SHARED_KEY_AUTH_SM_EVENT_MAX_RETRY, pAuth);
	}

	return auth_skSMEvent(&pAuth->currentState, SHARED_KEY_AUTH_SM_EVENT_TIMEOUT, pAuth);
}
Ejemplo n.º 2
0
/**
*
* auth_stop - Stop event for the authentication SM
*
* \b Description: 
*
* Stop event for the authentication SM
*
* \b ARGS:
*
*  I   - hAuth - Authentication SM context  \n
*
* \b RETURNS:
*
*  TI_OK if successful, TI_NOK otherwise.
*
* \sa auth_Start, auth_Recv
*/
TI_STATUS auth_stop(TI_HANDLE hAuth, TI_BOOL sendDeAuth, mgmtStatus_e reason )
{
	auth_t		*pHandle;

	pHandle = (auth_t*)hAuth;

	if (pHandle == NULL)
		return TI_NOK;
	
	if (pHandle->authType == AUTH_LEGACY_NONE)
		return TI_NOK;

	if( sendDeAuth == TI_TRUE )
	{
		deAuth_t	deAuth;
		deAuth.reason = ENDIAN_HANDLE_WORD(reason);
		mlmeBuilder_sendFrame(pHandle->hMlme, DE_AUTH, (TI_UINT8*)&deAuth, sizeof(deAuth_t), 0);
	}

	switch (pHandle->authType)
	{
    case AUTH_LEGACY_RESERVED1:
	case AUTH_LEGACY_OPEN_SYSTEM:
		return auth_osSMEvent(&pHandle->currentState, OPEN_AUTH_SM_EVENT_STOP, pHandle);

	case AUTH_LEGACY_SHARED_KEY:
		return auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_STOP, pHandle);

	default:
		return TI_NOK;
	}
}
Ejemplo n.º 3
0
/**
*
* auth_start - Start event for the authentication SM
*
* \b Description: 
*
* Start event for the authentication SM
*
* \b ARGS:
*
*  I   - hAuth - Authentication SM context  \n
*
* \b RETURNS:
*
*  TI_OK if successful, TI_NOK otherwise.
*
* \sa auth_Stop, auth_Recv
*/
TI_STATUS auth_start(TI_HANDLE hAuth)
{
	auth_t		*pHandle = (auth_t*)hAuth;

	if (pHandle == NULL)
    {
		return TI_NOK;
    }

	if (pHandle->authType == AUTH_LEGACY_NONE)
    {
        TRACE0(pHandle->hReport, REPORT_SEVERITY_ERROR, "auth_start: pHandle->authType == AUTH_LEGACY_NONE\n");
		return TI_NOK;
    }

	switch (pHandle->authType)
	{
    case AUTH_LEGACY_RESERVED1: 
	case AUTH_LEGACY_OPEN_SYSTEM:
		return auth_osSMEvent(&pHandle->currentState, OPEN_AUTH_SM_EVENT_START, pHandle);

	case AUTH_LEGACY_SHARED_KEY:
		return auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_START, pHandle);

	default:
        TRACE0(pHandle->hReport, REPORT_SEVERITY_ERROR, "auth_start: pHandle->authType unknown.\n");
		return TI_NOK;
	}
}
Ejemplo n.º 4
0
/**
*
* auth_start - Start event for the authentication SM
*
* \b Description:
*
* Start event for the authentication SM
*
* \b ARGS:
*
*  I   - hAuth - Authentication SM context  \n
*
* \b RETURNS:
*
*  TI_OK if successful, TI_NOK otherwise.
*
* \sa auth_Stop, auth_Recv
*/
TI_STATUS auth_start(TI_HANDLE hAuth)
{
	auth_t		*pHandle = (auth_t*)hAuth;

	if (pHandle == NULL) {
		return TI_NOK;
	}

	if (pHandle->authType == AUTH_LEGACY_NONE) {
		return TI_NOK;
	}

	switch (pHandle->authType) {
	case AUTH_LEGACY_RESERVED1:
	case AUTH_LEGACY_OPEN_SYSTEM:
		return auth_osSMEvent(&pHandle->currentState, OPEN_AUTH_SM_EVENT_START, pHandle);

	case AUTH_LEGACY_SHARED_KEY:
		return auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_START, pHandle);

	default:
		return TI_NOK;
	}
}
/**
*
* sharedKeyAuth_Recv - Recive a message from the AP
*
* \b Description: 
*
* Parse a message form the AP and perform the appropriate event.
*
* \b ARGS:
*
*  I   - hAuth - Association SM context  \n
*
* \b RETURNS:
*
*  TI_OK if successful, TI_NOK otherwise.
*
* \sa sharedKeyAuth_Start, sharedKeyAuth_Stop
*/
TI_STATUS sharedKeyAuth_Recv(TI_HANDLE hAuth, mlmeFrameInfo_t *pFrame)
{
	TI_STATUS 			status = TI_NOK;
	auth_t			*pHandle;
	TI_UINT16			authAlgo;
	TI_UINT16			rspSeq;

	pHandle = (auth_t*)hAuth;

	if (pHandle == NULL)
	{
		return TI_NOK;
	}
	
	/* check response status */
	authAlgo = ENDIAN_HANDLE_WORD(pFrame->content.auth.authAlgo);
	if (authAlgo != AUTH_LEGACY_SHARED_KEY)
	{
TRACE0(pHandle->hReport, REPORT_SEVERITY_SM, "SHARED_KEY_AUTH_SM: DEBUG recieved authentication message with wrong algorithm \n");
		return TI_NOK;
	}
    
	/* check response status */
	rspSeq  = pFrame->content.auth.seqNum;
	
    pHandle->authData.status = pFrame->content.auth.status;
    pHandle->authData.pChalange = (char *)(pFrame->content.auth.pChallenge->text);
    pHandle->authData.challangeLen = pFrame->content.auth.pChallenge->hdr[1];

	if (pHandle->authData.status == STATUS_SUCCESSFUL)
	{
		switch (rspSeq)
		{
		case 2:
TRACE0(pHandle->hReport, REPORT_SEVERITY_SM, "SHARED_KEY_AUTH_SM: DEBUG Success authenticating to AP stage 1\n");

			if (pFrame->content.auth.pChallenge->hdr[0] != CHALLANGE_TEXT_IE_ID)
			{
TRACE0(pHandle->hReport, REPORT_SEVERITY_ERROR, "SHARED_KEY_AUTH_SM: Wrong element ID for challange \n");
				status = TI_NOK;
				break;
			}

			status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_SUCCESS_1, hAuth);
			break;

		case 4:
TRACE0(pHandle->hReport, REPORT_SEVERITY_SM, "SHARED_KEY_AUTH_SM: DEBUG Success authenticating to AP stage 2\n");
			
			status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_SUCCESS_2, hAuth);
			break;

		default:
TRACE0(pHandle->hReport, REPORT_SEVERITY_ERROR, "SHARED_KEY_AUTH_SM: Wrong sequence number \n");
			status = TI_NOK;
			break;
		}
	} 
	
	else 
	{
		switch (rspSeq)
		{
		case 2:
			status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_FAIL_1, hAuth);
			break;

		case 4:
			status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_FAIL_2, hAuth);
			break;
	
		default:
			status = TI_NOK;
			break;
		}
	}

	return status;
}
Ejemplo n.º 6
0
/**
*
* sharedKeyAuth_Recv - Recive a message from the AP
*
* \b Description: 
*
* Parse a message form the AP and perform the appropriate event.
*
* \b ARGS:
*
*  I   - hAuth - Association SM context  \n
*
* \b RETURNS:
*
*  TI_OK if successful, TI_NOK otherwise.
*
* \sa sharedKeyAuth_Start, sharedKeyAuth_Stop
*/
TI_STATUS sharedKeyAuth_Recv(TI_HANDLE hAuth, mlmeFrameInfo_t *pFrame)
{
	TI_STATUS 			status = TI_NOK;
	auth_t			*pHandle;
	TI_UINT16			authAlgo;
	TI_UINT16			rspSeq;

	pHandle = (auth_t*)hAuth;

	if (pHandle == NULL)
	{
		return TI_NOK;
	}
	
	/* check response status */
	authAlgo = ENDIAN_HANDLE_WORD(pFrame->content.auth.authAlgo);
	if (authAlgo != AUTH_LEGACY_SHARED_KEY)
	{
		return TI_NOK;
	}
    
	/* check response status */
	rspSeq  = pFrame->content.auth.seqNum;
	
    pHandle->authData.status = pFrame->content.auth.status;
    pHandle->authData.pChalange = (char *)(pFrame->content.auth.pChallenge->text);
    pHandle->authData.challangeLen = pFrame->content.auth.pChallenge->hdr[1];

	if (pHandle->authData.status == STATUS_SUCCESSFUL)
	{
		switch (rspSeq)
		{
		case 2:

			if (pFrame->content.auth.pChallenge->hdr[0] != CHALLANGE_TEXT_IE_ID)
			{
				status = TI_NOK;
				break;
			}

			status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_SUCCESS_1, hAuth);
			break;

		case 4:
			
			status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_SUCCESS_2, hAuth);
			break;

		default:
			status = TI_NOK;
			break;
		}
	} 
	
	else 
	{
		switch (rspSeq)
		{
		case 2:
			status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_FAIL_1, hAuth);
			break;

		case 4:
			status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_FAIL_2, hAuth);
			break;
	
		default:
			status = TI_NOK;
			break;
		}
	}

	return status;
}