From: Roy Marples Date: Sat, 29 Mar 2008 11:36:43 +0000 (+0000) Subject: Move log_route to if.c X-Git-Tag: v4.0.2~522 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9cd4f845aff87a8b6d1faae544fc93dff2035e4;p=thirdparty%2Fdhcpcd.git Move log_route to if.c --- diff --git a/if-bsd.c b/if-bsd.c index cbb90c9d..41ca61c8 100644 --- 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; diff --git a/if-linux.c b/if-linux.c index b579989e..ebe02371 100644 --- a/if-linux.c +++ b/if-linux.c @@ -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 5044c2ee..97ed3cf9 100644 --- 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 1bfe2b2b..311c30b1 100644 --- 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 *);