]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: Remove #defines for functions when INET is disabled
authorRoy Marples <roy@marples.name>
Wed, 23 Jan 2019 11:37:37 +0000 (11:37 +0000)
committerRoy Marples <roy@marples.name>
Wed, 23 Jan 2019 11:37:37 +0000 (11:37 +0000)
This allows us to optimise the code better and hopefull
become less error prone.

src/dhcp.h
src/dhcpcd.c
src/if.c

index 1dc8a28bf77142224fcf8a594edeba706e8d36c6..5bb4d6e8166a9000c35066a134f4edffd89cc340 100644 (file)
@@ -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 */
index 9562af015dacfcd4c704a8abf75e9c567dbd67fe..37ca68f81dbe75b5d234e0d5a413d03786c53b88 100644 (file)
@@ -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)
index fabf99f3be0a6ece2f442c9ed09f991de1e3a88d..c0d26301d86b314ccbfc48a43aed22fe13ae9144 100644 (file)
--- 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))