diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2015-04-10 16:17:22 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2015-08-21 11:23:22 +0300 |
commit | 41e4615d4f4f5c61afa84ba857f23c0ac496687b (patch) | |
tree | 8419033d97e31070fb8f1c9bb5ad0bed6d9e0641 /src/libsystemd-network/sd-dhcp6-lease.c | |
parent | 6599680e2d33597f0f11a99e1c3c957b42418568 (diff) |
sd-dhcp6: Support deprecated SNTP Configuration Option
Although the SNTP option specified in RFC 4075 has been deprecated, some
servers are still sending NTP information with this option. Use the SNTP
information provided only if the NTP option is not present.
Update the test case as SNTP information is also requested.
Diffstat (limited to 'src/libsystemd-network/sd-dhcp6-lease.c')
-rw-r--r-- | src/libsystemd-network/sd-dhcp6-lease.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-lease.c b/src/libsystemd-network/sd-dhcp6-lease.c index 8631aabc40..f0494b3c91 100644 --- a/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/libsystemd-network/sd-dhcp6-lease.c @@ -257,6 +257,10 @@ int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) assert_return(lease, -EINVAL); assert_return(optval, -EINVAL); + free(lease->ntp); + lease->ntp_count = 0; + lease->ntp_allocated = 0; + while ((r = dhcp6_option_parse(&optval, &optlen, &subopt, &sublen, &subval)) >= 0) { int s; @@ -299,6 +303,38 @@ int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) return 0; } +int dhcp6_lease_set_sntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) { + int r; + + assert_return(lease, -EINVAL); + assert_return(optval, -EINVAL); + + if (!optlen) + return 0; + + if (lease->ntp || lease->ntp_fqdn) { + log_dhcp6_client(client, "NTP information already provided"); + + return 0; + } + + log_dhcp6_client(client, "Using deprecated SNTP information"); + + r = dhcp6_option_parse_ip6addrs(optval, optlen, &lease->ntp, + lease->ntp_count, + &lease->ntp_allocated); + if (r < 0) { + log_dhcp6_client(client, "Invalid SNTP server option: %s", + strerror(-r)); + + return r; + } + + lease->ntp_count = r; + + return 0; +} + int sd_dhcp6_lease_get_ntp_addrs(sd_dhcp6_lease *lease, struct in6_addr **addrs) { assert_return(lease, -EINVAL); |