ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
network.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 network.h
6 * @brief Layer 3 (Network) - the internet layer: the modules it carries, and its bring-up call.
7 *
8 * RFC 1122 sec 3 "INTERNET LAYER PROTOCOLS" is what sits here: IP (RFC 791) for v4 and RFC 8200
9 * for v6, with address assignment and ICMP beside them. The platform's TCP/IP stack holds the route
10 * table and performs RFC 1122 sec 3.3.1 "Routing Outbound Datagrams" itself, the Local/Remote
11 * Decision (sec 3.3.1.1) and Gateway Selection (sec 3.3.1.2) included, so ::NetworkNs::init runs no
12 * routing of its own. The layer names the modules a caller reaches through it.
13 *
14 * The module exports one symbol, @ref network. Everything in network.c has internal linkage.
15 *
16 * @author Douglas Quigg (dstroy0)
17 * @date 2026
18 */
19
20#ifndef PROTOCORE_NETWORK_H
21#define PROTOCORE_NETWORK_H
22
24#include "shared/ip/ip.h"
25
26#include "protocore_config.h" // first: the feature flags the includes below are gated on
27#if PROTOCORE_ENABLE_FORWARD
28#include "network_drivers/network/forward/forward.h" // ForwardNs: carried below as network.forward
29#endif
30
32
33/**
34 * @brief The internet layer (RFC 1122 sec 3), and the modules it carries.
35 *
36 * A caller invokes a call through ::network, passing the handle's own @ref internal, and reaches a
37 * carried module by its member: `network.ip->parse(network.ip->internal)`.
38 *
39 * @var NetworkNs::dns name resolution: the RESOLVER and the NAME SERVER (RFC 1034 sec 2.4
40 * "Elements of the DNS", the messages between them RFC 1035 sec 4)
41 * @var NetworkNs::forward the forwarding plane: the ingress ACL, the policy routes, the fan-out
42 * (RFC 1812 sec 5.2.1 "Forwarding Algorithm")
43 * @var NetworkNs::ip an internet address as a value: parse, format, classify, compare
44 * (RFC 791 sec 1.4 addressing, RFC 8200 for v6)
45 * @var NetworkNs::init bring the layer up. It runs no work: the platform stack holds the route
46 * table and selects the path (RFC 791 sec 1.4 "Operation")
47 *
48 * Each carried module is named by pointer; one behind a feature flag is declared under that flag,
49 * so the layer names only what the image already contains.
50 *
51 * No argument members: init reads nothing. No result members: init reports nothing.
52 * No storage member: the layer holds nothing of its own, each carried module owns its state.
53 */
54typedef struct
55{
56#if PROTOCORE_ENABLE_DNS
57 DnsNs *dns; ///< the RESOLVER and the NAME SERVER (RFC 1034 sec 2.4)
58#endif
59#if PROTOCORE_ENABLE_FORWARD
60 ForwardNs *forward; ///< the forwarding plane (RFC 1812 sec 5)
61#endif
62 IpNs *ip; ///< an internet address as a value (RFC 791, RFC 8200)
64
65/** @brief The operands and the outcome. */
67
68/** @brief The entries. */
69typedef struct
70{
71 void (*const init)(uint8_t *work);
72} NetworkNs;
73
74// What the table binds, defined once in the .c and taking one parameter each: everything
75// else an entry needs is an operand in networkV or a region of the borrow at a fixed offset.
76void protocore_network_init(uint8_t *work);
77
78// `static const`, initialised HERE rather than `extern` against a definition in the .c: a
79// const object whose initializer every translation unit can see is a COMPILE-TIME FACT, so
80// `network.init(work)` resolves to a named function and becomes a DIRECT call. An extern table
81// leaves the call indirect and the symbol live at every level, -O2 -flto included.
82static const NetworkNs network __attribute__((unused)) = {
84};
85
87
88#endif
Layer 3 (Network) - name resolution, both directions: asking and answering.
Layer 3 (Network) - the interface forwarding plane (PROTOCORE_ENABLE_FORWARD).
Layer 3 (Network) - a family-tagged IP address (IPv4 or IPv6) with RFC-faithful text parsing,...
void protocore_network_init(uint8_t *work)
networkVars networkV
The operands and the outcome.
The entries.
Definition ip.h:148
The entries.
Definition network.h:70
void(*const init)(uint8_t *work)
Definition network.h:71
IpNs * ip
an internet address as a value (RFC 791, RFC 8200)
Definition network.h:62
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition types.h:96
#define PROTOCORE_END_DECLS
Definition types.h:97