ProtoCore
v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
h3_server.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 h3_server.h
6
* @brief Bridge between the HTTP/3 server (protocore_quic_server) and the server's request pipeline.
7
*
8
* protocore_quic_server hands out a completed request as semantic fields. This module maps those fields
9
* into the reserved dispatch slot's HttpReq, installs a response sink that frames the reply back
10
* onto the originating QUIC stream, and runs the route table. The handler path is the one every
11
* other protocol takes: send_text() writes through the sink rather than a pcb.
12
*
13
* The h2 side of the same seam is http2/h2_server.h.
14
*
15
* @author Douglas Quigg (dstroy0)
16
* @date 2026
17
*/
18
19
#ifndef PROTOCORE_H3_SERVER_H
20
#define PROTOCORE_H3_SERVER_H
21
22
#include "
protocore_config.h
"
// the entry point: the enable gate below, and the widths
23
24
#if PROTOCORE_ENABLE_HTTP3
25
26
PROTOCORE_BEGIN_DECLS
27
28
#include "
network_drivers/presentation/http/http3/quic_server/quic_server.h
"
// QuicServerRequestFn: the seam this fills
29
30
/**
31
* @brief The request seam protocore_quic_server_begin() is handed.
32
*
33
* Maps @p method, @p path, @p authority and @p body onto the reserved dispatch slot and runs the
34
* route table. The slot is released on return, so a handler that sends nothing leaves the stream
35
* open. @p app is unused: the route table and the slot pools are single global owners.
36
*/
37
/** @brief RFC 9114: the QUIC connection and stream one request occupies. */
38
typedef
struct
39
{
40
uint32_t conn_id;
///< the QUIC connection a response routes back on
41
uint64_t stream_id;
///< the stream it is written on
42
} H3StreamRef;
43
44
/** @brief RFC 9114 sec 4.3.1 request pseudo-headers, and the body that follows them. */
45
typedef
struct
46
{
47
const
char
*method;
///< the request method
48
const
char
*path;
///< its path, query included
49
const
char
*authority;
///< its :authority, mapped to Host
50
const
uint8_t *body;
///< its body bytes
51
size_t
body_len;
///< how many
52
} H3ReqArgs;
53
54
/** @brief Where random bytes are drawn. */
55
typedef
struct
56
{
57
uint8_t *out;
///< where rng writes
58
size_t
len;
///< how many bytes it draws
59
} H3RngArgs;
60
61
/**
62
* @brief The HTTP/3 request bridge: a QUIC stream's request, run through the route table.
63
*
64
* A caller sets the members a call takes and invokes it through ::H3Server.
65
*
66
* @var H3ServerNs::stream the connection and stream a request arrived on
67
* @var H3ServerNs::req the request that stream carried
68
* @var H3ServerNs::rng_args where random bytes are drawn
69
* @var H3ServerNs::request map the request onto the reserved dispatch slot and run it
70
* @var H3ServerNs::rng fill rng_args.out with rng_args.len random bytes from the device source
71
*/
72
typedef
struct
73
{
74
H3StreamRef stream;
///< the connection and stream a request arrived on
75
H3ReqArgs req;
///< the request that stream carried
76
H3RngArgs rng_args;
///< where random bytes are drawn
77
78
void (*
const
request)(uint8_t *work);
79
void (*
const
rng)(uint8_t *work);
80
} H3ServerNs;
81
82
/** @brief The one symbol this module exports. */
83
extern
H3ServerNs H3Server;
84
85
// The QUIC server's seam dictates these two shapes, so they stay plain functions and carry their
86
// arguments onto the handle before the call that does the work.
87
void
protocore_h3_server_request(
void
*app, uint32_t conn_id, uint64_t stream_id,
const
char
*method,
const
char
*path,
88
const
char
*authority,
const
uint8_t *body,
size_t
body_len);
89
90
/**
91
* @brief Fill @p out with @p len random bytes for QuicServerConfig::rng.
92
*
93
* The hardware TRNG on device, a deterministic PRNG on host. Keys the ephemeral X25519 exchange,
94
* the ServerHello random, and the connection ids.
95
*/
96
void
protocore_h3_server_rng(uint8_t *out,
size_t
len);
97
98
PROTOCORE_END_DECLS
99
100
#endif
// PROTOCORE_ENABLE_HTTP3
101
102
#endif
// PROTOCORE_H3_SERVER_H
protocore_config.h
quic_server.h
PROTOCORE_BEGIN_DECLS
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition
types.h:96
PROTOCORE_END_DECLS
#define PROTOCORE_END_DECLS
Definition
types.h:97
src
network_drivers
presentation
http
http3
h3_server
h3_server.h
Generated by
1.9.8