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