}
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;
u_char ip_prefix_length;
union
{
+ u_char addr;
struct in_addr v4_addr;
struct in6_addr v6_addr;
} ip;
* side, which strips type safety since the cast will accept any pointer
* type.)
*/
-union prefix46ptr
+union prefixptr
{
struct prefix *p;
struct prefix_ipv4 *p4;
struct prefix_ipv6 *p6;
+ struct prefix_evpn *evp;
} __attribute__ ((transparent_union));
-union prefix46constptr
+union prefixconstptr
{
const struct prefix *p;
const struct prefix_ipv4 *p4;
const struct prefix_ipv6 *p6;
+ const struct prefix_evpn *evp;
} __attribute__ ((transparent_union));
#ifndef INET_ADDRSTRLEN
#define PREFIX2STR_BUFFER PREFIX_STRLEN
-extern const char *prefix2str (union prefix46constptr, char *, int);
+extern const char *prefix2str (union prefixconstptr, char *, int);
extern int prefix_match (const struct prefix *, const struct prefix *);
extern int prefix_same (const struct prefix *, const struct prefix *);
extern int prefix_cmp (const struct prefix *, const struct prefix *);
}
struct route_node *
-srcdest_rnode_get (struct route_table *table, union prefix46ptr dst_pu,
+srcdest_rnode_get (struct route_table *table, union prefixptr dst_pu,
struct prefix_ipv6 *src_p)
{
struct prefix_ipv6 *dst_p = dst_pu.p6;
}
struct route_node *
-srcdest_rnode_lookup (struct route_table *table, union prefix46ptr dst_pu,
+srcdest_rnode_lookup (struct route_table *table, union prefixptr dst_pu,
struct prefix_ipv6 *src_p)
{
struct prefix_ipv6 *dst_p = dst_pu.p6;
extern struct route_table *srcdest_table_init(void);
extern struct route_node *srcdest_rnode_get(struct route_table *table,
- union prefix46ptr dst_pu,
+ union prefixptr dst_pu,
struct prefix_ipv6 *src_p);
extern struct route_node *srcdest_rnode_lookup(struct route_table *table,
- union prefix46ptr dst_pu,
+ union prefixptr dst_pu,
struct prefix_ipv6 *src_p);
extern void srcdest_rnode_prefixes (struct route_node *rn, struct prefix **p,
struct prefix **src_p);
extern void rib_lookup_and_pushup (struct prefix_ipv4 *, vrf_id_t);
#define rib_dump(prefix, src, rib) _rib_dump(__func__, prefix, src, rib)
extern void _rib_dump (const char *,
- union prefix46constptr,
- union prefix46constptr, const struct rib *);
+ union prefixconstptr,
+ union prefixconstptr, const struct rib *);
extern int rib_lookup_ipv4_route (struct prefix_ipv4 *, union sockunion *,
vrf_id_t);
#define ZEBRA_RIB_LOOKUP_ERROR -1
*/
void _rib_dump (const char * func,
- union prefix46constptr pp,
- union prefix46constptr src_pp,
+ union prefixconstptr pp,
+ union prefixconstptr src_pp,
const struct rib * rib)
{
const struct prefix *p = pp.p;