DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
ssh_server.h
Go to the documentation of this file.
1// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file ssh_server.h
6 * @brief SSH message dispatcher - ties the transport, auth, and channel layers
7 * into one server state machine.
8 *
9 * The dispatcher is transport-agnostic: it consumes decrypted SSH message
10 * payloads (as produced by ssh_pkt_recv) and emits response payloads through a
11 * callback. The integration layer wires the callback to ssh_pkt_send + the TCP
12 * socket, so this module stays free of lwIP and is fully unit-testable.
13 *
14 * Lifecycle: banner exchange (handled by ssh_transport_recv_banner) → KEXINIT →
15 * KEXDH → NEWKEYS → ssh-userauth → connection/channel protocol, with in-session
16 * re-keys handled transparently.
17 *
18 * @author Douglas Quigg (dstroy0)
19 * @date 2026
20 */
21
22#ifndef DETERMINISTICESPASYNCWEBSERVER_SSH_SERVER_H
23#define DETERMINISTICESPASYNCWEBSERVER_SSH_SERVER_H
24
25#include <stddef.h>
26#include <stdint.h>
27
28/**
29 * @brief Emit one outbound SSH message payload for slot @p slot.
30 *
31 * The integration wraps this with ssh_pkt_send() (which frames, encrypts, and
32 * MACs the payload once keys are active) and writes the result to the socket.
33 */
34typedef void (*SshEmitCb)(uint8_t slot, const uint8_t *payload, size_t len);
35
36/** @brief Install the outbound-message callback. */
38
39/**
40 * @brief Dispatch one decrypted inbound SSH message for slot @p i.
41 *
42 * Routes by message type and handshake phase, driving the handshake and, once
43 * open, the channel protocol. Responses are produced via the emit callback.
44 *
45 * @param[in] i SSH slot.
46 * @param[in] msg_type First payload byte (SSH message number).
47 * @param[in] payload Full message payload (including @p msg_type at [0]).
48 * @param[in] len Payload length.
49 * @return 0 if handled, -1 if the connection must be closed.
50 */
51int ssh_server_dispatch(uint8_t i, uint8_t msg_type, const uint8_t *payload, size_t len);
52
53#endif // DETERMINISTICESPASYNCWEBSERVER_SSH_SERVER_H
int ssh_server_dispatch(uint8_t i, uint8_t msg_type, const uint8_t *payload, size_t len)
Dispatch one decrypted inbound SSH message for slot i.
void ssh_server_set_emit_cb(SshEmitCb cb)
Install the outbound-message callback.
void(* SshEmitCb)(uint8_t slot, const uint8_t *payload, size_t len)
Emit one outbound SSH message payload for slot slot.
Definition ssh_server.h:34