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