diff options
| author | Mike RE Mallin <mremallin@gmail.com> | 2024-05-31 10:08:59 -0400 |
|---|---|---|
| committer | Mike RE Mallin <mremallin@gmail.com> | 2024-05-31 10:27:22 -0400 |
| commit | f4f19cc20f73c692a7eead14d4c82740576ea059 (patch) | |
| tree | 5ed78f6fe31ccd6676fdbc8860b72d3ff037d2fe /lib/prefix.c | |
| parent | b69ec60dc6e1f7942a5818b9d7154c1caa0f4441 (diff) | |
lib, zebra: Update prefix_sg structure for IPv6 group support
Signed-off-by: Mike RE Mallin <mremallin@gmail.com>
Diffstat (limited to 'lib/prefix.c')
| -rw-r--r-- | lib/prefix.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/prefix.c b/lib/prefix.c index f342c4c1db..2485c3e61b 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, "*)"); |
