|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
QUIC variable-length integer coding (RFC 9000 sec 16). More...
#include "protocore_config.h"Go to the source code of this file.
Classes | |
| struct | QuicVarintNs |
| Dispatch table. Addressed by offset, so the layout is asserted below. More... | |
Macros | |
| #define | QUIC_VARINT_MAX 0x3FFFFFFFFFFFFFFFull |
| Largest value a QUIC varint can hold (2^62 - 1). | |
Functions | |
| PROTOCORE_NS_LAYOUT (QuicVarintNs, len, encode, decode) | |
| size_t | protocore_quic_varint_len (uint8_t *work, uint64_t value) |
| Bytes value encodes to (1 / 2 / 4 / 8), or 0 if it exceeds . | |
| size_t | protocore_quic_varint_encode (uint8_t *work, uint8_t *out, size_t cap, uint64_t value) |
| Encode value in its shortest form. bytes written, or 0 on overflow . | |
| proto_bool | protocore_quic_varint_decode (uint8_t *work, const uint8_t *in, size_t len, uint64_t *value, size_t *consumed) |
| Decode a varint at in. Sets value and consumed (1/2/4/8). false if . | |
Variables | |
| PROTOCORE_NS QuicVarintNs QuicVarint | PROTOCORE_UNUSED |
| Module namespace. | |
QUIC variable-length integer coding (RFC 9000 sec 16).
QUIC, HTTP/3 (RFC 9114), and QPACK (RFC 9204) encode most lengths and identifiers as a variable-length integer: the two most-significant bits of the first byte give the total length (00 -> 1 byte / 6-bit value, 01 -> 2 / 14-bit, 10 -> 4 / 30-bit, 11 -> 8 / 62-bit), and the remaining bits hold the value big-endian. The representable range is 0 .. 2^62-1.
This is the foundational primitive of the HTTP/3 stack. Pure and host-tested.
work is bytes the CALLER holds. This module reads none of them: it carries nothing between calls, so there is no state to keep and nothing to wipe. The parameter is there so a caller drives every namespace the same way.
Definition in file quic_varint.h.
| #define QUIC_VARINT_MAX 0x3FFFFFFFFFFFFFFFull |
Largest value a QUIC varint can hold (2^62 - 1).
Definition at line 35 of file quic_varint.h.
| PROTOCORE_NS_LAYOUT | ( | QuicVarintNs | , |
| len | , | ||
| encode | , | ||
| decode | |||
| ) |
| size_t protocore_quic_varint_len | ( | uint8_t * | work, |
| uint64_t | value | ||
| ) |
Bytes value encodes to (1 / 2 / 4 / 8), or 0 if it exceeds .
| work | PROTOCORE_QUIC_VARINT_BORROW bytes the caller took. Not held past the call. |
| value | Value |
| size_t protocore_quic_varint_encode | ( | uint8_t * | work, |
| uint8_t * | out, | ||
| size_t | cap, | ||
| uint64_t | value | ||
| ) |
Encode value in its shortest form. bytes written, or 0 on overflow .
| work | PROTOCORE_QUIC_VARINT_BORROW bytes the caller took. Not held past the call. |
| out | Out |
| cap | Cap |
| value | Value |
| proto_bool protocore_quic_varint_decode | ( | uint8_t * | work, |
| const uint8_t * | in, | ||
| size_t | len, | ||
| uint64_t * | value, | ||
| size_t * | consumed | ||
| ) |
Decode a varint at in. Sets value and consumed (1/2/4/8). false if .
| work | PROTOCORE_QUIC_VARINT_BORROW bytes the caller took. Not held past the call. |
| in | In |
| len | Len |
| value | Value |
| consumed | Consumed |
| PROTOCORE_NS QuicVarintNs QuicVarint PROTOCORE_UNUSED |
Module namespace.
Definition at line 75 of file quic_varint.h.