4#ifndef PROTOCORE_QUIC_PACKET_H
5#define PROTOCORE_QUIC_PACKET_H
36#define QUIC_VERSION_1 0x00000001u
37#define QUIC_MAX_CID_LEN 20
40#define QUIC_LP_INITIAL 0x00
41#define QUIC_LP_0RTT 0x01
42#define QUIC_LP_HANDSHAKE 0x02
43#define QUIC_LP_RETRY 0x03
75 size_t (*build_long_header)(uint8_t *, uint8_t *, size_t, uint8_t, uint32_t,
const uint8_t *, uint8_t,
76 const uint8_t *, uint8_t, uint8_t);
78 size_t (*build_version_negotiation)(uint8_t *, uint8_t *, size_t,
const uint8_t *, uint8_t,
const uint8_t *,
79 uint8_t,
const uint32_t *, size_t);
80 uint8_t (*pn_length)(uint8_t *, uint64_t, int64_t);
81 size_t (*pn_encode)(uint8_t *, uint8_t *, size_t, uint64_t, int64_t);
82 uint64_t (*pn_decode)(uint8_t *, uint64_t, uint64_t, uint8_t);
85 build_version_negotiation, pn_length, pn_encode, pn_decode);
118 const uint8_t *dcid, uint8_t dcid_len,
const uint8_t *scid,
119 uint8_t scid_len, uint8_t pn_len);
145 uint8_t dcid_len,
const uint8_t *scid, uint8_t scid_len,
146 const uint32_t *versions,
size_t nversions);
165 int64_t largest_acked);
181 .build_version_negotiation =
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
PROTOCORE_NS QuicPacketNs QuicPacket PROTOCORE_UNUSED
Module namespace.
size_t protocore_quic_packet_build_long_header(uint8_t *work, uint8_t *out, size_t cap, uint8_t type, uint32_t version, const uint8_t *dcid, uint8_t dcid_len, const uint8_t *scid, uint8_t scid_len, uint8_t pn_len)
Build a long header's invariant fields (first byte .. Source .
uint64_t protocore_quic_packet_pn_decode(uint8_t *work, uint64_t largest_pn, uint64_t truncated_pn, uint8_t pn_nbits)
Recover the full packet number from a truncated_pn of pn_nbits bits .
proto_bool protocore_quic_packet_is_long_header(uint8_t *work, uint8_t first)
True if byte 0 selects the long header form (0x80 set).
uint8_t protocore_quic_packet_pn_length(uint8_t *work, uint64_t full_pn, int64_t largest_acked)
Packet-number length in bytes (1..4) for full_pn; largest_acked < 0 .
proto_bool protocore_quic_packet_parse_long_header(uint8_t *work, const uint8_t *buf, size_t len, QuicLongHeader *out)
Parse a long header. false if truncated or a connection ID exceeds .
proto_bool protocore_quic_packet_parse_short_header(uint8_t *work, const uint8_t *buf, size_t len, uint8_t dcid_len, QuicShortHeader *out)
Parse a short (1-RTT) header given the locally chosen dcid_len. .
size_t protocore_quic_packet_build_version_negotiation(uint8_t *work, uint8_t *out, size_t cap, const uint8_t *dcid, uint8_t dcid_len, const uint8_t *scid, uint8_t scid_len, const uint32_t *versions, size_t nversions)
Build a Version Negotiation packet (RFC 9000 sec 17.2.1): Version 0 .
size_t protocore_quic_packet_pn_encode(uint8_t *work, uint8_t *out, size_t cap, uint64_t full_pn, int64_t largest_acked)
Encode full_pn truncated to QuicPacketNs::pn_length bytes, .
#define QUIC_MAX_CID_LEN
maximum connection-ID length in QUIC version 1
Dispatch table. Addressed by offset, so the layout is asserted below.
proto_bool(* is_long_header)(uint8_t *, uint8_t)
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS