ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
sse.h
Go to the documentation of this file.
1// ProtoCore v1.0.16 - Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file sse.h
6 * @brief Layer 5 (Session) - opening and closing an event stream.
7 *
8 * RFC 4254 sec 5 states the shape a multiplexed stream takes: a side that opens "allocates a local
9 * number for the channel", and a party "may then reuse the channel number" once it is closed.
10 * Sequencing that open and that close is this layer's.
11 *
12 * RFC 9293 sec 3.6 MUST-12 is why the close is one call rather than each caller's checklist: "If
13 * the local TCP connection is closed by the remote side due to a FIN or RST received from the
14 * remote side, then the local application MUST be informed whether it closed normally or was
15 * aborted."
16 *
17 * @author Douglas Quigg (dstroy0)
18 * @date 2026
19 */
20
21#ifndef PROTOCORE_SESSION_SSE_H
22#define PROTOCORE_SESSION_SSE_H
23
24#include "protocore_config.h"
25
26#if PROTOCORE_ENABLE_SSE
27
29
30/**
31 * @brief Opening and closing one event stream.
32 *
33 * @var SessionSseNs::ok whether the stream opened, or whether a close had one to release
34 * @var SessionSseNs::open take a stream for the named connection and run the route's connect
35 * @var SessionSseNs::close release the stream bound to the named connection
36 *
37 * No storage and no members naming the connection: the caller has already named it on ::Sse, and
38 * this sequences what happens to it. A second copy would be a second answer to "which connection".
39 */
40typedef struct
41{
42 proto_bool ok; ///< whether the stream opened, or whether a close had one to release
43} SessionSseVars;
44
45/** @brief The operands and the outcome. */
46extern SessionSseVars SessionSseV;
47
48/** @brief The entries. */
49typedef struct
50{
51 void (*const open)(uint8_t *work);
52 void (*const close)(uint8_t *work);
53} SessionSseNs;
54
55// What the table binds, defined once in the .c and taking one parameter each: everything
56// else an entry needs is an operand in SessionSseV or a region of the borrow at a fixed offset.
57void protocore_session_sse_open(uint8_t *work);
58void protocore_session_sse_close(uint8_t *work);
59
60// `static const`, initialised HERE rather than `extern` against a definition in the .c: a
61// const object whose initializer every translation unit can see is a COMPILE-TIME FACT, so
62// `SessionSse.open(work)` resolves to a named function and becomes a DIRECT call. An extern table
63// leaves the call indirect and the symbol live at every level, -O2 -flto included.
64static const SessionSseNs SessionSse __attribute__((unused)) = {
65 .open = protocore_session_sse_open,
66 .close = protocore_session_sse_close,
67};
68
70
71#endif // PROTOCORE_ENABLE_SSE
72
73#endif
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition types.h:96
_Bool proto_bool
The truth value.
Definition types.h:64
#define PROTOCORE_END_DECLS
Definition types.h:97