dhcpcd_ifafwaiting(const struct interface *ifp)
{
unsigned long long opts;
+ bool foundany = false;
if (ifp->active != IF_ACTIVE_USER)
return AF_MAX;
+#define DHCPCD_WAITALL (DHCPCD_WAITIP4 | DHCPCD_WAITIP6)
opts = ifp->options->options;
#ifdef INET
- if (opts & DHCPCD_WAITIP4 && !ipv4_hasaddr(ifp))
- return AF_INET;
+ if (opts & DHCPCD_WAITIP4 ||
+ (opts & DHCPCD_WAITIP && !(opts & DHCPCD_WAITALL)))
+ {
+ bool foundaddr = ipv4_hasaddr(ifp);
+
+ if (opts & DHCPCD_WAITIP4 && !foundaddr)
+ return AF_INET;
+ if (foundaddr)
+ foundany = true;
+ }
#endif
- if (opts & DHCPCD_WAITIP6 && !ipv6_hasaddr(ifp))
- return AF_INET6;
- if (opts & DHCPCD_WAITIP &&
- !(opts & (DHCPCD_WAITIP4 | DHCPCD_WAITIP6)) &&
-#ifdef INET
- !ipv4_hasaddr(ifp) &&
+#ifdef INET6
+ if (opts & DHCPCD_WAITIP6 ||
+ (opts & DHCPCD_WAITIP && !(opts & DHCPCD_WAITALL)))
+ {
+ bool foundaddr = ipv6_hasaddr(ifp);
+
+ if (opts & DHCPCD_WAITIP6 && !foundaddr)
+ return AF_INET;
+ if (foundaddr)
+ foundany = true;
+ }
#endif
- !ipv6_hasaddr(ifp))
+
+ if (opts & DHCPCD_WAITIP && !(opts & DHCPCD_WAITALL) && !foundany)
return AF_UNSPEC;
return AF_MAX;
}
ipv4_hasaddr(ifp))
opts &= ~(DHCPCD_WAITIP | DHCPCD_WAITIP4);
#endif
+#ifdef INET6
if (opts & (DHCPCD_WAITIP | DHCPCD_WAITIP6) &&
ipv6_hasaddr(ifp))
opts &= ~(DHCPCD_WAITIP | DHCPCD_WAITIP6);
+#endif
if (!(opts & DHCPCD_WAITOPTS))
break;
}
#ifdef INET
dhcp_abort(ifp);
#endif
+#ifdef INET6
ipv6nd_expire(ifp, 0);
+#endif
#ifdef DHCP6
dhcp6_abort(ifp);
#endif
}
dhcpcd_initstate(ifp, 0);
script_runreason(ifp, "CARRIER");
+#ifdef INET6
#ifdef NOCARRIER_PRESERVE_IP
/* Set any IPv6 Routers we remembered to expire
* faster than they would normally as we
#endif
/* RFC4941 Section 3.5 */
ipv6_gentempifid(ifp);
+#endif
dhcpcd_startinterface(ifp);
}
}
#endif
}
+#ifdef INET6
if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) {
logerr("%s: ipv6_start", ifp->name);
ifo->options &= ~DHCPCD_IPV6;
}
+
if (ifo->options & DHCPCD_IPV6) {
if (ifp->active == IF_ACTIVE_USER) {
ipv6_startstatic(ifp);
}
#endif
}
+#endif
#ifdef INET
if (ifo->options & DHCPCD_IPV4 && ifp->active == IF_ACTIVE_USER) {
#ifdef INET
dhcp_renew(ifp);
#endif
+#ifdef INET6
#define DHCPCD_RARENEW (DHCPCD_IPV6 | DHCPCD_IPV6RS)
if ((ifp->options->options & DHCPCD_RARENEW) == DHCPCD_RARENEW)
ipv6nd_startrs(ifp);
+#endif
#ifdef DHCP6
dhcp6_renew(ifp);
#endif
if (IPV4LL_STATE_RUNNING(ifp))
len++;
#endif
+#ifdef INET6
if (IPV6_STATE_RUNNING(ifp))
len++;
if (RS_STATE_RUNNING(ifp))
len++;
+#endif
#ifdef DHCP6
if (D6_STATE_RUNNING(ifp))
len++;
}
if_closesockets(&ctx);
free_globals(&ctx);
+#ifdef INET6
ipv6_ctxfree(&ctx);
+#endif
dev_stop(&ctx);
eloop_free(ctx.eloop);
free(ctx.iov[0].iov_base);
# define IN6_IFF_DETACHED 0
#endif
+#ifdef INET6
TAILQ_HEAD(ipv6_addrhead, ipv6_addr);
struct ipv6_addr {
TAILQ_ENTRY(ipv6_addr) next;
((const struct ipv6_state *)(ifp)->if_data[IF_DATA_IPV6])
#define IPV6_STATE_RUNNING(ifp) ipv6_staticdadcompleted((ifp))
-#ifdef INET6
int ipv6_init(struct dhcpcd_ctx *);
int ipv6_makestableprivate(struct in6_addr *addr,
ssize_t ipv6_env(char **, const char *, const struct interface *);
void ipv6_ctxfree(struct dhcpcd_ctx *);
bool inet6_getroutes(struct dhcpcd_ctx *, struct rt_head *);
+#endif /* INET6 */
-#else
-#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) {}
-#define ipv6_ctxfree(a) {}
-#define ipv6_gentempifid(a) {}
-#endif
-
-#endif
+#endif /* INET6_H */
#ifndef IPV6ND_H
#define IPV6ND_H
+#ifdef INET6
+
#include <time.h>
#include "config.h"
#define IPV6ND_REACHABLE (1 << 0)
#define IPV6ND_ROUTER (1 << 1)
-#ifdef INET6
void ipv6nd_printoptions(const struct dhcpcd_ctx *,
const struct dhcp_opt *, size_t);
void ipv6nd_startrs(struct interface *);
void ipv6nd_expire(struct interface *, uint32_t);
void ipv6nd_drop(struct interface *);
void ipv6nd_neighbour(struct dhcpcd_ctx *, struct in6_addr *, int);
-#else
-#define ipv6nd_startrs(a) {}
-#define ipv6nd_free(a) {}
-#define ipv6nd_hasra(a) (0)
-#define ipv6nd_dadcompleted(a) (0)
-#define ipv6nd_expire(a, b) {}
-#endif
+#endif /* INET6 */
-#endif
+#endif /* IPV6ND_H */