networkd/dhcpserver: Save and expose the client hostname sent when requesting a DHCP lease.

DHCP clients often send their own hostname in option 12. It can be useful
to store it with the lease so it can be shown to a human to easily identify
which lease belongs to which device.

RFC: https://www.rfc-editor.org/rfc/rfc2132#section-3.14
This commit is contained in:
Rene Hollander
2023-06-01 06:51:45 +09:00
committed by Yu Watanabe
parent 89e9df12b3
commit 930133d5df
7 changed files with 72 additions and 47 deletions
+1
View File
@@ -1191,6 +1191,7 @@ static int dhcp_server_offered_leases_build_json(Link *link, JsonVariant **ret)
lease->client_id.data,
lease->client_id.length),
JSON_BUILD_PAIR_IN4_ADDR_NON_NULL("Address", &address),
JSON_BUILD_PAIR_STRING_NON_EMPTY("Hostname", lease->hostname),
JSON_BUILD_PAIR_FINITE_USEC(
"ExpirationUSec", lease->expiration)));
if (r < 0)