diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-06-02 01:11:28 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-06-02 20:51:52 +0200 |
commit | 748a041f09a8f89d07979c0ba73738f3292a28aa (patch) | |
tree | 3c53a63ef39bd3210792e44b7dd242723abade2b /lib/zebra.h | |
parent | lib: Remove some iana_afi_t values that are not really afi's (diff) | |
download | frr-748a041f09a8f89d07979c0ba73738f3292a28aa.tar.xz frr-748a041f09a8f89d07979c0ba73738f3292a28aa.zip |
bgpd, lib: Add iana_afi2str and iana_safi2str for eye pleasing strings
Modify the code such that we can auto turn the iana values of afi
and safi to pleasant to read strings.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/zebra.h')
-rw-r--r-- | lib/zebra.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/zebra.h b/lib/zebra.h index a0337dc3c..336ecb38f 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -510,6 +510,22 @@ typedef uint32_t route_tag_t; #define ROUTE_TAG_MAX UINT32_MAX #define ROUTE_TAG_PRI PRIu32 +static inline const char *iana_afi2str(iana_afi_t afi) +{ + switch (afi) { + case IANA_AFI_RESERVED: + return "Reserved"; + case IANA_AFI_IPV4: + return "IPv4"; + case IANA_AFI_IPV6: + return "IPv6"; + case IANA_AFI_L2VPN: + return "L2VPN"; + } + + return "Unknown"; +} + static inline afi_t afi_iana2int(iana_afi_t afi) { switch (afi) { @@ -538,6 +554,30 @@ static inline iana_afi_t afi_int2iana(afi_t afi) } } +static inline const char *iana_safi2str(iana_safi_t safi) +{ + switch (safi) { + case IANA_SAFI_RESERVED: + return "Reserved"; + case IANA_SAFI_UNICAST: + return "Unicast"; + case IANA_SAFI_MULTICAST: + return "Multicast"; + case IANA_SAFI_LABELED_UNICAST: + return "Labeled Unicast"; + case IANA_SAFI_ENCAP: + return "Encap"; + case IANA_SAFI_EVPN: + return "EVPN"; + case IANA_SAFI_MPLS_VPN: + return "MPLS VPN"; + case IANA_SAFI_FLOWSPEC: + return "FlowSpec"; + } + + return "Unknown"; +} + static inline safi_t safi_iana2int(iana_safi_t safi) { switch (safi) { |