aboutsummaryrefslogtreecommitdiffstats
path: root/pingu_netlink.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-03-14 09:16:03 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2012-03-14 09:16:03 +0100
commit97456fa7bb23c22e2a06ca4a99e62e75529f8a91 (patch)
tree6958149286cb562d91ca0167eb8ffc3662442eb4 /pingu_netlink.c
parentb29539a9bbe9f328ec0dedfad2cc8efe8b344550 (diff)
downloadpingu-97456fa7bb23c22e2a06ca4a99e62e75529f8a91.tar.bz2
pingu-97456fa7bb23c22e2a06ca4a99e62e75529f8a91.tar.xz
pingu_route: add helper function for generating route string
Use for logging.
Diffstat (limited to 'pingu_netlink.c')
-rw-r--r--pingu_netlink.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/pingu_netlink.c b/pingu_netlink.c
index 0c0ff0e..1dec0c0 100644
--- a/pingu_netlink.c
+++ b/pingu_netlink.c
@@ -643,21 +643,14 @@ static struct pingu_route *gw_from_rtmsg(struct pingu_route *gw,
static void log_route_change(struct pingu_route *route, int table,
int action)
{
- char deststr[64] = "", gwstr[64] = "", viastr[68] = "";
- char ifname[IF_NAMESIZE] = "";
- char devstr[IF_NAMESIZE + 5] = "";
+ char routestr[512] = "";
char *actionstr = "New";
if (action == RTM_DELROUTE)
actionstr = "Delete";
- if (if_indextoname(route->dev_index, ifname) != NULL)
- snprintf(devstr, sizeof(devstr), "dev %s ", ifname);
- sockaddr_to_string(&route->dest, deststr, sizeof(deststr));
- sockaddr_to_string(&route->gw_addr, gwstr, sizeof(gwstr));
- if (gwstr[0] != '\0')
- snprintf(viastr, sizeof(viastr), "via %s ", gwstr);
- log_info("%s route to %s/%i %s%stable %i", actionstr,
- deststr, route->dst_len, viastr, devstr, table);
+ log_info("%s route to %s table %i", actionstr,
+ pingu_route_to_string(route, routestr, sizeof(routestr)),
+ table);
}
void route_changed_for_iface(struct pingu_iface *iface,