]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Export STATIC6 to libdhcpcd.
authorRoy Marples <roy@marples.name>
Mon, 15 Feb 2016 21:19:56 +0000 (21:19 +0000)
committerRoy Marples <roy@marples.name>
Mon, 15 Feb 2016 21:19:56 +0000 (21:19 +0000)
dhcpcd.c
ipv6.c
ipv6.h
script.c

index 78e08196c6b23cd07f43ef30cc5899567c74b1af..23af13f73586378eaa6213d312571fa3db4defa1 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1329,6 +1329,8 @@ dhcpcd_getinterfaces(void *arg)
                        len++;
                if (IPV4LL_STATE_RUNNING(ifp))
                        len++;
+               if (IPV6_STATE_RUNNING(ifp))
+                       len++;
                if (RS_STATE_RUNNING(ifp))
                        len++;
                if (D6_STATE_RUNNING(ifp))
diff --git a/ipv6.c b/ipv6.c
index 492f4b2e7ec998675aafc54408f328ceedebaf7f..8a6d011d21e164fb7b412411edaa80e2e4d68b0b 100644 (file)
--- a/ipv6.c
+++ b/ipv6.c
@@ -1382,6 +1382,25 @@ ipv6_env(char **env, const char *prefix, const struct interface *ifp)
        return n;
 }
 
+int
+ipv6_staticdadcompleted(const struct interface *ifp)
+{
+       const struct ipv6_state *state;
+       const struct ipv6_addr *ia;
+       int n;
+
+       if ((state = IPV6_CSTATE(ifp)) == NULL)
+               return 0;
+       n = 0;
+#define COMPLETED (IPV6_AF_STATIC | IPV6_AF_ADDED | IPV6_AF_DADCOMPLETED)
+       TAILQ_FOREACH(ia, &state->addrs, next) {
+               if ((ia->flags & COMPLETED) == COMPLETED &&
+                   !(ia->addr_flags & IN6_IFF_NOTUSEABLE))
+                       n++;
+       }
+       return n;
+}
+
 int
 ipv6_startstatic(struct interface *ifp)
 {
diff --git a/ipv6.h b/ipv6.h
index 952c1dcfc194b5f351ee38eaee2de3cb0e597c07..988ae701d7eaf1c0c64af343dd4baa991a2a598d 100644 (file)
--- a/ipv6.h
+++ b/ipv6.h
@@ -218,6 +218,7 @@ struct ipv6_state {
        ((struct ipv6_state *)(ifp)->if_data[IF_DATA_IPV6])
 #define IPV6_CSTATE(ifp)                                                      \
        ((const struct ipv6_state *)(ifp)->if_data[IF_DATA_IPV6])
+#define IPV6_STATE_RUNNING(ifp) ipv6_staticdadcompleted((ifp))
 
 /* dhcpcd requires CMSG_SPACE to evaluate to a compile time constant. */
 #ifdef __QNX__
@@ -310,6 +311,7 @@ void ipv6_addtempaddrs(struct interface *, const struct timespec *);
 #endif
 
 int ipv6_start(struct interface *);
+int ipv6_staticdadcompleted(const struct interface *);
 int ipv6_startstatic(struct interface *);
 ssize_t ipv6_env(char **, const char *, const struct interface *);
 void ipv6_ctxfree(struct dhcpcd_ctx *);
@@ -321,6 +323,7 @@ void ipv6_buildroutes(struct dhcpcd_ctx *);
 #define ipv6_init(a) (NULL)
 #define ipv6_start(a) (-1)
 #define ipv6_startstatic(a)
+#define ipv6_staticdadcompleted(a) (0)
 #define ipv6_hasaddr(a) (0)
 #define ipv6_free_ll_callbacks(a) {}
 #define ipv6_free(a) {}
index 7fb3db6e2ff562cf011c072e32e08dc2ef3681e6..195da69720f94e4b329d33c984b5b50131ab3fd7 100644 (file)
--- a/script.c
+++ b/script.c
@@ -356,20 +356,13 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
        {
                env[9] = strdup("if_up=false");
                env[10] = strdup("if_down=false");
-#ifdef INET6
-       } else if (strcmp(reason, "STATIC6") == 0) {
-               /* For the time being, a static IPv6 address is does not qualify
-                * the interface to be up.
-                * Should we consider the presence of a static DNS server? */
-               env[9] = strdup("if_up=false");
-               env[10] = strdup("if_down=false");
-#endif
        } else if (1 == 2 /* appease ifdefs */
 #ifdef INET
            || (dhcp && state && state->new)
            || (ipv4ll && IPV4LL_STATE_RUNNING(ifp))
 #endif
 #ifdef INET6
+           || (static6 && IPV6_STATE_RUNNING(ifp))
            || (dhcp6 && d6_state && d6_state->new)
            || (ra && ipv6nd_hasra(ifp))
 #endif
@@ -644,6 +637,10 @@ send_interface(struct fd_list *fd, const struct interface *ifp)
 #endif
 
 #ifdef INET6
+       if (IPV6_STATE_RUNNING(ifp)) {
+               if (send_interface1(fd, ifp, "STATIC6") == -1)
+                       retval = -1;
+       }
        if (RS_STATE_RUNNING(ifp)) {
                if (send_interface1(fd, ifp, "ROUTERADVERT") == -1)
                        retval = -1;