Shell: tls, ntp and netstat (#90)
CI / build (pull_request) Successful in 1m49s
Site / build (pull_request) Successful in 10s

The rest of the issue's list. tls makes a handshake that checks nothing,
then says the certificate in words: who it is for, who signed it, until
when, and whether this device's roots and the name asked for accept it,
with the reason when they don't. ntp compares a time server's clock with
the device's. netstat lists what listens and what is connected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
2026-10-08 02:54:59 +02:00
co-authored by Claude Opus 5.5
parent 9b6457d1ec
commit 9808013fc0
12 changed files with 395 additions and 16 deletions
+27
View File
@@ -68,4 +68,31 @@ struct DnsAnswer {
// False if it isn't the answer to query `id`, or is cut short.
bool parseDnsAnswer(const uint8_t* message, size_t len, uint16_t id, DnsAnswer& out);
// --- NTP: the clock's offset
constexpr size_t kNtpPacket = 48;
void buildNtpRequest(uint8_t out[kNtpPacket]);
struct NtpAnswer {
int stratum = 0; // 1: a reference clock; 2 and up: that many steps from one
int64_t seconds = 0; // the server's clock when it answered, UTC since 1970
uint32_t millis = 0; // and the part of a second
};
// False if it isn't a server's answer, or says the server has no time to give.
bool parseNtpAnswer(const uint8_t* packet, size_t len, NtpAnswer& out);
// "0.3 s ahead", "12 s behind", "right, to 0.1 s": this clock against the server's, both in ms.
std::string clockOffset(int64_t ownMs, int64_t serverMs);
// --- TLS: who a certificate is for
// The common name out of a certificate's subject or issuer as mbedTLS prints it
// ("C=US, O=Let's Encrypt, CN=R11"): the CN, else the O, else all of it.
std::string certName(const std::string& dn);
// Whole days from one date to another (negative: the second is earlier).
int daysBetween(int y1, int m1, int d1, int y2, int m2, int d2);
// --- netstat
// What listens on a port of this firmware, or "".
const char* portLabel(uint16_t port, bool tcp);
} // namespace roro::net