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

HTTP/3 framing (RFC 9114 sec 7) over QUIC varints. More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  H3FrameHeader
 A parsed frame header (payload begins at buf + header_len). More...
 
struct  H3Settings
 The settings we track, with defaults after H3FrameNs::settings_defaults. More...
 
struct  H3FrameNs
 Dispatch table. Addressed by offset, so the layout is asserted below. More...
 

Macros

#define H3_DATA   0x00
 HTTP/3 frame types (RFC 9114 sec 7.2 / 11.2.1).
 
#define H3_HEADERS   0x01
 
#define H3_CANCEL_PUSH   0x03
 
#define H3_SETTINGS   0x04
 
#define H3_PUSH_PROMISE   0x05
 
#define H3_GOAWAY   0x07
 
#define H3_MAX_PUSH_ID   0x0d
 
#define H3_NO_ERROR   0x0100
 HTTP/3 error codes (RFC 9114 sec 8.1).
 
#define H3_GENERAL_PROTOCOL_ERROR   0x0101
 
#define H3_INTERNAL_ERROR   0x0102
 
#define H3_STREAM_CREATION_ERROR   0x0103
 
#define H3_CLOSED_CRITICAL_STREAM   0x0104
 
#define H3_FRAME_UNEXPECTED   0x0105
 
#define H3_FRAME_ERROR   0x0106
 
#define H3_EXCESSIVE_LOAD   0x0107
 
#define H3_ID_ERROR   0x0108
 
#define H3_SETTINGS_ERROR   0x0109
 
#define H3_MISSING_SETTINGS   0x010a
 
#define H3_REQUEST_REJECTED   0x010b
 
#define H3_REQUEST_CANCELLED   0x010c
 
#define H3_REQUEST_INCOMPLETE   0x010d
 
#define H3_MESSAGE_ERROR   0x010e
 
#define H3_CONNECT_ERROR   0x010f
 
#define H3_VERSION_FALLBACK   0x0110
 
#define H3_SETTINGS_QPACK_MAX_TABLE_CAPACITY   0x01
 SETTINGS parameter identifiers (RFC 9114 sec 7.2.4.1 + RFC 9204).
 
#define H3_SETTINGS_MAX_FIELD_SECTION_SIZE   0x06
 
#define H3_SETTINGS_QPACK_BLOCKED_STREAMS   0x07
 

Functions

 PROTOCORE_NS_LAYOUT (H3FrameNs, parse_header, write_header, type_reserved, settings_defaults, parse_settings, build_data, build_headers, build_settings, build_goaway)
 
proto_bool protocore_h3_frame_parse_header (uint8_t *work, const uint8_t *buf, size_t len, H3FrameHeader *out)
 Parse a frame header (type + length varints) at buf. false if .
 
size_t protocore_h3_frame_write_header (uint8_t *work, uint8_t *out, size_t cap, uint64_t type, uint64_t length)
 Write a frame header (type + length varints). bytes written, or 0 .
 
proto_bool protocore_h3_frame_type_reserved (uint8_t *work, uint64_t type)
 True if type is a reserved HTTP/2 frame type (0x02/0x06/0x08/0x09) .
 
void protocore_h3_frame_settings_defaults (uint8_t *work, H3Settings *s)
 Fill s with the RFC default settings.
 
proto_bool protocore_h3_frame_parse_settings (uint8_t *work, const uint8_t *payload, size_t len, H3Settings *s)
 Apply a SETTINGS payload (id, value varint pairs) to s. false if .
 
size_t protocore_h3_frame_build_data (uint8_t *work, uint8_t *out, size_t cap, const uint8_t *data, size_t len)
 DATA frame wrapping data.
 
size_t protocore_h3_frame_build_headers (uint8_t *work, uint8_t *out, size_t cap, const uint8_t *block, size_t len)
 HEADERS frame wrapping a QPACK-encoded field section block.
 
size_t protocore_h3_frame_build_settings (uint8_t *work, uint8_t *out, size_t cap, const uint64_t *ids, const uint64_t *vals, size_t n)
 SETTINGS frame from n (id, value) pairs.
 
size_t protocore_h3_frame_build_goaway (uint8_t *work, uint8_t *out, size_t cap, uint64_t stream_id)
 GOAWAY frame carrying stream_id (RFC 9114 sec 7.2.6).
 

Variables

PROTOCORE_NS H3FrameNs H3Frame PROTOCORE_UNUSED
 Module namespace.
 

Detailed Description

HTTP/3 framing (RFC 9114 sec 7) over QUIC varints.

An HTTP/3 frame is Type (varint) | Length (varint) | Frame Payload. This module parses that header and builds the frames a server uses (DATA, HEADERS carrying a QPACK field section, SETTINGS, GOAWAY), reads a SETTINGS payload, and flags the reserved HTTP/2 frame types that must be treated as a connection error. Pure and host-tested.

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 h3_frame.h.

Macro Definition Documentation

◆ H3_DATA

#define H3_DATA   0x00

HTTP/3 frame types (RFC 9114 sec 7.2 / 11.2.1).

Definition at line 33 of file h3_frame.h.

◆ H3_HEADERS

#define H3_HEADERS   0x01

Definition at line 34 of file h3_frame.h.

◆ H3_CANCEL_PUSH

#define H3_CANCEL_PUSH   0x03

Definition at line 35 of file h3_frame.h.

◆ H3_SETTINGS

#define H3_SETTINGS   0x04

Definition at line 36 of file h3_frame.h.

◆ H3_PUSH_PROMISE

#define H3_PUSH_PROMISE   0x05

Definition at line 37 of file h3_frame.h.

◆ H3_GOAWAY

#define H3_GOAWAY   0x07

Definition at line 38 of file h3_frame.h.

◆ H3_MAX_PUSH_ID

#define H3_MAX_PUSH_ID   0x0d

Definition at line 39 of file h3_frame.h.

◆ H3_NO_ERROR

#define H3_NO_ERROR   0x0100

HTTP/3 error codes (RFC 9114 sec 8.1).

These travel in a CONNECTION_CLOSE of type 0x1d, whose error code comes from the application protocol's space. Sent in the transport variant (0x1c) they would be read against RFC 9000 sec 20.1 instead, where 0x0100-0x01ff is CRYPTO_ERROR plus a TLS alert.

Definition at line 48 of file h3_frame.h.

◆ H3_GENERAL_PROTOCOL_ERROR

#define H3_GENERAL_PROTOCOL_ERROR   0x0101

Definition at line 49 of file h3_frame.h.

◆ H3_INTERNAL_ERROR

#define H3_INTERNAL_ERROR   0x0102

Definition at line 50 of file h3_frame.h.

◆ H3_STREAM_CREATION_ERROR

#define H3_STREAM_CREATION_ERROR   0x0103

Definition at line 51 of file h3_frame.h.

◆ H3_CLOSED_CRITICAL_STREAM

#define H3_CLOSED_CRITICAL_STREAM   0x0104

Definition at line 52 of file h3_frame.h.

◆ H3_FRAME_UNEXPECTED

#define H3_FRAME_UNEXPECTED   0x0105

Definition at line 53 of file h3_frame.h.

◆ H3_FRAME_ERROR

#define H3_FRAME_ERROR   0x0106

Definition at line 54 of file h3_frame.h.

◆ H3_EXCESSIVE_LOAD

#define H3_EXCESSIVE_LOAD   0x0107

Definition at line 55 of file h3_frame.h.

◆ H3_ID_ERROR

#define H3_ID_ERROR   0x0108

Definition at line 56 of file h3_frame.h.

◆ H3_SETTINGS_ERROR

#define H3_SETTINGS_ERROR   0x0109

Definition at line 57 of file h3_frame.h.

◆ H3_MISSING_SETTINGS

#define H3_MISSING_SETTINGS   0x010a

Definition at line 58 of file h3_frame.h.

◆ H3_REQUEST_REJECTED

#define H3_REQUEST_REJECTED   0x010b

Definition at line 59 of file h3_frame.h.

◆ H3_REQUEST_CANCELLED

#define H3_REQUEST_CANCELLED   0x010c

Definition at line 60 of file h3_frame.h.

◆ H3_REQUEST_INCOMPLETE

#define H3_REQUEST_INCOMPLETE   0x010d

Definition at line 61 of file h3_frame.h.

◆ H3_MESSAGE_ERROR

#define H3_MESSAGE_ERROR   0x010e

Definition at line 62 of file h3_frame.h.

◆ H3_CONNECT_ERROR

#define H3_CONNECT_ERROR   0x010f

Definition at line 63 of file h3_frame.h.

◆ H3_VERSION_FALLBACK

#define H3_VERSION_FALLBACK   0x0110

Definition at line 64 of file h3_frame.h.

◆ H3_SETTINGS_QPACK_MAX_TABLE_CAPACITY

#define H3_SETTINGS_QPACK_MAX_TABLE_CAPACITY   0x01

SETTINGS parameter identifiers (RFC 9114 sec 7.2.4.1 + RFC 9204).

Definition at line 67 of file h3_frame.h.

◆ H3_SETTINGS_MAX_FIELD_SECTION_SIZE

#define H3_SETTINGS_MAX_FIELD_SECTION_SIZE   0x06

Definition at line 68 of file h3_frame.h.

◆ H3_SETTINGS_QPACK_BLOCKED_STREAMS

#define H3_SETTINGS_QPACK_BLOCKED_STREAMS   0x07

Definition at line 69 of file h3_frame.h.

Function Documentation

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( H3FrameNs  ,
parse_header  ,
write_header  ,
type_reserved  ,
settings_defaults  ,
parse_settings  ,
build_data  ,
build_headers  ,
build_settings  ,
build_goaway   
)

◆ protocore_h3_frame_parse_header()

proto_bool protocore_h3_frame_parse_header ( uint8_t *  work,
const uint8_t *  buf,
size_t  len,
H3FrameHeader *  out 
)

Parse a frame header (type + length varints) at buf. false if .

Parameters
workPROTOCORE_H3_FRAME_BORROW bytes the caller took. Not held past the call.
bufBuf
lenLen
outOut
Returns
PROTO_TRUE on success.

◆ protocore_h3_frame_write_header()

size_t protocore_h3_frame_write_header ( uint8_t *  work,
uint8_t *  out,
size_t  cap,
uint64_t  type,
uint64_t  length 
)

Write a frame header (type + length varints). bytes written, or 0 .

Parameters
workPROTOCORE_H3_FRAME_BORROW bytes the caller took. Not held past the call.
outOut
capCap
typeType
lengthLength
Returns
The size_t.

◆ protocore_h3_frame_type_reserved()

proto_bool protocore_h3_frame_type_reserved ( uint8_t *  work,
uint64_t  type 
)

True if type is a reserved HTTP/2 frame type (0x02/0x06/0x08/0x09) .

Parameters
workPROTOCORE_H3_FRAME_BORROW bytes the caller took. Not held past the call.
typeType
Returns
PROTO_TRUE on success.

◆ protocore_h3_frame_settings_defaults()

void protocore_h3_frame_settings_defaults ( uint8_t *  work,
H3Settings *  s 
)

Fill s with the RFC default settings.

Parameters
workPROTOCORE_H3_FRAME_BORROW bytes the caller took. Not held past the call.
sS

◆ protocore_h3_frame_parse_settings()

proto_bool protocore_h3_frame_parse_settings ( uint8_t *  work,
const uint8_t *  payload,
size_t  len,
H3Settings *  s 
)

Apply a SETTINGS payload (id, value varint pairs) to s. false if .

Parameters
workPROTOCORE_H3_FRAME_BORROW bytes the caller took. Not held past the call.
payloadPayload
lenLen
sS
Returns
PROTO_TRUE on success.

◆ protocore_h3_frame_build_data()

size_t protocore_h3_frame_build_data ( uint8_t *  work,
uint8_t *  out,
size_t  cap,
const uint8_t *  data,
size_t  len 
)

DATA frame wrapping data.

Parameters
workPROTOCORE_H3_FRAME_BORROW bytes the caller took. Not held past the call.
outOut
capCap
dataData
lenLen
Returns
The size_t.

◆ protocore_h3_frame_build_headers()

size_t protocore_h3_frame_build_headers ( uint8_t *  work,
uint8_t *  out,
size_t  cap,
const uint8_t *  block,
size_t  len 
)

HEADERS frame wrapping a QPACK-encoded field section block.

Parameters
workPROTOCORE_H3_FRAME_BORROW bytes the caller took. Not held past the call.
outOut
capCap
blockBlock
lenLen
Returns
The size_t.

◆ protocore_h3_frame_build_settings()

size_t protocore_h3_frame_build_settings ( uint8_t *  work,
uint8_t *  out,
size_t  cap,
const uint64_t *  ids,
const uint64_t *  vals,
size_t  n 
)

SETTINGS frame from n (id, value) pairs.

Parameters
workPROTOCORE_H3_FRAME_BORROW bytes the caller took. Not held past the call.
outOut
capCap
idsIds
valsVals
nN
Returns
The size_t.

◆ protocore_h3_frame_build_goaway()

size_t protocore_h3_frame_build_goaway ( uint8_t *  work,
uint8_t *  out,
size_t  cap,
uint64_t  stream_id 
)

GOAWAY frame carrying stream_id (RFC 9114 sec 7.2.6).

Parameters
workPROTOCORE_H3_FRAME_BORROW bytes the caller took. Not held past the call.
outOut
capCap
stream_idStream id
Returns
The size_t.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS H3FrameNs H3Frame PROTOCORE_UNUSED
Initial value:
size_t protocore_h3_frame_write_header(uint8_t *work, uint8_t *out, size_t cap, uint64_t type, uint64_t length)
Write a frame header (type + length varints). bytes written, or 0 .
size_t protocore_h3_frame_build_data(uint8_t *work, uint8_t *out, size_t cap, const uint8_t *data, size_t len)
DATA frame wrapping data.
proto_bool protocore_h3_frame_type_reserved(uint8_t *work, uint64_t type)
True if type is a reserved HTTP/2 frame type (0x02/0x06/0x08/0x09) .
size_t protocore_h3_frame_build_goaway(uint8_t *work, uint8_t *out, size_t cap, uint64_t stream_id)
GOAWAY frame carrying stream_id (RFC 9114 sec 7.2.6).
void protocore_h3_frame_settings_defaults(uint8_t *work, H3Settings *s)
Fill s with the RFC default settings.
proto_bool protocore_h3_frame_parse_header(uint8_t *work, const uint8_t *buf, size_t len, H3FrameHeader *out)
Parse a frame header (type + length varints) at buf. false if .
proto_bool protocore_h3_frame_parse_settings(uint8_t *work, const uint8_t *payload, size_t len, H3Settings *s)
Apply a SETTINGS payload (id, value varint pairs) to s. false if .
size_t protocore_h3_frame_build_settings(uint8_t *work, uint8_t *out, size_t cap, const uint64_t *ids, const uint64_t *vals, size_t n)
SETTINGS frame from n (id, value) pairs.
size_t protocore_h3_frame_build_headers(uint8_t *work, uint8_t *out, size_t cap, const uint8_t *block, size_t len)
HEADERS frame wrapping a QPACK-encoded field section block.

Module namespace.

Definition at line 187 of file h3_frame.h.