DeterministicESPAsyncWebServer
v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
quic_varint.h
Go to the documentation of this file.
1
// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2
// SPDX-License-Identifier: AGPL-3.0-or-later
3
4
/**
5
* @file quic_varint.h
6
* @brief QUIC variable-length integer coding (RFC 9000 sec 16).
7
*
8
* QUIC, HTTP/3 (RFC 9114), and QPACK (RFC 9204) encode most lengths and identifiers as a
9
* variable-length integer: the two most-significant bits of the first byte give the total length
10
* (00 -> 1 byte / 6-bit value, 01 -> 2 / 14-bit, 10 -> 4 / 30-bit, 11 -> 8 / 62-bit), and the
11
* remaining bits hold the value big-endian. The representable range is 0 .. 2^62-1.
12
*
13
* This is the foundational primitive of the HTTP/3 stack. Pure and host-tested.
14
*
15
* @author Douglas Quigg (dstroy0)
16
* @date 2026
17
*/
18
19
#ifndef DETERMINISTICESPASYNCWEBSERVER_QUIC_VARINT_H
20
#define DETERMINISTICESPASYNCWEBSERVER_QUIC_VARINT_H
21
22
#include "
ServerConfig.h
"
23
24
#if DETWS_ENABLE_HTTP3
25
26
#include <stddef.h>
27
#include <stdint.h>
28
29
/** @brief Largest value a QUIC varint can hold (2^62 - 1). */
30
#define QUIC_VARINT_MAX 0x3FFFFFFFFFFFFFFFull
31
32
/** @brief Bytes @p value encodes to (1 / 2 / 4 / 8), or 0 if it exceeds QUIC_VARINT_MAX. */
33
size_t
quic_varint_len(uint64_t value);
34
35
/** @brief Encode @p value in its shortest form. @return bytes written, or 0 on overflow / cap. */
36
size_t
quic_varint_encode(uint8_t *out,
size_t
cap, uint64_t value);
37
38
/**
39
* @brief Decode a varint at @p in. Sets @p value and @p consumed (1/2/4/8). @return false if the
40
* buffer is shorter than the length the first byte announces.
41
*/
42
bool
quic_varint_decode(
const
uint8_t *in,
size_t
len, uint64_t *value,
size_t
*consumed);
43
44
#endif
// DETWS_ENABLE_HTTP3
45
#endif
// DETERMINISTICESPASYNCWEBSERVER_QUIC_VARINT_H
ServerConfig.h
User-facing configuration for DeterministicESPAsyncWebServer.
src
network_drivers
presentation
http3
quic_varint.h
Generated by
1.9.8