ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
qpack.h File Reference

QPACK field-section compression for HTTP/3 (RFC 9204). More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  QpackNs
 Dispatch table. Addressed by offset, so the layout is asserted below. More...

Typedefs

typedef embed_bool(* QpackEmitFn) (void *ctx, const char *name, size_t name_len, const char *value, size_t value_len)
 Callback invoked for each decoded header; return false to abort the decode.

Functions

 PROTOCORE_NS_LAYOUT (QpackNs, encode_prefix, encode_header, decode)
size_t protocore_qpack_encode_prefix (const uint8_t *work, uint8_t *out, size_t cap)
 Write the encoded field-section prefix for a static-only section. .
size_t protocore_qpack_encode_header (uint8_t *work, uint8_t *out, size_t cap, const char *name, size_t name_len, const char *value, size_t value_len)
 Encode one header field (server side): a full static match -> .
embed_bool protocore_qpack_decode (uint8_t *work, const uint8_t *block, size_t len, char *scratch, size_t scratch_cap, QpackEmitFn emit, void *ctx)
 Decode a whole QPACK field section (prefix + representations), .

Variables

PROTOCORE_NS QpackNs Qpack PROTOCORE_UNUSED
 Module namespace.

Detailed Description

QPACK field-section compression for HTTP/3 (RFC 9204).

QPACK is HTTP/3's header compression. It reuses RFC 7541's prefix-integer coding and Huffman code (shared here via protocore_hpack_prim.h) and adds a 99-entry static table, an encoded field-section prefix, and its own field-line representations.

This codec is static-table-only and needs no per-connection state: the encoder emits indexed / literal representations against the static table (never inserting into a dynamic table), and it advertises SETTINGS_QPACK_MAX_TABLE_CAPACITY = 0, so a conformant peer's encoder never sends a dynamic-table reference. The decoder therefore rejects (returns false) any representation that references the dynamic table or a non-zero Required Insert Count. Pure, zero heap, host-tested against the RFC 9204 Appendix B.1 worked example.

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.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file qpack.h.

Typedef Documentation

◆ QpackEmitFn

typedef embed_bool(* QpackEmitFn)(void *ctx, const char *name, size_t name_len, const char *value, size_t value_len)

Callback invoked for each decoded header; return false to abort the decode.

Definition at line 39 of file qpack.h.

Function Documentation

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( QpackNs ,
encode_prefix ,
encode_header ,
decode  )

◆ protocore_qpack_encode_prefix()

size_t protocore_qpack_encode_prefix ( const uint8_t * work,
uint8_t * out,
size_t cap )

Write the encoded field-section prefix for a static-only section. .

Parameters
workPROTOCORE_QPACK_BORROW bytes the caller took. Not held past the call.
outOut
capCap
Returns
The size_t.

◆ protocore_qpack_encode_header()

size_t protocore_qpack_encode_header ( uint8_t * work,
uint8_t * out,
size_t cap,
const char * name,
size_t name_len,
const char * value,
size_t value_len )

Encode one header field (server side): a full static match -> .

Parameters
workPROTOCORE_QPACK_BORROW bytes the caller took. Not held past the call.
outOut
capCap
nameName
name_lenName len
valueValue
value_lenValue len
Returns
The size_t.

◆ protocore_qpack_decode()

embed_bool protocore_qpack_decode ( uint8_t * work,
const uint8_t * block,
size_t len,
char * scratch,
size_t scratch_cap,
QpackEmitFn emit,
void * ctx )

Decode a whole QPACK field section (prefix + representations), .

Parameters
workPROTOCORE_QPACK_BORROW bytes the caller took. Not held past the call.
blockBlock
lenLen
scratchcaller buffer holding one header's name+value during each emit call
scratch_capScratch cap
emitEmit
ctxCtx
Returns
EMBED_TRUE on success.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS QpackNs Qpack PROTOCORE_UNUSED
Initial value:
= {.encode_prefix = protocore_qpack_encode_prefix,
size_t protocore_qpack_encode_header(uint8_t *work, uint8_t *out, size_t cap, const char *name, size_t name_len, const char *value, size_t value_len)
Encode one header field (server side): a full static match -> .
size_t protocore_qpack_encode_prefix(const uint8_t *work, uint8_t *out, size_t cap)
Write the encoded field-section prefix for a static-only section. .
embed_bool protocore_qpack_decode(uint8_t *work, const uint8_t *block, size_t len, char *scratch, size_t scratch_cap, QpackEmitFn emit, void *ctx)
Decode a whole QPACK field section (prefix + representations), .

Module namespace.

Definition at line 89 of file qpack.h.