summaryrefslogtreecommitdiff
path: root/lib/prefix.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/prefix.h')
-rw-r--r--lib/prefix.h47
1 files changed, 43 insertions, 4 deletions
diff --git a/lib/prefix.h b/lib/prefix.h
index 56adce5eab..eb3ae3dafb 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -49,9 +49,45 @@
*/
struct ethaddr {
u_char octet[ETHER_ADDR_LEN];
-} __packed;
+} __attribute__ ((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
+#define IP_PREFIX_V4 0x4
+#define IP_PREFIX_V6 0x8
+ struct ethaddr mac;
+ uint32_t eth_tag;
+ u_char ip_prefix_length;
+ union
+ {
+ u_char addr;
+ 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
@@ -88,6 +124,7 @@ struct prefix
struct ethaddr prefix_eth; /* AF_ETHERNET */
u_char val[8];
uintptr_t ptr;
+ struct evpn_addr prefix_evpn;
} u __attribute__ ((aligned (8)));
};
@@ -152,18 +189,20 @@ struct prefix_sg
* 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
@@ -237,7 +276,7 @@ extern int str2prefix (const char *, struct prefix *);
#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 *);