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));
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
);
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__
);
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
{
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));
{
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));
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 *);