mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user