84e78a5839f4090984ad8f6ffc8c3cf46d553161
[openflowjava.git] / openflow-protocol-api / src / main / yang / openflow-protocol.yang
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9  module openflow-protocol {
10     namespace "urn:opendaylight:openflow:protocol";
11     prefix "ofproto";
12
13     import ietf-yang-types {prefix yang;}
14
15     import openflow-types {prefix oft;}
16     import openflow-extensible-match { prefix oxm;}
17     import openflow-instruction { prefix ofinstruction;}
18     import openflow-action {prefix ofaction;}
19
20     revision "2013-07-31" {
21         description "#NOT_PUBLISHED# OpenFlow 1.3 - protocol objects model";
22     }
23
24     // Generic Structures
25         grouping port-grouping {
26             reference "ofp_port";
27             leaf port-no {
28                 type uint32;
29             }
30             leaf hw-addr {
31                 type yang:mac-address;
32             }
33             leaf name {
34                 type string;
35             }
36             leaf config {
37                 description "Bitmap of OFPPC_* flags.";
38                 type oft:port-config;
39             }
40             leaf state {
41                 description "Bitmap of OFPPS_* flags.";
42                 type oft:port-state;
43             }
44             leaf current-features {
45                 description "Current features.";
46                 type oft:port-features;
47             }
48             leaf advertised-features {
49                 description "Features being advertised by the port.";
50                 type oft:port-features;
51             }
52             leaf supported-features {
53                 description "Features supported by the port.";
54                 type oft:port-features;
55             }
56             leaf peer-features {
57                 description "Features advertised by peer.";
58                 type oft:port-features;
59             }
60             leaf curr-speed {
61                 description "Current port bitrate in kbps.";
62                 type uint32;
63                 units "kbps";
64             }
65             leaf max-speed {
66                 description "Max port bitrate in kbps";
67                 type uint32;
68                 units "kbps";
69             }
70
71             // OF1.0 structures
72             leaf config-v10 {
73                 type oft:port-config-v10;
74             }
75             leaf state-v10 {
76                 type oft:port-state-v10;
77             }
78             leaf current-features-v10 {
79                 description "Current features.";
80                 type oft:port-features-v10;
81             }
82             leaf advertised-features-v10 {
83                 description "Features being advertised by the port.";
84                 type oft:port-features-v10;
85             }
86             leaf supported-features-v10 {
87                 description "Features supported by the port.";
88                 type oft:port-features-v10;
89             }
90             leaf peer-features-v10 {
91                 description "Features advertised by peer.";
92                 type oft:port-features-v10;
93             }
94         }
95
96         grouping buckets-grouping {
97                 list buckets-list {
98                     uses bucket-grouping;
99                 }
100             }
101
102             grouping bucket-grouping {
103                 description "Bucket for use in groups.";
104                 leaf weight {
105                     description "Relative weight of bucket. Only
106                                 defined for select groups.";
107                     type uint16;
108                 }
109                 leaf watch-port {
110                     description "Port whose state affects whether this
111                                 bucket is live. Only required for fast
112                                 failover groups.";
113                     type oft:port-number;
114                 }
115                 leaf watch-group {
116                     description "Group whose state affects whether this
117                                 bucket is live. Only required for fast
118                                 failover groups.";
119                     type uint32;
120                 }
121
122                 uses ofaction:actions-grouping;
123             }
124
125         container table-features-properties-container {
126             uses table-features-properties-grouping;
127         }
128
129         grouping table-features-properties-grouping {
130             list table-feature-properties {
131                 config false;
132                 leaf type {
133                     type oft:table-features-prop-type;
134                 }
135             }
136         }
137
138     // # MESSAGE Structures
139         /* Immutable messages. */
140             grouping ofHeader {
141                 reference "ofp_header struct in Openflow Switch 1.3 Spec";
142                 leaf version {
143                     type uint8;
144                     description "OpenFlow version";
145                 }
146                 leaf xid {
147                     type uint32;
148                     description "Transaction ID";
149                 }
150             }
151             grouping ofHelloElementHeader {
152                 reference "ofpt_hello_elem_header struct in Openflow Switch 1.3 Spec";
153                 leaf type {
154                     type oft:hello-element-type;
155                     //reference "OpenFlow Header element type - OFPHET_*";
156                 }
157             }
158             grouping hello {
159                 reference "OFPT_HELLO message in Openflow Switch 1.3 Spec";
160                 /* Symmetric message */
161                 uses ofHeader;
162
163                 list elements {
164                     uses ofHelloElementHeader;
165
166                     leaf-list version-bitmap {
167                         type boolean;
168                     }
169                 }
170             }
171             grouping error {
172                 reference "OFPT_ERROR message in Openflow Switch 1.3 Spec";
173                 /* Symmetric message */
174                 uses ofHeader;
175
176                 leaf type {
177                     type uint16;
178                 }
179                 leaf code {
180                     type uint16;
181                 }
182                 leaf type-string {
183                     type string;
184                 }
185                 leaf code-string {
186                     type string;
187                 }
188                 leaf data {
189                     type binary;
190                 }
191             }
192             grouping echo-request {
193                 reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec";
194                 /* Symmetric message */
195                 uses ofHeader;
196
197                 leaf data {
198                     type binary;
199                 }
200             }
201             grouping echo-reply {
202                 reference "OFPT_ECHO_REPLY message in Openflow Switch 1.3 Spec";
203                 /* Symmetric message */
204                 uses ofHeader;
205
206                 leaf data {
207                     type binary;
208                 }
209             }
210             grouping experimenter {
211                 reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec";
212                 /* Symmetric message */
213                 uses ofHeader;
214
215                 leaf experimenter {
216                     type oft:experimenter-id;
217                 }
218                 leaf exp_type {
219                     type uint32;
220                 }
221             }
222  
223             grouping experimenter-core {
224                 description "General experimenter message content suitable for symmetric and multipart message";
225                 leaf experimenter {
226                     type oft:experimenter-id;
227                 }
228                 leaf exp_type {
229                     type uint32;
230                 }
231                 choice experimenter-data-of-choice {
232                     // to be augmented by vendors
233                 }
234              }
235             grouping experimenter-of-message {
236                 reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec";
237                 /* Symmetric message */
238                 uses ofHeader;
239                 uses experimenter-core;
240             }
241
242         /* Switch configuration messages. */
243             grouping features-request {
244                 reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec";
245                 /* Controller/switch message */
246                 uses ofHeader;
247             }
248             grouping features-reply {
249                 reference "OFPT_FEATURES_REPLY message in Openflow Switch 1.3 Spec";
250                 /* Controller/switch message */
251                 uses ofHeader;
252
253                 leaf datapathId {
254                     type uint64;
255                 }
256                 leaf buffers {
257                     type uint32;
258                 }
259                 leaf tables {
260                     type uint8;
261                 }
262                 leaf auxiliaryId {
263                     type uint8;
264                 }
265                 leaf capabilities {
266                     type oft:capabilities;
267                 }
268                 leaf reserved {
269                     type uint32;
270                 }
271                 // OF1.0 structures
272                 leaf capabilities-v10 {
273                     type oft:capabilities-v10;
274                 }
275                 leaf actions-v10 {
276                     type oft:action-type-v10;
277                 }
278                 list phy-port {
279                     uses port-grouping;
280                 }
281             }
282             grouping get-config-request {
283                 reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec";
284                 /* Controller/switch message */
285                 uses ofHeader;
286             }
287             grouping get-config-reply {
288                 reference "OFPT_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec";
289                 /* Controller/switch message */
290                 uses ofHeader;
291
292                 leaf flags {
293                     type oft:switch-config-flag;
294                 }
295                 leaf miss-send-len {
296                     type uint16;
297                 }
298             }
299             grouping set-config {
300                 reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec";
301                 /* Controller/switch message */
302
303                 uses ofHeader;
304
305                 leaf flags {
306                     type oft:switch-config-flag;
307                 }
308                 leaf miss-send-len {
309                     type uint16;
310                 }
311             }
312         /* Asynchronous messages. */
313             grouping packet-in {
314                 reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec";
315                 /* Async message */
316
317                 uses ofHeader;
318
319                 leaf buffer-id {
320                     // ID assigned by datapath.
321                     type uint32;
322                 }
323                 leaf total-len {
324                     // Full length of frame.
325                     type uint16;
326                 }
327                 leaf reason {
328                     // Reason packet is being sent (one of OFPR_*)
329                     type oft:packet-in-reason;
330                 }
331                 leaf table-id {
332                     // ID of the table that was looked up
333                     type oft:table-id;
334                 }
335                 leaf cookie {
336                     // Cookie of the flow entry that was looked up.
337                     type uint64;
338                 }
339                 uses oxm:match-grouping;
340
341                 leaf data {
342                     type binary;
343                 }
344
345                 // OF1.0 structures
346                 leaf in-port {
347                     type uint16;
348                 }
349             }
350             grouping flow-removed {
351                 reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec";
352                 /* Async message */
353                 uses ofHeader;
354
355                 leaf cookie {
356                     type uint64;
357                 }
358                 leaf priority {
359                     type uint16;
360                 }
361                 leaf reason {
362                     type oft:flow-removed-reason;
363                 }
364                 leaf table-id {
365                     type oft:table-id;
366                 }
367                 leaf duration-sec {
368                     type uint32;
369                 }
370                 leaf duration-nsec {
371                     type uint32;
372                 }
373                 leaf idle-timeout {
374                     type uint16;
375                 }
376                 leaf hard-timeout {
377                     type uint16;
378                 }
379                 leaf packet-count {
380                     type uint64;
381                 }
382                 leaf byte-count {
383                     type uint64;
384                 }
385                 uses oxm:match-grouping;
386
387                 // OF1.0 structures
388                 uses oxm:match-v10-grouping;
389             }
390             grouping port-status {
391                 reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec";
392
393                 uses ofHeader;
394
395                 uses port-grouping;
396
397                 leaf reason {
398                     type oft:port-reason;
399                 }
400             }
401         /* Controller command messages. */
402             grouping packet-out {
403                 reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec";
404                 /* Controller/switch message */
405
406                 uses ofHeader;
407
408                 uses ofaction:actions-grouping;
409                 leaf data {
410                     type binary;
411                 }
412                 leaf buffer-id {
413                     type uint32;
414                 }
415                 leaf in-port {
416                     type oft:port-number;
417                 }
418             }
419             grouping flow-mod {
420                 reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec";
421                 /* Controller/switch message */
422
423                 uses ofHeader;
424
425                 leaf cookie {
426                     type uint64;
427                 }
428                 leaf cookie-mask {
429                     type uint64;
430                 }
431                 leaf table-id {
432                     type oft:table-id;
433                 }
434                 leaf command {
435                     type oft:flow-mod-command;
436                 }
437                 leaf idle-timeout {
438                     type uint16;
439                 }
440                 leaf hard-timeout {
441                     type uint16;
442                 }
443                 leaf priority {
444                     type uint16;
445                 }
446                 leaf buffer-id {
447                     type uint32;
448                 }
449                 leaf out-port {
450                     type oft:port-number;
451                 }
452                 leaf out-group {
453                     type uint32;
454                 }
455                 leaf flags {
456                     type oft:flow-mod-flags;
457                 }
458                 uses oxm:match-grouping;
459
460                 uses ofinstruction:instructions-grouping;
461
462                 // OF1.0 structures
463                 leaf flags-v10 {
464                     type oft:flow-mod-flags-v10;
465                 }
466                 uses oxm:match-v10-grouping;
467                 uses ofaction:actions-grouping;
468             }
469             grouping group-mod {
470                 reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec";
471                 /* Controller/switch message */
472
473                 uses ofHeader;
474
475                 leaf command {
476                     type oft:group-mod-command;
477                 }
478                 leaf type {
479                     type oft:group-type;
480                 }
481                 leaf group-id {
482                     type oft:group-id;
483                 }
484
485                 uses buckets-grouping;
486             }
487
488             grouping port-mod {
489                 reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec";
490                 /* Controller/switch message */
491
492                 uses ofHeader;
493
494                 leaf port-no {
495                     type oft:port-number;
496                 }
497                 leaf hw-address {
498                     type yang:mac-address;
499                 }
500                 leaf config {
501                     type oft:port-config;
502                 }
503                 leaf mask {
504                     type oft:port-config;
505                 }
506                 leaf advertise {
507                     type oft:port-features;
508                 }
509                 // OF1.0 structures
510                 leaf config-v10 {
511                     type oft:port-config-v10;
512                 }
513                 leaf mask-v10 {
514                     type oft:port-config-v10;
515                 }
516                 leaf advertise-v10 {
517                     type oft:port-features-v10;
518                 }
519             }
520             grouping table-mod {
521                 reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec";
522                 /* Controller/switch message */
523
524                 uses ofHeader;
525
526                 leaf table-id {
527                     type oft:table-id;
528                 }
529                 leaf config {
530                     type oft:table-config;
531                 }
532             }
533
534         /* Multipart messages. */
535             grouping multipart-request {
536                 reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec";
537                 /* Controller/switch message */
538
539                 uses ofHeader;
540
541                 leaf type {
542                     type oft:multipart-type;
543                 }
544                 leaf flags {
545                     type oft:multipart-request-flags;
546                 }
547                 choice multipart-request-body {
548                     case multipart-request-desc-case {
549                         container multipart-request-desc {
550                             leaf empty {
551                                 type empty;
552                             }
553                         }
554                     }
555                     case multipart-request-flow-case {
556                         container multipart-request-flow {
557                             leaf table-id {
558                                 type uint8;
559                             }
560                             leaf out-port {
561                                 type uint32;
562                             }
563                             leaf out-group {
564                                 type uint32;
565                             }
566                             leaf cookie {
567                                 type uint64;
568                             }
569                             leaf cookie-mask {
570                                 type uint64;
571                             }
572                             uses oxm:match-grouping;
573
574                             // OF1.0 structures
575                             uses oxm:match-v10-grouping;
576                         }
577                     }
578                     case multipart-request-aggregate-case {
579                         container multipart-request-aggregate {
580                             leaf table-id {
581                                 type uint8;
582                             }
583                             leaf out-port {
584                                 type uint32;
585                             }
586                             leaf out-group {
587                                 type uint32;
588                             }
589                             leaf cookie {
590                                 type uint64;
591                             }
592                             leaf cookie-mask {
593                                 type uint64;
594                             }
595                             uses oxm:match-grouping;
596
597                             // OF1.0 structures
598                             uses oxm:match-v10-grouping;
599                         }
600                     }
601                     case multipart-request-table-case {
602                         container multipart-request-table {
603                             leaf empty {
604                                 type empty;
605                             }
606                         }
607                     }
608                     case multipart-request-port-stats-case {
609                         container multipart-request-port-stats {
610                             leaf port-no {
611                                 type uint32;
612                             }
613                         }
614                     }
615                     case multipart-request-queue-case {
616                         container multipart-request-queue {
617                             leaf port-no {
618                                 type uint32;
619                             }
620                             leaf queue-id {
621                                 type uint32;
622                             }
623                         }
624                     }
625                     case multipart-request-group-case {
626                         container multipart-request-group {
627                             leaf group-id {
628                                 type oft:group-id;
629                             }
630                         }
631                     }
632                     case multipart-request-group-desc-case {
633                         container multipart-request-group-desc {
634                             leaf empty {
635                                 type empty;
636                             }
637                         }
638                     }
639                     case multipart-request-group-features-case {
640                         container multipart-request-group-features {
641                             leaf empty {
642                                 type empty;
643                             }
644                         }
645                     }
646                     case multipart-request-meter-case {
647                         container multipart-request-meter {
648                             leaf meter-id {
649                                 type oft:meter-id;
650                             }
651                         }
652                     }
653                     case multipart-request-meter-config-case {
654                         container multipart-request-meter-config {
655                             leaf meter-id {
656                                 type oft:meter-id;
657                             }
658                         }
659                     }
660                     case multipart-request-meter-features-case {
661                         container multipart-request-meter-features {
662                             leaf empty {
663                                 type empty;
664                             }
665                         }
666                     }
667                     case multipart-request-table-features-case {
668                         container multipart-request-table-features {
669                             list table-features {
670                                 leaf table-id {
671                                     type uint8;
672                                 }
673                                 leaf name {
674                                     type string;
675                                 }
676                                 leaf metadata-match {
677                                     type uint64;
678                                 }
679                                 leaf metadata-write {
680                                     type uint64;
681                                 }
682                                 leaf config {
683                                     type oft:table-config;
684                                 }
685                                 leaf max-entries {
686                                     type uint32;
687                                 }
688                                 uses table-features-properties-grouping;
689                             }
690                         }
691                     }
692                     case multipart-request-port-desc-case {
693                         container multipart-request-port-desc {
694                             leaf empty {
695                                 type empty;
696                             }
697                         }
698                     }
699                     case multipart-request-experimenter-case {
700                         container multipart-request-experimenter {
701                             uses experimenter-core;
702                         }
703                     }
704                 }
705             }
706             grouping multipart-reply {
707                 reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec";
708                 /* Controller/switch message */
709
710                 uses ofHeader;
711
712                 leaf type {
713                     type oft:multipart-type;
714                 }
715                 leaf flags {
716                     type oft:multipart-request-flags;
717                 }
718                 choice multipart-reply-body {
719                     case multipart-reply-desc-case {
720                         container multipart-reply-desc {
721                             leaf mfr_desc {
722                                 type string;
723                             }
724                             leaf hw_desc {
725                                 type string;
726                             }
727                             leaf sw_desc {
728                                 type string;
729                             }
730                             leaf serial_num {
731                                 type string;
732                             }
733                             leaf dp_desc {
734                                 type string;
735                             }
736                         }
737                     }
738                     case multipart-reply-flow-case {
739                         container multipart-reply-flow {
740                             list flow-stats {
741                                 leaf table-id {
742                                     type uint8;
743                                 }
744                                 leaf duration-sec {
745                                     type uint32;
746                                 }
747                                 leaf duration-nsec {
748                                     type uint32;
749                                 }
750                                 leaf priority {
751                                     type uint16;
752                                 }
753                                 leaf idle-timeout {
754                                     type uint16;
755                                 }
756                                 leaf hard-timeout {
757                                     type uint16;
758                                 }
759                                 leaf flags {
760                                     type oft:flow-mod-flags;
761                                 }
762                                 leaf cookie {
763                                     type uint64;
764                                 }
765                                 leaf packet-count {
766                                     type uint64;
767                                 }
768                                 leaf byte-count {
769                                     type uint64;
770                                 }
771                                 uses oxm:match-grouping;
772
773                                 uses ofinstruction:instructions-grouping;
774
775                                 // OF1.0 structures
776                                 uses oxm:match-v10-grouping;
777                                 uses ofaction:actions-grouping;
778                             }
779                         }
780                     }
781                     case multipart-reply-aggregate-case {
782                         container multipart-reply-aggregate {
783                             leaf packet-count {
784                                 type uint64;
785                             }
786                             leaf byte-count {
787                                 type uint64;
788                             }
789                             leaf flow-count {
790                                 type uint32;
791                             }
792                         }
793                     }
794                     case multipart-reply-table-case {
795                         container multipart-reply-table {
796                             list table-stats {
797                                 leaf table-id {
798                                     type uint8;
799                                 }
800                                 leaf active-count {
801                                     type uint32;
802                                 }
803                                 leaf lookup-count {
804                                     type uint64;
805                                 }
806                                 leaf matched-count {
807                                     type uint64;
808                                 }
809
810                                 // OF1.0 structures
811                                 leaf name {
812                                     type string;
813                                 }
814                                 leaf wildcards {
815                                     type oft:flow-wildcards-v10;
816                                 }
817                                 leaf nw-src-mask {
818                                     type uint8;
819                                 }
820                                 leaf nw-dst-mask {
821                                     type uint8;
822                                 }
823                                 leaf max-entries {
824                                     type uint32;
825                                 }
826                             }
827                         }
828                     }
829                     case multipart-reply-port-stats-case {
830                         container multipart-reply-port-stats {
831                             list port-stats {
832                                 leaf port-no {
833                                     type uint32;
834                                 }
835                                 leaf rx-packets {
836                                     type uint64;
837                                 }
838                                 leaf tx-packets {
839                                     type uint64;
840                                 }
841                                 leaf rx-bytes {
842                                     type uint64;
843                                 }
844                                 leaf tx-bytes {
845                                     type uint64;
846                                 }
847                                 leaf rx-dropped {
848                                     type uint64;
849                                 }
850                                 leaf tx-dropped {
851                                     type uint64;
852                                 }
853                                 leaf rx-errors {
854                                     type uint64;
855                                 }
856                                 leaf tx-errors {
857                                     type uint64;
858                                 }
859                                 leaf rx-frame-err {
860                                     type uint64;
861                                 }
862                                 leaf rx-over-err {
863                                     type uint64;
864                                 }
865                                 leaf rx-crc-err {
866                                     type uint64;
867                                 }
868                                 leaf collisions {
869                                     type uint64;
870                                 }
871                                 leaf duration-sec {
872                                     type uint32;
873                                 }
874                                 leaf duration-nsec {
875                                     type uint32;
876                                 }
877                             }
878                         }
879                     }
880                     case multipart-reply-queue-case {
881                         container multipart-reply-queue {
882                             list queue-stats {
883                                 leaf port-no {
884                                     type uint32;
885                                 }
886                                 leaf queue-id {
887                                     type uint32;
888                                 }
889                                 leaf tx-bytes {
890                                     type uint64;
891                                 }
892                                 leaf tx-packets {
893                                     type uint64;
894                                 }
895                                 leaf tx-errors {
896                                     type uint64;
897                                 }
898                                 leaf duration-sec {
899                                     type uint32;
900                                 }
901                                 leaf duration-nsec {
902                                     type uint32;
903                                 }
904                             }
905                         }
906                     }
907                     case multipart-reply-group-case {
908                         container multipart-reply-group {
909                             list group-stats {
910                                 leaf group-id {
911                                     type oft:group-id;
912                                 }
913                                 leaf ref-count {
914                                     type uint32;
915                                 }
916                                 leaf packet-count {
917                                     type uint64;
918                                 }
919                                 leaf byte-count {
920                                     type uint64;
921                                 }
922                                 leaf duration-sec {
923                                     type uint32;
924                                 }
925                                 leaf duration-nsec {
926                                     type uint32;
927                                 }
928                                 list bucket-stats {
929                                     leaf packet-count {
930                                         type uint64;
931                                     }
932                                     leaf byte-count {
933                                         type uint64;
934                                     }
935                                 }
936                             }
937                         }
938                     }
939                     case multipart-reply-group-desc-case {
940                         container multipart-reply-group-desc {
941                             list group-desc {
942                                 leaf type {
943                                     type oft:group-type;
944                                 }
945                                 leaf group-id {
946                                     type oft:group-id;
947                                 }
948                                 uses buckets-grouping;
949                             }
950                         }
951                     }
952                     case multipart-reply-group-features-case {
953                         container multipart-reply-group-features {
954                             leaf types {
955                                 type oft:group-types;
956                             }
957                             leaf capabilities {
958                                 type oft:group-capabilities;
959                             }
960                             leaf-list max_groups {
961                                 type uint32;
962                             }
963                             leaf-list actions-bitmap {
964                                 type oft:action-type;
965                             }
966                         }
967                     }
968                     case multipart-reply-meter-case {
969                         container multipart-reply-meter {
970                             list meter-stats {
971                                 leaf meter-id {
972                                     type oft:meter-id;
973                                 }
974                                 leaf flow-count {
975                                     type uint32;
976                                 }
977                                 leaf packet-in-count {
978                                     type uint64;
979                                 }
980                                 leaf byte-in-count {
981                                     type uint64;
982                                 }
983                                 leaf duration-sec {
984                                     type uint32;
985                                 }
986                                 leaf duration-nsec {
987                                     type uint32;
988                                 }
989                                 list meter-band-stats {
990                                     leaf packet-band-count {
991                                         type uint64;
992                                     }
993                                     leaf byte-band-count {
994                                         type uint64;
995                                     }
996                                 }
997                             }
998                         }
999                     }
1000                     case multipart-reply-meter-config-case {
1001                         container multipart-reply-meter-config {
1002                             list meter-config {
1003                                 leaf flags {
1004                                     type oft:meter-flags;
1005                                 }
1006                                 leaf meter-id {
1007                                     type oft:meter-id;
1008                                 }
1009                                 list bands {
1010                                     uses meter-band-header;
1011                                 }
1012                             }
1013                         }
1014                     }
1015                     case multipart-reply-meter-features-case {
1016                         container multipart-reply-meter-features {
1017                             leaf max-meter {
1018                                 type uint32;
1019                             }
1020                             leaf band-types {
1021                                 type oft:meter-band-type-bitmap;
1022                             }
1023                             leaf capabilities {
1024                                 type oft:meter-flags;
1025                             }
1026                             leaf max-bands {
1027                                 type uint8;
1028                             }
1029                             leaf max-color {
1030                                 type uint8;
1031                             }
1032                         }
1033                     }
1034                     case multipart-reply-table-features-case {
1035                         container multipart-reply-table-features {
1036                             list table-features {
1037                                 leaf table-id {
1038                                     type uint8;
1039                                 }
1040                                 leaf name {
1041                                     type string;
1042                                 }
1043                                 leaf metadata-match {
1044                                     type binary;
1045                                 }
1046                                 leaf metadata-write {
1047                                     type binary;
1048                                 }
1049                                 leaf config {
1050                                     type oft:table-config;
1051                                 }
1052                                 leaf max-entries {
1053                                     type uint32;
1054                                 }
1055                                 uses table-features-properties-grouping;
1056                             }
1057                         }
1058                     }
1059                     case multipart-reply-port-desc-case {
1060                         container multipart-reply-port-desc {
1061                             list ports {
1062                                 uses port-grouping;
1063                             }
1064                         }
1065                     }
1066                     case multipart-reply-experimenter-case {
1067                         container multipart-reply-experimenter {
1068                             // empty body - used for experimenter augmentation
1069                         }
1070                     }
1071                 }
1072             }
1073             /* Barrier messages. */
1074             grouping barrier-request {
1075                 reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec";
1076                 /* Controller/switch message */
1077                 uses ofHeader;
1078             }
1079             grouping barrier-reply {
1080                 reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec";
1081                 /* Controller/switch message */
1082                 uses ofHeader;
1083             }
1084         /* Queue Configuration messages. */
1085             grouping queue-get-config-request {
1086                 reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec";
1087                 /* Controller/switch message */
1088
1089                 uses ofHeader;
1090
1091                 leaf port {
1092                     type oft:port-number;
1093                 }
1094             }
1095             grouping queue-get-config-reply {
1096                 reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec";
1097                 /* Controller/switch message */
1098
1099                 uses ofHeader;
1100
1101                 leaf port {
1102                     type oft:port-number;
1103                 }
1104                 list queues {
1105                     uses packet-queue;
1106                 }
1107             }
1108             grouping packet-queue {
1109                 leaf queue-id {
1110                     type oft:queue-id;
1111                 }
1112                 leaf port {
1113                     type oft:port-number;
1114                 }
1115                 uses queue-property-header;
1116             }
1117             container queue-prop-container {
1118                 uses queue-property-header;
1119             }
1120             grouping queue-property-header {
1121                 list queue-property {
1122                     config false;
1123                     leaf property {
1124                         type oft:queue-properties;
1125                     }
1126                 }
1127             }
1128             /* Controller role change request messages. */
1129             grouping role-request {
1130                 reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec";
1131                 /* Controller/switch message */
1132
1133                 uses ofHeader;
1134
1135                 leaf role {
1136                     type oft:controller-role;
1137                 }
1138                 leaf generation-id {
1139                     type uint64;
1140                 }
1141             }
1142             grouping role-reply {
1143                 reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec";
1144                 /* Controller/switch message */
1145
1146                 uses ofHeader;
1147
1148                 leaf role {
1149                     type oft:controller-role;
1150                 }
1151                 leaf generation-id {
1152                     type uint64;
1153                 }
1154             }
1155             /* Asynchronous message configuration. */
1156             grouping get-async-request {
1157                 reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec";
1158                 /* Controller/switch message */
1159
1160                 uses ofHeader;
1161             }
1162             grouping get-async-reply {
1163                 reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec";
1164                 /* Controller/switch message */
1165
1166                 uses ofHeader;
1167                 uses async-body-grouping;
1168             }
1169             grouping set-async {
1170                 reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec";
1171                 /* Controller/switch message */
1172
1173                 uses ofHeader;
1174                 uses async-body-grouping;
1175             }
1176
1177             grouping async-body-grouping {
1178                 list packet-in-mask {
1179                     leaf-list mask {
1180                         type oft:packet-in-reason;
1181                     }
1182                 }
1183                 list port-status-mask {
1184                     leaf-list mask {
1185                         type oft:port-reason;
1186                     }
1187                 }
1188                 list flow-removed-mask {
1189                     leaf-list mask {
1190                         type oft:flow-removed-reason;
1191                     }
1192                 }
1193             }
1194             /* Meters and rate limiters configuration messages. */
1195             grouping meter-mod {
1196                 reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec";
1197                 /* Controller/switch message */
1198
1199                 uses ofHeader;
1200
1201                 leaf command {
1202                     type oft:meter-mod-command;
1203                 }
1204                 leaf flags {
1205                     type oft:meter-flags;
1206                 }
1207                 leaf meter-id {
1208                     type oft:meter-id;
1209                 }
1210                 list bands {
1211                     uses meter-band-header;
1212                 }
1213             }
1214
1215             container meter-band-container {
1216                 uses meter-band-header;
1217             }
1218             grouping meter-band-header {
1219                 choice meter-band {
1220                     case meter-band-drop-case {
1221                         container meter-band-drop {
1222                             uses meter-band-commons;
1223                         }
1224                     }
1225                     case meter-band-dscp-remark-case {
1226                         container meter-band-dscp-remark {
1227                             uses meter-band-commons;
1228                             leaf prec-level {
1229                                 type uint8;
1230                             }
1231                         }
1232                     }
1233                     case meter-band-experimenter-case {
1234                         container meter-band-experimenter {
1235                             uses meter-band-commons;
1236                         }
1237                     }
1238                 }
1239             }
1240
1241             grouping meter-band-commons {
1242                 leaf type {
1243                     type oft:meter-band-type;
1244                 }
1245                 leaf rate {
1246                     type uint32;
1247                 }
1248                 leaf burst-size {
1249                     type uint32;
1250                 }
1251             }
1252
1253             /* Immutable messages. */
1254             notification hello-message {
1255                 uses hello;
1256                 reference "OFPT_HELLO message in Openflow Switch 1.3 Spec";
1257
1258                 /* Symmetric message */
1259             }
1260             notification error-message {
1261                 uses error;
1262                 reference "OFPT_ERROR message in Openflow Switch 1.3 Spec";
1263
1264                 /* Symmetric message */
1265             }
1266             notification echo-request-message {
1267                 uses echo-request;
1268                 reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec";
1269
1270                 /* Symmetric message */
1271             }
1272             notification experimenter-message {
1273                 uses experimenter;
1274                 reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec";
1275                 // TODO:: does switch send this when understood experimenter msg from lib?
1276                 /* Symmetric message */
1277             }
1278     // # Notification and RPCs
1279         /* Symmetric RPC. */
1280             rpc echo {
1281                 input {
1282                     uses echo-request;
1283                 }
1284                 /* Controller/switch message */
1285                 output {
1286                     uses echo-reply;
1287                 }
1288             }
1289
1290             rpc echo-reply {
1291                 input {
1292                     uses echo-reply;
1293                 }
1294             }
1295
1296             rpc hello {
1297                 input {
1298                     uses hello;
1299                 }
1300             }
1301
1302             rpc experimenter {
1303                 description "Send experimenter message to device, reply is not solicitated.";
1304                 input {
1305                     uses experimenter-of-message;
1306                 }
1307             }
1308
1309         /* Switch configuration messages. */
1310             rpc get-features {
1311                 input {
1312                     uses features-request;
1313                 }
1314                 /* Controller/switch message */
1315                 output {
1316                     uses features-reply;
1317                 }
1318             }
1319
1320             rpc get-config {
1321                 input {
1322                     uses get-config-request;
1323                 }
1324                 output {
1325                     uses get-config-reply;
1326                 }
1327                 /* Controller/switch message */
1328             }
1329
1330             rpc set-config {
1331                 input {
1332                     uses set-config;
1333                 }
1334                 /* Controller/switch message */
1335             }
1336         /* Asynchronous messages. */
1337             notification packet-in-message {
1338                 uses packet-in;
1339
1340              /* Async message */
1341             }
1342             notification flow-removed-message {
1343                 uses flow-removed;
1344
1345                 /* Async message */
1346             }
1347             notification port-status-message {
1348                 uses port-status;
1349
1350             } /* Async message */
1351
1352         /* Controller command messages. */
1353             rpc packet-out {
1354                 input {
1355                     uses packet-out;
1356                 }
1357                 /* Controller/switch message */
1358             }
1359             rpc flow-mod {
1360                 input {
1361                     uses flow-mod;
1362                 }
1363                 /* Controller/switch message */
1364             }
1365             rpc group-mod {
1366                 input {
1367                     uses group-mod;
1368                 }
1369                 /* Controller/switch message */
1370             }
1371             rpc port-mod {
1372                 input {
1373                     uses port-mod;
1374                 }
1375             } /* Controller/switch message */
1376
1377             rpc table-mod {
1378                 input {
1379                     uses table-mod;
1380                 }
1381             } /* Controller/switch message */
1382
1383         /* Multipart messages. */
1384
1385             rpc multipart-request {
1386                 input {
1387                     uses multipart-request;
1388                 }
1389             }
1390
1391              /* Controller/switch message */
1392             notification multipart-reply-message {
1393                 uses multipart-reply;
1394                 // notification because of multiple following responses
1395             } /* Controller/switch message */
1396
1397
1398             /* Barrier messages. */
1399             rpc barrier {
1400                 input {
1401                     uses barrier-request;
1402                 }
1403                 output {
1404                     uses barrier-reply;
1405                 }
1406             }
1407         /* Queue Configuration messages. */
1408             rpc get-queue-config {
1409                 input {
1410                     uses queue-get-config-request;
1411                 }
1412                 output {
1413                     uses queue-get-config-reply;
1414                 }
1415             }
1416
1417         /* Controller role change request messages. */
1418             rpc role-request {
1419                 input {
1420                     uses role-request;
1421                 }
1422                 output {
1423                     uses role-reply;
1424                 }
1425             } /* Controller/switch message */
1426
1427         /* Asynchronous message configuration. */
1428             rpc get-async {
1429                 input {
1430                     uses get-async-request;
1431                 }
1432                 output {
1433                     uses get-async-reply;
1434                 }
1435             }
1436              /* Controller/switch message */
1437             rpc set-async {
1438                 input {
1439                     uses set-async;
1440                 }
1441
1442             }
1443         /* Meters and rate limiters configuration messages. */
1444             rpc meter-mod {
1445                 input {
1446                     uses meter-mod;
1447                 }
1448             } /* Controller/switch message */
1449 }