]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Report delegated addresses, fixes [2887c4de47].
authorRoy Marples <roy@marples.name>
Fri, 26 Sep 2014 21:22:14 +0000 (21:22 +0000)
committerRoy Marples <roy@marples.name>
Fri, 26 Sep 2014 21:22:14 +0000 (21:22 +0000)
dhcp6.c
script.c

diff --git a/dhcp6.c b/dhcp6.c
index 9ff78516db66475d9727cca16f331048e96ec8c3..d313e1586acc2c40eb6a1c2175183cf972f1f237 100644 (file)
--- 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;
 }
 
index b244ff19458b6233d2cd0c5e8e8df478708010a0..c5adb8e5b78d058a929e75a5aa6cf7a511bfcb78 100644 (file)
--- 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) {