wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
dyntable.h
1#ifndef QUIC_QPACK_DYNTABLE_H
2#define QUIC_QPACK_DYNTABLE_H
3
4#include "app/qpack/qpack/field.h"
5
6/* RFC 9204 3.2. QPACK dynamic table: a fixed-capacity ring of inserted
7 * (name, value) entries. Absolute indices grow from 0 with each insert; old
8 * entries are evicted when capacity is exceeded. Names and values are stored
9 * inline with fixed per-field upper bounds (no allocation, no libc). */
10
11#define QUIC_QPACK_DYN_MAX_ENTRIES 64
12#define QUIC_QPACK_DYN_MAX_NAME 256
13#define QUIC_QPACK_DYN_MAX_VALUE 1024
14
17typedef struct {
18 u8 name[QUIC_QPACK_DYN_MAX_NAME];
19 u8 value[QUIC_QPACK_DYN_MAX_VALUE];
23
26typedef struct {
27 quic_qpack_dyn_entry ring[QUIC_QPACK_DYN_MAX_ENTRIES];
34
35/* RFC 9204 3.2. Initialise an empty table with the given byte capacity. */
36void quic_qpack_dyn_init(quic_qpack_dyn* t, usz capacity);
37
38/* RFC 9204 3.2 / 3.2.1. Insert the (name, value) pair, evicting oldest
39 * entries as needed to fit. Returns 1 on success, 0 if the entry cannot fit
40 * even in an empty table or exceeds the inline field bounds. */
41int quic_qpack_dyn_insert(quic_qpack_dyn* t, const quic_qpack_field* f);
42
43/* RFC 9204 3.2.1. Current total size in bytes. */
44usz quic_qpack_dyn_size(const quic_qpack_dyn* t);
45
46/* RFC 9204 3.2.2. Apply a new dynamic table capacity from a received Set
47 * Dynamic Table Capacity instruction (Section 4.3.1) once it has already
48 * passed quic_qpack_capacity_within_limit: evicts entries from the end of
49 * the table until its size is at most new_capacity (a no-op if the
50 * capacity is being raised, or set to 0 to clear the table entirely). */
51void quic_qpack_dyn_set_capacity(quic_qpack_dyn* t, usz new_capacity);
52
53/* RFC 9204 4.3.1. A received Set Dynamic Table Capacity instruction's value is
54 * valid only up to the limit the server advertised in
55 * SETTINGS_QPACK_MAX_TABLE_CAPACITY. Returns 1 if capacity is within that
56 * limit, 0 if it exceeds it -- the caller treats 0 as a connection error of
57 * type QPACK_ENCODER_STREAM_ERROR. */
58int quic_qpack_capacity_within_limit(u64 capacity, u64 max_table_capacity);
59
60#endif
RFC 9204 3.2.
Definition dyntable.h:17
u8 value[QUIC_QPACK_DYN_MAX_VALUE]
entry value bytes
Definition dyntable.h:19
usz value_len
bytes used in value
Definition dyntable.h:21
u8 name[QUIC_QPACK_DYN_MAX_NAME]
entry name bytes
Definition dyntable.h:18
usz name_len
bytes used in name
Definition dyntable.h:20
RFC 9204 3.2.
Definition dyntable.h:26
quic_qpack_dyn_entry ring[QUIC_QPACK_DYN_MAX_ENTRIES]
entry storage
Definition dyntable.h:27
usz capacity
maximum allowed size in bytes
Definition dyntable.h:32
u64 dropped
absolute index of the oldest live entry
Definition dyntable.h:30
usz count
number of live entries
Definition dyntable.h:29
usz size
sum of entry sizes (RFC 9204 3.2.1)
Definition dyntable.h:31
usz head
physical slot of the oldest live entry
Definition dyntable.h:28
A QPACK field line's (name, value) pair as borrowed views (encoder input / decoder table lookups).
Definition field.h:8
u64 usz
unsigned size (size_t equivalent)
Definition syscall.h:19
unsigned char u8
unsigned 8-bit integer / byte
Definition syscall.h:17
unsigned long u64
unsigned 64-bit integer
Definition syscall.h:12