diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-08-26 19:19:32 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-08-26 20:44:20 +0200 |
commit | 8eb9058dc1f99a5eb9b8726a978fcc0720837a10 (patch) | |
tree | 9e2670f8a77d6fd01d763c7097908f6824694571 /src/network/networkd-link.c | |
parent | 43f447b121b38c01a7c5626a51cc571a822250b8 (diff) |
dhcp,network: implement RFC 4833 (DHCP Timezone option)
This one is simply to add: encode the tzdata timezone in the DHCP
options and optionally make use of it.
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r-- | src/network/networkd-link.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index cc9dc393c6..c179aafebb 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -672,6 +672,27 @@ static int link_enter_set_addresses(Link *link) { return r; */ + if (link->network->dhcp_server_emit_timezone) { + _cleanup_free_ char *buffer = NULL; + const char *tz; + + if (link->network->dhcp_server_timezone) + tz = link->network->dhcp_server_timezone; + else { + r = get_timezone(&buffer); + if (r < 0) + log_warning_errno(r, "Failed to determine timezone: %m"); + else + tz = buffer; + } + + if (tz) { + r = sd_dhcp_server_set_timezone(link->dhcp_server, tz); + if (r < 0) + return r; + } + } + r = sd_dhcp_server_start(link->dhcp_server); if (r < 0) { log_link_warning_errno(link, r, "Could not start DHCPv4 server instance: %m"); @@ -2414,6 +2435,14 @@ int link_save(Link *link) { } if (link->dhcp_lease) { + const char *tz = NULL; + + r = sd_dhcp_lease_get_timezone(link->dhcp_lease, &tz); + if (r >= 0) + fprintf(f, "TIMEZONE=%s\n", tz); + } + + if (link->dhcp_lease) { assert(link->network); r = sd_dhcp_lease_save(link->dhcp_lease, link->lease_file); |