MVPN Extended communities Handlers
[bgpcep.git] / bgp / concepts / src / main / yang / bgp-types.yang
1 module bgp-types {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:bgp-types";
4     prefix "bgp-t";
5
6     import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
7     import network-concepts { prefix netc; revision-date 2013-11-25; }
8
9     organization "Cisco Systems, Inc.";
10     contact "Dana Kutenicsova <dkutenic@cisco.com>";
11
12     description
13         "This module contains the base concepts contained in RFC4271 and RFC4760.
14
15         Copyright (c)2013 Cisco Systems, Inc. All rights reserved.
16
17         This program and the accompanying materials are made available
18         under the terms of the Eclipse Public License v1.0 which
19         accompanies this distribution, and is available at
20         http://www.eclipse.org/legal/epl-v10.html";
21
22     revision "2018-03-29" {
23         description "RFC6514 Extended communities";
24         reference "https://tools.ietf.org/html/rfc6514";
25     }
26
27     revision "2013-09-19" {
28         description
29             "Initial revision.";
30         reference "RFC4271, RFC4760";
31     }
32
33     typedef bgp-origin {
34         reference "http://tools.ietf.org/html/rfc4271#section-5";
35         description "Values of BGP Origin Path Attribute.";
36         type enumeration {
37             enum igp {
38                 value 0;
39             }
40             enum egp {
41                 value 1;
42             }
43             enum incomplete {
44                 value 2;
45             }
46         }
47     }
48
49     typedef bgp-id {
50         description "BGP identifier";
51         type inet:ipv4-address;
52     }
53
54     identity address-family {
55         reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
56     }
57
58     identity ipv4-address-family {
59         base address-family;
60     }
61
62     identity ipv6-address-family {
63         base address-family;
64     }
65
66     identity subsequent-address-family {
67         reference "http://tools.ietf.org/html/rfc4760#section-6";
68     }
69
70     identity unicast-subsequent-address-family {
71         reference "http://tools.ietf.org/html/rfc4760#section-6";
72
73         base subsequent-address-family;
74     }
75
76     identity mpls-labeled-vpn-subsequent-address-family {
77         reference "http://tools.ietf.org/html/rfc4760#section-6";
78
79         base subsequent-address-family;
80     }
81
82     typedef cluster-identifier {
83         reference "http://tools.ietf.org/html/rfc4456#section-8";
84         type inet:ipv4-address;
85     }
86
87     typedef short-as-number {
88         type inet:as-number {
89             range 0..65535;
90         }
91     }
92
93     typedef route-distinguisher {
94         reference "https://tools.ietf.org/html/rfc4364#section-4.2";
95         type union {
96             type rd-two-octet-as;
97             type rd-ipv4;
98             type rd-as;
99         }
100     }
101
102     typedef rd-two-octet-as {
103         type string {
104             /* 2B AS : 4B number */
105             pattern '0:'
106                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
107                 + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
108                 + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])'
109                 + ':'
110                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
111                 + '[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|'
112                 + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
113                 + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-3][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
114                 + '4[0-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|42[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
115                 + '429[0-3][0-9][0-9][0-9][0-9][0-9][0-9]|4294[0-8][0-9][0-9][0-9][0-9][0-9]|'
116                 + '42949[0-5][0-9][0-9][0-9][0-9]|429496[0-6][0-9][0-9][0-9]|4294967[0-1][0-9][0-9]|'
117                 + '42949672[0-8][0-9]|429496729[0-5])';
118         }
119     }
120
121     typedef rd-ipv4 {
122         type string {
123             /* IPv4 : 2B number */
124             pattern '((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
125                 + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))'
126                 + ':'
127                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
128                 + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
129                 + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
130         }
131     }
132
133     typedef rd-as {
134         type string {
135             /* 4B AS : 2B number */
136             pattern '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
137                 + '[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|'
138                 + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
139                 + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-3][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
140                 + '4[0-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|42[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
141                 + '429[0-3][0-9][0-9][0-9][0-9][0-9][0-9]|4294[0-8][0-9][0-9][0-9][0-9][0-9]|'
142                 + '42949[0-5][0-9][0-9][0-9][0-9]|429496[0-6][0-9][0-9][0-9]|4294967[0-1][0-9][0-9]|'
143                 + '42949672[0-8][0-9]|429496729[0-5])'
144                 + ':'
145                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
146                 + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
147                 + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
148         }
149     }
150
151     typedef encapsulation-tunnel-type {
152         reference "http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#tunnel-types";
153         type enumeration {
154             enum l2tpv3-over-ip {
155                 value 1;
156             }
157             enum gre {
158                 value 2;
159             }
160             enum transmit-tunnel-endpoint {
161                 value 3;
162             }
163             enum ipsec-tunnel-mode {
164                 value 4;
165             }
166             enum ip-in-ip-ipsec-transport-mode {
167                 value 5;
168             }
169             enum mpls-in-ip-tunnel-ipsec-transport-mode {
170                 value 6;
171             }
172             enum ip-in-ip {
173                 value 7;
174             }
175             enum vxlan {
176                 value 8;
177             }
178             enum nvgre {
179                 value 9;
180             }
181             enum mpls {
182                 value 10;
183             }
184             enum mpls-in-gre {
185                 value 11;
186             }
187             enum vxlan-gpe {
188                 value 12;
189             }
190             enum mpls-in-udp {
191                 value 13;
192             }
193             enum ipv6-tunnel {
194                 value 14;
195             }
196         }
197     }
198
199     grouping bgp-aggregator {
200         reference "http://tools.ietf.org/html/rfc4271#section-5.1.7";
201         description "BGP Path Attribute AGGREGATOR.";
202         leaf as-number {
203             // We are acting as a NEW speaker, so only four bytes are allowed
204             type inet:as-number;
205         }
206         leaf network-address {
207             type inet:ipv4-address;
208         }
209     }
210
211     grouping community {
212         reference "https://tools.ietf.org/html/rfc1997";
213         description "Community Path Attribute";
214         leaf as-number {
215             type inet:as-number;
216         }
217         leaf semantics {
218             type uint16;
219         }
220     }
221
222     grouping route-ipv4-extended-community {
223         reference "http://tools.ietf.org/html/rfc4360";
224         leaf global-administrator {
225             type inet:ipv4-address;
226         }
227         leaf local-administrator {
228             type uint16;
229         }
230     }
231
232     grouping link-bandwidth-extended-community {
233         reference "https://tools.ietf.org/html/draft-ietf-idr-link-bandwidth-06#section-2";
234         description
235             "The Link Bandwidth extended community is optional non-transitive";
236
237         leaf bandwidth {
238             description "Bandwidth of the link";
239             mandatory true;
240             type netc:bandwidth;
241             units "bytes per second";
242         }
243     }
244
245     grouping as-4-spec-common {
246         container as-4-specific-common {
247             leaf as-number {
248                 description "Carries a 4-octet Autonomous System (AS) number";
249                 reference "https://tools.ietf.org/html/rfc5668#section-2";
250
251                 mandatory true;
252                 type inet:as-number;
253             }
254
255             leaf local-administrator {
256                 type uint16;
257                 mandatory true;
258             }
259         }
260     }
261
262     grouping encapsulation-extended-community {
263         reference "https://tools.ietf.org/html/rfc5512#section-4.5";
264         description "BGP Encapsulation extended community";
265
266         leaf tunnel-type {
267             description "Tunnel type specifying the encapsulation protocol";
268             mandatory true;
269             type encapsulation-tunnel-type;
270         }
271     }
272
273     grouping inet4-specific-extended-community-common {
274         container inet4-specific-extended-community-common {
275             leaf global-administrator {
276                 type inet:ipv4-address;
277             }
278             leaf local-administrator {
279                 type binary {
280                     length "2";
281                 }
282             }
283         }
284     }
285     grouping extended-community {
286         leaf transitive {
287             type boolean;
288         }
289         choice extended-community {
290             case as-specific-extended-community-case {
291                 container as-specific-extended-community {
292                     leaf global-administrator {
293                         type short-as-number;
294                     }
295                     leaf local-administrator {
296                         type binary {
297                             length "4";
298                         }
299                     }
300                 }
301             }
302             case inet4-specific-extended-community-case {
303                 container inet4-specific-extended-community {
304                     uses inet4-specific-extended-community-common;
305                     leaf global-administrator {
306                         status deprecated;
307                         type inet:ipv4-address;
308                     }
309                     leaf local-administrator {
310                         status deprecated;
311                         type binary {
312                             length "2";
313                         }
314                     }
315                 }
316             }
317             case opaque-extended-community-case {
318                 container opaque-extended-community {
319                     leaf value {
320                         type binary {
321                             length "6";
322                         }
323                     }
324                 }
325             }
326             case route-target-extended-community-case {
327                 container route-target-extended-community {
328                     leaf global-administrator {
329                         type short-as-number;
330                     }
331                     leaf local-administrator {
332                         type binary {
333                             length "4";
334                         }
335                     }
336                 }
337             }
338             case route-origin-extended-community-case {
339                 container route-origin-extended-community {
340                     leaf global-administrator {
341                         type short-as-number;
342                     }
343                     leaf local-administrator {
344                         type binary {
345                             length "4";
346                         }
347                     }
348                 }
349             }
350             case route-target-ipv4-case {
351                 container route-target-ipv4 {
352                     reference "http://tools.ietf.org/html/rfc4360#section-4";
353                     uses route-ipv4-extended-community;
354                 }
355             }
356             case route-origin-ipv4-case {
357                 container route-origin-ipv4 {
358                     reference "http://tools.ietf.org/html/rfc4360#section-5";
359                     uses route-ipv4-extended-community;
360                 }
361             }
362             case link-bandwidth-case {
363                 container link-bandwidth-extended-community {
364                     uses link-bandwidth-extended-community;
365                 }
366             }
367             case as-4-generic-spec-extended-community-case {
368                 container as-4-generic-spec-extended-community {
369                     reference "https://www.ietf.org/archive/id/draft-ietf-idr-as4octet-extcomm-generic-subtype-08.txt";
370                     uses as-4-spec-common;
371                 }
372             }
373             case as-4-route-target-extended-community-case {
374                 container as-4-route-target-extended-community {
375                     reference "https://tools.ietf.org/html/rfc5668";
376                     uses as-4-spec-common;
377                 }
378             }
379             case as-4-route-origin-extended-community-case {
380                 container as-4-route-origin-extended-community {
381                     reference "https://tools.ietf.org/html/rfc5668";
382                     uses as-4-spec-common;
383                 }
384             }
385             case encapsulation-case {
386                 container encapsulation-extended-community {
387                     uses encapsulation-extended-community;
388                 }
389             }
390         }
391     }
392
393     grouping next-hop {
394         choice c-next-hop {
395             default empty-next-hop-case;
396             case ipv4-next-hop-case {
397                 container ipv4-next-hop {
398                     reference "http://tools.ietf.org/html/rfc4271#section-5.1.3";
399                     leaf global {
400                         type inet:ipv4-address;
401                     }
402                 }
403             }
404             case ipv6-next-hop-case {
405                 container ipv6-next-hop {
406                     reference "http://tools.ietf.org/html/rfc4760#section-3";
407                     leaf global {
408                         type inet:ipv6-address;
409                     }
410                     leaf link-local {
411                         type inet:ipv6-address;
412                     }
413                 }
414             }
415             case empty-next-hop-case {
416                 leaf empty-next-hop {
417                     type empty;
418                 }
419             }
420         }
421     }
422
423     grouping as-path-segment {
424         reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
425         leaf-list as-sequence {
426             type inet:as-number;
427             ordered-by user;
428             max-elements "255";
429         }
430         leaf-list as-set {
431             type inet:as-number;
432         }
433     }
434
435     grouping route-distinguisher-grouping {
436         leaf route-distinguisher {
437             type route-distinguisher;
438             mandatory true;
439         }
440     }
441
442     grouping orig-route-ip-grouping {
443         leaf orig-route-ip {
444             type inet:ip-address;
445             mandatory true;
446         }
447     }
448 }