From a440846ea622ef4ac3ef681baff4c5331487b8f1 Mon Sep 17 00:00:00 2001 From: vivek Date: Wed, 27 Jul 2016 10:20:47 -0700 Subject: [PATCH] lib: EVPN prefix definition Extend the prefix data structure to allow for basic support for EVPN type-3 and type-2 routes. Note: This may be revised in future. Signed-off-by: Vivek Venkatraman Reviewed-by: Donald Sharp Ticket: CM-11937 Reviewed By: CCR-5001 Testing Done: None Signed-off-by: Philippe Guibert --- lib/prefix.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/prefix.h b/lib/prefix.h index eb69e98f0..b96a17cd0 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -47,6 +47,39 @@ struct ethaddr { } __packed; +/* length is the number of valuable bits of prefix structure +* 18 bytes is current length in structure, if address is ipv4 +* 30 bytes is in case of ipv6 +*/ +#define PREFIX_LEN_ROUTE_TYPE_5_IPV4 (18*8) +#define PREFIX_LEN_ROUTE_TYPE_5_IPV6 (30*8) + +/* EVPN address (RFC 7432) */ +struct evpn_addr +{ + u_char route_type; + u_char flags; +#define IP_ADDR_NONE 0x0 +#define IP_ADDR_V4 0x1 +#define IP_ADDR_V6 0x2 + struct ethaddr mac; + uint32_t eth_tag; + u_char ip_prefix_length; + union + { + struct in_addr v4_addr; + struct in6_addr v6_addr; + } ip; +}; + +/* EVPN prefix structure. */ +struct prefix_evpn +{ + u_char family; + u_char prefixlen; + struct evpn_addr prefix __attribute__ ((aligned (8))); +}; + /* * A struct prefix contains an address family, a prefix length, and an * address. This can represent either a 'network prefix' as defined @@ -83,6 +116,9 @@ struct prefix struct ethaddr prefix_eth; /* AF_ETHERNET */ u_char val[8]; uintptr_t ptr; +#if defined(HAVE_EVPN) + struct evpn_addr prefix_evpn; +#endif } u __attribute__ ((aligned (8))); }; -- 2.39.5