wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
qpackenc.h File Reference

RFC 9204 2.1 / 3.2 / 4.3.3 / 4.4. More...

#include "app/qpack/qpack/dyntable.h"
#include "app/qpack/qpack/field.h"

Go to the source code of this file.

Data Structures

struct  qpackenc_state
 One connection's QPACK encoder-side state. More...
struct  qpackenc_plan
 RFC 9204 4.3.3 / 3.2.5. More...

Functions

void qpackenc_init (qpackenc_state *st, u64 capacity)
 RFC 9204 3.2: initialise an empty encoder-side table with the given byte capacity (this server's own SETTINGS_QPACK_MAX_TABLE_CAPACITY) and zeroed counters.
int qpackenc_plan_field (qpackenc_state *st, const qpack_field *f, qpackenc_plan *out)
 RFC 9204 2.1 / 4.3.3.
void qpackenc_note_sent (qpackenc_state *st, u64 ric)
 RFC 9204 4.4.1: record that a field section referencing the dynamic table (Required Insert Count ric > 0) was just sent – a no-op when ric == 0 (nothing to acknowledge).
int qpackenc_on_increment (qpackenc_state *st, u64 increment)
 RFC 9204 4.4.3: apply a received Insert Count Increment.
int qpackenc_on_section_ack (qpackenc_state *st)
 RFC 9204 4.4.1: apply a received Section Acknowledgment.

Detailed Description

RFC 9204 2.1 / 3.2 / 4.3.3 / 4.4.

The server's OWN QPACK encoder-side state: the dynamic table it is actively inserting into (mirrors, byte for byte, what it has told the peer's decoder via the encoder stream), plus the Known Received Count / Total Inserts / pending-acknowledgment bookkeeping RFC 9204 2.1.4 requires an encoder to track. Separate from wired_h3srv_state.qdyn, which holds the PEER's encoder-stream instructions applied to THIS endpoint's decoder-side table (RFC 9204 3.2) – an endpoint's send and receive dynamic tables are independent (9204-006).

Function Documentation

◆ qpackenc_init()

void qpackenc_init ( qpackenc_state * st,
u64 capacity )

RFC 9204 3.2: initialise an empty encoder-side table with the given byte capacity (this server's own SETTINGS_QPACK_MAX_TABLE_CAPACITY) and zeroed counters.

Parameters
stthe state to initialise
capacitythis server's own advertised dynamic table capacity in bytes (0 disables dynamic-table use entirely)

◆ qpackenc_note_sent()

void qpackenc_note_sent ( qpackenc_state * st,
u64 ric )

RFC 9204 4.4.1: record that a field section referencing the dynamic table (Required Insert Count ric > 0) was just sent – a no-op when ric == 0 (nothing to acknowledge).

Call once per field section built.

◆ qpackenc_on_increment()

int qpackenc_on_increment ( qpackenc_state * st,
u64 increment )

RFC 9204 4.4.3: apply a received Insert Count Increment.

Validates via qpack_incr_valid before applying, so an invalid increment (zero, or one that would push known_received past total_inserts) leaves st unchanged.

Returns
1 if applied, 0 if increment was invalid (QPACK_DECODER_STREAM_ ERROR territory on the caller's side)

◆ qpackenc_on_section_ack()

int qpackenc_on_section_ack ( qpackenc_state * st)

RFC 9204 4.4.1: apply a received Section Acknowledgment.

Validates via qpack_section_ack_valid before applying, so an acknowledgment with no pending field section left unchanged.

Returns
1 if applied (pending_acks decremented), 0 if invalid (QPACK_DECODER_STREAM_ERROR territory on the caller's side)

◆ qpackenc_plan_field()

int qpackenc_plan_field ( qpackenc_state * st,
const qpack_field * f,
qpackenc_plan * out )

RFC 9204 2.1 / 4.3.3.

Plan how to encode field f against st's dynamic table: if an entry with f's exact (name, value) is already live, reference it (no new instruction); else, if st's capacity allows the entry to fit, insert it (qpack_dyn_insert), generate its Insert With Literal Name instruction (qdyn_insert_literal) and advance total_inserts; else leave used_dynamic 0 so the caller falls back to a static/literal field line (this happens whenever capacity is 0, keeping the pre-existing static-or-literal behavior for the default advertised capacity).

Parameters
stthe encoder-side state; dyn and total_inserts are updated on a fresh insert
fthe (name, value) pair to encode a reference for
outthe plan, always fully written
Returns
1 always (the plan itself carries the fallback outcome)