fd6529aa4e7154cf1a071049c05661ff35ae4853
[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     augment "/bgp-msg:update/bgp-msg:path-attributes" {
533         container linkstate-path-attribute {
534             choice link-state-attribute {
535                 case node-attributes-case {
536                     container node-attributes {
537                         when "../../nlri-type = node";
538                         uses node-state;
539                     }
540                 }
541                 case link-attributes-case {
542                     container link-attributes {
543                         when "../../nlri-type = link";
544                         uses link-state;
545                     }
546                 }
547                 case prefix-attributes-case {
548                     container prefix-attributes {
549                         when "../nlri-type = 'ipv4-prefix' or ../nlri-type = 'ipv6-prefix'";
550                         uses prefix-state;
551                     }
552                 }
553             }
554         }
555     }
556
557     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:loc-rib/bgp-rib:tables/bgp-rib:routes" {
558         case linkstate-routes-case {
559             container linkstate-routes {
560                 list linkstate-route {
561                     description
562                         "Link-state information entry. Due to
563                         the complexity of link-state information
564                         and YANG limitations this is the top-level
565                         object from contract perspective. It is
566                         keyed by route-key, whose format is
567                         internal to the implementation exposing
568                         this information. As an explicit example
569                         it can rely on information stored in the
570                         entry's subtree, so the subtree MUST NOT
571                         be modified by outside entities.
572                         Augmentations can attach data, but must
573                         be explicitly aware that such data, unlike
574                         the data modeled directly here, does not
575                         have any effects on keys, especially they
576                         must not impact equality tests.";
577
578                     leaf route-key {
579                         description
580                             "The sole function of this leaf
581                             to act as the key in the list.
582                             Its format does not form the
583                             API contract of this model.";
584                         type binary;
585                     }
586                     key "route-key";
587
588                     leaf distinguisher {
589                         type route-distinguisher;
590                     }
591                     leaf protocol-id {
592                         type protocol-id;
593                     }
594                     leaf identifier {
595                         type identifier;
596                     }
597
598                     choice object-type {
599                         case node-case {
600                             container node-descriptors {
601                                 uses node-identifier;
602                             }
603                         }
604                         case link-case {
605                             container local-node-descriptors {
606                                 uses node-identifier;
607                             }
608                             container remote-node-descriptors {
609                                 uses node-identifier;
610                             }
611                             container link-descriptors {
612                                 uses link-identifier;
613                             }
614                         }
615                         case prefix-case {
616                             container advertising-node-descriptors {
617                                 uses node-identifier;
618                             }
619
620                             uses prefix-identifiers;
621                         }
622                     }
623
624                     uses bgp-rib:route {
625                         augment attributes {
626                             choice attribute-type {
627                                 case node-case {
628                                     container node-attributes {
629                                         uses node-state;
630                                     }
631                                 }
632                                 case link-case {
633                                     container link-attributes {
634                                         uses link-state;
635                                     }
636                                 }
637                                 case prefix-case {
638                                     container prefix-attributes {
639                                         uses prefix-state;
640                                     }
641                                 }
642                             }
643                         }
644                     }
645                 }
646             }
647         }
648     }
649 }