From: Lou Berger Date: Tue, 12 Jan 2016 18:41:50 +0000 (-0500) Subject: lib: add SAFI_ENCAP type, safi2str prefix utility X-Git-Tag: frr-2.0-rc1~692 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=1ec23d90a36d4dd6067157d40a82a8ad8bdb1a80;p=matthieu%2Ffrr.git lib: add SAFI_ENCAP type, safi2str prefix utility Signed-off-by: Lou Berger (cherry picked from commit 2daf7f3a8d69213f35b16a04dbe300957481a811) --- diff --git a/lib/prefix.c b/lib/prefix.c index 1614cd5603..d0cd894690 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -223,6 +223,22 @@ family2afi (int family) return 0; } +const char * +safi2str(safi_t safi) +{ + switch (safi) { + case SAFI_UNICAST: + return "unicast"; + case SAFI_MULTICAST: + return "multicast"; + case SAFI_ENCAP: + return "encap"; + case SAFI_MPLS_VPN: + return "vpn"; + } + return NULL; +} + /* If n includes p prefix then return 1 else return 0. */ int prefix_match (const struct prefix *n, const struct prefix *p) diff --git a/lib/prefix.h b/lib/prefix.h index 73ae0f25a7..ebdd80b8fd 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -170,6 +170,7 @@ union prefix46constptr extern int str2family(const char *); extern int afi2family (afi_t); extern afi_t family2afi (int); +extern const char *safi2str(safi_t safi); /* Check bit of the prefix. */ extern unsigned int prefix_bit (const u_char *prefix, const u_char prefixlen); diff --git a/lib/zebra.h b/lib/zebra.h index 77870462e5..9a2b5441fc 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -536,7 +536,8 @@ extern const char *zserv_command_string (unsigned int command); #define SAFI_MULTICAST 2 #define SAFI_RESERVED_3 3 #define SAFI_MPLS_VPN 4 -#define SAFI_MAX 5 +#define SAFI_ENCAP 7 /* per IANA */ +#define SAFI_MAX 8 /* Filter direction. */ #define FILTER_IN 0