DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
telnet.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 telnet.h
6 * @brief Layer 6/7 - minimal RFC 854 Telnet server (DETWS_ENABLE_TELNET).
7 *
8 * A zero-heap line-oriented Telnet console dispatched from the session layer's
9 * ConnProto::PROTO_TELNET arms (the same way SSH is dispatched to ssh_conn). On connect it
10 * negotiates server-side echo + suppress-go-ahead (so the client runs in
11 * character mode and the server draws the line), accumulates a line, echoes
12 * keystrokes (with backspace handling), and hands each completed line to a
13 * command callback. Output can be pushed to all connected clients.
14 *
15 * Telnet is plaintext - no authentication or encryption. Use it only on a
16 * trusted network; prefer SSH or the WebSocket terminal otherwise.
17 *
18 * Usage:
19 * @code
20 * server.listen(23, ConnProto::PROTO_TELNET); // open the Telnet port
21 * telnet_on_command(my_cmd_handler); // void(const char *line, uint8_t id)
22 * @endcode
23 */
24
25#ifndef DETERMINISTICESPASYNCWEBSERVER_TELNET_H
26#define DETERMINISTICESPASYNCWEBSERVER_TELNET_H
27
28#include "ServerConfig.h"
29#include <stddef.h>
30#include <stdint.h>
31
32#if DETWS_ENABLE_TELNET
33
34/** @brief Called with each completed input line (NUL-terminated, no CR/LF) and its client id. */
35typedef void (*TelnetCommandCb)(const char *line, uint8_t conn_id);
36
37// ---- Application API ------------------------------------------------------
38
39/** @brief Register the per-line command handler. */
40void telnet_on_command(TelnetCommandCb cb);
41
42/** @brief Send text to every connected Telnet client (no trailing newline added). */
43void telnet_print(const char *s);
44
45/** @brief Send text + CRLF to every connected Telnet client. */
46void telnet_println(const char *s);
47
48/** @brief printf-style broadcast to every connected Telnet client (bounded by TELNET_BUF_SIZE). */
49void telnet_printf(const char *fmt, ...);
50
51/** @brief Number of connected Telnet clients. */
52uint8_t telnet_client_count();
53
54// ---- Connection layer (called by the session layer for ConnProto::PROTO_TELNET slots) -
55
56/** @brief A Telnet connection was accepted on TCP slot @p slot. */
57void telnet_accept(uint8_t slot);
58
59/** @brief Drain and process received bytes for the Telnet connection on @p slot. */
60void telnet_rx(uint8_t slot);
61
62/** @brief The Telnet connection on @p slot closed; release its state. */
63void telnet_close(uint8_t slot);
64
65/** @brief The Telnet ProtoHandler (accessor; installed by the builtins list, no session dep). */
66struct ProtoHandler;
67const struct ProtoHandler *telnet_proto_handler(void);
68
69#endif // DETWS_ENABLE_TELNET
70
71#endif // DETERMINISTICESPASYNCWEBSERVER_TELNET_H
User-facing configuration for DeterministicESPAsyncWebServer.
Per-protocol connection event/poll callbacks (Layer 5 dispatch vtable).