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