X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=src%2Fscript.c;h=ae791cc1d2913d01939a8a80230f41e4784aaa02;hb=4a58bef7322b830b2e87be39c611a1bf4845ef49;hp=ff81278bf59b6f3e1dd1082634f5086aed1da505;hpb=4be3f666fde73be0d7046fac1ab8075aa5b1e8db;p=odhcp6c.git diff --git a/src/script.c b/src/script.c index ff81278..ae791cc 100644 --- a/src/script.c +++ b/src/script.c @@ -24,7 +24,7 @@ #include "odhcp6c.h" static const char hexdigits[] = "0123456789abcdef"; -static const char hexvals[] = { +static const int8_t hexvals[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -58,7 +58,8 @@ ssize_t script_unhexlify(uint8_t *dst, size_t len, const char *src) || y < 0 || (y = hexvals[y]) < 0) return -1; dst[c] = x << 4 | y; - while (*src < 0 || (*src && hexvals[(uint8_t)*src] < 0)) + while (((int8_t)*src) < 0 || + (*src && hexvals[(uint8_t)*src] < 0)) src++; } @@ -158,10 +159,16 @@ static void prefix_to_env(const char *name, const uint8_t *fqdn, size_t len) 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; + size_t sip_ip_len, sip_fqdn_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); + struct in6_addr *sip = odhcp6c_get_state(STATE_SIP_IP, &sip_ip_len); + uint8_t *sip_fqdn = odhcp6c_get_state(STATE_SIP_FQDN, &sip_fqdn_len); size_t prefix_len, lost_pd_len; uint8_t *prefix = odhcp6c_get_state(STATE_IA_PD, &prefix_len); @@ -170,7 +177,11 @@ void script_call(const char *status) // 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)); + ipv6_to_env("SIP_IP", sip, sip_ip_len / sizeof(*sip)); fqdn_to_env("DOMAINS", search, search_len); + fqdn_to_env("SNTP_FQDN", sntp_dns, sntp_dns_len); + fqdn_to_env("SIP_DOMAIN", sip_fqdn, sip_fqdn_len); bin_to_env(custom, custom_len); prefix_to_env("PREFIXES", prefix, prefix_len); prefix_to_env("PREFIXES_LOST", lost_pd, lost_pd_len);