2 * iana_afi and safi definitions.
3 * Copyright (C) 2018-2019 Cumulus Networks, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef __IANA_AFI_H__
25 * The above AFI and SAFI definitions are for internal use. The protocol
26 * definitions (IANA values) as for example used in BGP protocol packets
27 * are defined below and these will get mapped to/from the internal values
28 * in the appropriate places.
29 * The rationale is that the protocol (IANA) values may be sparse and are
30 * not optimal for use in data-structure sizing.
31 * Note: Only useful (i.e., supported) values are defined below.
34 IANA_AFI_RESERVED
= 0,
41 IANA_SAFI_RESERVED
= 0,
42 IANA_SAFI_UNICAST
= 1,
43 IANA_SAFI_MULTICAST
= 2,
44 IANA_SAFI_LABELED_UNICAST
= 4,
47 IANA_SAFI_MPLS_VPN
= 128,
48 IANA_SAFI_FLOWSPEC
= 133
51 static inline afi_t
afi_iana2int(iana_afi_t afi
)
65 static inline iana_afi_t
afi_int2iana(afi_t afi
)
73 return IANA_AFI_L2VPN
;
75 return IANA_AFI_RESERVED
;
79 static inline const char *iana_afi2str(iana_afi_t afi
)
81 return afi2str(afi_iana2int(afi
));
84 static inline safi_t
safi_iana2int(iana_safi_t safi
)
87 case IANA_SAFI_UNICAST
:
89 case IANA_SAFI_MULTICAST
:
90 return SAFI_MULTICAST
;
91 case IANA_SAFI_MPLS_VPN
:
97 case IANA_SAFI_LABELED_UNICAST
:
98 return SAFI_LABELED_UNICAST
;
99 case IANA_SAFI_FLOWSPEC
:
100 return SAFI_FLOWSPEC
;
106 static inline iana_safi_t
safi_int2iana(safi_t safi
)
110 return IANA_SAFI_UNICAST
;
112 return IANA_SAFI_MULTICAST
;
114 return IANA_SAFI_MPLS_VPN
;
116 return IANA_SAFI_ENCAP
;
118 return IANA_SAFI_EVPN
;
119 case SAFI_LABELED_UNICAST
:
120 return IANA_SAFI_LABELED_UNICAST
;
122 return IANA_SAFI_FLOWSPEC
;
124 return IANA_SAFI_RESERVED
;
128 static inline const char *iana_safi2str(iana_safi_t safi
)
130 return safi2str(safi_iana2int(safi
));