From d92050a607c0400a2a0f78eaa95fb4aa9b86c5d4 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 2 Jun 2019 14:47:01 -0400 Subject: [PATCH 1/3] lib: Remove some iana_afi_t values that are not really afi's The IPMR and IP6MR values have no actual legal representation and we do not sue them at all. Signed-off-by: Donald Sharp --- lib/zebra.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/zebra.h b/lib/zebra.h index 3e1eefdb2e..a0337dc3cf 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -456,8 +456,6 @@ typedef enum { IANA_AFI_IPV4 = 1, IANA_AFI_IPV6 = 2, IANA_AFI_L2VPN = 25, - IANA_AFI_IPMR = 128, - IANA_AFI_IP6MR = 129 } iana_afi_t; typedef enum { From 748a041f09a8f89d07979c0ba73738f3292a28aa Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 1 Jun 2019 19:11:28 -0400 Subject: [PATCH 2/3] 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 --- bgpd/bgp_attr.c | 10 +++++---- bgpd/bgp_open.c | 55 +++++++++++++++++++++++++++-------------------- bgpd/bgp_packet.c | 35 ++++++++++++++++++------------ lib/zebra.h | 40 ++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 41 deletions(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 5a4105b400..d46623c9d2 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -1664,8 +1664,9 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args, */ if (bgp_debug_update(peer, NULL, NULL, 0)) zlog_debug( - "%s: MP_REACH received AFI %u or SAFI %u is unrecognized", - peer->host, pkt_afi, pkt_safi); + "%s: MP_REACH received AFI %s or SAFI %s is unrecognized", + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); return BGP_ATTR_PARSE_ERROR; } @@ -1849,8 +1850,9 @@ int bgp_mp_unreach_parse(struct bgp_attr_parser_args *args, */ if (bgp_debug_update(peer, NULL, NULL, 0)) zlog_debug( - "%s: MP_UNREACH received AFI %u or SAFI %u is unrecognized", - peer->host, pkt_afi, pkt_safi); + "%s: MP_UNREACH received AFI %s or SAFI %s is unrecognized", + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); return BGP_ATTR_PARSE_ERROR; } diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 7af5827d00..64529f6ef3 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -264,8 +264,9 @@ static int bgp_capability_mp(struct peer *peer, struct capability_header *hdr) bgp_capability_mp_data(s, &mpc); if (bgp_debug_neighbor_events(peer)) - zlog_debug("%s OPEN has MP_EXT CAP for afi/safi: %u/%u", - peer->host, mpc.afi, mpc.safi); + zlog_debug("%s OPEN has MP_EXT CAP for afi/safi: %s/%s", + peer->host, iana_afi2str(mpc.afi), + iana_safi2str(mpc.safi)); /* Convert AFI, SAFI to internal values, check. */ if (bgp_map_afi_safi_iana2int(mpc.afi, mpc.safi, &afi, &safi)) @@ -325,8 +326,8 @@ static int bgp_capability_orf_entry(struct peer *peer, pkt_safi = mpc.safi; if (bgp_debug_neighbor_events(peer)) - zlog_debug("%s ORF Cap entry for afi/safi: %u/%u", peer->host, - mpc.afi, mpc.safi); + zlog_debug("%s ORF Cap entry for afi/safi: %s/%s", peer->host, + iana_afi2str(mpc.afi), iana_safi2str(mpc.safi)); /* Convert AFI, SAFI to internal values, check. */ if (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi, &safi)) { @@ -407,11 +408,11 @@ static int bgp_capability_orf_entry(struct peer *peer, if (bgp_debug_neighbor_events(peer)) zlog_debug( "%s OPEN has %s ORF capability" - " as %s for afi/safi: %d/%d", + " as %s for afi/safi: %s/%s", peer->host, lookup_msg(orf_type_str, type, NULL), - lookup_msg(orf_mode_str, mode, NULL), pkt_afi, - pkt_safi); + lookup_msg(orf_mode_str, mode, NULL), + iana_afi2str(pkt_afi), iana_safi2str(pkt_safi)); if (hdr->code == CAPABILITY_CODE_ORF) { sm_cap = PEER_CAP_ORF_PREFIX_SM_RCV; @@ -487,15 +488,17 @@ static int bgp_capability_restart(struct peer *peer, if (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi, &safi)) { if (bgp_debug_neighbor_events(peer)) zlog_debug( - "%s Addr-family %d/%d(afi/safi) not supported." + "%s Addr-family %s/%s(afi/safi) not supported." " Ignore the Graceful Restart capability for this AFI/SAFI", - peer->host, pkt_afi, pkt_safi); + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); } else if (!peer->afc[afi][safi]) { if (bgp_debug_neighbor_events(peer)) zlog_debug( - "%s Addr-family %d/%d(afi/safi) not enabled." + "%s Addr-family %s/%s(afi/safi) not enabled." " Ignore the Graceful Restart capability", - peer->host, pkt_afi, pkt_safi); + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); } else { if (bgp_debug_neighbor_events(peer)) zlog_debug( @@ -564,8 +567,9 @@ static int bgp_capability_addpath(struct peer *peer, if (bgp_debug_neighbor_events(peer)) zlog_debug( - "%s OPEN has AddPath CAP for afi/safi: %u/%u%s%s", - peer->host, pkt_afi, pkt_safi, + "%s OPEN has AddPath CAP for afi/safi: %s/%s%s%s", + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi), (send_receive & BGP_ADDPATH_RX) ? ", receive" : "", (send_receive & BGP_ADDPATH_TX) ? ", transmit" @@ -575,16 +579,18 @@ static int bgp_capability_addpath(struct peer *peer, if (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi, &safi)) { if (bgp_debug_neighbor_events(peer)) zlog_debug( - "%s Addr-family %d/%d(afi/safi) not supported." + "%s Addr-family %s/%s(afi/safi) not supported." " Ignore the Addpath Attribute for this AFI/SAFI", - peer->host, pkt_afi, pkt_safi); + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); continue; } else if (!peer->afc[afi][safi]) { if (bgp_debug_neighbor_events(peer)) zlog_debug( - "%s Addr-family %d/%d(afi/safi) not enabled." + "%s Addr-family %s/%s(afi/safi) not enabled." " Ignore the AddPath capability for this AFI/SAFI", - peer->host, pkt_afi, pkt_safi); + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); continue; } @@ -624,16 +630,18 @@ static int bgp_capability_enhe(struct peer *peer, struct capability_header *hdr) if (bgp_debug_neighbor_events(peer)) zlog_debug( - "%s Received with afi/safi/next-hop afi: %u/%u/%u", - peer->host, pkt_afi, pkt_safi, pkt_nh_afi); + "%s Received with afi/safi/next-hop afi: %s/%s/%u", + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi), pkt_nh_afi); /* Convert AFI, SAFI to internal values, check. */ if (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi, &safi)) { if (bgp_debug_neighbor_events(peer)) zlog_debug( - "%s Addr-family %d/%d(afi/safi) not supported." + "%s Addr-family %s/%s(afi/safi) not supported." " Ignore the ENHE Attribute for this AFI/SAFI", - peer->host, pkt_afi, pkt_safi); + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); continue; } @@ -652,9 +660,10 @@ static int bgp_capability_enhe(struct peer *peer, struct capability_header *hdr) || safi == SAFI_LABELED_UNICAST)) { flog_warn( EC_BGP_CAPABILITY_INVALID_DATA, - "%s Unexpected afi/safi/next-hop afi: %u/%u/%u " + "%s Unexpected afi/safi/next-hop afi: %s/%s/%u " "in Extended Next-hop capability, ignoring", - peer->host, pkt_afi, pkt_safi, pkt_nh_afi); + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi), pkt_nh_afi); continue; } diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 655a4745cb..bb9c394047 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -822,12 +822,13 @@ void bgp_route_refresh_send(struct peer *peer, afi_t afi, safi_t safi, stream_putc(s, ORF_COMMON_PART_REMOVE_ALL); if (bgp_debug_neighbor_events(peer)) zlog_debug( - "%s sending REFRESH_REQ to remove ORF(%d) (%s) for afi/safi: %d/%d", + "%s sending REFRESH_REQ to remove ORF(%d) (%s) for afi/safi: %s/%s", peer->host, orf_type, (when_to_refresh == REFRESH_DEFER ? "defer" : "immediate"), - pkt_afi, pkt_safi); + iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); } else { SET_FLAG(peer->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND); @@ -838,12 +839,13 @@ void bgp_route_refresh_send(struct peer *peer, afi_t afi, safi_t safi, ORF_COMMON_PART_DENY); if (bgp_debug_neighbor_events(peer)) zlog_debug( - "%s sending REFRESH_REQ with pfxlist ORF(%d) (%s) for afi/safi: %d/%d", + "%s sending REFRESH_REQ with pfxlist ORF(%d) (%s) for afi/safi: %s/%s", peer->host, orf_type, (when_to_refresh == REFRESH_DEFER ? "defer" : "immediate"), - pkt_afi, pkt_safi); + iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); } /* Total ORF Entry Len. */ @@ -856,8 +858,9 @@ void bgp_route_refresh_send(struct peer *peer, afi_t afi, safi_t safi, if (bgp_debug_neighbor_events(peer)) { if (!orf_refresh) - zlog_debug("%s sending REFRESH_REQ for afi/safi: %d/%d", - peer->host, pkt_afi, pkt_safi); + zlog_debug("%s sending REFRESH_REQ for afi/safi: %s/%s", + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); } /* Add packet to the peer. */ @@ -901,11 +904,11 @@ void bgp_capability_send(struct peer *peer, afi_t afi, safi_t safi, if (bgp_debug_neighbor_events(peer)) zlog_debug( - "%s sending CAPABILITY has %s MP_EXT CAP for afi/safi: %d/%d", + "%s sending CAPABILITY has %s MP_EXT CAP for afi/safi: %s/%s", peer->host, action == CAPABILITY_ACTION_SET ? "Advertising" : "Removing", - pkt_afi, pkt_safi); + iana_afi2str(pkt_afi), iana_safi2str(pkt_safi)); } /* Set packet size. */ @@ -1788,14 +1791,16 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size) pkt_safi = stream_getc(s); if (bgp_debug_update(peer, NULL, NULL, 0)) - zlog_debug("%s rcvd REFRESH_REQ for afi/safi: %d/%d", - peer->host, pkt_afi, pkt_safi); + zlog_debug("%s rcvd REFRESH_REQ for afi/safi: %s/%s", + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); /* Convert AFI, SAFI to internal values and check. */ if (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi, &safi)) { zlog_info( - "%s REFRESH_REQ for unrecognized afi/safi: %d/%d - ignored", - peer->host, pkt_afi, pkt_safi); + "%s REFRESH_REQ for unrecognized afi/safi: %s/%s - ignored", + peer->host, iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); return BGP_PACKET_NOOP; } @@ -2090,8 +2095,10 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt, if (bgp_debug_neighbor_events(peer)) zlog_debug( "%s Dynamic Capability MP_EXT afi/safi invalid " - "(%u/%u)", - peer->host, pkt_afi, pkt_safi); + "(%s/%s)", + peer->host, + iana_afi2str(pkt_afi), + iana_safi2str(pkt_safi)); continue; } diff --git a/lib/zebra.h b/lib/zebra.h index a0337dc3cf..336ecb38f3 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) { From 17136bf23e2ceb1d8a93ef79e8ba87f23c3dd260 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 2 Jun 2019 15:02:07 -0400 Subject: [PATCH 3/3] lib, bgpd: Create iana_afi.h for storing iana_afi/safi enums The iana_afi_t and iana_safi_t were being created in zebra.h and zebra.h is a bit of a dumping ground. When the iana_afi2str and iana_safi2str functions were created, it was correctly pointed out that we should just use the internal afi_t and safi_t 2str functions but to do that we would need to include prefix.h in zebra.h. Which really is not the right thing to do. This tells us that we need to break out this code into it's own header. Move to iana_afi.h the enums and specific functions and remove from zebra. Convert to using the afi2str and safi2str functions. Signed-off-by: Donald Sharp --- bgpd/bgpd.h | 1 + lib/iana_afi.h | 133 ++++++++++++++++++++++++++++++++++++++++++++++ lib/subdir.am | 1 + lib/zebra.h | 139 ------------------------------------------------- 4 files changed, 135 insertions(+), 139 deletions(-) create mode 100644 lib/iana_afi.h diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index c600d9f3f3..81c741dd6a 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -28,6 +28,7 @@ #include "lib/json.h" #include "vrf.h" #include "vty.h" +#include "iana_afi.h" /* For union sockunion. */ #include "queue.h" diff --git a/lib/iana_afi.h b/lib/iana_afi.h new file mode 100644 index 0000000000..ac03f73193 --- /dev/null +++ b/lib/iana_afi.h @@ -0,0 +1,133 @@ +/* + * iana_afi and safi definitions. + * Copyright (C) 2018-2019 Cumulus Networks, Inc. + * Donald Sharp + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __IANA_AFI_H__ + +#include + +/* + * The above AFI and SAFI definitions are for internal use. The protocol + * definitions (IANA values) as for example used in BGP protocol packets + * are defined below and these will get mapped to/from the internal values + * in the appropriate places. + * The rationale is that the protocol (IANA) values may be sparse and are + * not optimal for use in data-structure sizing. + * Note: Only useful (i.e., supported) values are defined below. + */ +typedef enum { + IANA_AFI_RESERVED = 0, + IANA_AFI_IPV4 = 1, + IANA_AFI_IPV6 = 2, + IANA_AFI_L2VPN = 25, +} iana_afi_t; + +typedef enum { + IANA_SAFI_RESERVED = 0, + IANA_SAFI_UNICAST = 1, + IANA_SAFI_MULTICAST = 2, + IANA_SAFI_LABELED_UNICAST = 4, + IANA_SAFI_ENCAP = 7, + IANA_SAFI_EVPN = 70, + IANA_SAFI_MPLS_VPN = 128, + IANA_SAFI_FLOWSPEC = 133 +} iana_safi_t; + +static inline afi_t afi_iana2int(iana_afi_t afi) +{ + switch (afi) { + case IANA_AFI_IPV4: + return AFI_IP; + case IANA_AFI_IPV6: + return AFI_IP6; + case IANA_AFI_L2VPN: + return AFI_L2VPN; + default: + return AFI_MAX; + } +} + +static inline iana_afi_t afi_int2iana(afi_t afi) +{ + switch (afi) { + case AFI_IP: + return IANA_AFI_IPV4; + case AFI_IP6: + return IANA_AFI_IPV6; + case AFI_L2VPN: + return IANA_AFI_L2VPN; + default: + return IANA_AFI_RESERVED; + } +} + +static inline const char *iana_afi2str(iana_afi_t afi) +{ + return afi2str(afi_iana2int(afi)); +} + +static inline safi_t safi_iana2int(iana_safi_t safi) +{ + switch (safi) { + case IANA_SAFI_UNICAST: + return SAFI_UNICAST; + case IANA_SAFI_MULTICAST: + return SAFI_MULTICAST; + case IANA_SAFI_MPLS_VPN: + return SAFI_MPLS_VPN; + case IANA_SAFI_ENCAP: + return SAFI_ENCAP; + case IANA_SAFI_EVPN: + return SAFI_EVPN; + case IANA_SAFI_LABELED_UNICAST: + return SAFI_LABELED_UNICAST; + case IANA_SAFI_FLOWSPEC: + return SAFI_FLOWSPEC; + default: + return SAFI_MAX; + } +} + +static inline iana_safi_t safi_int2iana(safi_t safi) +{ + switch (safi) { + case SAFI_UNICAST: + return IANA_SAFI_UNICAST; + case SAFI_MULTICAST: + return IANA_SAFI_MULTICAST; + case SAFI_MPLS_VPN: + return IANA_SAFI_MPLS_VPN; + case SAFI_ENCAP: + return IANA_SAFI_ENCAP; + case SAFI_EVPN: + return IANA_SAFI_EVPN; + case SAFI_LABELED_UNICAST: + return IANA_SAFI_LABELED_UNICAST; + case SAFI_FLOWSPEC: + return IANA_SAFI_FLOWSPEC; + default: + return IANA_SAFI_RESERVED; + } +} + +static inline const char *iana_safi2str(iana_safi_t safi) +{ + return safi2str(safi_iana2int(safi)); +} + +#endif diff --git a/lib/subdir.am b/lib/subdir.am index 4897f5e8e5..55f5e3a5e6 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -159,6 +159,7 @@ pkginclude_HEADERS += \ lib/graph.h \ lib/hash.h \ lib/hook.h \ + lib/iana_afi.h \ lib/id_alloc.h \ lib/if.h \ lib/if_rmap.h \ diff --git a/lib/zebra.h b/lib/zebra.h index 336ecb38f3..c4c8577943 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -442,33 +442,6 @@ typedef enum { SAFI_MAX = 8 } safi_t; -/* - * The above AFI and SAFI definitions are for internal use. The protocol - * definitions (IANA values) as for example used in BGP protocol packets - * are defined below and these will get mapped to/from the internal values - * in the appropriate places. - * The rationale is that the protocol (IANA) values may be sparse and are - * not optimal for use in data-structure sizing. - * Note: Only useful (i.e., supported) values are defined below. - */ -typedef enum { - IANA_AFI_RESERVED = 0, - IANA_AFI_IPV4 = 1, - IANA_AFI_IPV6 = 2, - IANA_AFI_L2VPN = 25, -} iana_afi_t; - -typedef enum { - IANA_SAFI_RESERVED = 0, - IANA_SAFI_UNICAST = 1, - IANA_SAFI_MULTICAST = 2, - IANA_SAFI_LABELED_UNICAST = 4, - IANA_SAFI_ENCAP = 7, - IANA_SAFI_EVPN = 70, - IANA_SAFI_MPLS_VPN = 128, - IANA_SAFI_FLOWSPEC = 133 -} iana_safi_t; - /* Default Administrative Distance of each protocol. */ #define ZEBRA_KERNEL_DISTANCE_DEFAULT 0 #define ZEBRA_CONNECT_DISTANCE_DEFAULT 0 @@ -510,116 +483,4 @@ 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) { - case IANA_AFI_IPV4: - return AFI_IP; - case IANA_AFI_IPV6: - return AFI_IP6; - case IANA_AFI_L2VPN: - return AFI_L2VPN; - default: - return AFI_MAX; - } -} - -static inline iana_afi_t afi_int2iana(afi_t afi) -{ - switch (afi) { - case AFI_IP: - return IANA_AFI_IPV4; - case AFI_IP6: - return IANA_AFI_IPV6; - case AFI_L2VPN: - return IANA_AFI_L2VPN; - default: - return IANA_AFI_RESERVED; - } -} - -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) { - case IANA_SAFI_UNICAST: - return SAFI_UNICAST; - case IANA_SAFI_MULTICAST: - return SAFI_MULTICAST; - case IANA_SAFI_MPLS_VPN: - return SAFI_MPLS_VPN; - case IANA_SAFI_ENCAP: - return SAFI_ENCAP; - case IANA_SAFI_EVPN: - return SAFI_EVPN; - case IANA_SAFI_LABELED_UNICAST: - return SAFI_LABELED_UNICAST; - case IANA_SAFI_FLOWSPEC: - return SAFI_FLOWSPEC; - default: - return SAFI_MAX; - } -} - -static inline iana_safi_t safi_int2iana(safi_t safi) -{ - switch (safi) { - case SAFI_UNICAST: - return IANA_SAFI_UNICAST; - case SAFI_MULTICAST: - return IANA_SAFI_MULTICAST; - case SAFI_MPLS_VPN: - return IANA_SAFI_MPLS_VPN; - case SAFI_ENCAP: - return IANA_SAFI_ENCAP; - case SAFI_EVPN: - return IANA_SAFI_EVPN; - case SAFI_LABELED_UNICAST: - return IANA_SAFI_LABELED_UNICAST; - case SAFI_FLOWSPEC: - return IANA_SAFI_FLOWSPEC; - default: - return IANA_SAFI_RESERVED; - } -} - #endif /* _ZEBRA_H */