Merge "Added more (de)serialization factories + ByteBufUtils methods"
[openflowjava.git] / openflow-protocol-api / src / main / yang / openflow-protocol.yang
1 module openflow-protocol {
2     namespace "urn:opendaylight:openflow:protocol";
3     prefix "ofproto";
4
5
6     import ietf-inet-types {prefix inet;}
7     import ietf-yang-types {prefix yang;}
8     
9     import openflow-types {prefix oft;}
10     import openflow-extensible-match { prefix oxm;}
11     import openflow-instruction { prefix ofinstruction;}
12     import openflow-action {prefix ofaction;}
13
14
15
16     revision "2013-07-31" {
17         description "Initial model";
18     }
19
20     // Generic Structures
21
22         grouping port {
23             // reference "ofp_port";
24             leaf port-no { 
25                 // reference "ofp_port.port_no"; 
26                 type uint32;
27             }
28             leaf hw-addr { 
29                 // reference "ofp_port.hw_addr"; 
30                 type yang:mac-address;
31             }
32             leaf name { 
33                 // reference "ofp_port.name"; 
34                 type string;
35             }
36             leaf config { 
37                 // reference "ofp_port.config"; 
38                 type oft:port-config;
39             }
40             leaf state { 
41                 // reference "ofp_port.state"; 
42                 type oft:port-state;
43             }
44             leaf current-features { 
45                 description "Current features.";
46                 // reference "ofp_port.curr"; 
47                 type oft:port-features; 
48             }
49             leaf advertised-features { 
50                 description "Features being advertised by the port.";
51                 // reference "ofp_port.advertised"; 
52                 type oft:port-features; 
53             }
54             leaf supported-features { 
55                 description "Features supported by the port.";
56                 // reference "ofp_port.supported"; 
57                 type oft:port-features; 
58             }
59             leaf peer-features { 
60                 description "Features advertised by peer.";
61                 // reference "ofp_port.peer"; 
62                 type oft:port-features; 
63             }
64             leaf curr_speed { 
65                 description "Current port bitrate in kbps.";
66                 // reference "ofp_port.curr_speed"; 
67                 type uint32; 
68                 units "kbps";
69             }
70             leaf max_speed { 
71                 description "Max port bitrate in kbps";
72                 // reference "ofp_port.max_speed"; 
73                 type uint32;
74                 units "kbps"; 
75             }
76         }
77
78     // TODO: ofp_packat_queue
79
80     // # MESSAGE Structures
81         /* Immutable messages. */
82             grouping ofHeader {
83                 //reference "ofpt_header struct in Openflow Switch 1.3 Spec"
84                 leaf version {
85                     type uint8;
86                     //reference "OpenFlow Header - OFP_VERSION";
87                 }
88                 leaf xid {
89                     type uint32;
90                     //reference "OpenFlow Header - transaction id";
91                 }
92             }
93             grouping ofHelloElementHeader {
94                 //reference "ofpt_hello_elem_header struct in Openflow Switch 1.3 Spec"
95                 leaf type {
96                     type oft:hello-element-type;
97                     //reference "OpenFlow Header element type - OFPHET_*";
98                 }
99                 leaf length {
100                     type uint16;
101                     //reference "OpenFlow Header element length";
102                 }
103             }
104             grouping hello {
105                 // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"
106                 /* Symmetric message */
107                 uses ofHeader;
108                 
109                 list elements {
110                     uses ofHelloElementHeader;
111                     
112                     leaf data {
113                         type binary;
114                     }
115                 }
116             }
117             grouping error {
118                 // reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"
119                 /* Symmetric message */
120                 uses ofHeader;
121                 
122                 leaf type {
123                     type oft:error-type;
124                 }
125                 leaf code {
126                     type uint16;
127                 }
128                 leaf data {
129                     type binary; 
130                 }
131             }
132             grouping echo-request {
133                 // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
134                 /* Symmetric message */
135                 uses ofHeader;
136                 
137                 leaf data {
138                     type binary;
139                 }
140             }
141             grouping echo-reply {
142                 // reference "OFPT_ECHO_REPLY message in Openflow Switch 1.3 Spec"
143                 /* Symmetric message */
144                 uses ofHeader;
145                 
146                 leaf data {
147                     type binary;
148                 }
149             }
150             grouping experimenter {
151                 // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"
152                 /* Symmetric message */
153                 uses ofHeader;
154                 
155                 leaf experimenter {
156                     type uint32;
157                 }
158                 leaf exp_type {
159                     type uint32;
160                 }
161             }
162         /* Switch configuration messages. */
163             grouping features-request {
164                 // reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"
165                 /* Controller/switch message */
166                 uses ofHeader;
167             }
168             grouping features-reply {
169                 // reference "OFPT_FEATURES_REPLY message in Openflow Switch 1.3 Spec"
170                 /* Controller/switch message */
171                 uses ofHeader;
172                 
173                 leaf datapathId {
174                     type uint64;
175                 }
176                 leaf buffers {
177                     type uint32;
178                 }
179                 leaf tables {
180                     type uint8;
181                 }
182                 leaf auxiliaryId {
183                     type uint8;
184                 }
185                 leaf capabilities {
186                     type uint32;
187                 }
188                 leaf reserved {
189                     type uint32;
190                 }
191             }
192             grouping get-config-request {
193                 // reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
194                 /* Controller/switch message */
195                 uses ofHeader;
196             }
197             grouping get-config-reply {
198                 // reference "OFPT_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"
199                 /* Controller/switch message */
200                 uses ofHeader;
201                 
202                 leaf flags {
203                     type oft:switch-config-flag;
204                 }
205                 leaf miss-send-len {
206                     type uint16;
207                 }
208             }
209             grouping set-config {
210                 // reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"
211                 /* Controller/switch message */
212                 
213                 uses ofHeader;
214                 
215                 leaf flags {
216                     type oft:switch-config-flag;
217                 }
218                 leaf miss-send-len {
219                     type uint16;
220                 }
221             }
222         /* Asynchronous messages. */
223             grouping packet-in {
224                 // reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"
225                 /* Async message */
226                 
227                 uses ofHeader;
228                 
229                 leaf buffer-id {
230                     // ID assigned by datapath.
231                     type uint32;
232                 }  
233                 leaf total-len {
234                     // Full length of frame.
235                     type uint16;
236                 }
237                 leaf reason {
238                     // Reason packet is being sent (one of OFPR_*) 
239                     type uint8;
240                 }
241                 leaf table-id {
242                     // ID of the table that was looked up
243                     type oft:table-id;
244                 }
245                 leaf cookie {
246                     // Cookie of the flow entry that was looked up.
247                     type uint64;
248                 }
249                 
250                 //TODO:: add match leaf
251                 // leaf match {
252                 //     type oft:match
253                 // }
254
255 // struct ofp_match match; /* Packet metadata. Variable size. */
256 // /* The variable size and padded match is always followed by:
257 //  *   - Exactly 2 all-zero padding bytes, then
258 //  *   - An Ethernet frame whose length is inferred from header.length.
259 //  * The padding bytes preceding the Ethernet frame ensure that the IP
260 //  * header (if any) following the Ethernet header is 32-bit aligned.
261 //  */
262                 leaf data {
263                     type binary;
264                 }
265                 
266             }
267             grouping flow-removed {
268                 // reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"
269                 /* Async message */
270                 uses ofHeader;
271                 
272                 leaf cookie {
273                     type uint64;
274                 }
275                 leaf priority {
276                     type uint16;
277                 }
278                 leaf reason {
279                     type oft:flow-removed-reason;
280                 }
281                 leaf table-id {
282                     type oft:table-id;
283                 }
284                 leaf duration-sec {
285                     type uint32;
286                 }
287                 leaf duration-nsec {
288                     type uint32;
289                 }
290                 leaf idle-timeout {
291                     type uint16;
292                 }
293                 leaf hard-timeout {
294                     type uint16;
295                 }
296                 leaf packet-count {
297                     type uint64;
298                 }
299                 leaf byte-count {
300                     type uint64;
301                 }
302                 //TODO:: add match leaf
303                 //leaf match {
304                 //    type oft:match;
305                 //}
306             } 
307             grouping port-status {
308                 // reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"
309                 
310                 uses ofHeader;
311                 
312                 uses port;
313                 
314                 leaf reason {
315                     type oft:port-reason;
316                 }
317             } /* Async message */
318         /* Controller command messages. */
319             grouping packet-out {
320                 // reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"
321                 /* Controller/switch message */
322                 
323                 uses ofHeader;
324                 
325                 list actions {
326                     uses ofaction:action-header;
327                     
328                     leaf data {
329                         type binary;
330                     }
331                 }
332                 
333                 leaf buffer-id {
334                     type uint32;
335                 }
336                 leaf in-port {
337                     type oft:port-number;
338                 }
339             } 
340             grouping flow-mod {
341                 // reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"
342                 /* Controller/switch message */
343                 
344                 uses ofHeader;
345                 
346                 leaf cookie {
347                     type uint64;
348                 }
349                 leaf cookie-mask {
350                     type uint64;
351                 }
352                 leaf table-id {
353                     type oft:table-id;
354                 }
355                 leaf command {
356                     type oft:flow-mod-command;
357                 }
358                 leaf idle-timeout {
359                     type uint16;
360                 }
361                 leaf hard-timeout {
362                     type uint16;
363                 }
364                 leaf priority {
365                     type uint16;
366                 }
367                 leaf buffer-id {
368                     type uint32;
369                 }
370                 leaf out-port {
371                     type oft:port-number;
372                 }
373                 leaf out-group {
374                     type uint32;
375                 }
376                 leaf flags {
377                     type uint16;
378                 }
379                 //TODO:: add match leaf
380             } 
381             grouping group-mod {
382                 // reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"
383                 /* Controller/switch message */
384                 
385                 uses ofHeader;
386                 
387                 leaf command {
388                     type oft:group-mod-command;
389                 }
390                 leaf type {
391                     type oft:group-type;
392                 }
393                 leaf group-id {
394                     type uint32;
395                 }
396                 
397                 list buckets {
398                     uses bucket;
399                 }
400             }
401             grouping bucket {
402                 leaf weight {
403                     type uint16;
404                 }
405                 leaf watch-port {
406                     type oft:port-number;
407                 }
408                 leaf watch-group {
409                     type uint32;
410                 }
411                 
412                 list actions {
413                     uses ofaction:action-header;
414                 }
415             }
416             grouping port-mod {
417                 // reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"
418                 /* Controller/switch message */
419
420                 uses ofHeader;
421                 
422                 leaf port-no {
423                     type oft:port-number;
424                 }
425                 leaf hw-address {
426                     type yang:mac-address;
427                 }       
428                 leaf config {
429                     type oft:port-config;
430                 }   
431                 leaf mask {
432                     type oft:port-config;
433                 }  
434                 leaf advertise {
435                     type oft:port-config;
436                 }
437             } 
438             grouping table-mod {
439                 // reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"
440                 /* Controller/switch message */
441
442                 uses ofHeader;
443                 
444                 leaf table-id {
445                     type oft:table-id;
446                 }
447                 leaf config {
448                     type oft:port-config;
449                 }                
450             } 
451             
452         /* Multipart messages. */
453             grouping multipart-request {
454                 // reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"
455                 /* Controller/switch message */
456
457                 uses ofHeader;
458                 
459                 leaf type {
460                     type oft:multipart-type;
461                 }          
462                 leaf flags {
463                     type oft:multipart-request-flags;
464                 }      
465                 leaf body {
466                     type binary;
467                 }
468             } 
469             grouping multipart-reply {
470                 // reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"
471                 /* Controller/switch message */
472
473                 uses ofHeader;
474                 
475                 leaf type {
476                     type oft:multipart-type;
477                 }
478                 leaf flags {
479                     type oft:multipart-request-flags;
480                 }
481                 leaf body {
482                     type binary;
483                 }
484             } 
485             /* Barrier messages. */
486             grouping barrier-request {
487                 // reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"
488                 /* Controller/switch message */
489                 uses ofHeader;
490             } 
491             grouping barrier-reply {
492                 // reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"
493                 /* Controller/switch message */
494                 uses ofHeader;
495             } 
496         /* Queue Configuration messages. */
497             grouping queue-get-config-request {
498                 // reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
499                 /* Controller/switch message */
500                 
501                 uses ofHeader;
502                 
503                 leaf port {
504                     type oft:port-number;
505                 }
506             } 
507             grouping queue-get-config-reply {
508                 // reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"
509                 /* Controller/switch message */
510
511                 uses ofHeader;
512                 
513                 leaf port {
514                     type oft:port-number;
515                 }
516                 list queues {
517                     uses packet-queue;
518                 }
519             } 
520             grouping packet-queue {
521                 leaf queue-id {
522                     type oft:queue-id;
523                 }
524                 leaf port {
525                     type oft:port-number;
526                 }
527                 list properties {
528                     uses queue-property-header;
529                 }
530             }
531             grouping queue-property-header {
532                 leaf property {
533                     type oft:queue-property;
534                 }
535             }
536             /* Controller role change request messages. */
537             grouping role-request {
538                 // reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"
539                 /* Controller/switch message */
540                 
541                 uses ofHeader;
542                 
543                 leaf role {
544                     type oft:controller-role;
545                 }
546                 leaf generation-id {
547                     type uint64;
548                 }
549             } 
550             grouping role-reply {
551                 // reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"
552                 /* Controller/switch message */
553
554                 uses ofHeader;
555                 
556                 leaf role {
557                     type oft:controller-role;
558                 }
559                 leaf generation-id {
560                     type uint64;
561                 }
562             } 
563             /* Asynchronous message configuration. */
564             grouping get-async-request {
565                 // reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"
566                 /* Controller/switch message */
567
568                 uses ofHeader;                
569             } 
570             grouping get-async-reply {
571                 // reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"
572                 /* Controller/switch message */
573
574                 uses ofHeader;
575                 
576                 leaf-list packet-in-mask {
577                     type oft:packet-in-reason;
578                 }
579                 leaf-list port-status-mask {
580                     type oft:port-reason;
581                 }
582                 leaf-list flow-removed-mask {
583                     type oft:flow-removed-reason;
584                 }
585             } 
586             grouping set-async {
587                 // reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"
588                 /* Controller/switch message */
589                 
590                 uses ofHeader;
591                 
592                 leaf-list packet-in-mask {
593                     type oft:packet-in-reason;
594                 }
595                 leaf-list port-status-mask {
596                     type oft:port-reason;
597                 }
598                 leaf-list flow-removed-mask {
599                     type oft:flow-removed-reason;
600                 }
601             } 
602             /* Meters and rate limiters configuration messages. */
603             grouping meter-mod {
604                 // reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"
605                 /* Controller/switch message */
606
607                 uses ofHeader;
608                 
609                 leaf command {
610                     type oft:meter-mod-command;
611                 } 
612                 leaf flags {
613                     type oft:meter-flags;
614                 }            
615                 leaf meter-id {
616                     type oft:meter-id;
617                 }   
618                 list bands {
619                     uses meter-band-header;
620                 }
621             } 
622             
623             grouping meter-band-header {
624                 leaf type {
625                     type oft:meter-band-type;
626                 }
627                 leaf rate {
628                     type uint32;
629                 }
630                 leaf burst-size {
631                     type uint32;
632                 }
633             }
634
635
636
637                 /* Immutable messages. */
638             notification hello-message {
639                 uses hello;
640                 // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"
641                 
642                 /* Symmetric message */
643             }
644             notification error-message {
645                 uses error;
646                 // reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"
647                 
648                 /* Symmetric message */
649             }
650             notification echo-request-message {
651                 uses echo-request;
652                 // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
653                 
654                 /* Symmetric message */
655             }
656             notification experimenter-message {
657                 uses experimenter;
658                 // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"
659                 // TODO:: does switch send this when understood experimenter msg from lib?
660                 /* Symmetric message */
661             }
662     // # Notification and RPCs
663         /* Symmetric RPC. */
664             rpc echo {
665                 // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
666                 input {
667                     uses echo-request;
668                 }
669                 /* Controller/switch message */
670                 output {
671                     uses echo-reply;
672                 }
673             }
674             
675             rpc echo-reply {
676                 // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
677                 input {
678                     uses echo-reply;
679                 }
680             }
681             
682             rpc hello {
683                 // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"
684                 input {
685                     uses hello;
686                 }
687             }
688             
689             rpc experimenter {
690                 // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"
691                 input {
692                     uses experimenter;
693                 }
694             }
695
696         /* Switch configuration messages. */
697             rpc get-features {
698                 // reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"
699                 input {
700                     uses features-request;
701                 }
702                 /* Controller/switch message */
703                 output {
704                     uses features-reply;
705                 }
706             }
707             
708             rpc get-config {
709                 // reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
710                 input {
711                     uses get-config-request;
712                 }
713                 output {
714                     uses get-config-reply;
715                 }
716                 /* Controller/switch message */
717             }
718             
719             rpc set-config {
720                 // reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"
721                 input {
722                     uses set-config;
723                 }   
724                 /* Controller/switch message */
725             }
726         /* Asynchronous messages. */
727             notification packet-in-message {
728                 uses packet-in;
729                 // reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"
730                 
731              /* Async message */
732             }
733             notification flow-removed-message {
734                 uses flow-removed;
735                 // reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"
736                 
737                 /* Async message */
738             } 
739             notification port-status-message {
740                 uses port-status;
741                 // reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"
742                 
743             } /* Async message */
744
745         /* Controller command messages. */
746             rpc packet-out {
747                 input {
748                     uses packet-out;
749                     // reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"
750                 }
751                 /* Controller/switch message */
752             } 
753             rpc flow-mod {
754                 input {
755                     uses flow-mod;
756                     // reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"
757                 }
758                 /* Controller/switch message */
759             } 
760             rpc group-mod {
761                 input {
762                     uses group-mod;
763                     // reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"
764                 }
765                 /* Controller/switch message */
766             } 
767             rpc port-mod {
768                 input {
769                     uses port-mod;
770                     // reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"
771                 }
772             } /* Controller/switch message */
773             
774             rpc table-mod {
775                 input {
776                     uses table-mod;
777                     // reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"
778                 }
779             } /* Controller/switch message */
780
781         /* Multipart messages. */
782             //FIXME: Arent this wire protocol specific?
783
784             notification multipart-request-message {
785                 uses multipart-request;
786                 // reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"
787                 
788             } /* Controller/switch message */
789             notification multipart-reply-message {
790                 uses multipart-reply;
791                 // reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"
792                 
793             } /* Controller/switch message */
794             
795
796             /* Barrier messages. */
797             rpc barrier {
798                 input {
799                     uses barrier-request;
800                     // reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"
801                 }
802                 output {
803                     uses barrier-reply;
804                     // reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"
805                 }
806             }
807         /* Queue Configuration messages. */
808             rpc get-queue-config {
809                 input {
810                     uses queue-get-config-request;
811                     // reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
812                 }
813                 output {
814                     uses queue-get-config-reply;
815                     // reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"
816                 }
817             } 
818
819         /* Controller role change request messages. */
820             rpc role-request {
821                 input {
822                     uses role-request;
823                     // reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"
824                 }
825                 output {
826                     uses role-reply;
827                     // reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"
828                 }
829             } /* Controller/switch message */
830             
831         /* Asynchronous message configuration. */
832             rpc get-async {
833                 input {
834                     uses get-async-request;
835                     // reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"
836                 }
837                 output {
838                     uses get-async-reply;
839                     // reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"
840                 }
841             } 
842              /* Controller/switch message */
843             rpc set-async {
844                 input { 
845                     uses set-async;
846                 // reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"
847                 }
848                 
849             } 
850         /* Meters and rate limiters configuration messages. */
851             rpc meter-mod {
852                 input {
853                     uses meter-mod;
854                     // reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"
855                 }
856             } /* Controller/switch message */
857 }