summaryrefslogtreecommitdiff
path: root/lib/prefix.h
diff options
context:
space:
mode:
authorAnuradha Karuppiah <anuradhak@cumulusnetworks.com>2020-07-13 18:21:27 -0700
committerAnuradha Karuppiah <anuradhak@cumulusnetworks.com>2020-08-05 06:46:13 -0700
commit2ff12693b1d3aae8e1790a71bf280a98e4d9e910 (patch)
tree77a976515a314bc2efbd8f616c61419f74f6cbec /lib/prefix.h
parent9e0c2fd182b1f7ec687f2b29ac5f779cf2ce3a13 (diff)
bgpd, lib: move EVPN route type def to lib and use it in the prefix macros
Use route names instead of route type number in the EVPN prefix macros. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Diffstat (limited to 'lib/prefix.h')
-rw-r--r--lib/prefix.h39
1 files changed, 24 insertions, 15 deletions
diff --git a/lib/prefix.h b/lib/prefix.h
index d9edd9ee96..400f07386f 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -43,6 +43,15 @@ extern "C" {
#define ETH_ALEN 6
#endif
+/* EVPN route types. */
+typedef enum {
+ BGP_EVPN_AD_ROUTE = 1, /* Ethernet Auto-Discovery (A-D) route */
+ BGP_EVPN_MAC_IP_ROUTE, /* MAC/IP Advertisement route */
+ BGP_EVPN_IMET_ROUTE, /* Inclusive Multicast Ethernet Tag route */
+ BGP_EVPN_ES_ROUTE, /* Ethernet Segment route */
+ BGP_EVPN_IP_PREFIX_ROUTE, /* IP Prefix route */
+} bgp_evpn_route_type;
+
/* value of first byte of ESI */
#define ESI_TYPE_ARBITRARY 0 /* */
#define ESI_TYPE_LACP 1 /* <> */
@@ -236,45 +245,45 @@ struct prefix_evpn {
static inline int is_evpn_prefix_ipaddr_none(const struct prefix_evpn *evp)
{
- if (evp->prefix.route_type == 1)
+ if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE)
return IS_IPADDR_NONE(&(evp)->prefix.ead_addr.ip);
- if (evp->prefix.route_type == 2)
+ if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)
return IS_IPADDR_NONE(&(evp)->prefix.macip_addr.ip);
- if (evp->prefix.route_type == 3)
+ if (evp->prefix.route_type == BGP_EVPN_IMET_ROUTE)
return IS_IPADDR_NONE(&(evp)->prefix.imet_addr.ip);
- if (evp->prefix.route_type == 4)
+ if (evp->prefix.route_type == BGP_EVPN_ES_ROUTE)
return IS_IPADDR_NONE(&(evp)->prefix.es_addr.ip);
- if (evp->prefix.route_type == 5)
+ if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)
return IS_IPADDR_NONE(&(evp)->prefix.prefix_addr.ip);
return 0;
}
static inline int is_evpn_prefix_ipaddr_v4(const struct prefix_evpn *evp)
{
- if (evp->prefix.route_type == 1)
+ if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE)
return IS_IPADDR_V4(&(evp)->prefix.ead_addr.ip);
- if (evp->prefix.route_type == 2)
+ if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)
return IS_IPADDR_V4(&(evp)->prefix.macip_addr.ip);
- if (evp->prefix.route_type == 3)
+ if (evp->prefix.route_type == BGP_EVPN_IMET_ROUTE)
return IS_IPADDR_V4(&(evp)->prefix.imet_addr.ip);
- if (evp->prefix.route_type == 4)
+ if (evp->prefix.route_type == BGP_EVPN_ES_ROUTE)
return IS_IPADDR_V4(&(evp)->prefix.es_addr.ip);
- if (evp->prefix.route_type == 5)
+ if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)
return IS_IPADDR_V4(&(evp)->prefix.prefix_addr.ip);
return 0;
}
static inline int is_evpn_prefix_ipaddr_v6(const struct prefix_evpn *evp)
{
- if (evp->prefix.route_type == 1)
+ if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE)
return IS_IPADDR_V6(&(evp)->prefix.ead_addr.ip);
- if (evp->prefix.route_type == 2)
+ if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)
return IS_IPADDR_V6(&(evp)->prefix.macip_addr.ip);
- if (evp->prefix.route_type == 3)
+ if (evp->prefix.route_type == BGP_EVPN_IMET_ROUTE)
return IS_IPADDR_V6(&(evp)->prefix.imet_addr.ip);
- if (evp->prefix.route_type == 4)
+ if (evp->prefix.route_type == BGP_EVPN_ES_ROUTE)
return IS_IPADDR_V6(&(evp)->prefix.es_addr.ip);
- if (evp->prefix.route_type == 5)
+ if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)
return IS_IPADDR_V6(&(evp)->prefix.prefix_addr.ip);
return 0;
}