t1 = t2 = t3 = 86400;
- size_t ia_na_len, dns_len, search_len;
+ size_t ia_na_len, dns_len, search_len, sntp_ip_len, sntp_dns_len;
uint8_t *ia_na = odhcp6c_get_state(STATE_IA_NA, &ia_na_len);
uint8_t *ia_end;
odhcp6c_get_state(STATE_DNS, &dns_len);
odhcp6c_get_state(STATE_SEARCH, &search_len);
+ odhcp6c_get_state(STATE_SNTP_IP, &sntp_ip_len);
+ odhcp6c_get_state(STATE_SNTP_FQDN, &sntp_dns_len);
// Decrease valid and preferred lifetime of prefixes
size_t ia_pd_len;
odhcp6c_add_state(STATE_DNS, odata, olen);
} else if (otype == DHCPV6_OPT_DNS_DOMAIN) {
odhcp6c_add_state(STATE_SEARCH, odata, olen);
+ } else if (otype == DHCPV6_OPT_NTP_SERVER) {
+ uint16_t stype, slen;
+ uint8_t *sdata;
+ // Test status and bail if error
+ dhcpv6_for_each_option(odata, odata + olen,
+ stype, slen, sdata) {
+ if (slen == 16 && (stype == NTP_MC_ADDR ||
+ stype == NTP_SRV_ADDR))
+ odhcp6c_add_state(STATE_SNTP_IP,
+ sdata, slen);
+ else if (slen > 0 && stype == NTP_SRV_FQDN)
+ odhcp6c_add_state(STATE_SNTP_FQDN,
+ sdata, slen);
+ }
} else if (otype == DHCPV6_OPT_INFO_REFRESH && olen >= 4) {
uint32_t refresh = ntohl(*((uint32_t*)odata));
if (refresh < (uint32_t)t1)
if (opt) {
have_update |= odhcp6c_commit_state(STATE_DNS, dns_len);
have_update |= odhcp6c_commit_state(STATE_SEARCH, search_len);
+ have_update |= odhcp6c_commit_state(STATE_SNTP_IP,
+ sntp_ip_len);
+ have_update |= odhcp6c_commit_state(STATE_SNTP_FQDN,
+ sntp_dns_len);
size_t new_ia_pd_len, new_ia_na_len;
odhcp6c_get_state(STATE_IA_PD, &new_ia_pd_len);
odhcp6c_get_state(STATE_IA_NA, &new_ia_na_len);
odhcp6c_clear_state(STATE_SERVER_CAND);
odhcp6c_clear_state(STATE_IA_PD);
odhcp6c_clear_state(STATE_IA_PD_LOST);
+ odhcp6c_clear_state(STATE_SNTP_IP);
+ odhcp6c_clear_state(STATE_SNTP_FQDN);
dhcpv6_set_ia_na_mode(ia_na_mode);
alarm(timeout);
DHCPV6_OPT_IA_PREFIX = 26,
DHCPV6_OPT_INFO_REFRESH = 32,
DHCPV6_OPT_FQDN = 39,
+ DHCPV6_OPT_NTP_SERVER = 56,
+};
+
+enum dhcpv6_opt_npt {
+ NTP_SRV_ADDR = 1,
+ NTP_MC_ADDR = 2,
+ NTP_SRV_FQDN = 3
};
enum dhcpv6_msg {
STATE_IA_PD,
STATE_IA_PD_LOST,
STATE_CUSTOM_OPTS,
+ STATE_SNTP_IP,
+ STATE_SNTP_FQDN,
_STATE_MAX
};
void script_call(const char *status)
{
syslog(LOG_WARNING, "State for %s changed to %s", argv[1], status);
- size_t dns_len, search_len, custom_len;
+ size_t dns_len, search_len, custom_len, sntp_ip_len, sntp_dns_len;
struct in6_addr *dns = odhcp6c_get_state(STATE_DNS, &dns_len);
uint8_t *search = odhcp6c_get_state(STATE_SEARCH, &search_len);
uint8_t *custom = odhcp6c_get_state(STATE_CUSTOM_OPTS, &custom_len);
+ struct in6_addr *sntp = odhcp6c_get_state(STATE_SNTP_IP, &sntp_ip_len);
+ uint8_t *sntp_dns = odhcp6c_get_state(STATE_SNTP_FQDN, &sntp_dns_len);
size_t prefix_len, lost_pd_len;
uint8_t *prefix = odhcp6c_get_state(STATE_IA_PD, &prefix_len);
// Don't set environment before forking, because env is leaky.
if (fork() == 0) {
ipv6_to_env("RDNSS", dns, dns_len / sizeof(*dns));
+ ipv6_to_env("SNTP_IP", sntp, sntp_ip_len / sizeof(*sntp));
fqdn_to_env("DOMAINS", search, search_len);
+ fqdn_to_env("SNTP_FQDN", sntp_dns, sntp_dns_len);
bin_to_env(custom, custom_len);
prefix_to_env("PREFIXES", prefix, prefix_len);
prefix_to_env("PREFIXES_LOST", lost_pd, lost_pd_len);