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
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
} \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
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
}\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
}\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
}\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
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.";
}
}
}
}
}
}
+
+ 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 {
// 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.";
}
}
}
}
}
- 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.";
- }
- }
- }
}
import java.util.List;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.slf4j.Logger;
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);
/**
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
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
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
*/\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
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
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
*/
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
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
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
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
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
*/
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
+++ /dev/null
-/* 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
+++ /dev/null
-/* 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
+++ /dev/null
-/* 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
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
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
+++ /dev/null
-/* 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
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
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
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
*/\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
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
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
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
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
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
\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
+++ /dev/null
-/* 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
+++ /dev/null
-/* 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
+++ /dev/null
-/* 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
+++ /dev/null
-/* 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
+++ /dev/null
-/* 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
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
\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
/* 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
\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
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
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
\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
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
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
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());
}
}
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
@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
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
* @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
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
* @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
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
@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
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
@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
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
* @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
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
* @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
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;
@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();
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
@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
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
@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
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
@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
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
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
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
@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
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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
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
@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
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
@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
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
@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
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
@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
\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
* @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
\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
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
@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
* @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
* @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
\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
* @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