added new serialization factories and their tests 08/1508/2
authorTimotej Kubas <timotej.kubas@pantheon.sk>
Mon, 30 Sep 2013 12:30:32 +0000 (14:30 +0200)
committerTimotej Kubas <timotej.kubas@pantheon.sk>
Tue, 1 Oct 2013 08:16:32 +0000 (10:16 +0200)
Change-Id: I04e093c52d3d22002fbc6812a512dd87e2290c2b
Signed-off-by: timotej.kubas@pantheon.sk
16 files changed:
openflow-protocol-api/src/main/yang/openflow-protocol.yang
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtils.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtilsTest.java

index cbcd4e3b8a0e5a47d633ea74aca6cd43d3b8947f..18ee397a94325fec697640e5bb07c0d05e35be43 100644 (file)
-module openflow-protocol {
-    namespace "urn:opendaylight:openflow:protocol";
-    prefix "ofproto";
-
-
-    import ietf-inet-types {prefix inet;}
-    import ietf-yang-types {prefix yang;}
-    
-    import openflow-types {prefix oft;}
-    import openflow-extensible-match { prefix oxm;}
-    import openflow-instruction { prefix ofinstruction;}
-    import openflow-action {prefix ofaction;}
-
-
-
-    revision "2013-07-31" {
-        description "Initial model";
-    }
-
-    // Generic Structures
-
-        grouping port {
-            // reference "ofp_port";
-            leaf port-no { 
-                // reference "ofp_port.port_no"; 
-                type uint32;
-            }
-            leaf hw-addr { 
-                // reference "ofp_port.hw_addr"; 
-                type yang:mac-address;
-            }
-            leaf name { 
-                // reference "ofp_port.name"; 
-                type string;
-            }
-            leaf config { 
-                // reference "ofp_port.config"; 
-                type oft:port-config;
-            }
-            leaf state { 
-                // reference "ofp_port.state"; 
-                type oft:port-state;
-            }
-            leaf current-features { 
-                description "Current features.";
-                // reference "ofp_port.curr"; 
-                type oft:port-features; 
-            }
-            leaf advertised-features { 
-                description "Features being advertised by the port.";
-                // reference "ofp_port.advertised"; 
-                type oft:port-features; 
-            }
-            leaf supported-features { 
-                description "Features supported by the port.";
-                // reference "ofp_port.supported"; 
-                type oft:port-features; 
-            }
-            leaf peer-features { 
-                description "Features advertised by peer.";
-                // reference "ofp_port.peer"; 
-                type oft:port-features; 
-            }
-            leaf curr_speed { 
-                description "Current port bitrate in kbps.";
-                // reference "ofp_port.curr_speed"; 
-                type uint32; 
-                units "kbps";
-            }
-            leaf max_speed { 
-                description "Max port bitrate in kbps";
-                // reference "ofp_port.max_speed"; 
-                type uint32;
-                units "kbps"; 
-            }
-        }
-
-    // TODO: ofp_packat_queue
-
-    // # MESSAGE Structures
-        /* Immutable messages. */
-            grouping ofHeader {
-                //reference "ofpt_header struct in Openflow Switch 1.3 Spec"
-                leaf version {
-                    type uint8;
-                    //reference "OpenFlow Header - OFP_VERSION";
-                }
-                leaf xid {
-                    type uint32;
-                    //reference "OpenFlow Header - transaction id";
-                }
-            }
-            grouping ofHelloElementHeader {
-                //reference "ofpt_hello_elem_header struct in Openflow Switch 1.3 Spec"
-                leaf type {
-                    type oft:hello-element-type;
-                    //reference "OpenFlow Header element type - OFPHET_*";
-                }
-            }
-            grouping hello {
-                // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"
-                /* Symmetric message */
-                uses ofHeader;
-                
-                list elements {
-                    uses ofHelloElementHeader;
-                    
-                    leaf data {
-                        type binary;
-                    }
-                }
-            }
-            grouping error {
-                // reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"
-                /* Symmetric message */
-                uses ofHeader;
-                
-                leaf type {
-                    type oft:error-type;
-                }
-                leaf code {
-                    type uint16;
-                }
-                leaf data {
-                    type binary; 
-                }
-            }
-            grouping echo-request {
-                // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
-                /* Symmetric message */
-                uses ofHeader;
-                
-                leaf data {
-                    type binary;
-                }
-            }
-            grouping echo-reply {
-                // reference "OFPT_ECHO_REPLY message in Openflow Switch 1.3 Spec"
-                /* Symmetric message */
-                uses ofHeader;
-                
-                leaf data {
-                    type binary;
-                }
-            }
-            grouping experimenter {
-                // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"
-                /* Symmetric message */
-                uses ofHeader;
-                
-                leaf experimenter {
-                    type uint32;
-                }
-                leaf exp_type {
-                    type uint32;
-                }
-            }
-        /* Switch configuration messages. */
-            grouping features-request {
-                // reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                uses ofHeader;
-            }
-            grouping features-reply {
-                // reference "OFPT_FEATURES_REPLY message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                uses ofHeader;
-                
-                leaf datapathId {
-                    type uint64;
-                }
-                leaf buffers {
-                    type uint32;
-                }
-                leaf tables {
-                    type uint8;
-                }
-                leaf auxiliaryId {
-                    type uint8;
-                }
-                leaf capabilities {
-                    type uint32;
-                }
-                leaf reserved {
-                    type uint32;
-                }
-            }
-            grouping get-config-request {
-                // reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                uses ofHeader;
-            }
-            grouping get-config-reply {
-                // reference "OFPT_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                uses ofHeader;
-                
-                leaf flags {
-                    type oft:switch-config-flag;
-                }
-                leaf miss-send-len {
-                    type uint16;
-                }
-            }
-            grouping set-config {
-                // reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                
-                uses ofHeader;
-                
-                leaf flags {
-                    type oft:switch-config-flag;
-                }
-                leaf miss-send-len {
-                    type uint16;
-                }
-            }
-        /* Asynchronous messages. */
-            grouping packet-in {
-                // reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"
-                /* Async message */
-                
-                uses ofHeader;
-                
-                leaf buffer-id {
-                    // ID assigned by datapath.
-                    type uint32;
-                }  
-                leaf total-len {
-                    // Full length of frame.
-                    type uint16;
-                }
-                leaf reason {
-                    // Reason packet is being sent (one of OFPR_*) 
-                    type uint8;
-                }
-                leaf table-id {
-                    // ID of the table that was looked up
-                    type oft:table-id;
-                }
-                leaf cookie {
-                    // Cookie of the flow entry that was looked up.
-                    type uint64;
-                }
-                
-                //TODO:: add match leaf
-                // leaf match {
-                //     type oft:match
-                // }
-
-// struct ofp_match match; /* Packet metadata. Variable size. */
-// /* The variable size and padded match is always followed by:
-//  *   - Exactly 2 all-zero padding bytes, then
-//  *   - An Ethernet frame whose length is inferred from header.length.
-//  * The padding bytes preceding the Ethernet frame ensure that the IP
-//  * header (if any) following the Ethernet header is 32-bit aligned.
-//  */
-                leaf data {
-                    type binary;
-                }
-                
-            }
-            grouping flow-removed {
-                // reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"
-                /* Async message */
-                uses ofHeader;
-                
-                leaf cookie {
-                    type uint64;
-                }
-                leaf priority {
-                    type uint16;
-                }
-                leaf reason {
-                    type oft:flow-removed-reason;
-                }
-                leaf table-id {
-                    type oft:table-id;
-                }
-                leaf duration-sec {
-                    type uint32;
-                }
-                leaf duration-nsec {
-                    type uint32;
-                }
-                leaf idle-timeout {
-                    type uint16;
-                }
-                leaf hard-timeout {
-                    type uint16;
-                }
-                leaf packet-count {
-                    type uint64;
-                }
-                leaf byte-count {
-                    type uint64;
-                }
-                //TODO:: add match leaf
-                //leaf match {
-                //    type oft:match;
-                //}
-            } 
-            grouping port-status {
-                // reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"
-                
-                uses ofHeader;
-                
-                uses port;
-                
-                leaf reason {
-                    type oft:port-reason;
-                }
-            } /* Async message */
-        /* Controller command messages. */
-            grouping packet-out {
-                // reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                
-                uses ofHeader;
-                
-                list actions {
-                    uses ofaction:action-header;
-                    
-                    leaf data {
-                        type binary;
-                    }
-                }
-                
-                leaf buffer-id {
-                    type uint32;
-                }
-                leaf in-port {
-                    type oft:port-number;
-                }
-            } 
-            grouping flow-mod {
-                // reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                
-                uses ofHeader;
-                
-                leaf cookie {
-                    type uint64;
-                }
-                leaf cookie-mask {
-                    type uint64;
-                }
-                leaf table-id {
-                    type oft:table-id;
-                }
-                leaf command {
-                    type oft:flow-mod-command;
-                }
-                leaf idle-timeout {
-                    type uint16;
-                }
-                leaf hard-timeout {
-                    type uint16;
-                }
-                leaf priority {
-                    type uint16;
-                }
-                leaf buffer-id {
-                    type uint32;
-                }
-                leaf out-port {
-                    type oft:port-number;
-                }
-                leaf out-group {
-                    type uint32;
-                }
-                leaf flags {
-                    type uint16;
-                }
-                //TODO:: add match leaf
-            } 
-            grouping group-mod {
-                // reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                
-                uses ofHeader;
-                
-                leaf command {
-                    type oft:group-mod-command;
-                }
-                leaf type {
-                    type oft:group-type;
-                }
-                leaf group-id {
-                    type uint32;
-                }
-                
-                list buckets {
-                    uses bucket;
-                }
-            }
-            grouping bucket {
-                leaf weight {
-                    type uint16;
-                }
-                leaf watch-port {
-                    type oft:port-number;
-                }
-                leaf watch-group {
-                    type uint32;
-                }
-                
-                list actions {
-                    uses ofaction:action-header;
-                }
-            }
-            grouping port-mod {
-                // reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-
-                uses ofHeader;
-                
-                leaf port-no {
-                    type oft:port-number;
-                }
-                leaf hw-address {
-                    type yang:mac-address;
-                }       
-                leaf config {
-                    type oft:port-config;
-                }   
-                leaf mask {
-                    type oft:port-config;
-                }  
-                leaf advertise {
-                    type oft:port-config;
-                }
-            } 
-            grouping table-mod {
-                // reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-
-                uses ofHeader;
-                
-                leaf table-id {
-                    type oft:table-id;
-                }
-                leaf config {
-                    type oft:port-config;
-                }                
-            } 
-            
-        /* Multipart messages. */
-            grouping multipart-request {
-                // reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-
-                uses ofHeader;
-                
-                leaf type {
-                    type oft:multipart-type;
-                }          
-                leaf flags {
-                    type oft:multipart-request-flags;
-                }      
-                choice multipart-request-body {
-                    case multipart-request-flow {
-                        leaf table-id {
-                            type uint8;
-                        }
-                        leaf out-port {
-                            type uint32;
-                        }
-                        leaf out-group {
-                            type uint32;
-                        }
-                        leaf cookie {
-                            type uint64;
-                        }
-                        leaf cookie-mask {
-                            type uint64;
-                        }
-                        leaf match {
-                            type identityref {
-                                base oft:match-type-base;
-                            }
-                        }
-                    }
-                    case multipart-request-aggregate {
-                        leaf table-id {
-                            type uint8;
-                        }
-                        leaf out-port {
-                            type uint32;
-                        }
-                        leaf out-group {
-                            type uint32;
-                        }
-                        leaf cookie {
-                            type uint64;
-                        }
-                        leaf cookie-mask {
-                            type uint64;
-                        }
-                        leaf match {
-                            type identityref {
-                                base oft:match-type-base;
-                            }
-                        }
-                    }
-                    case multipart-request-port-stats {
-                        leaf port-no {
-                            type uint32;
-                        }
-                    }
-                    case multipart-request-queue {
-                        leaf port-no {
-                            type uint32;
-                        }
-                        leaf queue-id {
-                            type uint32;
-                        }
-                    }
-                    case multipart-request-group {
-                        leaf group-id {
-                            type uint32;
-                        }
-                    }
-                    case multipart-request-meter {
-                        leaf meter-id {
-                            type uint32;
-                        }
-                    }
-                    case multipart-request-meter-config {
-                        leaf meter-id {
-                            type uint32;
-                        }
-                    }
-                    case multipart-request-table-features {
-                        list table_features {
-                            leaf table-id {
-                                type uint8;
-                            }
-                            leaf name {
-                                type string;
-                            }
-                            leaf metadata-match {
-                                type uint64;
-                            }
-                            leaf metadata-write {
-                                type uint64;
-                            }
-                            leaf config {
-                                type oft:table-config;
-                            }
-                            leaf max-entries {
-                                type uint32;
-                            }
-                        }
-                    }
-                    case multipart-request-experimenter {
-                        leaf experimenter {
-                            type uint32;
-                        }
-                        leaf exp-type {
-                            type uint32;
-                        }
-                    }
-                }
-            } 
-            grouping multipart-reply {
-                // reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-
-                uses ofHeader;
-                
-                leaf type {
-                    type oft:multipart-type;
-                }
-                leaf flags {
-                    type oft:multipart-request-flags;
-                }
-                choice multipart-reply-body {
-                    case multipart-reply-desc {
-                        leaf mfr_desc {
-                            type string;
-                        }
-                        leaf hw_desc {
-                            type string;
-                        }
-                        leaf sw_desc {
-                            type string;
-                        }
-                        leaf serial_num {
-                            type string;
-                        }
-                        leaf dp_desc {
-                            type string;
-                        }
-                    }
-                    case multipart-reply-flow {
-                        list flow-stats {
-                            leaf table-id {
-                                type uint8;
-                            }
-                            leaf duration-sec {
-                                type uint32;
-                            }
-                            leaf duration-nsec {
-                                type uint32;
-                            }
-                            leaf priority {
-                                type uint16;
-                            }
-                            leaf idle-timeout {
-                                type uint16;
-                            }
-                            leaf hard-timeout {
-                                type uint16;
-                            }
-                            leaf flags {
-                                type uint16;
-                            }
-                            leaf cookie {
-                                type uint64;
-                            }
-                            leaf packet-count {
-                                type uint64;
-                            }
-                            leaf byte-count {
-                                type uint64;
-                            }
-                            leaf match {
-                                type uint64;
-                            }
-                        }
-                    }
-                    case multipart-reply-aggregate {
-                        leaf packet-count {
-                            type uint64;
-                        }
-                        leaf byte-count {
-                            type uint64;
-                        }
-                        leaf flow-count {
-                            type uint32;
-                        }
-                    }
-                    case multipart-reply-table {
-                        list table-stats {
-                            leaf table-id {
-                                type uint8;
-                            }
-                            leaf active-count {
-                                type uint32;
-                            }
-                            leaf lookup-count {
-                                type uint64;
-                            }
-                            leaf matched-count {
-                                type uint64;
-                            }
-                        }
-                    }
-                    case multipart-reply-port-stats {
-                        list port-stats {
-                            leaf port-no {
-                                type uint32;
-                            }
-                            leaf rx-packets {
-                                type uint64;
-                            }
-                            leaf tx-packets {
-                                type uint64;
-                            }
-                            leaf rx-bytes {
-                                type uint64;
-                            }
-                            leaf tx-bytes {
-                                type uint64;
-                            }
-                            leaf rx-dropped {
-                                type uint64;
-                            }
-                            leaf tx-dropped {
-                                type uint64;
-                            }
-                            leaf rx-errors {
-                                type uint64;
-                            }
-                            leaf tx-errors {
-                                type uint64;
-                            }
-                            leaf rx-frame-err {
-                                type uint64;
-                            }
-                            leaf rx-over-err {
-                                type uint64;
-                            }
-                            leaf rx-crc-err {
-                                type uint64;
-                            }
-                            leaf collisions {
-                                type uint64;
-                            }
-                            leaf duration-sec {
-                                type uint32;
-                            }
-                            leaf duration-nsec {
-                                type uint32;
-                            }
-                        }
-                    }
-                    case multipart-reply-queue {
-                        list queue-stats {
-                            leaf port-no {
-                                type uint32;
-                            }
-                            leaf queue-id {
-                                type uint32;
-                            }
-                            leaf tx-bytes {
-                                type uint64;
-                            }
-                            leaf tx-packets {
-                                type uint64;
-                            }
-                            leaf tx-errors {
-                                type uint64;
-                            }
-                            leaf duration-sec {
-                                type uint32;
-                            }
-                            leaf duration-nsec {
-                                type uint32;
-                            }
-                        }
-                    }
-                    case multipart-reply-group {
-                        list group-stats {
-                            leaf group-id {
-                                type uint32;
-                            }
-                            leaf ref-count {
-                                type uint32;
-                            }
-                            leaf packet-count {
-                                type uint64;
-                            }
-                            leaf byte-count {
-                                type uint64;
-                            }
-                            leaf duration-sec {
-                                type uint32;
-                            }
-                            leaf duration-nsec {
-                                type uint32;
-                            }
-                            list bucket-stats {
-                                leaf packet-count {
-                                    type uint64;
-                                }
-                                leaf byte-count {
-                                    type uint64;
-                                }
-                            }
-                        }
-                    }
-                    case multipart-reply-group-desc {
-                        list group-desc {
-                            leaf type {
-                                type uint8;
-                            }
-                            leaf group-id {
-                                type uint32;
-                            }
-                            list buckets {
-                                uses bucket;
-                            }
-                        }
-                    }
-                    case multipart-reply-group-features {
-                        leaf types {
-                            type oft:group-types;
-                        }
-                        leaf capabilities {
-                            type oft:group-capabilities;
-                        }
-                        leaf-list max_groups {
-                            type uint32;
-                        }
-                        leaf-list actions {
-                            type ofaction:action-type;
-                        }
-                    }
-                    case multipart-reply-meter {
-                        list meter-stats {
-                            leaf meter-id {
-                                type uint32;
-                            }
-                            leaf flow-count {
-                                type uint32;
-                            }
-                            leaf packet-in-count {
-                                type uint64;
-                            }
-                            leaf byte-in-count {
-                                type uint64;
-                            }
-                            leaf duration-sec {
-                                type uint32;
-                            }
-                            leaf duration-nsec {
-                                type uint32;
-                            }
-                            list meter-band-stats {
-                                leaf packet-band-count {
-                                    type uint64;
-                                }
-                                leaf byte-band-count {
-                                    type uint64;
-                                }
-                            }
-                        }
-                    }
-                    case multipart-reply-meter-config {
-                        list meter-config {
-                            leaf flags {
-                                type oft:meter-mod-command;
-                            }
-                            leaf meter-id {
-                                type uint32;
-                            }
-                            list bands {
-                                uses meter-band-header;
-                            }
-                        }
-                    }
-                    case multipart-reply-meter-features {
-                        leaf max-meter {
-                            type uint32;
-                        }
-                        leaf band-types {
-                            type oft:meter-band-type;
-                        }
-                        leaf capabilities {
-                            type oft:meter-flags;
-                        }
-                        leaf max-bands {
-                            type uint8;
-                        }
-                        leaf max-color {
-                            type uint8;
-                        }
-                    }
-                    case multipart-reply-table-features {
-                        list table-features {
-                            leaf table-id {
-                                type uint8;
-                            }
-                            leaf name {
-                                type string;
-                            }
-                            leaf metadata-match {
-                                type binary;
-                            }
-                            leaf metadata-write {
-                                type binary;
-                            }
-                            leaf config {
-                                type oft:port-config;
-                            } 
-                            leaf max-entries {
-                                type uint32;
-                            }
-                        }
-                    }
-                    case multipart-reply-port-desc {
-                        list ports {
-                            uses port;
-                        }
-                    }
-                    case multipart-reply-experimenter {
-                        leaf experimenter {
-                            type uint32;
-                        }
-                        leaf exp-type {
-                            type uint32;
-                        }
-                    }
-                }
-            } 
-            /* Barrier messages. */
-            grouping barrier-request {
-                // reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                uses ofHeader;
-            } 
-            grouping barrier-reply {
-                // reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                uses ofHeader;
-            } 
-        /* Queue Configuration messages. */
-            grouping queue-get-config-request {
-                // reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                
-                uses ofHeader;
-                
-                leaf port {
-                    type oft:port-number;
-                }
-            } 
-            grouping queue-get-config-reply {
-                // reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-
-                uses ofHeader;
-                
-                leaf port {
-                    type oft:port-number;
-                }
-                list queues {
-                    uses packet-queue;
-                }
-            } 
-            grouping packet-queue {
-                leaf queue-id {
-                    type oft:queue-id;
-                }
-                leaf port {
-                    type oft:port-number;
-                }
-                list properties {
-                    uses queue-property-header;
-                }
-            }
-            grouping queue-property-header {
-                leaf property {
-                    type oft:queue-property;
-                }
-            }
-            /* Controller role change request messages. */
-            grouping role-request {
-                // reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                
-                uses ofHeader;
-                
-                leaf role {
-                    type oft:controller-role;
-                }
-                leaf generation-id {
-                    type uint64;
-                }
-            } 
-            grouping role-reply {
-                // reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-
-                uses ofHeader;
-                
-                leaf role {
-                    type oft:controller-role;
-                }
-                leaf generation-id {
-                    type uint64;
-                }
-            } 
-            /* Asynchronous message configuration. */
-            grouping get-async-request {
-                // reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-
-                uses ofHeader;                
-            } 
-            grouping get-async-reply {
-                // reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-
-                uses ofHeader;
-                
-                list packet-in-mask {
-                    leaf-list mask {
-                        type oft:packet-in-reason;
-                    }
-                }
-                list port-status-mask {
-                    leaf-list mask {
-                        type oft:port-reason;
-                    }
-                }
-                list flow-removed-mask {
-                    leaf-list mask {
-                        type oft:flow-removed-reason;
-                    }
-                }
-            } 
-            grouping set-async {
-                // reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-                
-                uses ofHeader;
-                
-                leaf-list packet-in-mask {
-                    type oft:packet-in-reason;
-                }
-                leaf-list port-status-mask {
-                    type oft:port-reason;
-                }
-                leaf-list flow-removed-mask {
-                    type oft:flow-removed-reason;
-                }
-            } 
-            /* Meters and rate limiters configuration messages. */
-            grouping meter-mod {
-                // reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"
-                /* Controller/switch message */
-
-                uses ofHeader;
-                
-                leaf command {
-                    type oft:meter-mod-command;
-                } 
-                leaf flags {
-                    type oft:meter-flags;
-                }            
-                leaf meter-id {
-                    type oft:meter-id;
-                }   
-                list bands {
-                    uses meter-band-header;
-                }
-            } 
-            
-            grouping meter-band-header {
-                leaf type {
-                    type oft:meter-band-type;
-                }
-                leaf rate {
-                    type uint32;
-                }
-                leaf burst-size {
-                    type uint32;
-                }
-            }
-
-
-
-                /* Immutable messages. */
-            notification hello-message {
-                uses hello;
-                // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"
-                
-                /* Symmetric message */
-            }
-            notification error-message {
-                uses error;
-                // reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"
-                
-                /* Symmetric message */
-            }
-            notification echo-request-message {
-                uses echo-request;
-                // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
-                
-                /* Symmetric message */
-            }
-            notification experimenter-message {
-                uses experimenter;
-                // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"
-                // TODO:: does switch send this when understood experimenter msg from lib?
-                /* Symmetric message */
-            }
-    // # Notification and RPCs
-        /* Symmetric RPC. */
-            rpc echo {
-                // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
-                input {
-                    uses echo-request;
-                }
-                /* Controller/switch message */
-                output {
-                    uses echo-reply;
-                }
-            }
-            
-            rpc echo-reply {
-                // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
-                input {
-                    uses echo-reply;
-                }
-            }
-            
-            rpc hello {
-                // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"
-                input {
-                    uses hello;
-                }
-            }
-            
-            rpc experimenter {
-                // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"
-                input {
-                    uses experimenter;
-                }
-            }
-
-        /* Switch configuration messages. */
-            rpc get-features {
-                // reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"
-                input {
-                    uses features-request;
-                }
-                /* Controller/switch message */
-                output {
-                    uses features-reply;
-                }
-            }
-            
-            rpc get-config {
-                // reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
-                input {
-                    uses get-config-request;
-                }
-                output {
-                    uses get-config-reply;
-                }
-                /* Controller/switch message */
-            }
-            
-            rpc set-config {
-                // reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"
-                input {
-                    uses set-config;
-                }   
-                /* Controller/switch message */
-            }
-        /* Asynchronous messages. */
-            notification packet-in-message {
-                uses packet-in;
-                // reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"
-                
-             /* Async message */
-            }
-            notification flow-removed-message {
-                uses flow-removed;
-                // reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"
-                
-                /* Async message */
-            } 
-            notification port-status-message {
-                uses port-status;
-                // reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"
-                
-            } /* Async message */
-
-        /* Controller command messages. */
-            rpc packet-out {
-                input {
-                    uses packet-out;
-                    // reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"
-                }
-                /* Controller/switch message */
-            } 
-            rpc flow-mod {
-                input {
-                    uses flow-mod;
-                    // reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"
-                }
-                /* Controller/switch message */
-            } 
-            rpc group-mod {
-                input {
-                    uses group-mod;
-                    // reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"
-                }
-                /* Controller/switch message */
-            } 
-            rpc port-mod {
-                input {
-                    uses port-mod;
-                    // reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"
-                }
-            } /* Controller/switch message */
-            
-            rpc table-mod {
-                input {
-                    uses table-mod;
-                    // reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"
-                }
-            } /* Controller/switch message */
-
-        /* Multipart messages. */
-            //FIXME: Arent this wire protocol specific?
-
-            notification multipart-request-message {
-                uses multipart-request;
-                // reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"
-                
-            } /* Controller/switch message */
-            notification multipart-reply-message {
-                uses multipart-reply;
-                // reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"
-                
-            } /* Controller/switch message */
-            
-
-            /* Barrier messages. */
-            rpc barrier {
-                input {
-                    uses barrier-request;
-                    // reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"
-                }
-                output {
-                    uses barrier-reply;
-                    // reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"
-                }
-            }
-        /* Queue Configuration messages. */
-            rpc get-queue-config {
-                input {
-                    uses queue-get-config-request;
-                    // reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
-                }
-                output {
-                    uses queue-get-config-reply;
-                    // reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"
-                }
-            } 
-
-        /* Controller role change request messages. */
-            rpc role-request {
-                input {
-                    uses role-request;
-                    // reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"
-                }
-                output {
-                    uses role-reply;
-                    // reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"
-                }
-            } /* Controller/switch message */
-            
-        /* Asynchronous message configuration. */
-            rpc get-async {
-                input {
-                    uses get-async-request;
-                    // reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"
-                }
-                output {
-                    uses get-async-reply;
-                    // reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"
-                }
-            } 
-             /* Controller/switch message */
-            rpc set-async {
-                input { 
-                    uses set-async;
-                // reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"
-                }
-                
-            } 
-        /* Meters and rate limiters configuration messages. */
-            rpc meter-mod {
-                input {
-                    uses meter-mod;
-                    // reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"
-                }
-            } /* Controller/switch message */
+module openflow-protocol {\r
+    namespace "urn:opendaylight:openflow:protocol";\r
+    prefix "ofproto";\r
+\r
+\r
+    import ietf-inet-types {prefix inet;}\r
+    import ietf-yang-types {prefix yang;}\r
+    \r
+    import openflow-types {prefix oft;}\r
+    import openflow-extensible-match { prefix oxm;}\r
+    import openflow-instruction { prefix ofinstruction;}\r
+    import openflow-action {prefix ofaction;}\r
+\r
+\r
+\r
+    revision "2013-07-31" {\r
+        description "Initial model";\r
+    }\r
+\r
+    // Generic Structures\r
+\r
+        grouping port {\r
+            // reference "ofp_port";\r
+            leaf port-no { \r
+                // reference "ofp_port.port_no"; \r
+                type uint32;\r
+            }\r
+            leaf hw-addr { \r
+                // reference "ofp_port.hw_addr"; \r
+                type yang:mac-address;\r
+            }\r
+            leaf name { \r
+                // reference "ofp_port.name"; \r
+                type string;\r
+            }\r
+            leaf config { \r
+                // reference "ofp_port.config"; \r
+                type oft:port-config;\r
+            }\r
+            leaf state { \r
+                // reference "ofp_port.state"; \r
+                type oft:port-state;\r
+            }\r
+            leaf current-features { \r
+                description "Current features.";\r
+                // reference "ofp_port.curr"; \r
+                type oft:port-features; \r
+            }\r
+            leaf advertised-features { \r
+                description "Features being advertised by the port.";\r
+                // reference "ofp_port.advertised"; \r
+                type oft:port-features; \r
+            }\r
+            leaf supported-features { \r
+                description "Features supported by the port.";\r
+                // reference "ofp_port.supported"; \r
+                type oft:port-features; \r
+            }\r
+            leaf peer-features { \r
+                description "Features advertised by peer.";\r
+                // reference "ofp_port.peer"; \r
+                type oft:port-features; \r
+            }\r
+            leaf curr_speed { \r
+                description "Current port bitrate in kbps.";\r
+                // reference "ofp_port.curr_speed"; \r
+                type uint32; \r
+                units "kbps";\r
+            }\r
+            leaf max_speed { \r
+                description "Max port bitrate in kbps";\r
+                // reference "ofp_port.max_speed"; \r
+                type uint32;\r
+                units "kbps"; \r
+            }\r
+        }\r
+\r
+    // TODO: ofp_packat_queue\r
+\r
+    // # MESSAGE Structures\r
+        /* Immutable messages. */\r
+            grouping ofHeader {\r
+                //reference "ofpt_header struct in Openflow Switch 1.3 Spec"\r
+                leaf version {\r
+                    type uint8;\r
+                    //reference "OpenFlow Header - OFP_VERSION";\r
+                }\r
+                leaf xid {\r
+                    type uint32;\r
+                    //reference "OpenFlow Header - transaction id";\r
+                }\r
+            }\r
+            grouping ofHelloElementHeader {\r
+                //reference "ofpt_hello_elem_header struct in Openflow Switch 1.3 Spec"\r
+                leaf type {\r
+                    type oft:hello-element-type;\r
+                    //reference "OpenFlow Header element type - OFPHET_*";\r
+                }\r
+            }\r
+            grouping hello {\r
+                // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"\r
+                /* Symmetric message */\r
+                uses ofHeader;\r
+                \r
+                list elements {\r
+                    uses ofHelloElementHeader;\r
+                    \r
+                    leaf data {\r
+                        type binary;\r
+                    }\r
+                }\r
+            }\r
+            grouping error {\r
+                // reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"\r
+                /* Symmetric message */\r
+                uses ofHeader;\r
+                \r
+                leaf type {\r
+                    type oft:error-type;\r
+                }\r
+                leaf code {\r
+                    type uint16;\r
+                }\r
+                leaf data {\r
+                    type binary; \r
+                }\r
+            }\r
+            grouping echo-request {\r
+                // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"\r
+                /* Symmetric message */\r
+                uses ofHeader;\r
+                \r
+                leaf data {\r
+                    type binary;\r
+                }\r
+            }\r
+            grouping echo-reply {\r
+                // reference "OFPT_ECHO_REPLY message in Openflow Switch 1.3 Spec"\r
+                /* Symmetric message */\r
+                uses ofHeader;\r
+                \r
+                leaf data {\r
+                    type binary;\r
+                }\r
+            }\r
+            grouping experimenter {\r
+                // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"\r
+                /* Symmetric message */\r
+                uses ofHeader;\r
+                \r
+                leaf experimenter {\r
+                    type uint32;\r
+                }\r
+                leaf exp_type {\r
+                    type uint32;\r
+                }\r
+            }\r
+        /* Switch configuration messages. */\r
+            grouping features-request {\r
+                // reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                uses ofHeader;\r
+            }\r
+            grouping features-reply {\r
+                // reference "OFPT_FEATURES_REPLY message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                uses ofHeader;\r
+                \r
+                leaf datapathId {\r
+                    type uint64;\r
+                }\r
+                leaf buffers {\r
+                    type uint32;\r
+                }\r
+                leaf tables {\r
+                    type uint8;\r
+                }\r
+                leaf auxiliaryId {\r
+                    type uint8;\r
+                }\r
+                leaf capabilities {\r
+                    type uint32;\r
+                }\r
+                leaf reserved {\r
+                    type uint32;\r
+                }\r
+            }\r
+            grouping get-config-request {\r
+                // reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                uses ofHeader;\r
+            }\r
+            grouping get-config-reply {\r
+                // reference "OFPT_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                uses ofHeader;\r
+                \r
+                leaf flags {\r
+                    type oft:switch-config-flag;\r
+                }\r
+                leaf miss-send-len {\r
+                    type uint16;\r
+                }\r
+            }\r
+            grouping set-config {\r
+                // reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                \r
+                uses ofHeader;\r
+                \r
+                leaf flags {\r
+                    type oft:switch-config-flag;\r
+                }\r
+                leaf miss-send-len {\r
+                    type uint16;\r
+                }\r
+            }\r
+        /* Asynchronous messages. */\r
+            grouping packet-in {\r
+                // reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"\r
+                /* Async message */\r
+                \r
+                uses ofHeader;\r
+                \r
+                leaf buffer-id {\r
+                    // ID assigned by datapath.\r
+                    type uint32;\r
+                }  \r
+                leaf total-len {\r
+                    // Full length of frame.\r
+                    type uint16;\r
+                }\r
+                leaf reason {\r
+                    // Reason packet is being sent (one of OFPR_*) \r
+                    type uint8;\r
+                }\r
+                leaf table-id {\r
+                    // ID of the table that was looked up\r
+                    type oft:table-id;\r
+                }\r
+                leaf cookie {\r
+                    // Cookie of the flow entry that was looked up.\r
+                    type uint64;\r
+                }\r
+                \r
+                //TODO:: add match leaf\r
+                // leaf match {\r
+                //     type oft:match\r
+                // }\r
+\r
+// struct ofp_match match; /* Packet metadata. Variable size. */\r
+// /* The variable size and padded match is always followed by:\r
+//  *   - Exactly 2 all-zero padding bytes, then\r
+//  *   - An Ethernet frame whose length is inferred from header.length.\r
+//  * The padding bytes preceding the Ethernet frame ensure that the IP\r
+//  * header (if any) following the Ethernet header is 32-bit aligned.\r
+//  */\r
+                leaf data {\r
+                    type binary;\r
+                }\r
+                \r
+            }\r
+            grouping flow-removed {\r
+                // reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"\r
+                /* Async message */\r
+                uses ofHeader;\r
+                \r
+                leaf cookie {\r
+                    type uint64;\r
+                }\r
+                leaf priority {\r
+                    type uint16;\r
+                }\r
+                leaf reason {\r
+                    type oft:flow-removed-reason;\r
+                }\r
+                leaf table-id {\r
+                    type oft:table-id;\r
+                }\r
+                leaf duration-sec {\r
+                    type uint32;\r
+                }\r
+                leaf duration-nsec {\r
+                    type uint32;\r
+                }\r
+                leaf idle-timeout {\r
+                    type uint16;\r
+                }\r
+                leaf hard-timeout {\r
+                    type uint16;\r
+                }\r
+                leaf packet-count {\r
+                    type uint64;\r
+                }\r
+                leaf byte-count {\r
+                    type uint64;\r
+                }\r
+                //TODO:: add match leaf\r
+                //leaf match {\r
+                //    type oft:match;\r
+                //}\r
+            } \r
+            grouping port-status {\r
+                // reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"\r
+                \r
+                uses ofHeader;\r
+                \r
+                uses port;\r
+                \r
+                leaf reason {\r
+                    type oft:port-reason;\r
+                }\r
+            } /* Async message */\r
+        /* Controller command messages. */\r
+            grouping packet-out {\r
+                // reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                \r
+                uses ofHeader;\r
+                \r
+                list actions {\r
+                    uses ofaction:action-header;\r
+                    \r
+                    leaf data {\r
+                        type binary;\r
+                    }\r
+                }\r
+                \r
+                leaf buffer-id {\r
+                    type uint32;\r
+                }\r
+                leaf in-port {\r
+                    type oft:port-number;\r
+                }\r
+            } \r
+            grouping flow-mod {\r
+                // reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                \r
+                uses ofHeader;\r
+                \r
+                leaf cookie {\r
+                    type uint64;\r
+                }\r
+                leaf cookie-mask {\r
+                    type uint64;\r
+                }\r
+                leaf table-id {\r
+                    type oft:table-id;\r
+                }\r
+                leaf command {\r
+                    type oft:flow-mod-command;\r
+                }\r
+                leaf idle-timeout {\r
+                    type uint16;\r
+                }\r
+                leaf hard-timeout {\r
+                    type uint16;\r
+                }\r
+                leaf priority {\r
+                    type uint16;\r
+                }\r
+                leaf buffer-id {\r
+                    type uint32;\r
+                }\r
+                leaf out-port {\r
+                    type oft:port-number;\r
+                }\r
+                leaf out-group {\r
+                    type uint32;\r
+                }\r
+                leaf flags {\r
+                    type uint16;\r
+                }\r
+                //TODO:: add match leaf\r
+            } \r
+            grouping group-mod {\r
+                // reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                \r
+                uses ofHeader;\r
+                \r
+                leaf command {\r
+                    type oft:group-mod-command;\r
+                }\r
+                leaf type {\r
+                    type oft:group-type;\r
+                }\r
+                leaf group-id {\r
+                    type uint32;\r
+                }\r
+                \r
+                list buckets {\r
+                    uses bucket;\r
+                }\r
+            }\r
+            grouping bucket {\r
+                leaf weight {\r
+                    type uint16;\r
+                }\r
+                leaf watch-port {\r
+                    type oft:port-number;\r
+                }\r
+                leaf watch-group {\r
+                    type uint32;\r
+                }\r
+                \r
+                list actions {\r
+                    uses ofaction:action-header;\r
+                }\r
+            }\r
+            grouping port-mod {\r
+                // reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+\r
+                uses ofHeader;\r
+                \r
+                leaf port-no {\r
+                    type oft:port-number;\r
+                }\r
+                leaf hw-address {\r
+                    type yang:mac-address;\r
+                }       \r
+                leaf config {\r
+                    type oft:port-config;\r
+                }   \r
+                leaf mask {\r
+                    type oft:port-config;\r
+                }  \r
+                leaf advertise {\r
+                    type oft:port-features;\r
+                }\r
+            } \r
+            grouping table-mod {\r
+                // reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+\r
+                uses ofHeader;\r
+                \r
+                leaf table-id {\r
+                    type oft:table-id;\r
+                }\r
+                leaf config {\r
+                    type oft:port-config;\r
+                }                \r
+            } \r
+            \r
+        /* Multipart messages. */\r
+            grouping multipart-request {\r
+                // reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+\r
+                uses ofHeader;\r
+                \r
+                leaf type {\r
+                    type oft:multipart-type;\r
+                }          \r
+                leaf flags {\r
+                    type oft:multipart-request-flags;\r
+                }      \r
+                choice multipart-request-body {\r
+                    case multipart-request-flow {\r
+                        leaf table-id {\r
+                            type uint8;\r
+                        }\r
+                        leaf out-port {\r
+                            type uint32;\r
+                        }\r
+                        leaf out-group {\r
+                            type uint32;\r
+                        }\r
+                        leaf cookie {\r
+                            type uint64;\r
+                        }\r
+                        leaf cookie-mask {\r
+                            type uint64;\r
+                        }\r
+                        leaf match {\r
+                            type identityref {\r
+                                base oft:match-type-base;\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-request-aggregate {\r
+                        leaf table-id {\r
+                            type uint8;\r
+                        }\r
+                        leaf out-port {\r
+                            type uint32;\r
+                        }\r
+                        leaf out-group {\r
+                            type uint32;\r
+                        }\r
+                        leaf cookie {\r
+                            type uint64;\r
+                        }\r
+                        leaf cookie-mask {\r
+                            type uint64;\r
+                        }\r
+                        leaf match {\r
+                            type identityref {\r
+                                base oft:match-type-base;\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-request-port-stats {\r
+                        leaf port-no {\r
+                            type uint32;\r
+                        }\r
+                    }\r
+                    case multipart-request-queue {\r
+                        leaf port-no {\r
+                            type uint32;\r
+                        }\r
+                        leaf queue-id {\r
+                            type uint32;\r
+                        }\r
+                    }\r
+                    case multipart-request-group {\r
+                        leaf group-id {\r
+                            type uint32;\r
+                        }\r
+                    }\r
+                    case multipart-request-meter {\r
+                        leaf meter-id {\r
+                            type uint32;\r
+                        }\r
+                    }\r
+                    case multipart-request-meter-config {\r
+                        leaf meter-id {\r
+                            type uint32;\r
+                        }\r
+                    }\r
+                    case multipart-request-table-features {\r
+                        list table_features {\r
+                            leaf table-id {\r
+                                type uint8;\r
+                            }\r
+                            leaf name {\r
+                                type string;\r
+                            }\r
+                            leaf metadata-match {\r
+                                type uint64;\r
+                            }\r
+                            leaf metadata-write {\r
+                                type uint64;\r
+                            }\r
+                            leaf config {\r
+                                type oft:table-config;\r
+                            }\r
+                            leaf max-entries {\r
+                                type uint32;\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-request-experimenter {\r
+                        leaf experimenter {\r
+                            type uint32;\r
+                        }\r
+                        leaf exp-type {\r
+                            type uint32;\r
+                        }\r
+                    }\r
+                }\r
+            } \r
+            grouping multipart-reply {\r
+                // reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+\r
+                uses ofHeader;\r
+                \r
+                leaf type {\r
+                    type oft:multipart-type;\r
+                }\r
+                leaf flags {\r
+                    type oft:multipart-request-flags;\r
+                }\r
+                choice multipart-reply-body {\r
+                    case multipart-reply-desc {\r
+                        leaf mfr_desc {\r
+                            type string;\r
+                        }\r
+                        leaf hw_desc {\r
+                            type string;\r
+                        }\r
+                        leaf sw_desc {\r
+                            type string;\r
+                        }\r
+                        leaf serial_num {\r
+                            type string;\r
+                        }\r
+                        leaf dp_desc {\r
+                            type string;\r
+                        }\r
+                    }\r
+                    case multipart-reply-flow {\r
+                        list flow-stats {\r
+                            leaf table-id {\r
+                                type uint8;\r
+                            }\r
+                            leaf duration-sec {\r
+                                type uint32;\r
+                            }\r
+                            leaf duration-nsec {\r
+                                type uint32;\r
+                            }\r
+                            leaf priority {\r
+                                type uint16;\r
+                            }\r
+                            leaf idle-timeout {\r
+                                type uint16;\r
+                            }\r
+                            leaf hard-timeout {\r
+                                type uint16;\r
+                            }\r
+                            leaf flags {\r
+                                type uint16;\r
+                            }\r
+                            leaf cookie {\r
+                                type uint64;\r
+                            }\r
+                            leaf packet-count {\r
+                                type uint64;\r
+                            }\r
+                            leaf byte-count {\r
+                                type uint64;\r
+                            }\r
+                            leaf match {\r
+                                type uint64;\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-reply-aggregate {\r
+                        leaf packet-count {\r
+                            type uint64;\r
+                        }\r
+                        leaf byte-count {\r
+                            type uint64;\r
+                        }\r
+                        leaf flow-count {\r
+                            type uint32;\r
+                        }\r
+                    }\r
+                    case multipart-reply-table {\r
+                        list table-stats {\r
+                            leaf table-id {\r
+                                type uint8;\r
+                            }\r
+                            leaf active-count {\r
+                                type uint32;\r
+                            }\r
+                            leaf lookup-count {\r
+                                type uint64;\r
+                            }\r
+                            leaf matched-count {\r
+                                type uint64;\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-reply-port-stats {\r
+                        list port-stats {\r
+                            leaf port-no {\r
+                                type uint32;\r
+                            }\r
+                            leaf rx-packets {\r
+                                type uint64;\r
+                            }\r
+                            leaf tx-packets {\r
+                                type uint64;\r
+                            }\r
+                            leaf rx-bytes {\r
+                                type uint64;\r
+                            }\r
+                            leaf tx-bytes {\r
+                                type uint64;\r
+                            }\r
+                            leaf rx-dropped {\r
+                                type uint64;\r
+                            }\r
+                            leaf tx-dropped {\r
+                                type uint64;\r
+                            }\r
+                            leaf rx-errors {\r
+                                type uint64;\r
+                            }\r
+                            leaf tx-errors {\r
+                                type uint64;\r
+                            }\r
+                            leaf rx-frame-err {\r
+                                type uint64;\r
+                            }\r
+                            leaf rx-over-err {\r
+                                type uint64;\r
+                            }\r
+                            leaf rx-crc-err {\r
+                                type uint64;\r
+                            }\r
+                            leaf collisions {\r
+                                type uint64;\r
+                            }\r
+                            leaf duration-sec {\r
+                                type uint32;\r
+                            }\r
+                            leaf duration-nsec {\r
+                                type uint32;\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-reply-queue {\r
+                        list queue-stats {\r
+                            leaf port-no {\r
+                                type uint32;\r
+                            }\r
+                            leaf queue-id {\r
+                                type uint32;\r
+                            }\r
+                            leaf tx-bytes {\r
+                                type uint64;\r
+                            }\r
+                            leaf tx-packets {\r
+                                type uint64;\r
+                            }\r
+                            leaf tx-errors {\r
+                                type uint64;\r
+                            }\r
+                            leaf duration-sec {\r
+                                type uint32;\r
+                            }\r
+                            leaf duration-nsec {\r
+                                type uint32;\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-reply-group {\r
+                        list group-stats {\r
+                            leaf group-id {\r
+                                type uint32;\r
+                            }\r
+                            leaf ref-count {\r
+                                type uint32;\r
+                            }\r
+                            leaf packet-count {\r
+                                type uint64;\r
+                            }\r
+                            leaf byte-count {\r
+                                type uint64;\r
+                            }\r
+                            leaf duration-sec {\r
+                                type uint32;\r
+                            }\r
+                            leaf duration-nsec {\r
+                                type uint32;\r
+                            }\r
+                            list bucket-stats {\r
+                                leaf packet-count {\r
+                                    type uint64;\r
+                                }\r
+                                leaf byte-count {\r
+                                    type uint64;\r
+                                }\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-reply-group-desc {\r
+                        list group-desc {\r
+                            leaf type {\r
+                                type uint8;\r
+                            }\r
+                            leaf group-id {\r
+                                type uint32;\r
+                            }\r
+                            list buckets {\r
+                                uses bucket;\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-reply-group-features {\r
+                        leaf types {\r
+                            type oft:group-types;\r
+                        }\r
+                        leaf capabilities {\r
+                            type oft:group-capabilities;\r
+                        }\r
+                        leaf-list max_groups {\r
+                            type uint32;\r
+                        }\r
+                        leaf-list actions {\r
+                            type ofaction:action-type;\r
+                        }\r
+                    }\r
+                    case multipart-reply-meter {\r
+                        list meter-stats {\r
+                            leaf meter-id {\r
+                                type uint32;\r
+                            }\r
+                            leaf flow-count {\r
+                                type uint32;\r
+                            }\r
+                            leaf packet-in-count {\r
+                                type uint64;\r
+                            }\r
+                            leaf byte-in-count {\r
+                                type uint64;\r
+                            }\r
+                            leaf duration-sec {\r
+                                type uint32;\r
+                            }\r
+                            leaf duration-nsec {\r
+                                type uint32;\r
+                            }\r
+                            list meter-band-stats {\r
+                                leaf packet-band-count {\r
+                                    type uint64;\r
+                                }\r
+                                leaf byte-band-count {\r
+                                    type uint64;\r
+                                }\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-reply-meter-config {\r
+                        list meter-config {\r
+                            leaf flags {\r
+                                type oft:meter-mod-command;\r
+                            }\r
+                            leaf meter-id {\r
+                                type uint32;\r
+                            }\r
+                            list bands {\r
+                                uses meter-band-header;\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-reply-meter-features {\r
+                        leaf max-meter {\r
+                            type uint32;\r
+                        }\r
+                        leaf band-types {\r
+                            type oft:meter-band-type;\r
+                        }\r
+                        leaf capabilities {\r
+                            type oft:meter-flags;\r
+                        }\r
+                        leaf max-bands {\r
+                            type uint8;\r
+                        }\r
+                        leaf max-color {\r
+                            type uint8;\r
+                        }\r
+                    }\r
+                    case multipart-reply-table-features {\r
+                        list table-features {\r
+                            leaf table-id {\r
+                                type uint8;\r
+                            }\r
+                            leaf name {\r
+                                type string;\r
+                            }\r
+                            leaf metadata-match {\r
+                                type binary;\r
+                            }\r
+                            leaf metadata-write {\r
+                                type binary;\r
+                            }\r
+                            leaf config {\r
+                                type oft:port-config;\r
+                            } \r
+                            leaf max-entries {\r
+                                type uint32;\r
+                            }\r
+                        }\r
+                    }\r
+                    case multipart-reply-port-desc {\r
+                        list ports {\r
+                            uses port;\r
+                        }\r
+                    }\r
+                    case multipart-reply-experimenter {\r
+                        leaf experimenter {\r
+                            type uint32;\r
+                        }\r
+                        leaf exp-type {\r
+                            type uint32;\r
+                        }\r
+                    }\r
+                }\r
+            } \r
+            /* Barrier messages. */\r
+            grouping barrier-request {\r
+                // reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                uses ofHeader;\r
+            } \r
+            grouping barrier-reply {\r
+                // reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                uses ofHeader;\r
+            } \r
+        /* Queue Configuration messages. */\r
+            grouping queue-get-config-request {\r
+                // reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                \r
+                uses ofHeader;\r
+                \r
+                leaf port {\r
+                    type oft:port-number;\r
+                }\r
+            } \r
+            grouping queue-get-config-reply {\r
+                // reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+\r
+                uses ofHeader;\r
+                \r
+                leaf port {\r
+                    type oft:port-number;\r
+                }\r
+                list queues {\r
+                    uses packet-queue;\r
+                }\r
+            } \r
+            grouping packet-queue {\r
+                leaf queue-id {\r
+                    type oft:queue-id;\r
+                }\r
+                leaf port {\r
+                    type oft:port-number;\r
+                }\r
+                list properties {\r
+                    uses queue-property-header;\r
+                }\r
+            }\r
+            grouping queue-property-header {\r
+                leaf property {\r
+                    type oft:queue-property;\r
+                }\r
+            }\r
+            /* Controller role change request messages. */\r
+            grouping role-request {\r
+                // reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                \r
+                uses ofHeader;\r
+                \r
+                leaf role {\r
+                    type oft:controller-role;\r
+                }\r
+                leaf generation-id {\r
+                    type uint64;\r
+                }\r
+            } \r
+            grouping role-reply {\r
+                // reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+\r
+                uses ofHeader;\r
+                \r
+                leaf role {\r
+                    type oft:controller-role;\r
+                }\r
+                leaf generation-id {\r
+                    type uint64;\r
+                }\r
+            } \r
+            /* Asynchronous message configuration. */\r
+            grouping get-async-request {\r
+                // reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+\r
+                uses ofHeader;                \r
+            } \r
+            grouping get-async-reply {\r
+                // reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+\r
+                uses ofHeader;\r
+                \r
+                list packet-in-mask {\r
+                    leaf-list mask {\r
+                        type oft:packet-in-reason;\r
+                    }\r
+                }\r
+                list port-status-mask {\r
+                    leaf-list mask {\r
+                        type oft:port-reason;\r
+                    }\r
+                }\r
+                list flow-removed-mask {\r
+                    leaf-list mask {\r
+                        type oft:flow-removed-reason;\r
+                    }\r
+                }\r
+            } \r
+            grouping set-async {\r
+                // reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+                \r
+                uses ofHeader;\r
+                \r
+                leaf-list packet-in-mask {\r
+                    type oft:packet-in-reason;\r
+                }\r
+                leaf-list port-status-mask {\r
+                    type oft:port-reason;\r
+                }\r
+                leaf-list flow-removed-mask {\r
+                    type oft:flow-removed-reason;\r
+                }\r
+            } \r
+            /* Meters and rate limiters configuration messages. */\r
+            grouping meter-mod {\r
+                // reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"\r
+                /* Controller/switch message */\r
+\r
+                uses ofHeader;\r
+                \r
+                leaf command {\r
+                    type oft:meter-mod-command;\r
+                } \r
+                leaf flags {\r
+                    type oft:meter-flags;\r
+                }            \r
+                leaf meter-id {\r
+                    type oft:meter-id;\r
+                }   \r
+                list bands {\r
+                    uses meter-band-header;\r
+                }\r
+            } \r
+            \r
+            grouping meter-band-header {\r
+                leaf type {\r
+                    type oft:meter-band-type;\r
+                }\r
+                leaf rate {\r
+                    type uint32;\r
+                }\r
+                leaf burst-size {\r
+                    type uint32;\r
+                }\r
+            }\r
+\r
+\r
+\r
+                /* Immutable messages. */\r
+            notification hello-message {\r
+                uses hello;\r
+                // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"\r
+                \r
+                /* Symmetric message */\r
+            }\r
+            notification error-message {\r
+                uses error;\r
+                // reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"\r
+                \r
+                /* Symmetric message */\r
+            }\r
+            notification echo-request-message {\r
+                uses echo-request;\r
+                // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"\r
+                \r
+                /* Symmetric message */\r
+            }\r
+            notification experimenter-message {\r
+                uses experimenter;\r
+                // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"\r
+                // TODO:: does switch send this when understood experimenter msg from lib?\r
+                /* Symmetric message */\r
+            }\r
+    // # Notification and RPCs\r
+        /* Symmetric RPC. */\r
+            rpc echo {\r
+                // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"\r
+                input {\r
+                    uses echo-request;\r
+                }\r
+                /* Controller/switch message */\r
+                output {\r
+                    uses echo-reply;\r
+                }\r
+            }\r
+            \r
+            rpc echo-reply {\r
+                // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"\r
+                input {\r
+                    uses echo-reply;\r
+                }\r
+            }\r
+            \r
+            rpc hello {\r
+                // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"\r
+                input {\r
+                    uses hello;\r
+                }\r
+            }\r
+            \r
+            rpc experimenter {\r
+                // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"\r
+                input {\r
+                    uses experimenter;\r
+                }\r
+            }\r
+\r
+        /* Switch configuration messages. */\r
+            rpc get-features {\r
+                // reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"\r
+                input {\r
+                    uses features-request;\r
+                }\r
+                /* Controller/switch message */\r
+                output {\r
+                    uses features-reply;\r
+                }\r
+            }\r
+            \r
+            rpc get-config {\r
+                // reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"\r
+                input {\r
+                    uses get-config-request;\r
+                }\r
+                output {\r
+                    uses get-config-reply;\r
+                }\r
+                /* Controller/switch message */\r
+            }\r
+            \r
+            rpc set-config {\r
+                // reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"\r
+                input {\r
+                    uses set-config;\r
+                }   \r
+                /* Controller/switch message */\r
+            }\r
+        /* Asynchronous messages. */\r
+            notification packet-in-message {\r
+                uses packet-in;\r
+                // reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"\r
+                \r
+             /* Async message */\r
+            }\r
+            notification flow-removed-message {\r
+                uses flow-removed;\r
+                // reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"\r
+                \r
+                /* Async message */\r
+            } \r
+            notification port-status-message {\r
+                uses port-status;\r
+                // reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"\r
+                \r
+            } /* Async message */\r
+\r
+        /* Controller command messages. */\r
+            rpc packet-out {\r
+                input {\r
+                    uses packet-out;\r
+                    // reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"\r
+                }\r
+                /* Controller/switch message */\r
+            } \r
+            rpc flow-mod {\r
+                input {\r
+                    uses flow-mod;\r
+                    // reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"\r
+                }\r
+                /* Controller/switch message */\r
+            } \r
+            rpc group-mod {\r
+                input {\r
+                    uses group-mod;\r
+                    // reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"\r
+                }\r
+                /* Controller/switch message */\r
+            } \r
+            rpc port-mod {\r
+                input {\r
+                    uses port-mod;\r
+                    // reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"\r
+                }\r
+            } /* Controller/switch message */\r
+            \r
+            rpc table-mod {\r
+                input {\r
+                    uses table-mod;\r
+                    // reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"\r
+                }\r
+            } /* Controller/switch message */\r
+\r
+        /* Multipart messages. */\r
+            //FIXME: Arent this wire protocol specific?\r
+\r
+            notification multipart-request-message {\r
+                uses multipart-request;\r
+                // reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"\r
+                \r
+            } /* Controller/switch message */\r
+            notification multipart-reply-message {\r
+                uses multipart-reply;\r
+                // reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"\r
+                \r
+            } /* Controller/switch message */\r
+            \r
+\r
+            /* Barrier messages. */\r
+            rpc barrier {\r
+                input {\r
+                    uses barrier-request;\r
+                    // reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"\r
+                }\r
+                output {\r
+                    uses barrier-reply;\r
+                    // reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"\r
+                }\r
+            }\r
+        /* Queue Configuration messages. */\r
+            rpc get-queue-config {\r
+                input {\r
+                    uses queue-get-config-request;\r
+                    // reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"\r
+                }\r
+                output {\r
+                    uses queue-get-config-reply;\r
+                    // reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"\r
+                }\r
+            } \r
+\r
+        /* Controller role change request messages. */\r
+            rpc role-request {\r
+                input {\r
+                    uses role-request;\r
+                    // reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"\r
+                }\r
+                output {\r
+                    uses role-reply;\r
+                    // reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"\r
+                }\r
+            } /* Controller/switch message */\r
+            \r
+        /* Asynchronous message configuration. */\r
+            rpc get-async {\r
+                input {\r
+                    uses get-async-request;\r
+                    // reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"\r
+                }\r
+                output {\r
+                    uses get-async-reply;\r
+                    // reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"\r
+                }\r
+            } \r
+             /* Controller/switch message */\r
+            rpc set-async {\r
+                input { \r
+                    uses set-async;\r
+                // reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"\r
+                }\r
+                \r
+            } \r
+        /* Meters and rate limiters configuration messages. */\r
+            rpc meter-mod {\r
+                input {\r
+                    uses meter-mod;\r
+                    // reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"\r
+                }\r
+            } /* Controller/switch message */\r
 }
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java
new file mode 100644 (file)
index 0000000..15d989b
--- /dev/null
@@ -0,0 +1,49 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;\r
+\r
+/**\r
+ * @author timotej.kubas\r
+ * @author michal.polkorab\r
+ */\r
+public class GetAsyncRequestMessageFactory implements OFSerializer<GetAsyncInput> {\r
+    private static final byte MESSAGE_TYPE = 26;\r
+    private static final int MESSAGE_LENGTH = 8;\r
+    private static GetAsyncRequestMessageFactory instance;\r
+    \r
+    private GetAsyncRequestMessageFactory() {\r
+        // singleton\r
+    }\r
+    \r
+    /**\r
+     * @return singleton factory\r
+     */\r
+    public static GetAsyncRequestMessageFactory getInstance() {\r
+        if (instance == null) {\r
+            instance = new GetAsyncRequestMessageFactory();\r
+        }\r
+        return instance;\r
+    }\r
+    \r
+    @Override\r
+    public void messageToBuffer(short version, ByteBuf out,\r
+            GetAsyncInput message) {\r
+        ByteBufUtils.writeOFHeader(instance, message, out);\r
+    }\r
+    \r
+    @Override\r
+    public int computeLength() {\r
+        return MESSAGE_LENGTH;\r
+    }\r
+    \r
+    @Override\r
+    public byte getMessageType() {\r
+        return MESSAGE_TYPE;\r
+    }\r
+\r
+}\r
index 36842d660b6697a4a1a23a9731a345621e6972a2..69cd51476f618494d29c4a4203eb7b8fc4707ade 100644 (file)
@@ -15,7 +15,7 @@ public class PacketOutInputMessageFactory implements OFSerializer<PacketOutInput
 \r
     /** Code type of PacketOut message */\r
     public static final byte MESSAGE_TYPE = 13;\r
-    private static final int MESSAGE_LENGTH = 8;\r
+    private static final int MESSAGE_LENGTH = 30;\r
     private static final byte PADDING_IN_PACKET_OUT_MESSAGE = 6;\r
     private static PacketOutInputMessageFactory instance;\r
     \r
@@ -39,9 +39,11 @@ public class PacketOutInputMessageFactory implements OFSerializer<PacketOutInput
         ByteBufUtils.writeOFHeader(instance, message, out);\r
         out.writeInt(message.getBufferId().intValue());\r
         out.writeInt(message.getInPort().getValue().intValue());\r
+        ByteBufUtils.padBuffer(PADDING_IN_PACKET_OUT_MESSAGE, out);\r
         // TODO - finish implementation after Action serialization is done\r
         //out.writeShort(message.getActions().size());\r
-        ByteBufUtils.padBuffer(PADDING_IN_PACKET_OUT_MESSAGE, out);\r
+        // TODO - data field is not clearly defined\r
+        \r
        \r
     }\r
 \r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java
new file mode 100644 (file)
index 0000000..f871df3
--- /dev/null
@@ -0,0 +1,104 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;\r
+\r
+/**\r
+ * @author timotej.kubas\r
+ * @author michal.polkorab\r
+ */\r
+public class PortModInputMessageFactory implements OFSerializer<PortModInput> {\r
+    private static final byte MESSAGE_TYPE = 16;\r
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_01 = 4;\r
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2;\r
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4;\r
+    private static final int MESSAGE_LENGTH = 40;\r
+    private static PortModInputMessageFactory instance;\r
+    \r
+    private PortModInputMessageFactory() {\r
+        // singleton\r
+    }\r
+    \r
+    /**\r
+     * @return singleton factory\r
+     */\r
+    public static PortModInputMessageFactory getInstance() {\r
+        if (instance == null) {\r
+            instance = new PortModInputMessageFactory();\r
+        }\r
+        return instance;\r
+    }\r
+    \r
+    @Override\r
+    public void messageToBuffer(short version, ByteBuf out, PortModInput message) {\r
+        ByteBufUtils.writeOFHeader(instance, message, out);\r
+        out.writeInt(message.getPortNo().getValue().intValue());\r
+        ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_01, out);\r
+        out.writeBytes(ByteBufUtils.hexStringToBytes(message.getHwAddress().getValue(), false));\r
+        ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_02, out);\r
+        out.writeInt(createPortConfigBitmask(message.getConfig()));\r
+        out.writeInt(createPortConfigBitmask(message.getMask()));\r
+        out.writeInt(createPortFeaturesBitmask(message.getAdvertise()));\r
+        ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_03, out);\r
+    }\r
+\r
+    @Override\r
+    public int computeLength() {\r
+        return MESSAGE_LENGTH;\r
+    }\r
+\r
+    @Override\r
+    public byte getMessageType() {\r
+        return MESSAGE_TYPE;\r
+    }\r
+   \r
+    \r
+    /**\r
+     * @param config\r
+     * @return port config bitmask \r
+     */\r
+    private static int createPortConfigBitmask(PortConfig config) {\r
+        int configBitmask = 0;\r
+        Map<Integer, Boolean> portConfigMap = new HashMap<>();\r
+        portConfigMap.put(0, config.isPortDown());\r
+        portConfigMap.put(2, config.isNoRecv());\r
+        portConfigMap.put(5, config.isNoFwd());\r
+        portConfigMap.put(6, config.isNoPacketIn());\r
+        \r
+        configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);\r
+        return configBitmask;\r
+    }\r
+    \r
+    private static int createPortFeaturesBitmask(PortFeatures feature) {\r
+        int configBitmask = 0;\r
+        Map<Integer, Boolean> portFeaturesMap = new HashMap<>();\r
+        portFeaturesMap.put(0, feature.is_10mbHd());\r
+        portFeaturesMap.put(1, feature.is_10mbFd());\r
+        portFeaturesMap.put(2, feature.is_100mbHd());\r
+        portFeaturesMap.put(3, feature.is_100mbFd());\r
+        portFeaturesMap.put(4, feature.is_1gbHd());\r
+        portFeaturesMap.put(5, feature.is_1gbFd());\r
+        portFeaturesMap.put(6, feature.is_10gbFd());\r
+        portFeaturesMap.put(7, feature.is_40gbFd());\r
+        portFeaturesMap.put(8, feature.is_100gbFd());\r
+        portFeaturesMap.put(9, feature.is_1tbFd());\r
+        portFeaturesMap.put(10, feature.isOther());\r
+        portFeaturesMap.put(11, feature.isCopper());\r
+        portFeaturesMap.put(12, feature.isFiber());\r
+        portFeaturesMap.put(13, feature.isAutoneg());\r
+        portFeaturesMap.put(14, feature.isPause());\r
+        portFeaturesMap.put(15, feature.isPauseAsym());\r
+        \r
+        configBitmask = ByteBufUtils.fillBitMaskFromMap(portFeaturesMap);\r
+        return configBitmask;\r
+    }\r
+}\r
index 04200d117f8aeda7af7f68e44d838042a2ad0d95..95d3ac9f8dc143e1dcee071c9856c707957dfd55 100644 (file)
@@ -15,7 +15,7 @@ public class RoleRequestInputMessageFactory implements OFSerializer<RoleRequestI
 \r
     /** Code type of RoleRequest message */\r
     public static final byte MESSAGE_TYPE = 24;\r
-    private static final int MESSAGE_LENGTH = 8;\r
+    private static final int MESSAGE_LENGTH = 24;\r
     private static final byte PADDING_IN_ROLE_REQUEST_MESSAGE = 4;\r
     private static RoleRequestInputMessageFactory instance;\r
     \r
index a5717cc1010ac4ff47de971086bab1ccba0c4db5..9d5bae483919391c7ad917839dd036175fb057c4 100644 (file)
@@ -15,7 +15,7 @@ public class SetConfigMessageFactory implements OFSerializer<SetConfigInput> {
 \r
     /** Code type of SetConfig message */\r
     public static final byte MESSAGE_TYPE = 9;\r
-    private static final int MESSAGE_LENGTH = 8;\r
+    private static final int MESSAGE_LENGTH = 12;\r
     private static SetConfigMessageFactory instance;\r
     \r
     private SetConfigMessageFactory() {\r
index 718d93d7b28d678e6fd57a06c8cc825cf8fa7533..52ac882a87a1a11b44d55f77a800a46393034511 100644 (file)
@@ -1,73 +1,71 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
-
-import io.netty.buffer.ByteBuf;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
-
-/**
- * @author timotej.kubas
- * @author michal.polkorab
- */
-public class TableModInputMessageFactory implements OFSerializer<TableModInput> {
-
-    private static final byte MESSAGE_TYPE = 17;
-    private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;
-    private static final int MESSAGE_LENGTH = 16;
-    private static TableModInputMessageFactory instance;
-    
-    private TableModInputMessageFactory() {
-        // just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static TableModInputMessageFactory getInstance() {
-        if(instance == null){
-            instance = new TableModInputMessageFactory();
-        }
-        return instance;
-    }
-    
-    @Override
-    public void messageToBuffer(short version, ByteBuf out, TableModInput message) {
-        
-        ByteBufUtils.writeOFHeader(instance, message, out);
-        out.writeByte(message.getTableId().getValue().byteValue());
-        ByteBufUtils.padBuffer(PADDING_IN_TABLE_MOD_MESSAGE, out);
-        out.writeInt(createConfigBitmask(message.getConfig()));
-    }
-
-    @Override
-    public int computeLength() {
-        return MESSAGE_LENGTH;
-    }
-
-    @Override
-    public byte getMessageType() {
-        return MESSAGE_TYPE;
-    }
-    
-    /**
-     * @param config
-     * @return port config bitmask 
-     */
-    private static int createConfigBitmask(PortConfig config) {
-        int configBitmask = 0;
-        Map<Integer, Boolean> portConfigMap = new HashMap<>();
-        portConfigMap.put(0, config.isPortDown());
-        portConfigMap.put(2, config.isNoRecv());
-        portConfigMap.put(5, config.isNoFwd());
-        portConfigMap.put(6, config.isNoPacketIn());
-        
-        configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);
-        return configBitmask;
-    }
-}
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;\r
+\r
+/**\r
+ * @author timotej.kubas\r
+ * @author michal.polkorab\r
+ */\r
+public class TableModInputMessageFactory implements OFSerializer<TableModInput> {\r
+    private static final byte MESSAGE_TYPE = 17;\r
+    private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;\r
+    private static final int MESSAGE_LENGTH = 16;\r
+    private static TableModInputMessageFactory instance;\r
+    \r
+    private TableModInputMessageFactory() {\r
+        // just singleton\r
+    }\r
+    \r
+    /**\r
+     * @return singleton factory\r
+     */\r
+    public static TableModInputMessageFactory getInstance() {\r
+        if(instance == null){\r
+            instance = new TableModInputMessageFactory();\r
+        }\r
+        return instance;\r
+    }\r
+    \r
+    @Override\r
+    public void messageToBuffer(short version, ByteBuf out, TableModInput message) {\r
+        ByteBufUtils.writeOFHeader(instance, message, out);\r
+        out.writeByte(message.getTableId().getValue().byteValue());\r
+        ByteBufUtils.padBuffer(PADDING_IN_TABLE_MOD_MESSAGE, out);\r
+        out.writeInt(createConfigBitmask(message.getConfig()));\r
+    }\r
+\r
+    @Override\r
+    public int computeLength() {\r
+        return MESSAGE_LENGTH;\r
+    }\r
+\r
+    @Override\r
+    public byte getMessageType() {\r
+        return MESSAGE_TYPE;\r
+    }\r
+    \r
+    /**\r
+     * @param config\r
+     * @return port config bitmask \r
+     */\r
+    private static int createConfigBitmask(PortConfig config) {\r
+        int configBitmask = 0;\r
+        Map<Integer, Boolean> portConfigMap = new HashMap<>();\r
+        portConfigMap.put(0, config.isPortDown());\r
+        portConfigMap.put(2, config.isNoRecv());\r
+        portConfigMap.put(5, config.isNoFwd());\r
+        portConfigMap.put(6, config.isNoPacketIn());\r
+        \r
+        configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);\r
+        return configBitmask;\r
+    }\r
+}\r
index a4fe74588199cf43aabef1a0e2210b6f3affe598..981ee7ce175efdd9b290a80519f4cad150e3fef7 100644 (file)
@@ -37,7 +37,22 @@ public abstract class ByteBufUtils {
      * @return byte[] filled with input data\r
      */\r
     public static byte[] hexStringToBytes(String hexSrc) {\r
-        String[] byteChips = hexSrc.split("\\s+");\r
+        return hexStringToBytes(hexSrc, true);\r
+    }\r
+    \r
+    /**\r
+     * Converts String into byte[]\r
+     * @param hexSrc input String\r
+     * @param withSpaces if there are spaces in string \r
+     * @return byte[] filled with input data\r
+     */\r
+    public static byte[] hexStringToBytes(String hexSrc, boolean withSpaces ) {\r
+        String splitPattern = "\\s+";\r
+        if (!withSpaces) {\r
+            splitPattern = "(?<=\\G.{2})";\r
+        }\r
+        \r
+        String[] byteChips = hexSrc.split(splitPattern);\r
         byte[] result = new byte[byteChips.length];\r
         for (int i = 0; i < byteChips.length; i++) {\r
             result[i] = (byte) Short.parseShort(byteChips[i], 16);\r
index 0f2a54199db5c97f1770b7a8ca834346d47925ef..05dd292a8b0d04a0f53d09835ad5515f88c4a0a5 100644 (file)
@@ -18,12 +18,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * @author michal.polkorab
  */
 public class GetQueueConfigInputMessageFactoryTest {
-
     private static final byte GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE = 22;
     private static final byte PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE = 4;
     
+    /**
+     * Testing of {@link GetQueueConfigInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
     @Test
-    public void testWithElements() throws Exception {
+    public void testGetQueueConfigInputMessage() throws Exception {
         GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
         BufferHelper.setupHeader(builder);
         builder.setPort(new PortNumber(0x00010203L));
@@ -37,5 +40,4 @@ public class GetQueueConfigInputMessageFactoryTest {
         Assert.assertEquals("Wrong port", 0x00010203, out.readUnsignedInt());
         out.skipBytes(PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE);
     }
-        
 }
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..902afdb
--- /dev/null
@@ -0,0 +1,37 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.buffer.UnpooledByteBufAllocator;\r
+\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInputBuilder;\r
+\r
+/**\r
+ * @author timotej.kubas\r
+ * @author michal.polkorab\r
+ */\r
+public class GetaAsyncRequestMessageFactoryTest {\r
+    private static final byte MESSAGE_TYPE = 26;\r
+    private static final int MESSAGE_LENGTH = 8;\r
+    \r
+    /**\r
+     * Testing of {@link GetaAsyncRequestMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void testGetaAsyncReques() throws Exception {\r
+        GetAsyncInputBuilder builder = new GetAsyncInputBuilder();\r
+        BufferHelper.setupHeader(builder);\r
+        GetAsyncInput message = builder.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        GetAsyncRequestMessageFactory factory = GetAsyncRequestMessageFactory.getInstance();\r
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
+        \r
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..348a77d
--- /dev/null
@@ -0,0 +1,47 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.buffer.UnpooledByteBufAllocator;\r
+import junit.framework.Assert;\r
+\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;\r
+\r
+/**\r
+ * @author timotej.kubas\r
+ *\r
+ */\r
+public class PacketOutInputMessageFactoryTest {\r
+    private static final byte MESSAGE_TYPE = 13;\r
+    private static final int MESSAGE_LENGTH = 30;\r
+    private static final byte PADDING_IN_PACKET_OUT_MESSAGE = 6;\r
+       \r
+    /**\r
+     * Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void testPacketOutInputMessage() throws Exception {\r
+        PacketOutInputBuilder builder = new PacketOutInputBuilder();\r
+        BufferHelper.setupHeader(builder);\r
+        builder.setBufferId(256L);\r
+        builder.setInPort(new PortNumber(256L));\r
+        PacketOutInput message = builder.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        PacketOutInputMessageFactory factory = PacketOutInputMessageFactory.getInstance();\r
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
+        \r
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
+        Assert.assertEquals("Wrong BufferId", message.getBufferId().longValue(), out.readUnsignedInt());\r
+        Assert.assertEquals("Wrong PortNumber", message.getInPort().getValue().longValue(), out.readUnsignedInt());\r
+        // TODO make test for actions after its implementation in factory \r
+        // TODO data\r
+        out.skipBytes(PADDING_IN_PACKET_OUT_MESSAGE);\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..6a65703
--- /dev/null
@@ -0,0 +1,102 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.buffer.UnpooledByteBufAllocator;\r
+import junit.framework.Assert;\r
+\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;\r
+\r
+/**\r
+ * @author timotej.kubas\r
+ * @author michal.polkorab\r
+ */\r
+public class PortModInputMessageFactoryTest {\r
+    private static final byte MESSAGE_TYPE = 16;\r
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_01 = 4;\r
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2;\r
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4;\r
+    private static final int MESSAGE_LENGTH = 40;\r
+    \r
+    /**\r
+     * Testing of {@link PortModInputMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void testPortModInput() throws Exception {\r
+        PortModInputBuilder builder = new PortModInputBuilder();\r
+        BufferHelper.setupHeader(builder);\r
+        builder.setPortNo(new PortNumber(9L));\r
+        builder.setHwAddress(new MacAddress("08002700B0EB"));\r
+        builder.setConfig(new PortConfig(true, false, true, false));\r
+        builder.setMask(new PortConfig(false, true, false, true));\r
+        builder.setAdvertise(new PortFeatures(true, false, false, false,\r
+                                              false, false, false, true, \r
+                                              false, false, false, false, \r
+                                              false, false, false, false));\r
+        PortModInput message = builder.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        PortModInputMessageFactory factory = PortModInputMessageFactory.getInstance();\r
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
+        \r
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
+        Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt());\r
+        out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01);\r
+        Assert.assertEquals("Wrong MacAddress", message.getHwAddress().getValue(), new MacAddress(makeMacAddress(out)).getValue());\r
+        out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_02);\r
+        Assert.assertEquals("Wrong config", message.getConfig(), createPortConfig(out.readInt()));\r
+        Assert.assertEquals("Wrong mask", message.getMask(), createPortConfig(out.readInt()));\r
+        Assert.assertEquals("Wrong advertise", message.getAdvertise(), createPortFeatures(out.readInt()));\r
+        out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_03);\r
+    }\r
+\r
+    private static PortConfig createPortConfig(long input){\r
+        final Boolean _portDown   = ((input) & 0x01) > 0;\r
+        final Boolean _noRecv    = ((input) & 0x04) > 0;\r
+        final Boolean _noFwd       = ((input) & 0x20) > 0;\r
+        final Boolean _noPacketIn = ((input) & 0x40) > 0;\r
+        return new PortConfig(_portDown, _noRecv, _noFwd, _noPacketIn);\r
+    }\r
+    \r
+    private static PortFeatures createPortFeatures(long input){\r
+        final Boolean _10mbHd = ((input) & 0x01) > 0;\r
+        final Boolean _10mbFd = ((input) & 0x02) > 0;\r
+        final Boolean _100mbHd = ((input) & 0x04) > 0;\r
+        final Boolean _100mbFd = ((input) & 0x08) > 0;\r
+        final Boolean _1gbHd = ((input) & 0x10) > 0;\r
+        final Boolean _1gbFd = ((input) & 0x20) > 0;\r
+        final Boolean _10gbFd = ((input) & 0x40) > 0;\r
+        final Boolean _40gbFd = ((input) & 0x80) > 0;\r
+        final Boolean _100gbFd = ((input) & 0x100) > 0;\r
+        final Boolean _1tbFd = ((input) & 0x200) > 0;\r
+        final Boolean _other = ((input) & 0x400) > 0;\r
+        final Boolean _copper = ((input) & 0x800) > 0;\r
+        final Boolean _fiber = ((input) & 0x1000) > 0;\r
+        final Boolean _autoneg = ((input) & 0x2000) > 0;\r
+        final Boolean _pause = ((input) & 0x4000) > 0;\r
+        final Boolean _pauseAsym = ((input) & 0x8000) > 0;\r
+        return new PortFeatures(_10mbHd, _10mbFd, _100mbHd, _100mbFd, _1gbHd, _1gbFd, _10gbFd,\r
+                _40gbFd, _100gbFd, _1tbFd, _other, _copper, _fiber, _autoneg, _pause, _pauseAsym);\r
+    }\r
+    \r
+    private static String makeMacAddress(ByteBuf input) {\r
+        final int macAddressLength = 6;\r
+        StringBuffer macToString = new StringBuffer();\r
+        \r
+        for(int i=0; i<macAddressLength; i++){\r
+            short mac = 0;\r
+            mac = input.readUnsignedByte();\r
+            macToString.append(String.format("%02X", mac));\r
+        }\r
+        return macToString.toString();\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..5e31fc5
--- /dev/null
@@ -0,0 +1,49 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.buffer.UnpooledByteBufAllocator;\r
+\r
+import java.math.BigInteger;\r
+\r
+import junit.framework.Assert;\r
+\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder;\r
+\r
+/**\r
+ * @author timotej.kubas\r
+ * @author michal.polkorab\r
+ */\r
+public class RoleRequestInputMessageFactoryTest {\r
+    private static final byte MESSAGE_TYPE = 24;\r
+    private static final int MESSAGE_LENGTH = 24;\r
+    private static final byte PADDING_IN_ROLE_REQUEST_MESSAGE = 4;\r
+    \r
+    /**\r
+     * Testing of {@link RoleRequestInputMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void testRoleRequestInputMessage() throws Exception {\r
+        RoleRequestInputBuilder builder = new RoleRequestInputBuilder();\r
+        BufferHelper.setupHeader(builder);\r
+        builder.setRole(ControllerRole.forValue(2));\r
+        byte[] generationId = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};\r
+        builder.setGenerationId(new BigInteger(generationId));\r
+        RoleRequestInput message = builder.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        RoleRequestInputMessageFactory factory = RoleRequestInputMessageFactory.getInstance();\r
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
+        \r
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
+        Assert.assertEquals("Wrong role", message.getRole().getIntValue(), ControllerRole.forValue((int) out.readUnsignedInt()).getIntValue());\r
+        out.skipBytes(PADDING_IN_ROLE_REQUEST_MESSAGE);\r
+        Assert.assertEquals("Wrong generation ID", message.getGenerationId().longValue(), out.readLong());\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..d501371
--- /dev/null
@@ -0,0 +1,43 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.buffer.UnpooledByteBufAllocator;\r
+import junit.framework.Assert;\r
+\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder;\r
+\r
+/**\r
+ * @author timotej.kubas\r
+ * @author michal.polkorab\r
+ */\r
+public class SetConfigMessageFactoryTest {\r
+    private static final byte MESSAGE_TYPE = 9;\r
+    private static final int MESSAGE_LENGTH = 12;\r
+    \r
+    /**\r
+     * Testing of {@link SetConfigMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void testSetConfigMessage() throws Exception {\r
+        SetConfigInputBuilder builder = new SetConfigInputBuilder();\r
+        BufferHelper.setupHeader(builder);\r
+        builder.setFlags(SwitchConfigFlag.forValue(0));\r
+        builder.setMissSendLen(10);\r
+        SetConfigInput message = builder.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        SetConfigMessageFactory factory = SetConfigMessageFactory.getInstance();\r
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
+        \r
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
+        Assert.assertEquals("Wrong flags", message.getFlags().getIntValue(),SwitchConfigFlag.forValue(out.readUnsignedShort()).getIntValue());\r
+        Assert.assertTrue("Wrong missSendLen", message.getMissSendLen() == out.readShort());\r
+    }\r
+}\r
index 463caf9deea0264fb5fdd9d7e4038ae953c5c2b1..ad17ce487355640eed2707732d56151587ab310a 100644 (file)
@@ -1,41 +1,45 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.UnpooledByteBufAllocator;
-import junit.framework.Assert;
-import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder;
-
-/**
- * @author timotej.kubas
- * @author michal.polkorab
- */
-public class TableModInputMessageFactoryTest {
-    
-    private static final byte MESSAGE_TYPE = 17;
-    private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;
-    
-    @Test
-    public void testTableModInput() throws Exception {
-        TableModInputBuilder builder = new TableModInputBuilder();
-        BufferHelper.setupHeader(builder);
-        builder.setTableId(new TableId(9L));
-        builder.setConfig(new PortConfig(true, false, true, false));
-        TableModInput message = builder.build();
-        
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
-        TableModInputMessageFactory factory = TableModInputMessageFactory.getInstance();
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
-        
-        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16);
-        Assert.assertEquals("Wrong TableID", 0x09, out.readByte());
-        out.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE);
-        Assert.assertEquals("Wrong PortConfig", 33, out.readInt());
-    }
-}
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.buffer.UnpooledByteBufAllocator;\r
+import junit.framework.Assert;\r
+\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder;\r
+\r
+/**\r
+ * @author timotej.kubas\r
+ * @author michal.polkorab\r
+ */\r
+public class TableModInputMessageFactoryTest {\r
+    private static final byte MESSAGE_TYPE = 17;\r
+    private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;\r
+    \r
+    /**\r
+     * Testing of {@link TableModInputMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void testTableModInput() throws Exception {\r
+        TableModInputBuilder builder = new TableModInputBuilder();\r
+        BufferHelper.setupHeader(builder);\r
+        builder.setTableId(new TableId(9L));\r
+        builder.setConfig(new PortConfig(true, false, true, false));\r
+        TableModInput message = builder.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        TableModInputMessageFactory factory = TableModInputMessageFactory.getInstance();\r
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
+        \r
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16);\r
+        Assert.assertEquals("Wrong TableID", 0x09, out.readByte());\r
+        out.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE);\r
+        Assert.assertEquals("Wrong PortConfig", 33, out.readInt());\r
+    }\r
+}\r
index b8919a8713a2795138771f0c03c007b2f82ebee0..34f00a179636f9a8f767d9d765d06d1c196de4c8 100644 (file)
@@ -4,6 +4,9 @@ package org.opendaylight.openflowjava.protocol.impl.util;
 import io.netty.buffer.ByteBuf;\r
 import io.netty.buffer.UnpooledByteBufAllocator;\r
 \r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
 import org.junit.Assert;\r
 import org.junit.Test;\r
 \r
@@ -19,17 +22,27 @@ public class ByteBufUtilsTest {
      * Test of {@link ByteBufUtils#hexStringToBytes(String)}\r
      */\r
     @Test\r
-    public void hexStringToBytesTest() {\r
+    public void testHexStringToBytes() {\r
         byte[] data = ByteBufUtils.hexStringToBytes("01 02 03 04 05 ff");\r
 \r
         Assert.assertArrayEquals(expected, data);\r
     }\r
     \r
+    /**\r
+     * Test of {@link ByteBufUtils#hexStringToBytes(String, boolean)}\r
+     */\r
+    @Test\r
+    public void testHexStringToBytes2() {\r
+        byte[] data = ByteBufUtils.hexStringToBytes("0102030405ff", false);\r
+\r
+        Assert.assertArrayEquals(expected, data);\r
+    }\r
+    \r
     /**\r
      * Test of {@link ByteBufUtils#hexStringToByteBuf(String)}\r
      */\r
     @Test\r
-    public void hexStringToByteBufTest() {\r
+    public void testHexStringToByteBuf() {\r
         ByteBuf bb = ByteBufUtils.hexStringToByteBuf("01 02 03 04 05 ff");\r
         \r
         Assert.assertArrayEquals(expected, byteBufToByteArray(bb));\r
@@ -39,7 +52,7 @@ public class ByteBufUtilsTest {
      * Test of {@link ByteBufUtils#hexStringToByteBuf(String, ByteBuf)}\r
      */\r
     @Test\r
-    public void hexStringToGivenByteBufTest() {\r
+    public void testHexStringToGivenByteBuf() {\r
         ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();\r
         ByteBufUtils.hexStringToByteBuf("01 02 03 04 05 ff", buffer);\r
 \r
@@ -51,5 +64,72 @@ public class ByteBufUtilsTest {
         bb.readBytes(result);\r
         return result;\r
     }\r
+    \r
+    /**\r
+     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}\r
+     */\r
+    @Test\r
+    public void testFillBitmaskByEmptyMap() {\r
+        Map<Integer, Boolean> emptyMap = new HashMap<>();\r
+        String expectedBinaryString = "00000000000000000000000000000000";\r
+        String bitmaskInBinaryString = toBinaryString(emptyMap, 32);\r
+        \r
+        Assert.assertEquals("Not null string", expectedBinaryString, bitmaskInBinaryString);\r
+    }\r
+\r
+    private String toBinaryString(Map<Integer, Boolean> emptyMap, int length) {\r
+        String binaryString = Integer.toBinaryString(ByteBufUtils.fillBitMaskFromMap(emptyMap));; \r
+        return String.format("%"+length+"s", binaryString).replaceAll(" ", "0");\r
+    }\r
+    \r
+    /**\r
+     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}\r
+     */\r
+    @Test\r
+    public void testFillBitmaskByFullMap() {\r
+        Map<Integer, Boolean> fullMap = new HashMap<>();\r
+        String expectedBinaryString = "11111111111111111111111111111111";\r
+        String bitmaskValueInBinarySytring;\r
+        for(Integer i=0;i<=31;i++) {\r
+            fullMap.put(i, true);\r
+        }\r
+        bitmaskValueInBinarySytring = toBinaryString(fullMap, 32);\r
+        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);\r
+    }\r
+    \r
+    /**\r
+     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}\r
+     */\r
+    @Test\r
+    public void testFillBitmaskByZeroMap() {\r
+        Map<Integer, Boolean> zeroMap = new HashMap<>();\r
+        String expectedBinaryString = "00000000000000000000000000000000";\r
+        String bitmaskValueInBinarySytring;\r
+        for(Integer i=0;i<=31;i++) {\r
+            zeroMap.put(i, false);\r
+        }\r
+        bitmaskValueInBinarySytring = toBinaryString(zeroMap, 32);\r
+        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);\r
+    }\r
+    \r
+    /**\r
+     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}\r
+     */\r
+    @Test\r
+    public void testFillBitmaskByRandomSet() {\r
+        Map<Integer, Boolean> randomMap = new HashMap<>();\r
+        String expectedBinaryString = "00000000000000000111100000000000";\r
+        String bitmaskValueInBinarySytring;\r
+        Boolean mapValue;\r
+        for(Integer i=0;i<=31;i++) {\r
+            mapValue = false;\r
+            if(i>=11 && i<=14) {\r
+                mapValue = true;\r
+            }\r
+            randomMap.put(i, mapValue);\r
+        }\r
+        bitmaskValueInBinarySytring = toBinaryString(randomMap, 32);\r
+        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);\r
+    }\r
 \r
 }\r