Removed checkstyle warnings.
[bgpcep.git] / pcep / api / src / main / yang / pcep-types.yang
1 module pcep-types {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:pcep:types";
4     prefix "pcep-t";
5
6     import ieee754 { prefix ieee754; revision-date 2013-08-19; }
7     import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
8     import network-concepts { prefix netc; revision-date 2013-11-25; }
9     import rsvp { prefix rsvp; revision-date 2013-08-20; }
10     import iana { prefix iana; revision-date 2013-08-16; }
11
12     organization "Cisco Systems, Inc.";
13     contact "Robert Varga <rovarga@cisco.com>";
14
15     description
16         "This module contains the base data model of a PCEP message.
17         It rolls up the definitions contained in RFC5440, RFC5520
18         and RFC6006.
19
20         Copyright (c)2013 Cisco Systems, Inc. All rights reserved.
21
22         This program and the accompanying materials are made available
23         under the terms of the Eclipse Public License v1.0 which
24         accompanies this distribution, and is available at
25         http://www.eclipse.org/legal/epl-v10.html";
26
27     revision "2013-10-05" {
28         description
29             "Initial revision.";
30         reference "RFC5440";
31     }
32
33     // NOTE: this model uses counts bits in fields from left to right,
34     //       just as IANA does for PCEP protocol.
35
36     // Types
37     typedef protocol-version {
38         type uint8 {
39             range 1..7;
40         }
41     }
42
43     typedef request-id {
44         type uint32 {
45             range 1..max;
46         }
47     }
48
49     typedef of-id {
50         type uint16;
51     }
52
53     typedef path-key {
54         type uint16;
55     }
56
57     typedef pce-id {
58         type union {
59             type binary {
60                 length 4;
61             }
62             type binary {
63                 length 16;
64             }
65         }
66     }
67
68     // TLVs
69     grouping tlv {
70         description "Marker grouping for TLV groupings.";
71     }
72
73     grouping no-path-vector-tlv {
74         description "NO-PATH-VECTOR TLV";
75         reference "https://tools.ietf.org/html/rfc5440#section-7.5";
76
77         uses tlv;
78         leaf flags {
79             type bits {
80                 bit p2mp-unreachable {
81                     position 24;
82                 }
83                 bit no-gco-solution {
84                     position 25;
85                 }
86                 bit no-gco-migration {
87                     position 26;
88                 }
89                 bit path-key {
90                     reference "https://tools.ietf.org/html/rfc5520#section-7.4";
91                     position 27;
92                 }
93                 bit chain-unavailable {
94                     position 28;
95                 }
96                 bit unknown-source {
97                     position 29;
98                 }
99                 bit unknown-destination {
100                     position 30;
101                 }
102                 bit pce-unavailable {
103                     position 31;
104                 }
105             }
106             mandatory true;
107         }
108     }
109
110     grouping overload-duration-tlv {
111         description "OVERLOAD-DURATION TLV";
112         reference "https://tools.ietf.org/html/rfc5440#section-7.14";
113         container overload-duration {
114             uses tlv;
115             leaf duration {
116                 type uint32;
117                 units seconds;
118             }
119         }
120     }
121
122     grouping req-missing-tlv {
123         description "REQ-MISSING TLV";
124         reference "https://tools.ietf.org/html/rfc5440#section-7.5";
125         container req-missing {
126             uses tlv;
127             leaf request-id {
128                 type request-id;
129             }
130         }
131     }
132
133     grouping of-list-tlv {
134         description "OF-List TLV";
135         reference "https://tools.ietf.org/html/rfc5541#section-2.1";
136         container of-list {
137             uses tlv;
138             leaf-list codes {
139                 type of-id;
140             }
141         }
142     }
143
144     grouping order-tlv {
145         description "Order TLV";
146         reference "https://tools.ietf.org/html/rfc5557#section-5.4";
147         container order {
148             uses tlv;
149             leaf delete {
150                 type uint32;
151                 mandatory true;
152             }
153
154             leaf setup {
155                 type uint32;
156                 mandatory true;
157             }
158         }
159     }
160
161     grouping vs-tlv {
162         description "Vendor-specific TLV.";
163         container vs-tlv {
164                 uses tlv;
165
166                 leaf enterprise-number {
167                     type iana:enterprise-number;
168                 }
169
170                 choice vendor-payload {
171                 }
172         }
173     }
174
175     // Objects
176     grouping object-header {
177         description "Common Object Header";
178         reference "https://tools.ietf.org/html/rfc5440#section-7.2";
179
180         leaf processing-rule {
181             type boolean;
182             default false;
183         }
184
185         leaf ignore {
186             type boolean;
187             default false;
188         }
189     }
190
191     grouping object {
192         description "Core object structure with optional TLVs";
193         uses object-header;
194     }
195
196     grouping open-object {
197         description "OPEN Object";
198         reference "https://tools.ietf.org/html/rfc5440#section-7.3";
199
200         container open {
201             uses object;
202             container "tlvs" {
203                 uses of-list-tlv;
204             }
205
206             leaf version {
207                 type protocol-version;
208                 default 1;
209             }
210
211             leaf keepalive {
212                 // Note: non-presence is equal to '0'
213                 type uint8 {
214                     range 1..255;
215                 }
216                 mandatory true;
217             }
218
219             leaf dead-timer {
220                 // Note: non-presence is equal to '0'
221                 type uint8 {
222                     range 1..255;
223                 }
224                 mandatory true;
225             }
226
227             leaf session-id {
228                 type uint8;
229             }
230         }
231     }
232
233     grouping rp-object {
234         description "RP Object";
235         reference "https://tools.ietf.org/html/rfc5440#section-7.4";
236         container rp {
237             uses object;
238             container "tlvs" {
239                 uses order-tlv;
240             }
241
242             leaf priority {
243                 type uint8 {
244                     range 1..7;
245                 }
246             }
247
248             leaf request-id {
249                 type request-id;
250                 mandatory true;
251             }
252
253             leaf reoptimization {
254                 type boolean;
255                 default false;
256             }
257
258             leaf bi-directional {
259                 type boolean;
260                 default false;
261             }
262
263             leaf loose {
264                 type boolean;
265                 default false;
266             }
267
268             leaf path-key {
269                 type boolean;
270                 default false;
271                 reference "https://tools.ietf.org/html/rfc5520#section-3.2.1";
272             }
273
274             leaf fragmentation {
275                 type boolean;
276                 default false;
277                 reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
278             }
279
280             leaf p2mp {
281                 type boolean;
282                 default false;
283                 reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
284             }
285
286             leaf ero-compression {
287                 type boolean;
288                 default false;
289                 reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
290             }
291
292             leaf supply-of {
293                 type boolean;
294                 default false;
295                 reference "https://tools.ietf.org/html/rfc5541#section-3.3";
296             }
297
298             leaf order {
299                 type boolean;
300                 default false;
301                 reference "https://tools.ietf.org/html/rfc5557#section-5.3";
302             }
303
304             leaf make-before-break {
305                 type boolean;
306                 default false;
307                 reference "https://tools.ietf.org/html/rfc5557#section-5.3";
308             }
309         }
310     }
311
312     grouping no-path-object {
313         description "NO-PATH Object";
314         reference "https://tools.ietf.org/html/rfc5440#section-7.5";
315
316         uses object;
317
318         leaf nature-of-issue {
319             type uint8;
320             mandatory true;
321         }
322
323         leaf unsatisfied-constraints {
324             when "nature-of-issue = 0" {
325                 description
326                     "The C flag has no meaning
327                     and is ignored unless the NI
328                     field is set to 0x00.";
329             }
330             type boolean;
331             default false;
332         }
333     }
334
335     grouping endpoints {
336         choice address-family {
337             mandatory true;
338
339             case ipv4-case {
340                 container ipv4 {
341                     leaf source-ipv4-address {
342                         type inet:ipv4-address;
343                         mandatory true;
344                     }
345
346                     leaf destination-ipv4-address {
347                         type inet:ipv4-address;
348                         mandatory true;
349                     }
350                 }
351             }
352             case ipv6-case {
353                 container ipv6 {
354                     leaf source-ipv6-address {
355                         type inet:ipv6-address;
356                         mandatory true;
357                     }
358
359                     leaf destination-ipv6-address {
360                         type inet:ipv6-address;
361                         mandatory true;
362                     }
363                 }
364             }
365         }
366     }
367
368     grouping endpoints-object {
369         description "END-POINTS Object";
370         reference "https://tools.ietf.org/html/rfc5440#section-7.6";
371
372         container endpoints-obj {
373             uses object;
374             uses endpoints;
375         }
376     }
377
378     grouping bandwidth-object {
379         description "BANDWIDTH Object";
380         reference "https://tools.ietf.org/html/rfc5440#section-7.7";
381         container bandwidth {
382             uses object;
383
384             // No possibility to carry TLVs
385             leaf bandwidth {
386                 type netc:bandwidth;
387             }
388         }
389     }
390
391     grouping metric-object {
392         description "METRIC Object";
393         reference "https://tools.ietf.org/html/rfc5440#section-7.8";
394         container metric {
395             uses object;
396
397             leaf metric-type {
398                 type uint8;
399                 mandatory true;
400             }
401
402             leaf bound {
403                 type boolean;
404                 default false;
405             }
406
407             leaf computed {
408                 type boolean;
409                 default false;
410             }
411
412             leaf value {
413                 type ieee754:float32;
414             }
415         }
416     }
417
418     grouping exclude-route-object {
419         description "Exclude Route Object";
420         reference "https://tools.ietf.org/html/rfc5521#section-2.1.1";
421
422         container xro {
423             uses object;
424
425             leaf flags {
426                 type bits {
427                     bit fail {
428                         position 31;
429                     }
430                 }
431                 mandatory true;
432             }
433
434             list subobject {
435                 uses rsvp:exclude-route-subobjects;
436                 order-by user;
437             }
438         }
439     }
440
441     grouping explicit-route-object {
442         description "Explicit Route Object";
443         reference "https://tools.ietf.org/html/rfc5440#section-7.9";
444
445         container ero {
446             // No possibility of TLVs
447             uses object;
448
449             list subobject {
450                 leaf loose {
451                     type boolean;
452                     mandatory true;
453                 }
454
455                 uses rsvp:explicit-route-subobjects {
456                     augment "subobject-type" {
457                         case path-key-case {
458                             container path-key {
459                                 uses path-key-subobject;
460                             }
461                         }
462                     }
463                 }
464
465                 order-by user;
466             }
467         }
468     }
469
470     grouping include-route-object {
471         description "Include Route Object";
472         reference "https://tools.ietf.org/html/rfc5440#section-7.12";
473
474         container iro {
475             // No possibility of TLVs
476             uses object;
477
478             list subobject {
479                 uses rsvp:explicit-route-subobjects;
480                 order-by user;
481             }
482         }
483     }
484
485     grouping reported-route-object {
486         description "Reported Route Object";
487         reference "https://tools.ietf.org/html/rfc5440#section-7.10";
488
489         container rro {
490             // No possibility of TLVs
491             uses object;
492
493             list subobject {
494                 uses rsvp:record-route-subobjects {
495                     augment "subobject-type" {
496                         case path-key-case {
497                             container path-key {
498                                 uses path-key-subobject;
499                             }
500                         }
501                     }
502                 }
503                 order-by user;
504             }
505         }
506     }
507
508     grouping lspa-object {
509         description "LSPA Object";
510         reference "https://tools.ietf.org/html/rfc5440#section-7.11";
511
512         container lspa {
513             uses object;
514             uses rsvp:tunnel-attributes;
515             container "tlvs" {
516             }
517         }
518     }
519
520     grouping svec-object {
521         description "Synchronization Vector Object";
522         reference "https://tools.ietf.org/html/rfc5440#section-7.13";
523
524         container svec {
525             // No possibility of TLVs
526             uses object;
527
528             leaf link-diverse {
529                 type boolean;
530                 default false;
531             }
532
533             leaf node-diverse {
534                 type boolean;
535                 default false;
536             }
537
538             leaf srlg-diverse {
539                 type boolean;
540                 default false;
541             }
542
543             leaf-list requests-ids {
544                 type request-id;
545             }
546         }
547     }
548
549     grouping notification-object {
550         description "NOTIFICATION Object";
551         reference "https://tools.ietf.org/html/rfc5440#section-7.14";
552         container c-notification {
553             uses object;
554             container "tlvs" {
555                 when "../type = 2 and ../value = 1";
556
557                 uses overload-duration-tlv;
558             }
559
560             leaf type {
561                 type uint8;
562                 mandatory true;
563             }
564
565             leaf value {
566                 type uint8;
567                 mandatory true;
568             }
569         }
570     }
571
572     grouping pcep-error-object {
573         description "PCEP-ERROR Object";
574         reference "https://tools.ietf.org/html/rfc5440#section-7.15";
575         container error-object {
576             uses object;
577             container "tlvs" {
578                 when "../type = 7";
579                 uses req-missing-tlv;
580             }
581
582             leaf type {
583                 type uint8;
584                 mandatory true;
585             }
586
587             leaf value {
588                 type uint8;
589                 mandatory true;
590             }
591         }
592     }
593
594     grouping load-balancing-object {
595         description "LOAD-BALANCING Object";
596         reference "https://tools.ietf.org/html/rfc5440#section-7.16";
597
598         container load-balancing {
599             // No possibility of TLVs
600             uses object;
601
602             leaf max-lsp {
603                 type uint8;
604                 mandatory true;
605             }
606
607             leaf min-bandwidth {
608                 type netc:bandwidth;
609             }
610         }
611     }
612
613     grouping close-object {
614         description "CLOSE Object";
615         reference "https://tools.ietf.org/html/rfc5440#section-7.17";
616
617         container c-close {
618             uses object;
619
620             leaf reason {
621                 type uint8;
622                 mandatory true;
623             }
624
625             container tlvs {
626
627             }
628         }
629     }
630
631     grouping path-key-subobject {
632         reference "https://tools.ietf.org/html/rfc5520#section-3.1";
633         uses rsvp:c-subobject;
634
635         leaf pce-id {
636             type pce-id;
637             mandatory true;
638         }
639
640         leaf path-key {
641             type path-key;
642             mandatory true;
643         }
644     }
645
646     grouping path-key-object {
647         description "PATH-KEY Object";
648         reference "https://tools.ietf.org/html/rfc5520#section-3.2.2";
649         container path-key {
650             uses object;
651
652             list path-keys {
653                 min-elements 1;
654
655                 leaf loose {
656                     type boolean;
657                     default false;
658                 }
659
660                 uses path-key-subobject;
661                 order-by user;
662             }
663         }
664     }
665
666     grouping of-object {
667         description "OF Object";
668         reference "https://tools.ietf.org/html/rfc5541#section-3.1";
669         container of {
670             uses object;
671
672             leaf code {
673                 type of-id;
674                 mandatory true;
675             }
676         }
677     }
678
679     typedef class-type {
680         type uint8 {
681             range 1..7;
682         }
683     }
684
685     grouping classtype-object {
686         description "CLASSTYPE Object";
687         reference "https://tools.ietf.org/html/rfc5455#section-3";
688
689         container class-type {
690             uses object;
691
692             leaf class-type {
693                 type class-type;
694                 mandatory true;
695             }
696         }
697     }
698
699     grouping gc-object {
700         description "GLOBAL CONSTRAINTS (GC) Object";
701         reference "https://tools.ietf.org/html/rfc5557#section-5.5";
702         container gc {
703             uses object;
704
705             leaf max-hop {
706                 type uint8;
707                 mandatory true;
708             }
709
710             leaf max-utilization {
711                 type uint8 {
712                     range 0..100;
713                 }
714                 units percent;
715                 mandatory true;
716             }
717
718             leaf min-utilization {
719                 type uint8 {
720                     range 0..100;
721                 }
722                 units percent;
723                 mandatory true;
724             }
725
726             leaf over-booking-factor {
727                 type uint8 {
728                     range 0..100;
729                 }
730                 units percent;
731                 mandatory true;
732             }
733         }
734     }
735
736     // Messages
737     grouping message {
738         description "Marker grouping for message groupings.";
739     }
740
741     grouping message-header {
742         description "Common Header";
743         reference "https://tools.ietf.org/html/rfc5440#section-6.1";
744
745         leaf version {
746             type protocol-version;
747             default 1;
748         }
749     }
750
751     grouping open-message {
752         uses message;
753
754         container open-message {
755             description "Open Message";
756             reference "https://tools.ietf.org/html/rfc5440#section-6.2";
757
758             uses message-header;
759
760             uses open-object;
761         }
762     }
763
764     grouping keepalive-message {
765         uses message;
766
767         container keepalive-message {
768             description "Keepalive Message";
769             reference "https://tools.ietf.org/html/rfc5440#section-6.3";
770
771             uses message-header;
772         }
773     }
774
775     grouping lsp-attributes {
776         uses lspa-object;
777
778         uses bandwidth-object;
779
780         list metrics {
781             uses metric-object;
782         }
783         uses include-route-object;
784
785         uses reported-route-object;
786
787         uses exclude-route-object;
788
789         uses of-object;
790
791         uses classtype-object;
792     }
793
794     grouping pcreq-message {
795         uses message;
796
797         container pcreq-message {
798             description "Path Computation Request Message";
799             reference "https://tools.ietf.org/html/rfc5440#section-6.4";
800
801             uses message-header;
802
803             list requests {
804                 uses rp-object;
805
806                 container path-key-expansion {
807                     when "rp/path-key = true";
808                     uses path-key-object;
809                 }
810
811                 container segment-computation {
812                     when "rp/path-key = false";
813
814                     container p2p {
815                         when "../rp/p2mp = false";
816
817                         uses endpoints-object;
818
819                         container reported-route {
820                             uses reported-route-object;
821
822                             uses bandwidth-object;
823                         }
824
825                         uses load-balancing-object;
826
827                         uses lsp-attributes;
828                     }
829                 }
830             }
831
832             list svec {
833                 uses svec-object;
834
835                 uses of-object;
836
837                 uses gc-object;
838
839                 uses exclude-route-object;
840
841                 list metric {
842                     uses metric-object;
843                 }
844             }
845         }
846     }
847
848     grouping path-definition {
849         uses explicit-route-object;
850
851         uses lsp-attributes;
852     }
853
854     grouping pcrep-message {
855         uses message;
856
857         container pcrep-message {
858             description "Path Computation Reply Message";
859             reference "https://tools.ietf.org/html/rfc5440#section-6.5";
860
861             uses message-header;
862
863             list replies {
864                 uses rp-object;
865
866                 choice result {
867                     case success-case {
868                         container success {
869                             list paths {
870                                 uses path-definition;
871                             }
872                         }
873                     }
874                     case failure-case {
875                         container no-path {
876                             uses no-path-object;
877                             container "tlvs" {
878                                 container no-path-vector {
879                                     uses no-path-vector-tlv;
880                                 }
881                             }
882                         }
883                         uses lsp-attributes;
884                     }
885                 }
886             }
887         }
888     }
889
890     grouping pcntf-message {
891         uses message;
892
893         container pcntf-message {
894             description "Notification Message";
895             reference "https://tools.ietf.org/html/rfc5440#section-6.6";
896
897             uses message-header;
898
899             list notifications {
900                 list rps {
901                     uses rp-object;
902                 }
903
904                 list notifications {
905                     uses notification-object;
906                 }
907             }
908         }
909     }
910
911     grouping pcerr-message {
912         uses message;
913
914         container pcerr-message {
915             description "Error Message";
916             reference "https://tools.ietf.org/html/rfc5440#section-6.7";
917
918             uses message-header;
919
920             list errors {
921                 uses pcep-error-object;
922             }
923
924             choice error-type {
925                 case request-case {
926                     container request {
927                         list rps {
928                             uses rp-object;
929                         }
930                     }
931                 }
932
933                 case session-case {
934                     container session {
935                         uses open-object;
936                     }
937                 }
938             }
939         }
940     }
941
942     grouping close-message {
943         uses message;
944
945         container c-close-message {
946             description "Close Message";
947             reference "https://tools.ietf.org/html/rfc5440#section-6.8";
948
949             uses message-header;
950
951             uses close-object;
952         }
953     }
954 }