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__
29 * The above AFI and SAFI definitions are for internal use. The protocol
30 * definitions (IANA values) as for example used in BGP protocol packets
31 * are defined below and these will get mapped to/from the internal values
32 * in the appropriate places.
33 * The rationale is that the protocol (IANA) values may be sparse and are
34 * not optimal for use in data-structure sizing.
35 * Note: Only useful (i.e., supported) values are defined below.
38 IANA_AFI_RESERVED
= 0,
45 IANA_SAFI_RESERVED
= 0,
46 IANA_SAFI_UNICAST
= 1,
47 IANA_SAFI_MULTICAST
= 2,
48 IANA_SAFI_LABELED_UNICAST
= 4,
51 IANA_SAFI_MPLS_VPN
= 128,
52 IANA_SAFI_FLOWSPEC
= 133
55 static inline afi_t
afi_iana2int(iana_afi_t afi
)
69 static inline iana_afi_t
afi_int2iana(afi_t afi
)
77 return IANA_AFI_L2VPN
;
79 return IANA_AFI_RESERVED
;
83 static inline const char *iana_afi2str(iana_afi_t afi
)
85 return afi2str(afi_iana2int(afi
));
88 static inline safi_t
safi_iana2int(iana_safi_t safi
)
91 case IANA_SAFI_UNICAST
:
93 case IANA_SAFI_MULTICAST
:
94 return SAFI_MULTICAST
;
95 case IANA_SAFI_MPLS_VPN
:
101 case IANA_SAFI_LABELED_UNICAST
:
102 return SAFI_LABELED_UNICAST
;
103 case IANA_SAFI_FLOWSPEC
:
104 return SAFI_FLOWSPEC
;
110 static inline iana_safi_t
safi_int2iana(safi_t safi
)
114 return IANA_SAFI_UNICAST
;
116 return IANA_SAFI_MULTICAST
;
118 return IANA_SAFI_MPLS_VPN
;
120 return IANA_SAFI_ENCAP
;
122 return IANA_SAFI_EVPN
;
123 case SAFI_LABELED_UNICAST
:
124 return IANA_SAFI_LABELED_UNICAST
;
126 return IANA_SAFI_FLOWSPEC
;
128 return IANA_SAFI_RESERVED
;
132 static inline const char *iana_safi2str(iana_safi_t safi
)
134 return safi2str(safi_iana2int(safi
));