diff options
author | Jiri Pirko <jiri@resnulli.us> | 2013-04-15 17:21:15 +0200 |
---|---|---|
committer | Jiri Pirko <jiri@resnulli.us> | 2013-04-17 17:17:48 +0200 |
commit | 1bb29270ca09e9444630450fa134427e2b387cb3 (patch) | |
tree | 13ea79a6f03587a7118711f5f99276e21930d191 /utils | |
parent | 70540ef693a54785ff7696ff938943a4b272ec3f (diff) | |
download | libndp-1bb29270ca09e9444630450fa134427e2b387cb3.tar.gz |
ndptool: push litefime printout into separete function
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/ndptool.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/utils/ndptool.c b/utils/ndptool.c index 6d45097..fc0d307 100644 --- a/utils/ndptool.c +++ b/utils/ndptool.c @@ -179,6 +179,14 @@ static void pr_out_route_preference(enum ndp_route_preference pref) } } +static void pr_out_lft(uint32_t lifetime) +{ + if (lifetime == (uint32_t) -1) + pr_out("infinity"); + else + pr_out("%us", lifetime); +} + static int msgrcv_handler_func(struct ndp *ndp, struct ndp_msg *msg, void *priv) { char ifname[IF_NAMESIZE]; @@ -254,17 +262,11 @@ static int msgrcv_handler_func(struct ndp *ndp, struct ndp_msg *msg, void *priv) ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_MTU) pr_out(" MTU: %u\n", ndp_msg_opt_mtu(msg, offset)); ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_ROUTE) { - uint32_t lifetime; - - lifetime = ndp_msg_opt_route_lifetime(msg, offset); pr_out(" Route: %s/%u", str_in6_addr(ndp_msg_opt_route_prefix(msg, offset)), ndp_msg_opt_route_prefix_len(msg, offset)); pr_out(", lifetime: "); - if (lifetime == (uint32_t) -1) - pr_out("infinity"); - else - pr_out("%us", lifetime); + pr_out_lft(ndp_msg_opt_route_lifetime(msg, offset)); pr_out(", preference: "); pr_out_route_preference(ndp_msg_opt_route_preference(msg, offset)); pr_out("\n"); @@ -272,9 +274,7 @@ static int msgrcv_handler_func(struct ndp *ndp, struct ndp_msg *msg, void *priv) ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_RDNSS) { static struct in6_addr *addr; int addr_index; - uint32_t lifetime; - lifetime = ndp_msg_opt_rdnss_lifetime(msg, offset); pr_out(" Recursive DNS Servers: "); ndp_msg_opt_rdnss_for_each_addr(addr, addr_index, msg, offset) { if (addr_index != 0) @@ -282,18 +282,13 @@ static int msgrcv_handler_func(struct ndp *ndp, struct ndp_msg *msg, void *priv) pr_out("%s", str_in6_addr(addr)); } pr_out(", lifetime: "); - if (lifetime == (uint32_t) -1) - pr_out("infinity"); - else - pr_out("%us", lifetime); + pr_out_lft(ndp_msg_opt_rdnss_lifetime(msg, offset)); pr_out("\n"); } ndp_msg_opt_for_each_offset(offset, msg, NDP_MSG_OPT_DNSSL) { char *domain; int domain_index; - uint32_t lifetime; - lifetime = ndp_msg_opt_rdnss_lifetime(msg, offset); pr_out(" DNS Search List: "); ndp_msg_opt_dnssl_for_each_domain(domain, domain_index, msg, offset) { if (domain_index != 0) @@ -301,10 +296,7 @@ static int msgrcv_handler_func(struct ndp *ndp, struct ndp_msg *msg, void *priv) pr_out("%s", domain); } pr_out(", lifetime: "); - if (lifetime == (uint32_t) -1) - pr_out("infinity"); - else - pr_out("%us", lifetime); + pr_out_lft(ndp_msg_opt_rdnss_lifetime(msg, offset)); pr_out("\n"); } } else if (msg_type == NDP_MSG_NS) { |