From: Roy Marples Date: Wed, 12 Feb 2014 09:25:58 +0000 (+0000) Subject: Fix compile on BSD X-Git-Tag: v6.3.0~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=63d4472589e7862c426942532bd645d2321a6935;p=thirdparty%2Fdhcpcd.git Fix compile on BSD --- diff --git a/dhcpcd.c b/dhcpcd.c index aedeb753..0a684c73 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -1115,11 +1115,13 @@ main(int argc, char **argv) pidfile = NULL; ifo = NULL; ctx.cffile = CONFIG; - ctx.pid_fd = -1; - ctx.control_fd = -1; + ctx.pid_fd = ctx.control_fd = ctx.link_fd = -1; +#ifdef PLUGIN_DEV ctx.dev_fd = -1; - ctx.link_fd = -1; +#endif +#ifdef INET ctx.udp_fd = -1; +#endif i = 0; while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1) { diff --git a/dhcpcd.h b/dhcpcd.h index dd326ddc..895c3e93 100644 --- a/dhcpcd.h +++ b/dhcpcd.h @@ -117,7 +117,10 @@ struct dhcpcd_ctx { #ifdef __linux__ char **ra_restore; ssize_t ra_restore_len; -#endif /* __linux__ */ +#else /* __linux__ */ + int ra_global; + int ra_kernel_set; +#endif #endif /* INET6 */ #ifdef PLUGIN_DEV @@ -126,8 +129,6 @@ struct dhcpcd_ctx { struct dev *dev; void *dev_handle; #endif - - }; extern const int handle_sigs[]; diff --git a/platform-bsd.c b/platform-bsd.c index ba44b68e..925b74ea 100644 --- a/platform-bsd.c +++ b/platform-bsd.c @@ -88,12 +88,11 @@ inet6_sysctl(int code, int val, int action) return val; } -static int kernel_ra_set; void restore_kernel_ra(struct dhcpcd_ctx *ctx) { - if (kernel_ra_set == 0 || ctx->options & DHCPCD_FORKED) + if (ctx->ra_kernel_set == 0 || ctx->options & DHCPCD_FORKED) return; syslog(LOG_INFO, "restoring Kernel IPv6 RA support"); if (set_inet6_sysctl(IPV6CTL_ACCEPT_RTADV, 1) == -1) @@ -119,15 +118,14 @@ ipv6_ra_flush(void) } int -check_ipv6(const char *ifname, int own) +check_ipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) { - static int global_ra = 0; int ra; /* BSD doesn't support these values per iface, so just return * the global ra setting */ if (ifname) - return global_ra; + return ctx->ra_global; ra = get_inet6_sysctl(IPV6CTL_ACCEPT_RTADV); if (ra == -1) @@ -142,7 +140,7 @@ check_ipv6(const char *ifname, int own) return ra; } ra = 0; - kernel_ra_set = 1; + ctx->ra_kernel_set = 1; /* Flush the kernel knowledge of advertised routers * and prefixes so the kernel does not expire prefixes @@ -150,7 +148,7 @@ check_ipv6(const char *ifname, int own) ipv6_ra_flush(); } if (ifname == NULL) - global_ra = ra; + ctx->ra_global = ra; return ra; }