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