DHCP hostname: send net.hostname in DHCP requests

- aes67_net: esp_netif_set_hostname() before the interface starts, and
  in the net apply callback (takes effect at the next lease renewal).
- Verified: the router's DNS (lan.apointless.space) resolves p4-aes67
  to 192.168.192.244.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-24 23:16:39 +10:00
parent 30c32e702b
commit 07e16e6163
2 changed files with 8 additions and 1 deletions
+7 -1
View File
@@ -128,6 +128,8 @@ static void mdns_setup(void)
static void net_apply(const cJSON *g)
{
const char *host = cJSON_GetObjectItemCaseSensitive(g, "hostname")->valuestring;
// DHCP server sees the new name at the next lease renewal.
esp_netif_set_hostname(s_netif, host);
if (mdns_hostname_set(host) == ESP_OK && mdns_instance_name_set(host) == ESP_OK) {
ESP_LOGI(TAG, "mDNS: now %s.local", host);
}
@@ -155,7 +157,7 @@ static void net_status(cJSON *st)
esp_err_t aes67_net_init(esp_eth_handle_t eth)
{
// Applied so far: hostname (mDNS). Static IP and VLAN come later.
// Applied so far: hostname (DHCP, mDNS, LLDP). Static IP and VLAN come later.
ESP_ERROR_CHECK(cfg_register("net", NET_DEFAULTS, net_validate, net_apply));
ESP_ERROR_CHECK(cfg_register("inet", INET_DEFAULTS, inet_validate, NULL));
@@ -172,6 +174,10 @@ esp_err_t aes67_net_init(esp_eth_handle_t eth)
ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, eth_event, NULL));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, ip_event, NULL));
// Hostname in DHCP requests (option 12), so the router's lease list shows it.
cJSON *net = cfg_get("net");
ESP_ERROR_CHECK(esp_netif_set_hostname(s_netif, cJSON_GetObjectItemCaseSensitive(net, "hostname")->valuestring));
cJSON_Delete(net);
mdns_setup();
ESP_ERROR_CHECK(lldp_start(eth, s_netif));
status_register(net_status);
+1
View File
@@ -91,6 +91,7 @@ When this device is the GM, offset/frequency/delay show "–".
## Network
- Default: one untagged interface. VLAN split option: AES67 untagged + internet tagged (inet.vlan_id/pcp) using the ESP-IDF vlan_support approach (examples/network/vlan_support, ESP32-P4 supported). AES67 side has no gateway; default route and DNS are on inet.
- PTP, RTP, SAP and IGMP bind to the AES67 netif. HTTP server filters on `web_on`.
- DHCP sends net.hostname (option 12), so the router's lease list / local DNS shows it; after a rename it applies at the next lease renewal.
- mDNS (espressif/mdns): `<net.hostname>.local` plus the web UI as `_http._tcp` port 80. A hostname change applies live (the new name answers after ~1 s of RFC 6762 probing).
- LLDP (IEEE 802.1AB), transmit only, own code (not in IDF/lwIP): every 30 s, TTL 120 s, plus immediately on a new IP or hostname. TLVs: chassis ID and port ID = MAC, port description "eth0", system name = net.hostname, system description = project + firmware version, capabilities station-only, management address = IPv4. With the VLAN split, send it on the AES67 (untagged) side; the 802.1 port VLAN ID TLV can be added then.
- Switch port: AES67 as native/untagged VLAN, internet tagged, PoE on. IGMP snooping + querier on the AES67 VLAN.