diff options
| author | vivek <vivek@cumulusnetworks.com> | 2016-08-09 15:55:51 -0700 |
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2017-02-14 13:58:58 +0100 |
| commit | 78b81eaa44d74c988a681b96574a7b6897e7dea0 (patch) | |
| tree | 797b8d3d0ad309c04379118527e1e427d6c4d9ea /lib/prefix.c | |
| parent | fd6c6cb49b37168dc5fd936b046299009da2fc7e (diff) | |
lib: Enhance prefix dump for EVPN prefixes
This commit is also taking into account changes related to srcdes
feature introduction in zebra folder.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Ticket: CM-12262
Reviewed By: CCR-5065
Testing Done: Manual
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'lib/prefix.c')
| -rw-r--r-- | lib/prefix.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/lib/prefix.c b/lib/prefix.c index 06ed00baa9..6d3de3d6c6 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -859,23 +859,39 @@ str2prefix (const char *str, struct prefix *p) } const char * -prefix2str (union prefix46constptr pu, char *str, int size) +prefix2str (union prefixconstptr pu, char *str, int size) { const struct prefix *p = pu.p; + char buf[PREFIX2STR_BUFFER]; - if (p->family == AF_ETHERNET) - { - snprintf(str, size, "%02x:%02x:%02x:%02x:%02x:%02x/%d", - p->u.prefix_eth.octet[0], p->u.prefix_eth.octet[1], - p->u.prefix_eth.octet[2], p->u.prefix_eth.octet[3], - p->u.prefix_eth.octet[4], p->u.prefix_eth.octet[5], - p->prefixlen); - } - else + switch (p->family) { - char buf[PREFIX2STR_BUFFER]; - inet_ntop(p->family, &p->u.prefix, buf, sizeof(buf)); - snprintf(str, size, "%s/%d", buf, p->prefixlen); + u_char family; + + case AF_INET: + case AF_INET6: + snprintf (str, size, "%s/%d", + inet_ntop (p->family, &p->u.prefix, buf, PREFIX2STR_BUFFER), + p->prefixlen); + break; + + case AF_ETHERNET: + if (p->u.prefix_evpn.route_type == 5) + { + family = (p->u.prefix_evpn.flags & (IP_ADDR_V4 | IP_PREFIX_V4)) ? + AF_INET : AF_INET6; + snprintf (str, size, "[%d]:[%u][%s]/%d", + p->u.prefix_evpn.route_type, + p->u.prefix_evpn.eth_tag, + inet_ntop (family, &p->u.prefix_evpn.ip.addr, + buf, PREFIX2STR_BUFFER), + p->prefixlen); + } + break; + + default: + sprintf (str, "UNK prefix"); + break; } return str; |
