Ejemplo n.º 1
0
//
// Description:
//	Determine the packet type of the action frame.
// Argument:
//	[in] posMpdu -
//		The full 802.11 packet.
// Return:
//	If this packet is determined successfully, return the ACT_PKT_xxx.
//	If this function cannot recognize this packet, return ACT_PKT_TYPE_UNKNOWN.
// Remark:
//	It checks the category, action field (if there is such one) and OUI information to determine the type.
//	Do not input non-action frame to this function and it doesn't check if this packet is action frame.
// By Bruce, 2012-03-09.	
//
ACT_PKT_TYPE
PacketGetActionFrameType(
	IN	POCTET_STRING	posMpdu
	)
{
	u4Byte	idx = 0;

	if(posMpdu->Length <= sMacHdrLng)
	{
		RT_TRACE_F(COMP_DBG, DBG_WARNING, ("[WARNING] Invalid length (%d) for this packet!\n", posMpdu->Length));
		return ACT_PKT_TYPE_UNKNOWN;
	}

	//Retrieve the table and check the patterns
	for(idx = 0; ACT_PKT_TYPE_UNKNOWN != (ACT_PKT_TYPE)(PktActPatternsMap[idx].PktType); idx ++)
	{
		// Packet length mismatch
		if((posMpdu->Length - sMacHdrLng) < PktActPatternsMap[idx].PatternLen)
			continue;

		// Compare pattern
		if(0 == PlatformCompareMemory(Frame_FrameBody(*posMpdu), PktActPatternsMap[idx].Pattern, PktActPatternsMap[idx].PatternLen))
		{
			return (ACT_PKT_TYPE)(PktActPatternsMap[idx].PktType);
		}		
	}
	return ACT_PKT_TYPE_UNKNOWN;
}
Ejemplo n.º 2
0
BOOLEAN
p2p_Channel_Add(
	IN  P2P_CHANNELS			*channels,
	IN  u1Byte					regClass,
	IN  u1Byte					nChannels,
	IN  const u1Byte			*channelList
	)
{
	u1Byte						itRegClass = 0;
	u1Byte						itChannel = 0;
	BOOLEAN						bAdded = FALSE;

	if(P2P_MAX_REG_CLASS_CHANNELS < nChannels)
	{
		RT_TRACE_F(COMP_P2P, DBG_WARNING, ("too many channels: %u\n", nChannels));
		return FALSE;
	}

	for(itRegClass = 0; itRegClass < channels->regClasses; itRegClass++)
	{
		P2P_REG_CLASS			*pRegCls = &channels->regClass[itRegClass];
		
		if(regClass != pRegCls->regClass)
			continue;

		// Override all the orignal channels
		p2p_channel_AddRegClass(pRegCls, regClass, nChannels, channelList);
		bAdded = TRUE;
		break;
	}

	if(!bAdded)
	{
		if(P2P_MAX_REG_CLASSES <= channels->regClasses)
		{
			RT_TRACE_F(COMP_P2P, DBG_WARNING, ("no more reg class could be added\n"));
			return FALSE;
		}

		p2p_channel_AddRegClass(&channels->regClass[channels->regClasses++], regClass, nChannels, channelList);
		bAdded = TRUE;
	}

	return bAdded;
}
Ejemplo n.º 3
0
VOID
p2p_channel_Dump(
	IN  const P2P_CHANNELS		*channels
	)
{
	u1Byte						itRegCls = 0;
	u1Byte						itChnl = 0;
	
	RT_TRACE_F(COMP_P2P, DBG_LOUD, ("# reg class: %u\n", channels->regClasses));

	for(itRegCls = 0; itRegCls < channels->regClasses; itRegCls++)
	{
		RT_TRACE_F(COMP_P2P, DBG_LOUD, ("reg: %u, ", channels->regClass[itRegCls].regClass));
		for(itChnl = 0; itChnl < channels->regClass[itRegCls].channels; itChnl++)
			RT_TRACE(COMP_P2P, DBG_LOUD, ("%u ", channels->regClass[itRegCls].channel[itChnl]));
		RT_TRACE(COMP_P2P, DBG_LOUD, ("\n"));
	}
}
Ejemplo n.º 4
0
VOID
p2p_Channel_Intersect(
	IN  const P2P_CHANNELS		*a,
	IN  const P2P_CHANNELS		*b,
	OUT P2P_CHANNELS			*res
	)
{
	u1Byte						itRegClsA = 0;
	u1Byte						itRegClsB = 0;
	
	p2p_Channel_Reset(res);
	
	if(!a->regClasses || !b->regClasses)
		return;

	for(itRegClsA = 0; itRegClsA < a->regClasses; itRegClsA++)
	{
		// Match reg class
		for(itRegClsB = 0; itRegClsB < b->regClasses; itRegClsB++)
			if(a->regClass[itRegClsA].regClass == b->regClass[itRegClsB].regClass)
				break;

		// The class can't be found in b
		if(itRegClsB == b->regClasses)
			continue;

		p2p_channel_IntersectRegClass(&a->regClass[itRegClsA], &b->regClass[itRegClsB], &res->regClass[res->regClasses]);
		if(res->regClass[res->regClasses].channels)
		{
			res->regClasses++;
			if(P2P_MAX_REG_CLASSES == res->regClasses)
				return;
		}
	}

	RT_TRACE_F(COMP_P2P, DBG_LOUD, ("a:\n"));
	p2p_channel_Dump(a);
	RT_TRACE_F(COMP_P2P, DBG_LOUD, ("b:\n"));
	p2p_channel_Dump(b);
	RT_TRACE_F(COMP_P2P, DBG_LOUD, ("res:\n"));
	p2p_channel_Dump(res);

	return;
}
Ejemplo n.º 5
0
VOID
EnableIMR88XX(
    IN  HAL_PADAPTER    Adapter
)
{
    PHAL_DATA_TYPE              pHalData = _GET_HAL_DATA(Adapter);
    
    RT_TRACE_F(COMP_INIT, DBG_LOUD, ("\n"));

    HAL_RTL_W32(REG_HIMR0, pHalData->IntMask[0]);
    HAL_RTL_W32(REG_HIMR1, pHalData->IntMask[1]);
}
Ejemplo n.º 6
0
BOOLEAN
WPS_OnAsocReq(
	IN		PADAPTER	Adapter,
	OUT		BOOLEAN		*pbIndicate
	)
{
//	PMGNT_INFO			pMgntInfo = &(Adapter->MgntInfo);
	PMGNT_INFO 			pDefaultMgntInfo = &(GetDefaultAdapter(Adapter)->MgntInfo);
	PSIMPLE_CONFIG_T	pSimpleConfig = GET_SIMPLE_CONFIG(pDefaultMgntInfo);

	if(pSimpleConfig->bEnabled || pSimpleConfig->IELen > 0)
	{// don't check RSNIE whenever WPS is enabled, 20100528, haich.
		RT_TRACE_F(COMP_MLME, DBG_LOUD, ("Support WPS, don't indicate to OS!\n"));
		*pbIndicate = FALSE;
	}
	else
	{
		RT_TRACE_F(COMP_MLME, DBG_LOUD, ("Check RSN-IE if necessary. return FALSE<====\n"));
		return FALSE;
	}
	return	TRUE;
	
}
Ejemplo n.º 7
0
//
// Description:
//	Get the primary channel from the channel information and hw configurations.
// Note:
//	There are two kinds of channel, one is kept in mgnt/channel info and another one is kept in hal.
//	They may be mismatched when the channel switching is in progress or scan in progress.
//	When the scan is performing, the channel in mgnt/channel is not updated.
//
//	If channels are different between HW and ChannelInfo, this function returns HW channel.
//
u1Byte
RT_GetChannelNumber(
	IN	PADAPTER	pAdapter
	)
{
	u1Byte			hwCenterChannel = 0;
	EXTCHNL_OFFSET	hwBW40MOffset = EXTCHNL_OFFSET_NO_EXT;
	EXTCHNL_OFFSET	hwBW80MOffset = EXTCHNL_OFFSET_NO_EXT;

	pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_CUR_CENTER_CHNL, (pu1Byte)(&hwCenterChannel));
	pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_BW40MHZ_EXTCHNL, (pu1Byte)(&hwBW40MOffset));
	pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_BW80MHZ_EXTCHNL, (pu1Byte)(&hwBW80MOffset));

	if(0 == hwCenterChannel)
	{ // Please fix this case
		hwCenterChannel = GET_HAL_DATA(pAdapter)->CurrentChannel;
		RT_TRACE_F(COMP_SCAN, DBG_WARNING, ("[WARNING] Get hw channel = 0 by HW_VAR_CUR_CENTER_CHNL, access hal directly = %d\n",
			hwCenterChannel));
	}
	
	if(((GetDefaultAdapter(pAdapter)->pPortCommonInfo->pChnlCommInfo->CurrentChannelCenterFrequency) == hwCenterChannel))
	{
		return (GetDefaultAdapter(pAdapter)->pPortCommonInfo->pChnlCommInfo->PrimaryChannelNumber);
	}
	else
	{ // In this case, the returned channel may not be the right one because channel switching is in progress.
		if((GetDefaultAdapter(pAdapter)->pPortCommonInfo->pChnlCommInfo->CurrentChannelCenterFrequency) != 0)
		{
			RT_TRACE_F(COMP_MLME, DBG_WARNING, ("[WARNING] Mismatched channel info ceter = %d, primary = %d, hwCenterChannel = %d (40M = %d, 80M = %d), SwChnlInProgress = %d, ScanInProgress = %d\n",
				(GetDefaultAdapter(pAdapter)->pPortCommonInfo->pChnlCommInfo->CurrentChannelCenterFrequency),
				(GetDefaultAdapter(pAdapter)->pPortCommonInfo->pChnlCommInfo->PrimaryChannelNumber),
				hwCenterChannel, hwBW40MOffset, hwBW80MOffset, (RT_IsSwChnlAndBwInProgress(pAdapter) | CHNL_SwChnlAndSetBwInProgress(pAdapter)), MgntScanInProgress(&(pAdapter->MgntInfo))));
		}
		return hwCenterChannel;
	}
}
Ejemplo n.º 8
0
BOOLEAN
MultiPortCanCheckCheckBssid(
	PADAPTER	pAdapter
)
{
	BOOLEAN		bCanCheckBssid = TRUE;

	do
	{
		if(pAdapter->MgntInfo.bWiFiConfg)
		{
			break;
		}
		
		if(GetFirstClientPort(pAdapter))
		{
			bCanCheckBssid = FALSE;
			break;
		}

		if(IsDevicePortDiscoverable(pAdapter))
		{
			bCanCheckBssid = FALSE;
			break;
		}

		if(MultiChannelSwitchNeeded(pAdapter))
		{
			RT_TRACE(COMP_MULTICHANNEL, DBG_LOUD, ("MultiChannelSwitchNeeded() return FALSE!\n"));
			bCanCheckBssid = FALSE;
			break;
		}
	}while(FALSE);
		

	RT_TRACE_F(COMP_P2P, DBG_LOUD, ("bCanCheckBssid: %d\n", bCanCheckBssid));

	return bCanCheckBssid;
}
RT_STATUS
P2PSvc_MakeRspdorPDRspIE(
	IN  PP2PSVC_INFO				pP2PSvcInfo,
	IN  PP2PSVC_PD_ENTRY 			pPDEntry,
	IN  POCTET_STRING 				posP2PAttrs,
	OUT FRAME_BUF					*pBuf
	) 
{
	RT_STATUS						rtStatus = RT_STATUS_SUCCESS;
	PP2P_INFO						pP2PInfo = GET_P2P_INFO(pP2PSvcInfo->pAdapter);
	PP2PSVC_RSPDOR_PD_ENTRY			pRspdorPDEntry = (PP2PSVC_RSPDOR_PD_ENTRY)pPDEntry;
	pu1Byte							pLen = NULL;

	P2PSVC_FUNC_IN(DBG_LOUD);

	do
	{
		PP2P_WPS_ATTRIBUTES 		pWps = &pP2PInfo->WpsAttributes;
		
		if(NULL == (pLen = p2p_add_IEHdr(pBuf))) break;

		// P2P-cap, always present
		if(p2p_ActingAs_Go(pP2PInfo))
			RT_TRACE_F(COMP_P2P, DBG_WARNING, ("Invalid role\n"));
		P2PAttr_Make_Capability(pBuf, 
			pP2PInfo->DeviceCapability & ~P2P_DEV_CAP_CLIENT_DISCOVERABILITY, // this cap valid only in P2P Group Info and AssocReq
			pP2PInfo->GroupCapability);

		// P2P-dev-info, always present
		P2PAttr_Make_DevInfo(pBuf, 
			pP2PInfo->DeviceAddress, 
			pWps->ConfigMethod, 
			&pWps->PrimaryDeviceType, 
			pWps->SecondaryDeviceTypeLength, 
			pWps->SecondaryDeviceTypeList,
			pWps->DeviceNameLength,
			pWps->DeviceName);

		// Group-id, IS GO
		if(P2PSVC_CONN_CAP_BMP_GO == pRspdorPDEntry->pdRspConnCap)
		{
			FrameBuf_Add_u1(pBuf, P2P_ATTR_GROUP_ID);
			FrameBuf_Add_le_u2(pBuf, 6 + pPDEntry->selfGrpInfo.ssidLen);
			FrameBuf_Add_Data(pBuf, pPDEntry->selfGrpInfo.grpDevAddr, 6);
			FrameBuf_Add_Data(pBuf, pPDEntry->selfGrpInfo.ssidBuf, pPDEntry->selfGrpInfo.ssidLen);
		}
		
		// Intended-intf-addr, contains NEW or GO
		if(TEST_FLAG(pRspdorPDEntry->pdRspConnCap, P2PSVC_CONN_CAP_BMP_GO))
		{
			FrameBuf_Add_u1(pBuf, P2P_ATTR_INTENDED_INTERFACE_ADDRESS);
			FrameBuf_Add_le_u2(pBuf, 6);
			FrameBuf_Add_Data(pBuf, pPDEntry->selfGrpInfo.grpIntfAddr, 6);
		}

		// Status, always present
		FrameBuf_Add_u1(pBuf, P2P_ATTR_STATUS);
		FrameBuf_Add_le_u2(pBuf, 1);
		FrameBuf_Add_u1(pBuf, pRspdorPDEntry->pdRspStatus);

		// Operating-channel, IS GO
		if(P2PSVC_CONN_CAP_BMP_GO == pRspdorPDEntry->pdRspConnCap)
		{
			P2PAttr_Make_OperatingChannel(pBuf, pP2PInfo->CountryString, pP2PInfo->RegulatoryClass, pP2PInfo->OperatingChannel);
		}

		// Channel-list, IS CLI or GO
		if(P2PSVC_CONN_CAP_BMP_GO == pRspdorPDEntry->pdRspConnCap 
			|| P2PSVC_CONN_CAP_BMP_CLI == pRspdorPDEntry->pdRspConnCap 
			)
		{
			P2PAttr_Make_ChannelList(pBuf, pP2PInfo, &pP2PInfo->ChannelEntryList);
		}

		// session-info-data-info, NONE

		// conn-cap, always present, present if SUCCESS
		if(P2P_STATUS_SUCCESS == pRspdorPDEntry->pdRspStatus)
		{
			FrameBuf_Add_u1(pBuf, P2P_ATTR_CONN_CAP_INFO);
			FrameBuf_Add_le_u2(pBuf, 1);
			FrameBuf_Add_u1(pBuf, pRspdorPDEntry->pdRspConnCap);
		}

		// adv-id (adv-id, svc-mac), always present
		FrameBuf_Add_u1(pBuf, P2P_ATTR_ADV_ID_INFO);
		FrameBuf_Add_le_u2(pBuf, 4 + 6);
		FrameBuf_Add_le_u4(pBuf, pRspdorPDEntry->super.advId);
		FrameBuf_Add_Data(pBuf, pP2PInfo->DeviceAddress, 6);

		// Config-timeout, IS GO or CLI
		// Always add config-timeout since WFA is checking this even status is failed
		//if(P2PSVC_CONN_CAP_BMP_GO == pRspdorPDEntry->pdRspConnCap 
		//	|| P2PSVC_CONN_CAP_BMP_CLI == pRspdorPDEntry->pdRspConnCap 
		//	)
		{	
			P2PAttr_Make_ConfigTimeout(pBuf, pP2PInfo->GOConfigurationTimeout, pP2PInfo->ClientConfigurationTimeout);
		}

		// Listen-channel, NONE
		
		// Session-id-info, always present
		FrameBuf_Add_u1(pBuf, P2P_ATTR_SESSION_ID_INFO);
		FrameBuf_Add_le_u2(pBuf, 4 + 6);
		FrameBuf_Add_le_u4(pBuf, pRspdorPDEntry->super.sessionId);
		FrameBuf_Add_Data(pBuf, pRspdorPDEntry->super.peerDevAddr, 6);

		// Feature-cap, always present
		FrameBuf_Add_u1(pBuf, P2P_ATTR_FEATURE_CAP_INFO);
		FrameBuf_Add_le_u2(pBuf, 2);
		FrameBuf_Add_le_u2(pBuf, 0x0001);

		// Persistent-grp-info, present if persistent grp known and ASP intent using it
		// TODO:

		//4 Indicate P2P attrs sent
		P2PSvc_IndicateFrameSent(pP2PSvcInfo, 
			P2PSVC_OBJ_HDR_ID_INDIC_RSPDOR_PD_RSP_SENT, 
			pRspdorPDEntry->super.peerDevAddr, 
			(u2Byte)(FrameBuf_Tail(pBuf) - 1 - pLen), 
			pLen + 1);
		
		p2p_update_IeHdrLen(pBuf, pLen);
	}while(FALSE);

	P2PSVC_FUNC_OUT(DBG_LOUD, rtStatus);

	return rtStatus;

}
Ejemplo n.º 10
0
// Description: According received EAPOL-key, enter the next state.
// Output: void
// Modify: Annie, 2005-07-02
//		Discard using condition pKeyMgnt->bPTKInstalled.
//		Instead, I add a macro KeyMgntStateIsWaitingEAPOLKey to check the state.
void 
Authenticator_OnEAPOLKeyRecvd(
	IN	PADAPTER				Adapter,
	IN	PAUTH_PKEY_MGNT_TAG	pKeyMgnt,
	IN	OCTET_STRING			pdu
	)
{
	PMGNT_INFO			pMgntInfo = &Adapter->MgntInfo;
	PAUTH_GLOBAL_KEY_TAG	pGlInfo = &pMgntInfo->globalKeyInfo;
	PRT_WLAN_STA		pEntry = pKeyMgnt->pWLanSTA;
	pu1Byte				pSTA_addr = Frame_pSaddr(pdu);
	pu1Byte				pAP_addr = Frame_pDaddr(pdu);
	PEAPOL_KEY_STRUCT	eapol_key_recvd;
	OCTET_STRING		SNonce;
	OCTET_STRING		RSNIE;
	MsgType				msg_type = type_unknow;

	RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("===> Authenticator_OnEAPOLKeyRecvd()\n") );

	pKeyMgnt->EvntID = ASMEID_EAPOLKeyRecvd;

	FillOctetString(pGlInfo->EapolKeyMsgRecvd,								\
		pGlInfo->EAPOLMsgRecvd.Octet+LIB1X_EAPOL_HDRLEN,					\
		pGlInfo->EAPOLMsgRecvd.Length-LIB1X_EAPOL_HDRLEN );				\

	eapol_key_recvd = (PEAPOL_KEY_STRUCT)pGlInfo->EapolKeyMsgRecvd.Octet;

	//PRINT_DATA( ("EapolKeyMsgRecvd: "), pGlInfo->EapolKeyMsgRecvd.Octet, pGlInfo->EapolKeyMsgRecvd.Length);
	RSNIE.Octet = NULL;
	RSNIE.Length = 0;
	
	// Get the message number.
	if( Message_KeyType(pGlInfo->EapolKeyMsgRecvd) == type_Pairwise )
	{
		if( (Message_Error(pGlInfo->EapolKeyMsgRecvd) == 1) &&
			(Message_Request(pGlInfo->EapolKeyMsgRecvd) == 1))
		{			
			//Enter integrity failure state...			
			Authenticator_StateINTEGRITYFAILURE(Adapter, pEntry);	
		}

		if( (eapol_key_recvd->key_info[0]==0x01 && eapol_key_recvd->key_info[1]==0x09) ||
		    ( eapol_key_recvd->key_info[0]==0x01 && eapol_key_recvd->key_info[1]==0x0a) ||
		    ( eapol_key_recvd->key_info[0]==0x03 && eapol_key_recvd->key_info[1]==0x0a) ||
		    ( eapol_key_recvd->key_info[0]==0x03 && eapol_key_recvd->key_info[1]==0x09) )
		{
			if( pMgntInfo->SecurityInfo.SecLvl == RT_SEC_LVL_WPA)
			RSNIE = EAPOLkeyGetRSNIE( pGlInfo->EapolKeyMsgRecvd, EID_Vendor );
			else if( pMgntInfo->SecurityInfo.SecLvl == RT_SEC_LVL_WPA2)
				RSNIE = EAPOLkeyGetRSNIE( pGlInfo->EapolKeyMsgRecvd, EID_WPA2 );
				
			if( RSNIE.Length != 0 )
				msg_type = type_4way2nd;		// with RSNIE: msg 2 (159 or 161)
			else
				msg_type = type_4way4th;		// msg 4 (135)
		}
		else
		{
			RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("unknow pairwise EAPOL-key: info=0x%X-0x%X\n", eapol_key_recvd->key_info[0], eapol_key_recvd->key_info[1]) );
		}
	}
	else
	{
		// [AnnieNote] Windows zero-config may send 2-way message as 03-01.
		//
		//if( eapol_key_recvd->key_info[0]==0x03 && eapol_key_recvd->key_info[1]==0x11 )	// if group key index is fixed 1, key information is 03-11.
		//	msg_type = type_2way2nd;			// group key msg2 (155)
		//else
		//	RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("unknow group EAPOL-key: info=0x%X-0x%X\n", eapol_key_recvd->key_info[0], eapol_key_recvd->key_info[1]) );
		
		msg_type = type_2way2nd;
	}

	// Check state.
	if( KeyMgntStateIsWaitingEAPOLKey(pKeyMgnt) )
	{

		if( 	(pKeyMgnt->PrState==ASMPS_PTKSTART && msg_type==type_4way2nd ) ||
			( pKeyMgnt->PrState==ASMPS_PTKINITNEGOTIATING && msg_type==type_4way2nd ))
		{
			RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Recvd 4-way message 2\n"));
			pKeyMgnt->TimeoutCtr = 0;

			//  AnnieTODO: if (1)k is pairwise and (2)MICVerified , then enter ASMPS_PTKINITNEGOTIATING state
			//  TODO: MIC Verify
			SNonce = Message_KeyNonce( pGlInfo->EapolKeyMsgRecvd );
			CopyMem( pKeyMgnt->SNonce, SNonce.Octet, KEY_NONCE_LEN );

			
			CalcPTK( pAP_addr, pSTA_addr, pKeyMgnt->ANonce, pKeyMgnt->SNonce,
					 pGlInfo->PMK, PMK_LEN, pKeyMgnt->PTK_update, PTK_LEN );

			if(!CheckEapolMIC(Adapter , pGlInfo->EAPOLMsgRecvd , pKeyMgnt->PTK_update , KEY_MIC_LEN ))
			{
				SendDeauthentication( Adapter, pSTA_addr , mic_failure );
				PlatformStallExecution(100);
				RT_TRACE_F(COMP_AP, DBG_TRACE, ("AsocEntry_RemoveStation\n"));
				
				AsocEntry_RemoveStation( Adapter , pSTA_addr);
				RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("MIC erroe\n"));
				return;
			 }


			Authenticator_StatePTKINITNEGOTIATING(Adapter, pEntry);
		}
		else if( pKeyMgnt->PrState==ASMPS_PTKINITNEGOTIATING && msg_type==type_4way4th )
		{
			RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Recvd 4-way message 4\n"));
			pKeyMgnt->TimeoutCtr = 0;

			// if (1)k is pairwise and (2)MICVerified , then enter ASMPS_PTKINITDONE state
			if(!CheckEapolMIC(Adapter , pGlInfo->EAPOLMsgRecvd , pKeyMgnt->PTK_update , KEY_MIC_LEN ))
			{
				SendDeauthentication( Adapter, pSTA_addr , mic_failure );
				PlatformStallExecution(100);
				RT_TRACE_F(COMP_AP, DBG_TRACE, ("AsocEntry_RemoveStation case 2\n"));
				
				AsocEntry_RemoveStation( Adapter , pSTA_addr);
				RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("MIC erroe\n"));
				return;
			 }

			PlatformMoveMemory(&pEntry->perSTAKeyInfo.RxIV, &((PEAPOL_KEY_STRUCT)eapol_key_recvd)->key_rsc[0], 6);
			pEntry->perSTAKeyInfo.RxIV &= UINT64_C(0x0000ffffffffffff);
			//RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("pEntry->perSTAKeyInfo.RxIV = 0x%16"i64fmt"x", pEntry->perSTAKeyInfo.RxIV));

			Authenticator_StatePTKINITDONE(Adapter, pEntry);		
		}
		else if(  pKeyMgnt->GrState == ASMGS_REKEYNEGOTIATING && msg_type==type_2way2nd )
		{
			RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Recvd 2-way message 2\n"));
			pKeyMgnt->TimeoutCtr = 0;

			//  if (1)k is group and (2)MICVerified , then enter ASMGS_REKEYESTABLISHED state
			// 2012/01/17 CCW If 4-way check is ok, we need not to check 2-way again.
			/*
			if(!CheckEapolMIC(Adapter , pGlInfo->EAPOLMsgRecvd , pKeyMgnt->PTK_update , KEY_MIC_LEN ))
			{
				SendDeauthentication( Adapter, pSTA_addr , mic_failure );
				PlatformStallExecution(100);
				AsocEntry_RemoveStation( Adapter , pSTA_addr);
				RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("MIC erroe\n"));
				return;
			}
			*/
			Authenticator_StateREKEYESTABLISHED(Adapter, pEntry);
		}
		else
		{
			RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Authenticator_OnEAPOLKeyRecvd(): Unexpected case: PrState=%d, GrState=%d, msg_type=%d\n",
											pKeyMgnt->PrState, pKeyMgnt->GrState, msg_type ) );
		}

	}
	else
	{
		RT_TRACE(COMP_AUTHENTICATOR, DBG_LOUD, ("Authenticator_OnEAPOLKeyRecvd(): Unexpected State!!\n"));
		RT_TRACE(COMP_AUTHENTICATOR, DBG_LOUD, ("--- TimeoutCounter:%d, PairwiseKeyState:%d, GroupKeyState:%d ---\n", pKeyMgnt->TimeoutCtr, pKeyMgnt->PrState, pKeyMgnt->GrState));
	}

	RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("<=== Authenticator_OnEAPOLKeyRecvd()\n") );

}
Ejemplo n.º 11
0
//
// Description:
//	Indiacate the fake provision discovery response to the upper layer.
// Arguments:
//	[in] pDev -
//		The device entry which is considered as the respondor for the provision discovery.
//	[in] pP2PInfo -
//		P2P information context.
// Return:
//	Return RT_STATUS_SUCCESS if the indication of fake reponse succeeds.
// By Bruce, 2015-02-17.
//
RT_STATUS
p2p_IndicateFakePdRspReceived(
	IN  P2P_DEV_LIST_ENTRY		*pDev,
	IN  P2P_INFO 				*pP2PInfo
	)
{
	PADAPTER				pAdapter = pP2PInfo->pAdapter;
	RT_STATUS				rtStatus = RT_STATUS_SUCCESS;
	pu1Byte					pRxFrame = NULL;
	FRAME_BUF				fbuf;
	PRT_GEN_TEMP_BUFFER 	pGenBuf = NULL;

	FunctionIn(COMP_P2P);

	do
	{
		if(NULL == (pGenBuf = GetGenTempBuffer(pAdapter, GEN_TEMP_BUFFER_SIZE)))
		{
			RT_TRACE_F(COMP_P2P, DBG_SERIOUS, ("[ERROR] Memory allocation failed!\n"));
			rtStatus = RT_STATUS_RESOURCE;
			break;
		}

		FrameBuf_Init(pAdapter->MAX_TRANSMIT_BUFFER_SIZE, 0, (pu1Byte)(pGenBuf->Buffer.Ptr), &fbuf);
		FrameBuf_SetDbgLevel(&fbuf, DBG_LOUD);

		if(RT_STATUS_SUCCESS != (rtStatus = p2p_Construct_FakePDRsp(
												pP2PInfo,
												pDev,
												pP2PInfo->DeviceAddress,
												&fbuf
												)))
		{
			RT_TRACE_F(COMP_P2P, DBG_WARNING, ("Failed (0x%08X) from p2p_Construct_FakePDRsp()\n", rtStatus));
			break;
		}

		RT_PRINT_DATA(COMP_P2P, DBG_WARNING, "Fake provision response frame:\n", fbuf.os.Octet, fbuf.os.Length);

		// Handle PD req dialog token
		// Note that if status is not success, frame and frameLen could be 0
		if(P2P_ADAPTER_OS_SUPPORT_P2P(pP2PInfo->pAdapter))
		{
			// Change dialog token to make sure the token is the same as the previous query.
			p2p_IndicateActionFrameReceivedWithToken(pP2PInfo, 
				P2P_EVENT_RECEIVED_PROVISION_DISCOVERY_RESPONSE, 
				rtStatus, 
				fbuf.os.Octet, 
				fbuf.os.Length,
				pP2PInfo->oidDialogToken);
		}
		else
		{
			p2p_IndicateActionFrameReceived(pP2PInfo, 
				P2P_EVENT_RECEIVED_PROVISION_DISCOVERY_RESPONSE, 
				rtStatus, 
				fbuf.os.Octet, 
				fbuf.os.Length);
		}
	}while(FALSE);

	
	if(pGenBuf)
	{
		ReturnGenTempBuffer (pAdapter, pGenBuf);
		pGenBuf = NULL;
	}

	FunctionOut(COMP_P2P);

	return rtStatus;
}
//
// Description:
// 	Validate the object list contains all the required parameters of the id.
// 	E.g., for P2PSVC_OBJ_HDR_ID_ACT_SEEK, the obj list shall contain list of
//		[svc-name, svc-hash, svc-info-req].
// 	Each required obj shall appear just once.
//		Order is not important.
//
RT_STATUS
P2PSvc_ValidateActionParam(
	IN  u4Byte								id,
	IN  PP2PSVC_OBJ_LIST					pObjList
	)
{
	RT_STATUS								rtStatus = RT_STATUS_SUCCESS;
	

	int										actSpecIdx = 0;
	int										nParams = 0;
	int										paramIdx = 0;
	PP2PSVC_ACTION_SPEC_ENTRY 				pActSpec = NULL;
	
	do
	{
		// Search table
		for(actSpecIdx = 0; P2PSVC_OBJ_HDR_ID_ACT_UNKNOWN != lP2PSvcActionSpecTab[actSpecIdx].actId; actSpecIdx++)
		{
			if(id == lP2PSvcActionSpecTab[actSpecIdx].actId)
			{
				pActSpec = &(lP2PSvcActionSpecTab[actSpecIdx]);
				break;
			}
		}
		
		RT_ASSERT(pActSpec, ("p2psvc_AddSeekInfo(): Spec of P2PSVC_OBJ_HDR_ID_ACT_SEEK not specified in the action spec table\n"));

		// Count # of parameters
		if (pActSpec != NULL)
		{
			for (nParams = 0; P2PSVC_OBJ_HDR_ID_DATA_UNKNOWN != pActSpec->paramList[nParams]; nParams++) {}
		}

		// Shall have exactly 1 set of parameters
		for(paramIdx = 0; paramIdx < nParams; paramIdx++)
		{// foreach required parameter
			u4Byte					objIter = 0;
			PRT_OBJECT_HEADER		pCurObj = NULL;
			u4Byte 					nOccurrence = 0;
			
			for(objIter = 0; objIter < pObjList->nObjs; objIter++)
			{
				pCurObj = P2PSVC_OBJ_LIST_GET_OBJ(pObjList, objIter);
				if(pCurObj->Id == pActSpec->paramList[paramIdx]) nOccurrence++;
			}

			if(0 == nOccurrence)
			{
				RT_TRACE_F(COMP_P2P, DBG_WARNING, ("param (0x%08X) not found\n", pActSpec->paramList[paramIdx]));
				rtStatus = RT_STATUS_INVALID_PARAMETER;
				break;
			}
			else if(1 < nOccurrence 
				&& P2PSVC_OBJ_HDR_ID_DATA_UNKNOWN != pActSpec->paramList[paramIdx]
				)
			{
				RT_TRACE_F(COMP_P2P, DBG_WARNING, ("id of cur obj (%u) occur more than once: %u\n", pCurObj->Id, nOccurrence));
				rtStatus = RT_STATUS_INVALID_PARAMETER;
				break;
			}
		}

		if(RT_STATUS_SUCCESS != rtStatus)
		{
			break;
		}
	}while(FALSE);

	// Dump raw data if invalid
	if(RT_STATUS_SUCCESS != rtStatus)
	{
		RT_TRACE_F(COMP_P2P, DBG_WARNING, ("[WARNING] info action param\n"));
		RT_PRINT_DATA(COMP_P2P, DBG_WARNING, "ObjList:\n", pObjList, P2PSVC_OBJ_LIST_LEN(pObjList));
	}

	return rtStatus;
}
Ejemplo n.º 13
0
//
// Description:
//	Check the interrupt content (read from previous process) in HAL.
// Arguments:
//	[in] pAdapter -
//		The adapter context pointer.
//	[in] intType -
//		The HAL interrupt type for querying.
// Return:
//	If the corresponding interrupt content (bit) is toggled, return TRUE.
//	If the input interrupt type isn't recognized or this corresponding
//	hal interupt isn't toggled, return FALSE.
// Note:
//	We don't perform I/O here to read interrupt such as ISR here, so the
//	interrupt content shall be read before this handler.
//
HAL_IMEM
BOOLEAN
GetInterrupt88XX(
	IN	HAL_PADAPTER	Adapter,
	IN	HAL_INT_TYPE	intType
	)
{
	HAL_DATA_TYPE	*pHalData   = _GET_HAL_DATA(Adapter);
	BOOLEAN			bResult     = FALSE;

	switch(intType)
	{
	default:
		// Unknown interrupt type, no need to alarm because this IC may not
		// support this interrupt.
		RT_TRACE_F(COMP_SYSTEM, DBG_WARNING, ("Unkown intType: %d!\n", intType));
		break;

	case HAL_INT_TYPE_ANY:
		bResult = (pHalData->IntArray[0] || pHalData->IntArray[1]) ? TRUE : FALSE;
		break;

	//4 // ========== DWORD 0 ==========
	case HAL_INT_TYPE_BCNDERR0:
		bResult = (pHalData->IntArray[0] & BIT_BCNDERR0) ? TRUE : FALSE;
		break;

	case HAL_INT_TYPE_TBDOK:
		bResult = (pHalData->IntArray[0] & BIT_TXBCNOK) ? TRUE : FALSE;
		break;
		
	case HAL_INT_TYPE_TBDER:
		bResult = (pHalData->IntArray[0] & BIT_TXBCNERR) ? TRUE : FALSE;
		break;
		
	case HAL_INT_TYPE_BcnInt:
		bResult = (pHalData->IntArray[0] & BIT_BCNDMAINT0) ? TRUE : FALSE;
		break;
		
	case HAL_INT_TYPE_PSTIMEOUT:
		bResult = (pHalData->IntArray[0] & BIT_PSTIMEOUT) ? TRUE : FALSE;
		break;

	case HAL_INT_TYPE_PSTIMEOUT1:
		bResult = (pHalData->IntArray[0] & BIT_TIMEOUT1) ? TRUE : FALSE;
		break;

	case HAL_INT_TYPE_PSTIMEOUT2:
		bResult = (pHalData->IntArray[0] & BIT_TIMEOUT2) ? TRUE : FALSE;
		break; 
		
	case HAL_INT_TYPE_C2HCMD:
		bResult = (pHalData->IntArray[0] & BIT_C2HCMD_INT) ? TRUE : FALSE;
		break;	
		
	case HAL_INT_TYPE_VIDOK:
		bResult = (pHalData->IntArray[0] & BIT_VIDOK) ? TRUE : FALSE;
		break;
		
	case HAL_INT_TYPE_VODOK:
		bResult = (pHalData->IntArray[0] & BIT_VODOK) ? TRUE : FALSE;
		break;
		
	case HAL_INT_TYPE_BEDOK:
		bResult = (pHalData->IntArray[0] & BIT_BEDOK) ? TRUE : FALSE;
		break;
		
	case HAL_INT_TYPE_BKDOK:
		bResult = (pHalData->IntArray[0] & BIT_BKDOK) ? TRUE : FALSE;
		break;

	case HAL_INT_TYPE_MGNTDOK:
		bResult = (pHalData->IntArray[0] & BIT_MGTDOK) ? TRUE : FALSE;
		break;

	case HAL_INT_TYPE_HIGHDOK:
		bResult = (pHalData->IntArray[0] & BIT_HIGHDOK) ? TRUE : FALSE;
		break;

    #if 0   //Filen: removed
	case HAL_INT_TYPE_BDOK:
		bResult = (pHalData->IntArray[0] & IMR_BCNDOK0_88E) ? TRUE : FALSE;
		break;
    #endif
		
	case HAL_INT_TYPE_CPWM:
		bResult = (pHalData->IntArray[0] & BIT_CPWM_INT) ? TRUE : FALSE;
		break;

	case HAL_INT_TYPE_TSF_BIT32_TOGGLE:
		bResult = (pHalData->IntArray[0] & BIT_TSF_BIT32_TOGGLE) ? TRUE : FALSE;
		break;

    case HAL_INT_TYPE_RX_OK:
		bResult = (pHalData->IntArray[0] & BIT_RXOK) ? TRUE : FALSE;
        break;
        
    case HAL_INT_TYPE_RDU:
		bResult = (pHalData->IntArray[0] & BIT_RDU) ? TRUE : FALSE;
        break;        

    case HAL_INT_TYPE_CTWEND:
		bResult = (pHalData->IntArray[0] & BIT_CTWEND) ? TRUE : FALSE;
        break;

	//4 // ========== DWORD 1 ==========
	case HAL_INT_TYPE_RXFOVW:
		bResult = (pHalData->IntArray[1] & BIT_FOVW) ? TRUE : FALSE;
		break;

    case HAL_INT_TYPE_TXFOVW:
        bResult = (pHalData->IntArray[1] & BIT_TXFOVW) ? TRUE : FALSE;
		break;

    case HAL_INT_TYPE_RXERR:
        bResult = (pHalData->IntArray[1] & BIT_RXERR_INT) ? TRUE : FALSE;
		break;        
        
    case HAL_INT_TYPE_TXERR:
        bResult = (pHalData->IntArray[1] & BIT_TXERR_INT) ? TRUE : FALSE;
		break;        

    case HAL_INT_TYPE_BcnInt_MBSSID:
        bResult = ((pHalData->IntArray[1] & (BIT_BCNDMAINT1|BIT_BCNDMAINT2|BIT_BCNDMAINT3|BIT_BCNDMAINT4|
                                    BIT_BCNDMAINT5|BIT_BCNDMAINT6|BIT_BCNDMAINT7)) ||
                    (pHalData->IntArray[0] & BIT_BCNDMAINT0)
                    ) ? TRUE : FALSE;
        break;

    case HAL_INT_TYPE_BcnInt1:
		bResult = (pHalData->IntArray[1] & BIT_BCNDMAINT1) ? TRUE : FALSE;
        break;

    case HAL_INT_TYPE_BcnInt2:
		bResult = (pHalData->IntArray[1] & BIT_BCNDMAINT2) ? TRUE : FALSE;
        break;

    case HAL_INT_TYPE_BcnInt3:
		bResult = (pHalData->IntArray[1] & BIT_BCNDMAINT3) ? TRUE : FALSE;
        break;

    case HAL_INT_TYPE_BcnInt4:
		bResult = (pHalData->IntArray[1] & BIT_BCNDMAINT4) ? TRUE : FALSE;
        break;

    case HAL_INT_TYPE_BcnInt5:
		bResult = (pHalData->IntArray[1] & BIT_BCNDMAINT5) ? TRUE : FALSE;
        break;

    case HAL_INT_TYPE_BcnInt6:
		bResult = (pHalData->IntArray[1] & BIT_BCNDMAINT6) ? TRUE : FALSE;
        break;

    case HAL_INT_TYPE_BcnInt7:
		bResult = (pHalData->IntArray[1] & BIT_BCNDMAINT7) ? TRUE : FALSE;
        break;

	}

	return bResult;
}
Ejemplo n.º 14
0
VOID
RemoveInterruptMask88XX(
	IN	HAL_PADAPTER	Adapter,
	IN	HAL_INT_TYPE	intType
	)
{
	HAL_DATA_TYPE	*pHalData   = _GET_HAL_DATA(Adapter);

	switch(intType)
	{
    	default:
    		// Unknown interrupt type, no need to alarm because this IC may not
    		// support this interrupt.
    		RT_TRACE_F(COMP_SYSTEM, DBG_WARNING, ("Unkown intType: %d!\n", intType));
    		break;

    	case HAL_INT_TYPE_ANY:
            pHalData->IntMask[0] &= ~0xFFFFFFFF;
            pHalData->IntMask[1] &= ~0xFFFFFFFF;
    		break;

    	//4 // ========== DWORD 0 ==========
    	case HAL_INT_TYPE_TBDOK:
    		pHalData->IntMask[0] &= ~BIT_TXBCNOK;
    		break;
    		
    	case HAL_INT_TYPE_TBDER:
            pHalData->IntMask[0] &= ~BIT_TXBCNERR;
    		break;
    		
    	case HAL_INT_TYPE_BcnInt:
    		pHalData->IntMask[0] &= ~BIT_BCNDMAINT0;
    		break;
    		
    	case HAL_INT_TYPE_PSTIMEOUT:
            pHalData->IntMask[0] &= ~BIT_PSTIMEOUT;
    		break;

    	case HAL_INT_TYPE_PSTIMEOUT1:
    		pHalData->IntMask[0] &= ~BIT_TIMEOUT1;
    		break;

    	case HAL_INT_TYPE_PSTIMEOUT2:
    		pHalData->IntMask[0] &= ~BIT_TIMEOUT2;
    		break; 
    		
    	case HAL_INT_TYPE_C2HCMD:
    		pHalData->IntMask[0] &= ~BIT_C2HCMD_INT;
    		break;	
    		
    	case HAL_INT_TYPE_VIDOK:
    		pHalData->IntMask[0] &= ~BIT_VIDOK;
    		break;
    		
    	case HAL_INT_TYPE_VODOK:
    		pHalData->IntMask[0] &= ~BIT_VODOK;
    		break;
    		
    	case HAL_INT_TYPE_BEDOK:
    		pHalData->IntMask[0] &= ~BIT_BEDOK;
    		break;
    		
    	case HAL_INT_TYPE_BKDOK:
    		pHalData->IntMask[0] &= ~BIT_BKDOK;
    		break;

    	case HAL_INT_TYPE_MGNTDOK:
    		pHalData->IntMask[0] &= ~BIT_MGTDOK;
    		break;

    	case HAL_INT_TYPE_HIGHDOK:
    		pHalData->IntMask[0] &= ~BIT_HIGHDOK;
    		break;

        #if 0   //Filen: removed
    	case HAL_INT_TYPE_BDOK:
            pHalData->IntMask[0] &= ~IMR_BCNDOK0_88E;
    		break;
        #endif
    		
    	case HAL_INT_TYPE_CPWM:
    		pHalData->IntMask[0] &= ~BIT_CPWM_INT;
    		break;

    	case HAL_INT_TYPE_TSF_BIT32_TOGGLE:
    		pHalData->IntMask[0] &= ~BIT_TSF_BIT32_TOGGLE;
    		break;

        case HAL_INT_TYPE_RX_OK:
    		pHalData->IntMask[0] &= ~BIT_RXOK;
            break;

        case HAL_INT_TYPE_RDU:
    		pHalData->IntMask[0] &= ~BIT_RDU;
            break;            

    	//4 // ========== DWORD 1 ==========
    	case HAL_INT_TYPE_RXFOVW:
    		pHalData->IntMask[1] &= ~BIT_FOVW;
    		break;

        case HAL_INT_TYPE_TXFOVW:
            pHalData->IntMask[1] &= ~BIT_TXFOVW;
            break;

        case HAL_INT_TYPE_RXERR:
            pHalData->IntMask[1] &= ~BIT_RXERR_INT;
            break;
            
        case HAL_INT_TYPE_TXERR:
            pHalData->IntMask[1] &= ~BIT_TXERR_INT;
            break;
	}
}
Ejemplo n.º 15
0
//
// This function set bandwidth mode in protocol layer.
//
VOID
CHNL_SetBwChnl(
	IN	PADAPTER			pAdapter,
	IN	u1Byte				PrimaryChnl,
	IN	CHANNEL_WIDTH		Bandwidth,
	IN	EXTCHNL_OFFSET		BwOffset
	)
{
	PMGNT_INFO					pMgntInfo = &pAdapter->MgntInfo;
	PRT_CHANNEL_INFO			pChnlInfo = GET_CHNL_INFO(pMgntInfo);
	
	PADAPTER					DefAdapter = GetDefaultAdapter(pAdapter);
	PMGNT_INFO					pDefMgntInfo = &DefAdapter->MgntInfo;
	PRT_CHANNEL_INFO			pDefChnlInfo = GET_CHNL_INFO(pDefMgntInfo);
	PCHANNEL_COMMON_CONTEXT		pDefChnlCommInfo = DefAdapter->pPortCommonInfo->pChnlCommInfo;

	CHANNEL_WIDTH				ToSetBandWidth = CHANNEL_WIDTH_20;
	EXTCHNL_OFFSET				ToSTAExtChnlOffsetof40MHz= EXTCHNL_OFFSET_NO_EXT;
	EXTCHNL_OFFSET				ToSTAExtChnlOffsetof80MHz= EXTCHNL_OFFSET_NO_EXT;
	u1Byte						ToSTACenterFrequency;

	RT_TRACE_F(COMP_SCAN, DBG_LOUD, ("PrimaryChnl %d\n", PrimaryChnl));

	if(ACTING_AS_IBSS(DefAdapter))
	{
		{
			// 2013/10/15 MH Add for higher adhoc and VHT 2.4G mode.
			if (!pMgntInfo->bReg11nAdhoc && !pMgntInfo->bRegVht24g)
			{
				Bandwidth= CHANNEL_WIDTH_20;
				BwOffset = EXTCHNL_OFFSET_NO_EXT;
			}
		}
	}

	ToSetBandWidth = Bandwidth;
	ToSTAExtChnlOffsetof40MHz = BwOffset;
	ToSTACenterFrequency = CHNL_GetCenterFrequency(PrimaryChnl, Bandwidth, BwOffset);
	
	ToSetBandWidth = CHNL_CheckChnlPlanWithBW(pAdapter,PrimaryChnl,Bandwidth,BwOffset);

	if((ToSetBandWidth != Bandwidth) &&  ToSetBandWidth==CHANNEL_WIDTH_20)
		ToSTACenterFrequency =PrimaryChnl;
	
	if(Bandwidth == CHANNEL_WIDTH_80)
	{
		if(ToSTACenterFrequency > pMgntInfo->dot11CurrentChannelNumber)
			ToSTAExtChnlOffsetof80MHz = EXTCHNL_OFFSET_UPPER;
		else if(ToSTACenterFrequency < pMgntInfo->dot11CurrentChannelNumber)
			ToSTAExtChnlOffsetof80MHz = EXTCHNL_OFFSET_LOWER;
		else
			ToSTAExtChnlOffsetof80MHz = EXTCHNL_OFFSET_NO_EXT;		
	}

	RT_DISP(FCHNL, FCHNL_FUN,  ("Set ToSetBandWidth = %d, ToSTAExtChnlOffset = %d,ToSTAExtChnlOffsetof80MHz %d, ToSTACenterFrequency= %d \n", ToSetBandWidth, ToSTAExtChnlOffsetof40MHz,ToSTAExtChnlOffsetof80MHz,ToSTACenterFrequency));

	pMgntInfo->dot11CurrentChannelBandWidth = ToSetBandWidth;
	pChnlInfo->PrimaryChannelNumber = pDefChnlCommInfo->PrimaryChannelNumber = PrimaryChnl;
	pChnlInfo->CurrentChannelBandWidth = pDefChnlCommInfo->CurrentChannelBandWidth = ToSetBandWidth;
	pChnlInfo->CurrentChannelCenterFrequency = pDefChnlCommInfo->CurrentChannelCenterFrequency = ToSTACenterFrequency;
	pChnlInfo->Ext20MHzChnlOffsetOf40MHz = pDefChnlCommInfo->Ext20MHzChnlOffsetOf40MHz = ToSTAExtChnlOffsetof40MHz;
	pChnlInfo->Ext40MHzChnlOffsetOf80MHz = pDefChnlCommInfo->Ext40MHzChnlOffsetOf80MHz = ToSTAExtChnlOffsetof80MHz;

	// TODO: 2007.7.13 by Emily Wait 2000ms  in order to garantee that switching
	//   bandwidth is executed after scan is finished. It is a temporal solution
	//   because software should ganrantee the last operation of switching bandwidth
	//   is executed properlly. 
	if(!(RT_DRIVER_HALT(DefAdapter)))
		PlatformSetTimer(DefAdapter, &pDefChnlInfo->SwBwTimer, 0);

	FunctionOut(COMP_SCAN);
}
Ejemplo n.º 16
0
//
// Description:
//	Get the offset according to the packet type.
// Arguments:
//	[in] posMpdu -
//		The full 802.11 packet.
//	[out] pOffset -
//		The returned offset for the fist IE.
// Return:
//	If this executes without any error, return FALSE.
//	If this packet has no IE, return FALSE.
// Remark:
//	None.
// By Bruce, 2012-03-09.
//
BOOLEAN
PacketGetIeOffset(
	IN	POCTET_STRING	posMpdu,
	OUT	pu2Byte			pOffset
	)
{
	BOOLEAN		bValid = TRUE;
	u4Byte		idx = 0;
	
	switch(PacketGetType(*posMpdu))
	{
		default:
			bValid = FALSE;
			break;
			
		case Type_Auth:
			*pOffset = (sMacHdrLng + 6);
			break;
			
		case Type_Probe_Req:
			*pOffset = (sMacHdrLng + 0);
			break;
			
		case Type_Beacon:
		case Type_Probe_Rsp:
			*pOffset = (sMacHdrLng + 12);
			break;
			
		case Type_Reasoc_Req:
			*pOffset = (sMacHdrLng + 10);
			break;
			
		case Type_Asoc_Req:
			*pOffset = (sMacHdrLng + 4);
			break;
			
		case Type_Asoc_Rsp:
		case Type_Reasoc_Rsp:
			*pOffset = (sMacHdrLng + 6);
			break;
			
		case Type_Disasoc:
		case Type_Deauth:
			*pOffset = (sMacHdrLng + 2);
			break;
				
		case Type_Action:
			{
				ACT_PKT_TYPE	actType = PacketGetActionFrameType(posMpdu);

				bValid = FALSE;
				if(ACT_PKT_TYPE_UNKNOWN == actType)
				{
					RT_TRACE_F(COMP_DBG, DBG_WARNING, ("[WARNING] Unrecognized action frame type!\n"));
					break;
				}
				for(idx = 0; ACT_PKT_TYPE_UNKNOWN != (ACT_PKT_TYPE)(ActPktIeOffsetMap[idx].PktType); idx ++)
				{
					if(actType == (ACT_PKT_TYPE)(ActPktIeOffsetMap[idx].PktType))
					{
						*pOffset = ActPktIeOffsetMap[idx].IeOffset;
						bValid = TRUE;
						break;
					}
				}

				if(!bValid)
				{
					RT_TRACE_F(COMP_DBG, DBG_WARNING, ("[WARNING] cannot find offset for action frame type = %d!\n", actType));
				}
			}
			break;
	}

	return bValid;
}
//
// Description:
//		Validate if the input buffer contains an object with obj list as its payload
//
RT_STATUS 
P2PSvc_ValidateReqInfo(
	IN  PVOID								infoBuf,
	IN  u4Byte								inBufLen,
	OUT pu4Byte								pBytesNeeded
	)
{
	RT_STATUS								rtStatus = RT_STATUS_SUCCESS;
	u4Byte									bytesNeeded = 0;


	P2PSVC_FUNC_IN(DBG_LOUD);

	do
	{
		PRT_OBJECT_HEADER					pObjHdr = NULL;
		PP2PSVC_OBJ_LIST					pObjList = NULL;
		u4Byte								objIter = 0;

		// Check if we can read the obj hdr
		bytesNeeded = RT_OBJECT_HEADER_SIZE;

		if(inBufLen < bytesNeeded)
		{
			RT_TRACE_F(COMP_P2P, DBG_WARNING, ("[WARNING] Buffer (%d) too short for required (%d)!\n", inBufLen, bytesNeeded));
			rtStatus = RT_STATUS_INVALID_LENGTH;
			break;
		}

		// Check if the in buf is large enough to hold the data whose length is declared in the obj header
		pObjHdr = (PRT_OBJECT_HEADER)(infoBuf);
		
		if(inBufLen < bytesNeeded + pObjHdr->Length)
		{
			RT_TRACE_F(COMP_P2P, DBG_WARNING, ("[WARNING] in buf is not large enough to hold the value, value len: %u, inbuf len: %u!\n", pObjHdr->Length, inBufLen));
			rtStatus = RT_STATUS_INVALID_DATA;
			break;
		}

		// Check if the payload is a valid obj list
		pObjList = (PP2PSVC_OBJ_LIST)(pObjHdr->Value);
		bytesNeeded += FIELD_OFFSET(P2PSVC_OBJ_LIST, varStart);
		if(inBufLen < bytesNeeded)
		{
			RT_TRACE_F(COMP_P2P, DBG_WARNING, ("[WARNING] in buf is not large enough to hold an obj list, inbuf len: %u!\n", inBufLen));
			rtStatus = RT_STATUS_INVALID_DATA;
			break;
		}

		// Validate the obj hdr of the info list		
		if(P2PSVC_OBJ_HDR_ID_DATA_OBJ_LIST != pObjList->hdr.Id)
		{
			RT_TRACE_F(COMP_P2P, DBG_WARNING, ("[WARNING] payload is not an obj list, its id is: %u\n", pObjList->hdr.Id));
			rtStatus = RT_STATUS_INVALID_DATA;
			break;
		}

		// Check if the objs in the obj list has valid length
		for(objIter = 0; objIter < pObjList->nObjs; objIter++)
		{	
			PRT_OBJECT_HEADER pCurObj = NULL;
			
			// Check we can read the obj hdr of the current obj
			if(inBufLen < bytesNeeded + pObjList->ObjTab[objIter] + RT_OBJECT_HEADER_SIZE)
			{
				bytesNeeded = bytesNeeded + pObjList->ObjTab[objIter] + RT_OBJECT_HEADER_SIZE;
				RT_TRACE_F(COMP_P2P, DBG_WARNING, ("[WARNING] obj with index %u is not valid\n", objIter));
				rtStatus = RT_STATUS_INVALID_DATA;
				break;
			}

			// Get the obj
			pCurObj = P2PSVC_OBJ_LIST_GET_OBJ(pObjList, objIter);

			// Check the hdr of the cur obj
			if(inBufLen < bytesNeeded + pObjList->ObjTab[objIter] + RT_OBJECT_HEADER_SIZE + pCurObj->Length)
			{
				bytesNeeded = bytesNeeded + pObjList->ObjTab[objIter] + RT_OBJECT_HEADER_SIZE + pCurObj->Length;
				RT_TRACE_F(COMP_P2P, DBG_WARNING, ("[WARNING] inbuf (len: %u) is not large enough to hold the obj (index: %u, len: %u)\n", inBufLen, objIter, pCurObj->Length));
				rtStatus = RT_STATUS_INVALID_DATA;
				break;
			}
		}

		if(RT_STATUS_SUCCESS != rtStatus)
		{
			break;
		}
	}while(FALSE);

	*pBytesNeeded = bytesNeeded;

	// Dump raw data if invalid
	if(RT_STATUS_SUCCESS != rtStatus)
	{
		RT_TRACE_F(COMP_P2P, DBG_WARNING, ("[WARNING] info req invalid, bytesNeeded: %u\n", *pBytesNeeded));
		RT_PRINT_DATA(COMP_P2P, DBG_WARNING, "InBuf:\n", infoBuf, inBufLen);
	}

	P2PSVC_FUNC_OUT(DBG_LOUD, rtStatus);

	return rtStatus;
}