summaryrefslogtreecommitdiffstats
path: root/lib/prefix.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/prefix.c')
-rw-r--r--lib/prefix.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/prefix.c b/lib/prefix.c
index f342c4c..2485c3e 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -1124,6 +1124,15 @@ const char *prefix2str(union prefixconstptr pu, char *str, int size)
return str;
}
+void prefix_mcast_ip_dump(const char *onfail, const struct ipaddr *addr,
+ char *buf, int buf_size)
+{
+ if (ipaddr_is_zero(addr))
+ strlcpy(buf, "*", buf_size);
+ else
+ (void)snprintfrr(buf, buf_size, "%pIA", addr);
+}
+
static ssize_t prefixhost2str(struct fbuf *fbuf, union prefixconstptr pu)
{
const struct prefix *p = pu.p;
@@ -1166,7 +1175,7 @@ const char *prefix_sg2str(const struct prefix_sg *sg, char *sg_str)
char src_str[INET_ADDRSTRLEN];
char grp_str[INET_ADDRSTRLEN];
- prefix_mcast_inet4_dump("<src?>", sg->src, src_str, sizeof(src_str));
+ prefix_mcast_ip_dump("<src?>", &sg->src, src_str, sizeof(src_str));
prefix_mcast_inet4_dump("<grp?>", sg->grp, grp_str, sizeof(grp_str));
snprintf(sg_str, PREFIX_SG_STR_LEN, "(%s,%s)", src_str, grp_str);
@@ -1637,10 +1646,10 @@ static ssize_t printfrr_psg(struct fbuf *buf, struct printfrr_eargs *ea,
if (!sg)
return bputs(buf, "(null)");
- if (sg->src.s_addr == INADDR_ANY)
+ if (ipaddr_is_zero(&sg->src))
ret += bputs(buf, "(*,");
else
- ret += bprintfrr(buf, "(%pI4,", &sg->src);
+ ret += bprintfrr(buf, "(%pIA,", &sg->src);
if (sg->grp.s_addr == INADDR_ANY)
ret += bputs(buf, "*)");