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