]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Move log_route to if.c
authorRoy Marples <roy@marples.name>
Sat, 29 Mar 2008 11:36:43 +0000 (11:36 +0000)
committerRoy Marples <roy@marples.name>
Sat, 29 Mar 2008 11:36:43 +0000 (11:36 +0000)
if-bsd.c
if-linux.c
if.c
if.h

index cbb90c9d7e8cc72b398e6359cb8dfd367feab0e3..41ca61c859e51c3d1761505205609b3ea6602822 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -120,8 +120,6 @@ if_route(const char *ifname, struct in_addr destination,
        size_t hwlen = 0;
        int retval = 0;
 
-       log_route(destination, netmask, gateway, metric, change, del);
-
        if ((s = socket(PF_ROUTE, SOCK_RAW, 0)) == -1)
                return -1;
 
index b579989ebcd462e96a086dc36f078118b791e08f..ebe023712481f673833bf0b421a4cb3a043bf04a 100644 (file)
@@ -274,7 +274,6 @@ if_route(const char *ifname,
        unsigned int ifindex;
        int retval = 0;
 
-       log_route(destination, netmask, gateway, metric, change, del);
 
        if (!(ifindex = if_nametoindex(ifname))) {
                errno = ENODEV;
diff --git a/if.c b/if.c
index 5044c2ee12b3a7e2b5a92fe6f7b175391bdd4d23..97ed3cf9d926099fed7034eb437d34da8a63b64b 100644 (file)
--- a/if.c
+++ b/if.c
@@ -411,9 +411,9 @@ set_mtu(const char *ifname, short int mtu)
        return r == 0 ? 0 : -1;
 }
 
-void
+static void
 log_route(struct in_addr destination, struct in_addr netmask,
-         struct in_addr gateway, _unused int metric, int change, int del)
+         struct in_addr gateway, _unused int metric, int del)
 {
        char *dstd = xstrdup(inet_ntoa(destination));
 
@@ -426,7 +426,7 @@ log_route(struct in_addr destination, struct in_addr netmask,
        if (gateway.s_addr == destination.s_addr ||
            gateway.s_addr == INADDR_ANY)
                logger(LOG_INFO, "%s route to %s/%d" METRIC,
-                      change ? "changing" : del ? "removing" : "adding",
+                      del ? "removing" : "adding",
                       dstd, inet_ntocidr(netmask)
 #ifdef __linux__
                       , metric
@@ -434,7 +434,7 @@ log_route(struct in_addr destination, struct in_addr netmask,
                      );
        else if (destination.s_addr == INADDR_ANY)
                logger(LOG_INFO, "%s default route via %s" METRIC,
-                      change ? "changing" : del ? "removing" : "adding",
+                      del ? "removing" : "adding",
                       inet_ntoa(gateway)
 
 #ifdef __linux__
@@ -443,7 +443,7 @@ log_route(struct in_addr destination, struct in_addr netmask,
                      );
        else
                logger(LOG_INFO, "%s route to %s/%d via %s" METRIC,
-                      change ? "changing" : del ? "removing" : "adding",
+                      del ? "removing" : "adding",
                       dstd, inet_ntocidr(netmask), inet_ntoa(gateway)
 #ifdef __linux__
                       , metric
@@ -489,6 +489,7 @@ add_route(const char *ifname, struct in_addr destination,
 {
        int retval;
 
+       log_route(destination, netmask, gateway, metric, 0);
        retval = if_route(ifname, destination, netmask, gateway, metric, 0, 0);
        if (retval == -1)
                logger(LOG_ERR, "if_route: %s", strerror(errno));
@@ -501,6 +502,7 @@ del_route(const char *ifname, struct in_addr destination,
 {
        int retval;
 
+       log_route(destination, netmask, gateway, metric, 1);
        retval = if_route(ifname, destination, netmask, gateway, metric, 0, 1);
        if (retval == -1)
                logger(LOG_ERR, "if_route: %s", strerror(errno));
diff --git a/if.h b/if.h
index 1bfe2b2b1ae7a2b90fe9b8018a0c31f042e9287e..311c30b1915afef5da42dbd9d5d744f2bebaa334 100644 (file)
--- a/if.h
+++ b/if.h
@@ -140,7 +140,6 @@ int add_route(const char *, struct in_addr, struct in_addr, struct in_addr,
              int);
 int del_route(const char *, struct in_addr, struct in_addr, struct in_addr,
              int);
-void log_route(struct in_addr, struct in_addr, struct in_addr, int, int, int);
 
 int inet_ntocidr(struct in_addr);
 int inet_cidrtoaddr(int, struct in_addr *);