ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
client.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 client.h
6 * @brief What an application calls to drive and provision the outbound role.
7 *
8 * The client engine is client/client.c; these are the entry points above it - where the connection
9 * has got to, and the ssh-ed25519 public half of a seed for RFC 4252 sec 7 provisioning. Nothing
10 * here is one of the three components of RFC 4251 sec 1.
11 */
12
13#ifndef PROTOCORE_APP_CLIENT_H
14#define PROTOCORE_APP_CLIENT_H
15
17
19
20#if PROTOCORE_ENABLE_SSH_CLIENT
21
22/** @brief Current lifecycle state. */
23
24/** @brief True once authenticated and the remote forward is live. */
25
26/**
27 * @brief Derive the ssh-ed25519 public key (32 bytes) from a private @p seed.
28 *
29 * Convenience for provisioning: print/serve this so it can be added to the relay's `authorized_keys`
30 * (as `ssh-ed25519 <base64(0x0000000b "ssh-ed25519" 0x00000020 <pub>)>`).
31 */
32
33#endif // PROTOCORE_ENABLE_SSH_CLIENT
34
35/**
36 * @brief What a sketch asks about the SSH forward.
37 *
38 * A caller sets the members a call takes, invokes it through ::SshAppClient, and reads the outcome
39 * off the same handle.
40 *
41 * @var SshAppClientNs::seed the 32-byte signing seed a key derivation starts from
42 * @var SshAppClientNs::pub where its public half is written
43 * @var SshAppClientNs::ok the forward is up
44 * @var SshAppClientNs::state the phase the forward is in
45 * @var SshAppClientNs::state_get read that phase
46 * @var SshAppClientNs::up whether it is up
47 * @var SshAppClientNs::pubkey the seed's public half, without a connection
48 */
49typedef struct
50{
51 const uint8_t *seed;
52 uint8_t *pub;
56
57/** @brief The operands and the outcome. */
59
60/** @brief The entries. */
61typedef struct
62{
63 void (*const state_get)(uint8_t *work);
64 void (*const up)(uint8_t *work);
65 void (*const pubkey)(uint8_t *work);
67
68// What the table binds, defined once in the .c and taking one parameter each: everything
69// else an entry needs is an operand in SshAppClientV or a region of the borrow at a fixed offset.
71void protocore_ssh_app_client_up(uint8_t *work);
73
74// `static const`, initialised HERE rather than `extern` against a definition in the .c: a
75// const object whose initializer every translation unit can see is a COMPILE-TIME FACT, so
76// `SshAppClient.state_get(work)` resolves to a named function and becomes a DIRECT call. An extern table
77// leaves the call indirect and the symbol live at every level, -O2 -flto included.
78static const SshAppClientNs SshAppClient __attribute__((unused)) = {
82};
83
85
86#endif // PROTOCORE_APP_CLIENT_H
void protocore_ssh_app_client_up(uint8_t *work)
SshAppClientVars SshAppClientV
The operands and the outcome.
void protocore_ssh_app_client_state_get(uint8_t *work)
void protocore_ssh_app_client_pubkey(uint8_t *work)
The client engine: drive the handshake, authenticate, and request the port forward.
PROTOCORE_BEGIN_DECLS enum PROTO_ENUM_PACKED protocore_ssh_client_state
Lifecycle phase of the forward, for observability.
The entries.
Definition client.h:62
void(*const state_get)(uint8_t *work)
Definition client.h:63
proto_bool ok
Definition client.h:53
const uint8_t * seed
Definition client.h:51
uint8_t * pub
Definition client.h:52
protocore_ssh_client_state state
Definition client.h:54
#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