]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_encap_types.h
release: FRR 3.0-rc1
[mirror_frr.git] / bgpd / bgp_encap_types.h
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
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 */
19
20 #ifndef _QUAGGA_BGP_ENCAP_TYPES_H
21 #define _QUAGGA_BGP_ENCAP_TYPES_H
22
23 /* from
24 * http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#tunnel-types
25 */
26 typedef enum {
27 BGP_ENCAP_TYPE_RESERVED = 0,
28 BGP_ENCAP_TYPE_L2TPV3_OVER_IP = 1,
29 BGP_ENCAP_TYPE_GRE = 2,
30 BGP_ENCAP_TYPE_TRANSMIT_TUNNEL_ENDPOINT = 3,
31 BGP_ENCAP_TYPE_IPSEC_IN_TUNNEL_MODE = 4,
32 BGP_ENCAP_TYPE_IP_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE = 5,
33 BGP_ENCAP_TYPE_MPLS_IN_IP_TUNNEL_WITH_IPSEC_TRANSPORT_MODE = 6,
34 BGP_ENCAP_TYPE_IP_IN_IP = 7,
35 BGP_ENCAP_TYPE_VXLAN = 8,
36 BGP_ENCAP_TYPE_NVGRE = 9,
37 BGP_ENCAP_TYPE_MPLS = 10, /* NOTE: Encap SAFI&Attribute not used */
38 BGP_ENCAP_TYPE_MPLS_IN_GRE = 11,
39 BGP_ENCAP_TYPE_VXLAN_GPE = 12,
40 BGP_ENCAP_TYPE_MPLS_IN_UDP = 13,
41 BGP_ENCAP_TYPE_PBB
42 } bgp_encap_types;
43
44 typedef enum {
45 BGP_ENCAP_SUBTLV_TYPE_ENCAPSULATION = 1,
46 BGP_ENCAP_SUBTLV_TYPE_PROTO_TYPE = 2,
47 BGP_ENCAP_SUBTLV_TYPE_IPSEC_TA = 3,
48 BGP_ENCAP_SUBTLV_TYPE_COLOR = 4,
49 BGP_ENCAP_SUBTLV_TYPE_REMOTE_ENDPOINT =
50 6 /* speculative, IANA assignment TBD */
51 } bgp_encap_subtlv_types;
52
53 /*
54 * Tunnel Encapsulation Attribute subtlvs
55 */
56 struct bgp_tea_subtlv_encap_l2tpv3_over_ip {
57 uint32_t sessionid;
58 uint8_t cookie_length;
59 uint8_t cookie[8];
60 };
61
62 struct bgp_tea_subtlv_encap_gre_key {
63 uint32_t gre_key;
64 };
65
66 struct bgp_tea_subtlv_encap_pbb {
67 uint32_t flag_isid : 1;
68 uint32_t flag_vid : 1;
69 uint32_t isid : 24;
70 uint16_t vid : 12;
71 uint8_t macaddr[6];
72 };
73
74 struct bgp_tea_subtlv_proto_type {
75 uint16_t proto; /* ether-type */
76 };
77
78 struct bgp_tea_subtlv_color {
79 uint32_t color;
80 };
81
82 /* per draft-rosen-idr-tunnel-encaps */
83 struct bgp_tea_subtlv_remote_endpoint {
84 u_char family; /* IPv4 or IPv6 */
85 union {
86 struct in_addr v4;
87 struct in6_addr v6;
88 } ip_address;
89 as_t as4; /* always 4 bytes */
90 };
91
92 /*
93 * This is the length of the value part of the ipsec tunnel authenticator
94 * subtlv. Currently we only support the length for authenticator type 1.
95 */
96 #define BGP_ENCAP_SUBTLV_IPSEC_TA_SIZE 20
97
98 struct bgp_tea_subtlv_ipsec_ta {
99 uint16_t authenticator_type; /* only type 1 is supported so far */
100 uint8_t authenticator_length; /* octets in value field */
101 uint8_t value[BGP_ENCAP_SUBTLV_IPSEC_TA_SIZE];
102 };
103
104 /*
105 * Subtlv valid flags
106 * TBD change names to add "VALID"
107 */
108 #define BGP_TEA_SUBTLV_ENCAP 0x00000001
109 #define BGP_TEA_SUBTLV_PROTO_TYPE 0x00000002
110 #define BGP_TEA_SUBTLV_COLOR 0x00000004
111 #define BGP_TEA_SUBTLV_IPSEC_TA 0x00000008
112 #define BGP_TEA_SUBTLV_REMOTE_ENDPOINT 0x00000010
113
114 #define CHECK_SUBTLV_FLAG(ptr, flag) CHECK_FLAG((ptr)->valid_subtlvs, (flag))
115 #define SET_SUBTLV_FLAG(ptr, flag) SET_FLAG((ptr)->valid_subtlvs, (flag))
116 #define UNSET_SUBTLV_FLAG(ptr, flag) UNSET_FLAG((ptr)->valid_subtlvs, (flag))
117
118 /*
119 * Tunnel Type-specific APIs
120 */
121 struct bgp_encap_type_reserved {
122 uint32_t valid_subtlvs;
123 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
124 };
125
126 struct bgp_encap_type_l2tpv3_over_ip {
127 uint32_t valid_subtlvs;
128 struct bgp_tea_subtlv_encap_l2tpv3_over_ip st_encap;
129 struct bgp_tea_subtlv_proto_type st_proto; /* optional */
130 struct bgp_tea_subtlv_color st_color; /* optional */
131 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
132 };
133
134 struct bgp_encap_type_gre {
135 uint32_t valid_subtlvs;
136 struct bgp_tea_subtlv_encap_gre_key st_encap; /* optional */
137 struct bgp_tea_subtlv_proto_type st_proto; /* optional */
138 struct bgp_tea_subtlv_color st_color; /* optional */
139 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
140 };
141
142 struct bgp_encap_type_ip_in_ip {
143 uint32_t valid_subtlvs;
144 struct bgp_tea_subtlv_proto_type st_proto; /* optional */
145 struct bgp_tea_subtlv_color st_color; /* optional */
146 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
147 };
148
149 struct bgp_encap_type_transmit_tunnel_endpoint {
150 uint32_t valid_subtlvs;
151 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
152 /* No subtlvs defined in spec? */
153 };
154
155 struct bgp_encap_type_ipsec_in_tunnel_mode {
156 uint32_t valid_subtlvs;
157 struct bgp_tea_subtlv_ipsec_ta st_ipsec_ta; /* optional */
158 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
159 };
160
161 struct bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode {
162 uint32_t valid_subtlvs;
163 struct bgp_tea_subtlv_ipsec_ta st_ipsec_ta; /* optional */
164 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
165 };
166
167 struct bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode {
168 uint32_t valid_subtlvs;
169 struct bgp_tea_subtlv_ipsec_ta st_ipsec_ta; /* optional */
170 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
171 };
172
173 #define VXLAN_ENCAP_MASK_VNID_VALID 0x80000000
174 #define VXLAN_ENCAP_MASK_MAC_VALID 0x40000000
175
176 struct bgp_encap_type_vxlan {
177 uint32_t valid_subtlvs;
178 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
179 /* draft-ietf-idr-tunnel-encaps-02 */
180 uint32_t vnid; /* does not include V and M bit */
181 uint8_t *mac_address; /* optional */
182 };
183
184 struct bgp_encap_type_nvgre {
185 uint32_t valid_subtlvs;
186 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
187 /* No subtlvs defined in spec? */
188 };
189
190 struct bgp_encap_type_mpls {
191 uint32_t valid_subtlvs;
192 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
193 /* No subtlvs defined in spec? */
194 };
195
196 struct bgp_encap_type_mpls_in_gre {
197 uint32_t valid_subtlvs;
198 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
199 /* No subtlvs defined in spec? */
200 };
201
202 struct bgp_encap_type_vxlan_gpe {
203 uint32_t valid_subtlvs;
204 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
205 /* No subtlvs defined in spec? */
206 };
207
208 struct bgp_encap_type_mpls_in_udp {
209 uint32_t valid_subtlvs;
210 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
211 /* No subtlvs defined in spec? */
212 };
213
214 struct bgp_encap_type_pbb {
215 uint32_t valid_subtlvs;
216 struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
217 struct bgp_tea_subtlv_encap_pbb st_encap;
218 };
219
220 #endif /* _QUAGGA_BGP_ENCAP_TYPES_H */