CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
27 namespace catapult {
namespace ionet {
36 return Size <= sizeof(Packet) ? nullptr : reinterpret_cast<uint8_t*>(
this) +
sizeof(
Packet);
40 constexpr
const uint8_t*
Data()
const {
41 return Size <= sizeof(Packet) ? nullptr : reinterpret_cast<const uint8_t*>(
this) +
sizeof(
Packet);
48 template<
typename TPacket>
50 uint32_t packetSize =
sizeof(TPacket) + payloadSize;
51 auto pPacket = utils::MakeSharedWithSize<TPacket>(packetSize);
52 pPacket->Size = packetSize;
59 uint32_t packetSize =
sizeof(
Packet) + payloadSize;
60 auto pPacket = utils::MakeSharedWithSize<Packet>(packetSize);
61 pPacket->Size = packetSize;
62 pPacket->Type = PacketType::Undefined;
67 template<
typename TPacket>
71 : static_cast<const TPacket*>(pPacket);
constexpr const uint8_t * Data() const
Returns a const pointer to data contained in this packet.
Definition: Packet.h:40
A packet header with a data payload.
Definition: Packet.h:32
uint8_t * Data()
Returns a non-const pointer to data contained in this packet.
Definition: Packet.h:35
PacketType
An enumeration of known packet types.
Definition: PacketType.h:171
std::shared_ptr< TPacket > CreateSharedPacket(uint32_t payloadSize=0)
Creates a packet of the specified type (TPacket) with the specified payload size.
Definition: Packet.h:49
static constexpr auto Packet_Type
Definition: RemoteNodeApi.cpp:33
const TPacket * CoercePacket(const Packet *pPacket)
Coerces pPacket to the desired packet type or nullptr if it is incompatible.
Definition: Packet.h:68
Definition: AddressExtractionExtension.cpp:28
A class that can neither be copied nor moved.
Definition: NonCopyable.h:26
constexpr bool IsPacketValid(const Packet &packet, PacketType type)
Checks if packet is valid with type.
Definition: Packet.h:75