Merge "BUG-50 : added test for Error message."
[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; }
8         import bgp-multiprotocol { prefix bgp-mp; }
9         import bgp-rib { prefix bgp-rib; }
10         import bgp-types { prefix bgp-t; }
11         import nps-concepts { prefix nps-c;}
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-09-18" {
30                 description
31                         "Initial revision.";
32                 reference "draft-ietf-idr-ls-distribution-03";
33         }
34
35         identity linkstate-address-family {
36                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
37
38                 base bgp-t:address-family;
39         }
40
41         identity linkstate-subsequent-address-family {
42                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
43
44                 base bgp-t:subsequent-address-family;
45         }
46
47         typedef nlri-type {
48                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
49                 type enumeration {
50                         enum node {
51                                 value 1;
52                         }
53                         enum link {
54                                 value 2;
55                         }
56                         enum ipv4-prefix {
57                                 value 3;
58                         }
59                         enum ipv6-prefix {
60                                 value 4;
61                         }
62                 }
63         }
64
65         typedef protocol-id {
66                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
67                 type enumeration {
68                         enum unknown {
69                                 value 0;
70                         }
71                         enum isis-level1 {
72                                 value 1;
73                         }
74                         enum isis-level2 {
75                                 value 2;
76                         }
77                         enum ospf {
78                                 value 3;
79                         }
80                         enum direct {
81                                 value 4;
82                         }
83                         enum static {
84                                 value 5;
85                         }
86                 }
87         }
88
89         typedef ospf-route-type {
90                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.3.1";
91                 type enumeration {
92                         enum intra-area {
93                                 value 1;
94                         }
95                         enum inter-area {
96                                 value 2;
97                         }
98                         enum external1 {
99                                 value 3;
100                         }
101                         enum external2 {
102                                 value 4;
103                         }
104                         enum nssa1 {
105                                 value 5;
106                         }
107                         enum nssa2 {
108                                 value 6;
109                         }
110                 }
111         }
112
113         typedef route-distinguisher {
114                 type uint64;
115         }
116
117         typedef identifier {
118                 type uint64;
119         }
120
121         typedef domain-identifier {
122                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
123                 type binary {
124                         length "4";
125                 }
126         }
127
128         typedef area-identifier {
129                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
130                 type binary {
131                         length "4";
132                 }
133         }
134
135         typedef ipv4-interface-identifier {
136                 reference "http://tools.ietf.org/html/rfc5305#section-3.2";
137                 type inet:ipv4-address;
138         }
139
140         typedef ipv6-interface-identifier {
141                 reference "http://tools.ietf.org/html/rfc6119#section-4.2";
142                 type inet:ipv6-address;
143         }
144
145         typedef ospf-interface-identifier {
146                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
147                 type binary {
148                         length "4";
149                 }
150         }
151
152         typedef topology-identifier {
153                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.5";
154                 type uint16 {
155                         range "0..4095";
156                 }
157         }
158
159
160         grouping isis-router-identifier {
161                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
162                 leaf iso-system-id {
163                         type nps-c:iso-system-identifier;
164                         mandatory true;
165                 }
166         }
167
168         grouping isis-lan-identifier {
169                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
170                 container is-is-router-identifier {
171                         uses isis-router-identifier;
172                 }
173                 leaf psn {
174                         type uint8 {
175                                 range "1..255";
176                         }
177                         mandatory true;
178                 }
179         }
180
181         grouping ospf-router-identifier {
182                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
183                 leaf ospf-router-id {
184                         type binary {
185                                 length "4";
186                         }
187                         mandatory true;
188                 }
189         }
190
191         grouping ospf-v2-lan-identifier {
192                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
193                 uses ospf-router-identifier;
194                 leaf ipv4-address {
195                         type ipv4-interface-identifier;
196                         mandatory true;
197                 }
198         }
199
200         grouping ospf-v3-lan-identifier {
201                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
202                 uses ospf-router-identifier;
203                 leaf lan-interface {
204                         type ospf-interface-identifier;
205                         mandatory true;
206                 }
207         }
208
209         grouping node-identifier {
210                 leaf as-number {
211                         type inet:as-number;
212                 }
213                 leaf area-id {
214                         type area-identifier;
215                 }
216                 leaf domain-id {
217                         type domain-identifier;
218                 }
219                 choice c-router-identifier {
220                         case c-isis-node {
221                                 container isis-node {
222                                         uses isis-router-identifier;
223                                 }
224                         }
225
226                         case c-isis-pseudonode {
227                                 container isis-pseudonode {
228                                         uses isis-lan-identifier;
229                                 }
230                         }
231
232                         case c-ospf-node {
233                                 container ospf-node {
234                                         uses ospf-router-identifier;
235                                 }
236                         }
237
238                         case c-ospf-pseudonode {
239                                 container ospf-pseudonode {
240                                         uses ospf-v3-lan-identifier;
241                                 }
242                         }
243                 }
244         }
245
246         grouping link-identifiers {
247                 reference "http://tools.ietf.org/html/rfc5307";
248                 leaf link-local-identifier {
249                         type binary {
250                                 length "4";
251                         }
252                 }
253                 leaf link-remote-identifier {
254                         type binary {
255                                 length "4";
256                         }
257                 }
258         }
259
260         grouping linkstate-destination {
261                 list c-linkstate-destination {
262                         leaf nlri-type {
263                                 type nlri-type;
264                         }
265                         leaf distinguisher {
266                                 type route-distinguisher;
267                         }
268                         leaf protocol-id {
269                                 type protocol-id;
270                         }
271                         leaf identifier {
272                                 type identifier;
273                         }
274                         container local-node-descriptors {
275                                 uses node-identifier;
276                         }
277                         container remote-node-descriptors {
278                                 when "../nlri-type = link";
279                                 uses node-identifier;
280                         }
281                         container link-descriptors {
282                                 when "../nlri-type = link";
283                                 uses link-identifiers;
284                                 leaf ipv4-interface-address {
285                                         type ipv4-interface-identifier;
286                                 }
287                                 leaf ipv6-interface-address {
288                                         type ipv6-interface-identifier;
289                                 }
290                                 leaf ipv4-neighbor-address {
291                                         type ipv4-interface-identifier;
292                                 }
293                                 leaf ipv6-neighbor-address {
294                                         type ipv6-interface-identifier;
295                                 }
296                                 leaf multi-topology-id {
297                                         type topology-identifier;
298                                 }
299                         }
300                         container prefix-descriptors {
301                                 when "../nlri-type = 'ipv4-prefix' or ../nlri-type = 'ipv6-prefix'";
302                                 leaf multi-topology-id {
303                                         type topology-identifier;
304                                 }
305                                 leaf ospf-route-type {
306                                         when "../protocol-id = 'ospf'";
307                                         type ospf-route-type;
308                                 }
309                                 leaf ip-reachability-information {
310                                         type inet:ip-prefix;
311                                 }
312                         }
313                 }
314         }
315
316         augment "/bgp-msg:update/bgp-msg:path-attributes/bgp-mp:mp-reach-nlri/bgp-mp:advertized-routes/bgp-mp:destination-type" {
317                 case destination-linkstate {
318                         uses linkstate-destination;
319                 }
320         }
321
322         augment "/bgp-msg:update/bgp-msg:path-attributes/bgp-mp:mp-unreach-nlri/bgp-mp:withdrawn-routes/bgp-mp:destination-type" {
323                 case destination-linkstate {
324                         uses linkstate-destination;
325                 }
326         }
327
328         typedef node-flag-bits {
329                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.1";
330                 type bits {
331                         bit overload {
332                                 position 0;
333                         }
334                         bit attached {
335                                 position 1;
336                         }
337                         bit external {
338                                 position 2;
339                         }
340                         bit abr {
341                                 position 3;
342                         }
343                 }
344         }
345
346         typedef isis-area-identifier {
347                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.2";
348                 type binary {
349                         length "20";
350                 }
351         }
352
353         typedef ipv4-router-identifier {
354                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.4";
355                 type inet:ipv4-address;
356         }
357
358         typedef ipv6-router-identifier {
359                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.4";
360                 type inet:ipv6-address;
361         }
362
363         grouping node-state {
364                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1";
365                 leaf-list topology-identifier {
366                         type topology-identifier;
367                 }
368                 leaf node-flags {
369                         type node-flag-bits;
370                 }
371                 leaf-list isis-area-id {
372                         type isis-area-identifier;
373                 }
374                 leaf dynamic-hostname {
375                         type string;
376                 }
377                 leaf ipv4-router-id {
378                         type ipv4-router-identifier;
379                 }
380                 leaf ipv6-router-id {
381                         type ipv6-router-identifier;
382                 }
383         }
384
385         typedef link-protection-type {
386                 reference "http://tools.ietf.org/html/rfc5307#section-1.2";
387                 type enumeration {
388                         enum extra-traffix {
389                                 value 1;
390                         }
391                         enum unprotected {
392                                 value 2;
393                         }
394                         enum shared {
395                                 value 4;
396                         }
397                         enum dedicated-1to1 {
398                                 value 8;
399                         }
400                         enum dedicated-1plus1 {
401                                 value 16;
402                         }
403                         enum enhanced {
404                                 value 32;
405                         }
406                 }
407         }
408
409         // linkstate
410         typedef mpls-protocol-mask {
411                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.2.2";
412                 type bits {
413                         bit ldp {
414                                 position 0;
415                         }
416                         bit rsvpte {
417                                 position 1;
418                         }
419                 }
420         }
421
422         typedef administrative-group {
423                 type uint32;
424         }
425
426         grouping unreserved-bandwidth {
427                 leaf priority {
428                         type uint8 {
429                                 range "0..7";
430                         }
431                 }
432                 leaf bandwidth {
433                         type nps-c:bandwidth;
434                 }
435         }
436
437         grouping link-state {
438                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.2";
439                 leaf local-ipv4-router-id {
440                         type ipv4-router-identifier;
441                 }
442                 leaf local-ipv6-router-id {
443                         type ipv6-router-identifier;
444                 }
445                 leaf remote-ipv4-router-id {
446                         type ipv4-router-identifier;
447                 }
448                 leaf remote-ipv6-router-id {
449                         type ipv6-router-identifier;
450                 }
451                 leaf mpls-protocol {
452                         type mpls-protocol-mask;
453                 }
454                 leaf te-metric {
455                         type nps-c:te-metric;
456                 }
457                 leaf metric {
458                         type nps-c:metric;
459                 }
460                 leaf-list shared-risk-link-groups {
461                         type rsvp:srlg-id;
462                 }
463                 leaf link-name {
464                         type string;
465                 }
466                 leaf max-link-bandwidth {
467                         type nps-c:bandwidth;
468                 }
469                 leaf max-reservable-bandwidth {
470                         type nps-c:bandwidth;
471                 }
472                 list unreserved-bandwidth {
473                         key "priority";
474                         uses unreserved-bandwidth;
475                 }
476                 leaf link-protection {
477                         type link-protection-type;
478                 }
479                 leaf admin-group {
480                         type administrative-group;
481                 }
482         }
483
484         typedef route-tag {
485                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.3.2";
486                 type binary {
487                         length "4";
488                 }
489         }
490
491         typedef extended-route-tag {
492                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.3.3";
493                 type binary {
494                         length "8";
495                 }
496         }
497
498         grouping igp-bits {
499                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.3.1";
500                 leaf up-down {
501                         type bits {
502                                 bit up-down {
503                                         position 0;
504                                 }
505                         }
506                 }
507         }
508
509         grouping prefix-state {
510                 container igp-bits {
511                         uses igp-bits;
512                 }
513                 leaf-list route-tags {
514                         type route-tag;
515                 }
516                 leaf-list extended-tags {
517                         type extended-route-tag;
518                 }
519                 leaf prefix-metric {
520                         type nps-c:igp-metric;
521                 }
522                 leaf ospf-forwarding-address {
523                         type inet:ipv4-address;
524                 }
525         }
526
527         augment "/bgp-msg:update/bgp-msg:path-attributes" {
528                 container linkstate-path-attribute {
529                         choice link-state-attribute {
530                                 case node-attributes {
531                                         when "../../nlri-type = node";
532                                         uses node-state;
533                                 }
534                                 case link-attributes {
535                                         when "../../nlri-type = link";
536                                         uses link-state;
537                                 }
538                                 case prefix-attributes {
539                                         when "../nlri-type = 'ipv4-prefix' or ../nlri-type = 'ipv6-prefix'";
540                                         uses prefix-state;
541                                 }
542                         }
543                 }
544         }
545
546         augment "/bgp-rib:loc-rib/bgp-rib:tables/bgp-rib:routes" {
547                 case linkstate-routes {
548                         container linkstate-routes {
549                                 leaf distinguisher {
550                                         type bgp-ls:route-distinguisher;
551                                 }
552                                 leaf protocol-id {
553                                         type bgp-ls:protocol-id;
554                                 }
555                                 leaf identifier {
556                                         type bgp-ls:identifier;
557                                 }
558
559                                 choice object-type {
560                                         case node {
561                                                 container node-descriptors {
562                                                         uses bgp-ls:node-identifier;
563                                                 }
564                                         }
565                                         case link {
566                                                 container local-node-descriptors {
567                                                         uses bgp-ls:node-identifier;
568                                                 }
569                                                 container remote-node-descriptors {
570                                                         uses bgp-ls:node-identifier;
571                                                 }
572                                                 container link-descriptors {
573                                                         uses bgp-ls:link-identifiers;
574                                                         leaf ipv4-interface-address {
575                                                                 type bgp-ls:ipv4-interface-identifier;
576                                                         }
577                                                         leaf ipv6-interface-address {
578                                                                 type bgp-ls:ipv6-interface-identifier;
579                                                         }
580                                                         leaf ipv4-neighbor-address {
581                                                                 type bgp-ls:ipv4-interface-identifier;
582                                                         }
583                                                         leaf ipv6-neighbor-address {
584                                                                 type bgp-ls:ipv6-interface-identifier;
585                                                         }
586                                                         leaf multi-topology-id {
587                                                                 type bgp-ls:topology-identifier;
588                                                         }
589                                                 }
590                                         }
591                                         case prefix {
592                                                 leaf multi-topology-id {
593                                                         type bgp-ls:topology-identifier;
594                                                 }
595                                                 leaf ospf-route-type {
596                                                         when "../../protocol-id = 'ospf'";
597                                                         type bgp-ls:ospf-route-type;
598                                                 }
599                                                 leaf ip-reachability-information {
600                                                         type inet:ip-prefix;
601                                                 }
602                                         }
603                                 }
604
605                                 uses bgp-rib:route;
606                         }
607                 }
608         }
609 }