ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
datalink.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#ifndef PROTOCORE_DATALINK_H
5#define PROTOCORE_DATALINK_H
6
7#include "protocore_config.h" // the entry point: protocore_types.h for the widths
8
10
11/**
12 * @file datalink.h
13 * @brief Layer 2 (Data Link) - the LINK LAYER of RFC 1122 sec 2.
14 *
15 * RFC 1122 sec 2.3.3 "Ethernet and IEEE 802 Encapsulation" states what a host on the cable does
16 * with a frame: it MUST send and receive RFC 894 encapsulation (RFC 894 "Frame Format": Ether-Type
17 * 0x0800, a data field of 46 to 1500 octets, zero-padded to the minimum), SHOULD receive RFC 1042
18 * encapsulation intermixed with it (802.2 LLC/SNAP, K1=170), and MUST NOT send 802 packets using
19 * K1=6. RFC 1122 sec 2.4 fixes the interface this layer presents upward: a receive carries the
20 * link-layer-broadcast flag, a send carries the 5-bit TOS field.
21 *
22 * The platform's own link driver and IP stack port perform all of it - MAC framing, medium access,
23 * address resolution - and this module is the seam a target with direct MAC-level access extends.
24 * Its one call only reports the layer up.
25 *
26 * The module exports one symbol, @ref Datalink. Everything in datalink.c has internal linkage.
27 *
28 * No argument members: init takes none.
29 * No storage member: the layer holds nothing of its own, so there is no state to hand out.
30 *
31 * @author Douglas Quigg (dstroy0)
32 * @date 2026
33 */
34
35// PROTOCORE_DATALINK_BORROW - the bytes this module runs out of - is stated in protocore_config.h, which sums
36// it into its arena. Its size and its offset are each a static_assert, so a feature
37// combination that does not fit fails to compile rather than overrunning at run time.
38
39/** @brief Dispatch table. Addressed by offset, so the layout is asserted below. */
40typedef struct
41{
42 proto_bool (*init)(uint8_t *);
45
46/**
47 * @brief Bring the layer up: sets ok. The platform's link driver performs.
48 * @param work PROTOCORE_DATALINK_BORROW bytes the caller took. Not held past the call.
49 * @return PROTO_TRUE on success.
50 */
52
53/** @brief Module namespace. */
55
57
58#endif // PROTOCORE_DATALINK_H
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
Definition datalink.h:41
proto_bool(* init)(uint8_t *)
Definition datalink.h:42
#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