ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
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 server.h
6 * @brief The file-transfer services RFC 4254 sec 6.5 carries, server side.
7 *
8 * SFTP (draft-ietf-secsh-filexfer) and SCP (rcp) are not components of SSH; they are programs the
9 * connection protocol starts through a "subsystem" or "exec" request. The classifier that decides a
10 * request names one of them is declared by the connection layer it hooks into
11 * (ssh_classify_file_transfer_request, connection.h) and implemented here, so the dependency runs
12 * upward only.
13 */
14
15#ifndef PROTOCORE_APP_SERVER_H
16#define PROTOCORE_APP_SERVER_H
17
19
21
22/** @brief RFC 4254 sec 5.4 CHANNEL_REQUEST: the type it names, and the body that follows. */
23typedef struct
24{
25 const uint8_t *rtype; ///< the request type
26 uint32_t rtype_len; ///< its length
27 const uint8_t *payload; ///< the request body
28 size_t len; ///< how many bytes it has
29 size_t off; ///< in/out: the request-specific argument, advanced past what was read
31
32/**
33 * @brief The file-transfer classifier: whether a channel request names SFTP or SCP.
34 *
35 * A caller sets the members the call takes, invokes it through ::SshAppServer, and reads the outcome
36 * off the same handle.
37 *
38 * @var SshAppServerNs::slot the SSH slot the request arrived on
39 * @var SshAppServerNs::channel the channel it names
40 * @var SshAppServerNs::req what one channel request names and carries (RFC 4254 sec 5.4)
41 * @var SshAppServerNs::accept in/out: set when an accepted SFTP subsystem flips acceptance
42 * @var SshAppServerNs::classify tag the channel and fire the matching open handler
43 */
44typedef struct
45{
46 uint8_t slot; ///< the SSH slot the request arrived on
47 uint32_t channel; ///< the channel it names
48 proto_bool accept; ///< in/out: set when an accepted SFTP subsystem flips acceptance
49 SshChanReqArgs req; ///< what one channel request names and carries
51
52/** @brief The operands and the outcome. */
54
55/** @brief The entries. */
56typedef struct
57{
58 void (*const classify)(uint8_t *work);
60
61// What the table binds, defined once in the .c and taking one parameter each: everything
62// else an entry needs is an operand in SshAppServerV or a region of the borrow at a fixed offset.
64
65// `static const`, initialised HERE rather than `extern` against a definition in the .c: a
66// const object whose initializer every translation unit can see is a COMPILE-TIME FACT, so
67// `SshAppServer.classify(work)` resolves to a named function and becomes a DIRECT call. An extern table
68// leaves the call indirect and the symbol live at every level, -O2 -flto included.
69static const SshAppServerNs SshAppServer __attribute__((unused)) = {
71};
72
74
75#endif // PROTOCORE_APP_SERVER_H
RFC 4254 connection protocol: channel multiplexing, windows, and port forwarding.
void protocore_ssh_app_server_classify(uint8_t *work)
SshAppServerVars SshAppServerV
The operands and the outcome.
The entries.
Definition server.h:57
void(*const classify)(uint8_t *work)
Definition server.h:58
proto_bool accept
in/out: set when an accepted SFTP subsystem flips acceptance
Definition server.h:48
uint32_t channel
the channel it names
Definition server.h:47
uint8_t slot
the SSH slot the request arrived on
Definition server.h:46
SshChanReqArgs req
what one channel request names and carries
Definition server.h:49
RFC 4254 sec 5.4 CHANNEL_REQUEST: the type it names, and the body that follows.
Definition server.h:24
const uint8_t * rtype
the request type
Definition server.h:25
size_t off
in/out: the request-specific argument, advanced past what was read
Definition server.h:29
const uint8_t * payload
the request body
Definition server.h:27
size_t len
how many bytes it has
Definition server.h:28
uint32_t rtype_len
its length
Definition server.h:26
#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