summaryrefslogtreecommitdiffstats
path: root/pimd/pim_str.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetwroks.com>2016-09-02 16:50:50 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-12-22 02:26:08 +0100
commite66dd14ae46f1dd3929bb6e8d3b436b3ac6fabce (patch)
treec3755eaed325c72e4a52fe0bb7a6a5a12a5ce819 /pimd/pim_str.c
parentpimd: Fix duplicate code in zlookup (diff)
downloadfrr-e66dd14ae46f1dd3929bb6e8d3b436b3ac6fabce.tar.xz
frr-e66dd14ae46f1dd3929bb6e8d3b436b3ac6fabce.zip
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 <sharpd@cumulusnetworks.com>
Diffstat (limited to 'pimd/pim_str.c')
-rw-r--r--pimd/pim_str.c14
1 files changed, 14 insertions, 0 deletions
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;