8#include "PacketReader.hpp"
9#include "PacketWriter.hpp"
14constexpr std::uint32_t
MAGIC = 0x52545950;
Bounds checked reader of big-endian values over a byte buffer.
Definition PacketReader.hpp:15
Growable buffer of big-endian values, capped at MAX_PAYLOAD_SIZE.
Definition PacketWriter.hpp:16
HandshakeType
Kind of handshake datagram.
Definition HandshakeHeader.hpp:21
constexpr std::uint8_t VERSION
Protocol version announced and expected during the handshake.
Definition HandshakeHeader.hpp:16
constexpr std::uint32_t MAGIC
Magic number that starts every handshake datagram, "RTYP" in ASCII.
Definition HandshakeHeader.hpp:14
@ Welcome
Server accepts the client and gives its connection id.
@ Hello
Client asks the server to open a connection.
@ Rejected
Server refuses the connection.
Header of the datagrams exchanged before a connection exists.
Definition HandshakeHeader.hpp:38
static constexpr std::size_t HEADER_SIZE
Encoded size of the header, in bytes.
Definition HandshakeHeader.hpp:44
HandshakeType type
Handshake step.
Definition HandshakeHeader.hpp:41
bool deserialize(PacketReader &reader)
Reads and validates the magic number and handshake type.
Definition HandshakeHeader.cpp:9
std::uint8_t version
Protocol version.
Definition HandshakeHeader.hpp:40
bool serialize(PacketWriter &writer) const
Writes the header in network byte order.
Definition HandshakeHeader.cpp:4
std::uint32_t magic
Protocol magic number.
Definition HandshakeHeader.hpp:39