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