1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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 <prefix.h>
/*
* 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
|