Clean up ShortestPathFirst
[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 2020-01-20 {
23         description "Update to use -no-zone-adresses";
24     }
25
26     revision "2018-03-29" {
27         description "RFC6514 Extended communities";
28         reference "https://tools.ietf.org/html/rfc6514";
29     }
30
31     revision "2013-09-19" {
32         description
33             "Initial revision.";
34         reference "RFC4271, RFC4760";
35     }
36
37     typedef bgp-origin {
38         reference "http://tools.ietf.org/html/rfc4271#section-5";
39         description "Values of BGP Origin Path Attribute.";
40         type enumeration {
41             enum igp {
42                 value 0;
43             }
44             enum egp {
45                 value 1;
46             }
47             enum incomplete {
48                 value 2;
49             }
50         }
51     }
52
53     typedef bgp-id {
54         description "BGP identifier";
55         type inet:ipv4-address-no-zone;
56     }
57
58     identity address-family {
59         reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
60     }
61
62     identity ipv4-address-family {
63         base address-family;
64     }
65
66     identity ipv6-address-family {
67         base address-family;
68     }
69
70     identity subsequent-address-family {
71         reference "http://tools.ietf.org/html/rfc4760#section-6";
72     }
73
74     identity unicast-subsequent-address-family {
75         reference "http://tools.ietf.org/html/rfc4760#section-6";
76
77         base subsequent-address-family;
78     }
79
80     identity mpls-labeled-vpn-subsequent-address-family {
81         reference "http://tools.ietf.org/html/rfc4760#section-6";
82
83         base subsequent-address-family;
84     }
85
86     typedef cluster-identifier {
87         reference "http://tools.ietf.org/html/rfc4456#section-8";
88         type inet:ipv4-address-no-zone;
89     }
90
91     typedef short-as-number {
92         type inet:as-number {
93             range 0..65535;
94         }
95     }
96
97     typedef route-distinguisher {
98         reference "https://tools.ietf.org/html/rfc4364#section-4.2";
99         type union {
100             type rd-two-octet-as;
101             type rd-ipv4;
102             type rd-as;
103         }
104     }
105
106     typedef rd-two-octet-as {
107         type string {
108             /* 2B AS : 4B number */
109             pattern '0:'
110                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
111                 + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
112                 + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])'
113                 + ':'
114                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
115                 + '[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|'
116                 + '[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]|'
117                 + '[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]|'
118                 + '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]|'
119                 + '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]|'
120                 + '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]|'
121                 + '42949672[0-8][0-9]|429496729[0-5])';
122         }
123     }
124
125     typedef rd-ipv4 {
126         type string {
127             /* IPv4 : 2B number */
128             pattern '((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
129                 + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))'
130                 + ':'
131                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
132                 + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
133                 + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
134         }
135     }
136
137     typedef rd-as {
138         type string {
139             /* 4B AS : 2B number */
140             pattern '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
141                 + '[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|'
142                 + '[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]|'
143                 + '[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]|'
144                 + '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]|'
145                 + '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]|'
146                 + '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]|'
147                 + '42949672[0-8][0-9]|429496729[0-5])'
148                 + ':'
149                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
150                 + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
151                 + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
152         }
153     }
154
155     typedef encapsulation-tunnel-type {
156         reference "http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#tunnel-types";
157         type enumeration {
158             enum l2tpv3-over-ip {
159                 value 1;
160             }
161             enum gre {
162                 value 2;
163             }
164             enum transmit-tunnel-endpoint {
165                 value 3;
166             }
167             enum ipsec-tunnel-mode {
168                 value 4;
169             }
170             enum ip-in-ip-ipsec-transport-mode {
171                 value 5;
172             }
173             enum mpls-in-ip-tunnel-ipsec-transport-mode {
174                 value 6;
175             }
176             enum ip-in-ip {
177                 value 7;
178             }
179             enum vxlan {
180                 value 8;
181             }
182             enum nvgre {
183                 value 9;
184             }
185             enum mpls {
186                 value 10;
187             }
188             enum mpls-in-gre {
189                 value 11;
190             }
191             enum vxlan-gpe {
192                 value 12;
193             }
194             enum mpls-in-udp {
195                 value 13;
196             }
197             enum ipv6-tunnel {
198                 value 14;
199             }
200         }
201     }
202
203     grouping bgp-aggregator {
204         reference "http://tools.ietf.org/html/rfc4271#section-5.1.7";
205         description "BGP Path Attribute AGGREGATOR.";
206         leaf as-number {
207             // We are acting as a NEW speaker, so only four bytes are allowed
208             type inet:as-number;
209         }
210         leaf network-address {
211             type inet:ipv4-address-no-zone;
212         }
213     }
214
215     grouping community {
216         reference "https://tools.ietf.org/html/rfc1997";
217         description "Community Path Attribute";
218         leaf as-number {
219             type inet:as-number;
220         }
221         leaf semantics {
222             type uint16;
223         }
224     }
225
226     grouping route-ipv4-extended-community {
227         reference "http://tools.ietf.org/html/rfc4360";
228         leaf global-administrator {
229             type inet:ipv4-address-no-zone;
230         }
231         leaf local-administrator {
232             type uint16;
233         }
234     }
235
236     grouping link-bandwidth-extended-community {
237         reference "https://tools.ietf.org/html/draft-ietf-idr-link-bandwidth-06#section-2";
238         description
239             "The Link Bandwidth extended community is optional non-transitive";
240
241         leaf bandwidth {
242             description "Bandwidth of the link";
243             mandatory true;
244             type netc:bandwidth;
245             units "bytes per second";
246         }
247     }
248
249     grouping as-4-spec-common {
250         container as-4-specific-common {
251             leaf as-number {
252                 description "Carries a 4-octet Autonomous System (AS) number";
253                 reference "https://tools.ietf.org/html/rfc5668#section-2";
254
255                 mandatory true;
256                 type inet:as-number;
257             }
258
259             leaf local-administrator {
260                 type uint16;
261                 mandatory true;
262             }
263         }
264     }
265
266     grouping encapsulation-extended-community {
267         reference "https://tools.ietf.org/html/rfc5512#section-4.5";
268         description "BGP Encapsulation extended community";
269
270         leaf tunnel-type {
271             description "Tunnel type specifying the encapsulation protocol";
272             mandatory true;
273             type encapsulation-tunnel-type;
274         }
275     }
276
277     grouping inet4-specific-extended-community-common {
278         container inet4-specific-extended-community-common {
279             leaf global-administrator {
280                 type inet:ipv4-address-no-zone;
281             }
282             leaf local-administrator {
283                 type binary {
284                     length "2";
285                 }
286             }
287         }
288     }
289
290     grouping source-as-4-extended-community-grouping {
291         reference "https://tools.ietf.org/html/rfc6514#section-6";
292         leaf global-administrator {
293             description "Carries a 4-octet Autonomous System (AS) number";
294             reference "https://tools.ietf.org/html/rfc5668#section-2";
295
296             mandatory true;
297             type inet:as-number;
298         }
299     }
300
301     grouping source-as-extended-community-grouping {
302         reference "https://tools.ietf.org/html/rfc6514#section-6";
303         leaf global-administrator {
304             type bgp-t:short-as-number;
305         }
306     }
307
308     grouping route-target {
309         description "Marker grouping for Route Target extended communities.";
310     }
311
312     grouping route-target-constrain-default-route-grouping {
313         container route-target-constrain-default-route {
314             uses route-target;
315             presence
316                 "The presence of this container indicates that the routes
317                 is a default route target";
318         }
319     }
320
321     grouping route-target-extended-community-grouping {
322         container route-target-extended-community {
323             description "Type 0x00 / Subtype 0x02";
324             reference "http://tools.ietf.org/html/rfc4360#section-4";
325             uses route-target;
326
327             leaf global-administrator {
328                 type short-as-number;
329             }
330             leaf local-administrator {
331                 type binary {
332                     length "4";
333                 }
334             }
335         }
336     }
337
338     grouping route-target-ipv4-grouping {
339         container route-target-ipv4 {
340             description "Type 0x01 / Subtype 0x02";
341             reference "http://tools.ietf.org/html/rfc4360#section-4";
342             uses route-target;
343             uses route-ipv4-extended-community;
344         }
345     }
346
347     grouping as-4-route-target-extended-community-grouping {
348         container as-4-route-target-extended-community {
349             description "Type 0x02 / Subtype 0x02";
350             reference "https://tools.ietf.org/html/rfc5668";
351             uses route-target;
352             uses as-4-spec-common;
353         }
354     }
355
356     grouping extended-community {
357         leaf transitive {
358             type boolean;
359         }
360         choice extended-community {
361             case as-specific-extended-community-case {
362                 container as-specific-extended-community {
363                     leaf global-administrator {
364                         type short-as-number;
365                     }
366                     leaf local-administrator {
367                         type binary {
368                             length "4";
369                         }
370                     }
371                 }
372             }
373             case inet4-specific-extended-community-case {
374                 container inet4-specific-extended-community {
375                     uses inet4-specific-extended-community-common;
376                     leaf global-administrator {
377                         status deprecated;
378                         type inet:ipv4-address-no-zone;
379                     }
380                     leaf local-administrator {
381                         status deprecated;
382                         type binary {
383                             length "2";
384                         }
385                     }
386                 }
387             }
388             case opaque-extended-community-case {
389                 container opaque-extended-community {
390                     leaf value {
391                         type binary {
392                             length "6";
393                         }
394                     }
395                 }
396             }
397             case route-target-extended-community-case {
398                 uses route-target-extended-community-grouping;
399             }
400             case route-target-ipv4-case {
401                 uses route-target-ipv4-grouping;
402             }
403             case as-4-route-target-extended-community-case {
404                 uses as-4-route-target-extended-community-grouping;
405             }
406             case route-origin-extended-community-case {
407                 container route-origin-extended-community {
408                     leaf global-administrator {
409                         type short-as-number;
410                     }
411                     leaf local-administrator {
412                         type binary {
413                             length "4";
414                         }
415                     }
416                 }
417             }
418             case route-origin-ipv4-case {
419                 container route-origin-ipv4 {
420                     reference "http://tools.ietf.org/html/rfc4360#section-5";
421                     uses route-ipv4-extended-community;
422                 }
423             }
424             case link-bandwidth-case {
425                 container link-bandwidth-extended-community {
426                     uses link-bandwidth-extended-community;
427                 }
428             }
429             case as-4-generic-spec-extended-community-case {
430                 container as-4-generic-spec-extended-community {
431                     reference "https://www.ietf.org/archive/id/draft-ietf-idr-as4octet-extcomm-generic-subtype-08.txt";
432                     uses as-4-spec-common;
433                 }
434             }
435             case as-4-route-origin-extended-community-case {
436                 container as-4-route-origin-extended-community {
437                     reference "https://tools.ietf.org/html/rfc5668";
438                     uses as-4-spec-common;
439                 }
440             }
441             case encapsulation-case {
442                 container encapsulation-extended-community {
443                     uses encapsulation-extended-community;
444                 }
445             }
446             case vrf-route-import-extended-community-case {
447                 reference "https://tools.ietf.org/html/rfc6514#section-7";
448                 container vrf-route-import-extended-community {
449                     uses inet4-specific-extended-community-common;
450                 }
451             }
452             case source-as-4-extended-community-case {
453                 container source-as-4-extended-community {
454                     uses source-as-4-extended-community-grouping;
455                 }
456             }
457             case source-as-extended-community-case {
458                 container source-as-extended-community {
459                     uses source-as-extended-community-grouping;
460                 }
461             }
462         }
463     }
464
465     grouping next-hop {
466         choice c-next-hop {
467             default empty-next-hop-case;
468             case ipv4-next-hop-case {
469                 container ipv4-next-hop {
470                     reference "http://tools.ietf.org/html/rfc4271#section-5.1.3";
471                     leaf global {
472                         type inet:ipv4-address-no-zone;
473                         mandatory true;
474                     }
475                 }
476             }
477             case ipv6-next-hop-case {
478                 container ipv6-next-hop {
479                     reference "http://tools.ietf.org/html/rfc4760#section-3";
480                     leaf global {
481                         type inet:ipv6-address-no-zone;
482                         mandatory true;
483                     }
484                     leaf link-local {
485                         type inet:ipv6-address-no-zone;
486                     }
487                 }
488             }
489             case empty-next-hop-case {
490                 leaf empty-next-hop {
491                     type empty;
492                 }
493             }
494         }
495     }
496
497     grouping as-path-segment {
498         reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
499         leaf-list as-sequence {
500             type inet:as-number;
501             ordered-by user;
502             max-elements "255";
503         }
504         leaf-list as-set {
505             type inet:as-number;
506         }
507     }
508
509     grouping route-distinguisher-grouping {
510         leaf route-distinguisher {
511             type route-distinguisher;
512             mandatory true;
513         }
514     }
515
516     grouping orig-route-ip-grouping {
517         leaf orig-route-ip {
518             type inet:ip-address-no-zone;
519             mandatory true;
520         }
521     }
522 }