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

src/dhcpcd.c
src/if.c
src/ipv4.c
src/ipv4ll.h

index 6d99e3791ed5646f97300281a7940b0274bb0db8..9562af015dacfcd4c704a8abf75e9c567dbd67fe 100644 (file)
@@ -1340,8 +1340,10 @@ dhcpcd_getinterfaces(void *arg)
                len++;
                if (D_STATE_RUNNING(ifp))
                        len++;
+#ifdef IPV4LL
                if (IPV4LL_STATE_RUNNING(ifp))
                        len++;
+#endif
                if (IPV6_STATE_RUNNING(ifp))
                        len++;
                if (RS_STATE_RUNNING(ifp))
index 2aa281904d4b9021c7b7d8ff827cff3b3d8273ee..fabf99f3be0a6ece2f442c9ed09f991de1e3a88d 100644 (file)
--- a/src/if.c
+++ b/src/if.c
@@ -78,7 +78,9 @@ if_free(struct interface *ifp)
 
        if (ifp == NULL)
                return;
+#ifdef IPV4LL
        ipv4ll_free(ifp);
+#endif
        dhcp_free(ifp);
        ipv4_free(ifp);
        dhcp6_free(ifp);
index 7d70825ab0fa87f4f2fdefde78c3936821f36caf..44f8a15d45163f8748a0f07055d5cdc59671be62 100644 (file)
@@ -200,8 +200,10 @@ ipv4_hasaddr(const struct interface *ifp)
 {
        const struct dhcp_state *dstate;
 
+#ifdef IPV4LL
        if (IPV4LL_STATE_RUNNING(ifp))
                return 1;
+#endif
 
        dstate = D_CSTATE(ifp);
        return (dstate &&
@@ -425,20 +427,25 @@ bool
 inet_getroutes(struct dhcpcd_ctx *ctx, struct rt_head *routes)
 {
        struct interface *ifp;
+#ifdef IPV4LL
        struct rt def;
        bool have_default;
+#endif
 
        TAILQ_FOREACH(ifp, ctx->ifaces, next) {
                if (!ifp->active)
                        continue;
                if (inet_dhcproutes(routes, ifp) == -1)
                        return false;
+#ifdef IPV4LL
                if (ipv4ll_subnetroute(routes, ifp) == -1)
                        return false;
+#endif
                if (inet_routerhostroute(routes, ifp) == -1)
                        return false;
        }
 
+#ifdef IPV4LL
        /* If there is no default route, see if we can use an IPv4LL one. */
        memset(&def, 0, sizeof(def));
        def.rt_dest.sa_family = AF_INET;
@@ -450,6 +457,7 @@ inet_getroutes(struct dhcpcd_ctx *ctx, struct rt_head *routes)
                                break;
                }
        }
+#endif
 
        return true;
 }
index 95a6a524f98903f78ed5d906803dc72458768c9e..23fad1b1232a230558a4728f5a72b7aace0b4205 100644 (file)
@@ -71,12 +71,6 @@ int ipv4ll_recvrt(int, const struct rt *);
 void ipv4ll_reset(struct interface *);
 void ipv4ll_drop(struct interface *);
 void ipv4ll_free(struct interface *);
-#else
-#define        IPV4LL_STATE_RUNNING(ifp)       (0)
-#define        ipv4ll_subnetroute(route, ifp)  (0)
-#define        ipv4ll_defaultroute(route, ifp) (0)
-#define        ipv4ll_handlert(a, b, c)        (0)
-#define        ipv4ll_free(a)                  {}
 #endif
 
 #endif