From e66dd14ae46f1dd3929bb6e8d3b436b3ac6fabce Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 2 Sep 2016 10:50:50 -0400 Subject: pimd: Add pim_addr_dump to facilitate v4 and v6 address dumping Allow pim_addr_dump to understand prefixes to print out. Signed-off-by: Donald Sharp --- pimd/pim_str.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'pimd/pim_str.c') diff --git a/pimd/pim_str.c b/pimd/pim_str.c index 8e1d7cec2..ca635c8a5 100644 --- a/pimd/pim_str.c +++ b/pimd/pim_str.c @@ -29,6 +29,20 @@ #include "pim_str.h" +void pim_addr_dump (const char *onfail, struct prefix *p, char *buf, int buf_size) +{ + int save_errno = errno; + + if (!inet_ntop(p->family, &p->u.prefix, buf, buf_size)) { + zlog_warn("pim_addr_dump: inet_ntop(buf_size=%d): errno=%d: %s", + buf_size, errno, safe_strerror(errno)); + if (onfail) + snprintf(buf, buf_size, "%s", onfail); + } + + errno = save_errno; +} + void pim_inet4_dump(const char *onfail, struct in_addr addr, char *buf, int buf_size) { int save_errno = errno; -- cgit v1.2.3