wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
enc_stream.h
1#ifndef QPACKDYN_ENC_STREAM_H
2#define QPACKDYN_ENC_STREAM_H
3
4#include "app/qpack/qpack/dyntable.h"
5
6/* RFC 9204 4.3. Decode the one encoder-stream instruction at buf's head and
7 * apply it to t: Set Dynamic Table Capacity (4.3.1, bounded by the server's
8 * advertised max, 5), Insert With Name Reference (4.3.2, static or dynamic
9 * name), Insert With Literal Name (4.3.3) or Duplicate (4.3.4). Returns the
10 * bytes consumed; 0 with *err untouched while the instruction is not whole
11 * in buf yet; 0 with *err = QPACK_ENCODER_STREAM_ERROR when it is invalid --
12 * a capacity past max, an entry larger than the capacity, a name/duplicate
13 * reference to no live entry, or a bad string. */
14usz qdyn_enc_apply(wired_span buf, qpack_dyn* t, u64 max, u16* err);
15
23#define QDYN_ENCRX_CAP 49152
24
31typedef struct {
32 u8 buf[QDYN_ENCRX_CAP];
34 u8 have[QDYN_ENCRX_CAP / 8];
44
45/* Start holding stream_id's bytes (0: none), dropping anything held. */
46void qdyn_encrx_take(qdyn_encrx* rx, u64 stream_id);
47
48/* Land d at stream offset off of the held stream. While unidentified, once
49 * the leading type varint is whole: the encoder type (RFC 9204 4.2) claims
50 * the stream, any other type lets it go (qdyn_encrx_take(rx, 0)). Once
51 * claimed, apply every whole instruction now contiguous from base to t.
52 * Returns 1 ok, 0 with *err = QPACK_ENCODER_STREAM_ERROR when a claimed
53 * stream's d reaches past the window (only a flow-control violation can) or
54 * an instruction is invalid (qdyn_enc_apply). */
55int qdyn_encrx_feed(
56 qdyn_encrx* rx, u64 off, wired_span d, qpack_dyn* t, u64 max, u16* err);
57
58/* RFC 9000 4.1 / 19.10: the claimed encoder stream's flow-control limit --
59 * base + QDYN_ENCRX_CAP, which grows only as instructions are consumed. */
60u64 qdyn_encrx_credit(const qdyn_encrx* rx);
61
62#endif
RFC 9204 4.2 / RFC 9000 2.2: the peer's encoder stream reassembled from stream offset 0,...
Definition enc_stream.h:31
usz hi
buf/have bytes past the last received one are all unused
Definition enc_stream.h:36
usz type_len
the type varint's length (RFC 9000 16 allows a non-minimal one) once stream_id is known to be the enc...
Definition enc_stream.h:42
u8 buf[QDYN_ENCRX_CAP]
received bytes from stream offset base
Definition enc_stream.h:32
u8 have[QDYN_ENCRX_CAP/8]
bit i (have[i / 8] >> i % 8) set where buf[i] holds a received byte
Definition enc_stream.h:34
u64 base
stream offset of buf[0]; everything below is consumed
Definition enc_stream.h:35
u64 stream_id
the candidate or claimed encoder stream (0: none – never a client uni id)
Definition enc_stream.h:39
RFC 9204 3.2.
Definition dyntable.h:31
Read-only view of a byte range.
Definition span.h:30
u64 usz
unsigned size (size_t equivalent)
Definition types.h:20
unsigned short u16
unsigned 16-bit integer
Definition types.h:17
unsigned char u8
unsigned 8-bit integer / byte
Definition types.h:18
unsigned long u64
unsigned 64-bit integer
Definition types.h:13