From: Roy Marples Date: Fri, 26 Sep 2014 21:22:14 +0000 (+0000) Subject: Report delegated addresses, fixes [2887c4de47]. X-Git-Tag: v6.4.6~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=94e34c6e6d06983c527a5c64dc7f2ebcdb2cce32;p=thirdparty%2Fdhcpcd.git Report delegated addresses, fixes [2887c4de47]. --- diff --git a/dhcp6.c b/dhcp6.c index 9ff78516..d313e158 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -3255,6 +3255,13 @@ dhcp6_env(char **env, const char *prefix, const struct interface *ifp, char *pfx; uint32_t en; const struct dhcpcd_ctx *ctx; + const struct dhcp6_state *state; + const struct ipv6_addr *ap; + char *v, *val; + + n = 0; + if (m == NULL) + goto delegated; if (len < sizeof(*m)) { /* Should be impossible with guards at packet in @@ -3263,7 +3270,6 @@ dhcp6_env(char **env, const char *prefix, const struct interface *ifp, return -1; } - n = 0; ifo = ifp->options; ctx = ifp->ctx; @@ -3346,6 +3352,35 @@ dhcp6_env(char **env, const char *prefix, const struct interface *ifp, } free(pfx); +delegated: + /* Needed for Delegated Prefixes */ + state = D6_CSTATE(ifp); + i = 0; + TAILQ_FOREACH(ap, &state->addrs, next) { + if (ap->delegating_iface) { + i += strlen(ap->saddr) + 1; + } + } + if (env && i) { + i += strlen(prefix) + strlen("_dhcp6_prefix="); + v = val = env[n] = malloc(i); + if (v == NULL) { + syslog(LOG_ERR, "%s: %m", __func__); + return -1; + } + v += snprintf(val, i, "%s_dhcp6_prefix=", prefix); + TAILQ_FOREACH(ap, &state->addrs, next) { + if (ap->delegating_iface) { + strcpy(v, ap->saddr); + v += strlen(ap->saddr); + *v++ = ' '; + } + } + *--v = '\0'; + } + if (i) + n++; + return (ssize_t)n; } diff --git a/script.c b/script.c index b244ff19..c5adb8e5 100644 --- a/script.c +++ b/script.c @@ -470,7 +470,9 @@ dumplease: } #endif #ifdef INET6 - if (dhcp6 && d6_state && d6_state->new) { + if (dhcp6 && d6_state && + (d6_state->new || d6_state->state == DH6S_DELEGATED)) + { n = dhcp6_env(NULL, NULL, ifp, d6_state->new, d6_state->new_len); if (n > 0) {