BUG-608 : added prefix-sid tlv
[bgpcep.git] / bgp / linkstate / src / main / yang / bgp-linkstate.yang
1 module bgp-linkstate {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:bgp-linkstate";
4     prefix "bgp-ls";
5
6     import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
7     import bgp-message { prefix bgp-msg; revision-date 2013-09-19; }
8     import bgp-multiprotocol { prefix bgp-mp; revision-date 2013-09-19; }
9     import bgp-rib { prefix bgp-rib; revision-date 2013-09-25; }
10     import bgp-types { prefix bgp-t; revision-date 2013-09-19; }
11     import network-concepts { prefix netc; revision-date 2013-11-25; }
12     import rsvp { prefix rsvp; revision-date 2013-08-20; }
13     import bgp-segment-routing { prefix bgp-sr; revision-date 2015-02-06; }
14
15     organization "Cisco Systems, Inc.";
16     contact "Dana Kutenicsova <dkutenic@cisco.com>";
17
18     description
19         "This module contains the base data model of a BGP message.
20         It rolls up the definitions contained in RFC4271
21         and draft-ietf-idr-ls-distribution-03.
22
23         Copyright (c)2013 Cisco Systems, Inc. All rights reserved.
24
25         This program and the accompanying materials are made available
26         under the terms of the Eclipse Public License v1.0 which
27         accompanies this distribution, and is available at
28         http://www.eclipse.org/legal/epl-v10.html";
29
30     revision "2015-02-10" {
31         description
32             "Updated to include segment routing.";
33     }
34
35     revision "2013-11-25" {
36         description
37             "Updated to cover network-concepts.";
38     }
39
40     revision "2013-09-18" {
41         description
42             "Initial revision.";
43         reference "draft-ietf-idr-ls-distribution-03";
44     }
45
46     identity linkstate-address-family {
47         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
48
49         base bgp-t:address-family;
50     }
51
52     identity linkstate-subsequent-address-family {
53         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
54
55         base bgp-t:subsequent-address-family;
56     }
57
58     typedef nlri-type {
59         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
60         type enumeration {
61             enum node {
62                 value 1;
63             }
64             enum link {
65                 value 2;
66             }
67             enum ipv4-prefix {
68                 value 3;
69             }
70             enum ipv6-prefix {
71                 value 4;
72             }
73         }
74     }
75
76     typedef protocol-id {
77         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
78         type enumeration {
79             enum unknown {
80                 value 0;
81             }
82             enum isis-level1 {
83                 value 1;
84             }
85             enum isis-level2 {
86                 value 2;
87             }
88             enum ospf {
89                 value 3;
90             }
91             enum direct {
92                 value 4;
93             }
94             enum static {
95                 value 5;
96             }
97         }
98     }
99
100     typedef ospf-route-type {
101         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.3.1";
102         type enumeration {
103             enum intra-area {
104                 value 1;
105             }
106             enum inter-area {
107                 value 2;
108             }
109             enum external1 {
110                 value 3;
111             }
112             enum external2 {
113                 value 4;
114             }
115             enum nssa1 {
116                 value 5;
117             }
118             enum nssa2 {
119                 value 6;
120             }
121         }
122     }
123
124     typedef route-distinguisher {
125         type uint64;
126     }
127
128     typedef identifier {
129         type uint64;
130     }
131
132     typedef domain-identifier {
133         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
134         type uint32;
135     }
136
137     typedef area-identifier {
138         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
139         type uint32;
140     }
141
142     typedef ipv4-interface-identifier {
143         reference "http://tools.ietf.org/html/rfc5305#section-3.2";
144         type inet:ipv4-address;
145     }
146
147     typedef ipv6-interface-identifier {
148         reference "http://tools.ietf.org/html/rfc6119#section-4.2";
149         type inet:ipv6-address;
150     }
151
152     typedef ospf-interface-identifier {
153         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
154         type uint32;
155     }
156
157     typedef topology-identifier {
158         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.5";
159         type uint16 {
160             range "0..4095";
161         }
162     }
163
164
165     grouping isis-router-identifier {
166         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
167         leaf iso-system-id {
168             type netc:iso-system-identifier;
169             mandatory true;
170         }
171     }
172
173     grouping isis-lan-identifier {
174         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
175         container is-is-router-identifier {
176             uses isis-router-identifier;
177         }
178         leaf psn {
179             type uint8 {
180                 range "1..255";
181             }
182             mandatory true;
183         }
184     }
185
186     grouping ospf-router-identifier {
187         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
188         leaf ospf-router-id {
189             type uint32;
190             mandatory true;
191         }
192     }
193
194     grouping ospf-v2-lan-identifier {
195         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
196         uses ospf-router-identifier;
197         leaf ipv4-address {
198             type ipv4-interface-identifier;
199             mandatory true;
200         }
201     }
202
203     grouping ospf-v3-lan-identifier {
204         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
205         uses ospf-router-identifier;
206         leaf lan-interface {
207             type ospf-interface-identifier;
208             mandatory true;
209         }
210     }
211
212     grouping node-identifier {
213         leaf as-number {
214             type inet:as-number;
215         }
216         leaf area-id {
217             type area-identifier;
218         }
219         leaf domain-id {
220             type domain-identifier;
221         }
222         choice c-router-identifier {
223             case isis-node-case {
224                 container isis-node {
225                     uses isis-router-identifier;
226                 }
227             }
228
229             case isis-pseudonode-case {
230                 container isis-pseudonode {
231                     uses isis-lan-identifier;
232                 }
233             }
234
235             case ospf-node-case {
236                 container ospf-node {
237                     uses ospf-router-identifier;
238                 }
239             }
240
241             case ospf-pseudonode-case {
242                 container ospf-pseudonode {
243                     uses ospf-v3-lan-identifier;
244                 }
245             }
246         }
247     }
248
249     grouping link-lr-identifiers {
250         reference "http://tools.ietf.org/html/rfc5307";
251         leaf link-local-identifier {
252             type uint32;
253         }
254         leaf link-remote-identifier {
255             type uint32;
256         }
257     }
258
259     grouping prefix-identifiers {
260         leaf multi-topology-id {
261             type topology-identifier;
262         }
263         leaf ospf-route-type {
264             when "../../protocol-id = 'ospf'";
265             type ospf-route-type;
266         }
267         leaf ip-reachability-information {
268             type inet:ip-prefix;
269         }
270     }
271
272     grouping link-identifier {
273         uses link-lr-identifiers;
274         leaf ipv4-interface-address {
275             type ipv4-interface-identifier;
276         }
277         leaf ipv6-interface-address {
278             type ipv6-interface-identifier;
279         }
280         leaf ipv4-neighbor-address {
281             type ipv4-interface-identifier;
282         }
283         leaf ipv6-neighbor-address {
284             type ipv6-interface-identifier;
285         }
286         leaf multi-topology-id {
287             type topology-identifier;
288         }
289     }
290
291     grouping linkstate-destination {
292         list c-linkstate-destination {
293             leaf nlri-type {
294                 type nlri-type;
295             }
296             leaf distinguisher {
297                 type route-distinguisher;
298             }
299             leaf protocol-id {
300                 type protocol-id;
301             }
302             leaf identifier {
303                 type identifier;
304             }
305             container local-node-descriptors {
306                 uses node-identifier;
307             }
308             container remote-node-descriptors {
309                 when "../nlri-type = link";
310                 uses node-identifier;
311             }
312             container link-descriptors {
313                 when "../nlri-type = link";
314                 uses link-identifier;
315             }
316             container prefix-descriptors {
317                 when "../nlri-type = 'ipv4-prefix' or ../nlri-type = 'ipv6-prefix'";
318                 uses prefix-identifiers;
319             }
320         }
321     }
322
323     augment "/bgp-msg:update/bgp-msg:path-attributes/bgp-mp:mp-reach-nlri/bgp-mp:advertized-routes/bgp-mp:destination-type" {
324         case destination-linkstate-case {
325             container destination-linkstate {
326                 uses linkstate-destination;
327             }
328         }
329     }
330
331     augment "/bgp-msg:update/bgp-msg:path-attributes/bgp-mp:mp-unreach-nlri/bgp-mp:withdrawn-routes/bgp-mp:destination-type" {
332         case destination-linkstate-case {
333             container destination-linkstate {
334                 uses linkstate-destination;
335             }
336         }
337     }
338
339     typedef node-flag-bits {
340         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.1";
341         type bits {
342             bit overload {
343                 position 0;
344             }
345             bit attached {
346                 position 1;
347             }
348             bit external {
349                 position 2;
350             }
351             bit abr {
352                 position 3;
353             }
354         }
355     }
356
357     typedef isis-area-identifier {
358         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.2";
359         type binary {
360             length "1..20";
361         }
362     }
363
364     typedef ipv4-router-identifier {
365         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.4";
366         type inet:ipv4-address;
367     }
368
369     typedef ipv6-router-identifier {
370         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.4";
371         type inet:ipv6-address;
372     }
373
374     grouping node-state {
375         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1";
376         leaf-list topology-identifier {
377             type topology-identifier;
378         }
379         leaf node-flags {
380             type node-flag-bits;
381         }
382         leaf-list isis-area-id {
383             type isis-area-identifier;
384         }
385         leaf dynamic-hostname {
386             type string;
387         }
388         leaf ipv4-router-id {
389             type ipv4-router-identifier;
390         }
391         leaf ipv6-router-id {
392             type ipv6-router-identifier;
393         }
394         uses bgp-sr:sid-label-binding;
395         uses bgp-sr:sr-capabilities;
396         uses bgp-sr:sr-algorithm;
397     }
398
399     typedef link-protection-type {
400         reference "http://tools.ietf.org/html/rfc5307#section-1.2";
401         type enumeration {
402             enum extra-traffic {
403                 value 1;
404             }
405             enum unprotected {
406                 value 2;
407             }
408             enum shared {
409                 value 4;
410             }
411             enum dedicated-1to1 {
412                 value 8;
413             }
414             enum dedicated-1plus1 {
415                 value 16;
416             }
417             enum enhanced {
418                 value 32;
419             }
420         }
421     }
422
423     // linkstate
424     typedef mpls-protocol-mask {
425         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.2.2";
426         type bits {
427             bit ldp {
428                 position 0;
429             }
430             bit rsvpte {
431                 position 1;
432             }
433         }
434     }
435
436     typedef administrative-group {
437         type uint32;
438     }
439
440     grouping unreserved-bandwidth {
441         leaf priority {
442             type uint8 {
443                 range "0..7";
444             }
445         }
446         leaf bandwidth {
447             type netc:bandwidth;
448         }
449     }
450
451     grouping link-state {
452         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.2";
453         leaf local-ipv4-router-id {
454             type ipv4-router-identifier;
455         }
456         leaf local-ipv6-router-id {
457             type ipv6-router-identifier;
458         }
459         leaf remote-ipv4-router-id {
460             type ipv4-router-identifier;
461         }
462         leaf remote-ipv6-router-id {
463             type ipv6-router-identifier;
464         }
465         leaf mpls-protocol {
466             type mpls-protocol-mask;
467         }
468         leaf te-metric {
469             type netc:te-metric;
470         }
471         leaf metric {
472             type netc:metric;
473         }
474         leaf-list shared-risk-link-groups {
475             type rsvp:srlg-id;
476         }
477         leaf link-name {
478             type string;
479         }
480         leaf max-link-bandwidth {
481             type netc:bandwidth;
482         }
483         leaf max-reservable-bandwidth {
484             type netc:bandwidth;
485         }
486         list unreserved-bandwidth {
487             key "priority";
488             uses unreserved-bandwidth;
489         }
490         leaf link-protection {
491             type link-protection-type;
492         }
493         leaf admin-group {
494             type administrative-group;
495         }
496         uses bgp-sr:adjacency-segment-identifier;
497         uses bgp-sr:lan-adjacency-segment-identifier;
498     }
499
500     typedef route-tag {
501         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.3.2";
502         type binary {
503             length "4";
504         }
505     }
506
507     typedef extended-route-tag {
508         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.3.3";
509         type binary {
510             length "8";
511         }
512     }
513
514     grouping igp-bits {
515         reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.3.1";
516         leaf up-down {
517             type bits {
518                 bit up-down {
519                     position 0;
520                 }
521             }
522         }
523     }
524
525     grouping prefix-state {
526         container igp-bits {
527             uses igp-bits;
528         }
529         leaf-list route-tags {
530             type route-tag;
531         }
532         leaf-list extended-tags {
533             type extended-route-tag;
534         }
535         leaf prefix-metric {
536             type netc:igp-metric;
537         }
538         leaf ospf-forwarding-address {
539             type inet:ip-address;
540         }
541         uses bgp-sr:prefix-sid;
542     }
543
544     grouping linkstate-routes {
545         container linkstate-routes {
546             list linkstate-route {
547                 description
548                     "Link-state information entry. Due to
549                     the complexity of link-state information
550                     and YANG limitations this is the top-level
551                     object from contract perspective. It is
552                     keyed by route-key, whose format is
553                     internal to the implementation exposing
554                     this information. As an explicit example
555                     it can rely on information stored in the
556                     entry's subtree, so the subtree MUST NOT
557                     be modified by outside entities.
558                     Augmentations can attach data, but must
559                     be explicitly aware that such data, unlike
560                     the data modeled directly here, does not
561                     have any effects on keys, especially they
562                     must not impact equality tests.";
563
564                 leaf route-key {
565                     description
566                         "The sole function of this leaf
567                         to act as the key in the list.
568                         Its format does not form the
569                         API contract of this model.";
570                     type binary;
571                 }
572                 key "route-key";
573
574                 leaf distinguisher {
575                     type route-distinguisher;
576                 }
577                 leaf protocol-id {
578                     type protocol-id;
579                 }
580                 leaf identifier {
581                     type identifier;
582                 }
583
584                 choice object-type {
585                     case node-case {
586                         container node-descriptors {
587                             uses node-identifier;
588                         }
589                     }
590                     case link-case {
591                         container local-node-descriptors {
592                             uses node-identifier;
593                         }
594                         container remote-node-descriptors {
595                             uses node-identifier;
596                         }
597                         container link-descriptors {
598                             uses link-identifier;
599                         }
600                     }
601                     case prefix-case {
602                         container advertising-node-descriptors {
603                             uses node-identifier;
604                         }
605
606                         uses prefix-identifiers;
607                     }
608                 }
609
610                 uses bgp-rib:route {
611                     augment attributes {
612                         choice attribute-type {
613                             case node-case {
614                                 container node-attributes {
615                                     uses node-state;
616                                 }
617                             }
618                             case link-case {
619                                 container link-attributes {
620                                     uses link-state;
621                                 }
622                             }
623                             case prefix-case {
624                                 container prefix-attributes {
625                                     uses prefix-state;
626                                 }
627                             }
628                         }
629                     }
630                 }
631             }
632         }
633     }
634
635     augment "/bgp-msg:update/bgp-msg:path-attributes" {
636         container linkstate-path-attribute {
637             choice link-state-attribute {
638                 case node-attributes-case {
639                     container node-attributes {
640                         when "../../nlri-type = node";
641                         uses node-state;
642                     }
643                 }
644                 case link-attributes-case {
645                     container link-attributes {
646                         when "../../nlri-type = link";
647                         uses link-state;
648                     }
649                 }
650                 case prefix-attributes-case {
651                     container prefix-attributes {
652                         when "../nlri-type = 'ipv4-prefix' or ../nlri-type = 'ipv6-prefix'";
653                         uses prefix-state;
654                     }
655                 }
656             }
657         }
658     }
659
660     augment "/bgp-rib:application-rib/bgp-rib:tables/bgp-rib:routes" {
661         case linkstate-routes-case {
662             uses linkstate-routes;
663         }
664     }
665
666     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:loc-rib/bgp-rib:tables/bgp-rib:routes" {
667         case linkstate-routes-case {
668             uses linkstate-routes;
669         }
670     }
671 }