wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
control.h
1#ifndef H3_CONTROL_H
2#define H3_CONTROL_H
3
5
6/* RFC 9114 6.2.1/7.2.4/5.2: the HTTP/3 control stream, SETTINGS ordering, and
7 * GOAWAY graceful shutdown. A peer opens at most one control stream which is
8 * never closed; its first frame must be SETTINGS (once); GOAWAY ids are
9 * monotonically non-increasing and forbid new requests at or above the
10 * limit. Any violation latches a connection error (terminal). */
11
14typedef enum {
15 H3_ERR_NONE = 0,
16 H3_ERR_STREAM_CREATION, /* 2nd control stream */
17 H3_ERR_CLOSED_CRITICAL, /* control stream closed */
18 H3_ERR_MISSING_SETTINGS, /* first control frame not SETTINGS */
19 H3_ERR_FRAME_UNEXPECTED, /* a second SETTINGS */
20 H3_ERR_ID /* GOAWAY id increased */
21} h3_error;
22
33
34void h3_control_init(h3_control* c);
35
36/* A peer opened its control stream. The second one is a STREAM_CREATION error.
37 */
38void h3_control_open(h3_control* c);
39
40/* The control stream closed: a CLOSED_CRITICAL_STREAM error. */
41void h3_control_closed(h3_control* c);
42
43/* A control-stream frame arrived; is_settings marks the SETTINGS type. The
44 * first frame must be SETTINGS (else MISSING_SETTINGS); a later SETTINGS is
45 * FRAME_UNEXPECTED. */
46void h3_control_frame(h3_control* c, int is_settings);
47
48/* A GOAWAY with `id` arrived. Accepted if not greater than a prior GOAWAY id;
49 * an increase is an ID error. */
50void h3_control_goaway(h3_control* c, u64 id);
51
52/* Whether a new request with `id` may be accepted: not after a GOAWAY whose
53 * limit it reaches (RFC 9114 5.2). Existing requests are unaffected. */
54int h3_control_accept_request(const h3_control* c, u64 id);
55
56#endif
RFC 9114 6.2.1/7.2.4/5.2: this connection's control-stream state — whether it is open,...
Definition control.h:26
u8 goaway_seen
a GOAWAY has been received
Definition control.h:29
h3_error error
latched; nonzero means the connection failed
Definition control.h:31
u8 settings_seen
SETTINGS was the first control frame.
Definition control.h:28
u64 goaway_limit
highest request id still accepted is below this
Definition control.h:30
u8 control_open
a control stream is open
Definition control.h:27
Linux direct syscalls.
unsigned char u8
unsigned 8-bit integer / byte
Definition types.h:18
unsigned long u64
unsigned 64-bit integer
Definition types.h:13