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
17
typedef
struct
{
18
u8
name
[QUIC_QPACK_DYN_MAX_NAME];
19
u8
value
[QUIC_QPACK_DYN_MAX_VALUE];
20
usz
name_len
;
21
usz
value_len
;
22
}
quic_qpack_dyn_entry
;
23
26
typedef
struct
{
27
quic_qpack_dyn_entry
ring
[QUIC_QPACK_DYN_MAX_ENTRIES];
28
usz
head
;
29
usz
count
;
30
u64
dropped
;
31
usz
size
;
32
usz
capacity
;
33
}
quic_qpack_dyn
;
34
35
/* RFC 9204 3.2. Initialise an empty table with the given byte capacity. */
36
void
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. */
41
int
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. */
44
usz
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). */
51
void
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. */
58
int
quic_qpack_capacity_within_limit(
u64
capacity,
u64
max_table_capacity);
59
60
#endif
quic_qpack_dyn_entry
RFC 9204 3.2.
Definition
dyntable.h:17
quic_qpack_dyn_entry::value
u8 value[QUIC_QPACK_DYN_MAX_VALUE]
entry value bytes
Definition
dyntable.h:19
quic_qpack_dyn_entry::value_len
usz value_len
bytes used in value
Definition
dyntable.h:21
quic_qpack_dyn_entry::name
u8 name[QUIC_QPACK_DYN_MAX_NAME]
entry name bytes
Definition
dyntable.h:18
quic_qpack_dyn_entry::name_len
usz name_len
bytes used in name
Definition
dyntable.h:20
quic_qpack_dyn
RFC 9204 3.2.
Definition
dyntable.h:26
quic_qpack_dyn::ring
quic_qpack_dyn_entry ring[QUIC_QPACK_DYN_MAX_ENTRIES]
entry storage
Definition
dyntable.h:27
quic_qpack_dyn::capacity
usz capacity
maximum allowed size in bytes
Definition
dyntable.h:32
quic_qpack_dyn::dropped
u64 dropped
absolute index of the oldest live entry
Definition
dyntable.h:30
quic_qpack_dyn::count
usz count
number of live entries
Definition
dyntable.h:29
quic_qpack_dyn::size
usz size
sum of entry sizes (RFC 9204 3.2.1)
Definition
dyntable.h:31
quic_qpack_dyn::head
usz head
physical slot of the oldest live entry
Definition
dyntable.h:28
quic_qpack_field
A QPACK field line's (name, value) pair as borrowed views (encoder input / decoder table lookups).
Definition
field.h:8
usz
u64 usz
unsigned size (size_t equivalent)
Definition
syscall.h:19
u8
unsigned char u8
unsigned 8-bit integer / byte
Definition
syscall.h:17
u64
unsigned long u64
unsigned 64-bit integer
Definition
syscall.h:12
app
qpack
qpack
dyntable.h
Generated by
1.16.1