Error code support for ErrorMessage 04/3204/2
authorMichal Polkorab <michal.polkorab@pantheon.sk>
Thu, 28 Nov 2013 14:08:44 +0000 (15:08 +0100)
committerMichal Polkorab <michal.polkorab@pantheon.sk>
Fri, 29 Nov 2013 10:40:50 +0000 (11:40 +0100)
Removed duplicate factories
Global contants in EncodeConstants
Updated tests

Signed-off-by: Michal Polkorab <michal.polkorab@pantheon.sk>
Change-Id: Ib2c77a55c7997de135d1a5d974c6af0acddc1a2f

56 files changed:
openflow-protocol-api/src/main/yang/openflow-augments.yang
openflow-protocol-api/src/main/yang/openflow-protocol.yang
openflow-protocol-api/src/main/yang/openflow-types.yang
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DecoderTable.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/EncoderTable.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10EchoInputMessageFactory.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10EchoReplyInputMessageFactory.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesInputMessageFactory.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10GetConfigInputMessageFactory.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10SetConfigMessageFactory.java [deleted file]
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/util/ActionsSerializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EncodeConstants.java [moved from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EncodeConstants.java with 51% similarity]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchSerializer.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.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
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java
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/BufferHelper.java

index 3f8502a2cba38fb119d17005d7eba9ecb921e943..866acfe26f8971ec8997d71e39af599380ef192b 100644 (file)
@@ -373,4 +373,16 @@ module openflow-augments {
              type binary;\r
          }\r
      }\r
+     \r
+// OFP_ERROR_AUGMENTS (only experimenter till OpenFlow v1.3)\r
+    augment "/ofproto:error-message" {\r
+         ext:augment-identifier "experimenter-error";\r
+         leaf exp_type {\r
+             type uint16;\r
+         }\r
+         leaf experimenter {\r
+             type uint32;\r
+         }\r
+     }\r
+\r
 }
\ No newline at end of file
index cb1397d603d07d657c80a239ce363c6c6bd200b1..e4501ab1e8853b398c5c719c469c751250935c32 100644 (file)
@@ -183,18 +183,14 @@ module openflow-protocol {
                 uses ofHeader;\r
                 \r
                 leaf type {\r
-                    type oft:error-type;\r
+                    type string;\r
                 }\r
                 leaf code {\r
-                    type uint16;\r
+                    type string;\r
                 }\r
                 leaf data {\r
                     type binary; \r
                 }\r
-                // OF1.0 structures\r
-                leaf type-v10 {\r
-                    type oft:error-type-v10;\r
-                }\r
             }\r
             grouping echo-request {\r
                 // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"\r
@@ -542,7 +538,9 @@ module openflow-protocol {
                 }      \r
                 choice multipart-request-body {\r
                     case multipart-request-desc {\r
-                        // empty body\r
+                        leaf empty {\r
+                            type empty;\r
+                        }\r
                     }\r
                     case multipart-request-flow {\r
                         leaf table-id {\r
@@ -587,7 +585,9 @@ module openflow-protocol {
                         uses oxm:match-v10-grouping;\r
                     }\r
                     case multipart-request-table {\r
-                        // empty body\r
+                        leaf empty {\r
+                            type empty;\r
+                        }\r
                     }\r
                     case multipart-request-port-stats {\r
                         leaf port-no {\r
@@ -608,10 +608,14 @@ module openflow-protocol {
                         }\r
                     }\r
                     case multipart-request-group-desc {\r
-                        // empty body\r
+                        leaf empty {\r
+                            type empty;\r
+                        }\r
                     }\r
                     case multipart-request-group-features {\r
-                        // empty body\r
+                        leaf empty {\r
+                            type empty;\r
+                        }\r
                     }\r
                     case multipart-request-meter {\r
                         leaf meter-id {\r
@@ -624,7 +628,9 @@ module openflow-protocol {
                         }\r
                     }\r
                     case multipart-request-meter-features {\r
-                        // empty body\r
+                        leaf empty {\r
+                            type empty;\r
+                        }\r
                     }\r
                     case multipart-request-table-features {\r
                         list table-features {\r
@@ -650,7 +656,9 @@ module openflow-protocol {
                         }\r
                     }\r
                     case multipart-request-port-desc {\r
-                        // empty body\r
+                        leaf empty {\r
+                            type empty;\r
+                        }\r
                     }\r
                     case multipart-request-experimenter {\r
                         leaf experimenter {\r
index 732933ed7d76a683d987bc3d1276036d9f160535..3d09eaa1ab074d5ebe0d5d2242d2a2fd4fe20c62 100644 (file)
@@ -14,39 +14,30 @@ module openflow-types {
         type enumeration {
             enum MAX {
                 value -256; // 0xffffff00 
-                description "Hello Protocol failed.";
             }
             enum IN_PORT {
                 value -8; // 0xfffffff8
-                description "Request was not understood.";
             }
             enum TABLE {
                 value -7; // 0xfffffff9 
-                description "Error in action description.";
             }
             enum NORMAL {
                 value -6; // 0xfffffffa 
-                description "Error in instruction list.";
             }
             enum FLOOD {
                 value -5; // 0xfffffffb 
-                description "Error in match.";
             }
             enum ALL {
                 value -4; // 0xfffffffc 
-                description "Problem modifying flow entry.";
             }
             enum CONTROLLER {
                 value -3; // 0xfffffffd
-                description "Problem modifying group entry.";
             }
             enum LOCAL {
                 value -2; // 0xfffffffe
-                description "Port mod request failed.";
             }
             enum ANY {
                 value -1; // 0xffffffff
-                description "Table mod request failed.";
             }
         }
     }
@@ -277,7 +268,412 @@ module openflow-types {
             }
         }
     }
+    
+    typedef hello-failed-code {
+        type enumeration {
+            enum INCOMPATIBLE {
+                value 0; 
+                description "Hello Protocol failed.";
+            }
+            enum EPERM {
+                value 1; 
+                description "Request was not understood.";
+            }
+        }
+    }
+    
+    typedef bad-request-code {
+        type enumeration {
+            enum BAD_VERSION {
+                value 0; 
+            }
+            enum BAD_TYPE {
+                value 1; 
+            }
+            enum BAD_MULTIPART {
+                value 2; 
+            }
+            enum BAD_EXPERIMENTER {
+                value 3; 
+            }
+            enum BAD_EXP_TYPE {
+                value 4; 
+            }
+            enum EPERM {
+                value 5; 
+            }
+            enum BAD_LEN {
+                value 6; 
+            }
+            enum BUFFER_EMPTY {
+                value 7; 
+            }
+            enum BUFFER_UNKNOWN {
+                value 8; 
+            }
+            enum BAD_TABLE_ID {
+                value 9; 
+            }
+            enum IS_SLAVE {
+                value 10; 
+            }
+            enum BAD_PORT {
+                value 11; 
+            }
+            enum BAD_PACKET {
+                value 12; 
+            }
+            enum MULTIPART_BUFFER_OVERFLOW {
+                value 13; 
+            }
+        }
+    }
+    
+    typedef bad-action-code {
+        type enumeration {
+            enum BAD_TYPE {
+                value 0; 
+            }
+            enum BAD_LEN {
+                value 1; 
+            }
+            enum BAD_EXPERIMENTER {
+                value 2; 
+            }
+            enum BAD_EXP_TYPE {
+                value 3; 
+            }
+            enum BAD_OUT_PORT {
+                value 4; 
+            }
+            enum BAD_ARGUMENT {
+                value 5; 
+            }
+            enum EPERM {
+                value 6; 
+            }
+            enum TOO_MANY {
+                value 7; 
+            }
+            enum BAD_QUEUE {
+                value 8; 
+            }
+            enum BAD_OUT_GROUP {
+                value 9; 
+            }
+            enum MATCH_INCONSISTENT {
+                value 10; 
+            }
+            enum UNSUPPORTED_ORDER {
+                value 11; 
+            }
+            enum BAD_TAG {
+                value 12; 
+            }
+            enum BAD_SET_TYPE {
+                value 13; 
+            }
+            enum BAD_SET_LEN {
+                value 14; 
+            }
+            enum BAD_SET_ARGUMENT {
+                value 15; 
+            }
+        }
+    }
+    
+    typedef bad-instruction-code {
+        type enumeration {
+            enum UNKNOWN_INST {
+                value 0; 
+            }
+            enum UNSUP_INST {
+                value 1; 
+            }
+            enum BAD_TABLE_ID {
+                value 2; 
+            }
+            enum UNSUP_METADATA {
+                value 3; 
+            }
+            enum UNSUP_METADATA_MASK {
+                value 4; 
+            }
+            enum BAD_EXPERIMENTER {
+                value 5; 
+            }
+            enum BAD_EXP_TYPE {
+                value 6; 
+            }
+            enum BAD_LEN {
+                value 7; 
+            }
+            enum EPERM {
+                value 8; 
+            }
+        }
+    }
+    
+    typedef bad-match-code {
+        type enumeration {
+            enum BAD_TYPE {
+                value 0; 
+            }
+            enum BAD_LEN {
+                value 1; 
+            }
+            enum BAD_TAG {
+                value 2; 
+            }
+            enum BAD_DL_ADDR_MASK {
+                value 3; 
+            }
+            enum BAD_NW_ADDR_MASK {
+                value 4; 
+            }
+            enum BAD_WILDCARDS {
+                value 5; 
+            }
+            enum BAD_FIELD {
+                value 6; 
+            }
+            enum BAD_VALUE {
+                value 7; 
+            }
+            enum BAD_MASK {
+                value 8; 
+            }
+            enum BAD_PREREQ {
+                value 9; 
+            }
+            enum DUP_FIELD {
+                value 10; 
+            }
+            enum EPERM {
+                value 11; 
+            }
+        }
+    }
+    
+    typedef flow-mod-failed-code {
+        type enumeration {
+            enum UNKNOWN {
+                value 0; 
+            }
+            enum TABLE_FULL {
+                value 1; 
+            }
+            enum BAD_TABLE_ID {
+                value 2; 
+            }
+            enum OVERLAP {
+                value 3; 
+            }
+            enum EPERM {
+                value 4; 
+            }
+            enum BAD_TIMEOUT {
+                value 5; 
+            }
+            enum BAD_COMMAND {
+                value 6; 
+            }
+            enum BAD_FLAGS {
+                value 7; 
+            }
+        }
+    }
+    
+    typedef group-mod-failed-code {
+        type enumeration {
+            enum GROUP_EXISTS {
+                value 0; 
+            }
+            enum INVALID_GROUP {
+                value 1; 
+            }
+            enum WEIGHT_UNSUPPORTED {
+                value 2; 
+            }
+            enum OUT_OF_GROUPS {
+                value 3; 
+            }
+            enum OUT_OF_BUCKETS {
+                value 4; 
+            }
+            enum CHAINING_UNSUPPORTED {
+                value 5; 
+            }
+            enum WATCH_UNSUPPORTED {
+                value 6; 
+            }
+            enum LOOP {
+                value 7; 
+            }
+            enum UNKNOWN_GROUP {
+                value 8; 
+            }
+            enum CHAINED_GROUP {
+                value 9; 
+            }
+            enum BAD_TYPE {
+                value 10; 
+            }
+            enum BAD_COMMAND {
+                value 11; 
+            }
+            enum BAD_BUCKET {
+                value 12; 
+            }
+            enum BAD_WATCH {
+                value 13; 
+            }
+            enum EPERM {
+                value 14; 
+            }
+        }
+    }
+    
+    typedef port-mod-failed-code {
+        type enumeration {
+            enum BAD_PORT {
+                value 0; 
+            }
+            enum BAD_HW_ADDR {
+                value 1; 
+            }
+            enum BAD_CONFIG {
+                value 2; 
+            }
+            enum BAD_ADVERTISE {
+                value 3; 
+            }
+            enum EPERM {
+                value 4; 
+            }
+        }
+    }
+    
+    typedef table-mod-failed-code {
+        type enumeration {
+            enum BAD_TABLE {
+                value 0; 
+            }
+            enum BAD_CONFIG {
+                value 1; 
+            }
+            enum EPERM {
+                value 2; 
+            }
+        }
+    }
 
+    typedef queue-op-failed-code {
+        type enumeration {
+            enum BAD_PORT {
+                value 0; 
+            }
+            enum BAD_QUEUE {
+                value 1; 
+            }
+            enum EPERM {
+                value 2; 
+            }
+        }
+    }
+    
+    typedef switch-config-failed-code {
+        type enumeration {
+            enum BAD_FLAGS {
+                value 0; 
+            }
+            enum BAD_LEN {
+                value 1; 
+            }
+            enum EPERM {
+                value 2; 
+            }
+        }
+    }
+    
+    typedef role-request-failed-code {
+        type enumeration {
+            enum STALE {
+                value 0; 
+            }
+            enum UNSUP {
+                value 1; 
+            }
+            enum BAD_ROLE {
+                value 2; 
+            }
+        }
+    }
+    
+    typedef meter-mod-failed-code {
+        type enumeration {
+            enum UNKNOWN {
+                value 0; 
+            }
+            enum METER_EXISTS {
+                value 1; 
+            }
+            enum INVALID_METER {
+                value 2; 
+            }
+            enum UNKNOWN_METER {
+                value 3; 
+            }
+            enum BAD_COMMAND {
+                value 4; 
+            }
+            enum BAD_FLAGS {
+                value 5; 
+            }
+            enum BAD_RATE {
+                value 6; 
+            }
+            enum BAD_BURST {
+                value 7; 
+            }
+            enum BAD_BAND {
+                value 8; 
+            }
+            enum BAD_BAND_VALUE {
+                value 9; 
+            }
+            enum OUT_OF_METERS {
+                value 10; 
+            }
+            enum OUT_OF_BANDS {
+                value 11; 
+            }
+        }
+    }
+    
+    typedef table-features-failed-code {
+        type enumeration {
+            enum BAD_TABLE {
+                value 0; 
+            }
+            enum BAD_METADATA {
+                value 1; 
+            }
+            enum BAD_TYPE {
+                value 2; 
+            }
+            enum BAD_LEN {
+                value 3; 
+            }
+            enum BAD_ARGUMENT {
+                value 4; 
+            }
+            enum EPERM {
+                value 5; 
+            }
+        }
+    }
+    
     typedef hello-element-type {
         type enumeration {
             enum VERSIONBITMAP {
@@ -962,45 +1358,190 @@ module openflow-types {
     
 // OPENFLOW v1.0 STRUCTURES
     // Structures under this line are needed to support OpenFlow version 1.0 
-    // wire protocol 0x01; 
+    // wire protocol 0x01;
+    
+    typedef error-type-v10 {
+        type enumeration {
+            enum HELLO_FAILED {
+                value 0; 
+                description "Hello Protocol failed.";
+            }
+            enum BAD_REQUEST {
+                value 1; 
+                description "Request was not understood.";
+            }
+            enum BAD_ACTION {
+                value 2; 
+                description "Error in action description.";
+            }
+            enum FLOW_MOD_FAILED {
+                value 3; 
+                description "Problem modifying flow entry.";
+            }
+            enum PORT_MOD_FAILED {
+                value 4; 
+                description "Port mod request failed.";
+            }
+            enum QUEUE_OP_FAILED {
+                value 5; 
+                description "Queue operation failed.";
+            }
+        }
+    }
+    
+    typedef hello-failed-code-v10 {
+        type enumeration {
+            enum INCOMPATIBLE {
+                value 0; 
+                description "Hello Protocol failed.";
+            }
+            enum EPERM {
+                value 1; 
+                description "Request was not understood.";
+            }
+        }
+    }
+    
+    typedef bad-request-code-v10 {
+        type enumeration {
+            enum BAD_VERSION {
+                value 0; 
+            }
+            enum BAD_TYPE {
+                value 1; 
+            }
+            enum BAD_STAT {
+                value 2; 
+            }
+            enum BAD_VENDOR {
+                value 3; 
+            }
+            enum BAD_SUBTYPE {
+                value 4; 
+            }
+            enum EPERM {
+                value 5; 
+            }
+            enum BAD_LEN {
+                value 6; 
+            }
+            enum BUFFER_EMPTY {
+                value 7; 
+            }
+            enum BUFFER_UNKNOWN {
+                value 8; 
+            }
+        }
+    }
+    
+    typedef bad-action-code-v10 {
+        type enumeration {
+            enum BAD_TYPE {
+                value 0; 
+            }
+            enum BAD_LEN {
+                value 1; 
+            }
+            enum VENDOR {
+                value 2; 
+            }
+            enum BAD_VENDOR_TYPE {
+                value 3; 
+            }
+            enum BAD_OUT_PORT {
+                value 4; 
+            }
+            enum BAD_ARGUMENT {
+                value 5; 
+            }
+            enum EPERM {
+                value 6; 
+            }
+            enum TOO_MANY {
+                value 7; 
+            }
+            enum BAD_QUEUE {
+                value 8; 
+            }
+        }
+    }
+    
+    typedef flow-mod-failed-code-v10 {
+        type enumeration {
+            enum ALL_TABLES_FULL {
+                value 0; 
+            }
+            enum OVERLAP {
+                value 1; 
+            }
+            enum EPERM {
+                value 2; 
+            }
+            enum BAD_EMERG_TIMEOUT {
+                value 3; 
+            }
+            enum BAD_COMMAND {
+                value 4; 
+            }
+            enum UNSUPPORTED {
+                value 5; 
+            }
+        }
+    }
+    
+    typedef port-mod-failed-code-v10 {
+        type enumeration {
+            enum BAD_PORT {
+                value 0; 
+            }
+            enum BAD_HW_ADDR {
+                value 1; 
+            }
+        }
+    }
+    
+    typedef queue-op-failed-code-v10 {
+        type enumeration {
+            enum BAD_PORT {
+                value 0; 
+            }
+            enum BAD_QUEUE {
+                value 1; 
+            }
+            enum EPERM {
+                value 2; 
+            }
+        }
+    }
     
     typedef port-number-values-v10 {
         type enumeration {
             enum MAX {
                 value 65280; // 0xff00 
-                description "Hello Protocol failed.";
             }
             enum IN_PORT {
                 value 65528; // 0xfff8
-                description "Request was not understood.";
             }
             enum TABLE {
                 value 65529; // 0xfff9 
-                description "Error in action description.";
             }
             enum NORMAL {
                 value 65530; // 0xfffa 
-                description "Error in instruction list.";
             }
             enum FLOOD {
                 value 65531; // 0xfffb 
-                description "Error in match.";
             }
             enum ALL {
                 value 65532; // 0xfffc 
-                description "Problem modifying flow entry.";
             }
             enum CONTROLLER {
                 value 65533; // 0xfffd
-                description "Problem modifying group entry.";
             }
             enum LOCAL {
                 value 65534; // 0xfffe
-                description "Port mod request failed.";
             }
             enum ANY {
                 value 65535; // 0xffff
-                description "Table mod request failed.";
             }
         }
     }
@@ -1250,32 +1791,4 @@ module openflow-types {
         }
     }
     
-    typedef error-type-v10 {
-        type enumeration {
-            enum HELLO_FAILED {
-                value 0; 
-                description "Hello Protocol failed.";
-            }
-            enum BAD_REQUEST {
-                value 1; 
-                description "Request was not understood.";
-            }
-            enum BAD_ACTION {
-                value 2; 
-                description "Error in action description.";
-            }
-            enum FLOW_MOD_FAILED {
-                value 3; 
-                description "Problem modifying flow entry.";
-            }
-            enum PORT_MOD_FAILED {
-                value 4; 
-                description "Port mod request failed.";
-            }
-            enum QUEUE_OP_FAILED {
-                value 5; 
-                description "Queue operation failed.";
-            }
-        }
-    }
 }
index bfa21900f647e7ca21186a302dbe48b6c23788e5..9026dcc68d957b0b3cc323b7462896c5880d6f94 100644 (file)
@@ -7,6 +7,7 @@ import io.netty.handler.codec.ByteToMessageDecoder;
 
 import java.util.List;
 
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -17,9 +18,9 @@ import org.slf4j.LoggerFactory;
 public class OFVersionDetector extends ByteToMessageDecoder {
 
     /** Version number of OpenFlow 1.0 protocol */
-    public static final byte OF10_VERSION_ID = 0x01;
+    private static final byte OF10_VERSION_ID = EncodeConstants.OF10_VERSION_ID;
     /** Version number of OpenFlow 1.3 protocol */
-    public static final byte OF13_VERSION_ID = 0x04;
+    private static final byte OF13_VERSION_ID = EncodeConstants.OF13_VERSION_ID;
     private static final Logger LOGGER = LoggerFactory.getLogger(OFVersionDetector.class);
 
     /**
index f2bea2b9797e81ddfb2c759a2e457889709d2909..0013b433984bcc1338f57195c17b8497878ca87c 100644 (file)
@@ -4,7 +4,6 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization;
 import java.util.HashMap;\r
 import java.util.Map;\r
 \r
-import org.opendaylight.openflowjava.protocol.impl.core.OFVersionDetector;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;\r
@@ -16,13 +15,9 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.Get
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoRequestMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigReplyMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory;\r
@@ -33,6 +28,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.Pac
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
 \r
 /**\r
  * Stores and provides correct decoders for received messages\r
@@ -74,8 +70,8 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.Rol
  */\r
 public class DecoderTable {\r
     \r
-    private static final short OF10 = OFVersionDetector.OF10_VERSION_ID;\r
-    private static final short OF13 = OFVersionDetector.OF13_VERSION_ID;\r
+    private static final short OF10 = EncodeConstants.OF10_VERSION_ID;\r
+    private static final short OF13 = EncodeConstants.OF13_VERSION_ID;\r
     private Map<MessageTypeCodeKey, OFDeserializer<?>> table;\r
     private static DecoderTable instance;\r
     \r
@@ -102,16 +98,16 @@ public class DecoderTable {
         table = new HashMap<>();\r
         table.put(new MessageTypeCodeKey(OF10, (short) 0), OF10HelloMessageFactory.getInstance());\r
         table.put(new MessageTypeCodeKey(OF10, (short) 1), OF10ErrorMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 2), OF10EchoRequestMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 3), OF10EchoReplyMessageFactory.getInstance());\r
+        table.put(new MessageTypeCodeKey(OF10, (short) 2), EchoRequestMessageFactory.getInstance());\r
+        table.put(new MessageTypeCodeKey(OF10, (short) 3), EchoReplyMessageFactory.getInstance());\r
         table.put(new MessageTypeCodeKey(OF10, (short) 4), OF10VendorMessageFactory.getInstance());\r
         table.put(new MessageTypeCodeKey(OF10, (short) 6), OF10FeaturesReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 8), OF10GetConfigReplyMessageFactory.getInstance());\r
+        table.put(new MessageTypeCodeKey(OF10, (short) 8), GetConfigReplyMessageFactory.getInstance());\r
         table.put(new MessageTypeCodeKey(OF10, (short) 10), OF10PacketInMessageFactory.getInstance());\r
         table.put(new MessageTypeCodeKey(OF10, (short) 11), OF10FlowRemovedMessageFactory.getInstance());\r
         table.put(new MessageTypeCodeKey(OF10, (short) 12), OF10PortStatusMessageFactory.getInstance());\r
         table.put(new MessageTypeCodeKey(OF10, (short) 16), OF10StatsReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 18), OF10BarrierReplyMessageFactory.getInstance());\r
+        table.put(new MessageTypeCodeKey(OF10, (short) 18), BarrierReplyMessageFactory.getInstance());\r
         table.put(new MessageTypeCodeKey(OF10, (short) 20), OF10QueueGetConfigReplyMessageFactory.getInstance());\r
         table.put(new MessageTypeCodeKey(OF13, (short) 0), HelloMessageFactory.getInstance());\r
         table.put(new MessageTypeCodeKey(OF13, (short) 1), ErrorMessageFactory.getInstance());\r
index aa39b2dafac580744c83f8e49a7a477059082f14..e2402b47766ff9bcc6b5e2c4bb13e3af816c42b9 100644 (file)
@@ -8,7 +8,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
 
 /**
- * Translates BarrierReply messages
+ * Translates BarrierReply messages (both OpenFlow v1.0 and OpenFlow v1.3)
  * @author michal.polkorab
  * @author timotej.kubas
  */
index 163a89c427336b624d2e8ee99b461d62793924a8..0c591bb5589626d7f02835707abfcdb17c1f043f 100644 (file)
@@ -8,7 +8,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;\r
 \r
 /**\r
- * Translates EchoReply messages\r
+ * Translates EchoReply messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
  * @author michal.polkorab\r
  * @author timotej.kubas\r
  */\r
index e736203903bfd47e2e2444018c7549ccf6f811fb..5ff67d7fa57b96e24140ed5ba8df67deeffbf741 100644 (file)
@@ -8,7 +8,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;\r
 \r
 /**\r
- * Translates EchoRequest messages\r
+ * Translates EchoRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
  * @author michal.polkorab\r
  * @author timotej.kubas\r
  */\r
index f66a54dc27ca23495a0fea3277cf479ab1395d98..45705144e18eacd80e02716b481a532129653f33 100644 (file)
@@ -4,7 +4,23 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;\r
 \r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterError;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterErrorBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadInstructionCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadMatchCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadRequestCode;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFailedCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModFailedCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloFailedCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModFailedCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortModFailedCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueOpFailedCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.RoleRequestFailedCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFailedCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesFailedCode;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableModFailedCode;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;\r
 \r
@@ -36,12 +52,149 @@ public class ErrorMessageFactory implements OFDeserializer<ErrorMessage> {
         ErrorMessageBuilder builder = new ErrorMessageBuilder();\r
         builder.setVersion(version);\r
         builder.setXid(rawMessage.readUnsignedInt());\r
-        builder.setType(ErrorType.forValue(rawMessage.readUnsignedShort()));\r
-        builder.setCode(rawMessage.readUnsignedShort());\r
+        ErrorType type = ErrorType.forValue(rawMessage.readUnsignedShort());\r
+        decodeType(builder, type);\r
+        decodeCode(rawMessage, builder, type);\r
         if (rawMessage.readableBytes() > 0) {\r
             builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());\r
         }\r
         return builder.build();\r
     }\r
 \r
+    private static void decodeCode(ByteBuf rawMessage, ErrorMessageBuilder builder,\r
+            ErrorType type) {\r
+        \r
+        switch (type) {\r
+        case HELLOFAILED:\r
+        {\r
+            HelloFailedCode code = HelloFailedCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case BADREQUEST:\r
+        {\r
+            BadRequestCode code = BadRequestCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case BADACTION:\r
+        {\r
+            BadActionCode code = BadActionCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case BADINSTRUCTION:\r
+        {\r
+            BadInstructionCode code = BadInstructionCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case BADMATCH:\r
+        {\r
+            BadMatchCode code = BadMatchCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case FLOWMODFAILED:\r
+        {\r
+            FlowModFailedCode code = FlowModFailedCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case GROUPMODFAILED:\r
+        {\r
+            GroupModFailedCode code = GroupModFailedCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case PORTMODFAILED:\r
+        {\r
+            PortModFailedCode code = PortModFailedCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case TABLEMODFAILED:\r
+        {\r
+            TableModFailedCode code = TableModFailedCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case QUEUEOPFAILED:\r
+        {\r
+            QueueOpFailedCode code = QueueOpFailedCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case SWITCHCONFIGFAILED:\r
+        {\r
+            SwitchConfigFailedCode code = SwitchConfigFailedCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case ROLEREQUESTFAILED:\r
+        {\r
+            RoleRequestFailedCode code = RoleRequestFailedCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case METERMODFAILED:\r
+        {\r
+            MeterModFailedCode code = MeterModFailedCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case TABLEFEATURESFAILED:\r
+        {\r
+            TableFeaturesFailedCode code = TableFeaturesFailedCode.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case EXPERIMENTER:\r
+            ExperimenterErrorBuilder expBuilder = new ExperimenterErrorBuilder();\r
+            expBuilder.setExpType(rawMessage.readUnsignedShort());\r
+            expBuilder.setExperimenter(rawMessage.readUnsignedInt());\r
+            builder.addAugmentation(ExperimenterError.class, expBuilder.build());\r
+            break;\r
+        default:\r
+            builder.setCode("UNKNOWN_CODE");\r
+            break;\r
+        }\r
+    }\r
+\r
+    private static void decodeType(ErrorMessageBuilder builder, ErrorType type) {\r
+        if (type != null) {\r
+            builder.setType(type.name());\r
+        } else {\r
+            builder.setType("UNKNOWN_TYPE");\r
+        }\r
+    }\r
+\r
 }\r
index dc56a5b94faab48ea18c8ecbd330da645dccd2d3..011e5ba43c5b19947e9ae5614406a8901bc5b77a 100644 (file)
@@ -9,7 +9,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder;
 
 /**
- * Translates GetConfigReply messages
+ * Translates GetConfigReply messages (both OpenFlow v1.0 and OpenFlow v1.3)
  * @author michal.polkorab
  * @author timotej.kubas
  */
index 4c362d22f42aa7527c8c691f3408a71656b56ce5..1523159f09d34681484b9e24c1137ac7b593a433 100644 (file)
@@ -7,8 +7,8 @@ import java.util.List;
 import io.netty.buffer.ByteBuf;\r
 \r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EncodeConstants;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.HelloInputMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder;\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java
deleted file mode 100644 (file)
index 2af5052..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;\r
-\r
-/**\r
- * Translates BarrierReply messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10BarrierReplyMessageFactory implements OFDeserializer<BarrierOutput> {\r
-\r
-    private static OF10BarrierReplyMessageFactory instance;\r
-\r
-    private OF10BarrierReplyMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-\r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10BarrierReplyMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10BarrierReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public BarrierOutput bufferToMessage(ByteBuf rawMessage, short version) {\r
-        BarrierOutputBuilder builder = new BarrierOutputBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        return builder.build();\r
-    }\r
-}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java
deleted file mode 100644 (file)
index 21eb118..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;\r
-\r
-/**\r
- * Translates EchoReply messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10EchoReplyMessageFactory implements OFDeserializer<EchoOutput> {\r
-\r
-    private static OF10EchoReplyMessageFactory instance;\r
-\r
-    private OF10EchoReplyMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10EchoReplyMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10EchoReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public EchoOutput bufferToMessage(ByteBuf rawMessage, short version) {\r
-        EchoOutputBuilder builder = new EchoOutputBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        int remainingBytes = rawMessage.readableBytes();\r
-        if (remainingBytes > 0) {\r
-            builder.setData(rawMessage.readBytes(remainingBytes).array());\r
-        }\r
-        return builder.build();\r
-    }\r
-}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java
deleted file mode 100644 (file)
index e41ffd7..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;\r
-\r
-/**\r
- * Translates EchoRequest messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10EchoRequestMessageFactory implements OFDeserializer<EchoRequestMessage> {\r
-\r
-    private static OF10EchoRequestMessageFactory instance;\r
-\r
-    private OF10EchoRequestMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10EchoRequestMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10EchoRequestMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public EchoRequestMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());\r
-        return builder.build();\r
-    }\r
-}\r
index 383bd7e5319e22d662c20950ea8c7355b3f5f0ff..f7fc25df0edfa55594594b850e33aff08ed4c659 100644 (file)
@@ -4,7 +4,13 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;\r
 \r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCodeV10;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadRequestCodeV10;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorTypeV10;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFailedCodeV10;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloFailedCodeV10;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortModFailedCodeV10;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueOpFailedCodeV10;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;\r
 \r
@@ -35,12 +41,78 @@ private static OF10ErrorMessageFactory instance;
         ErrorMessageBuilder builder = new ErrorMessageBuilder();\r
         builder.setVersion(version);\r
         builder.setXid(rawMessage.readUnsignedInt());\r
-        builder.setType(ErrorType.forValue(rawMessage.readUnsignedShort()));\r
-        builder.setCode(rawMessage.readUnsignedShort());\r
+        ErrorTypeV10 type = ErrorTypeV10.forValue(rawMessage.readUnsignedShort());\r
+        decodeType(builder, type);\r
+        decodeCode(rawMessage, builder, type);\r
         if (rawMessage.readableBytes() > 0) {\r
             builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());\r
         }\r
         return builder.build();\r
     }\r
 \r
+    private static void decodeCode(ByteBuf rawMessage, ErrorMessageBuilder builder,\r
+            ErrorTypeV10 type) {\r
+        switch (type) {\r
+        case HELLOFAILED:\r
+        {\r
+            HelloFailedCodeV10 code = HelloFailedCodeV10.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case BADREQUEST:\r
+        {\r
+            BadRequestCodeV10 code = BadRequestCodeV10.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case BADACTION:\r
+        {\r
+            BadActionCodeV10 code = BadActionCodeV10.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case FLOWMODFAILED:\r
+        {\r
+            FlowModFailedCodeV10 code = FlowModFailedCodeV10.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case PORTMODFAILED:\r
+        {\r
+            PortModFailedCodeV10 code = PortModFailedCodeV10.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        case QUEUEOPFAILED:\r
+        {\r
+            QueueOpFailedCodeV10 code = QueueOpFailedCodeV10.forValue(rawMessage.readUnsignedShort());\r
+            if (code != null) {\r
+                builder.setCode(code.name());\r
+            }\r
+            break;\r
+        }\r
+        default:\r
+            builder.setCode("UNKNOWN_CODE");\r
+            break;\r
+        }\r
+    }\r
+\r
+    private static void decodeType(ErrorMessageBuilder builder, ErrorTypeV10 type) {\r
+        if (type != null) {\r
+            builder.setType(type.name());\r
+        } else {\r
+            builder.setType("UNKNOWN_TYPE");\r
+        }\r
+    }\r
+\r
 }\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java
deleted file mode 100644 (file)
index 44fd5d7..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\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.GetConfigOutput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder;\r
-\r
-/**\r
- * Translates GetConfigReply messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10GetConfigReplyMessageFactory implements OFDeserializer<GetConfigOutput> {\r
-    \r
-private static OF10GetConfigReplyMessageFactory instance;\r
-    \r
-    private OF10GetConfigReplyMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10GetConfigReplyMessageFactory getInstance(){\r
-        if(instance == null){\r
-            instance = new OF10GetConfigReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public GetConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {\r
-        GetConfigOutputBuilder builder = new GetConfigOutputBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort()));\r
-        builder.setMissSendLen(rawMessage.readUnsignedShort());\r
-        return builder.build();\r
-    }\r
-\r
-}\r
index 903ea7ddf553afac1301acaeba2be0b0a6066d71..b26d4257e5f37a777b1d75ecb26676635b50cefb 100644 (file)
@@ -4,7 +4,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization;
 import java.util.HashMap;\r
 import java.util.Map;\r
 \r
-import org.opendaylight.openflowjava.protocol.impl.core.OFVersionDetector;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierInputMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoInputMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoReplyInputMessageFactory;\r
@@ -19,16 +18,11 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.factories.Hello
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MeterModInputMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10BarrierInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10EchoInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10EchoReplyInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FeaturesInputMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FlowModInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10GetConfigInputMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10HelloInputMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PacketOutInputMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PortModInputMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10QueueGetConfigInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10SetConfigMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10VendorInputMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PacketOutInputMessageFactory;\r
@@ -37,6 +31,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.factories.RoleR
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetAsyncInputMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetConfigMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;\r
@@ -65,8 +60,8 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
  */\r
 public class EncoderTable {\r
 \r
-    private static final short OF10 = OFVersionDetector.OF10_VERSION_ID;\r
-    private static final short OF13 = OFVersionDetector.OF13_VERSION_ID;\r
+    private static final short OF10 = EncodeConstants.OF10_VERSION_ID;\r
+    private static final short OF13 = EncodeConstants.OF13_VERSION_ID;\r
     private static EncoderTable instance;\r
     private Map<MessageTypeKey<?>, OFSerializer<?>> table;\r
 \r
@@ -92,18 +87,18 @@ public class EncoderTable {
     public void init() {\r
         table = new HashMap<>();\r
         table.put(new MessageTypeKey<>(OF10, BarrierInput.class), OF10BarrierInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, EchoInput.class), OF10EchoInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, EchoReplyInput.class), OF10EchoReplyInputMessageFactory.getInstance());\r
+        table.put(new MessageTypeKey<>(OF10, EchoInput.class), EchoInputMessageFactory.getInstance());\r
+        table.put(new MessageTypeKey<>(OF10, EchoReplyInput.class), EchoReplyInputMessageFactory.getInstance());\r
         table.put(new MessageTypeKey<>(OF10, ExperimenterInput.class), OF10VendorInputMessageFactory.getInstance());\r
         table.put(new MessageTypeKey<>(OF10, FlowModInput.class), OF10FlowModInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, GetConfigInput.class), OF10GetConfigInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, GetFeaturesInput.class), OF10FeaturesInputMessageFactory.getInstance());\r
+        table.put(new MessageTypeKey<>(OF10, GetConfigInput.class), GetConfigInputMessageFactory.getInstance());\r
+        table.put(new MessageTypeKey<>(OF10, GetFeaturesInput.class), GetFeaturesInputMessageFactory.getInstance());\r
         table.put(new MessageTypeKey<>(OF10, GetQueueConfigInput.class), OF10QueueGetConfigInputMessageFactory.getInstance());\r
         table.put(new MessageTypeKey<>(OF10, HelloInput.class), OF10HelloInputMessageFactory.getInstance());\r
         table.put(new MessageTypeKey<>(OF10, MultipartRequestInput.class), OF10StatsRequestInputFactory.getInstance());\r
         table.put(new MessageTypeKey<>(OF10, PacketOutInput.class), OF10PacketOutInputMessageFactory.getInstance());\r
         table.put(new MessageTypeKey<>(OF10, PortModInput.class), OF10PortModInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, SetConfigInput.class), OF10SetConfigMessageFactory.getInstance());\r
+        table.put(new MessageTypeKey<>(OF10, SetConfigInput.class), SetConfigMessageFactory.getInstance());\r
         table.put(new MessageTypeKey<>(OF13, BarrierInput.class), BarrierInputMessageFactory.getInstance());\r
         table.put(new MessageTypeKey<>(OF13, EchoInput.class), EchoInputMessageFactory.getInstance());\r
         table.put(new MessageTypeKey<>(OF13, EchoReplyInput.class), EchoReplyInputMessageFactory.getInstance());\r
index 59e8b0436b256fc814a6898702710d297117bff5..ef83d5c49d2d0da90d34f08cc89e10e27d4b34aa 100644 (file)
@@ -8,7 +8,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;\r
 \r
 /**\r
- * Translates EchoRequest messages\r
+ * Translates EchoRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
  * @author michal.polkorab\r
  * @author timotej.kubas\r
  */\r
index 18a0243fa0b9d0e13a9d7e16ce09b284c1ed4db5..2c8effbecabf965f1360ccf20af7dc106eeb1180 100644 (file)
@@ -8,7 +8,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;\r
 \r
 /**\r
- * Translates EchoReply messages\r
+ * Translates EchoReply messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
  * @author michal.polkorab\r
  * @author timotej.kubas\r
  */\r
index ee3877c6b46f1ee5ba51f3283b9561edad95db88..bea1eeb6f4c74fb46faf8417e45ebe4cdbb939cc 100644 (file)
@@ -8,7 +8,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;\r
 \r
 /**\r
- * Translates GetConfigRequest messages\r
+ * Translates GetConfigRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
  * @author michal.polkorab\r
  * @author timotej.kubas\r
  */\r
index e573b280c36ebfe24a46799aab72a20d75effb8b..ff29f4d5adfc13d7f67421601b9e99ed42213df2 100644 (file)
@@ -8,7 +8,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;\r
 \r
 /**\r
- * Translates FeaturesRequest messages\r
+ * Translates FeaturesRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
  * @author michal.polkorab\r
  * @author timotej.kubas\r
  */\r
index 303eb6c8055e1db3fa8547bcfdef1d9e7d707773..0ce34624d380f1d556262c7add6aaa874cd4ebf9 100644 (file)
@@ -7,6 +7,7 @@ import java.util.List;
 \r
 import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10EchoInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10EchoInputMessageFactory.java
deleted file mode 100644 (file)
index 5593156..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* 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.EchoInput;\r
-\r
-/**\r
- * Translates EchoRequest messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10EchoInputMessageFactory implements OFSerializer<EchoInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 2;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-\r
-    private static OF10EchoInputMessageFactory instance;\r
-    \r
-    private OF10EchoInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10EchoInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10EchoInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, EchoInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            out.writeBytes(data);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(EchoInput message) {\r
-        int length = MESSAGE_LENGTH;\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            length += data.length;\r
-        }\r
-        return length;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10EchoReplyInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10EchoReplyInputMessageFactory.java
deleted file mode 100644 (file)
index b97fbc6..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* 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.EchoReplyInput;\r
-\r
-/**\r
- * Translates EchoReply messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10EchoReplyInputMessageFactory implements OFSerializer<EchoReplyInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 3;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-    \r
-    private static OF10EchoReplyInputMessageFactory instance;\r
-    \r
-    private OF10EchoReplyInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10EchoReplyInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10EchoReplyInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            EchoReplyInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            out.writeBytes(data);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(EchoReplyInput message) {\r
-        int length = MESSAGE_LENGTH;\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            length += data.length;\r
-        }\r
-        return length;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesInputMessageFactory.java
deleted file mode 100644 (file)
index 4c727ff..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/* 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.GetFeaturesInput;\r
-\r
-/**\r
- * Translates FeaturesRequest messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10FeaturesInputMessageFactory implements OFSerializer<GetFeaturesInput>{\r
-\r
-    private static final byte MESSAGE_TYPE = 5;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-    \r
-    private static OF10FeaturesInputMessageFactory instance;\r
-    \r
-    private OF10FeaturesInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10FeaturesInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10FeaturesInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            GetFeaturesInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(GetFeaturesInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10GetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10GetConfigInputMessageFactory.java
deleted file mode 100644 (file)
index 7a3591c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* 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.GetConfigInput;\r
-\r
-/**\r
- * Translates GetConfigRequest messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10GetConfigInputMessageFactory implements OFSerializer<GetConfigInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 7;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-    \r
-    private static OF10GetConfigInputMessageFactory instance;\r
-    \r
-    private OF10GetConfigInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10GetConfigInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10GetConfigInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            GetConfigInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(GetConfigInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10SetConfigMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10SetConfigMessageFactory.java
deleted file mode 100644 (file)
index 926a3b8..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* 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.SetConfigInput;\r
-\r
-/**\r
- * Translates SetConfig messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10SetConfigMessageFactory implements OFSerializer<SetConfigInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 9;\r
-    private static final int MESSAGE_LENGTH = 12;\r
-    \r
-    private static OF10SetConfigMessageFactory instance;\r
-    \r
-    private OF10SetConfigMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10SetConfigMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10SetConfigMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            SetConfigInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeShort(message.getFlags().getIntValue());\r
-        out.writeShort(message.getMissSendLen());\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(SetConfigInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-}\r
index c9b2471d1df237106b53604afec49b38b718c7a5..2c6f3795944955f29abb9f1f5d15d650c25d2e0f 100644 (file)
@@ -8,7 +8,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;\r
 \r
 /**\r
- * Translates SetConfig messages\r
+ * Translates SetConfig messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
  * @author michal.polkorab\r
  * @author timotej.kubas\r
  */\r
index 333a7cab0902cb22e429c238902ad77eac0b6556..89920c2fc3eb461784408279d6769d5f846a55c5 100644 (file)
@@ -5,7 +5,6 @@ import io.netty.buffer.ByteBuf;
 \r
 import java.util.List;\r
 \r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;\r
@@ -1,5 +1,5 @@
 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
 \r
 /**\r
  * Stores common constants\r
@@ -9,5 +9,9 @@ public abstract class EncodeConstants {
 \r
     /** Default OF padding (in bytes) */\r
     public static final byte PADDING = Long.SIZE / Byte.SIZE;\r
+    /** OpenFlow v1.0 wire protocol number */\r
+    public static final byte OF10_VERSION_ID = 0x01;\r
+    /** OpenFlow v1.0 wire protocol number */\r
+    public static final byte OF13_VERSION_ID = 0x04;\r
 \r
 }\r
index b5e6b486d34e732989df3e1b031ed003535baf32..98b01c4b0745b39ed4295519876f19a71c28172c 100644 (file)
@@ -6,7 +6,6 @@ import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;\r
 import java.util.List;\r
 \r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
index 7af3e11ccddddbb190953e71fea0834e78ae3153..e4028c369a1c657d842108a33fb78c8f8099a68f 100644 (file)
@@ -8,7 +8,6 @@ import java.util.HashMap;
 import java.util.List;\r
 import java.util.Map;\r
 \r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;\r
index 5572342f594a12519d22aa96689d16bc92e4a728..714e23c5b1687e3f2018d2a090dbd2057cb00694 100644 (file)
@@ -24,4 +24,16 @@ public class BarrierReplyMessageFactoryTest {
 \r
         BufferHelper.checkHeaderV13(builtByFactory);\r
     }\r
+    \r
+    /**\r
+     * Testing of {@link BarrierReplyMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testV10() {\r
+        ByteBuf bb = BufferHelper.buildBuffer();\r
+        BarrierOutput builtByFactory = BufferHelper.decodeV10(\r
+                BarrierReplyMessageFactory.getInstance(), bb);\r
+\r
+        BufferHelper.checkHeaderV10(builtByFactory);\r
+    }\r
 }\r
index 08d42b5ed4108de9bc6ad7239c03d5309050426c..0d648d012c15df84ac29cc298eb4060042db74c0 100644 (file)
@@ -40,5 +40,31 @@ public class EchoReplyMessageFactoryTest {
         BufferHelper.checkHeaderV13(builtByFactory);\r
         Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());\r
     }\r
+    \r
+    /**\r
+     * Testing {@link EchoReplyMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testWithEmptyDataFieldV10() {\r
+        ByteBuf bb = BufferHelper.buildBuffer();\r
+        EchoOutput builtByFactory = BufferHelper.decodeV10(\r
+                EchoReplyMessageFactory.getInstance(), bb);\r
+\r
+        BufferHelper.checkHeaderV10(builtByFactory);\r
+    }\r
+    \r
+    /**\r
+     * Testing {@link EchoReplyMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testWithDataFieldSetV10() {\r
+        byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};\r
+        ByteBuf bb = BufferHelper.buildBuffer(data);\r
+        EchoOutput builtByFactory = BufferHelper.decodeV10(\r
+                EchoReplyMessageFactory.getInstance(), bb);\r
+        \r
+        BufferHelper.checkHeaderV10(builtByFactory);\r
+        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());\r
+    }\r
 \r
 }\r
index 5f882dbb6bdfafde9fa0830d164a519b63b31666..da5f60e8960f552b6cde173af05851d2dd65b686 100644 (file)
@@ -40,5 +40,31 @@ public class EchoRequestMessageFactoryTest {
         BufferHelper.checkHeaderV13(builtByFactory);\r
         Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());\r
     }\r
+    \r
+    /**\r
+     * Testing {@link EchoRequestMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testWithEmptyDataFieldV10() {\r
+        ByteBuf bb = BufferHelper.buildBuffer();\r
+        EchoRequestMessage builtByFactory = BufferHelper.decodeV10(\r
+                EchoRequestMessageFactory.getInstance(), bb);\r
+\r
+        BufferHelper.checkHeaderV10(builtByFactory);\r
+    }\r
+    \r
+    /**\r
+     * Testing {@link EchoRequestMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testWithDataFieldSetV10() {\r
+        byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};\r
+        ByteBuf bb = BufferHelper.buildBuffer(data);\r
+        EchoRequestMessage builtByFactory = BufferHelper.decodeV10(\r
+                EchoRequestMessageFactory.getInstance(), bb);\r
+\r
+        BufferHelper.checkHeaderV10(builtByFactory);\r
+        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());\r
+    }\r
 \r
 }\r
index 6a3f8fdf323454aa9bb878b489692e3e4bcb9c99..43f7ebcbfa824853724dc6c2b264a1c29d244b61 100644 (file)
@@ -23,8 +23,8 @@ public class ErrorMessageFactoryTest {
         ErrorMessage builtByFactory = BufferHelper.decodeV13(ErrorMessageFactory.getInstance(), bb);
         BufferHelper.checkHeaderV13(builtByFactory);
         
-        Assert.assertEquals("Wrong reason", 0x04, builtByFactory.getType().getIntValue());
-        Assert.assertEquals("Wrong code", 3, builtByFactory.getCode().intValue());
+        Assert.assertEquals("Wrong reason", "BADMATCH", builtByFactory.getType());
+        Assert.assertEquals("Wrong code", "BADDLADDRMASK", builtByFactory.getCode());
         Assert.assertArrayEquals("Wrong body", new byte[]{0x01, 0x02, 0x03, 0x04}, builtByFactory.getData());
     }
 }
index d8f59f81bda27d3e7f832f62b3ef65fb8f7e6c08..7f1908e15ecbdc989293f2176b7b83e77e97e380 100644 (file)
@@ -7,6 +7,7 @@ import io.netty.buffer.UnpooledByteBufAllocator;
 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.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;\r
 \r
@@ -25,7 +26,7 @@ public class BarrierInputMessageFactoryTest {
     @Test\r
     public void test() throws Exception {\r
         BarrierInputBuilder bib = new BarrierInputBuilder();\r
-        BufferHelper.setupHeader(bib);\r
+        BufferHelper.setupHeader(bib, EncodeConstants.OF13_VERSION_ID);\r
         BarrierInput bi = bib.build();\r
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
index bfeb53ba18c193ffe62d14d4cef93a19fea13a12..3c2faa64356be13e9ea150192cba6dd0ae59dacd 100644 (file)
@@ -5,8 +5,8 @@ import io.netty.buffer.ByteBuf;
 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.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder;\r
 \r
@@ -23,16 +23,33 @@ public class EchoInputMessageFactoryTest {
      * @throws Exception \r
      */\r
     @Test\r
-    public void test() throws Exception {\r
+    public void testV13() throws Exception {\r
         EchoInputBuilder eib = new EchoInputBuilder();\r
-        BufferHelper.setupHeader(eib);\r
+        BufferHelper.setupHeader(eib, EncodeConstants.OF13_VERSION_ID);\r
         EchoInput ei = eib.build();\r
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
         EchoInputMessageFactory eimf = EchoInputMessageFactory.getInstance();\r
-        eimf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, ei);\r
+        eimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, ei);\r
         \r
         BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8);\r
     }\r
+    \r
+    /**\r
+     * Testing of {@link EchoInputMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void testV10() throws Exception {\r
+        EchoInputBuilder eib = new EchoInputBuilder();\r
+        BufferHelper.setupHeader(eib, EncodeConstants.OF10_VERSION_ID);\r
+        EchoInput ei = eib.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        EchoInputMessageFactory eimf = EchoInputMessageFactory.getInstance();\r
+        eimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, ei);\r
+        \r
+        BufferHelper.checkHeaderV10(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8);\r
+    }\r
 \r
 }\r
index b14754341cb72f28b9895011c80c523534d96c93..0052488f184114a8f5f4da317f3b0ef9682c4464 100644 (file)
@@ -5,8 +5,8 @@ import io.netty.buffer.ByteBuf;
 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.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder;\r
 \r
@@ -23,16 +23,33 @@ public class EchoReplyInputMessageFactoryTest {
      * @throws Exception \r
      */\r
     @Test\r
-    public void test() throws Exception {\r
+    public void testV13() throws Exception {\r
         EchoReplyInputBuilder erib = new EchoReplyInputBuilder();\r
-        BufferHelper.setupHeader(erib);\r
+        BufferHelper.setupHeader(erib, EncodeConstants.OF13_VERSION_ID);\r
         EchoReplyInput eri = erib.build();\r
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
         EchoReplyInputMessageFactory eimf = EchoReplyInputMessageFactory.getInstance();\r
-        eimf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, eri);\r
+        eimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, eri);\r
         \r
         BufferHelper.checkHeaderV13(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8);\r
     }\r
+    \r
+    /**\r
+     * Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void testV10() throws Exception {\r
+        EchoReplyInputBuilder erib = new EchoReplyInputBuilder();\r
+        BufferHelper.setupHeader(erib, EncodeConstants.OF10_VERSION_ID);\r
+        EchoReplyInput eri = erib.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        EchoReplyInputMessageFactory eimf = EchoReplyInputMessageFactory.getInstance();\r
+        eimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, eri);\r
+        \r
+        BufferHelper.checkHeaderV10(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8);\r
+    }\r
 \r
 }\r
index 1bea8f429ee545b5c152b0a5613b7ab5eeffb116..b75c1c9326544478325aa5cce495bd8a8eddbaeb 100644 (file)
@@ -8,6 +8,7 @@ import org.junit.Assert;
 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.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;\r
 \r
@@ -26,7 +27,7 @@ public class ExperimenterInputMessageFactoryTest {
     @Test\r
     public void test() throws Exception {\r
         ExperimenterInputBuilder builder = new ExperimenterInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setExperimenter(0x0001020304L);\r
         builder.setExpType(0x0001020304L);\r
         builder.setData(new byte[] {0x01, 0x02, 0x03});\r
index 7fcd9b889957470550b67d5baa2d45d534cd8fe6..522d7054229130ab4a763a785092969e5a6e72b6 100644 (file)
@@ -12,6 +12,7 @@ import org.junit.Assert;
 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.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction;\r
@@ -52,7 +53,7 @@ public class FlowModInputMessageFactoryTest {
     @Test\r
     public void testFlowModInputMessageFactory() throws Exception {\r
         FlowModInputBuilder builder = new FlowModInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         byte[] cookie = new byte[]{0x00, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01};\r
         builder.setCookie(new BigInteger(cookie));\r
         byte[] cookieMask = new byte[]{0x01, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30};\r
index 48649e80620a90818b5e20300bc7d9f8c992bd3f..44bbe557e300a56ba1110fdb784d59624372d387 100644 (file)
@@ -5,8 +5,8 @@ import io.netty.buffer.ByteBuf;
 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.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInputBuilder;\r
 \r
@@ -23,16 +23,33 @@ public class GetConfigInputMessageFactoryTest {
      * @throws Exception \r
      */\r
     @Test\r
-    public void test() throws Exception {\r
+    public void testV13() throws Exception {\r
         GetConfigInputBuilder gcib = new GetConfigInputBuilder();\r
-        BufferHelper.setupHeader(gcib);\r
+        BufferHelper.setupHeader(gcib, EncodeConstants.OF13_VERSION_ID);\r
         GetConfigInput gci = gcib.build();\r
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
         GetConfigInputMessageFactory gcimf = GetConfigInputMessageFactory.getInstance();\r
-        gcimf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, gci);\r
+        gcimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, gci);\r
         \r
         BufferHelper.checkHeaderV13(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8);\r
     }\r
+    \r
+    /**\r
+     * Testing of {@link GetConfigInputMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void testV10() throws Exception {\r
+        GetConfigInputBuilder gcib = new GetConfigInputBuilder();\r
+        BufferHelper.setupHeader(gcib, EncodeConstants.OF10_VERSION_ID);\r
+        GetConfigInput gci = gcib.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        GetConfigInputMessageFactory gcimf = GetConfigInputMessageFactory.getInstance();\r
+        gcimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, gci);\r
+        \r
+        BufferHelper.checkHeaderV10(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8);\r
+    }\r
 \r
 }\r
index c90b0afb125cfdd57df65e63cdf08b9fa9561235..7ebf90812d9e35e0326c56fdfab62889e8240531 100644 (file)
@@ -5,8 +5,8 @@ import io.netty.buffer.ByteBuf;
 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.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder;\r
 \r
@@ -23,16 +23,32 @@ public class GetFeaturesInputMessageFactoryTest {
      * @throws Exception \r
      */\r
     @Test\r
-    public void test() throws Exception {\r
+    public void testV13() throws Exception {\r
         GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();\r
-        BufferHelper.setupHeader(gfib);\r
+        BufferHelper.setupHeader(gfib, EncodeConstants.OF13_VERSION_ID);\r
         GetFeaturesInput gfi = gfib.build();\r
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
         GetFeaturesInputMessageFactory gfimf = GetFeaturesInputMessageFactory.getInstance();\r
-        gfimf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, gfi);\r
+        gfimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, gfi);\r
         \r
         BufferHelper.checkHeaderV13(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);\r
     }\r
 \r
+    /**\r
+     * Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void testV10() throws Exception {\r
+        GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();\r
+        BufferHelper.setupHeader(gfib, EncodeConstants.OF10_VERSION_ID);\r
+        GetFeaturesInput gfi = gfib.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        GetFeaturesInputMessageFactory gfimf = GetFeaturesInputMessageFactory.getInstance();\r
+        gfimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, gfi);\r
+        \r
+        BufferHelper.checkHeaderV10(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);\r
+    }\r
 }\r
index 624be6ce7a6736e5e58127e7ad36ee5d804b6bea..974934fa3d40a6f31246e15b731099acd8805317 100644 (file)
@@ -8,6 +8,7 @@ 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.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder;
@@ -27,7 +28,7 @@ public class GetQueueConfigInputMessageFactoryTest {
     @Test
     public void testGetQueueConfigInputMessage() throws Exception {
         GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
-        BufferHelper.setupHeader(builder);
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
         builder.setPort(new PortNumber(0x00010203L));
         GetQueueConfigInput message = builder.build();
         
index fa63cdabd3f437c7f85ea4e4507ed26f4af70f5a..ddc5ebd42695b375ccd2f139c9f1ee39165425eb 100644 (file)
@@ -7,6 +7,7 @@ import io.netty.buffer.UnpooledByteBufAllocator;
 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.openflowjava.protocol.impl.util.EncodeConstants;\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
@@ -25,7 +26,7 @@ public class GetaAsyncRequestMessageFactoryTest {
     @Test\r
     public void testGetAsyncReques() throws Exception {\r
         GetAsyncInputBuilder builder = new GetAsyncInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         GetAsyncInput message = builder.build();\r
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
index d42d52553bf34a2cdf7e72b95e74ba0b363799d4..6c11af37d7f457f2507be1d5b721d1c4a7630eee 100644 (file)
@@ -11,6 +11,7 @@ import org.junit.Assert;
 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.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
@@ -33,7 +34,7 @@ public class GroupModInputMessageFactoryTest {
     @Test\r
     public void testGroupModInputMessage() throws Exception {\r
         GroupModInputBuilder builder = new GroupModInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setCommand(GroupModCommand.forValue(2));\r
         builder.setType(GroupType.forValue(3));\r
         builder.setGroupId(256L);\r
index 8f710bc1f0686d55bdf5ec6af7712c5de7309971..aa2712b67cc753fb06a82e7ff2ede02c724ee105 100644 (file)
@@ -12,6 +12,7 @@ import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;\r
@@ -35,7 +36,7 @@ public class HelloInputMessageFactoryTest {
     @Test\r
     public void testWithoutElementsSet() throws Exception {\r
         HelloInputBuilder hib = new HelloInputBuilder();\r
-        BufferHelper.setupHeader(hib);\r
+        BufferHelper.setupHeader(hib, EncodeConstants.OF13_VERSION_ID);\r
         HelloInput hi = hib.build();\r
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
@@ -53,7 +54,7 @@ public class HelloInputMessageFactoryTest {
     public void testWith4BitVersionBitmap() throws Exception {\r
         int lengthOfBitmap = 4;\r
         HelloInputBuilder builder = new HelloInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         List<Elements> expectedElement = createElement(lengthOfBitmap);\r
         builder.setElements(expectedElement);\r
         HelloInput message = builder.build();\r
@@ -78,7 +79,7 @@ public class HelloInputMessageFactoryTest {
     public void testWith64BitVersionBitmap() throws Exception {\r
         int lengthOfBitmap = 64;\r
         HelloInputBuilder builder = new HelloInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         List<Elements> expectedElement = createElement(lengthOfBitmap);\r
         builder.setElements(expectedElement);\r
         HelloInput message = builder.build();\r
index 65cd206c9674902c437c0437e9b83f30f38122d2..16a1e1bb8bfd0af62633c75484cf55142fa7db77 100644 (file)
@@ -12,6 +12,7 @@ import junit.framework.Assert;
 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.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;\r
@@ -37,7 +38,7 @@ public class MeterModInputMessageFactoryTest {
     @Test\r
     public void testMeterModInputMessage() throws Exception {\r
         MeterModInputBuilder builder = new MeterModInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setCommand(MeterModCommand.forValue(1));\r
         builder.setFlags(new MeterFlags(false, true, true, false));\r
         builder.setMeterId(new MeterId(2248L));\r
index 38e234a68a79706b0c5becbc260f95b65cfe82c6..45c70e319e0a3981b99c475a038316efd7a48589 100644 (file)
@@ -13,6 +13,7 @@ import junit.framework.Assert;
 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.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;\r
@@ -55,7 +56,7 @@ public class MultipartRequestInputFactoryTest {
     @Test\r
     public void testMultipartRequestInputFactory() throws Exception {\r
         MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setType(MultipartType.forValue(1));\r
         builder.setFlags(new MultipartRequestFlags(true));\r
         builder.setMultipartRequestBody(createRequestFlow());\r
@@ -112,7 +113,7 @@ public class MultipartRequestInputFactoryTest {
     @Test\r
     public void testMultipartRequestInputAggregateBodyFactory() throws Exception {\r
         MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setType(MultipartType.forValue(2));\r
         builder.setFlags(new MultipartRequestFlags(true));\r
         builder.setMultipartRequestBody(createRequestAggregate());\r
@@ -175,7 +176,7 @@ public class MultipartRequestInputFactoryTest {
     @Test\r
     public void testMultipartRequestInputTableFactory() throws Exception {\r
         MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setType(MultipartType.forValue(3));\r
         builder.setFlags(new MultipartRequestFlags(true));\r
         //multipart request for table does not have body\r
@@ -198,7 +199,7 @@ public class MultipartRequestInputFactoryTest {
     @Test\r
     public void testMultipartRequestPortStatsMessageFactory() throws Exception {\r
         MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setType(MultipartType.forValue(4));\r
         builder.setFlags(new MultipartRequestFlags(true));\r
         builder.setMultipartRequestBody(createRequestPortStats());\r
@@ -238,7 +239,7 @@ public class MultipartRequestInputFactoryTest {
     @Test\r
     public void testMultipartRequestQueueMessageFactory() throws Exception {\r
         MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setType(MultipartType.forValue(5));\r
         builder.setFlags(new MultipartRequestFlags(true));\r
         builder.setMultipartRequestBody(createRequestQueue());\r
@@ -278,7 +279,7 @@ public class MultipartRequestInputFactoryTest {
     @Test\r
     public void testMultipartRequestGroupMessageFactory() throws Exception {\r
         MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setType(MultipartType.forValue(6));\r
         builder.setFlags(new MultipartRequestFlags(true));\r
         builder.setMultipartRequestBody(createRequestGroup());\r
@@ -318,7 +319,7 @@ public class MultipartRequestInputFactoryTest {
     @Test\r
     public void testMultipartRequestMeterMessageFactory() throws Exception {\r
         MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setType(MultipartType.forValue(9));\r
         builder.setFlags(new MultipartRequestFlags(true));\r
         builder.setMultipartRequestBody(createRequestMeter());\r
@@ -358,7 +359,7 @@ public class MultipartRequestInputFactoryTest {
     @Test\r
     public void testMultipartRequestMeterConfigMessageFactory() throws Exception {\r
         MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setType(MultipartType.forValue(10));\r
         builder.setFlags(new MultipartRequestFlags(true));\r
         builder.setMultipartRequestBody(createRequestMeterConfig());\r
@@ -398,7 +399,7 @@ public class MultipartRequestInputFactoryTest {
     @Test\r
     public void testMultipartRequestExperimenterMessageFactory() throws Exception {\r
         MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setType(MultipartType.forValue(0xffff));\r
         builder.setFlags(new MultipartRequestFlags(true));\r
         builder.setMultipartRequestBody(createRequestExperimenter());\r
@@ -438,7 +439,7 @@ public class MultipartRequestInputFactoryTest {
     @Test\r
     public void testMultipartRequestDescMessageFactory() throws Exception {\r
         MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setType(MultipartType.forValue(0));\r
         builder.setFlags(new MultipartRequestFlags(true));\r
         builder.setMultipartRequestBody(createRequestDesc());\r
@@ -465,7 +466,7 @@ public class MultipartRequestInputFactoryTest {
     @Test\r
     public void testMultipartRequestTableFeaturesMessageFactory() throws Exception {\r
         MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setType(MultipartType.forValue(12));\r
         builder.setFlags(new MultipartRequestFlags(true));\r
         builder.setMultipartRequestBody(createRequestTableFeatures());\r
index 7e78f561c02dd660e43e7c1fcfeb1e894fbd27bf..8d004d353ed1feab6b1fe979975425472184137a 100644 (file)
@@ -12,6 +12,7 @@ import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;\r
@@ -40,7 +41,7 @@ public class PacketOutInputMessageFactoryTest {
     @Test\r
     public void testPacketOutInputMessage() throws Exception {\r
         PacketOutInputBuilder builder = new PacketOutInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setBufferId(256L);\r
         builder.setInPort(new PortNumber(256L));\r
         List<ActionsList> actions = new ArrayList<>();\r
index e3d837986a64c1729c9eb83ee7be387f3f793eed..9617e61251597652b6a23d7c10636e0ba29b975f 100644 (file)
@@ -8,6 +8,7 @@ import junit.framework.Assert;
 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.openflowjava.protocol.impl.util.EncodeConstants;\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
@@ -33,7 +34,7 @@ public class PortModInputMessageFactoryTest {
     @Test\r
     public void testPortModInput() throws Exception {\r
         PortModInputBuilder builder = new PortModInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setPortNo(new PortNumber(9L));\r
         builder.setHwAddress(new MacAddress("08002700B0EB"));\r
         builder.setConfig(new PortConfig(true, false, true, false));\r
index 5e31fc5d5a8bc143c4e74119d3c3a40e0f49064d..27274aadb34ed6d403eb95a5ea8130b630f302a7 100644 (file)
@@ -11,6 +11,7 @@ import junit.framework.Assert;
 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.openflowjava.protocol.impl.util.EncodeConstants;\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
@@ -31,7 +32,7 @@ public class RoleRequestInputMessageFactoryTest {
     @Test\r
     public void testRoleRequestInputMessage() throws Exception {\r
         RoleRequestInputBuilder builder = new RoleRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\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
index 1677d7b5756e0b04a3eab63ae1a2b5d1e291e866..217177cc471c54b25d4f57dcc2f62913decad1ea 100644 (file)
@@ -12,6 +12,7 @@ import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;\r
@@ -40,7 +41,7 @@ public class SetAsyncInputMessageFactoryTest {
     @Test\r
     public void testSetAsyncInputMessage() throws Exception {\r
         SetAsyncInputBuilder builder = new SetAsyncInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setPacketInMask(createPacketInMask());\r
         builder.setPortStatusMask(createPortStatusMask());\r
         builder.setFlowRemovedMask(createFlowRemowedMask());\r
index e462975a1d4b3b9b12b3ece3ed4e4d2f059fde3e..5f54df8aa982250d011c0157d0aee271bbdd8e00 100644 (file)
@@ -6,8 +6,8 @@ import io.netty.buffer.UnpooledByteBufAllocator;
 \r
 import org.junit.Assert;\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.openflowjava.protocol.impl.util.EncodeConstants;\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
@@ -25,9 +25,9 @@ public class SetConfigMessageFactoryTest {
      * @throws Exception \r
      */\r
     @Test\r
-    public void testSetConfigMessage() throws Exception {\r
+    public void testSetConfigMessageV13() throws Exception {\r
         SetConfigInputBuilder builder = new SetConfigInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         SwitchConfigFlag flag = SwitchConfigFlag.FRAGNORMAL;\r
         builder.setFlags(flag);\r
         builder.setMissSendLen(10);\r
@@ -35,10 +35,32 @@ public class SetConfigMessageFactoryTest {
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
         SetConfigMessageFactory factory = SetConfigMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
+        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);\r
         \r
         BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
-        Assert.assertEquals("Wrong flags", message.getFlags().getIntValue(), out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong missSendLen", message.getMissSendLen().intValue(), out.readUnsignedShort());\r
+        Assert.assertEquals("Wrong flags", SwitchConfigFlag.FRAGNORMAL.getIntValue(), out.readUnsignedShort());\r
+        Assert.assertEquals("Wrong missSendLen", 10, out.readUnsignedShort());\r
+    }\r
+    \r
+    /**\r
+     * Testing of {@link SetConfigMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void testSetConfigMessageV10() throws Exception {\r
+        SetConfigInputBuilder builder = new SetConfigInputBuilder();\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);\r
+        SwitchConfigFlag flag = SwitchConfigFlag.OFPCFRAGDROP;\r
+        builder.setFlags(flag);\r
+        builder.setMissSendLen(85);\r
+        SetConfigInput message = builder.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        SetConfigMessageFactory factory = SetConfigMessageFactory.getInstance();\r
+        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);\r
+        \r
+        BufferHelper.checkHeaderV10(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
+        Assert.assertEquals("Wrong flags", SwitchConfigFlag.OFPCFRAGDROP.getIntValue(), out.readUnsignedShort());\r
+        Assert.assertEquals("Wrong missSendLen", 85, out.readUnsignedShort());\r
     }\r
 }\r
index ddcdb27c664daf0897928fc2fcafb7cd65f09270..e0e3d78c4e552007c51a992418851cee60a50778 100644 (file)
@@ -8,6 +8,7 @@ import junit.framework.Assert;
 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.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;\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
@@ -28,7 +29,7 @@ public class TableModInputMessageFactoryTest {
     @Test\r
     public void testTableModInput() throws Exception {\r
         TableModInputBuilder builder = new TableModInputBuilder();\r
-        BufferHelper.setupHeader(builder);\r
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
         builder.setTableId(new TableId(9L));\r
         builder.setConfig(new TableConfig(true));\r
         TableModInput message = builder.build();\r
index a125764f97e1cce81ff6eae9932501332f12bb4b..aac10dab7fb5705aa7526884e54c3c0548fd37f0 100644 (file)
@@ -65,7 +65,17 @@ public abstract class BufferHelper {
      * @param length expected length of message in header\r
      */\r
     public static void checkHeaderV13(ByteBuf input, byte msgType, int length) {\r
-        checkHeader(input, msgType, length, HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
+        checkHeader(input, msgType, length, (short) EncodeConstants.OF13_VERSION_ID);\r
+    }\r
+    \r
+    /**\r
+     * Use version 1.0 for encoded message\r
+     * @param input ByteBuf to be checked for correct OpenFlow Protocol header\r
+     * @param msgType type of received message\r
+     * @param length expected length of message in header\r
+     */\r
+    public static void checkHeaderV10(ByteBuf input, byte msgType, int length) {\r
+        checkHeader(input, msgType, length, (short) EncodeConstants.OF10_VERSION_ID);\r
     }\r
     \r
     private static void checkHeader(ByteBuf input, byte msgType, int length, Short version) {\r
@@ -80,7 +90,14 @@ public abstract class BufferHelper {
      * @param ofHeader OpenFlow protocol header\r
      */\r
     public static void checkHeaderV13(OfHeader ofHeader) {\r
-        checkHeader(ofHeader,  HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
+        checkHeader(ofHeader, (short) EncodeConstants.OF13_VERSION_ID);\r
+    }\r
+    \r
+    /**\r
+     * @param ofHeader OpenFlow protocol header\r
+     */\r
+    public static void checkHeaderV10(OfHeader ofHeader) {\r
+        checkHeader(ofHeader, (short) EncodeConstants.OF10_VERSION_ID);\r
     }\r
     \r
     private static void checkHeader(OfHeader ofHeader, Short version) {\r
@@ -90,15 +107,16 @@ public abstract class BufferHelper {
     \r
     /**\r
      * @param builder\r
+     * @param version wire protocol number used\r
      * @throws NoSuchMethodException\r
      * @throws SecurityException\r
      * @throws IllegalAccessException\r
      * @throws IllegalArgumentException\r
      * @throws InvocationTargetException\r
      */\r
-    public static void setupHeader(Object builder) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {\r
+    public static void setupHeader(Object builder, int version) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {\r
         Method m = builder.getClass().getMethod("setVersion", Short.class);\r
-        m.invoke(builder, HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
+        m.invoke(builder, (short) version);\r
         Method m2 = builder.getClass().getMethod("setXid", Long.class);\r
         m2.invoke(builder, BufferHelper.DEFAULT_XID);\r
     }\r
@@ -110,7 +128,17 @@ public abstract class BufferHelper {
      * @return message decoded pojo\r
      */\r
     public static <E extends DataObject> E decodeV13(OFDeserializer<E> decoder, ByteBuf bb) {\r
-        return bufferToMessage(decoder, HelloMessageFactoryTest.VERSION_YET_SUPPORTED, bb);\r
+        return bufferToMessage(decoder, EncodeConstants.OF13_VERSION_ID, bb);\r
+    }\r
+    \r
+    /**\r
+     * Use version 1.0 for decoding message\r
+     * @param decoder decoder instance\r
+     * @param bb data input buffer\r
+     * @return message decoded pojo\r
+     */\r
+    public static <E extends DataObject> E decodeV10(OFDeserializer<E> decoder, ByteBuf bb) {\r
+        return bufferToMessage(decoder, EncodeConstants.OF10_VERSION_ID, bb);\r
     }\r
     \r
     private static <E extends DataObject> E bufferToMessage(OFDeserializer<E> decoder, short version, ByteBuf bb) {\r