system: configurable hostname (device identity)

Add a device hostname settable from the CLI (`hostname <text>`) and the
System Settings page. The value is sanitized on ingest to JSON-safe
printable ASCII (<=23 chars), stored in a shared __xdata buffer, seeded
to "RTLPlayground" at boot, persisted through the startup-config, and
reported in /information.json. It lives in the common header so other
modules can advertise it (LLDP uses it as the System Name TLV).
This commit is contained in:
d00f
2026-07-25 13:07:09 +02:00
parent 481c02c740
commit f21b3a32bd
8 changed files with 47 additions and 0 deletions
+12
View File
@@ -1524,6 +1524,18 @@ void cmd_parser(void) __banked
igmp_show();
else
igmp_setup(); // Reverts to default with IP-MC being flooded
} else if (cmd_compare(0, "hostname")) {
/* hostname <text>: rest of the line, sanitized to JSON-safe
* printable ASCII (<=23 chars), stored in the shared hostname. */
__xdata uint8_t *hp = &cmd_buffer[cmd_words_b[1]];
uint8_t hn = 0;
if (cmd_words_len >= 2)
while (hn < 23 && hp[hn] && hp[hn] != '\r' && hp[hn] != '\n') {
hostname[hn] = (hp[hn] < 0x20 || hp[hn] > 0x7e
|| hp[hn] == '"' || hp[hn] == '\\') ? '.' : hp[hn];
hn++;
}
hostname[hn] = 0;
} else if (cmd_compare(0, "stp")) {
if (cmd_compare(1, "on")) {
print_string("STP enabled\n");