size_t StreamProcessor::DispatchProcessPacket(const UInt32 packetID, DataVector::iterator curr, DataVector::iterator bufferEnd) 
	{
		for(UInt32 i=0; i<m_numPacketTypes; i++)
		{
			const PacketDescriptorPacket &desc = m_packetDescriptors[i];
			if(desc.packetID == packetID)
			{
				const ProcessPacketFunc processFunc = m_packetProcessors[i];
				if(processFunc)
				{
					return processFunc(*this, curr, bufferEnd);
				}
				else
				{
					// No process function available for this packet type! Attempt to skip it!
					switch(desc.sizeofPayloadSizeType)
					{
						case 0: return SkipPacket(                    (size_t)desc.sizeofPacket, curr, bufferEnd );
						case 1: return SkipPacketWithPayload<UInt8>(  (size_t)desc.sizeofPacket, curr, bufferEnd );
						case 2: return SkipPacketWithPayload<UInt16>( (size_t)desc.sizeofPacket, curr, bufferEnd );
						case 4: return SkipPacketWithPayload<UInt32>( (size_t)desc.sizeofPacket, curr, bufferEnd );
					}
				}
			}
		}

		// We should never reach here...
		// typically means unknown packet type, so any further reading from the socket will yield undefined results...
		OVR_CAPTURE_ASSERT(0);
		return 0;
	}
Ejemplo n.º 2
0
BOOL CNetMsg::ReadPacket( LPVOID pBuf, DWORD dwSize )
{_STT();
	// Process packets
	if ( CDataPacket::ReadPacket( pBuf, dwSize ) ) do
	{
		// Process this packet
		MSendMessage( eRx, (LPARAM)this );

	// Skip this packet
	} while ( SkipPacket() );

	return TRUE;
}
Ejemplo n.º 3
0
BOOL CNetMsg::VerifyPacket()
{_STT();
	do
	{
		// Verify a valid data packet
		if ( !CDataPacket::VerifyPacket() )
			return FALSE;

		// Verify the packet is for us
		SAddress dst;
		if ( ReadPacketData( 0, NETMSGDT_DSTADDRESS, &dst, sizeof( dst ) ) )
		{
			// Is this packet addressed to us?
			if ( IsEqualGUID( dst.guidNode, m_guidAddress ) ||
				 IsEqualGUID( dst.guidNode, CLSID_CNETMSG_BROADCAST ) )
				return TRUE;

		} // end if	

	// Look to the next packet
	} while ( SkipPacket() );

	return FALSE;
}