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