DMShell: an on-board test client for the remote shell (#12111)

* DMShell: an on-board test client for the remote shell

A DMShell session is normally driven by bin/dmshell_client.py over the API,
which puts the test's own traffic on the serial port it is logging. This
builds the client into the firmware instead: -DDMSHELL_TEST_PEER=0x<node>
gives the board a client that opens a session to that node and types a
workload itself, so a run needs no host and the serial port stays in
logging mode for its whole length.

It speaks the same protocol as the Python client, on the sequence and
replay bookkeeping already in DMShellRecovery.h, and keeps the same
per-session counters so the two can be compared directly.

Unset, nothing is built and nothing is linked: the flag guards both source
files and the one hook in Modules.cpp. DMSHELL_TEST_* set the workload (the
command, keystroke interval, session length and count, how keystrokes are
batched into frames, the input window). DMSHELL_TEST_SLOT_PARITY, when set,
stamps slot_parity on every packet it sends.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VUcRFYYQhAcSSKRC2h7mMn

* DMShellTest: require PKI on the peer's frames

The test client accepted any decoded packet on the remote shell port whose
`from` matched its peer. A channel-encrypted packet can claim any `from`, so
a forged CLOSED with the live session id would end a session and a forged
`ack_seq` would move the send window. The server already refuses a frame
without PKI; the client now does the same.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VUcRFYYQhAcSSKRC2h7mMn

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Jonathan BennettandClaude Opus 5 authored and GitHub committed 2026-10-09 03:34:00 +00:00
1 parent 364a111f4a
commit 315ec0e4ed
3 files changed
+838

No files matched your search

+6
View File
@@ -63,6 +63,9 @@
#include "modules/GeofenceModule.h"
#include "modules/WaypointModule.h"
#endif
#ifdef DMSHELL_TEST_PEER
#include "modules/DMShellTestModule.h"
#endif
#if ARCH_PORTDUINO
#include "modules/DMShell.h"
#include "modules/Telemetry/HostMetrics.h"
@@ -229,6 +232,9 @@ void setupModules()
dmShellModule = new DMShellModule();
#endif
#endif
#ifdef DMSHELL_TEST_PEER
dmShellTestModule = new DMShellTestModule();
#endif
#if HAS_TELEMETRY
new DeviceTelemetryModule();
#endif