Export STATIC6 to libdhcpcd.

This commit is contained in:
Roy Marples 2016-02-15 21:19:56 +00:00
parent ee184a69d1
commit aafc7d05c8
4 changed files with 29 additions and 8 deletions

View File

@ -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))

19
ipv6.c
View File

@ -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)
{

3
ipv6.h
View File

@ -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) {}

View File

@ -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;