|
wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
|
draft-ietf-moq-transport-19 3.3 / 5.1: session establishment/control- stream discipline, and 5.1 SUBSCRIBE/PUBLISH lifecycle. More...
#include "common/platform/sys/syscall.h"Go to the source code of this file.
Data Structures | |
| struct | moqsess |
| Session state including the GOAWAY-lifecycle flags (5.1: GOAWAY may be sent/received at most once per direction; violations and shutdown decisions read these). More... | |
| struct | moqsub |
| One subscription's lifecycle state plus the flags moqsub_step keeps. More... | |
Macros | |
| #define | MOQSESS_CLOSE_NONE 0 |
| Close reasons a step can produce (0 = still open). | |
| #define | MOQSESS_CLOSE_PROTOCOL_VIOLATION 1 |
| Close with PROTOCOL_VIOLATION: a control-stream or GOAWAY rule was broken (e.g. | |
| #define | MOQSESS_CLOSE_INVALID_REQUEST_ID 2 |
| Close with INVALID_REQUEST_ID: wrong-parity or reused Request ID. | |
| #define | MOQSESS_CLOSE_GOAWAY_TIMEOUT 3 |
| Close with GOAWAY_TIMEOUT: the peer did not close after GOAWAY. | |
| #define | MOQSESS_CLOSE_NO_ERROR 4 |
| Clean close (NO_ERROR); no moqsess_step event produces it. | |
| #define | MOQSUB_TERM_NONE 0 |
| Terminated reasons (informational; a subscription's own close does not imply the session closes). | |
| #define | MOQSUB_TERM_STOP_SENDING 1 |
| Cancelled via STOP_SENDING. | |
| #define | MOQSUB_TERM_PUBLISH_DONE 2 |
| Publisher finished normally (PUBLISH_DONE). | |
| #define | MOQSUB_TERM_ERROR 3 |
| REQUEST_ERROR (reject or fault). | |
| #define | MOQSUB_TERM_EARLY_FIN 4 |
| Peer FIN'd before responding (not set by moqsub_step). | |
| #define | MOQSUB_TERM_DUP_RESPONSE 5 |
| A second response arrived; moqsub_step flags session_fault instead and never sets this. | |
Enumerations | |
| enum | moqsess_state { MOQSESS_IDLE = 0 , MOQSESS_SETUP_HALF = 1 , MOQSESS_ESTABLISHED = 2 , MOQSESS_CLOSED = 3 } |
| Session state (draft 3.3: each endpoint opens one uni control stream and sends SETUP first; the session is established once both sides have done so). | |
| enum | moqsess_event { MOQSESS_EV_SENT_SETUP = 0 , MOQSESS_EV_RECV_SETUP = 1 , MOQSESS_EV_CTRL_CLOSED = 2 , MOQSESS_EV_UNKNOWN_UNI = 3 , MOQSESS_EV_SECOND_CTRL = 4 , MOQSESS_EV_MALFORMED_CTRL = 5 , MOQSESS_EV_SEND_GOAWAY = 6 , MOQSESS_EV_RECV_GOAWAY = 7 , MOQSESS_EV_RECV_GOAWAY_BAD_URI = 8 , MOQSESS_EV_GOAWAY_TIMEOUT = 9 , MOQSESS_EV_BAD_FIRST = 10 , MOQSESS_EV_BAD_REQUEST_ID = 11 } |
| Events the run layer feeds in as it decodes the wire. | |
| enum | moqsub_state { MOQSUB_IDLE = 0 , MOQSUB_PENDING = 1 , MOQSUB_ESTABLISHED = 2 , MOQSUB_TERMINATED = 3 } |
| One subscription's state (draft 5.1: SUBSCRIBE/PUBLISH -> response -> termination, one instance per request stream). | |
| enum | moqsub_role { MOQSUB_ROLE_SUBSCRIBER = 0 , MOQSUB_ROLE_PUBLISHER = 1 } |
| Which side opened the request stream with its First message. | |
| enum | moqsub_event { MOQSUB_EV_OPEN = 0 , MOQSUB_EV_OK = 1 , MOQSUB_EV_ERROR = 2 , MOQSUB_EV_UPDATE = 3 , MOQSUB_EV_STOP_SENDING = 4 , MOQSUB_EV_PUBLISH_DONE = 5 , MOQSUB_EV_FIN_RESP = 6 , MOQSUB_EV_FIN_REQ = 7 } |
| Events moqsub_step applies, each sent or received on the request stream. | |
Functions | |
| void | moqsess_init (moqsess *s) |
| Zero-initialize (equivalent to = {0}; provided for callers that build the struct at runtime rather than with a static initializer). | |
| int | moqsess_step (moqsess *s, moqsess_event ev) |
| Apply one event. | |
| int | moqsess_should_buffer (const moqsess *s) |
| True while SETUP has not yet completed both directions: requests and data streams that arrive now must be buffered, not delivered to the application (3.3 / draft 5.1 buffering discipline). | |
| int | moqsess_established (const moqsess *s) |
| True once SETUP is fully established (both directions done). | |
| int | moqsess_may_reject_request (const moqsess *s) |
| True if a newly arriving request MAY be rejected with GOING_AWAY (either side sent or received GOAWAY: draft 5.1 GOAWAY discipline). | |
| int | moqsess_suppress_own_requests (const moqsess *s) |
| True if this endpoint SHOULD NOT initiate new requests of its own (GOAWAY received on the control stream: draft 5.1, SHOULD NOT). | |
| void | moqsub_init (moqsub *s, moqsub_role role) |
| Initialize a fresh subscription: role is fixed by which message (SUBSCRIBE vs PUBLISH) opened the request stream. | |
| int | moqsub_step (moqsub *s, moqsub_event ev) |
| Apply one event. | |
| int | moqsub_established (const moqsub *s) |
| True once the subscription is Established (SS10.6/10.9 semantics apply: REQUEST_UPDATE legal, Object forwarding gated by moqsub_may_forward). | |
| int | moqsub_terminated (const moqsub *s) |
| True once Terminated (state machine done; s->term_reason explains why). | |
| int | moqsub_may_forward (const moqsub *s, int forward) |
| Forward State gate (5.1 / SS10.2 FORWARD parameter, subscribe notes decision 9): Object sending toward this subscription is permitted only while pending or established AND not yet errored. | |
| int | moqsub_may_send_publish_done (usz open_stream_count) |
| PUBLISH_DONE precondition (draft 8.9): a publisher may only send PUBLISH_DONE once every data stream it opened for this subscription has been closed. | |
draft-ietf-moq-transport-19 3.3 / 5.1: session establishment/control- stream discipline, and 5.1 SUBSCRIBE/PUBLISH lifecycle.
Pure state machines: callers (the run layer, decoding wire bytes via moqctl) drive these with events; no wire codec is invoked here.
| #define MOQSESS_CLOSE_PROTOCOL_VIOLATION 1 |
Close with PROTOCOL_VIOLATION: a control-stream or GOAWAY rule was broken (e.g.
a second GOAWAY, a malformed control message).
| #define MOQSUB_TERM_NONE 0 |
Terminated reasons (informational; a subscription's own close does not imply the session closes).
0 = not terminated.
| int moqsess_step | ( | moqsess * | s, |
| moqsess_event | ev ) |
Apply one event.
Returns the resulting close_reason (MOQSESS_CLOSE_ NONE if the session is still open). Once state == CLOSED, further events are no-ops (idempotent close).
| int moqsub_may_forward | ( | const moqsub * | s, |
| int | forward ) |
Forward State gate (5.1 / SS10.2 FORWARD parameter, subscribe notes decision 9): Object sending toward this subscription is permitted only while pending or established AND not yet errored.
forward is the negotiated FORWARD value (0 = never send Objects, 1 = normal gate).
| int moqsub_may_send_publish_done | ( | usz | open_stream_count | ) |
PUBLISH_DONE precondition (draft 8.9): a publisher may only send PUBLISH_DONE once every data stream it opened for this subscription has been closed.
Callers pass their own open-stream count; this only encodes the gate, not the count itself.
| int moqsub_step | ( | moqsub * | s, |
| moqsub_event | ev ) |
Apply one event.
Returns 1 if the event was legal for the current state (state/flags updated), 0 if it violates the subscribe discipline (e.g. a duplicate response) – callers read s->session_fault to distinguish a subscription-local termination from a session-level protocol error.