]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix compile on BSD.
authorRoy Marples <roy@marples.name>
Thu, 7 Apr 2016 20:41:51 +0000 (20:41 +0000)
committerRoy Marples <roy@marples.name>
Thu, 7 Apr 2016 20:41:51 +0000 (20:41 +0000)
dhcpcd.c
if-bsd.c
if.c

index 9486a9c39f812d0e5d4dbe86694b868d6e8f6b89..31dc60c8dea45dba7f3967db2d5b8f08ff3ce365 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1482,9 +1482,6 @@ main(int argc, char **argv)
        ctx.cffile = CONFIG;
        ctx.control_fd = ctx.control_unpriv_fd = ctx.link_fd = -1;
        ctx.pf_inet_fd = -1;
-#if defined(INET6) && defined(BSD)
-       ctx.pf_inet6_fd = -1;
-#endif
 #ifdef IFLR_ACTIVE
        ctx.pf_link_fd = -1;
 #endif
index eb98862326ff6e702c88d3ed2186b35f6424a3a7..fd5e990b2384c4e3f550d9155a877b19df70612e 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -837,6 +837,7 @@ if_address6(const struct ipv6_addr *ia, int action)
 {
        struct in6_aliasreq ifa;
        struct in6_addr mask;
+       struct priv *priv;
 
        memset(&ifa, 0, sizeof(ifa));
        strlcpy(ifa.ifra_name, ia->iface->name, sizeof(ifa.ifra_name));
@@ -871,7 +872,8 @@ if_address6(const struct ipv6_addr *ia, int action)
        ifa.ifra_lifetime.ia6t_pltime = ia->prefix_pltime;
 #undef ADDADDR
 
-       return ioctl(ia->iface->ctx->pf_inet6_fd,
+       priv = (struct priv *)ia->iface->ctx->priv;
+       return ioctl(priv->pf_inet6_fd,
            action < 0 ? SIOCDIFADDR_IN6 : SIOCAIFADDR_IN6, &ifa);
 }
 
@@ -1161,13 +1163,15 @@ if_addrflags6(const struct in6_addr *addr, const struct interface *ifp)
 {
        int flags;
        struct in6_ifreq ifr6;
+       struct priv *priv;
 
        memset(&ifr6, 0, sizeof(ifr6));
        strlcpy(ifr6.ifr_name, ifp->name, sizeof(ifr6.ifr_name));
        ifr6.ifr_addr.sin6_family = AF_INET6;
        ifr6.ifr_addr.sin6_addr = *addr;
        ifa_scope(&ifr6.ifr_addr, ifp->index);
-       if (ioctl(ifp->ctx->pf_inet6_fd, SIOCGIFAFLAG_IN6, &ifr6) != -1)
+       priv = (struct priv *)ifp->ctx->priv;
+       if (ioctl(priv->pf_inet6_fd, SIOCGIFAFLAG_IN6, &ifr6) != -1)
                flags = ifr6.ifr_ifru.ifru_flags6;
        else
                flags = -1;
@@ -1180,14 +1184,15 @@ if_getlifetime6(struct ipv6_addr *ia)
        struct in6_ifreq ifr6;
        time_t t;
        struct in6_addrlifetime *lifetime;
+       struct priv *priv;
 
        memset(&ifr6, 0, sizeof(ifr6));
        strlcpy(ifr6.ifr_name, ia->iface->name, sizeof(ifr6.ifr_name));
        ifr6.ifr_addr.sin6_family = AF_INET6;
        ifr6.ifr_addr.sin6_addr = ia->addr;
        ifa_scope(&ifr6.ifr_addr, ia->iface->index);
-       if (ioctl(ia->iface->ctx->pf_inet6_fd,
-           SIOCGIFALIFETIME_IN6, &ifr6) == -1)
+       priv = (struct priv *)ia->iface->ctx->priv;
+       if (ioctl(priv->pf_inet6_fd, SIOCGIFALIFETIME_IN6, &ifr6) == -1)
                return -1;
 
        t = time(NULL);
@@ -1768,7 +1773,9 @@ _if_checkipv6(int s, struct dhcpcd_ctx *ctx,
 int
 if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own)
 {
+       struct priv *priv;
 
-       return _if_checkipv6(ctx->pf_inet6_fd, ctx, ifp, own);
+       priv = (struct priv *)ctx->priv;
+       return _if_checkipv6(priv->pf_inet6_fd, ctx, ifp, own);
 }
 #endif
diff --git a/if.c b/if.c
index d482a755b4c417d06845fdd0460bf326d9d3c20e..c840bfbad76b56c3855c9265a0499fce3c95032e 100644 (file)
--- a/if.c
+++ b/if.c
@@ -97,13 +97,6 @@ if_opensockets(struct dhcpcd_ctx *ctx)
        if (ctx->pf_inet_fd == -1)
                return -1;
 
-#if defined(INET6) && defined(BSD)
-       ctx->pf_inet6_fd = xsocket(PF_INET6, SOCK_DGRAM, 0, SOCK_CLOEXEC);
-       /* Don't return an error so we at least work on kernels witout INET6
-        * even though we expect INET6 support.
-        * We will fail noisily elsewhere anyway. */
-#endif
-
 #ifdef IFLR_ACTIVE
        ctx->pf_link_fd = xsocket(PF_LINK, SOCK_DGRAM, 0, SOCK_CLOEXEC);
        if (ctx->pf_link_fd == -1)