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