From: Roy Marples Date: Wed, 23 Jan 2019 11:37:37 +0000 (+0000) Subject: DHCP: Remove #defines for functions when INET is disabled X-Git-Tag: v7.1.1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=581d309a0ead80ae2fd6bf750149a3b6d547ed10;p=thirdparty%2Fdhcpcd.git DHCP: Remove #defines for functions when INET is disabled This allows us to optimise the code better and hopefull become less error prone. --- diff --git a/src/dhcp.h b/src/dhcp.h index 1dc8a28b..5bb4d6e8 100644 --- a/src/dhcp.h +++ b/src/dhcp.h @@ -228,6 +228,7 @@ struct dhcp_state { #endif }; +#ifdef INET #define D_STATE(ifp) \ ((struct dhcp_state *)(ifp)->if_data[IF_DATA_DHCP]) #define D_CSTATE(ifp) \ @@ -243,7 +244,6 @@ struct dhcp_state { #include "dhcpcd.h" #include "if-options.h" -#ifdef INET char *decode_rfc3361(const uint8_t *, size_t); ssize_t decode_rfc3442(char *, size_t, const uint8_t *p, size_t); @@ -266,15 +266,6 @@ void dhcp_reboot_newopts(struct interface *, unsigned long long); void dhcp_close(struct interface *); void dhcp_free(struct interface *); int dhcp_dump(struct interface *); -#else -#define dhcp_start(a) {} -#define dhcp_abort(a) {} -#define dhcp_renew(a) {} -#define dhcp_reboot(a, b) (b = b) -#define dhcp_reboot_newopts(a, b) (b = b) -#define dhcp_close(a) {} -#define dhcp_free(a) {} -#define dhcp_dump(a) (-1) -#endif +#endif /* INET */ -#endif +#endif /* DHCP_H */ diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 9562af01..37ca68f8 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -733,7 +733,9 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags, #ifdef ARP arp_drop(ifp); #endif +#ifdef INET dhcp_abort(ifp); +#endif ipv6nd_expire(ifp, 0); dhcp6_abort(ifp); #else @@ -1173,7 +1175,9 @@ if_reboot(struct interface *ifp, int argc, char **argv) oldopts = ifp->options->options; script_runreason(ifp, "RECONFIGURE"); dhcpcd_initstate1(ifp, argc, argv, 0); +#ifdef INET dhcp_reboot_newopts(ifp, oldopts); +#endif dhcp6_reboot(ifp); dhcpcd_prestartinterface(ifp); } @@ -1252,7 +1256,9 @@ dhcpcd_ifrenew(struct interface *ifp) ifp->carrier == LINK_DOWN) return; +#ifdef INET dhcp_renew(ifp); +#endif #define DHCPCD_RARENEW (DHCPCD_IPV6 | DHCPCD_IPV6RS) if ((ifp->options->options & DHCPCD_RARENEW) == DHCPCD_RARENEW) ipv6nd_startrs(ifp); @@ -1338,8 +1344,10 @@ dhcpcd_getinterfaces(void *arg) if (!ifp->active) continue; len++; +#ifdef INET if (D_STATE_RUNNING(ifp)) len++; +#endif #ifdef IPV4LL if (IPV4LL_STATE_RUNNING(ifp)) len++; @@ -1797,8 +1805,13 @@ printpidfile: configure_interface(ifp, ctx.argc, ctx.argv, 0); i = 0; if (family == 0 || family == AF_INET) { +#ifdef INET if (dhcp_dump(ifp) == -1) i = -1; +#else + if (family == AF_INET) + logerrx("No INET support"); +#endif } if (family == 0 || family == AF_INET6) { if (dhcp6_dump(ifp) == -1) diff --git a/src/if.c b/src/if.c index fabf99f3..c0d26301 100644 --- a/src/if.c +++ b/src/if.c @@ -81,8 +81,10 @@ if_free(struct interface *ifp) #ifdef IPV4LL ipv4ll_free(ifp); #endif +#ifdef INET dhcp_free(ifp); ipv4_free(ifp); +#endif dhcp6_free(ifp); ipv6nd_free(ifp); ipv6_free(ifp); @@ -728,11 +730,12 @@ if_cmp(const struct interface *si, const struct interface *ti) return -1; if (si->carrier < ti->carrier) return 1; - +#ifdef INET if (D_STATE_RUNNING(si) && !D_STATE_RUNNING(ti)) return -1; if (!D_STATE_RUNNING(si) && D_STATE_RUNNING(ti)) return 1; +#endif if (RS_STATE_RUNNING(si) && !RS_STATE_RUNNING(ti)) return -1; if (!RS_STATE_RUNNING(si) && RS_STATE_RUNNING(ti))