]> git.proxmox.com Git - mirror_frr.git/blame_incremental - bgpd/bgp_encap_types.h
lib: speedup test exit when startup fails
[mirror_frr.git] / bgpd / bgp_encap_types.h
... / ...
CommitLineData
1/*
2 * Copyright 2015, LabN Consulting, L.L.C.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; see the file COPYING; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef _QUAGGA_BGP_ENCAP_TYPES_H
20#define _QUAGGA_BGP_ENCAP_TYPES_H
21
22#include "bgpd/bgp_ecommunity.h"
23
24/* from
25 * http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#tunnel-types
26 */
27typedef enum {
28 BGP_ENCAP_TYPE_RESERVED = 0,
29 BGP_ENCAP_TYPE_L2TPV3_OVER_IP = 1,
30 BGP_ENCAP_TYPE_GRE = 2,
31 BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT = 3,
32 BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE = 4,
33 BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE = 5,
34 BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE = 6,
35 BGP_ENCAP_TYPE_IP_IN_IP = 7,
36 BGP_ENCAP_TYPE_VXLAN = 8,
37 BGP_ENCAP_TYPE_NVGRE = 9,
38 BGP_ENCAP_TYPE_MPLS = 10, /* NOTE: Encap SAFI&Attribute not used */
39 BGP_ENCAP_TYPE_MPLS_IN_GRE = 11,
40 BGP_ENCAP_TYPE_VXLAN_GPE = 12,
41 BGP_ENCAP_TYPE_MPLS_IN_UDP = 13,
42 BGP_ENCAP_TYPE_PBB
43} bgp_encap_types;
44
45typedef enum {
46 BGP_ENCAP_SUBTLV_TYPE_ENCAPSULATION = 1,
47 BGP_ENCAP_SUBTLV_TYPE_PROTO_TYPE = 2,
48 BGP_ENCAP_SUBTLV_TYPE_IPSEC_TA = 3,
49 BGP_ENCAP_SUBTLV_TYPE_COLOR = 4,
50 BGP_ENCAP_SUBTLV_TYPE_REMOTE_ENDPOINT =
51 6 /* speculative, IANA assignment TBD */
52} bgp_encap_subtlv_types;
53
54/*
55 * Tunnel Encapsulation Attribute subtlvs
56 */
57struct bgp_tea_subtlv_encap_l2tpv3_over_ip {
58 uint32_t sessionid;
59 uint8_t cookie_length;
60 uint8_t cookie[8];
61};
62
63struct bgp_tea_subtlv_encap_gre_key {
64 uint32_t gre_key;
65};
66
67struct bgp_tea_subtlv_encap_pbb {
68 uint32_t flag_isid : 1;
69 uint32_t flag_vid : 1;
70 uint32_t isid : 24;
71 uint16_t vid : 12;
72 uint8_t macaddr[6];
73};
74
75struct bgp_tea_subtlv_proto_type {
76 uint16_t proto; /* ether-type */
77};
78
79struct bgp_tea_subtlv_color {
80 uint32_t color;
81};
82
83/* per draft-rosen-idr-tunnel-encaps */
84struct bgp_tea_subtlv_remote_endpoint {
85 uint8_t family; /* IPv4 or IPv6 */
86 union {
87 struct in_addr v4;
88 struct in6_addr v6;
89 } ip_address;
90 as_t as4; /* always 4 bytes */
91};
92
93/*
94 * This is the length of the value part of the ipsec tunnel authenticator
95 * subtlv. Currently we only support the length for authenticator type 1.
96 */
97#define BGP_ENCAP_SUBTLV_IPSEC_TA_SIZE 20
98
99struct bgp_tea_subtlv_ipsec_ta {
100 uint16_t authenticator_type; /* only type 1 is supported so far */
101 uint8_t authenticator_length; /* octets in value field */
102 uint8_t value[BGP_ENCAP_SUBTLV_IPSEC_TA_SIZE];
103};
104
105/*
106 * Subtlv valid flags
107 * TBD change names to add "VALID"
108 */
109#define BGP_TEA_SUBTLV_ENCAP 0x00000001
110#define BGP_TEA_SUBTLV_PROTO_TYPE 0x00000002
111#define BGP_TEA_SUBTLV_COLOR 0x00000004
112#define BGP_TEA_SUBTLV_IPSEC_TA 0x00000008
113#define BGP_TEA_SUBTLV_REMOTE_ENDPOINT 0x00000010
114
115#define CHECK_SUBTLV_FLAG(ptr, flag) CHECK_FLAG((ptr)->valid_subtlvs, (flag))
116#define SET_SUBTLV_FLAG(ptr, flag) SET_FLAG((ptr)->valid_subtlvs, (flag))
117#define UNSET_SUBTLV_FLAG(ptr, flag) UNSET_FLAG((ptr)->valid_subtlvs, (flag))
118
119/*
120 * Tunnel Type-specific APIs
121 */
122struct bgp_encap_type_reserved {
123 uint32_t valid_subtlvs;
124 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
125};
126
127struct bgp_encap_type_l2tpv3_over_ip {
128 uint32_t valid_subtlvs;
129 struct bgp_tea_subtlv_encap_l2tpv3_over_ip st_encap;
130 struct bgp_tea_subtlv_proto_type st_proto; /* optional */
131 struct bgp_tea_subtlv_color st_color; /* optional */
132 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
133};
134
135struct bgp_encap_type_gre {
136 uint32_t valid_subtlvs;
137 struct bgp_tea_subtlv_encap_gre_key st_encap; /* optional */
138 struct bgp_tea_subtlv_proto_type st_proto; /* optional */
139 struct bgp_tea_subtlv_color st_color; /* optional */
140 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
141};
142
143struct bgp_encap_type_ip_in_ip {
144 uint32_t valid_subtlvs;
145 struct bgp_tea_subtlv_proto_type st_proto; /* optional */
146 struct bgp_tea_subtlv_color st_color; /* optional */
147 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
148};
149
150struct bgp_encap_type_transmit_tunnel_endpoint {
151 uint32_t valid_subtlvs;
152 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
153 /* No subtlvs defined in spec? */
154};
155
156struct bgp_encap_type_ipsec_in_tunnel_mode {
157 uint32_t valid_subtlvs;
158 struct bgp_tea_subtlv_ipsec_ta st_ipsec_ta; /* optional */
159 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
160};
161
162struct bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode {
163 uint32_t valid_subtlvs;
164 struct bgp_tea_subtlv_ipsec_ta st_ipsec_ta; /* optional */
165 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
166};
167
168struct bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode {
169 uint32_t valid_subtlvs;
170 struct bgp_tea_subtlv_ipsec_ta st_ipsec_ta; /* optional */
171 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
172};
173
174#define VXLAN_ENCAP_MASK_VNID_VALID 0x80000000
175#define VXLAN_ENCAP_MASK_MAC_VALID 0x40000000
176
177struct bgp_encap_type_vxlan {
178 uint32_t valid_subtlvs;
179 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
180 /* draft-ietf-idr-tunnel-encaps-02 */
181 uint32_t vnid; /* does not include V and M bit */
182 uint8_t *mac_address; /* optional */
183};
184
185struct bgp_encap_type_nvgre {
186 uint32_t valid_subtlvs;
187 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
188 /* No subtlvs defined in spec? */
189};
190
191struct bgp_encap_type_mpls {
192 uint32_t valid_subtlvs;
193 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
194 /* No subtlvs defined in spec? */
195};
196
197struct bgp_encap_type_mpls_in_gre {
198 uint32_t valid_subtlvs;
199 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
200 /* No subtlvs defined in spec? */
201};
202
203struct bgp_encap_type_vxlan_gpe {
204 uint32_t valid_subtlvs;
205 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
206 /* No subtlvs defined in spec? */
207};
208
209struct bgp_encap_type_mpls_in_udp {
210 uint32_t valid_subtlvs;
211 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
212 /* No subtlvs defined in spec? */
213};
214
215struct bgp_encap_type_pbb {
216 uint32_t valid_subtlvs;
217 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
218 struct bgp_tea_subtlv_encap_pbb st_encap;
219};
220
221static inline void encode_encap_extcomm(bgp_encap_types tnl_type,
222 struct ecommunity_val *eval)
223{
224 memset(eval, 0, sizeof(*eval));
225 eval->val[0] = ECOMMUNITY_ENCODE_OPAQUE;
226 eval->val[1] = ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP;
227 eval->val[6] = ((tnl_type) >> 8) & 0xff;
228 eval->val[7] = (tnl_type)&0xff;
229}
230
231#endif /* _QUAGGA_BGP_ENCAP_TYPES_H */