DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
ssh_server.h File Reference

SSH message dispatcher - ties the transport, auth, and channel layers into one server state machine. More...

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Typedefs

typedef void(* SshEmitCb) (uint8_t slot, const uint8_t *payload, size_t len)
 Emit one outbound SSH message payload for slot slot.
 

Functions

void ssh_server_set_emit_cb (SshEmitCb cb)
 Install the outbound-message callback.
 
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.
 

Detailed Description

SSH message dispatcher - ties the transport, auth, and channel layers into one server state machine.

The dispatcher is transport-agnostic: it consumes decrypted SSH message payloads (as produced by ssh_pkt_recv) and emits response payloads through a callback. The integration layer wires the callback to ssh_pkt_send + the TCP socket, so this module stays free of lwIP and is fully unit-testable.

Lifecycle: banner exchange (handled by ssh_transport_recv_banner) → KEXINIT → KEXDH → NEWKEYS → ssh-userauth → connection/channel protocol, with in-session re-keys handled transparently.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file ssh_server.h.

Typedef Documentation

◆ SshEmitCb

typedef void(* SshEmitCb) (uint8_t slot, const uint8_t *payload, size_t len)

Emit one outbound SSH message payload for slot slot.

The integration wraps this with ssh_pkt_send() (which frames, encrypts, and MACs the payload once keys are active) and writes the result to the socket.

Definition at line 34 of file ssh_server.h.

Function Documentation

◆ ssh_server_set_emit_cb()

void ssh_server_set_emit_cb ( SshEmitCb  cb)

Install the outbound-message callback.

Definition at line 28 of file ssh_server.cpp.

References SshServerCtx::emit_cb.

Referenced by ssh_conn_setup().

◆ ssh_server_dispatch()

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.

Routes by message type and handshake phase, driving the handshake and, once open, the channel protocol. Responses are produced via the emit callback.

Parameters
[in]iSSH slot.
[in]msg_typeFirst payload byte (SSH message number).
[in]payloadFull message payload (including msg_type at [0]).
[in]lenPayload length.
Returns
0 if handled, -1 if the connection must be closed.

Definition at line 65 of file ssh_server.cpp.

References SshSession::auth_failures, SshSession::authed, SshSession::ext_info_c, MAX_SSH_CONNS, SshSession::phase, SshPacketState::seq_no_recv, ssh_auth_handle_request(), ssh_auth_handle_service_request(), ssh_channel_handle_close(), ssh_channel_handle_data(), ssh_channel_handle_open(), ssh_channel_handle_open_confirm(), ssh_channel_handle_open_failure(), ssh_channel_handle_request(), ssh_channel_handle_window_adjust(), ssh_extinfo_build(), ssh_global_request_handle(), ssh_kex_generate(), ssh_kexdh_handle(), ssh_kexinit_build(), ssh_kexinit_parse(), SSH_MAX_AUTH_ATTEMPTS, SSH_MSG_CHANNEL_CLOSE, SSH_MSG_CHANNEL_DATA, SSH_MSG_CHANNEL_EOF, SSH_MSG_CHANNEL_OPEN, SSH_MSG_CHANNEL_OPEN_CONFIRM, SSH_MSG_CHANNEL_OPEN_FAILURE, SSH_MSG_CHANNEL_REQUEST, SSH_MSG_CHANNEL_WINDOW_ADJUST, SSH_MSG_DISCONNECT, SSH_MSG_EXT_INFO, SSH_MSG_GLOBAL_REQUEST, SSH_MSG_IGNORE, SSH_MSG_KEXDH_INIT, SSH_MSG_KEXINIT, SSH_MSG_NEWKEYS, SSH_MSG_SERVICE_REQUEST, SSH_MSG_UNIMPLEMENTED, SSH_MSG_USERAUTH_FAILURE, SSH_MSG_USERAUTH_REQUEST, SSH_MSG_USERAUTH_SUCCESS, ssh_newkeys_complete(), ssh_newkeys_sent(), SSH_PHASE_AUTH, SSH_PHASE_DH_INIT, SSH_PHASE_SERVICE, ssh_pkt, SSH_PKT_BUF_SIZE, and ssh_sess.