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