Extend openflow-protocol-impl serialization 49/31349/3
authorpeppepetra <giuseppex.petralia@intel.com>
Tue, 15 Dec 2015 13:48:25 +0000 (13:48 +0000)
committerMichal Polkorab <michal.polkorab@pantheon.sk>
Thu, 17 Dec 2015 12:23:04 +0000 (12:23 +0000)
     - Add new serializers/deserializers for OF1.0/1.3
     - Register new MessageFactory's
     - Register new TypeToClass's
     - Add relevant unit tests for each factory

Change-Id: I9a711aef3d7c4a934369ed1d9e9edfdd0d995f98
Signed-off-by: peppepetra <giuseppex.petralia@intel.com>
114 files changed:
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/AdditionalMessageFactoryInitializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestAggregateInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestDescInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestFlowInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestGroupInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterConfigInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestPortStatsInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestQueueInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableFeaturesInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputAggregateFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputDescFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFlowFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputPortStatsFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputQueueFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputTableFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactoryTest.java [new file with mode: 0644]

diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java
new file mode 100644 (file)
index 0000000..adbec25
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncRequestMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetFeaturesInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetQueueConfigInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GroupModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MeterModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesRequestMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetQueueConfigInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketOutInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10SetConfigMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsRequestInputFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketOutInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleRequestInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.SetAsyncInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.SetConfigInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.TableModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class AdditionalMessageDeserializerInitializer {
+    private AdditionalMessageDeserializerInitializer() {
+        throw new UnsupportedOperationException("Utility class shouldn't be instantiated");
+    }
+
+    /**
+     * Registers additional message deserializers.
+     *
+     * @param registry
+     *            registry to be filled with deserializers
+     */
+    public static void registerMessageDeserializers(DeserializerRegistry registry) {
+
+        SimpleDeserializerRegistryHelper helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID,
+                registry);
+
+        // register OF v1.0 message deserializers
+        helper.registerDeserializer(5, null, GetFeaturesInput.class, new OF10FeaturesRequestMessageFactory());
+        helper.registerDeserializer(7, null, GetConfigInput.class, new OF10GetConfigInputMessageFactory());
+        helper.registerDeserializer(9, null, SetConfigInput.class, new OF10SetConfigMessageFactory());
+        helper.registerDeserializer(13, null, PacketOutInput.class, new OF10PacketOutInputMessageFactory());
+        helper.registerDeserializer(14, null, FlowModInput.class, new OF10FlowModInputMessageFactory());
+        helper.registerDeserializer(15, null, PortModInput.class, new OF10PortModInputMessageFactory());
+        helper.registerDeserializer(16, null, MultipartRequestInput.class, new OF10StatsRequestInputFactory());
+        helper.registerDeserializer(18, null, BarrierInput.class, new OF10BarrierInputMessageFactory());
+        helper.registerDeserializer(20, null, GetQueueConfigInput.class, new OF10GetQueueConfigInputMessageFactory());
+
+        // register Of v1.3 message deserializers
+        helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry);
+        helper.registerDeserializer(5, null, GetFeaturesInput.class, new GetFeaturesInputMessageFactory());
+        helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory());
+        helper.registerDeserializer(9, null, SetConfigInput.class, new SetConfigInputMessageFactory());
+        helper.registerDeserializer(13, null, PacketOutInput.class, new PacketOutInputMessageFactory());
+        helper.registerDeserializer(14, null, FlowModInput.class, new FlowModInputMessageFactory());
+        helper.registerDeserializer(15, null, GroupModInput.class, new GroupModInputMessageFactory());
+        helper.registerDeserializer(16, null, PortModInput.class, new PortModInputMessageFactory());
+        helper.registerDeserializer(17, null, TableModInput.class, new TableModInputMessageFactory());
+        helper.registerDeserializer(18, null, MultipartRequestInput.class, new MultipartRequestInputMessageFactory());
+        helper.registerDeserializer(20, null, BarrierInput.class, new BarrierInputMessageFactory());
+        helper.registerDeserializer(22, null, GetQueueConfigInput.class, new GetQueueConfigInputMessageFactory());
+        helper.registerDeserializer(24, null, RoleRequestInput.class, new RoleRequestInputMessageFactory());
+        helper.registerDeserializer(26, null, GetAsyncInput.class, new GetAsyncRequestMessageFactory());
+        helper.registerDeserializer(28, null, SetAsyncInput.class, new SetAsyncInputMessageFactory());
+        helper.registerDeserializer(29, null, MeterModInput.class, new MeterModInputMessageFactory());
+    }
+
+}
index 51e1ff6ffe64fa98b95ec884e12521ad0cd7d3c5..bf535b2d2aaf8acbdeefc23f66181edf31149dfc 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 /**
  * @author michal.polkorab
  * @author timotej.kubas
+ * @author giuseppex.petralia@intel.com
  */
 public class DeserializationFactory {
 
@@ -34,13 +35,19 @@ public class DeserializationFactory {
     public DeserializationFactory() {
         final Map<TypeToClassKey, Class<?>> temp = new HashMap<>();
         TypeToClassMapInitializer.initializeTypeToClassMap(temp);
+
+        // Register type to class map for additional deserializers
+        TypeToClassMapInitializer.initializeAdditionalTypeToClassMap(temp);
+
         messageClassMap = ImmutableMap.copyOf(temp);
     }
 
     /**
      * Transforms ByteBuf into correct POJO message
+     *
      * @param rawMessage
-     * @param version version decoded from OpenFlow protocol message
+     * @param version
+     *            version decoded from OpenFlow protocol message
      * @return correct POJO as DataObject
      */
     public DataObject deserialize(final ByteBuf rawMessage, final short version) {
@@ -48,8 +55,7 @@ public class DeserializationFactory {
         int type = rawMessage.readUnsignedByte();
         Class<?> clazz = messageClassMap.get(new TypeToClassKey(version, type));
         rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-        OFDeserializer<DataObject> deserializer = registry.getDeserializer(
-                new MessageCodeKey(version, type, clazz));
+        OFDeserializer<DataObject> deserializer = registry.getDeserializer(new MessageCodeKey(version, type, clazz));
         dataObject = deserializer.deserialize(rawMessage);
         return dataObject;
     }
index bbbb0681519c86abf523a4bd57f3f87ba6322625..6ee4818344ec655ab57480897d63a3ff1b5af383 100644 (file)
@@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Stores and registers deserializers
+ *
  * @author michal.polkorab
  */
 public class DeserializerRegistryImpl implements DeserializerRegistry {
@@ -37,14 +38,20 @@ public class DeserializerRegistryImpl implements DeserializerRegistry {
     @Override
     public void init() {
         registry = new HashMap<>();
+
         // register message deserializers
         MessageDeserializerInitializer.registerMessageDeserializers(this);
 
+        // register additional message deserializers
+        AdditionalMessageDeserializerInitializer.registerMessageDeserializers(this);
+
         // register common structure deserializers
-        registerDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,
-                EncodeConstants.EMPTY_VALUE, MatchV10.class), new OF10MatchDeserializer());
-        registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
-                EncodeConstants.EMPTY_VALUE, Match.class), new MatchDeserializer());
+        registerDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class),
+                new OF10MatchDeserializer());
+        registerDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class),
+                new MatchDeserializer());
 
         // register match entry deserializers
         MatchEntryDeserializerInitializer.registerMatchEntryDeserializers(this);
@@ -56,8 +63,7 @@ public class DeserializerRegistryImpl implements DeserializerRegistry {
 
     @Override
     @SuppressWarnings("unchecked")
-    public <T extends OFGeneralDeserializer> T getDeserializer(
-            MessageCodeKey key) {
+    public <T extends OFGeneralDeserializer> T getDeserializer(MessageCodeKey key) {
         OFGeneralDeserializer deserializer = registry.get(key);
         if (deserializer == null) {
             throw new IllegalStateException("Deserializer for key: " + key
@@ -67,15 +73,14 @@ public class DeserializerRegistryImpl implements DeserializerRegistry {
     }
 
     @Override
-    public void registerDeserializer(MessageCodeKey key,
-            OFGeneralDeserializer deserializer) {
+    public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer) {
         if ((key == null) || (deserializer == null)) {
             throw new IllegalArgumentException("MessageCodeKey or Deserializer is null");
         }
         OFGeneralDeserializer desInRegistry = registry.put(key, deserializer);
         if (desInRegistry != null) {
-            LOGGER.debug("Deserializer for key {} overwritten. Old deserializer: {}, new deserializer: {}",
-                    key, desInRegistry.getClass().getName(), deserializer.getClass().getName());
+            LOGGER.debug("Deserializer for key {} overwritten. Old deserializer: {}, new deserializer: {}", key,
+                    desInRegistry.getClass().getName(), deserializer.getClass().getName());
         }
         if (deserializer instanceof DeserializerRegistryInjector) {
             ((DeserializerRegistryInjector) deserializer).injectDeserializerRegistry(this);
index 37f3a71ff3f64fa008591e918cd1e0bd726d004b..0e6720247913a774eb5e1c26936645663e19c077 100644 (file)
@@ -66,12 +66,14 @@ public final class MessageDeserializerInitializer {
 
     /**
      * Registers message deserializers
-     * @param registry registry to be filled with deserializers
+     *
+     * @param registry
+     *            registry to be filled with deserializers
      */
     public static void registerMessageDeserializers(DeserializerRegistry registry) {
         // register OF v1.0 message deserializers
-        SimpleDeserializerRegistryHelper helper =
-                new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry);
+        SimpleDeserializerRegistryHelper helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID,
+                registry);
         helper.registerDeserializer(0, null, HelloMessage.class, new OF10HelloMessageFactory());
         helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory());
         helper.registerDeserializer(2, null, EchoRequestMessage.class, new OF10EchoRequestMessageFactory());
@@ -85,6 +87,7 @@ public final class MessageDeserializerInitializer {
         helper.registerDeserializer(17, null, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory());
         helper.registerDeserializer(19, null, BarrierOutput.class, new OF10BarrierReplyMessageFactory());
         helper.registerDeserializer(21, null, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory());
+
         // register Of v1.3 message deserializers
         helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry);
         helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory());
index 9ed52140e7ee489be17a38124983ea270137381d..97ae5364ae01d7ecc418e609601aa2e8b5526e8f 100644 (file)
@@ -8,28 +8,43 @@
 package org.opendaylight.openflowjava.protocol.impl.deserialization;
 
 import java.util.Map;
-
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper;
 import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
 
 /**
  * @author michal.polkorab
+ * @author giuseppex.petralia@intel.com
  *
  */
 public final class TypeToClassMapInitializer {
@@ -40,12 +55,12 @@ public final class TypeToClassMapInitializer {
 
     /**
      * Initializes type to class map
+     *
      * @param messageClassMap
      */
     public static void initializeTypeToClassMap(Map<TypeToClassKey, Class<?>> messageClassMap) {
         // init OF v1.0 mapping
-        TypeToClassInitHelper helper =
-                new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap);
+        TypeToClassInitHelper helper = new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap);
         helper.registerTypeToClass((short) 0, HelloMessage.class);
         helper.registerTypeToClass((short) 1, ErrorMessage.class);
         helper.registerTypeToClass((short) 2, EchoRequestMessage.class);
@@ -59,7 +74,7 @@ public final class TypeToClassMapInitializer {
         helper.registerTypeToClass((short) 17, MultipartReplyMessage.class);
         helper.registerTypeToClass((short) 19, BarrierOutput.class);
         helper.registerTypeToClass((short) 21, GetQueueConfigOutput.class);
-        // init OF v1.0 mapping
+        // init OF v1.3 mapping
         helper = new TypeToClassInitHelper(EncodeConstants.OF13_VERSION_ID, messageClassMap);
         helper.registerTypeToClass((short) 0, HelloMessage.class);
         helper.registerTypeToClass((short) 1, ErrorMessage.class);
@@ -77,4 +92,41 @@ public final class TypeToClassMapInitializer {
         helper.registerTypeToClass((short) 25, RoleRequestOutput.class);
         helper.registerTypeToClass((short) 27, GetAsyncOutput.class);
     }
+
+    /**
+     * Initializes type to class map to associate OF code to Java Class for
+     * messages for additional deserializers.
+     *
+     * @param messageClassMap
+     */
+    public static void initializeAdditionalTypeToClassMap(Map<TypeToClassKey, Class<?>> messageClassMap) {
+        // init OF v1.0 mapping
+        TypeToClassInitHelper helper = new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap);
+        helper.registerTypeToClass((short) 5, GetFeaturesInput.class);
+        helper.registerTypeToClass((short) 7, GetConfigInput.class);
+        helper.registerTypeToClass((short) 9, SetConfigInput.class);
+        helper.registerTypeToClass((short) 13, PacketOutInput.class);
+        helper.registerTypeToClass((short) 14, FlowModInput.class);
+        helper.registerTypeToClass((short) 15, PortModInput.class);
+        helper.registerTypeToClass((short) 16, MultipartRequestInput.class);
+        helper.registerTypeToClass((short) 18, BarrierInput.class);
+        helper.registerTypeToClass((short) 20, GetQueueConfigInput.class);
+        // init OF v1.3 mapping
+        helper = new TypeToClassInitHelper(EncodeConstants.OF13_VERSION_ID, messageClassMap);
+        helper.registerTypeToClass((short) 5, GetFeaturesInput.class);
+        helper.registerTypeToClass((short) 7, GetConfigInput.class);
+        helper.registerTypeToClass((short) 9, SetConfigInput.class);
+        helper.registerTypeToClass((short) 13, PacketOutInput.class);
+        helper.registerTypeToClass((short) 14, FlowModInput.class);
+        helper.registerTypeToClass((short) 15, GroupModInput.class);
+        helper.registerTypeToClass((short) 16, PortModInput.class);
+        helper.registerTypeToClass((short) 17, TableModInput.class);
+        helper.registerTypeToClass((short) 18, MultipartRequestInput.class);
+        helper.registerTypeToClass((short) 20, BarrierInput.class);
+        helper.registerTypeToClass((short) 22, GetQueueConfigInput.class);
+        helper.registerTypeToClass((short) 24, RoleRequestInput.class);
+        helper.registerTypeToClass((short) 26, GetAsyncInput.class);
+        helper.registerTypeToClass((short) 28, SetAsyncInput.class);
+        helper.registerTypeToClass((short) 29, MeterModInput.class);
+    }
 }
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactory.java
new file mode 100644 (file)
index 0000000..fd3af02
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class BarrierInputMessageFactory implements OFDeserializer<BarrierInput>{
+
+    @Override
+    public BarrierInput deserialize(ByteBuf rawMessage) {
+        BarrierInputBuilder builder = new BarrierInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        return builder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactory.java
new file mode 100644 (file)
index 0000000..1531c8e
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.math.BigInteger;
+import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
+
+/**
+ * Translates FlowModInput messages
+ */
+public class FlowModInputMessageFactory implements OFDeserializer<FlowModInput>, DeserializerRegistryInjector {
+
+    private static final byte PADDING = 2;
+    private DeserializerRegistry registry;
+
+    @Override
+    public FlowModInput deserialize(ByteBuf rawMessage) {
+        FlowModInputBuilder builder = new FlowModInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        rawMessage.readBytes(cookie);
+        builder.setCookie(new BigInteger(1, cookie));
+        byte[] cookie_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        rawMessage.readBytes(cookie_mask);
+        builder.setCookieMask(new BigInteger(1, cookie_mask));
+        builder.setTableId(new TableId((long) rawMessage.readUnsignedByte()));
+        builder.setCommand(FlowModCommand.forValue(rawMessage.readUnsignedByte()));
+        builder.setIdleTimeout(rawMessage.readUnsignedShort());
+        builder.setHardTimeout(rawMessage.readUnsignedShort());
+        builder.setPriority(rawMessage.readUnsignedShort());
+        builder.setBufferId(rawMessage.readUnsignedInt());
+        builder.setOutPort(new PortNumber(rawMessage.readUnsignedInt()));
+        builder.setOutGroup(rawMessage.readUnsignedInt());
+        builder.setFlags(createFlowModFlagsFromBitmap(rawMessage.readUnsignedShort()));
+        rawMessage.skipBytes(PADDING);
+        OFDeserializer<Match> matchDeserializer = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
+        builder.setMatch(matchDeserializer.deserialize(rawMessage));
+        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
+        List<Instruction> instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
+                rawMessage.readableBytes(), rawMessage, keyMaker, registry);
+        builder.setInstruction(instructions);
+        return builder.build();
+    }
+
+    private static FlowModFlags createFlowModFlagsFromBitmap(int input) {
+        final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) > 0;
+        final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0;
+        final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0;
+        final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) > 0;
+        final Boolean _oFPFFNOBYTCOUNTS = (input & (1 << 4)) > 0;
+        return new FlowModFlags(_oFPFFCHECKOVERLAP, _oFPFFNOBYTCOUNTS, _oFPFFNOPKTCOUNTS, _oFPFFRESETCOUNTS,
+                _oFPFFSENDFLOWREM);
+    }
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactory.java
new file mode 100644 (file)
index 0000000..6a3485e
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GetAsyncRequestMessageFactory implements OFDeserializer<GetAsyncInput> {
+
+    @Override
+    public GetAsyncInput deserialize(ByteBuf rawMessage) {
+        GetAsyncInputBuilder builder = new GetAsyncInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid((rawMessage.readUnsignedInt()));
+        return builder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java
new file mode 100644 (file)
index 0000000..5c6fd0b
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GetConfigInputMessageFactory implements OFDeserializer<GetConfigInput> {
+
+    @Override
+    public GetConfigInput deserialize(ByteBuf rawMessage) {
+        GetConfigInputBuilder builder = new GetConfigInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        return builder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputMessageFactory.java
new file mode 100644 (file)
index 0000000..4295644
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder;
+
+public class GetFeaturesInputMessageFactory implements OFDeserializer<GetFeaturesInput> {
+
+    @Override
+    public GetFeaturesInput deserialize(ByteBuf rawMessage) {
+        GetFeaturesInputBuilder builder = new GetFeaturesInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        return builder.build();
+    }
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactory.java
new file mode 100644 (file)
index 0000000..8b63dac
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.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;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GetQueueConfigInputMessageFactory implements OFDeserializer<GetQueueConfigInput> {
+
+    @Override
+    public GetQueueConfigInput deserialize(ByteBuf rawMessage) {
+        GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid((rawMessage.readUnsignedInt()));
+        builder.setPort(new PortNumber(rawMessage.readUnsignedInt()));
+        return builder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactory.java
new file mode 100644 (file)
index 0000000..5d7de02
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GroupModInputMessageFactory implements OFDeserializer<GroupModInput>, DeserializerRegistryInjector {
+
+    private DeserializerRegistry registry;
+    private static final byte PADDING = 1;
+    private static final byte PADDING_IN_BUCKETS_HEADER = 4;
+    private static final byte BUCKETS_HEADER_LENGTH = 16;
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
+
+    @Override
+    public GroupModInput deserialize(ByteBuf rawMessage) {
+        GroupModInputBuilder builder = new GroupModInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setCommand(GroupModCommand.forValue(rawMessage.readUnsignedShort()));
+        builder.setType(GroupType.forValue(rawMessage.readUnsignedByte()));
+        rawMessage.skipBytes(PADDING);
+        builder.setGroupId(new GroupId(rawMessage.readUnsignedInt()));
+        List<BucketsList> bucketsList = new ArrayList<>();
+        while (rawMessage.readableBytes() > 0) {
+            BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
+            int bucketsLength = rawMessage.readUnsignedShort();
+            bucketsBuilder.setWeight(rawMessage.readUnsignedShort());
+            bucketsBuilder.setWatchPort(new PortNumber(rawMessage.readUnsignedInt()));
+            bucketsBuilder.setWatchGroup(rawMessage.readUnsignedInt());
+            rawMessage.skipBytes(PADDING_IN_BUCKETS_HEADER);
+            CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
+            List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
+                    bucketsLength - BUCKETS_HEADER_LENGTH, rawMessage, keyMaker, registry);
+            bucketsBuilder.setAction(actions);
+            bucketsList.add(bucketsBuilder.build());
+        }
+        builder.setBucketsList(bucketsList);
+        return builder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactory.java
new file mode 100644 (file)
index 0000000..0196b4b
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MeterModInputMessageFactory implements OFDeserializer<MeterModInput>, DeserializerRegistryInjector {
+
+    private DeserializerRegistry registry;
+    private static final byte PADDING_IN_METER_BAND_DROP_HEADER = 4;
+    private static final byte PADDING_IN_METER_BAND_DSCP_HEADER = 3;
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
+
+    @Override
+    public MeterModInput deserialize(ByteBuf rawMessage) {
+        MeterModInputBuilder builder = new MeterModInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setCommand(MeterModCommand.forValue(rawMessage.readUnsignedShort()));
+        builder.setFlags(createMeterFlags(rawMessage.readUnsignedShort()));
+        builder.setMeterId(new MeterId(rawMessage.readUnsignedInt()));
+        List<Bands> bandsList = new ArrayList<>();
+        while (rawMessage.readableBytes() > 0) {
+            BandsBuilder bandsBuilder = new BandsBuilder();
+            int bandStartIndex = rawMessage.readerIndex();
+            int bandType = rawMessage.readUnsignedShort();
+            switch (bandType) {
+            case 1:
+                MeterBandDropCaseBuilder bandDropCaseBuilder = new MeterBandDropCaseBuilder();
+                MeterBandDropBuilder bandDropBuilder = new MeterBandDropBuilder();
+                bandDropBuilder.setType(MeterBandType.forValue(bandType));
+                rawMessage.readUnsignedShort();
+                bandDropBuilder.setRate(rawMessage.readUnsignedInt());
+                bandDropBuilder.setBurstSize(rawMessage.readUnsignedInt());
+                rawMessage.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
+                bandDropCaseBuilder.setMeterBandDrop(bandDropBuilder.build());
+                bandsBuilder.setMeterBand(bandDropCaseBuilder.build());
+                break;
+            case 2:
+                MeterBandDscpRemarkCaseBuilder bandDscpRemarkCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
+                MeterBandDscpRemarkBuilder bandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder();
+                bandDscpRemarkBuilder.setType(MeterBandType.forValue(bandType));
+                rawMessage.readUnsignedShort();
+                bandDscpRemarkBuilder.setRate(rawMessage.readUnsignedInt());
+                bandDscpRemarkBuilder.setBurstSize(rawMessage.readUnsignedInt());
+                bandDscpRemarkBuilder.setPrecLevel(rawMessage.readUnsignedByte());
+                rawMessage.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
+                bandDscpRemarkCaseBuilder.setMeterBandDscpRemark(bandDscpRemarkBuilder.build());
+                bandsBuilder.setMeterBand(bandDscpRemarkCaseBuilder.build());
+                break;
+            case 0xFFFF:
+                long expId = rawMessage
+                        .getUnsignedInt(rawMessage.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
+                rawMessage.readerIndex(bandStartIndex);
+                OFDeserializer<MeterBandExperimenterCase> deserializer = registry
+                        .getDeserializer(ExperimenterDeserializerKeyFactory
+                                .createMeterBandDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId));
+                bandsBuilder.setMeterBand(deserializer.deserialize(rawMessage));
+                break;
+            }
+            bandsList.add(bandsBuilder.build());
+        }
+        builder.setBands(bandsList);
+        return builder.build();
+    }
+
+    private static MeterFlags createMeterFlags(int input) {
+        final Boolean mfKBPS = (input & (1 << 0)) != 0;
+        final Boolean mfPKTPS = (input & (1 << 1)) != 0;
+        final Boolean mfBURST = (input & (1 << 2)) != 0;
+        final Boolean mfSTATS = (input & (1 << 3)) != 0;
+        return new MeterFlags(mfBURST, mfKBPS, mfPKTPS, mfSTATS);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestInputMessageFactory.java
new file mode 100644 (file)
index 0000000..008b22c
--- /dev/null
@@ -0,0 +1,433 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.desc._case.MultipartRequestGroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.features._case.MultipartRequestGroupFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.features._case.MultipartRequestMeterFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.desc._case.MultipartRequestPortDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartRequestInputMessageFactory
+        implements OFDeserializer<MultipartRequestInput>, DeserializerRegistryInjector {
+    private DeserializerRegistry registry;
+    private static final byte PADDING = 4;
+    private static final byte FLOW_PADDING_1 = 3;
+    private static final byte FLOW_PADDING_2 = 4;
+    private static final byte AGGREGATE_PADDING_1 = 3;
+    private static final byte AGGREGATE_PADDING_2 = 4;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES = 5;
+    private static final byte MAX_TABLE_NAME_LENGTH = 32;
+    private static final byte MULTIPART_REQUEST_TABLE_FEATURES_STRUCTURE_LENGTH = 64;
+    private static final byte COMMON_PROPERTY_LENGTH = 4;
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
+
+    @Override
+    public MultipartRequestInput deserialize(ByteBuf rawMessage) {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        int type = rawMessage.readUnsignedShort();
+        builder.setType(getMultipartType(type));
+        builder.setFlags(getMultipartRequestFlags(rawMessage.readUnsignedShort()));
+        rawMessage.skipBytes(PADDING);
+        switch (MultipartType.forValue(type)) {
+        case OFPMPDESC:
+            builder.setMultipartRequestBody(setDesc(rawMessage));
+            break;
+        case OFPMPFLOW:
+            builder.setMultipartRequestBody(setFlow(rawMessage));
+            break;
+        case OFPMPAGGREGATE:
+            builder.setMultipartRequestBody(setAggregate(rawMessage));
+            break;
+        case OFPMPTABLE:
+            builder.setMultipartRequestBody(setTable(rawMessage));
+            break;
+        case OFPMPTABLEFEATURES:
+            builder.setMultipartRequestBody(setTableFeatures(rawMessage));
+            break;
+        case OFPMPPORTSTATS:
+            builder.setMultipartRequestBody(setPortStats(rawMessage));
+            break;
+        case OFPMPPORTDESC:
+            builder.setMultipartRequestBody(setPortDesc(rawMessage));
+            break;
+        case OFPMPQUEUE:
+            builder.setMultipartRequestBody(setQueue(rawMessage));
+            break;
+        case OFPMPGROUP:
+            builder.setMultipartRequestBody(setGroup(rawMessage));
+            break;
+        case OFPMPGROUPDESC:
+            builder.setMultipartRequestBody(setGroupDesc(rawMessage));
+            break;
+        case OFPMPGROUPFEATURES:
+            builder.setMultipartRequestBody(setGroupFeatures(rawMessage));
+            break;
+        case OFPMPMETER:
+            builder.setMultipartRequestBody(setMeter(rawMessage));
+            break;
+        case OFPMPMETERCONFIG:
+            builder.setMultipartRequestBody(setMeterConfig(rawMessage));
+            break;
+        case OFPMPMETERFEATURES:
+            builder.setMultipartRequestBody(setMeterFeatures(rawMessage));
+            break;
+        case OFPMPEXPERIMENTER:
+            builder.setMultipartRequestBody(setExperimenter(rawMessage));
+            break;
+        default:
+            break;
+        }
+
+        return builder.build();
+    }
+
+    private static MultipartType getMultipartType(int input) {
+        return MultipartType.forValue(input);
+    }
+
+    private static MultipartRequestFlags getMultipartRequestFlags(int input) {
+        final Boolean _oFPMPFREQMORE = (input & (1 << 0)) > 0;
+        MultipartRequestFlags flag = new MultipartRequestFlags(_oFPMPFREQMORE);
+        return flag;
+    }
+
+    private MultipartRequestTableFeaturesCase setTableFeatures(ByteBuf input) {
+        MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
+        MultipartRequestTableFeaturesBuilder tableFeaturesBuilder = new MultipartRequestTableFeaturesBuilder();
+        List<TableFeatures> features = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
+            int length = input.readUnsignedShort();
+            featuresBuilder.setTableId(input.readUnsignedByte());
+            input.skipBytes(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES);
+            featuresBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH));
+            byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            input.readBytes(metadataMatch);
+            featuresBuilder.setMetadataMatch(new BigInteger(1, metadataMatch));
+            byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            input.readBytes(metadataWrite);
+            featuresBuilder.setMetadataWrite(new BigInteger(1, metadataWrite));
+            featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));
+            featuresBuilder.setMaxEntries(input.readUnsignedInt());
+            featuresBuilder.setTableFeatureProperties(
+                    createTableFeaturesProperties(input, length - MULTIPART_REQUEST_TABLE_FEATURES_STRUCTURE_LENGTH));
+            features.add(featuresBuilder.build());
+        }
+        tableFeaturesBuilder.setTableFeatures(features);
+        caseBuilder.setMultipartRequestTableFeatures(tableFeaturesBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {
+        List<TableFeatureProperties> properties = new ArrayList<>();
+        int tableFeaturesLength = length;
+        while (tableFeaturesLength > 0) {
+            int propStartIndex = input.readerIndex();
+            TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder();
+            TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort());
+            builder.setType(type);
+            int propertyLength = input.readUnsignedShort();
+            int paddingRemainder = propertyLength % EncodeConstants.PADDING;
+            tableFeaturesLength -= propertyLength;
+            if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
+                InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
+                CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
+                List<Instruction> instructions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID,
+                        propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
+                insBuilder.setInstruction(instructions);
+                builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());
+            } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES)
+                    || type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {
+                propertyLength -= COMMON_PROPERTY_LENGTH;
+                NextTableRelatedTableFeaturePropertyBuilder tableBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
+                List<NextTableIds> ids = new ArrayList<>();
+                while (propertyLength > 0) {
+                    NextTableIdsBuilder nextTableIdsBuilder = new NextTableIdsBuilder();
+                    nextTableIdsBuilder.setTableId(input.readUnsignedByte());
+                    ids.add(nextTableIdsBuilder.build());
+                    propertyLength--;
+                }
+                tableBuilder.setNextTableIds(ids);
+                builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, tableBuilder.build());
+            } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
+                ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
+                CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
+                List<Action> actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID,
+                        propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
+                actionBuilder.setAction(actions);
+                builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());
+            } else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH)
+                    || type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELD)
+                    || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD)
+                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {
+                OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+                CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
+                List<MatchEntry> entries = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID,
+                        propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
+                oxmBuilder.setMatchEntry(entries);
+                builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+            } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)
+                    || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {
+                long expId = input.readUnsignedInt();
+                input.readerIndex(propStartIndex);
+                OFDeserializer<TableFeatureProperties> propDeserializer = registry
+                        .getDeserializer(ExperimenterDeserializerKeyFactory
+                                .createMultipartReplyTFDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId));
+                TableFeatureProperties expProp = propDeserializer.deserialize(input);
+                properties.add(expProp);
+                continue;
+            }
+            if (paddingRemainder != 0) {
+                input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
+                tableFeaturesLength -= EncodeConstants.PADDING - paddingRemainder;
+            }
+            properties.add(builder.build());
+        }
+        return properties;
+    }
+
+    private static TableConfig createTableConfig(long input) {
+        boolean deprecated = (input & 3) != 0;
+        return new TableConfig(deprecated);
+    }
+
+    private MultipartRequestDescCase setDesc(ByteBuf input) {
+        MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder();
+        MultipartRequestDescBuilder descBuilder = new MultipartRequestDescBuilder();
+        descBuilder.setEmpty(true);
+        caseBuilder.setMultipartRequestDesc(descBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestFlowCase setFlow(ByteBuf input) {
+        MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder();
+        MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder();
+        flowBuilder.setTableId(input.readUnsignedByte());
+        input.skipBytes(FLOW_PADDING_1);
+        flowBuilder.setOutPort(input.readUnsignedInt());
+        flowBuilder.setOutGroup(input.readUnsignedInt());
+        input.skipBytes(FLOW_PADDING_2);
+        byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        input.readBytes(cookie);
+        flowBuilder.setCookie(new BigInteger(1, cookie));
+        byte[] cookie_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        input.readBytes(cookie_mask);
+        flowBuilder.setCookieMask(new BigInteger(1, cookie_mask));
+        OFDeserializer<Match> matchDeserializer = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
+        flowBuilder.setMatch(matchDeserializer.deserialize(input));
+        caseBuilder.setMultipartRequestFlow(flowBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestAggregateCase setAggregate(ByteBuf input) {
+        MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
+        MultipartRequestAggregateBuilder aggregateBuilder = new MultipartRequestAggregateBuilder();
+        aggregateBuilder.setTableId(input.readUnsignedByte());
+        input.skipBytes(AGGREGATE_PADDING_1);
+        aggregateBuilder.setOutPort(input.readUnsignedInt());
+        aggregateBuilder.setOutGroup(input.readUnsignedInt());
+        input.skipBytes(AGGREGATE_PADDING_2);
+        byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        input.readBytes(cookie);
+        aggregateBuilder.setCookie(new BigInteger(1, cookie));
+        byte[] cookie_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        input.readBytes(cookie_mask);
+        aggregateBuilder.setCookieMask(new BigInteger(1, cookie_mask));
+        OFDeserializer<Match> matchDeserializer = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
+        aggregateBuilder.setMatch(matchDeserializer.deserialize(input));
+        caseBuilder.setMultipartRequestAggregate(aggregateBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestPortDescCase setPortDesc(ByteBuf input) {
+        MultipartRequestPortDescCaseBuilder caseBuilder = new MultipartRequestPortDescCaseBuilder();
+        MultipartRequestPortDescBuilder portBuilder = new MultipartRequestPortDescBuilder();
+        portBuilder.setEmpty(true);
+        caseBuilder.setMultipartRequestPortDesc(portBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestPortStatsCase setPortStats(ByteBuf input) {
+        MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder();
+        MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder();
+        portBuilder.setPortNo(input.readUnsignedInt());
+        caseBuilder.setMultipartRequestPortStats(portBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestQueueCase setQueue(ByteBuf input) {
+        MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
+        MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder();
+        queueBuilder.setPortNo(input.readUnsignedInt());
+        queueBuilder.setQueueId(input.readUnsignedInt());
+        caseBuilder.setMultipartRequestQueue(queueBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestGroupCase setGroup(ByteBuf input) {
+        MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
+        MultipartRequestGroupBuilder groupBuilder = new MultipartRequestGroupBuilder();
+        groupBuilder.setGroupId(new GroupId(input.readUnsignedInt()));
+        caseBuilder.setMultipartRequestGroup(groupBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestGroupDescCase setGroupDesc(ByteBuf input) {
+        MultipartRequestGroupDescCaseBuilder caseBuilder = new MultipartRequestGroupDescCaseBuilder();
+        MultipartRequestGroupDescBuilder groupBuilder = new MultipartRequestGroupDescBuilder();
+        groupBuilder.setEmpty(true);
+        caseBuilder.setMultipartRequestGroupDesc(groupBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestGroupFeaturesCase setGroupFeatures(ByteBuf input) {
+        MultipartRequestGroupFeaturesCaseBuilder caseBuilder = new MultipartRequestGroupFeaturesCaseBuilder();
+        MultipartRequestGroupFeaturesBuilder groupBuilder = new MultipartRequestGroupFeaturesBuilder();
+        groupBuilder.setEmpty(true);
+        caseBuilder.setMultipartRequestGroupFeatures(groupBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestMeterCase setMeter(ByteBuf input) {
+        MultipartRequestMeterCaseBuilder caseBuilder = new MultipartRequestMeterCaseBuilder();
+        MultipartRequestMeterBuilder meterBuilder = new MultipartRequestMeterBuilder();
+        meterBuilder.setMeterId(new MeterId(input.readUnsignedInt()));
+        caseBuilder.setMultipartRequestMeter(meterBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestMeterConfigCase setMeterConfig(ByteBuf input) {
+        MultipartRequestMeterConfigCaseBuilder caseBuilder = new MultipartRequestMeterConfigCaseBuilder();
+        MultipartRequestMeterConfigBuilder meterBuilder = new MultipartRequestMeterConfigBuilder();
+        meterBuilder.setMeterId(new MeterId(input.readUnsignedInt()));
+        caseBuilder.setMultipartRequestMeterConfig(meterBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestMeterFeaturesCase setMeterFeatures(ByteBuf input) {
+        MultipartRequestMeterFeaturesCaseBuilder caseBuilder = new MultipartRequestMeterFeaturesCaseBuilder();
+        MultipartRequestMeterFeaturesBuilder meterBuilder = new MultipartRequestMeterFeaturesBuilder();
+        meterBuilder.setEmpty(true);
+        caseBuilder.setMultipartRequestMeterFeatures(meterBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestTableCase setTable(ByteBuf input) {
+        MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder();
+        MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder();
+        tableBuilder.setEmpty(true);
+        caseBuilder.setMultipartRequestTable(tableBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestExperimenterCase setExperimenter(ByteBuf input) {
+        MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
+        MultipartRequestExperimenterBuilder experimenterBuilder = new MultipartRequestExperimenterBuilder();
+        caseBuilder.setMultipartRequestExperimenter(experimenterBuilder.build());
+        return caseBuilder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactory.java
new file mode 100644 (file)
index 0000000..ab08ea3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10BarrierInputMessageFactory implements OFDeserializer<BarrierInput> {
+
+    @Override
+    public BarrierInput deserialize(ByteBuf rawMessage) {
+        BarrierInputBuilder builder = new BarrierInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        return builder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactory.java
new file mode 100644 (file)
index 0000000..1ff8c7a
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10FeaturesRequestMessageFactory implements OFDeserializer<GetFeaturesInput> {
+
+    @Override
+    public GetFeaturesInput deserialize(ByteBuf rawMessage) {
+        GetFeaturesInputBuilder builder = new GetFeaturesInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        return builder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactory.java
new file mode 100644 (file)
index 0000000..3357995
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.math.BigInteger;
+import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10FlowModInputMessageFactory implements OFDeserializer<FlowModInput>, DeserializerRegistryInjector {
+
+    private DeserializerRegistry registry;
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
+
+    @Override
+    public FlowModInput deserialize(ByteBuf rawMessage) {
+        FlowModInputBuilder builder = new FlowModInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
+        builder.setMatchV10(matchDeserializer.deserialize(rawMessage));
+        byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        rawMessage.readBytes(cookie);
+        builder.setCookie(new BigInteger(1, cookie));
+        builder.setCommand(FlowModCommand.forValue(rawMessage.readUnsignedShort()));
+        builder.setIdleTimeout(rawMessage.readUnsignedShort());
+        builder.setHardTimeout(rawMessage.readUnsignedShort());
+        builder.setPriority(rawMessage.readUnsignedShort());
+        builder.setBufferId(rawMessage.readUnsignedInt());
+        builder.setOutPort(new PortNumber((long) rawMessage.readUnsignedShort()));
+        builder.setFlagsV10(createFlowModFlagsFromBitmap(rawMessage.readUnsignedShort()));
+        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);
+
+        List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID,
+                rawMessage.readableBytes(), rawMessage, keyMaker, registry);
+        builder.setAction(actions);
+        return builder.build();
+    }
+
+    private static FlowModFlagsV10 createFlowModFlagsFromBitmap(int input) {
+        final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) > 0;
+        final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0;
+        final Boolean _oFPFFEMERG = (input & (1 << 2)) > 0;
+        return new FlowModFlagsV10(_oFPFFCHECKOVERLAP, _oFPFFEMERG, _oFPFFSENDFLOWREM);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactory.java
new file mode 100644 (file)
index 0000000..d46dcac
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10GetConfigInputMessageFactory implements OFDeserializer<GetConfigInput> {
+
+    @Override
+    public GetConfigInput deserialize(ByteBuf rawMessage) {
+        GetConfigInputBuilder builder = new GetConfigInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        return builder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactory.java
new file mode 100644 (file)
index 0000000..7584a73
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.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;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10GetQueueConfigInputMessageFactory implements OFDeserializer<GetQueueConfigInput> {
+
+    @Override
+    public GetQueueConfigInput deserialize(ByteBuf rawMessage) {
+        GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid((rawMessage.readUnsignedInt()));
+        builder.setPort(new PortNumber((long) rawMessage.readUnsignedShort()));
+        return builder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactory.java
new file mode 100644 (file)
index 0000000..1f4d2c1
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10PacketOutInputMessageFactory implements OFDeserializer<PacketOutInput>, DeserializerRegistryInjector {
+
+    private DeserializerRegistry registry;
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
+
+    @Override
+    public PacketOutInput deserialize(ByteBuf rawMessage) {
+        PacketOutInputBuilder builder = new PacketOutInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setBufferId(rawMessage.readUnsignedInt());
+        builder.setInPort(new PortNumber((long) rawMessage.readUnsignedShort()));
+        int actions_len = rawMessage.readShort();
+        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);
+        List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, actions_len,
+                rawMessage, keyMaker, registry);
+        builder.setAction(actions);
+
+        byte[] data = rawMessage.readBytes(rawMessage.readableBytes()).array();
+
+        if (data != null) {
+
+            builder.setData(data);
+        }
+        return builder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactory.java
new file mode 100644 (file)
index 0000000..1e869eb
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10PortModInputMessageFactory implements OFDeserializer<PortModInput> {
+
+    @Override
+    public PortModInput deserialize(ByteBuf rawMessage) {
+        PortModInputBuilder builder = new PortModInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setPortNo(new PortNumber((long) rawMessage.readUnsignedShort()));
+        byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
+        rawMessage.readBytes(hwAddress);
+        builder.setHwAddress(new MacAddress(ByteBufUtils.macAddressToString(hwAddress)));
+        builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt()));
+        builder.setMaskV10(createPortConfig(rawMessage.readUnsignedInt()));
+        builder.setAdvertiseV10(createPortFeatures(rawMessage.readUnsignedInt()));
+        return builder.build();
+    }
+
+    private static PortConfigV10 createPortConfig(long input) {
+        final Boolean _portDown = ((input) & (1 << 0)) > 0;
+        final Boolean _noStp = ((input) & (1 << 1)) > 0;
+        final Boolean _noRecv = ((input) & (1 << 2)) > 0;
+        final Boolean _noRecvStp = ((input) & (1 << 3)) > 0;
+        final Boolean _noFlood = ((input) & (1 << 4)) > 0;
+        final Boolean _noFwd = ((input) & (1 << 5)) > 0;
+        final Boolean _noPacketIn = ((input) & (1 << 6)) > 0;
+        return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown);
+    }
+
+    private static PortFeaturesV10 createPortFeatures(long input) {
+        final Boolean _10mbHd = ((input) & (1 << 0)) > 0;
+        final Boolean _10mbFd = ((input) & (1 << 1)) > 0;
+        final Boolean _100mbHd = ((input) & (1 << 2)) > 0;
+        final Boolean _100mbFd = ((input) & (1 << 3)) > 0;
+        final Boolean _1gbHd = ((input) & (1 << 4)) > 0;
+        final Boolean _1gbFd = ((input) & (1 << 5)) > 0;
+        final Boolean _10gbFd = ((input) & (1 << 6)) > 0;
+        final Boolean _copper = ((input) & (1 << 7)) > 0;
+        final Boolean _fiber = ((input) & (1 << 8)) > 0;
+        final Boolean _autoneg = ((input) & (1 << 9)) > 0;
+        final Boolean _pause = ((input) & (1 << 10)) > 0;
+        final Boolean _pauseAsym = ((input) & (1 << 11)) > 0;
+        return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _autoneg, _copper,
+                _fiber, _pause, _pauseAsym);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactory.java
new file mode 100644 (file)
index 0000000..23c4de2
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10SetConfigMessageFactory implements OFDeserializer<SetConfigInput> {
+
+    @Override
+    public SetConfigInput deserialize(ByteBuf rawMessage) {
+        SetConfigInputBuilder builder = new SetConfigInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort()));
+        builder.setMissSendLen(rawMessage.readUnsignedShort());
+        return builder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFactory.java
new file mode 100644 (file)
index 0000000..4f49f19
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10StatsRequestInputFactory
+        implements OFDeserializer<MultipartRequestInput>, DeserializerRegistryInjector {
+    private DeserializerRegistry registry;
+    private static final byte FLOW_PADDING_1 = 1;
+    private static final byte AGGREGATE_PADDING_1 = 1;
+
+    @Override
+    public MultipartRequestInput deserialize(ByteBuf rawMessage) {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        int type = rawMessage.readUnsignedShort();
+        builder.setType(getMultipartType(type));
+        builder.setFlags(getMultipartRequestFlags(rawMessage.readUnsignedShort()));
+        switch (getMultipartType(type)) {
+        case OFPMPDESC:
+            builder.setMultipartRequestBody(setDesc(rawMessage));
+            break;
+        case OFPMPFLOW:
+            builder.setMultipartRequestBody(setFlow(rawMessage));
+            break;
+        case OFPMPAGGREGATE:
+            builder.setMultipartRequestBody(setAggregate(rawMessage));
+            break;
+        case OFPMPTABLE:
+            builder.setMultipartRequestBody(setTable(rawMessage));
+            break;
+        case OFPMPPORTSTATS:
+            builder.setMultipartRequestBody(setPortStats(rawMessage));
+            break;
+        case OFPMPQUEUE:
+            builder.setMultipartRequestBody(setQueue(rawMessage));
+            break;
+        case OFPMPEXPERIMENTER:
+            builder.setMultipartRequestBody(setExperimenter(rawMessage));
+            break;
+        default:
+            break;
+        }
+        return builder.build();
+    }
+
+    private MultipartRequestExperimenterCase setExperimenter(ByteBuf input) {
+        MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
+        MultipartRequestExperimenterBuilder experimenterBuilder = new MultipartRequestExperimenterBuilder();
+        caseBuilder.setMultipartRequestExperimenter(experimenterBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestQueueCase setQueue(ByteBuf input) {
+        MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
+        MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder();
+        queueBuilder.setPortNo((long) input.readUnsignedShort());
+        input.skipBytes(2);
+        queueBuilder.setQueueId(input.readUnsignedInt());
+        caseBuilder.setMultipartRequestQueue(queueBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestPortStatsCase setPortStats(ByteBuf input) {
+        MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder();
+        MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder();
+        portBuilder.setPortNo((long) input.readUnsignedShort());
+        caseBuilder.setMultipartRequestPortStats(portBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestTableCase setTable(ByteBuf input) {
+        MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder();
+        MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder();
+        tableBuilder.setEmpty(true);
+        caseBuilder.setMultipartRequestTable(tableBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestAggregateCase setAggregate(ByteBuf input) {
+        MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
+        MultipartRequestAggregateBuilder aggregateBuilder = new MultipartRequestAggregateBuilder();
+        OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
+        aggregateBuilder.setMatchV10(matchDeserializer.deserialize(input));
+        aggregateBuilder.setTableId(input.readUnsignedByte());
+        input.skipBytes(AGGREGATE_PADDING_1);
+        aggregateBuilder.setOutPort((long) input.readUnsignedShort());
+        caseBuilder.setMultipartRequestAggregate(aggregateBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestFlowCase setFlow(ByteBuf input) {
+        MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder();
+        MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder();
+        OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
+        flowBuilder.setMatchV10(matchDeserializer.deserialize(input));
+        flowBuilder.setTableId(input.readUnsignedByte());
+        input.skipBytes(FLOW_PADDING_1);
+        flowBuilder.setOutPort((long) input.readUnsignedShort());
+        caseBuilder.setMultipartRequestFlow(flowBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private MultipartRequestDescCase setDesc(ByteBuf input) {
+        MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder();
+        MultipartRequestDescBuilder descBuilder = new MultipartRequestDescBuilder();
+        descBuilder.setEmpty(true);
+        caseBuilder.setMultipartRequestDesc(descBuilder.build());
+        return caseBuilder.build();
+    }
+
+    private static MultipartRequestFlags getMultipartRequestFlags(int input) {
+        final Boolean _oFPMPFREQMORE = (input & (1 << 0)) > 0;
+        MultipartRequestFlags flag = new MultipartRequestFlags(_oFPMPFREQMORE);
+        return flag;
+    }
+
+    private static MultipartType getMultipartType(int input) {
+        return MultipartType.forValue(input);
+    }
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java
new file mode 100644 (file)
index 0000000..6b1ddc9
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;
+
+public class PacketOutInputMessageFactory implements OFDeserializer<PacketOutInput>, DeserializerRegistryInjector {
+    private DeserializerRegistry registry;
+    private final byte PADDING = 6;
+
+    @Override
+    public PacketOutInput deserialize(ByteBuf rawMessage) {
+        PacketOutInputBuilder builder = new PacketOutInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setBufferId(rawMessage.readUnsignedInt());
+        builder.setInPort(new PortNumber(rawMessage.readUnsignedInt()));
+        int actions_len = rawMessage.readShort();
+        rawMessage.skipBytes(PADDING);
+        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
+        List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, actions_len,
+                rawMessage, keyMaker, registry);
+        builder.setAction(actions);
+        byte[] data = rawMessage.readBytes(rawMessage.readableBytes()).array();
+        if (data != null) {
+            builder.setData(data);
+        }
+        return builder.build();
+    }
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactory.java
new file mode 100644 (file)
index 0000000..37bfd72
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class PortModInputMessageFactory implements OFDeserializer<PortModInput> {
+
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_1 = 4;
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_2 = 2;
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_3 = 4;
+
+    @Override
+    public PortModInput deserialize(ByteBuf rawMessage) {
+        PortModInputBuilder builder = new PortModInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setPortNo(new PortNumber(rawMessage.readUnsignedInt()));
+        rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_1);
+        byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
+        rawMessage.readBytes(hwAddress);
+        builder.setHwAddress(new MacAddress(ByteBufUtils.macAddressToString(hwAddress)));
+        rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_2);
+        builder.setConfig(createPortConfig(rawMessage.readUnsignedInt()));
+        builder.setMask(createPortConfig(rawMessage.readUnsignedInt()));
+        builder.setAdvertise(createPortFeatures(rawMessage.readUnsignedInt()));
+        rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_3);
+        return builder.build();
+    }
+
+    private static PortConfig createPortConfig(long input) {
+        final Boolean pcPortDown = ((input) & (1 << 0)) != 0;
+        final Boolean pcNRecv = ((input) & (1 << 2)) != 0;
+        final Boolean pcNFwd = ((input) & (1 << 5)) != 0;
+        final Boolean pcNPacketIn = ((input) & (1 << 6)) != 0;
+        return new PortConfig(pcNFwd, pcNPacketIn, pcNRecv, pcPortDown);
+    }
+
+    private static PortFeatures createPortFeatures(long input) {
+        final Boolean pf10mbHd = ((input) & (1 << 0)) != 0;
+        final Boolean pf10mbFd = ((input) & (1 << 1)) != 0;
+        final Boolean pf100mbHd = ((input) & (1 << 2)) != 0;
+        final Boolean pf100mbFd = ((input) & (1 << 3)) != 0;
+        final Boolean pf1gbHd = ((input) & (1 << 4)) != 0;
+        final Boolean pf1gbFd = ((input) & (1 << 5)) != 0;
+        final Boolean pf10gbFd = ((input) & (1 << 6)) != 0;
+        final Boolean pf40gbFd = ((input) & (1 << 7)) != 0;
+        final Boolean pf100gbFd = ((input) & (1 << 8)) != 0;
+        final Boolean pf1tbFd = ((input) & (1 << 9)) != 0;
+        final Boolean pfOther = ((input) & (1 << 10)) != 0;
+        final Boolean pfCopper = ((input) & (1 << 11)) != 0;
+        final Boolean pfFiber = ((input) & (1 << 12)) != 0;
+        final Boolean pfAutoneg = ((input) & (1 << 13)) != 0;
+        final Boolean pfPause = ((input) & (1 << 14)) != 0;
+        final Boolean pfPauseAsym = ((input) & (1 << 15)) != 0;
+        return new PortFeatures(pf100gbFd, pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, pf1gbFd, pf1gbHd,
+                pf1tbFd, pf40gbFd, pfAutoneg, pfCopper, pfFiber, pfOther, pfPause, pfPauseAsym);
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactory.java
new file mode 100644 (file)
index 0000000..1627f2b
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.math.BigInteger;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class RoleRequestInputMessageFactory implements OFDeserializer<RoleRequestInput> {
+
+    private static final byte PADDING = 4;
+
+    @Override
+    public RoleRequestInput deserialize(ByteBuf rawMessage) {
+        RoleRequestInputBuilder builder = new RoleRequestInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid((rawMessage.readUnsignedInt()));
+        builder.setRole(ControllerRole.forValue(rawMessage.readInt()));
+        rawMessage.skipBytes(PADDING);
+        byte[] generationId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        rawMessage.readBytes(generationId);
+        builder.setGenerationId(new BigInteger(1, generationId));
+        return builder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactory.java
new file mode 100644 (file)
index 0000000..af18069
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class SetAsyncInputMessageFactory implements OFDeserializer<SetAsyncInput> {
+
+    private static final byte SEPARATE_ROLES = 2;
+
+    @Override
+    public SetAsyncInput deserialize(ByteBuf rawMessage) {
+        SetAsyncInputBuilder builder = new SetAsyncInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setPacketInMask(decodePacketInMask(rawMessage));
+        builder.setPortStatusMask(decodePortStatusMask(rawMessage));
+        builder.setFlowRemovedMask(decodeFlowRemovedMask(rawMessage));
+        return builder.build();
+    }
+
+    private static List<PacketInMask> decodePacketInMask(ByteBuf input) {
+        List<PacketInMask> inMasks = new ArrayList<>();
+        PacketInMaskBuilder maskBuilder;
+        for (int i = 0; i < SEPARATE_ROLES; i++) {
+            maskBuilder = new PacketInMaskBuilder();
+            maskBuilder.setMask(decodePacketInReasons(input.readUnsignedInt()));
+            inMasks.add(maskBuilder.build());
+        }
+        return inMasks;
+    }
+
+    private static List<PacketInReason> decodePacketInReasons(long input) {
+        List<PacketInReason> reasons = new ArrayList<>();
+        if ((input & (1 << 0)) != 0) {
+            reasons.add(PacketInReason.OFPRNOMATCH);
+        }
+        if ((input & (1 << 1)) != 0) {
+            reasons.add(PacketInReason.OFPRACTION);
+        }
+        if ((input & (1 << 2)) != 0) {
+            reasons.add(PacketInReason.OFPRINVALIDTTL);
+        }
+        return reasons;
+    }
+
+    private static List<PortStatusMask> decodePortStatusMask(ByteBuf input) {
+        List<PortStatusMask> inMasks = new ArrayList<>();
+        PortStatusMaskBuilder maskBuilder;
+        for (int i = 0; i < SEPARATE_ROLES; i++) {
+            maskBuilder = new PortStatusMaskBuilder();
+            maskBuilder.setMask(decodePortReasons(input.readUnsignedInt()));
+            inMasks.add(maskBuilder.build());
+        }
+        return inMasks;
+    }
+
+    private static List<PortReason> decodePortReasons(long input) {
+        List<PortReason> reasons = new ArrayList<>();
+        if ((input & (1 << 0)) != 0) {
+            reasons.add(PortReason.OFPPRADD);
+        }
+        if ((input & (1 << 1)) != 0) {
+            reasons.add(PortReason.OFPPRDELETE);
+        }
+        if ((input & (1 << 2)) != 0) {
+            reasons.add(PortReason.OFPPRMODIFY);
+        }
+        return reasons;
+    }
+
+    private static List<FlowRemovedMask> decodeFlowRemovedMask(ByteBuf input) {
+        List<FlowRemovedMask> inMasks = new ArrayList<>();
+        FlowRemovedMaskBuilder maskBuilder;
+        for (int i = 0; i < SEPARATE_ROLES; i++) {
+            maskBuilder = new FlowRemovedMaskBuilder();
+            maskBuilder.setMask(decodeFlowRemovedReasons(input.readUnsignedInt()));
+            inMasks.add(maskBuilder.build());
+        }
+        return inMasks;
+    }
+
+    private static List<FlowRemovedReason> decodeFlowRemovedReasons(long input) {
+        List<FlowRemovedReason> reasons = new ArrayList<>();
+        if ((input & (1 << 0)) != 0) {
+            reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
+        }
+        if ((input & (1 << 1)) != 0) {
+            reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
+        }
+        if ((input & (1 << 2)) != 0) {
+            reasons.add(FlowRemovedReason.OFPRRDELETE);
+        }
+        if ((input & (1 << 3)) != 0) {
+            reasons.add(FlowRemovedReason.OFPRRGROUPDELETE);
+        }
+        return reasons;
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java
new file mode 100644 (file)
index 0000000..a0a8e36
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class SetConfigInputMessageFactory implements OFDeserializer<SetConfigInput> {
+
+    @Override
+    public SetConfigInput deserialize(ByteBuf rawMessage) {
+        SetConfigInputBuilder builder = new SetConfigInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort()));
+        builder.setMissSendLen(rawMessage.readUnsignedShort());
+        return builder.build();
+    }
+
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactory.java
new file mode 100644 (file)
index 0000000..425bc57
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class TableModInputMessageFactory implements OFDeserializer<TableModInput> {
+
+    private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;
+
+    @Override
+    public TableModInput deserialize(ByteBuf rawMessage) {
+        TableModInputBuilder builder = new TableModInputBuilder();
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setTableId(new TableId((long) rawMessage.readUnsignedByte()));
+        rawMessage.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE);
+        builder.setConfig(createTableConfig(rawMessage.readUnsignedInt()));
+        return builder.build();
+    }
+
+    private static TableConfig createTableConfig(long input) {
+        boolean deprecated = (input & 3) != 0;
+        return new TableConfig(deprecated);
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/AdditionalMessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/AdditionalMessageFactoryInitializer.java
new file mode 100644 (file)
index 0000000..85bcbda
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoOutputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoRequestMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.ErrorMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.ExperimenterMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.FlowRemovedMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetAsyncReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetConfigReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetFeaturesOutputFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.HelloMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10BarrierReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FeaturesReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FlowRemovedMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PacketInMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PortStatusMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10QueueGetConfigReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PacketInMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PacketOutInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PortStatusMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.QueueGetConfigReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.RoleReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class AdditionalMessageFactoryInitializer {
+    private AdditionalMessageFactoryInitializer() {
+        throw new UnsupportedOperationException("Utility class shouldn't be instantiated");
+    }
+
+    /**
+     * Registers message serializers implemented within NetIde project into
+     * provided registry
+     *
+     * @param serializerRegistry
+     *            registry to be initialized with message serializers
+     */
+    public static void registerMessageSerializers(SerializerRegistry serializerRegistry) {
+        // register OF v1.0 message serializers
+        short version = EncodeConstants.OF10_VERSION_ID;
+        CommonMessageRegistryHelper registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry);
+        registryHelper.registerSerializer(ErrorMessage.class, new ErrorMessageFactory());
+        registryHelper.registerSerializer(EchoRequestMessage.class, new EchoRequestMessageFactory());
+        registryHelper.registerSerializer(EchoOutput.class, new EchoOutputMessageFactory());
+        registryHelper.registerSerializer(GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory());
+        registryHelper.registerSerializer(GetConfigOutput.class, new GetConfigReplyMessageFactory());
+        registryHelper.registerSerializer(PacketInMessage.class, new OF10PacketInMessageFactory());
+        registryHelper.registerSerializer(FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory());
+        registryHelper.registerSerializer(PortStatusMessage.class, new OF10PortStatusMessageFactory());
+        registryHelper.registerSerializer(MultipartReplyMessage.class, new OF10StatsReplyMessageFactory());
+        registryHelper.registerSerializer(BarrierOutput.class, new OF10BarrierReplyMessageFactory());
+        registryHelper.registerSerializer(GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory());
+
+        // register OF v1.3 message serializers
+        version = EncodeConstants.OF13_VERSION_ID;
+        registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry);
+        registryHelper.registerSerializer(EchoOutput.class, new EchoOutputMessageFactory());
+        registryHelper.registerSerializer(PacketInMessage.class, new PacketInMessageFactory());
+        registryHelper.registerSerializer(PacketOutInput.class, new PacketOutInputMessageFactory());
+        registryHelper.registerSerializer(GetFeaturesOutput.class, new GetFeaturesOutputFactory());
+        registryHelper.registerSerializer(EchoRequestMessage.class, new EchoRequestMessageFactory());
+        registryHelper.registerSerializer(MultipartReplyMessage.class, new MultipartReplyMessageFactory());
+        registryHelper.registerSerializer(HelloMessage.class, new HelloMessageFactory());
+        registryHelper.registerSerializer(ErrorMessage.class, new ErrorMessageFactory());
+        registryHelper.registerSerializer(ExperimenterMessage.class, new ExperimenterMessageFactory());
+        registryHelper.registerSerializer(GetConfigOutput.class, new GetConfigReplyMessageFactory());
+        registryHelper.registerSerializer(FlowRemovedMessage.class, new FlowRemovedMessageFactory());
+        registryHelper.registerSerializer(PortStatusMessage.class, new PortStatusMessageFactory());
+        registryHelper.registerSerializer(BarrierOutput.class, new BarrierReplyMessageFactory());
+        registryHelper.registerSerializer(GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory());
+        registryHelper.registerSerializer(RoleRequestOutput.class, new RoleReplyMessageFactory());
+        registryHelper.registerSerializer(GetAsyncOutput.class, new GetAsyncReplyMessageFactory());
+    }
+}
index 953034091988c8b11f790e4310c9dda8490a3ede..a150de89bb118a64c655f33ab7f4b5a71de597cc 100644 (file)
@@ -69,7 +69,9 @@ public final class MessageFactoryInitializer {
 
     /**
      * Registers message serializers into provided registry
-     * @param serializerRegistry registry to be initialized with message serializers
+     *
+     * @param serializerRegistry
+     *            registry to be initialized with message serializers
      */
     public static void registerMessageSerializers(SerializerRegistry serializerRegistry) {
         // register OF v1.0 message serializers
@@ -88,6 +90,7 @@ public final class MessageFactoryInitializer {
         registryHelper.registerSerializer(PacketOutInput.class, new OF10PacketOutInputMessageFactory());
         registryHelper.registerSerializer(PortModInput.class, new OF10PortModInputMessageFactory());
         registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory());
+
         // register OF v1.3 message serializers
         version = EncodeConstants.OF13_VERSION_ID;
         registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry);
@@ -108,7 +111,7 @@ public final class MessageFactoryInitializer {
         registryHelper.registerSerializer(PortModInput.class, new PortModInputMessageFactory());
         registryHelper.registerSerializer(RoleRequestInput.class, new RoleRequestInputMessageFactory());
         registryHelper.registerSerializer(SetAsyncInput.class, new SetAsyncInputMessageFactory());
-        registryHelper.registerSerializer( SetConfigInput.class, new SetConfigMessageFactory());
+        registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory());
         registryHelper.registerSerializer(TableModInput.class, new TableModInputMessageFactory());
     }
 }
index 5756352c7c579b2cb4bc8ed2519c568464afbcfb..96307fa2c2aaceb8e9389cea4845bd703bd59176 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization;
 
 import java.util.HashMap;
 import java.util.Map;
-
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
@@ -27,8 +26,11 @@ import org.slf4j.LoggerFactory;
  * Stores and handles serializers<br>
  * K - {@link MessageTypeKey} type<br>
  * S - returned serializer type
+ *
  * @author michal.polkorab
  * @author timotej.kubas
+ * @author giuseppex.petralia@intel.com
+ *
  */
 public class SerializerRegistryImpl implements SerializerRegistry {
 
@@ -37,13 +39,15 @@ public class SerializerRegistryImpl implements SerializerRegistry {
     private static final short OF13 = EncodeConstants.OF13_VERSION_ID;
     private Map<MessageTypeKey<?>, OFGeneralSerializer> registry;
 
-
     @Override
     public void init() {
         registry = new HashMap<>();
         // Openflow message type serializers
         MessageFactoryInitializer.registerMessageSerializers(this);
 
+        // Register Additional serializers
+        AdditionalMessageFactoryInitializer.registerMessageSerializers(this);
+
         // match structure serializers
         registerSerializer(new MessageTypeKey<>(OF10, MatchV10.class), new OF10MatchSerializer());
         registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());
@@ -62,8 +66,7 @@ public class SerializerRegistryImpl implements SerializerRegistry {
      */
     @Override
     @SuppressWarnings("unchecked")
-    public <K, S extends OFGeneralSerializer> S getSerializer(
-            MessageTypeKey<K> msgTypeKey) {
+    public <K, S extends OFGeneralSerializer> S getSerializer(MessageTypeKey<K> msgTypeKey) {
         OFGeneralSerializer serializer = registry.get(msgTypeKey);
         if (serializer == null) {
             throw new IllegalStateException("Serializer for key: " + msgTypeKey
@@ -74,15 +77,14 @@ public class SerializerRegistryImpl implements SerializerRegistry {
     }
 
     @Override
-    public <K> void registerSerializer(
-            MessageTypeKey<K> msgTypeKey, OFGeneralSerializer serializer) {
+    public <K> void registerSerializer(MessageTypeKey<K> msgTypeKey, OFGeneralSerializer serializer) {
         if ((msgTypeKey == null) || (serializer == null)) {
             throw new IllegalArgumentException("MessageTypeKey or Serializer is null");
         }
         OFGeneralSerializer serInRegistry = registry.put(msgTypeKey, serializer);
         if (serInRegistry != null) {
-            LOGGER.debug("Serializer for key {} overwritten. Old serializer: {}, new serializer: {}",
-                    msgTypeKey, serInRegistry.getClass().getName(), serializer.getClass().getName());
+            LOGGER.debug("Serializer for key {} overwritten. Old serializer: {}, new serializer: {}", msgTypeKey,
+                    serInRegistry.getClass().getName(), serializer.getClass().getName());
         }
         if (serializer instanceof SerializerRegistryInjector) {
             ((SerializerRegistryInjector) serializer).injectSerializerRegistry(this);
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..3212f78
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class BarrierReplyMessageFactory implements OFSerializer<BarrierOutput> {
+
+    private static final byte MESSAGE_TYPE = 21;
+
+    @Override
+    public void serialize(BarrierOutput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactory.java
new file mode 100644 (file)
index 0000000..3a244db
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class EchoOutputMessageFactory implements OFSerializer<EchoOutput> {
+
+    private static final byte MESSAGE_TYPE = 3;
+
+    @Override
+    public void serialize(EchoOutput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        byte[] data = message.getData();
+
+        if (data != null) {
+            outBuffer.writeBytes(data);
+        }
+
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactory.java
new file mode 100644 (file)
index 0000000..9f5076c
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class EchoRequestMessageFactory implements OFSerializer<EchoRequestMessage> {
+    private static final byte MESSAGE_TYPE = 2;
+
+    @Override
+    public void serialize(EchoRequestMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        byte[] data = message.getData();
+
+        if (data != null) {
+            outBuffer.writeBytes(data);
+        }
+
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactory.java
new file mode 100644 (file)
index 0000000..2eeaf76
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class ErrorMessageFactory implements OFSerializer<ErrorMessage> {
+
+    private static final byte MESSAGE_TYPE = 1;
+
+    @Override
+    public void serialize(ErrorMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeShort(message.getType());
+        outBuffer.writeShort(message.getCode());
+        byte[] data = message.getData();
+
+        if (data != null) {
+            outBuffer.writeBytes(data);
+        }
+
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterMessageFactory.java
new file mode 100644 (file)
index 0000000..dc6e66c
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class ExperimenterMessageFactory implements OFSerializer<ExperimenterMessage> {
+
+    private static final byte MESSAGE_TYPE = 4;
+
+    @Override
+    public void serialize(ExperimenterMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeInt(message.getExperimenter().getValue().intValue());
+        outBuffer.writeInt(message.getExpType().intValue());
+        // TODO: Serializer for data field is vendor specific.
+        byte[] data = null;
+
+        if (data != null) {
+            outBuffer.writeBytes(data);
+        }
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java
new file mode 100644 (file)
index 0000000..7e7c484
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class FlowRemovedMessageFactory implements OFSerializer<FlowRemovedMessage>, SerializerRegistryInjector {
+
+    private static final byte MESSAGE_TYPE = 11;
+    private SerializerRegistry registry;
+
+    @Override
+    public void injectSerializerRegistry(SerializerRegistry serializerRegistry) {
+        this.registry = serializerRegistry;
+    }
+
+    @Override
+    public void serialize(FlowRemovedMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeLong(message.getCookie().longValue());
+        outBuffer.writeShort(message.getPriority());
+        outBuffer.writeByte(message.getReason().getIntValue());
+        outBuffer.writeByte(message.getTableId().getValue().byteValue());
+        outBuffer.writeInt(message.getDurationSec().intValue());
+        outBuffer.writeInt(message.getDurationNsec().intValue());
+        outBuffer.writeShort(message.getIdleTimeout());
+        outBuffer.writeShort(message.getHardTimeout());
+        outBuffer.writeLong(message.getPacketCount().longValue());
+        outBuffer.writeLong(message.getByteCount().longValue());
+        OFSerializer<Match> matchSerializer = registry
+                .<Match, OFSerializer<Match>> getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class));
+        matchSerializer.serialize(message.getMatch(), outBuffer);
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..4ba876c
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+
+public class GetAsyncReplyMessageFactory implements OFSerializer<GetAsyncOutput> {
+    private static final byte MESSAGE_TYPE = 27;
+
+    @Override
+    public void serialize(GetAsyncOutput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        serializePacketInMask(message.getPacketInMask(), outBuffer);
+        serializePortStatusMask(message.getPortStatusMask(), outBuffer);
+        serializeFlowRemovedMask(message.getFlowRemovedMask(), outBuffer);
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+    private static void serializePacketInMask(List<PacketInMask> packetInMask, ByteBuf outBuffer) {
+        if (packetInMask != null) {
+            for (PacketInMask currentPacketMask : packetInMask) {
+                List<PacketInReason> mask = currentPacketMask.getMask();
+                if (mask != null) {
+                    Map<Integer, Boolean> packetInReasonMap = new HashMap<>();
+                    for (PacketInReason packetInReason : mask) {
+                        if (PacketInReason.OFPRNOMATCH.equals(packetInReason)) {
+                            packetInReasonMap.put(PacketInReason.OFPRNOMATCH.getIntValue(), true);
+                        } else if (PacketInReason.OFPRACTION.equals(packetInReason)) {
+                            packetInReasonMap.put(PacketInReason.OFPRACTION.getIntValue(), true);
+                        } else if (PacketInReason.OFPRINVALIDTTL.equals(packetInReason)) {
+                            packetInReasonMap.put(PacketInReason.OFPRINVALIDTTL.getIntValue(), true);
+                        }
+                    }
+                    outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(packetInReasonMap));
+                }
+            }
+        }
+    }
+
+    private static void serializePortStatusMask(List<PortStatusMask> portStatusMask, ByteBuf outBuffer) {
+        if (portStatusMask != null) {
+            for (PortStatusMask currentPortStatusMask : portStatusMask) {
+                List<PortReason> mask = currentPortStatusMask.getMask();
+                if (mask != null) {
+                    Map<Integer, Boolean> portStatusReasonMap = new HashMap<>();
+                    for (PortReason packetInReason : mask) {
+                        if (PortReason.OFPPRADD.equals(packetInReason)) {
+                            portStatusReasonMap.put(PortReason.OFPPRADD.getIntValue(), true);
+                        } else if (PortReason.OFPPRDELETE.equals(packetInReason)) {
+                            portStatusReasonMap.put(PortReason.OFPPRDELETE.getIntValue(), true);
+                        } else if (PortReason.OFPPRMODIFY.equals(packetInReason)) {
+                            portStatusReasonMap.put(PortReason.OFPPRMODIFY.getIntValue(), true);
+                        }
+                    }
+                    outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(portStatusReasonMap));
+                }
+            }
+        }
+    }
+
+    private static void serializeFlowRemovedMask(List<FlowRemovedMask> flowRemovedMask, ByteBuf outBuffer) {
+        if (flowRemovedMask != null) {
+            for (FlowRemovedMask currentFlowRemovedMask : flowRemovedMask) {
+                List<FlowRemovedReason> mask = currentFlowRemovedMask.getMask();
+                if (mask != null) {
+                    Map<Integer, Boolean> flowRemovedReasonMap = new HashMap<>();
+                    for (FlowRemovedReason packetInReason : mask) {
+                        if (FlowRemovedReason.OFPRRIDLETIMEOUT.equals(packetInReason)) {
+                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRIDLETIMEOUT.getIntValue(), true);
+                        } else if (FlowRemovedReason.OFPRRHARDTIMEOUT.equals(packetInReason)) {
+                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRHARDTIMEOUT.getIntValue(), true);
+                        } else if (FlowRemovedReason.OFPRRDELETE.equals(packetInReason)) {
+                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRDELETE.getIntValue(), true);
+                        } else if (FlowRemovedReason.OFPRRGROUPDELETE.equals(packetInReason)) {
+                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRGROUPDELETE.getIntValue(), true);
+                        }
+                    }
+                    outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(flowRemovedReasonMap));
+                }
+            }
+        }
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..d711b86
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GetConfigReplyMessageFactory implements OFSerializer<GetConfigOutput> {
+
+    private static final byte MESSAGE_TYPE = 8;
+
+    @Override
+    public void serialize(GetConfigOutput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeShort(message.getFlags().getIntValue());
+        outBuffer.writeShort(message.getMissSendLen());
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactory.java
new file mode 100644 (file)
index 0000000..2a2fdc2
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.HashMap;
+import java.util.Map;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GetFeaturesOutputFactory implements OFSerializer<GetFeaturesOutput>, SerializerRegistryInjector {
+
+    @SuppressWarnings("unused")
+    private SerializerRegistry registry;
+    private static final byte MESSAGE_TYPE = 6;
+    private static final byte PADDING = 2;
+
+    @Override
+    public void serialize(GetFeaturesOutput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeLong(message.getDatapathId().longValue());
+        outBuffer.writeInt(message.getBuffers().intValue());
+        outBuffer.writeByte(message.getTables().intValue());
+        outBuffer.writeByte(message.getAuxiliaryId().intValue());
+        outBuffer.writeZero(PADDING);
+        writeCapabilities(message.getCapabilities(), outBuffer);
+        outBuffer.writeInt(message.getReserved().intValue());
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+    @Override
+    public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) {
+        this.registry = serializerRegistry;
+    }
+
+    private static void writeCapabilities(Capabilities capabilities, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, capabilities.isOFPCFLOWSTATS());
+        map.put(1, capabilities.isOFPCTABLESTATS());
+        map.put(2, capabilities.isOFPCPORTSTATS());
+        map.put(3, capabilities.isOFPCGROUPSTATS());
+        map.put(5, capabilities.isOFPCIPREASM());
+        map.put(6, capabilities.isOFPCQUEUESTATS());
+        map.put(8, capabilities.isOFPCPORTBLOCKED());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactory.java
new file mode 100644 (file)
index 0000000..b3ccbbe
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class HelloMessageFactory implements OFSerializer<HelloMessage> {
+    private static final byte MESSAGE_TYPE = 0;
+
+    @Override
+    public void serialize(HelloMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..e0393c7
--- /dev/null
@@ -0,0 +1,799 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker;
+import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterBandCommons;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartReplyMessageFactory implements OFSerializer<MultipartReplyMessage>, SerializerRegistryInjector {
+
+    private static final byte MESSAGE_TYPE = 19;
+    private SerializerRegistry registry;
+    private static final byte PADDING = 4;
+    private static final byte PORT_DESC_PADDING_1 = 4;
+    private static final byte PORT_DESC_PADDING_2 = 2;
+    private static final int FLOW_STATS_LENGTH_INDEX = 0;
+    private static final byte FLOW_STATS_PADDING_1 = 1;
+    private static final byte FLOW_STATS_PADDING_2 = 6;
+    private static final byte AGGREGATE_PADDING = 4;
+    private static final byte TABLE_PADDING = 3;
+    private static final byte PORT_STATS_PADDING = 4;
+    private static final byte GROUP_STATS_PADDING_1 = 2;
+    private static final byte GROUP_STATS_PADDING_2 = 4;
+    private static final int GROUP_STATS_LENGTH_INDEX = 0;
+    private static final int GROUP_DESC_LENGTH_INDEX = 0;
+    private static final int BUCKET_LENGTH_INDEX = 0;
+    private static final byte GROUP_DESC_PADDING = 1;
+    private static final byte BUCKET_PADDING = 4;
+    private static final int METER_LENGTH_INDEX = 4;
+    private static final byte METER_PADDING = 6;
+    private static final int METER_CONFIG_LENGTH_INDEX = 0;
+    private static final short LENGTH_OF_METER_BANDS = 16;
+    private static final byte METER_FEATURES_PADDING = 2;
+    private static final int TABLE_FEATURES_LENGTH_INDEX = 0;
+    private static final byte TABLE_FEATURES_PADDING = 5;
+    private static final byte INSTRUCTIONS_CODE = 0;
+    private static final byte INSTRUCTIONS_MISS_CODE = 1;
+    private static final byte NEXT_TABLE_CODE = 2;
+    private static final byte NEXT_TABLE_MISS_CODE = 3;
+    private static final byte WRITE_ACTIONS_CODE = 4;
+    private static final byte WRITE_ACTIONS_MISS_CODE = 5;
+    private static final byte APPLY_ACTIONS_CODE = 6;
+    private static final byte APPLY_ACTIONS_MISS_CODE = 7;
+    private static final byte MATCH_CODE = 8;
+    private static final byte WILDCARDS_CODE = 10;
+    private static final byte WRITE_SETFIELD_CODE = 12;
+    private static final byte WRITE_SETFIELD_MISS_CODE = 13;
+    private static final byte APPLY_SETFIELD_CODE = 14;
+    private static final byte APPLY_SETFIELD_MISS_CODE = 15;
+
+    @Override
+    public void injectSerializerRegistry(SerializerRegistry serializerRegistry) {
+        this.registry = serializerRegistry;
+    }
+
+    @Override
+    public void serialize(MultipartReplyMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeShort(message.getType().getIntValue());
+        writeFlags(message.getFlags(), outBuffer);
+        outBuffer.writeZero(PADDING);
+        switch (message.getType()) {
+        case OFPMPDESC:
+            serializeDescBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPFLOW:
+            serializeFlowBody(message.getMultipartReplyBody(), outBuffer, message);
+            break;
+        case OFPMPAGGREGATE:
+            serializeAggregateBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPTABLE:
+            serializeTableBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPPORTSTATS:
+            serializePortStatsBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPQUEUE:
+            serializeQueueBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPGROUP:
+            serializeGroupBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPGROUPDESC:
+            serializeGroupDescBody(message.getMultipartReplyBody(), outBuffer, message);
+            break;
+        case OFPMPGROUPFEATURES:
+            serializeGroupFeaturesBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPMETER:
+            serializeMeterBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPMETERCONFIG:
+            serializeMeterConfigBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPMETERFEATURES:
+            serializeMeterFeaturesBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPTABLEFEATURES:
+            serializeTableFeaturesBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPPORTDESC:
+            serializePortDescBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPEXPERIMENTER:
+            serializeExperimenterBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        }
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+    private void serializeExperimenterBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyExperimenterCase experimenterCase = (MultipartReplyExperimenterCase) body;
+        MultipartReplyExperimenter experimenterBody = experimenterCase.getMultipartReplyExperimenter();
+        // TODO: experimenterBody does not have get methods
+    }
+
+    private void writeFlags(MultipartRequestFlags flags, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, flags.isOFPMPFREQMORE());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeShort(bitmap);
+    }
+
+    private void serializeTableFeaturesBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyTableFeaturesCase tableFeaturesCase = (MultipartReplyTableFeaturesCase) body;
+        MultipartReplyTableFeatures tableFeatures = tableFeaturesCase.getMultipartReplyTableFeatures();
+        for (TableFeatures tableFeature : tableFeatures.getTableFeatures()) {
+            ByteBuf tableFeatureBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+            tableFeatureBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+            tableFeatureBuff.writeByte(tableFeature.getTableId());
+            tableFeatureBuff.writeZero(TABLE_FEATURES_PADDING);
+            write32String(tableFeature.getName(), tableFeatureBuff);
+            tableFeatureBuff.writeBytes(tableFeature.getMetadataMatch());
+            tableFeatureBuff.writeZero(64 - tableFeature.getMetadataMatch().length);
+            tableFeatureBuff.writeBytes(tableFeature.getMetadataWrite());
+            tableFeatureBuff.writeZero(64 - tableFeature.getMetadataWrite().length);
+            writeTableConfig(tableFeature.getConfig(), tableFeatureBuff);
+            tableFeatureBuff.writeInt(tableFeature.getMaxEntries().intValue());
+            for (TableFeatureProperties tableFeatureProp : tableFeature.getTableFeatureProperties()) {
+                switch (tableFeatureProp.getType()) {
+                case OFPTFPTINSTRUCTIONS:
+                    writeInstructionRelatedTableProperty(tableFeatureBuff, tableFeatureProp, INSTRUCTIONS_CODE);
+                    break;
+                case OFPTFPTINSTRUCTIONSMISS:
+                    writeInstructionRelatedTableProperty(tableFeatureBuff, tableFeatureProp, INSTRUCTIONS_MISS_CODE);
+                    break;
+                case OFPTFPTNEXTTABLES:
+                    writeNextTableRelatedTableProperty(tableFeatureBuff, tableFeatureProp, NEXT_TABLE_CODE);
+                    break;
+                case OFPTFPTNEXTTABLESMISS:
+                    writeNextTableRelatedTableProperty(tableFeatureBuff, tableFeatureProp, NEXT_TABLE_MISS_CODE);
+                    break;
+                case OFPTFPTWRITEACTIONS:
+                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_ACTIONS_CODE);
+                    break;
+                case OFPTFPTWRITEACTIONSMISS:
+                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_ACTIONS_MISS_CODE);
+                    break;
+                case OFPTFPTAPPLYACTIONS:
+                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_ACTIONS_CODE);
+                    break;
+                case OFPTFPTAPPLYACTIONSMISS:
+                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_ACTIONS_MISS_CODE);
+                    break;
+                case OFPTFPTMATCH:
+                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, MATCH_CODE);
+                    break;
+                case OFPTFPTWILDCARDS:
+                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WILDCARDS_CODE);
+                    break;
+                case OFPTFPTWRITESETFIELD:
+                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_SETFIELD_CODE);
+                    break;
+                case OFPTFPTWRITESETFIELDMISS:
+                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_SETFIELD_MISS_CODE);
+                    break;
+                case OFPTFPTAPPLYSETFIELD:
+                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_SETFIELD_CODE);
+                    break;
+                case OFPTFPTAPPLYSETFIELDMISS:
+                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_SETFIELD_MISS_CODE);
+                    break;
+                case OFPTFPTEXPERIMENTER:
+                    writeExperimenterRelatedTableProperty(tableFeatureBuff, tableFeatureProp);
+                    break;
+                case OFPTFPTEXPERIMENTERMISS:
+                    writeExperimenterRelatedTableProperty(tableFeatureBuff, tableFeatureProp);
+                    break;
+                }
+            }
+            tableFeatureBuff.setShort(TABLE_FEATURES_LENGTH_INDEX, tableFeatureBuff.readableBytes());
+            outBuffer.writeBytes(tableFeatureBuff);
+        }
+    }
+
+    private void writeExperimenterRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property) {
+        long expId = property.getAugmentation(ExperimenterIdTableFeatureProperty.class).getExperimenter().getValue();
+        OFSerializer<TableFeatureProperties> serializer = registry.getSerializer(ExperimenterSerializerKeyFactory
+                .createMultipartRequestTFSerializerKey(EncodeConstants.OF13_VERSION_ID, expId));
+        serializer.serialize(property, output);
+    }
+
+    private void writeOxmRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property,
+            final byte code) {
+        int startIndex = output.writerIndex();
+        output.writeShort(code);
+        int lengthIndex = output.writerIndex();
+        output.writeShort(EncodeConstants.EMPTY_LENGTH);
+        List<MatchEntry> entries = property.getAugmentation(OxmRelatedTableFeatureProperty.class).getMatchEntry();
+        if (entries != null) {
+            TypeKeyMaker<MatchEntry> keyMaker = TypeKeyMakerFactory
+                    .createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
+            ListSerializer.serializeHeaderList(entries, keyMaker, registry, output);
+        }
+        int length = output.writerIndex() - startIndex;
+        output.setShort(lengthIndex, length);
+        output.writeZero(paddingNeeded(length));
+    }
+
+    private void writeActionsRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property,
+            final byte code) {
+        int startIndex = output.writerIndex();
+        output.writeShort(code);
+        int lengthIndex = output.writerIndex();
+        output.writeShort(EncodeConstants.EMPTY_LENGTH);
+        List<Action> actions = property.getAugmentation(ActionRelatedTableFeatureProperty.class).getAction();
+        if (actions != null) {
+            TypeKeyMaker<Action> keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID);
+            ListSerializer.serializeHeaderList(actions, keyMaker, registry, output);
+        }
+        int length = output.writerIndex() - startIndex;
+        output.setShort(lengthIndex, length);
+        output.writeZero(paddingNeeded(length));
+    }
+
+    private static void writeNextTableRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property,
+            final byte code) {
+        int startIndex = output.writerIndex();
+        output.writeShort(code);
+        int lengthIndex = output.writerIndex();
+        output.writeShort(EncodeConstants.EMPTY_LENGTH);
+        List<NextTableIds> nextTableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class)
+                .getNextTableIds();
+        if (nextTableIds != null) {
+            for (NextTableIds next : nextTableIds) {
+                output.writeByte(next.getTableId());
+            }
+        }
+        int length = output.writerIndex() - startIndex;
+        output.setShort(lengthIndex, length);
+        output.writeZero(paddingNeeded(length));
+    }
+
+    private void writeInstructionRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property,
+            final byte code) {
+        int startIndex = output.writerIndex();
+        output.writeShort(code);
+        int lengthIndex = output.writerIndex();
+        output.writeShort(EncodeConstants.EMPTY_LENGTH);
+        List<Instruction> instructions = property.getAugmentation(InstructionRelatedTableFeatureProperty.class)
+                .getInstruction();
+        if (instructions != null) {
+            TypeKeyMaker<Instruction> keyMaker = TypeKeyMakerFactory
+                    .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID);
+            ListSerializer.serializeHeaderList(instructions, keyMaker, registry, output);
+        }
+        int length = output.writerIndex() - startIndex;
+        output.setShort(lengthIndex, length);
+        output.writeZero(paddingNeeded(length));
+    }
+
+    private static int paddingNeeded(final int length) {
+        int paddingRemainder = length % EncodeConstants.PADDING;
+        int result = 0;
+        if (paddingRemainder != 0) {
+            result = EncodeConstants.PADDING - paddingRemainder;
+        }
+        return result;
+    }
+
+    private void writeTableConfig(TableConfig tableConfig, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, tableConfig.isOFPTCDEPRECATEDMASK());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void serializeMeterFeaturesBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyMeterFeaturesCase meterFeaturesCase = (MultipartReplyMeterFeaturesCase) body;
+        MultipartReplyMeterFeatures meterFeatures = meterFeaturesCase.getMultipartReplyMeterFeatures();
+        outBuffer.writeInt(meterFeatures.getMaxMeter().intValue());
+        writeBandTypes(meterFeatures.getBandTypes(), outBuffer);
+        writeMeterFlags(meterFeatures.getCapabilities(), outBuffer);
+        outBuffer.writeByte(meterFeatures.getMaxBands());
+        outBuffer.writeByte(meterFeatures.getMaxColor());
+        outBuffer.writeZero(METER_FEATURES_PADDING);
+    }
+
+    private void writeBandTypes(MeterBandTypeBitmap bandTypes, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, bandTypes.isOFPMBTDROP());
+        map.put(1, bandTypes.isOFPMBTDSCPREMARK());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void serializeMeterConfigBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyMeterConfigCase meterConfigCase = (MultipartReplyMeterConfigCase) body;
+        MultipartReplyMeterConfig meter = meterConfigCase.getMultipartReplyMeterConfig();
+        for (MeterConfig meterConfig : meter.getMeterConfig()) {
+            ByteBuf meterConfigBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+            meterConfigBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+            writeMeterFlags(meterConfig.getFlags(), meterConfigBuff);
+            meterConfigBuff.writeInt(meterConfig.getMeterId().getValue().intValue());
+            for (Bands currentBand : meterConfig.getBands()) {
+                MeterBand meterBand = currentBand.getMeterBand();
+                if (meterBand instanceof MeterBandDropCase) {
+                    MeterBandDropCase dropBandCase = (MeterBandDropCase) meterBand;
+                    MeterBandDrop dropBand = dropBandCase.getMeterBandDrop();
+                    writeBandCommonFields(dropBand, meterConfigBuff);
+                } else if (meterBand instanceof MeterBandDscpRemarkCase) {
+                    MeterBandDscpRemarkCase dscpRemarkBandCase = (MeterBandDscpRemarkCase) meterBand;
+                    MeterBandDscpRemark dscpRemarkBand = dscpRemarkBandCase.getMeterBandDscpRemark();
+                    writeBandCommonFields(dscpRemarkBand, meterConfigBuff);
+                } else if (meterBand instanceof MeterBandExperimenterCase) {
+                    MeterBandExperimenterCase experimenterBandCase = (MeterBandExperimenterCase) meterBand;
+                    MeterBandExperimenter experimenterBand = experimenterBandCase.getMeterBandExperimenter();
+                    writeBandCommonFields(experimenterBand, meterConfigBuff);
+                }
+            }
+            meterConfigBuff.setShort(METER_CONFIG_LENGTH_INDEX, meterConfigBuff.readableBytes());
+            outBuffer.writeBytes(meterConfigBuff);
+        }
+    }
+
+    private static void writeBandCommonFields(final MeterBandCommons meterBand, final ByteBuf outBuffer) {
+        outBuffer.writeShort(meterBand.getType().getIntValue());
+        outBuffer.writeShort(LENGTH_OF_METER_BANDS);
+        outBuffer.writeInt(meterBand.getRate().intValue());
+        outBuffer.writeInt(meterBand.getBurstSize().intValue());
+    }
+
+    private void writeMeterFlags(MeterFlags flags, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, flags.isOFPMFKBPS());
+        map.put(1, flags.isOFPMFPKTPS());
+        map.put(2, flags.isOFPMFBURST());
+        map.put(3, flags.isOFPMFSTATS());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeShort(bitmap);
+    }
+
+    private void serializeMeterBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyMeterCase meterCase = (MultipartReplyMeterCase) body;
+        MultipartReplyMeter meter = meterCase.getMultipartReplyMeter();
+        for (MeterStats meterStats : meter.getMeterStats()) {
+            ByteBuf meterStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+            meterStatsBuff.writeInt(meterStats.getMeterId().getValue().intValue());
+            meterStatsBuff.writeInt(EncodeConstants.EMPTY_LENGTH);
+            meterStatsBuff.writeZero(METER_PADDING);
+            meterStatsBuff.writeInt(meterStats.getFlowCount().intValue());
+            meterStatsBuff.writeLong(meterStats.getPacketInCount().longValue());
+            meterStatsBuff.writeLong(meterStats.getByteInCount().longValue());
+            meterStatsBuff.writeInt(meterStats.getDurationSec().intValue());
+            meterStatsBuff.writeInt(meterStats.getDurationNsec().intValue());
+            for (MeterBandStats meterBandStats : meterStats.getMeterBandStats()) {
+                meterStatsBuff.writeLong(meterBandStats.getPacketBandCount().longValue());
+                meterStatsBuff.writeLong(meterBandStats.getByteBandCount().longValue());
+            }
+            meterStatsBuff.setInt(METER_LENGTH_INDEX, meterStatsBuff.readableBytes());
+            outBuffer.writeBytes(meterStatsBuff);
+        }
+    }
+
+    private void serializeGroupFeaturesBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyGroupFeaturesCase groupFeaturesCase = (MultipartReplyGroupFeaturesCase) body;
+        MultipartReplyGroupFeatures groupFeatures = groupFeaturesCase.getMultipartReplyGroupFeatures();
+        writeGroupTypes(groupFeatures.getTypes(), outBuffer);
+        writeGroupCapabilities(groupFeatures.getCapabilities(), outBuffer);
+        for (Long maxGroups : groupFeatures.getMaxGroups()) {
+            outBuffer.writeInt(maxGroups.intValue());
+        }
+        for (ActionType action : groupFeatures.getActionsBitmap()) {
+            writeActionType(action, outBuffer);
+        }
+    }
+
+    private void writeActionType(ActionType action, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, action.isOFPATOUTPUT());
+        map.put(1, action.isOFPATCOPYTTLOUT());
+        map.put(2, action.isOFPATCOPYTTLIN());
+        map.put(3, action.isOFPATSETMPLSTTL());
+        map.put(4, action.isOFPATDECMPLSTTL());
+        map.put(5, action.isOFPATPUSHVLAN());
+        map.put(6, action.isOFPATPOPVLAN());
+        map.put(7, action.isOFPATPUSHMPLS());
+        map.put(8, action.isOFPATPOPMPLS());
+        map.put(9, action.isOFPATSETQUEUE());
+        map.put(10, action.isOFPATGROUP());
+        map.put(11, action.isOFPATSETNWTTL());
+        map.put(12, action.isOFPATDECNWTTL());
+        map.put(13, action.isOFPATSETFIELD());
+        map.put(14, action.isOFPATPUSHPBB());
+        map.put(15, action.isOFPATPOPPBB());
+        map.put(16, action.isOFPATEXPERIMENTER());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void writeGroupCapabilities(GroupCapabilities capabilities, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, capabilities.isOFPGFCSELECTWEIGHT());
+        map.put(1, capabilities.isOFPGFCSELECTLIVENESS());
+        map.put(2, capabilities.isOFPGFCCHAINING());
+        map.put(3, capabilities.isOFPGFCCHAININGCHECKS());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void writeGroupTypes(GroupTypes types, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, types.isOFPGTALL());
+        map.put(1, types.isOFPGTSELECT());
+        map.put(2, types.isOFPGTINDIRECT());
+        map.put(3, types.isOFPGTFF());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void serializeGroupDescBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) {
+        MultipartReplyGroupDescCase groupDescCase = (MultipartReplyGroupDescCase) body;
+        MultipartReplyGroupDesc group = groupDescCase.getMultipartReplyGroupDesc();
+        for (GroupDesc groupDesc : group.getGroupDesc()) {
+            ByteBuf groupDescBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+            groupDescBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+            groupDescBuff.writeByte(groupDesc.getType().getIntValue());
+            groupDescBuff.writeZero(GROUP_DESC_PADDING);
+            groupDescBuff.writeInt(groupDesc.getGroupId().getValue().intValue());
+            for (BucketsList bucket : groupDesc.getBucketsList()) {
+                ByteBuf bucketBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+                bucketBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+                bucketBuff.writeShort(bucket.getWeight());
+                bucketBuff.writeInt(bucket.getWatchPort().getValue().intValue());
+                bucketBuff.writeInt(bucket.getWatchGroup().intValue());
+                bucketBuff.writeZero(BUCKET_PADDING);
+                ListSerializer.serializeList(bucket.getAction(),
+                        TypeKeyMakerFactory.createActionKeyMaker(message.getVersion()), registry, bucketBuff);
+                bucketBuff.setShort(BUCKET_LENGTH_INDEX, bucketBuff.readableBytes());
+                groupDescBuff.writeBytes(bucketBuff);
+            }
+            groupDescBuff.setShort(GROUP_DESC_LENGTH_INDEX, groupDescBuff.readableBytes());
+            outBuffer.writeBytes(groupDescBuff);
+        }
+    }
+
+    private void serializeGroupBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyGroupCase groupCase = (MultipartReplyGroupCase) body;
+        MultipartReplyGroup group = groupCase.getMultipartReplyGroup();
+        for (GroupStats groupStats : group.getGroupStats()) {
+            ByteBuf groupStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+            groupStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+            groupStatsBuff.writeZero(GROUP_STATS_PADDING_1);
+            groupStatsBuff.writeInt(groupStats.getGroupId().getValue().intValue());
+            groupStatsBuff.writeInt(groupStats.getRefCount().intValue());
+            groupStatsBuff.writeZero(GROUP_STATS_PADDING_2);
+            groupStatsBuff.writeLong(groupStats.getPacketCount().longValue());
+            groupStatsBuff.writeLong(groupStats.getByteCount().longValue());
+            groupStatsBuff.writeInt(groupStats.getDurationSec().intValue());
+            groupStatsBuff.writeInt(groupStats.getDurationNsec().intValue());
+            for (BucketStats bucketStats : groupStats.getBucketStats()) {
+                groupStatsBuff.writeLong(bucketStats.getPacketCount().longValue());
+                groupStatsBuff.writeLong(bucketStats.getByteCount().longValue());
+            }
+            groupStatsBuff.setShort(GROUP_STATS_LENGTH_INDEX, groupStatsBuff.readableBytes());
+            outBuffer.writeBytes(groupStatsBuff);
+        }
+    }
+
+    private void serializeQueueBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyQueueCase queueCase = (MultipartReplyQueueCase) body;
+        MultipartReplyQueue queue = queueCase.getMultipartReplyQueue();
+        for (QueueStats queueStats : queue.getQueueStats()) {
+            outBuffer.writeInt(queueStats.getPortNo().intValue());
+            outBuffer.writeInt(queueStats.getQueueId().intValue());
+            outBuffer.writeLong(queueStats.getTxBytes().longValue());
+            outBuffer.writeLong(queueStats.getTxPackets().longValue());
+            outBuffer.writeLong(queueStats.getTxErrors().longValue());
+            outBuffer.writeInt(queueStats.getDurationSec().intValue());
+            outBuffer.writeInt(queueStats.getDurationNsec().intValue());
+        }
+    }
+
+    private void serializePortStatsBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyPortStatsCase portStatsCase = (MultipartReplyPortStatsCase) body;
+        MultipartReplyPortStats portStats = portStatsCase.getMultipartReplyPortStats();
+        for (PortStats portStat : portStats.getPortStats()) {
+            outBuffer.writeInt(portStat.getPortNo().intValue());
+            outBuffer.writeZero(PORT_STATS_PADDING);
+            outBuffer.writeLong(portStat.getRxPackets().longValue());
+            outBuffer.writeLong(portStat.getTxPackets().longValue());
+            outBuffer.writeLong(portStat.getRxBytes().longValue());
+            outBuffer.writeLong(portStat.getTxBytes().longValue());
+            outBuffer.writeLong(portStat.getRxDropped().longValue());
+            outBuffer.writeLong(portStat.getTxDropped().longValue());
+            outBuffer.writeLong(portStat.getRxErrors().longValue());
+            outBuffer.writeLong(portStat.getTxErrors().longValue());
+            outBuffer.writeLong(portStat.getRxFrameErr().longValue());
+            outBuffer.writeLong(portStat.getRxOverErr().longValue());
+            outBuffer.writeLong(portStat.getRxCrcErr().longValue());
+            outBuffer.writeLong(portStat.getCollisions().longValue());
+            outBuffer.writeInt(portStat.getDurationSec().intValue());
+            outBuffer.writeInt(portStat.getDurationNsec().intValue());
+        }
+    }
+
+    private void serializeTableBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyTableCase tableCase = (MultipartReplyTableCase) body;
+        MultipartReplyTable table = tableCase.getMultipartReplyTable();
+        for (TableStats tableStats : table.getTableStats()) {
+            outBuffer.writeByte(tableStats.getTableId());
+            outBuffer.writeZero(TABLE_PADDING);
+            outBuffer.writeInt(tableStats.getActiveCount().intValue());
+            outBuffer.writeLong(tableStats.getLookupCount().longValue());
+            outBuffer.writeLong(tableStats.getMatchedCount().longValue());
+        }
+    }
+
+    private void serializeAggregateBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyAggregateCase aggregateCase = (MultipartReplyAggregateCase) body;
+        MultipartReplyAggregate aggregate = aggregateCase.getMultipartReplyAggregate();
+        outBuffer.writeLong(aggregate.getPacketCount().longValue());
+        outBuffer.writeLong(aggregate.getByteCount().longValue());
+        outBuffer.writeInt(aggregate.getFlowCount().intValue());
+        outBuffer.writeZero(AGGREGATE_PADDING);
+    }
+
+    private void serializeFlowBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) {
+        MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body;
+        MultipartReplyFlow flow = flowCase.getMultipartReplyFlow();
+        for (FlowStats flowStats : flow.getFlowStats()) {
+            ByteBuf flowStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+            flowStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+            flowStatsBuff.writeByte(new Long(flowStats.getTableId()).byteValue());
+            flowStatsBuff.writeZero(FLOW_STATS_PADDING_1);
+            flowStatsBuff.writeInt(flowStats.getDurationSec().intValue());
+            flowStatsBuff.writeInt(flowStats.getDurationNsec().intValue());
+            flowStatsBuff.writeShort(flowStats.getPriority());
+            flowStatsBuff.writeShort(flowStats.getIdleTimeout());
+            flowStatsBuff.writeShort(flowStats.getHardTimeout());
+            flowStatsBuff.writeZero(FLOW_STATS_PADDING_2);
+            flowStatsBuff.writeLong(flowStats.getCookie().longValue());
+            flowStatsBuff.writeLong(flowStats.getPacketCount().longValue());
+            flowStatsBuff.writeLong(flowStats.getByteCount().longValue());
+            OFSerializer<Match> matchSerializer = registry.<Match, OFSerializer<Match>> getSerializer(
+                    new MessageTypeKey<>(message.getVersion(), Match.class));
+            matchSerializer.serialize(flowStats.getMatch(), flowStatsBuff);
+            ListSerializer.serializeList(flowStats.getInstruction(),
+                    TypeKeyMakerFactory.createInstructionKeyMaker(message.getVersion()), registry, flowStatsBuff);
+
+            flowStatsBuff.setShort(FLOW_STATS_LENGTH_INDEX, flowStatsBuff.readableBytes());
+            outBuffer.writeBytes(flowStatsBuff);
+        }
+    }
+
+    private void serializeDescBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyDescCase descCase = (MultipartReplyDescCase) body;
+        MultipartReplyDesc desc = descCase.getMultipartReplyDesc();
+        write256String(desc.getMfrDesc(), outBuffer);
+        write256String(desc.getHwDesc(), outBuffer);
+        write256String(desc.getSwDesc(), outBuffer);
+        write32String(desc.getSerialNum(), outBuffer);
+        write256String(desc.getDpDesc(), outBuffer);
+    }
+
+    private void write256String(String toWrite, ByteBuf outBuffer) {
+        byte[] nameBytes = toWrite.getBytes();
+        if (nameBytes.length < 256) {
+            byte[] nameBytesPadding = new byte[256];
+            int i = 0;
+            for (byte b : nameBytes) {
+                nameBytesPadding[i] = b;
+                i++;
+            }
+            for (; i < 256; i++) {
+                nameBytesPadding[i] = 0x0;
+            }
+            outBuffer.writeBytes(nameBytesPadding);
+        } else {
+            outBuffer.writeBytes(nameBytes);
+        }
+    }
+
+    private void write32String(String toWrite, ByteBuf outBuffer) {
+        byte[] nameBytes = toWrite.getBytes();
+        if (nameBytes.length < 32) {
+            byte[] nameBytesPadding = new byte[32];
+            int i = 0;
+            for (byte b : nameBytes) {
+                nameBytesPadding[i] = b;
+                i++;
+            }
+            for (; i < 32; i++) {
+                nameBytesPadding[i] = 0x0;
+            }
+            outBuffer.writeBytes(nameBytesPadding);
+        } else {
+            outBuffer.writeBytes(nameBytes);
+        }
+    }
+
+    private void serializePortDescBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyPortDescCase portCase = (MultipartReplyPortDescCase) body;
+        MultipartReplyPortDesc portDesc = portCase.getMultipartReplyPortDesc();
+        for (Ports port : portDesc.getPorts()) {
+            outBuffer.writeInt(port.getPortNo().intValue()); // Assuming PortNo
+                                                             // = PortId
+            outBuffer.writeZero(PORT_DESC_PADDING_1);
+            writeMacAddress(port.getHwAddr().getValue(), outBuffer);
+            outBuffer.writeZero(PORT_DESC_PADDING_2);
+            writeName(port.getName(), outBuffer);
+            writePortConfig(port.getConfig(), outBuffer);
+            writePortState(port.getState(), outBuffer);
+            writePortFeatures(port.getCurrentFeatures(), outBuffer);
+            writePortFeatures(port.getAdvertisedFeatures(), outBuffer);
+            writePortFeatures(port.getSupportedFeatures(), outBuffer);
+            writePortFeatures(port.getPeerFeatures(), outBuffer);
+            outBuffer.writeInt(port.getCurrSpeed().intValue());
+            outBuffer.writeInt(port.getMaxSpeed().intValue());
+        }
+    }
+
+    private void writeName(String name, ByteBuf outBuffer) {
+        byte[] nameBytes = name.getBytes();
+        if (nameBytes.length < 16) {
+            byte[] nameBytesPadding = new byte[16];
+            int i = 0;
+            for (byte b : nameBytes) {
+                nameBytesPadding[i] = b;
+                i++;
+            }
+            for (; i < 16; i++) {
+                nameBytesPadding[i] = 0x0;
+            }
+            outBuffer.writeBytes(nameBytesPadding);
+        } else {
+            outBuffer.writeBytes(nameBytes);
+        }
+
+    }
+
+    private void writeMacAddress(String macAddress, ByteBuf outBuffer) {
+        String[] macAddressParts = macAddress.split(":");
+        byte[] macAddressBytes = new byte[6];
+        for (int i = 0; i < 6; i++) {
+            Integer hex = Integer.parseInt(macAddressParts[i], 16);
+            macAddressBytes[i] = hex.byteValue();
+        }
+        outBuffer.writeBytes(macAddressBytes);
+    }
+
+    private void writePortConfig(PortConfig config, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, config.isPortDown());
+        map.put(2, config.isNoRecv());
+        map.put(5, config.isNoFwd());
+        map.put(6, config.isNoPacketIn());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void writePortState(PortState state, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, state.isLinkDown());
+        map.put(1, state.isBlocked());
+        map.put(2, state.isLive());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void writePortFeatures(PortFeatures features, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, features.is_10mbHd());
+        map.put(1, features.is_10mbFd());
+        map.put(2, features.is_100mbHd());
+        map.put(3, features.is_100mbFd());
+        map.put(4, features.is_1gbHd());
+        map.put(5, features.is_1gbFd());
+        map.put(6, features.is_10gbFd());
+        map.put(7, features.is_40gbFd());
+        map.put(8, features.is_100gbFd());
+        map.put(9, features.is_1tbFd());
+        map.put(10, features.isOther());
+        map.put(11, features.isCopper());
+        map.put(12, features.isFiber());
+        map.put(13, features.isAutoneg());
+        map.put(14, features.isPause());
+        map.put(15, features.isPauseAsym());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..2e317a1
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10BarrierReplyMessageFactory implements OFSerializer<BarrierOutput> {
+
+    private static final byte MESSAGE_TYPE = 19;
+
+    @Override
+    public void serialize(BarrierOutput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..8edf30c
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.HashMap;
+import java.util.Map;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10FeaturesReplyMessageFactory implements OFSerializer<GetFeaturesOutput> {
+
+    private static final byte PADDING = 3;
+    private static final byte MESSAGE_TYPE = 6;
+
+    @Override
+    public void serialize(GetFeaturesOutput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeLong(message.getDatapathId().longValue());
+        outBuffer.writeInt(message.getBuffers().intValue());
+        outBuffer.writeByte(message.getTables().intValue());
+        outBuffer.writeZero(PADDING);
+        outBuffer.writeInt(createCapabilities(message.getCapabilitiesV10()));
+        outBuffer.writeInt(createActionsV10(message.getActionsV10()));
+        for (PhyPort port : message.getPhyPort()) {
+            outBuffer.writeShort(port.getPortNo().intValue());
+            writeMacAddress(port.getHwAddr().getValue(), outBuffer);
+            writeName(port.getName(), outBuffer);
+            writePortConfig(port.getConfigV10(), outBuffer);
+            writePortState(port.getStateV10(), outBuffer);
+            writePortFeature(port.getCurrentFeaturesV10(), outBuffer);
+            writePortFeature(port.getAdvertisedFeaturesV10(), outBuffer);
+            writePortFeature(port.getSupportedFeaturesV10(), outBuffer);
+            writePortFeature(port.getPeerFeaturesV10(), outBuffer);
+        }
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+    private void writePortFeature(PortFeaturesV10 feature, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, feature.is_10mbHd());
+        map.put(1, feature.is_10mbFd());
+        map.put(2, feature.is_100mbHd());
+        map.put(3, feature.is_100mbFd());
+        map.put(4, feature.is_1gbHd());
+        map.put(5, feature.is_1gbFd());
+        map.put(6, feature.is_10gbFd());
+        map.put(7, feature.isCopper());
+        map.put(8, feature.isFiber());
+        map.put(9, feature.isAutoneg());
+        map.put(10, feature.isPause());
+        map.put(11, feature.isPauseAsym());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void writePortState(PortStateV10 state, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, state.isLinkDown());
+        map.put(1, state.isBlocked());
+        map.put(2, state.isLive());
+        map.put(3, state.isStpListen());
+        map.put(4, state.isStpLearn());
+        map.put(5, state.isStpForward());
+        map.put(6, state.isStpBlock());
+        map.put(7, state.isStpMask());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void writePortConfig(PortConfigV10 config, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, config.isPortDown());
+        map.put(1, config.isNoStp());
+        map.put(2, config.isNoRecv());
+        map.put(3, config.isNoRecvStp());
+        map.put(4, config.isNoFlood());
+        map.put(5, config.isNoFwd());
+        map.put(6, config.isNoPacketIn());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private static int createCapabilities(CapabilitiesV10 capabilities) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, capabilities.isOFPCFLOWSTATS());
+        map.put(1, capabilities.isOFPCTABLESTATS());
+        map.put(2, capabilities.isOFPCPORTSTATS());
+        map.put(3, capabilities.isOFPCSTP());
+        map.put(4, capabilities.isOFPCRESERVED());
+        map.put(5, capabilities.isOFPCIPREASM());
+        map.put(6, capabilities.isOFPCQUEUESTATS());
+        map.put(7, capabilities.isOFPCARPMATCHIP());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        return bitmap;
+    }
+
+    private static int createActionsV10(final ActionTypeV10 action) {
+        return ByteBufUtils.fillBitMask(0, action.isOFPATOUTPUT(), action.isOFPATSETVLANVID(),
+                action.isOFPATSETVLANPCP(), action.isOFPATSTRIPVLAN(), action.isOFPATSETDLSRC(),
+                action.isOFPATSETDLDST(), action.isOFPATSETNWSRC(), action.isOFPATSETNWDST(), action.isOFPATSETNWTOS(),
+                action.isOFPATSETTPSRC(), action.isOFPATSETTPDST(), action.isOFPATENQUEUE(), action.isOFPATVENDOR());
+
+    }
+
+    private void writeMacAddress(String macAddress, ByteBuf outBuffer) {
+        String[] macAddressParts = macAddress.split(":");
+        byte[] macAddressBytes = new byte[6];
+        for (int i = 0; i < 6; i++) {
+            Integer hex = Integer.parseInt(macAddressParts[i], 16);
+            macAddressBytes[i] = hex.byteValue();
+        }
+        outBuffer.writeBytes(macAddressBytes);
+    }
+
+    private void writeName(String name, ByteBuf outBuffer) {
+        byte[] nameBytes = name.getBytes();
+        if (nameBytes.length < 16) {
+            byte[] nameBytesPadding = new byte[16];
+            int i = 0;
+            for (byte b : nameBytes) {
+                nameBytesPadding[i] = b;
+                i++;
+            }
+            for (; i < 16; i++) {
+                nameBytesPadding[i] = 0x0;
+            }
+            outBuffer.writeBytes(nameBytesPadding);
+        } else {
+            outBuffer.writeBytes(nameBytes);
+        }
+
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactory.java
new file mode 100644 (file)
index 0000000..71b5a28
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10FlowRemovedMessageFactory implements OFSerializer<FlowRemovedMessage>, SerializerRegistryInjector {
+
+    private static final byte MESSAGE_TYPE = 11;
+    private SerializerRegistry registry;
+    private static final byte PADDING = 1;
+
+    @Override
+    public void injectSerializerRegistry(SerializerRegistry serializerRegistry) {
+        registry = serializerRegistry;
+    }
+
+    @Override
+    public void serialize(FlowRemovedMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+
+        OFSerializer<MatchV10> matchSerializer = registry
+                .getSerializer(new MessageTypeKey<>(message.getVersion(), MatchV10.class));
+
+        matchSerializer.serialize(message.getMatchV10(), outBuffer);
+
+        outBuffer.writeLong(message.getCookie().longValue());
+        outBuffer.writeShort(message.getPriority());
+        outBuffer.writeByte(message.getReason().getIntValue());
+        outBuffer.writeZero(PADDING);
+        outBuffer.writeInt(message.getDurationSec().intValue());
+        outBuffer.writeInt(message.getDurationNsec().intValue());
+        outBuffer.writeShort(message.getIdleTimeout());
+        outBuffer.writeZero(PADDING);
+        outBuffer.writeZero(PADDING);
+        outBuffer.writeLong(message.getPacketCount().longValue());
+        outBuffer.writeLong(message.getByteCount().longValue());
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactory.java
new file mode 100644 (file)
index 0000000..d2a1812
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10PacketInMessageFactory implements OFSerializer<PacketInMessage> {
+    private static final byte MESSAGE_TYPE = 10;
+    private static final byte PADDING = 1;
+
+    @Override
+    public void serialize(PacketInMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeInt(message.getBufferId().intValue());
+        outBuffer.writeShort(message.getTotalLen().intValue());
+        outBuffer.writeShort(message.getInPort());
+        outBuffer.writeByte(message.getReason().getIntValue());
+        outBuffer.writeZero(PADDING);
+        byte[] data = message.getData();
+
+        if (data != null) {
+            outBuffer.writeBytes(data);
+        }
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactory.java
new file mode 100644 (file)
index 0000000..376d0bd
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.HashMap;
+import java.util.Map;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10PortStatusMessageFactory implements OFSerializer<PortStatusMessage> {
+
+    private static final byte MESSAGE_TYPE = 12;
+    private static final byte PADDING = 7;
+
+    @Override
+    public void serialize(PortStatusMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeByte(message.getReason().getIntValue());
+        outBuffer.writeZero(PADDING);
+        outBuffer.writeShort(message.getPortNo().intValue());
+        writeMacAddress(message.getHwAddr().getValue(), outBuffer);
+        writeName(message.getName(), outBuffer);
+        writePortConfig(message.getConfigV10(), outBuffer);
+        writePortState(message.getStateV10(), outBuffer);
+        writePortFeature(message.getCurrentFeaturesV10(), outBuffer);
+        writePortFeature(message.getAdvertisedFeaturesV10(), outBuffer);
+        writePortFeature(message.getSupportedFeaturesV10(), outBuffer);
+        writePortFeature(message.getPeerFeaturesV10(), outBuffer);
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+    private void writePortFeature(PortFeaturesV10 feature, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, feature.is_10mbHd());
+        map.put(1, feature.is_10mbFd());
+        map.put(2, feature.is_100mbHd());
+        map.put(3, feature.is_100mbFd());
+        map.put(4, feature.is_1gbHd());
+        map.put(5, feature.is_1gbFd());
+        map.put(6, feature.is_10gbFd());
+        map.put(7, feature.isCopper());
+        map.put(8, feature.isFiber());
+        map.put(9, feature.isAutoneg());
+        map.put(10, feature.isPause());
+        map.put(11, feature.isPauseAsym());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void writePortState(PortStateV10 state, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, state.isLinkDown());
+        map.put(1, state.isBlocked());
+        map.put(2, state.isLive());
+        map.put(3, state.isStpListen());
+        map.put(4, state.isStpLearn());
+        map.put(5, state.isStpForward());
+        map.put(6, state.isStpBlock());
+        map.put(7, state.isStpMask());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void writePortConfig(PortConfigV10 config, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, config.isPortDown());
+        map.put(1, config.isNoStp());
+        map.put(2, config.isNoRecv());
+        map.put(3, config.isNoRecvStp());
+        map.put(4, config.isNoFlood());
+        map.put(5, config.isNoFwd());
+        map.put(6, config.isNoPacketIn());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void writeMacAddress(String macAddress, ByteBuf outBuffer) {
+        String[] macAddressParts = macAddress.split(":");
+        byte[] macAddressBytes = new byte[6];
+        for (int i = 0; i < 6; i++) {
+            Integer hex = Integer.parseInt(macAddressParts[i], 16);
+            macAddressBytes[i] = hex.byteValue();
+        }
+        outBuffer.writeBytes(macAddressBytes);
+    }
+
+    private void writeName(String name, ByteBuf outBuffer) {
+        byte[] nameBytes = name.getBytes();
+        if (nameBytes.length < 16) {
+            byte[] nameBytesPadding = new byte[16];
+            int i = 0;
+            for (byte b : nameBytes) {
+                nameBytesPadding[i] = b;
+                i++;
+            }
+            for (; i < 16; i++) {
+                nameBytesPadding[i] = 0x0;
+            }
+            outBuffer.writeBytes(nameBytesPadding);
+        } else {
+            outBuffer.writeBytes(nameBytes);
+        }
+
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..8504447
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10QueueGetConfigReplyMessageFactory implements OFSerializer<GetQueueConfigOutput> {
+
+    private static final byte MESSAGE_TYPE = 21;
+    private static final byte PADDING = 6;
+    private static final int QUEUE_LENGTH_INDEX = 4;
+    private static final byte QUEUE_PADDING = 2;
+    private static final byte QUEUE_PROPERTY_PADDING = 6;
+    private static final int QUEUE_PROPERTY_LENGTH_INDEX = 2;
+
+    @Override
+    public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeShort(message.getPort().getValue().intValue());
+        outBuffer.writeZero(PADDING);
+        for (Queues queue : message.getQueues()) {
+            ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+            queueBuff.writeInt(queue.getQueueId().getValue().intValue());
+            queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+            queueBuff.writeZero(QUEUE_PADDING);
+            for (QueueProperty queueProperty : queue.getQueueProperty()) {
+                ByteBuf queuePropertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+                queuePropertyBuff.writeShort(queueProperty.getProperty().getIntValue());
+                queuePropertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+                queuePropertyBuff.writeZero(4);
+                if (queueProperty.getProperty() == QueueProperties.OFPQTMINRATE) {
+                    RateQueueProperty body = queueProperty.getAugmentation(RateQueueProperty.class);
+                    queuePropertyBuff.writeShort(body.getRate().intValue());
+                    queuePropertyBuff.writeZero(QUEUE_PROPERTY_PADDING);
+                }
+                queuePropertyBuff.setShort(QUEUE_PROPERTY_LENGTH_INDEX, queuePropertyBuff.readableBytes());
+                queueBuff.writeBytes(queuePropertyBuff);
+            }
+            queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes());
+            outBuffer.writeBytes(queueBuff);
+        }
+
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..268f7f0
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.util.HashMap;
+import java.util.Map;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker;
+import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10StatsReplyMessageFactory implements OFSerializer<MultipartReplyMessage>, SerializerRegistryInjector {
+
+    private SerializerRegistry registry;
+    private static final byte MESSAGE_TYPE = 17;
+    private static final byte FLOW_STATS_PADDING_1 = 1;
+    private static final byte FLOW_STATS_PADDING_2 = 6;
+    private static final TypeKeyMaker<Action> ACTION_KEY_MAKER = TypeKeyMakerFactory
+            .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID);
+    private static final int FLOW_STATS_LENGTH_INDEX = 0;
+    private static final int QUEUE_STATS_LENGTH_INDEX = 0;
+    private static final byte AGGREGATE_PADDING = 4;
+    private static final byte TABLE_PADDING = 3;
+    private static final byte QUEUE_PADDING = 2;
+    private static final byte PORT_STATS_PADDING = 6;
+
+    @Override
+    public void injectSerializerRegistry(SerializerRegistry serializerRegistry) {
+        registry = serializerRegistry;
+    }
+
+    @Override
+    public void serialize(MultipartReplyMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeShort(message.getType().getIntValue());
+        writeFlags(message.getFlags(), outBuffer);
+        switch (message.getType()) {
+        case OFPMPDESC:
+            serializeDescBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPFLOW:
+            serializeFlowBody(message.getMultipartReplyBody(), outBuffer, message);
+            break;
+        case OFPMPAGGREGATE:
+            serializeAggregateBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPTABLE:
+            serializeTableBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPPORTSTATS:
+            serializePortStatsBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPQUEUE:
+            serializeQueueBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        case OFPMPEXPERIMENTER:
+            serializeExperimenterBody(message.getMultipartReplyBody(), outBuffer);
+            break;
+        default:
+            break;
+        }
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+    private void serializeExperimenterBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyExperimenterCase experimenterCase = (MultipartReplyExperimenterCase) body;
+        MultipartReplyExperimenter experimenterBody = experimenterCase.getMultipartReplyExperimenter();
+        // TODO: experimenterBody does not have get methods
+    }
+
+    private void serializeQueueBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyQueueCase queueCase = (MultipartReplyQueueCase) body;
+        MultipartReplyQueue queue = queueCase.getMultipartReplyQueue();
+        for (QueueStats queueStats : queue.getQueueStats()) {
+            ByteBuf queueStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+            queueStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+            queueStatsBuff.writeZero(QUEUE_PADDING);
+            queueStatsBuff.writeInt(queueStats.getQueueId().intValue());
+            queueStatsBuff.writeLong(queueStats.getTxBytes().longValue());
+            queueStatsBuff.writeLong(queueStats.getTxPackets().longValue());
+            queueStatsBuff.writeLong(queueStats.getTxErrors().longValue());
+            queueStatsBuff.setShort(QUEUE_STATS_LENGTH_INDEX, queueStatsBuff.readableBytes());
+            outBuffer.writeBytes(queueStatsBuff);
+        }
+    }
+
+    private void serializePortStatsBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyPortStatsCase portStatsCase = (MultipartReplyPortStatsCase) body;
+        MultipartReplyPortStats portStats = portStatsCase.getMultipartReplyPortStats();
+        for (PortStats portStat : portStats.getPortStats()) {
+            outBuffer.writeInt(portStat.getPortNo().intValue());
+            outBuffer.writeZero(PORT_STATS_PADDING);
+            outBuffer.writeLong(portStat.getRxPackets().longValue());
+            outBuffer.writeLong(portStat.getTxPackets().longValue());
+            outBuffer.writeLong(portStat.getRxBytes().longValue());
+            outBuffer.writeLong(portStat.getTxBytes().longValue());
+            outBuffer.writeLong(portStat.getRxDropped().longValue());
+            outBuffer.writeLong(portStat.getTxDropped().longValue());
+            outBuffer.writeLong(portStat.getRxErrors().longValue());
+            outBuffer.writeLong(portStat.getTxErrors().longValue());
+            outBuffer.writeLong(portStat.getRxFrameErr().longValue());
+            outBuffer.writeLong(portStat.getRxOverErr().longValue());
+            outBuffer.writeLong(portStat.getRxCrcErr().longValue());
+            outBuffer.writeLong(portStat.getCollisions().longValue());
+        }
+    }
+
+    private void serializeTableBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyTableCase tableCase = (MultipartReplyTableCase) body;
+        MultipartReplyTable table = tableCase.getMultipartReplyTable();
+        for (TableStats tableStats : table.getTableStats()) {
+            outBuffer.writeByte(tableStats.getTableId());
+            outBuffer.writeZero(TABLE_PADDING);
+            write16String(tableStats.getName(), outBuffer);
+            writeFlowWildcardsV10(tableStats.getWildcards(), outBuffer);
+            outBuffer.writeInt(tableStats.getMaxEntries().intValue());
+            outBuffer.writeInt(tableStats.getActiveCount().intValue());
+            outBuffer.writeLong(tableStats.getLookupCount().longValue());
+            outBuffer.writeLong(tableStats.getMatchedCount().longValue());
+        }
+    }
+
+    private void writeFlowWildcardsV10(FlowWildcardsV10 feature, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, feature.isINPORT());
+        map.put(1, feature.isDLVLAN());
+        map.put(2, feature.isDLSRC());
+        map.put(3, feature.isDLDST());
+        map.put(4, feature.isDLTYPE());
+        map.put(5, feature.isNWPROTO());
+        map.put(6, feature.isTPSRC());
+        map.put(7, feature.isTPDST());
+        map.put(20, feature.isDLVLANPCP());
+        map.put(21, feature.isNWTOS());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void serializeAggregateBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyAggregateCase aggregateCase = (MultipartReplyAggregateCase) body;
+        MultipartReplyAggregate aggregate = aggregateCase.getMultipartReplyAggregate();
+        outBuffer.writeLong(aggregate.getPacketCount().longValue());
+        outBuffer.writeLong(aggregate.getByteCount().longValue());
+        outBuffer.writeInt(aggregate.getFlowCount().intValue());
+        outBuffer.writeZero(AGGREGATE_PADDING);
+    }
+
+    private void serializeFlowBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) {
+        MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body;
+        MultipartReplyFlow flow = flowCase.getMultipartReplyFlow();
+        for (FlowStats flowStats : flow.getFlowStats()) {
+            ByteBuf flowStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+            flowStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+            flowStatsBuff.writeByte(new Long(flowStats.getTableId()).byteValue());
+            flowStatsBuff.writeZero(FLOW_STATS_PADDING_1);
+            OFSerializer<MatchV10> matchSerializer = registry
+                    .getSerializer(new MessageTypeKey<>(message.getVersion(), MatchV10.class));
+            matchSerializer.serialize(flowStats.getMatchV10(), flowStatsBuff);
+            flowStatsBuff.writeInt(flowStats.getDurationSec().intValue());
+            flowStatsBuff.writeInt(flowStats.getDurationNsec().intValue());
+            flowStatsBuff.writeShort(flowStats.getPriority());
+            flowStatsBuff.writeShort(flowStats.getIdleTimeout());
+            flowStatsBuff.writeShort(flowStats.getHardTimeout());
+            flowStatsBuff.writeZero(FLOW_STATS_PADDING_2);
+            flowStatsBuff.writeLong(flowStats.getCookie().longValue());
+            flowStatsBuff.writeLong(flowStats.getPacketCount().longValue());
+            flowStatsBuff.writeLong(flowStats.getByteCount().longValue());
+            ListSerializer.serializeList(flowStats.getAction(), ACTION_KEY_MAKER, registry, flowStatsBuff);
+            flowStatsBuff.setShort(FLOW_STATS_LENGTH_INDEX, flowStatsBuff.readableBytes());
+            outBuffer.writeBytes(flowStatsBuff);
+        }
+    }
+
+    private void writeFlags(MultipartRequestFlags flags, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, flags.isOFPMPFREQMORE());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeShort(bitmap);
+    }
+
+    private void serializeDescBody(MultipartReplyBody body, ByteBuf outBuffer) {
+        MultipartReplyDescCase descCase = (MultipartReplyDescCase) body;
+        MultipartReplyDesc desc = descCase.getMultipartReplyDesc();
+        write256String(desc.getMfrDesc(), outBuffer);
+        write256String(desc.getHwDesc(), outBuffer);
+        write256String(desc.getSwDesc(), outBuffer);
+        write32String(desc.getSerialNum(), outBuffer);
+        write256String(desc.getDpDesc(), outBuffer);
+    }
+
+    private void write256String(String toWrite, ByteBuf outBuffer) {
+        byte[] nameBytes = toWrite.getBytes();
+        if (nameBytes.length < 256) {
+            byte[] nameBytesPadding = new byte[256];
+            int i = 0;
+            for (byte b : nameBytes) {
+                nameBytesPadding[i] = b;
+                i++;
+            }
+            for (; i < 256; i++) {
+                nameBytesPadding[i] = 0x0;
+            }
+            outBuffer.writeBytes(nameBytesPadding);
+        } else {
+            outBuffer.writeBytes(nameBytes);
+        }
+    }
+
+    private void write16String(String toWrite, ByteBuf outBuffer) {
+        byte[] nameBytes = toWrite.getBytes();
+        if (nameBytes.length < 16) {
+            byte[] nameBytesPadding = new byte[16];
+            int i = 0;
+            for (byte b : nameBytes) {
+                nameBytesPadding[i] = b;
+                i++;
+            }
+            for (; i < 16; i++) {
+                nameBytesPadding[i] = 0x0;
+            }
+            outBuffer.writeBytes(nameBytesPadding);
+        } else {
+            outBuffer.writeBytes(nameBytes);
+        }
+    }
+
+    private void write32String(String toWrite, ByteBuf outBuffer) {
+        byte[] nameBytes = toWrite.getBytes();
+        if (nameBytes.length < 32) {
+            byte[] nameBytesPadding = new byte[32];
+            int i = 0;
+            for (byte b : nameBytes) {
+                nameBytesPadding[i] = b;
+                i++;
+            }
+            for (; i < 32; i++) {
+                nameBytesPadding[i] = 0x0;
+            }
+            outBuffer.writeBytes(nameBytesPadding);
+        } else {
+            outBuffer.writeBytes(nameBytes);
+        }
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactory.java
new file mode 100644 (file)
index 0000000..713e8ed
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+
+/**
+ * Translates PacketIn messages
+ */
+public class PacketInMessageFactory implements OFSerializer<PacketInMessage>, SerializerRegistryInjector {
+    private static final byte PADDING = 2;
+    private static final byte MESSAGE_TYPE = 10;
+    private SerializerRegistry registry;
+
+    @Override
+    public void serialize(PacketInMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeInt(message.getBufferId().intValue());
+        outBuffer.writeShort(message.getTotalLen().intValue());
+        outBuffer.writeByte(message.getReason().getIntValue());
+        outBuffer.writeByte(message.getTableId().getValue().byteValue());
+        outBuffer.writeLong(message.getCookie().longValue());
+        OFSerializer<Match> matchSerializer = registry
+                .<Match, OFSerializer<Match>> getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class));
+        matchSerializer.serialize(message.getMatch(), outBuffer);
+        outBuffer.writeZero(PADDING);
+
+        byte[] data = message.getData();
+
+        if (data != null) {
+            outBuffer.writeBytes(data);
+        }
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+    @Override
+    public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) {
+        this.registry = serializerRegistry;
+    }
+
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java
new file mode 100644 (file)
index 0000000..897db17
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.HashMap;
+import java.util.Map;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class PortStatusMessageFactory implements OFSerializer<PortStatusMessage> {
+
+    private static final byte MESSAGE_TYPE = 12;
+    private static final byte PADDING = 7;
+    private static final byte PORT_PADDING_1 = 4;
+    private static final byte PORT_PADDING_2 = 2;
+
+    @Override
+    public void serialize(PortStatusMessage message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeByte(message.getReason().getIntValue());
+        outBuffer.writeZero(PADDING);
+        outBuffer.writeInt(message.getPortNo().intValue());
+        outBuffer.writeZero(PORT_PADDING_1);
+        writeMacAddress(message.getHwAddr().getValue(), outBuffer);
+        outBuffer.writeZero(PORT_PADDING_2);
+        writeName(message.getName(), outBuffer);
+        writePortConfig(message.getConfig(), outBuffer);
+        writePortState(message.getState(), outBuffer);
+        writePortFeatures(message.getCurrentFeatures(), outBuffer);
+        writePortFeatures(message.getAdvertisedFeatures(), outBuffer);
+        writePortFeatures(message.getSupportedFeatures(), outBuffer);
+        writePortFeatures(message.getPeerFeatures(), outBuffer);
+        outBuffer.writeInt(message.getCurrSpeed().intValue());
+        outBuffer.writeInt(message.getMaxSpeed().intValue());
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+    private void writePortConfig(PortConfig config, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, config.isPortDown());
+        map.put(2, config.isNoRecv());
+        map.put(5, config.isNoFwd());
+        map.put(6, config.isNoPacketIn());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void writeMacAddress(String macAddress, ByteBuf outBuffer) {
+        String[] macAddressParts = macAddress.split(":");
+        byte[] macAddressBytes = new byte[6];
+        for (int i = 0; i < 6; i++) {
+            Integer hex = Integer.parseInt(macAddressParts[i], 16);
+            macAddressBytes[i] = hex.byteValue();
+        }
+        outBuffer.writeBytes(macAddressBytes);
+    }
+
+    private void writeName(String name, ByteBuf outBuffer) {
+        byte[] nameBytes = name.getBytes();
+        if (nameBytes.length < 16) {
+            byte[] nameBytesPadding = new byte[16];
+            int i = 0;
+            for (byte b : nameBytes) {
+                nameBytesPadding[i] = b;
+                i++;
+            }
+            for (; i < 16; i++) {
+                nameBytesPadding[i] = 0x0;
+            }
+            outBuffer.writeBytes(nameBytesPadding);
+        } else {
+            outBuffer.writeBytes(nameBytes);
+        }
+
+    }
+
+    private void writePortState(PortState state, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, state.isLinkDown());
+        map.put(1, state.isBlocked());
+        map.put(2, state.isLive());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+    private void writePortFeatures(PortFeatures features, ByteBuf outBuffer) {
+        Map<Integer, Boolean> map = new HashMap<>();
+        map.put(0, features.is_10mbHd());
+        map.put(1, features.is_10mbFd());
+        map.put(2, features.is_100mbHd());
+        map.put(3, features.is_100mbFd());
+        map.put(4, features.is_1gbHd());
+        map.put(5, features.is_1gbFd());
+        map.put(6, features.is_10gbFd());
+        map.put(7, features.is_40gbFd());
+        map.put(8, features.is_100gbFd());
+        map.put(9, features.is_1tbFd());
+        map.put(10, features.isOther());
+        map.put(11, features.isCopper());
+        map.put(12, features.isFiber());
+        map.put(13, features.isAutoneg());
+        map.put(14, features.isPause());
+        map.put(15, features.isPauseAsym());
+        int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+        outBuffer.writeInt(bitmap);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..3a15aac
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdQueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class QueueGetConfigReplyMessageFactory implements OFSerializer<GetQueueConfigOutput> {
+
+    private static final byte MESSAGE_TYPE = 23;
+    private static final byte PADDING = 4;
+    public static final int QUEUE_LENGTH_INDEX = 8;
+    public static final int PROPERTY_LENGTH_INDEX = 2;
+    private static final byte QUEUE_PADDING = 6;
+    private static final byte PROPERTY_HEADER_PADDING = 4;
+    private static final byte PROPERTY_RATE_PADDING = 6;
+    private static final byte PROPERTY_EXPERIMENTER_PADDING = 4;
+
+    @Override
+    public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeInt(message.getPort().getValue().intValue());
+        outBuffer.writeZero(PADDING);
+        for (Queues queue : message.getQueues()) {
+            ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+            queueBuff.writeInt(queue.getQueueId().getValue().intValue());
+            queueBuff.writeInt(queue.getPort().getValue().intValue());
+            queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+            queueBuff.writeZero(QUEUE_PADDING);
+
+            for (QueueProperty property : queue.getQueueProperty()) {
+                ByteBuf propertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
+                propertyBuff.writeShort(property.getProperty().getIntValue());
+                propertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
+                propertyBuff.writeZero(PROPERTY_HEADER_PADDING);
+                switch (property.getProperty()) {
+                case OFPQTMINRATE:
+                    serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff);
+                    break;
+                case OFPQTMAXRATE:
+                    serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff);
+                    break;
+                case OFPQTEXPERIMENTER:
+                    serializeExperimenterBody(property.getAugmentation(ExperimenterIdQueueProperty.class),
+                            propertyBuff);
+                    break;
+                default:
+                    break;
+                }
+                propertyBuff.setShort(PROPERTY_LENGTH_INDEX, propertyBuff.readableBytes());
+                queueBuff.writeBytes(propertyBuff);
+            }
+
+            queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes());
+            outBuffer.writeBytes(queueBuff);
+        }
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+    private void serializeRateBody(RateQueueProperty body, ByteBuf outBuffer) {
+        outBuffer.writeShort(body.getRate());
+        outBuffer.writeZero(PROPERTY_RATE_PADDING);
+    }
+
+    private void serializeExperimenterBody(ExperimenterIdQueueProperty body, ByteBuf outBuffer) {
+        // TODO: Experimenter Data is vendor specific that should implement its
+        // own serializer
+        outBuffer.writeInt(body.getExperimenter().getValue().intValue());
+        outBuffer.writeZero(PROPERTY_EXPERIMENTER_PADDING);
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..0225665
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class RoleReplyMessageFactory implements OFSerializer<RoleRequestOutput> {
+    private static final byte MESSAGE_TYPE = 25;
+    private static final byte PADDING = 4;
+
+    @Override
+    public void serialize(RoleRequestOutput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeInt(message.getRole().getIntValue());
+        outBuffer.writeZero(PADDING);
+        outBuffer.writeLong(message.getGenerationId().longValue());
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
+    }
+
+}
index 65395c16422112585ab1f244f00d57acc6e5337c..cef8daa7dd68f794535dc827aa1e90b1ce2ec3fc 100644 (file)
@@ -12,28 +12,43 @@ import static org.junit.Assert.assertEquals;
 
 import java.util.HashMap;
 import java.util.Map;
-
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
 
 /**
  * @author michal.polkorab
+ * @author giuseppex.petralia@intel.com
  *
  */
 public class TypeToClassMapInitializerTest {
@@ -78,4 +93,38 @@ public class TypeToClassMapInitializerTest {
         assertEquals("Wrong class", RoleRequestOutput.class, messageClassMap.get(new TypeToClassKey(version, 25)));
         assertEquals("Wrong class", GetAsyncOutput.class, messageClassMap.get(new TypeToClassKey(version, 27)));
     }
+
+    @Test
+    public void testAdditionalTypes() {
+        messageClassMap = new HashMap<>();
+        TypeToClassMapInitializer.initializeAdditionalTypeToClassMap(messageClassMap);
+        short version = EncodeConstants.OF10_VERSION_ID;
+        assertEquals("Wrong class", GetFeaturesInput.class, messageClassMap.get(new TypeToClassKey(version, 5)));
+        assertEquals("Wrong class", GetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 7)));
+        assertEquals("Wrong class", SetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 9)));
+        assertEquals("Wrong class", PacketOutInput.class, messageClassMap.get(new TypeToClassKey(version, 13)));
+        assertEquals("Wrong class", FlowModInput.class, messageClassMap.get(new TypeToClassKey(version, 14)));
+        assertEquals("Wrong class", PortModInput.class, messageClassMap.get(new TypeToClassKey(version, 15)));
+        assertEquals("Wrong class", MultipartRequestInput.class, messageClassMap.get(new TypeToClassKey(version, 16)));
+        assertEquals("Wrong class", BarrierInput.class, messageClassMap.get(new TypeToClassKey(version, 18)));
+        assertEquals("Wrong class", GetQueueConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 20)));
+
+        version = EncodeConstants.OF13_VERSION_ID;
+        assertEquals("Wrong class", GetFeaturesInput.class, messageClassMap.get(new TypeToClassKey(version, 5)));
+        assertEquals("Wrong class", GetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 7)));
+        assertEquals("Wrong class", SetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 9)));
+        assertEquals("Wrong class", PacketOutInput.class, messageClassMap.get(new TypeToClassKey(version, 13)));
+        assertEquals("Wrong class", FlowModInput.class, messageClassMap.get(new TypeToClassKey(version, 14)));
+        assertEquals("Wrong class", GroupModInput.class, messageClassMap.get(new TypeToClassKey(version, 15)));
+        assertEquals("Wrong class", PortModInput.class, messageClassMap.get(new TypeToClassKey(version, 16)));
+        assertEquals("Wrong class", TableModInput.class, messageClassMap.get(new TypeToClassKey(version, 17)));
+        assertEquals("Wrong class", MultipartRequestInput.class, messageClassMap.get(new TypeToClassKey(version, 18)));
+        assertEquals("Wrong class", BarrierInput.class, messageClassMap.get(new TypeToClassKey(version, 20)));
+        assertEquals("Wrong class", GetQueueConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 22)));
+        assertEquals("Wrong class", RoleRequestInput.class, messageClassMap.get(new TypeToClassKey(version, 24)));
+        assertEquals("Wrong class", GetAsyncInput.class, messageClassMap.get(new TypeToClassKey(version, 26)));
+        assertEquals("Wrong class", SetAsyncInput.class, messageClassMap.get(new TypeToClassKey(version, 28)));
+        assertEquals("Wrong class", MeterModInput.class, messageClassMap.get(new TypeToClassKey(version, 29)));
+    }
+
 }
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..1fbcfc1
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class BarrierInputMessageFactoryTest {
+    private OFDeserializer<BarrierInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 20, BarrierInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        BarrierInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..f98564b
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class FlowModInputMessageFactoryTest {
+    private OFDeserializer<FlowModInput> flowFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        flowFactory = registry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 14, FlowModInput.class));
+    }
+
+    @Test
+    public void test() throws Exception {
+        ByteBuf bb = BufferHelper
+                .buildBuffer("ff 01 04 01 06 00 07 01 ff 05 00 00 09 30 00 30 41 02 00 0c 00 00 00 7e 00 "
+                        + "00 00 02 00 00 11 46 00 00 00 62 00 0b 00 00 00 01 00 11 80 00 02 04 00 00 00 2a 80 00 12 01 04 00 "
+                        + "00 00 00 00 00 00 00 01 00 08 2b 00 00 00 00 02 00 18 00 00 00 00 ff 01 04 01 06 00 07 01 ff 05 00 00 "
+                        + "09 30 00 30 00 04 00 18 00 00 00 00 00 00 00 10 00 00 00 2a 00 34 00 00 00 00 00 00");
+        FlowModInput deserializedMessage = BufferHelper.deserialize(flowFactory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+        byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
+        Assert.assertEquals("Wrong cookie", new BigInteger(1, cookie), deserializedMessage.getCookie());
+        byte[] cookieMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 };
+        Assert.assertEquals("Wrong cookie mask", new BigInteger(1, cookieMask), deserializedMessage.getCookieMask());
+        Assert.assertEquals("Wrong table id", new TableId(65L), deserializedMessage.getTableId());
+        Assert.assertEquals("Wrong command", FlowModCommand.forValue(2), deserializedMessage.getCommand());
+        Assert.assertEquals("Wrong idle timeout", 12, deserializedMessage.getIdleTimeout().intValue());
+        Assert.assertEquals("Wrong hard timeout", 0, deserializedMessage.getHardTimeout().intValue());
+        Assert.assertEquals("Wrong priority", 126, deserializedMessage.getPriority().intValue());
+        Assert.assertEquals("Wrong buffer id ", 2L, deserializedMessage.getBufferId().longValue());
+        Assert.assertEquals("Wrong out port", new PortNumber(4422L), deserializedMessage.getOutPort());
+        Assert.assertEquals("Wrong out group", 98L, deserializedMessage.getOutGroup().longValue());
+        Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true),
+                deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong match", createMatch(), deserializedMessage.getMatch());
+        Assert.assertEquals("Wrong instructions", createInstructions(), deserializedMessage.getInstruction());
+
+    }
+
+    private List<Instruction> createInstructions() {
+        List<Instruction> instructions = new ArrayList<>();
+        InstructionBuilder insBuilder = new InstructionBuilder();
+        GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder();
+        GotoTableBuilder instructionBuilder = new GotoTableBuilder();
+        instructionBuilder.setTableId((short) 43);
+        goToCaseBuilder.setGotoTable(instructionBuilder.build());
+        insBuilder.setInstructionChoice(goToCaseBuilder.build());
+        instructions.add(insBuilder.build());
+        WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
+        WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
+        byte[] metadata = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
+        metadataBuilder.setMetadata(metadata);
+        byte[] metadataMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 };
+        metadataBuilder.setMetadataMask(metadataMask);
+        metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
+        insBuilder.setInstructionChoice(metadataCaseBuilder.build());
+        instructions.add(insBuilder.build());
+        insBuilder = new InstructionBuilder();
+        ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
+        ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder();
+        List<Action> actions = new ArrayList<>();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
+        OutputActionBuilder outputBuilder = new OutputActionBuilder();
+        outputBuilder.setPort(new PortNumber(42L));
+        outputBuilder.setMaxLength(52);
+        caseBuilder.setOutputAction(outputBuilder.build());
+        actionBuilder.setActionChoice(caseBuilder.build());
+        actions.add(actionBuilder.build());
+        actionsBuilder.setAction(actions);
+        applyActionsCaseBuilder.setApplyActions(actionsBuilder.build());
+        insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
+        instructions.add(insBuilder.build());
+        return instructions;
+    }
+
+    private Match createMatch() {
+        MatchBuilder matchBuilder = new MatchBuilder();
+        matchBuilder.setType(OxmMatchType.class);
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(InPhyPort.class);
+        entriesBuilder.setHasMask(false);
+        InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
+        InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
+        inPhyPortBuilder.setPortNumber(new PortNumber(42L));
+        inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
+        entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
+        entries.add(entriesBuilder.build());
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(IpEcn.class);
+        entriesBuilder.setHasMask(false);
+        IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
+        IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
+        ipEcnBuilder.setEcn((short) 4);
+        ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
+        entries.add(entriesBuilder.build());
+        matchBuilder.setMatchEntry(entries);
+        return matchBuilder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..dba971e
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GetAsyncRequestMessageFactoryTest {
+    private OFDeserializer<GetAsyncInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 26, GetAsyncInput.class));
+
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        GetAsyncInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..a2c9085
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GetConfigInputMessageFactoryTest {
+    private OFDeserializer<GetConfigInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 7, GetConfigInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        GetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputFactoryTest.java
new file mode 100644 (file)
index 0000000..0615098
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GetFeaturesInputFactoryTest {
+    private OFDeserializer<GetFeaturesInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 5, GetFeaturesInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        GetFeaturesInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..95f5197
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+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;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GetQueueConfigInputMessageFactoryTest {
+    private OFDeserializer<GetQueueConfigInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 22, GetQueueConfigInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 00 00 00 00");
+        GetQueueConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+        Assert.assertEquals("Wrong  Port No", new PortNumber(0x00010203L), deserializedMessage.getPort());
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..0ede670
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GroupModInputMessageFactoryTest {
+    private OFDeserializer<GroupModInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 15, GroupModInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper
+                .buildBuffer("00 02 03 00 00 00 01 00 00 10 00 0a 00 " + "00 00 41 00 00 00 16 00 00 00 00");
+        GroupModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        // Test Message
+        Assert.assertEquals("Wrong command", GroupModCommand.forValue(2), deserializedMessage.getCommand());
+        Assert.assertEquals("Wrong type", GroupType.forValue(3), deserializedMessage.getType());
+        Assert.assertEquals("Wrong group id", new GroupId(256L), deserializedMessage.getGroupId());
+        BucketsList bucket = deserializedMessage.getBucketsList().get(0);
+        Assert.assertEquals("Wrong weight", 10, bucket.getWeight().intValue());
+        Assert.assertEquals("Wrong watch port", new PortNumber(65L), bucket.getWatchPort());
+        Assert.assertEquals("Wrong watch group", 22L, bucket.getWatchGroup().longValue());
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..72c0250
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MeterModInputMessageFactoryTest {
+
+    private OFDeserializer<MeterModInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 29, MeterModInput.class));
+
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03 00 00 08 c8 00 "
+                + "01 00 10 00 00 00 01 00 00 00 02 00 00 00 " + "00 00 02 00 10 00 00 00 01 00 00 00 02 03 00 00 00");
+        MeterModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        Assert.assertEquals("Wrong command", MeterModCommand.forValue(1), deserializedMessage.getCommand());
+        Assert.assertEquals("Wrong flags", new MeterFlags(false, true, true, false), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong meter id", new MeterId(2248L), deserializedMessage.getMeterId());
+        Assert.assertEquals("Wrong band", createBandsList().get(0), deserializedMessage.getBands().get(0));
+        Assert.assertEquals("Wrong band", createBandsList().get(1), deserializedMessage.getBands().get(1));
+    }
+
+    private static List<Bands> createBandsList() {
+        List<Bands> bandsList = new ArrayList<>();
+        BandsBuilder bandsBuilder = new BandsBuilder();
+        MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
+        MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
+        dropBand.setType(MeterBandType.OFPMBTDROP);
+        dropBand.setRate(1L);
+        dropBand.setBurstSize(2L);
+        dropCaseBuilder.setMeterBandDrop(dropBand.build());
+        bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
+        MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
+        MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
+        dscpRemarkBand.setType(MeterBandType.OFPMBTDSCPREMARK);
+        dscpRemarkBand.setRate(1L);
+        dscpRemarkBand.setBurstSize(2L);
+        dscpRemarkBand.setPrecLevel((short) 3);
+        dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
+        bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
+        return bandsList;
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestAggregateInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestAggregateInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..43397a8
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.math.BigInteger;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartRequestAggregateInputMessageFactoryTest {
+
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class));
+
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 08 00 "
+                + "00 00 00 00 00 55 00 00 00 5f 00 00 00 00 00 01 01 01 01 01 " + "01 01 00 01 01 01 01 01 01 01");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", MultipartType.forValue(2), deserializedMessage.getType());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong aggregate", createRequestAggregate(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestAggregateCase createRequestAggregate() {
+        MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
+        MultipartRequestAggregateBuilder builder = new MultipartRequestAggregateBuilder();
+        builder.setTableId((short) 8);
+        builder.setOutPort(85L);
+        builder.setOutGroup(95L);
+        byte[] cookie = new byte[] { 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
+        builder.setCookie(new BigInteger(1, cookie));
+        byte[] cookieMask = new byte[] { 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
+        builder.setCookieMask(new BigInteger(1, cookieMask));
+        caseBuilder.setMultipartRequestAggregate(builder.build());
+        return caseBuilder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestDescInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestDescInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..89aea31
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartRequestDescInputMessageFactoryTest {
+
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", MultipartType.forValue(0), deserializedMessage.getType());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong aggregate", createRequestDesc(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestDescCase createRequestDesc() {
+        MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder();
+        MultipartRequestDescBuilder builder = new MultipartRequestDescBuilder();
+        builder.setEmpty(true);
+        caseBuilder.setMultipartRequestDesc(builder.build());
+        return caseBuilder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestFlowInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestFlowInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..d8f9d0a
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.math.BigInteger;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartRequestFlowInputMessageFactoryTest {
+
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class));
+
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 " + "08 00 00 00 00 00 00 55 00 00 00 5f 00 "
+                + "00 00 00 00 01 01 01 01 01 01 01 00 01 01 01 01 01 01 01");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", MultipartType.forValue(1), deserializedMessage.getType());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong flow", createRequestFlow(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestFlowCase createRequestFlow() {
+        MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder();
+        MultipartRequestFlowBuilder builder = new MultipartRequestFlowBuilder();
+        builder.setTableId((short) 8);
+        builder.setOutPort(85L);
+        builder.setOutGroup(95L);
+        byte[] cookie = new byte[] { 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
+        builder.setCookie(new BigInteger(1, cookie));
+        byte[] cookieMask = new byte[] { 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
+        builder.setCookieMask(new BigInteger(1, cookieMask));
+        caseBuilder.setMultipartRequestFlow(builder.build());
+        return caseBuilder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestGroupInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestGroupInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..6f73801
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartRequestGroupInputMessageFactoryTest {
+    ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 00 00 08 d2 00 00 00 00");
+    MultipartRequestInputMessageFactory factory;
+    MultipartRequestInput deserializedMessage;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class));
+
+    }
+
+    @Test
+    public void test() {
+        deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", MultipartType.forValue(6), deserializedMessage.getType());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong aggregate", createRequestGroup(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestGroupCase createRequestGroup() {
+        MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
+        MultipartRequestGroupBuilder builder = new MultipartRequestGroupBuilder();
+        builder.setGroupId(new GroupId(2258L));
+        caseBuilder.setMultipartRequestGroup(builder.build());
+        return caseBuilder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterConfigInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..46c3a13
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartRequestMeterConfigInputMessageFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 0a 00 01 00 00 00 00 00 00 04 6d 00 00 00 00");
+
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+        Assert.assertEquals("Wrong type", MultipartType.forValue(10), deserializedMessage.getType());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong aggregate", createRequestMeterConfig(),
+                deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestMeterConfigCase createRequestMeterConfig() {
+        MultipartRequestMeterConfigCaseBuilder caseBuilder = new MultipartRequestMeterConfigCaseBuilder();
+        MultipartRequestMeterConfigBuilder builder = new MultipartRequestMeterConfigBuilder();
+        builder.setMeterId(new MeterId(1133L));
+        caseBuilder.setMultipartRequestMeterConfig(builder.build());
+        return caseBuilder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..b4f334f
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartRequestMeterInputMessageFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 00 00 04 61 00 00 00 00");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+        Assert.assertEquals("Wrong type", MultipartType.forValue(9), deserializedMessage.getType());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong aggregate", createRequestMeter(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestMeterCase createRequestMeter() {
+        MultipartRequestMeterCaseBuilder caseBuilder = new MultipartRequestMeterCaseBuilder();
+        MultipartRequestMeterBuilder builder = new MultipartRequestMeterBuilder();
+        builder.setMeterId(new MeterId(1121L));
+        caseBuilder.setMultipartRequestMeter(builder.build());
+        return caseBuilder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestPortStatsInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestPortStatsInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..68482e3
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartRequestPortStatsInputMessageFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 00 00 08 cb 00 00 00 00");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", MultipartType.forValue(4), deserializedMessage.getType());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong aggregate", createRequestPortStats(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestPortStatsCase createRequestPortStats() {
+        MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder();
+        MultipartRequestPortStatsBuilder builder = new MultipartRequestPortStatsBuilder();
+        builder.setPortNo(2251L);
+        caseBuilder.setMultipartRequestPortStats(builder.build());
+        return caseBuilder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestQueueInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestQueueInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..6a746ea
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartRequestQueueInputMessageFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 00 00 08 d0 00 00 08 a3");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", MultipartType.forValue(5), deserializedMessage.getType());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong aggregate", createRequestQueue(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestQueueCase createRequestQueue() {
+        MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
+        MultipartRequestQueueBuilder builder = new MultipartRequestQueueBuilder();
+        builder.setPortNo(2256L);
+        builder.setQueueId(2211L);
+        caseBuilder.setMultipartRequestQueue(builder.build());
+        return caseBuilder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableFeaturesInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableFeaturesInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..600a7aa
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartRequestTableFeaturesInputMessageFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 0c 00 01 00 00 00 00 00 68 01 00 00 00 00 00 4e 61 6d "
+                + "65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "
+                + "00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 10 00 01 "
+                + "00 04 00 02 00 04 00 04 00 04 00 02 00 05 01 00 00 00 00 04 00 08 00 00 00 04 00 08 00 08 80 00 02 04 ");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+        Assert.assertEquals("Wrong type", MultipartType.forValue(12), deserializedMessage.getType());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong body", createTableFeatures(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    public MultipartRequestTableFeaturesCase createTableFeatures() {
+        MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
+        MultipartRequestTableFeaturesBuilder builder = new MultipartRequestTableFeaturesBuilder();
+        builder.setTableFeatures(createTableFeaturesList());
+        caseBuilder.setMultipartRequestTableFeatures(builder.build());
+        return caseBuilder.build();
+
+    }
+
+    public List<TableFeatures> createTableFeaturesList() {
+        List<TableFeatures> list = new ArrayList<>();
+        TableFeaturesBuilder builder = new TableFeaturesBuilder();
+        builder.setTableId((short) 1);
+        builder.setName("Name");
+        builder.setMetadataWrite(new BigInteger("1"));
+        builder.setMetadataMatch(new BigInteger("1"));
+        builder.setMaxEntries(1L);
+        builder.setConfig(new TableConfig(false));
+        builder.setTableFeatureProperties(createTableFeatureProperties());
+        list.add(builder.build());
+        return list;
+    }
+
+    public List<TableFeatureProperties> createTableFeatureProperties() {
+        List<TableFeatureProperties> list = new ArrayList<>();
+        TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder();
+        builder.setType(TableFeaturesPropType.forValue(0));
+        InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
+        insBuilder.setInstruction(createInstructions());
+        builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());
+        list.add(builder.build());
+
+        builder = new TableFeaturePropertiesBuilder();
+        builder.setType(TableFeaturesPropType.forValue(2));
+        NextTableRelatedTableFeaturePropertyBuilder nextBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
+        nextBuilder.setNextTableIds(createNextTableIds());
+        builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextBuilder.build());
+        list.add(builder.build());
+
+        builder = new TableFeaturePropertiesBuilder();
+        builder.setType(TableFeaturesPropType.forValue(4));
+        ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
+        actionBuilder.setAction(createAction());
+        builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());
+        list.add(builder.build());
+
+        builder = new TableFeaturePropertiesBuilder();
+        builder.setType(TableFeaturesPropType.forValue(8));
+        OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+        oxmBuilder.setMatchEntry(createMatchEntries());
+        builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+        list.add(builder.build());
+
+        return list;
+    }
+
+    public List<MatchEntry> createMatchEntries() {
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(InPhyPort.class);
+        entriesBuilder.setHasMask(false);
+        entries.add(entriesBuilder.build());
+        return entries;
+    }
+
+    public List<Action> createAction() {
+        List<Action> actions = new ArrayList<>();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
+        actionBuilder.setActionChoice(caseBuilder.build());
+        actions.add(actionBuilder.build());
+        return actions;
+    }
+
+    public List<NextTableIds> createNextTableIds() {
+        List<NextTableIds> list = new ArrayList<>();
+        NextTableIdsBuilder builder = new NextTableIdsBuilder();
+        builder.setTableId((short) 1);
+        list.add(builder.build());
+        return list;
+    }
+
+    public List<Instruction> createInstructions() {
+        List<Instruction> instructions = new ArrayList<>();
+        InstructionBuilder insBuilder = new InstructionBuilder();
+        GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder();
+        insBuilder.setInstructionChoice(goToCaseBuilder.build());
+        instructions.add(insBuilder.build());
+        WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
+        insBuilder.setInstructionChoice(metadataCaseBuilder.build());
+        instructions.add(insBuilder.build());
+        insBuilder = new InstructionBuilder();
+        ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
+        insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
+        instructions.add(insBuilder.build());
+        return instructions;
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..8719dc2
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartRequestTableInputMessageFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 00 00 00 00");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", MultipartType.forValue(3), deserializedMessage.getType());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags());
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..01f5184
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10BarrierInputMessageFactoryTest {
+    private OFDeserializer<BarrierInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 18, BarrierInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        BarrierInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..97682d8
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10FeaturesRequestMessageFactoryTest {
+    private OFDeserializer<GetFeaturesInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 5, GetFeaturesInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        GetFeaturesInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..92c16dc
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10FlowModInputMessageFactoryTest {
+    private OFDeserializer<FlowModInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 14, FlowModInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 38 20 ff 00 3a 01 01 01 01 01 01 ff "
+                + "ff ff ff ff ff 00 12 05 00 00 2a 04 07 00 00 08 08 08 08 10 10 10 10 "
+                + "19 fd 19 e9 ff 01 04 01 06 00 07 01 00 00 00 0c 00 10 00 01 00 00 00 02 "
+                + "11 46 00 03 00 07 00 08 02 02 02 02 00 09 00 08 00 2a 00 00 ");
+        FlowModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+        Assert.assertEquals("Wrong Match", createMatch(), deserializedMessage.getMatchV10());
+        byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
+        Assert.assertEquals("Wrong cookie", new BigInteger(1, cookie), deserializedMessage.getCookie());
+        Assert.assertEquals("Wrong command", FlowModCommand.forValue(0), deserializedMessage.getCommand());
+        Assert.assertEquals("Idle Timeout", 12, deserializedMessage.getIdleTimeout().intValue());
+        Assert.assertEquals("Wrong Hard Timeout", 16, deserializedMessage.getHardTimeout().intValue());
+        Assert.assertEquals("Wrong priority", 1, deserializedMessage.getPriority().intValue());
+        Assert.assertEquals("Wrong buffer id", 2L, deserializedMessage.getBufferId().longValue());
+        Assert.assertEquals("Wrong out port", new PortNumber(4422L), deserializedMessage.getOutPort());
+        Assert.assertEquals("Wrong flags", new FlowModFlagsV10(true, false, true), deserializedMessage.getFlagsV10());
+        Assert.assertEquals("Wrong actions", createAction(), deserializedMessage.getAction());
+    }
+
+    private static List<Action> createAction() {
+        List<Action> actions = new ArrayList<>();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        SetNwDstCaseBuilder nwDstCaseBuilder = new SetNwDstCaseBuilder();
+        SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder();
+        nwDstBuilder.setIpAddress(new Ipv4Address("2.2.2.2"));
+        nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());
+        actionBuilder.setActionChoice(nwDstCaseBuilder.build());
+        actions.add(actionBuilder.build());
+        actionBuilder = new ActionBuilder();
+        SetTpSrcCaseBuilder tpSrcCaseBuilder = new SetTpSrcCaseBuilder();
+        SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder();
+        tpSrcBuilder.setPort(new PortNumber(42L));
+        tpSrcCaseBuilder.setSetTpSrcAction(tpSrcBuilder.build());
+        actionBuilder.setActionChoice(tpSrcCaseBuilder.build());
+        actions.add(actionBuilder.build());
+        return actions;
+    }
+
+    private static MatchV10 createMatch() {
+        MatchV10Builder matchBuilder = new MatchV10Builder();
+        matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
+        matchBuilder.setNwSrcMask((short) 0);
+        matchBuilder.setNwDstMask((short) 0);
+        matchBuilder.setInPort(58);
+        matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
+        matchBuilder.setDlDst(new MacAddress("FF:FF:FF:FF:FF:FF"));
+        matchBuilder.setDlVlan(18);
+        matchBuilder.setDlVlanPcp((short) 5);
+        matchBuilder.setDlType(42);
+        matchBuilder.setNwTos((short) 4);
+        matchBuilder.setNwProto((short) 7);
+        matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));
+        matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));
+        matchBuilder.setTpSrc(6653);
+        matchBuilder.setTpDst(6633);
+        return matchBuilder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..6ab2282
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10GetConfigInputMessageFactoryTest {
+    private OFDeserializer<GetConfigInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 7, GetConfigInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        GetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..15873bd
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+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;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10GetQueueConfigInputMessageFactoryTest {
+    private OFDeserializer<GetQueueConfigInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 20, GetQueueConfigInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("19 fd 00 00");
+        GetQueueConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+        Assert.assertEquals("Wrong port", new PortNumber(6653L), deserializedMessage.getPort());
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..9342502
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10PacketOutInputMessageFactoryTest {
+    private OFDeserializer<PacketOutInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 13, PacketOutInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 00 01 00 01 01 00 10 00 00 00 08 "
+                + "00 2a 00 32 00 03 00 08 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
+
+        PacketOutInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+        Assert.assertEquals("Wrong bufferId ", 256L, deserializedMessage.getBufferId().longValue());
+        Assert.assertEquals("Wrong inPort ", new PortNumber(257L), deserializedMessage.getInPort());
+        Assert.assertEquals("Wrong action ", createActionList().get(0), deserializedMessage.getAction().get(0));
+        Assert.assertEquals("Wrong action ", createActionList().get(1), deserializedMessage.getAction().get(1));
+        Assert.assertArrayEquals("Wrong data ",
+                ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"),
+                deserializedMessage.getData());
+    }
+
+    private static List<Action> createActionList() {
+        List<Action> actions = new ArrayList<>();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
+        OutputActionBuilder outputBuilder = new OutputActionBuilder();
+        outputBuilder.setPort(new PortNumber(42L));
+        outputBuilder.setMaxLength(50);
+        caseBuilder.setOutputAction(outputBuilder.build());
+        actionBuilder.setActionChoice(caseBuilder.build());
+        actions.add(actionBuilder.build());
+        actionBuilder = new ActionBuilder();
+        actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());
+        actions.add(actionBuilder.build());
+        return actions;
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..e4a3a80
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10PortModInputMessageFactoryTest {
+    private OFDeserializer<PortModInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 15, PortModInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper
+                .buildBuffer("19 e9 08 00 27 00 b0 eb " + "00 00 00 15 00 00 00 62 00 00 02 8c 00 00 00 00 ");
+        PortModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+        Assert.assertEquals("Wrong port", new PortNumber(6633L), deserializedMessage.getPortNo());
+        Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:B0:EB"), deserializedMessage.getHwAddress());
+        Assert.assertEquals("Wrong config", new PortConfigV10(true, false, false, true, false, false, true),
+                deserializedMessage.getConfigV10());
+        Assert.assertEquals("Wrong mask", new PortConfigV10(false, true, true, false, false, true, false),
+                deserializedMessage.getMaskV10());
+        Assert.assertEquals("Wrong advertise",
+                new PortFeaturesV10(true, true, false, false, false, false, false, true, true, false, false, false),
+                deserializedMessage.getAdvertiseV10());
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..763210c
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10SetConfigMessageFactoryTest {
+    private OFDeserializer<SetConfigInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 9, SetConfigInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03");
+        SetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+        Assert.assertEquals("Wrong switchConfigFlag", 0x01, deserializedMessage.getFlags().getIntValue());
+        Assert.assertEquals("Wrong missSendLen", 0x03, deserializedMessage.getMissSendLen().intValue());
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputAggregateFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputAggregateFactoryTest.java
new file mode 100644 (file)
index 0000000..1c58e70
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10StatsRequestInputAggregateFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 02 00 00 00 00 00 00 00 33 00 01 02 "
+                + "03 04 05 05 04 03 02 01 00 00 34 35 00 00 36 37 38 00 00 0a 00 00 01 "
+                + "0a 00 00 02 00 39 00 3a 2a 00 19 fd");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", 2, deserializedMessage.getType().getIntValue());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestBody createMultipartRequestBody() {
+        MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
+        MultipartRequestAggregateBuilder aggregateBuilder = new MultipartRequestAggregateBuilder();
+        MatchV10Builder matchBuilder = new MatchV10Builder();
+        matchBuilder.setWildcards(
+                new FlowWildcardsV10(false, false, false, false, false, false, false, false, false, false));
+        matchBuilder.setNwSrcMask((short) 32);
+        matchBuilder.setNwDstMask((short) 32);
+        matchBuilder.setInPort(51);
+        matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05"));
+        matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00"));
+        matchBuilder.setDlVlan(52);
+        matchBuilder.setDlVlanPcp((short) 53);
+        matchBuilder.setDlType(54);
+        matchBuilder.setNwTos((short) 55);
+        matchBuilder.setNwProto((short) 56);
+        matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1"));
+        matchBuilder.setNwDst(new Ipv4Address("10.0.0.2"));
+        matchBuilder.setTpSrc(57);
+        matchBuilder.setTpDst(58);
+        aggregateBuilder.setMatchV10(matchBuilder.build());
+        aggregateBuilder.setTableId((short) 42);
+        aggregateBuilder.setOutPort(6653L);
+        caseBuilder.setMultipartRequestAggregate(aggregateBuilder.build());
+        return caseBuilder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputDescFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputDescFactoryTest.java
new file mode 100644 (file)
index 0000000..545d1d7
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10StatsRequestInputDescFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", 0, deserializedMessage.getType().getIntValue());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestBody createMultipartRequestBody() {
+        MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder();
+        MultipartRequestDescBuilder descBuilder = new MultipartRequestDescBuilder();
+        descBuilder.setEmpty(true);
+        caseBuilder.setMultipartRequestDesc(descBuilder.build());
+        return caseBuilder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFlowFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFlowFactoryTest.java
new file mode 100644 (file)
index 0000000..e9c6dcb
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10StatsRequestInputFlowFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 34 18 ff 00 33 00 01 02 03 04 "
+                + "05 05 04 03 02 01 00 00 34 35 00 00 36 37 38 00 00 0a 00 00 01 0a 00 00 02 "
+                + "00 39 00 3a 01 00 00 2a ");
+
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+        Assert.assertEquals("Wrong type", 1, deserializedMessage.getType().getIntValue());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestBody createMultipartRequestBody() {
+        MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder();
+        MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder();
+        MatchV10Builder matchBuilder = new MatchV10Builder();
+        matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
+        matchBuilder.setNwSrcMask((short) 8);
+        matchBuilder.setNwDstMask((short) 16);
+        matchBuilder.setInPort(51);
+        matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05"));
+        matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00"));
+        matchBuilder.setDlVlan(52);
+        matchBuilder.setDlVlanPcp((short) 53);
+        matchBuilder.setDlType(54);
+        matchBuilder.setNwTos((short) 55);
+        matchBuilder.setNwProto((short) 56);
+        matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1"));
+        matchBuilder.setNwDst(new Ipv4Address("10.0.0.2"));
+        matchBuilder.setTpSrc(57);
+        matchBuilder.setTpDst(58);
+        flowBuilder.setMatchV10(matchBuilder.build());
+        flowBuilder.setTableId((short) 1);
+        flowBuilder.setOutPort(42L);
+        caseBuilder.setMultipartRequestFlow(flowBuilder.build());
+        return caseBuilder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputPortStatsFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputPortStatsFactoryTest.java
new file mode 100644 (file)
index 0000000..afe70c9
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10StatsRequestInputPortStatsFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 04 00 00 00 0f 00 00 00 00 00 00");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", 4, deserializedMessage.getType().getIntValue());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestBody createMultipartRequestBody() {
+        MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder();
+        MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder();
+        portBuilder.setPortNo(15L);
+        caseBuilder.setMultipartRequestPortStats(portBuilder.build());
+        return caseBuilder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputQueueFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputQueueFactoryTest.java
new file mode 100644 (file)
index 0000000..39c571c
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10StatsRequestInputQueueFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 05 00 00 00 0f 00 00 00 00 00 10");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", 5, deserializedMessage.getType().getIntValue());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestBody createMultipartRequestBody() {
+        MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
+        MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder();
+        queueBuilder.setPortNo(15L);
+        queueBuilder.setQueueId(16L);
+        caseBuilder.setMultipartRequestQueue(queueBuilder.build());
+        return caseBuilder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputTableFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputTableFactoryTest.java
new file mode 100644 (file)
index 0000000..bc9bdf7
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10StatsRequestInputTableFactoryTest {
+    private OFDeserializer<MultipartRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 03 00 00");
+        MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV10(deserializedMessage);
+
+        Assert.assertEquals("Wrong type", 3, deserializedMessage.getType().getIntValue());
+        Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody());
+    }
+
+    private static MultipartRequestBody createMultipartRequestBody() {
+        MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder();
+        MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder();
+        tableBuilder.setEmpty(true);
+        caseBuilder.setMultipartRequestTable(tableBuilder.build());
+        return caseBuilder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..8a2b1e9
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class PacketOutInputMessageFactoryTest {
+    private OFDeserializer<PacketOutInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 13, PacketOutInput.class));
+
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer(
+                "00 00 01 00 00 00 01 00 00 28 00 00 00 00 00 00 00 11 00 08 00 19 00 00 00 12 00 08 00 00 00 00 00 12 "
+                        + "00 08 00 00 00 00 00 12 00 08 00 00 00 00 00 12 00 08 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 10 "
+                        + "11 12 13 14");
+        PacketOutInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        Assert.assertEquals("Wrong buffer Id", 256L, deserializedMessage.getBufferId().longValue());
+        Assert.assertEquals("Wrong In Port", new PortNumber(256L), deserializedMessage.getInPort());
+        Assert.assertEquals("Wrong Numbers of actions", createAction(), deserializedMessage.getAction());
+        byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
+        Assert.assertArrayEquals("Wrong data", data, deserializedMessage.getData());
+    }
+
+    private List<Action> createAction() {
+        List<Action> actions = new ArrayList<>();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
+        PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder();
+        pushVlanBuilder.setEthertype(new EtherType(new EtherType(25)));
+        pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build());
+        actionBuilder.setActionChoice(pushVlanCaseBuilder.build());
+        actions.add(actionBuilder.build());
+        actionBuilder = new ActionBuilder();
+        actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
+        actions.add(actionBuilder.build());
+        actionBuilder = new ActionBuilder();
+        actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
+        actions.add(actionBuilder.build());
+        actionBuilder = new ActionBuilder();
+        actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
+        actions.add(actionBuilder.build());
+        actionBuilder = new ActionBuilder();
+        actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
+        actions.add(actionBuilder.build());
+        return actions;
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..6c4850c
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class PortModInputMessageFactoryTest {
+    private OFDeserializer<PortModInput> factory;
+
+    @Before
+    public void startUp() throws Exception {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 16, PortModInput.class));
+    }
+
+    @Test
+    public void test() throws Exception {
+        ByteBuf bb = BufferHelper.buildBuffer(
+                "00 00 00 09 00 00 00 00 08 00 27 00 " + "b0 eb 00 00 00 00 00 24 00 00 00 41 00 00 01 10 00 00 00 00");
+        PortModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        // Test Message
+        Assert.assertEquals("Wrong port", new PortNumber(9L), deserializedMessage.getPortNo());
+        Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:B0:EB"), deserializedMessage.getHwAddress());
+        Assert.assertEquals("Wrong config", new PortConfig(true, false, true, false), deserializedMessage.getConfig());
+        Assert.assertEquals("Wrong mask", new PortConfig(false, true, false, true), deserializedMessage.getMask());
+        Assert.assertEquals("Wrong advertise", new PortFeatures(true, false, false, false, false, false, false, true,
+                false, false, false, false, false, false, false, false), deserializedMessage.getAdvertise());
+
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..368aca4
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.math.BigInteger;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class RoleRequestInputMessageFactoryTest {
+    private OFDeserializer<RoleRequestInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 24, RoleRequestInput.class));
+
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 00 00 02 00 00 00 00 ff 01 01 01 01 01 01 01");
+        RoleRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+        Assert.assertEquals("Wrong role", ControllerRole.forValue(2), deserializedMessage.getRole());
+        byte[] generationId = new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
+        Assert.assertEquals("Wrong generation Id", new BigInteger(1, generationId),
+                deserializedMessage.getGenerationId());
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..e5c1d9a
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class SetAsyncInputMessageFactoryTest {
+    private OFDeserializer<SetAsyncInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 28, SetAsyncInput.class));
+
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper
+                .buildBuffer("00 00 00 07 00 00 00 00 00 00 00 " + "07 00 00 00 00 00 00 00 0f 00 00 00 00");
+        SetAsyncInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        Assert.assertEquals("Wrong packet in mask ", createPacketInMask().get(0),
+                deserializedMessage.getPacketInMask().get(0));
+        Assert.assertEquals("Wrong packet in mask ", createPacketInMask().get(1),
+                deserializedMessage.getPacketInMask().get(1));
+        Assert.assertEquals("Wrong port status mask ", createPortStatusMask().get(0),
+                deserializedMessage.getPortStatusMask().get(0));
+        Assert.assertEquals("Wrong port status mask ", createPortStatusMask().get(1),
+                deserializedMessage.getPortStatusMask().get(1));
+        Assert.assertEquals("Wrong flow removed mask ", createFlowRemowedMask().get(0),
+                deserializedMessage.getFlowRemovedMask().get(0));
+        Assert.assertEquals("Wrong flow removed mask ", createFlowRemowedMask().get(1),
+                deserializedMessage.getFlowRemovedMask().get(1));
+
+    }
+
+    private static List<PacketInMask> createPacketInMask() {
+        List<PacketInMask> masks = new ArrayList<>();
+        PacketInMaskBuilder builder;
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        builder = new PacketInMaskBuilder();
+        List<PacketInReason> packetInReasonList = new ArrayList<>();
+        packetInReasonList.add(PacketInReason.OFPRNOMATCH);
+        packetInReasonList.add(PacketInReason.OFPRACTION);
+        packetInReasonList.add(PacketInReason.OFPRINVALIDTTL);
+        builder.setMask(packetInReasonList);
+        masks.add(builder.build());
+        // OFPCR_ROLE_SLAVE
+        builder = new PacketInMaskBuilder();
+        packetInReasonList = new ArrayList<>();
+        builder.setMask(packetInReasonList);
+        masks.add(builder.build());
+        return masks;
+    }
+
+    private static List<PortStatusMask> createPortStatusMask() {
+        List<PortStatusMask> masks = new ArrayList<>();
+        PortStatusMaskBuilder builder;
+        builder = new PortStatusMaskBuilder();
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        List<PortReason> portReasonList = new ArrayList<>();
+        portReasonList.add(PortReason.OFPPRADD);
+        portReasonList.add(PortReason.OFPPRDELETE);
+        portReasonList.add(PortReason.OFPPRMODIFY);
+        builder.setMask(portReasonList);
+        masks.add(builder.build());
+        // OFPCR_ROLE_SLAVE
+        builder = new PortStatusMaskBuilder();
+        portReasonList = new ArrayList<>();
+        builder.setMask(portReasonList);
+        masks.add(builder.build());
+        return masks;
+    }
+
+    private static List<FlowRemovedMask> createFlowRemowedMask() {
+        List<FlowRemovedMask> masks = new ArrayList<>();
+        FlowRemovedMaskBuilder builder;
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        builder = new FlowRemovedMaskBuilder();
+        List<FlowRemovedReason> flowRemovedReasonList = new ArrayList<>();
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE);
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE);
+        builder.setMask(flowRemovedReasonList);
+        masks.add(builder.build());
+        // OFPCR_ROLE_SLAVE
+        builder = new FlowRemovedMaskBuilder();
+        flowRemovedReasonList = new ArrayList<>();
+        builder.setMask(flowRemovedReasonList);
+        masks.add(builder.build());
+        return masks;
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..d15b835
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class SetConfigMessageFactoryTest {
+    private OFDeserializer<SetConfigInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 9, SetConfigInput.class));
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 02 " + "00 0a");
+        SetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+
+        // Test Message
+        Assert.assertEquals("Wrong flags ", SwitchConfigFlag.forValue(2), deserializedMessage.getFlags());
+        Assert.assertEquals("Wrong Miss Send len ", 10, deserializedMessage.getMissSendLen().intValue());
+    }
+
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..3b63748
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class TableModInputMessageFactoryTest {
+
+    private OFDeserializer<TableModInput> factory;
+
+    @Before
+    public void startUp() {
+        DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
+        desRegistry.init();
+        factory = desRegistry
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 17, TableModInput.class));
+
+    }
+
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("09 00 00 00 00 00 00 01");
+        TableModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
+        BufferHelper.checkHeaderV13(deserializedMessage);
+        // Test Message
+        Assert.assertEquals("Wrong table id ", new TableId(9L), deserializedMessage.getTableId());
+        Assert.assertEquals("Wrong config ", new TableConfig(true), deserializedMessage.getConfig());
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..cbe260d
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class BarrierReplyMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 21;
+    private OFSerializer<BarrierOutput> factory;
+
+    @Before
+    public void startUp() throws Exception {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, BarrierOutput.class));
+
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        BarrierOutputBuilder builder = new BarrierOutputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        BarrierOutput message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 8);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..cc0ba0d
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class EchoOutputMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 3;
+    private OFSerializer<EchoOutput> factory;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, EchoOutput.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        EchoOutputBuilder builder = new EchoOutputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
+        builder.setData(data);
+        EchoOutput message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24);
+        Assert.assertArrayEquals("Wrong data", message.getData(),
+                serializedBuffer.readBytes(serializedBuffer.readableBytes()).array());
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..20f8b5f
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class EchoRequestMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 2;
+    EchoRequestMessage message;
+    private OFSerializer<EchoRequestMessage> factory;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, EchoRequestMessage.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
+        builder.setData(data);
+        EchoRequestMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24);
+        Assert.assertArrayEquals("Wrong data", message.getData(),
+                serializedBuffer.readBytes(serializedBuffer.readableBytes()).array());
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..ff3e70e
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class ErrorMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 1;
+    private OFSerializer<ErrorMessage> factory;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, ErrorMessage.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        ErrorMessageBuilder builder = new ErrorMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(10);
+        builder.setCode(20);
+        byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
+        builder.setData(data);
+        ErrorMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 28);
+        Assert.assertEquals("Wrong Type", message.getType().intValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong Code", message.getCode().intValue(), serializedBuffer.readShort());
+        Assert.assertArrayEquals("Wrong data", message.getData(),
+                serializedBuffer.readBytes(serializedBuffer.readableBytes()).array());
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..616b289
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class FlowRemovedMessageFactoryTest {
+    private OFSerializer<FlowRemovedMessage> factory;
+    private static final byte MESSAGE_TYPE = 11;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, FlowRemovedMessage.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setCookie(BigInteger.valueOf(1234L));
+        builder.setPriority(1234);
+        builder.setReason(FlowRemovedReason.forValue(2));
+        builder.setTableId(new TableId(65L));
+        builder.setDurationSec(1234L);
+        builder.setDurationNsec(1234L);
+        builder.setIdleTimeout(1234);
+        builder.setHardTimeout(1234);
+        builder.setPacketCount(BigInteger.valueOf(1234L));
+        builder.setByteCount(BigInteger.valueOf(1234L));
+        MatchBuilder matchBuilder = new MatchBuilder();
+        matchBuilder.setType(OxmMatchType.class);
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(InPhyPort.class);
+        entriesBuilder.setHasMask(false);
+        InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
+        InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
+        inPhyPortBuilder.setPortNumber(new PortNumber(42L));
+        inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
+        entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
+        entries.add(entriesBuilder.build());
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(IpEcn.class);
+        entriesBuilder.setHasMask(false);
+        IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
+        IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
+        ipEcnBuilder.setEcn((short) 4);
+        ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
+        entries.add(entriesBuilder.build());
+        matchBuilder.setMatchEntry(entries);
+        builder.setMatch(matchBuilder.build());
+        FlowRemovedMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 72);
+        Assert.assertEquals("Wrong cookie", message.getCookie().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong priority", message.getPriority().intValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readByte());
+        Assert.assertEquals("Wrong Table ID", message.getTableId().getValue().intValue(),
+                serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong duration sec", message.getDurationSec().intValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong duration nsec", message.getDurationNsec().intValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong Idle timeout", message.getIdleTimeout().intValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong Hard timeout", message.getIdleTimeout().intValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong Packet count", message.getPacketCount().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong Byte count", message.getByteCount().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong match type", 1, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort());
+        short fieldAndMask = serializedBuffer.readUnsignedByte();
+        Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
+        Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);
+        serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+        Assert.assertEquals("Wrong oxm value", 42, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort());
+        fieldAndMask = serializedBuffer.readUnsignedByte();
+        Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
+        Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);
+        serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+        Assert.assertEquals("Wrong oxm value", 4, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(7);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..f645944
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GetAsyncReplyMessageFactoryTest {
+    private OFSerializer<GetAsyncOutput> factory;
+    private static final byte MESSAGE_TYPE = 27;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, GetAsyncOutput.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setPacketInMask(createPacketInMask());
+        builder.setPortStatusMask(createPortStatusMask());
+        builder.setFlowRemovedMask(createFlowRemowedMask());
+        GetAsyncOutput message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 32);
+        Assert.assertEquals("Wrong packetInMask", 7, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong packetInMask", 0, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong portStatusMask", 7, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong portStatusMask", 0, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong flowRemovedMask", 15, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong flowRemovedMask", 0, serializedBuffer.readUnsignedInt());
+    }
+
+    private static List<PacketInMask> createPacketInMask() {
+        List<PacketInMask> masks = new ArrayList<>();
+        PacketInMaskBuilder builder;
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        builder = new PacketInMaskBuilder();
+        List<PacketInReason> packetInReasonList = new ArrayList<>();
+        packetInReasonList.add(PacketInReason.OFPRNOMATCH);
+        packetInReasonList.add(PacketInReason.OFPRACTION);
+        packetInReasonList.add(PacketInReason.OFPRINVALIDTTL);
+        builder.setMask(packetInReasonList);
+        masks.add(builder.build());
+        // OFPCR_ROLE_SLAVE
+        builder = new PacketInMaskBuilder();
+        packetInReasonList = new ArrayList<>();
+        builder.setMask(packetInReasonList);
+        masks.add(builder.build());
+        return masks;
+    }
+
+    private static List<PortStatusMask> createPortStatusMask() {
+        List<PortStatusMask> masks = new ArrayList<>();
+        PortStatusMaskBuilder builder;
+        builder = new PortStatusMaskBuilder();
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        List<PortReason> portReasonList = new ArrayList<>();
+        portReasonList.add(PortReason.OFPPRADD);
+        portReasonList.add(PortReason.OFPPRDELETE);
+        portReasonList.add(PortReason.OFPPRMODIFY);
+        builder.setMask(portReasonList);
+        masks.add(builder.build());
+        // OFPCR_ROLE_SLAVE
+        builder = new PortStatusMaskBuilder();
+        portReasonList = new ArrayList<>();
+        builder.setMask(portReasonList);
+        masks.add(builder.build());
+        return masks;
+    }
+
+    private static List<FlowRemovedMask> createFlowRemowedMask() {
+        List<FlowRemovedMask> masks = new ArrayList<>();
+        FlowRemovedMaskBuilder builder;
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        builder = new FlowRemovedMaskBuilder();
+        List<FlowRemovedReason> flowRemovedReasonList = new ArrayList<>();
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE);
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE);
+        builder.setMask(flowRemovedReasonList);
+        masks.add(builder.build());
+        // OFPCR_ROLE_SLAVE
+        builder = new FlowRemovedMaskBuilder();
+        flowRemovedReasonList = new ArrayList<>();
+        builder.setMask(flowRemovedReasonList);
+        masks.add(builder.build());
+        return masks;
+    }
+
+    @Test
+    public void testSetAsyncInputWithNullMasks() throws Exception {
+        GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setPacketInMask(null);
+        builder.setPortStatusMask(null);
+        builder.setFlowRemovedMask(null);
+        GetAsyncOutput message = builder.build();
+        GetAsyncReplyMessageFactory serializer = new GetAsyncReplyMessageFactory();
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        serializer.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 8);
+        Assert.assertTrue("Unexpected data", serializedBuffer.readableBytes() == 0);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..a6d00ad
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class GetConfigReplyMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 8;
+    private OFSerializer<GetConfigOutput> factory;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, GetConfigOutput.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        GetConfigOutputBuilder builder = new GetConfigOutputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(SwitchConfigFlag.forValue(2));
+        builder.setMissSendLen(20);
+        GetConfigOutput message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 12);
+        Assert.assertEquals("Wrong Type", message.getFlags().getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong Code", message.getMissSendLen().intValue(), serializedBuffer.readShort());
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactoryTest.java
new file mode 100644 (file)
index 0000000..271933d
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.math.BigInteger;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
+
+public class GetFeaturesOutputFactoryTest {
+    private OFSerializer<GetFeaturesOutput> factory;
+    private static final byte MESSAGE_TYPE = 6;
+    private static final byte PADDING = 2;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, GetFeaturesOutput.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setDatapathId(BigInteger.valueOf(1234L));
+        builder.setBuffers(1234L);
+        builder.setTables((short) 12);
+        builder.setAuxiliaryId((short) 12);
+        builder.setCapabilities(new Capabilities(true, false, true, false, true, false, true));
+        builder.setReserved(1234L);
+        GetFeaturesOutput message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 32);
+        Assert.assertEquals("Wrong DatapathId", message.getDatapathId().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong Buffer ID", message.getBuffers().longValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong auxiliary ID", message.getAuxiliaryId().shortValue(),
+                serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(PADDING);
+        Assert.assertEquals("Wrong Capabilities", message.getCapabilities(),
+                createCapabilities(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong reserved", message.getReserved().longValue(), serializedBuffer.readInt());
+    }
+
+    private static Capabilities createCapabilities(int input) {
+        final Boolean one = (input & (1 << 0)) > 0;
+        final Boolean two = (input & (1 << 1)) > 0;
+        final Boolean three = (input & (1 << 2)) > 0;
+        final Boolean four = (input & (1 << 3)) > 0;
+        final Boolean five = (input & (1 << 5)) > 0;
+        final Boolean six = (input & (1 << 6)) > 0;
+        final Boolean seven = (input & (1 << 8)) > 0;
+        return new Capabilities(one, four, five, seven, three, six, two);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..0db9c8d
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class HelloMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 0;
+    private OFSerializer<HelloMessage> factory;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, HelloMessage.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        HelloMessageBuilder builder = new HelloMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        HelloMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 8);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..05a106a
--- /dev/null
@@ -0,0 +1,1496 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.PortsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class MultipartReplyMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 19;
+    private static final byte PADDING = 4;
+
+    private OFSerializer<MultipartReplyMessage> factory;
+
+    @Before
+    public void startUp() throws Exception {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartReplyMessage.class));
+    }
+
+    @Test
+    public void testMultipartRequestTableFeaturesMessageFactory() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(12));
+        MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
+        MultipartReplyTableFeaturesBuilder featuresBuilder = new MultipartReplyTableFeaturesBuilder();
+        List<TableFeatures> tableFeaturesList = new ArrayList<>();
+        TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
+        tableFeaturesBuilder.setTableId((short) 8);
+        tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
+        tableFeaturesBuilder.setMetadataMatch(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 });
+        tableFeaturesBuilder.setMetadataWrite(new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 });
+        tableFeaturesBuilder.setConfig(new TableConfig(true));
+        tableFeaturesBuilder.setMaxEntries(65L);
+        List<TableFeatureProperties> properties = new ArrayList<>();
+        TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLES);
+        NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
+        List<NextTableIds> nextIds = new ArrayList<>();
+        nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build());
+        nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build());
+        nextPropBuilder.setNextTableIds(nextIds);
+        propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS);
+        nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
+        nextIds = new ArrayList<>();
+        nextPropBuilder.setNextTableIds(nextIds);
+        propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS);
+        InstructionRelatedTableFeaturePropertyBuilder insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
+        List<Instruction> insIds = new ArrayList<>();
+        InstructionBuilder insBuilder = new InstructionBuilder();
+        insBuilder.setInstructionChoice(new WriteActionsCaseBuilder().build());
+        insIds.add(insBuilder.build());
+        insBuilder = new InstructionBuilder();
+        insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
+        insIds.add(insBuilder.build());
+        insPropBuilder.setInstruction(insIds);
+        propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS);
+        insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
+        insIds = new ArrayList<>();
+        insBuilder = new InstructionBuilder();
+        insBuilder.setInstructionChoice(new WriteMetadataCaseBuilder().build());
+        insIds.add(insBuilder.build());
+        insBuilder = new InstructionBuilder();
+        insBuilder.setInstructionChoice(new ApplyActionsCaseBuilder().build());
+        insIds.add(insBuilder.build());
+        insBuilder = new InstructionBuilder();
+        insBuilder.setInstructionChoice(new MeterCaseBuilder().build());
+        insIds.add(insBuilder.build());
+        insBuilder = new InstructionBuilder();
+        insBuilder.setInstructionChoice(new ClearActionsCaseBuilder().build());
+        insIds.add(insBuilder.build());
+        insBuilder = new InstructionBuilder();
+        insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
+        insIds.add(insBuilder.build());
+        insPropBuilder.setInstruction(insIds);
+        propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
+        properties.add(propBuilder.build());
+        tableFeaturesBuilder.setTableFeatureProperties(properties);
+        tableFeaturesList.add(tableFeaturesBuilder.build());
+        tableFeaturesBuilder = new TableFeaturesBuilder();
+        tableFeaturesBuilder.setTableId((short) 8);
+        tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
+        byte[] metadataMatch = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 };
+        tableFeaturesBuilder.setMetadataMatch(metadataMatch);
+        byte[] metadataWrite = new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 };
+        tableFeaturesBuilder.setMetadataWrite(metadataWrite);
+        tableFeaturesBuilder.setConfig(new TableConfig(true));
+        tableFeaturesBuilder.setMaxEntries(67L);
+        properties = new ArrayList<>();
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS);
+        ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
+        List<Action> actions = new ArrayList<>();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setActionChoice(new OutputActionCaseBuilder().build());
+        actions.add(actionBuilder.build());
+        actBuilder.setAction(actions);
+        propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS);
+        actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
+        actions = new ArrayList<>();
+        actBuilder.setAction(actions);
+        propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS);
+        actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
+        actions = new ArrayList<>();
+        actBuilder.setAction(actions);
+        propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS);
+        actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
+        actions = new ArrayList<>();
+        actBuilder.setAction(actions);
+        propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH);
+        OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(InPhyPort.class);
+        entriesBuilder.setHasMask(false);
+        entries.add(entriesBuilder.build());
+        entriesBuilder = new MatchEntryBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(InPort.class);
+        entriesBuilder.setHasMask(false);
+        entries.add(entriesBuilder.build());
+        oxmBuilder.setMatchEntry(entries);
+        propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS);
+        oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+        entries = new ArrayList<>();
+        oxmBuilder.setMatchEntry(entries);
+        propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD);
+        oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+        entries = new ArrayList<>();
+        oxmBuilder.setMatchEntry(entries);
+        propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS);
+        oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+        entries = new ArrayList<>();
+        oxmBuilder.setMatchEntry(entries);
+        propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD);
+        oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+        entries = new ArrayList<>();
+        entriesBuilder = new MatchEntryBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(IpProto.class);
+        entriesBuilder.setHasMask(false);
+        entries.add(entriesBuilder.build());
+        entriesBuilder = new MatchEntryBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(IpEcn.class);
+        entriesBuilder.setHasMask(false);
+        entries.add(entriesBuilder.build());
+        oxmBuilder.setMatchEntry(entries);
+        propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+        properties.add(propBuilder.build());
+        propBuilder = new TableFeaturePropertiesBuilder();
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS);
+        oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+        entries = new ArrayList<>();
+        oxmBuilder.setMatchEntry(entries);
+        propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+        properties.add(propBuilder.build());
+        tableFeaturesBuilder.setTableFeatureProperties(properties);
+        tableFeaturesList.add(tableFeaturesBuilder.build());
+        featuresBuilder.setTableFeatures(tableFeaturesList);
+        caseBuilder.setMultipartReplyTableFeatures(featuresBuilder.build());
+        builder.setMultipartReplyBody(caseBuilder.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 520);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLEFEATURES.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+
+        Assert.assertEquals("Wrong length", 232, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong registry-id", 8, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(5);
+        Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG",
+                ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 32));
+        byte[] metadataMatchOutput = new byte[metadataMatch.length];
+        serializedBuffer.readBytes(metadataMatchOutput);
+        Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 },
+                metadataMatchOutput);
+        serializedBuffer.skipBytes(64 - metadataMatch.length);
+        byte[] metadataWriteOutput = new byte[metadataWrite.length];
+        serializedBuffer.readBytes(metadataWriteOutput);
+        Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 },
+                metadataWriteOutput);
+        serializedBuffer.skipBytes(64 - metadataWrite.length);
+        Assert.assertEquals("Wrong config", 1, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong max-entries", 65, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong property type", 2, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 6, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong next-registry-id", 1, serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong next-registry-id", 2, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(2);
+        Assert.assertEquals("Wrong property type", 3, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong property type", 0, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction type", 3, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction type", 1, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong property type", 1, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 24, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction type", 2, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction type", 4, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction type", 6, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction type", 5, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction type", 1, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong length", 272, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong registry-id", 8, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(5);
+        Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG",
+                ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 32));
+        metadataMatchOutput = new byte[metadataMatch.length];
+        serializedBuffer.readBytes(metadataMatchOutput);
+        serializedBuffer.skipBytes(64 - metadataMatch.length);
+        Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 },
+                metadataMatchOutput);
+        metadataWriteOutput = new byte[metadataWrite.length];
+        serializedBuffer.readBytes(metadataWriteOutput);
+        serializedBuffer.skipBytes(64 - metadataWrite.length);
+        Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 },
+                metadataWriteOutput);
+        Assert.assertEquals("Wrong config", 1, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong max-entries", 67, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong property type", 4, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 8, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong action type", 0, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 4, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property type", 5, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong property type", 6, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong property type", 7, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong property type", 8, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong match field&mask", 2, serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong match length", 4, serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong match field&mask", 0, serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong match length", 4, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong property type", 10, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong property type", 12, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong property type", 13, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong property type", 14, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong match field&mask", 20, serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong match length", 1, serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong match field&mask", 18, serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong match length", 1, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong property type", 15, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(4);
+        Assert.assertTrue("Unread data", serializedBuffer.readableBytes() == 0);
+    }
+
+    @Test
+    public void testPortDescSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(13));
+        MultipartReplyPortDescCaseBuilder portDescCase = new MultipartReplyPortDescCaseBuilder();
+        MultipartReplyPortDescBuilder portDesc = new MultipartReplyPortDescBuilder();
+        portDesc.setPorts(createPortList());
+        portDescCase.setMultipartReplyPortDesc(portDesc.build());
+        builder.setMultipartReplyBody(portDescCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTDESC.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        MultipartReplyPortDescCase body = (MultipartReplyPortDescCase) message.getMultipartReplyBody();
+        MultipartReplyPortDesc messageOutput = body.getMultipartReplyPortDesc();
+        Ports port = messageOutput.getPorts().get(0);
+        Assert.assertEquals("Wrong PortNo", port.getPortNo().intValue(), serializedBuffer.readUnsignedInt());
+        serializedBuffer.skipBytes(4);
+        byte[] address = new byte[6];
+        serializedBuffer.readBytes(address);
+        Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(),
+                new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
+        serializedBuffer.skipBytes(2);
+        byte[] name = new byte[16];
+        serializedBuffer.readBytes(name);
+        Assert.assertEquals("Wrong name", port.getName(), new String(name).trim());
+        Assert.assertEquals("Wrong config", port.getConfig(), createPortConfig(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong state", port.getState(), createPortState(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong current", port.getCurrentFeatures(), createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong advertised", port.getAdvertisedFeatures(),
+                createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong supported", port.getSupportedFeatures(),
+                createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong peer", port.getPeerFeatures(), createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong Current speed", port.getCurrSpeed().longValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong Max speed", port.getMaxSpeed().longValue(), serializedBuffer.readInt());
+    }
+
+    @Test
+    public void testMeterFeaturesSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(11));
+        MultipartReplyMeterFeaturesCaseBuilder meterFeaturesCase = new MultipartReplyMeterFeaturesCaseBuilder();
+        MultipartReplyMeterFeaturesBuilder meterFeatures = new MultipartReplyMeterFeaturesBuilder();
+        meterFeatures.setMaxMeter(1L);
+        meterFeatures.setBandTypes(new MeterBandTypeBitmap(true, false));
+        meterFeatures.setCapabilities(new MeterFlags(true, false, true, false));
+        meterFeatures.setMaxBands((short) 1);
+        meterFeatures.setMaxColor((short) 1);
+        meterFeaturesCase.setMultipartReplyMeterFeatures(meterFeatures.build());
+        builder.setMultipartReplyBody(meterFeaturesCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 30);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPMETERFEATURES.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        MultipartReplyMeterFeaturesCase body = (MultipartReplyMeterFeaturesCase) message.getMultipartReplyBody();
+        MultipartReplyMeterFeatures messageOutput = body.getMultipartReplyMeterFeatures();
+        Assert.assertEquals("Wrong max meter", messageOutput.getMaxMeter().intValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong band type", messageOutput.getBandTypes(),
+                createMeterBandTypeBitmap(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(),
+                createMeterFlags(serializedBuffer.readShort()));
+        Assert.assertEquals("Wrong max bands", messageOutput.getMaxBands().shortValue(),
+                serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong max color", messageOutput.getMaxColor().shortValue(),
+                serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(2);
+    }
+
+    @Test
+    public void testMeterConfigSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(10));
+        MultipartReplyMeterConfigCaseBuilder meterConfigCase = new MultipartReplyMeterConfigCaseBuilder();
+        MultipartReplyMeterConfigBuilder meterConfigBuilder = new MultipartReplyMeterConfigBuilder();
+        meterConfigBuilder.setMeterConfig(createMeterConfig());
+        meterConfigCase.setMultipartReplyMeterConfig(meterConfigBuilder.build());
+        builder.setMultipartReplyBody(meterConfigCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 48);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPMETERCONFIG.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        MultipartReplyMeterConfigCase body = (MultipartReplyMeterConfigCase) message.getMultipartReplyBody();
+        MultipartReplyMeterConfig messageOutput = body.getMultipartReplyMeterConfig();
+        MeterConfig meterConfig = messageOutput.getMeterConfig().get(0);
+        Assert.assertEquals("Wrong len", 32, serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", meterConfig.getFlags(), createMeterFlags(serializedBuffer.readShort()));
+        Assert.assertEquals("Wrong meterId", meterConfig.getMeterId().getValue().intValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong bands", meterConfig.getBands(), decodeBandsList(serializedBuffer));
+    }
+
+    @Test
+    public void testMeterSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(9));
+        MultipartReplyMeterCaseBuilder meterCase = new MultipartReplyMeterCaseBuilder();
+        MultipartReplyMeterBuilder meter = new MultipartReplyMeterBuilder();
+        meter.setMeterStats(createMeterStats());
+        meterCase.setMultipartReplyMeter(meter.build());
+        builder.setMultipartReplyBody(meterCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 74);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPMETER.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        MultipartReplyMeterCase body = (MultipartReplyMeterCase) message.getMultipartReplyBody();
+        MultipartReplyMeter messageOutput = body.getMultipartReplyMeter();
+        MeterStats meterStats = messageOutput.getMeterStats().get(0);
+        Assert.assertEquals("Wrong meterId", meterStats.getMeterId().getValue().intValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong len", 58, serializedBuffer.readInt());
+        serializedBuffer.skipBytes(6);
+        Assert.assertEquals("Wrong flow count", meterStats.getFlowCount().intValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong packet in count", meterStats.getPacketInCount().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong byte in count", meterStats.getByteInCount().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong duration sec", meterStats.getDurationSec().intValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong duration nsec", meterStats.getDurationNsec().intValue(), serializedBuffer.readInt());
+        MeterBandStats meterBandStats = meterStats.getMeterBandStats().get(0);
+        Assert.assertEquals("Wrong packet in count", meterBandStats.getPacketBandCount().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong byte in count", meterBandStats.getByteBandCount().longValue(),
+                serializedBuffer.readLong());
+    }
+
+    @Test
+    public void testGroupFeaturesSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(8));
+        MultipartReplyGroupFeaturesCaseBuilder featureCase = new MultipartReplyGroupFeaturesCaseBuilder();
+        MultipartReplyGroupFeaturesBuilder feature = new MultipartReplyGroupFeaturesBuilder();
+        feature.setTypes(new GroupTypes(true, false, true, false));
+        feature.setCapabilities(new GroupCapabilities(true, false, true, true));
+        List<Long> maxGroups = new ArrayList<>();
+        maxGroups.add(1L);
+        maxGroups.add(2L);
+        maxGroups.add(3L);
+        maxGroups.add(4L);
+        feature.setMaxGroups(maxGroups);
+        feature.setActionsBitmap(createActionType());
+        featureCase.setMultipartReplyGroupFeatures(feature.build());
+        builder.setMultipartReplyBody(featureCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUPFEATURES.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        MultipartReplyGroupFeaturesCase body = (MultipartReplyGroupFeaturesCase) message.getMultipartReplyBody();
+        MultipartReplyGroupFeatures messageOutput = body.getMultipartReplyGroupFeatures();
+        Assert.assertEquals("Wrong type", messageOutput.getTypes(), createGroupTypes(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(),
+                createGroupCapabilities(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(0).intValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(1).intValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(2).intValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(3).intValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(0),
+                createActionType(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(1),
+                createActionType(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(2),
+                createActionType(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(3),
+                createActionType(serializedBuffer.readInt()));
+    }
+
+    @Test
+    public void testGroupDescSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(7));
+        MultipartReplyGroupDescCaseBuilder groupCase = new MultipartReplyGroupDescCaseBuilder();
+        MultipartReplyGroupDescBuilder group = new MultipartReplyGroupDescBuilder();
+        group.setGroupDesc(createGroupDesc());
+        groupCase.setMultipartReplyGroupDesc(group.build());
+        builder.setMultipartReplyBody(groupCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 64);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUPDESC.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        MultipartReplyGroupDescCase body = (MultipartReplyGroupDescCase) message.getMultipartReplyBody();
+        MultipartReplyGroupDesc messageOutput = body.getMultipartReplyGroupDesc();
+        GroupDesc groupDesc = messageOutput.getGroupDesc().get(0);
+        Assert.assertEquals("Wrong length", 48, serializedBuffer.readShort());
+        Assert.assertEquals("Wrong type", groupDesc.getType().getIntValue(), serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(1);
+        Assert.assertEquals("Wrong group id", groupDesc.getGroupId().getValue().intValue(), serializedBuffer.readInt());
+        BucketsList bucketList = groupDesc.getBucketsList().get(0);
+        Assert.assertEquals("Wrong length", 40, serializedBuffer.readShort());
+        Assert.assertEquals("Wrong weight", bucketList.getWeight().intValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong watch port", bucketList.getWatchPort().getValue().intValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong watch group", bucketList.getWatchGroup().intValue(), serializedBuffer.readInt());
+        serializedBuffer.skipBytes(4);
+
+        Assert.assertEquals("Wrong action type", 0, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 16, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong action type", 45, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong action type", 55, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(6);
+        Assert.assertEquals("Wrong action type", 23, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 8, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong action type", 64, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(3);
+        Assert.assertTrue("Not all data were read", serializedBuffer.readableBytes() == 0);
+    }
+
+    @Test
+    public void testGroupSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(6));
+        MultipartReplyGroupCaseBuilder groupCase = new MultipartReplyGroupCaseBuilder();
+        MultipartReplyGroupBuilder group = new MultipartReplyGroupBuilder();
+        group.setGroupStats(createGroupStats());
+        groupCase.setMultipartReplyGroup(group.build());
+        builder.setMultipartReplyBody(groupCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 72);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUP.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        MultipartReplyGroupCase body = (MultipartReplyGroupCase) message.getMultipartReplyBody();
+        MultipartReplyGroup messageOutput = body.getMultipartReplyGroup();
+        GroupStats groupStats = messageOutput.getGroupStats().get(0);
+        Assert.assertEquals("Wrong length", 56, serializedBuffer.readShort());
+        serializedBuffer.skipBytes(2);
+        Assert.assertEquals("Wrong group id", groupStats.getGroupId().getValue().intValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong ref count", groupStats.getRefCount().intValue(), serializedBuffer.readInt());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong Packet count", groupStats.getPacketCount().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong Byte count", groupStats.getByteCount().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong duration sec", groupStats.getDurationSec().intValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong duration nsec", groupStats.getDurationNsec().intValue(), serializedBuffer.readInt());
+        BucketStats bucketStats = groupStats.getBucketStats().get(0);
+        Assert.assertEquals("Wrong Packet count", bucketStats.getPacketCount().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong Byte count", bucketStats.getByteCount().longValue(), serializedBuffer.readLong());
+    }
+
+    @Test
+    public void testQueueSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(5));
+        MultipartReplyQueueCaseBuilder queueCase = new MultipartReplyQueueCaseBuilder();
+        MultipartReplyQueueBuilder queue = new MultipartReplyQueueBuilder();
+        queue.setQueueStats(createQueueStats());
+        queueCase.setMultipartReplyQueue(queue.build());
+        builder.setMultipartReplyBody(queueCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPQUEUE.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        MultipartReplyQueueCase body = (MultipartReplyQueueCase) message.getMultipartReplyBody();
+        MultipartReplyQueue messageOutput = body.getMultipartReplyQueue();
+        QueueStats queueStats = messageOutput.getQueueStats().get(0);
+        Assert.assertEquals("Wrong PortNo", queueStats.getPortNo().intValue(), serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong queue id", queueStats.getQueueId().intValue(), serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong tx bytes", queueStats.getTxBytes().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx packets", queueStats.getTxPackets().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx errors", queueStats.getTxErrors().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong duration sec", queueStats.getDurationSec().intValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong duration nsec", queueStats.getDurationNsec().intValue(), serializedBuffer.readInt());
+    }
+
+    @Test
+    public void testPortStatsSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(4));
+        MultipartReplyPortStatsCaseBuilder portStatsCase = new MultipartReplyPortStatsCaseBuilder();
+        MultipartReplyPortStatsBuilder portStats = new MultipartReplyPortStatsBuilder();
+        portStats.setPortStats(createPortStats());
+        portStatsCase.setMultipartReplyPortStats(portStats.build());
+        builder.setMultipartReplyBody(portStatsCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 128);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTSTATS.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        MultipartReplyPortStatsCase body = (MultipartReplyPortStatsCase) message.getMultipartReplyBody();
+        MultipartReplyPortStats messageOutput = body.getMultipartReplyPortStats();
+        PortStats portStatsOutput = messageOutput.getPortStats().get(0);
+        Assert.assertEquals("Wrong port no", portStatsOutput.getPortNo().intValue(), serializedBuffer.readInt());
+        serializedBuffer.skipBytes(4);
+        Assert.assertEquals("Wrong rx packets", portStatsOutput.getRxPackets().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx packets", portStatsOutput.getTxPackets().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx bytes", portStatsOutput.getRxBytes().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx bytes", portStatsOutput.getTxBytes().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx dropped", portStatsOutput.getRxDropped().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx dropped", portStatsOutput.getTxDropped().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx errors", portStatsOutput.getRxErrors().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx errors", portStatsOutput.getTxErrors().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx frame err", portStatsOutput.getRxFrameErr().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx over err", portStatsOutput.getRxOverErr().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx crc err", portStatsOutput.getRxCrcErr().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong collisions", portStatsOutput.getCollisions().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong duration sec", portStatsOutput.getDurationSec().intValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong duration nsec", portStatsOutput.getDurationNsec().intValue(),
+                serializedBuffer.readInt());
+    }
+
+    @Test
+    public void testTableSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(3));
+        MultipartReplyTableCaseBuilder tableCase = new MultipartReplyTableCaseBuilder();
+        MultipartReplyTableBuilder table = new MultipartReplyTableBuilder();
+        table.setTableStats(createTableStats());
+        tableCase.setMultipartReplyTable(table.build());
+        builder.setMultipartReplyBody(tableCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 40);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLE.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        MultipartReplyTableCase body = (MultipartReplyTableCase) message.getMultipartReplyBody();
+        MultipartReplyTable messageOutput = body.getMultipartReplyTable();
+        TableStats tableStats = messageOutput.getTableStats().get(0);
+        Assert.assertEquals("Wrong tableId", tableStats.getTableId().shortValue(), serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(3);
+        Assert.assertEquals("Wrong active count", tableStats.getActiveCount().longValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong lookup count", tableStats.getLookupCount().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong matched count", tableStats.getMatchedCount().longValue(),
+                serializedBuffer.readLong());
+    }
+
+    @Test
+    public void testAggregateSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(2));
+        MultipartReplyAggregateCaseBuilder aggregateCase = new MultipartReplyAggregateCaseBuilder();
+        MultipartReplyAggregateBuilder aggregate = new MultipartReplyAggregateBuilder();
+        aggregate.setPacketCount(BigInteger.valueOf(1L));
+        aggregate.setByteCount(BigInteger.valueOf(1L));
+        aggregate.setFlowCount(1L);
+        aggregateCase.setMultipartReplyAggregate(aggregate.build());
+        builder.setMultipartReplyBody(aggregateCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 40);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPAGGREGATE.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        MultipartReplyAggregateCase body = (MultipartReplyAggregateCase) message.getMultipartReplyBody();
+        MultipartReplyAggregate messageOutput = body.getMultipartReplyAggregate();
+        Assert.assertEquals("Wrong Packet count", messageOutput.getPacketCount().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong Byte count", messageOutput.getByteCount().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong Flow count", messageOutput.getFlowCount().longValue(), serializedBuffer.readInt());
+        serializedBuffer.skipBytes(4);
+    }
+
+    @Test
+    public void testFlowSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(1));
+        MultipartReplyFlowCaseBuilder flowCase = new MultipartReplyFlowCaseBuilder();
+        MultipartReplyFlowBuilder flow = new MultipartReplyFlowBuilder();
+        flow.setFlowStats(createFlowStats());
+        flowCase.setMultipartReplyFlow(flow.build());
+        builder.setMultipartReplyBody(flowCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 192);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPFLOW.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        testFlowBody(message.getMultipartReplyBody(), serializedBuffer);
+    }
+
+    @Test
+    public void testDescSerialize() throws Exception {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(0));
+        MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder();
+        MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder();
+        desc.setMfrDesc("Test");
+        desc.setHwDesc("Test");
+        desc.setSwDesc("Test");
+        desc.setSerialNum("12345");
+        desc.setDpDesc("Test");
+        descCase.setMultipartReplyDesc(desc.build());
+        builder.setMultipartReplyBody(descCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 1072);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPDESC.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        serializedBuffer.skipBytes(PADDING);
+        Assert.assertEquals("Wrong desc body", message.getMultipartReplyBody(), decodeDescBody(serializedBuffer));
+    }
+
+    private static void testFlowBody(MultipartReplyBody body, ByteBuf output) {
+        MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body;
+        MultipartReplyFlow flow = flowCase.getMultipartReplyFlow();
+        FlowStats flowStats = flow.getFlowStats().get(0);
+        Assert.assertEquals("Wrong length", 176, output.readShort());
+        Assert.assertEquals("Wrong Table ID", flowStats.getTableId().intValue(), output.readUnsignedByte());
+        output.skipBytes(1);
+        Assert.assertEquals("Wrong duration sec", flowStats.getDurationSec().intValue(), output.readInt());
+        Assert.assertEquals("Wrong duration nsec", flowStats.getDurationNsec().intValue(), output.readInt());
+        Assert.assertEquals("Wrong priority", flowStats.getPriority().intValue(), output.readShort());
+        Assert.assertEquals("Wrong idle timeout", flowStats.getIdleTimeout().intValue(), output.readShort());
+        Assert.assertEquals("Wrong hard timeout", flowStats.getHardTimeout().intValue(), output.readShort());
+        output.skipBytes(6);
+        Assert.assertEquals("Wrong cookie", flowStats.getCookie().longValue(), output.readLong());
+        Assert.assertEquals("Wrong Packet count", flowStats.getPacketCount().longValue(), output.readLong());
+        Assert.assertEquals("Wrong Byte count", flowStats.getByteCount().longValue(), output.readLong());
+        Assert.assertEquals("Wrong match type", 1, output.readUnsignedShort());
+        output.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        Assert.assertEquals("Wrong oxm class", 0x8000, output.readUnsignedShort());
+        short fieldAndMask = output.readUnsignedByte();
+        Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
+        Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);
+        output.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+        Assert.assertEquals("Wrong oxm value", 42, output.readUnsignedInt());
+        Assert.assertEquals("Wrong oxm class", 0x8000, output.readUnsignedShort());
+        fieldAndMask = output.readUnsignedByte();
+        Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
+        Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);
+        output.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+        Assert.assertEquals("Wrong oxm value", 4, output.readUnsignedByte());
+        output.skipBytes(7);
+        Assert.assertEquals("Wrong instruction type", 1, output.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction table-id", 5, output.readUnsignedByte());
+        output.skipBytes(3);
+        Assert.assertEquals("Wrong instruction type", 2, output.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 24, output.readUnsignedShort());
+        output.skipBytes(4);
+        byte[] actual = new byte[8];
+        output.readBytes(actual);
+        Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07",
+                ByteBufUtils.bytesToHexString(actual));
+        actual = new byte[8];
+        output.readBytes(actual);
+        Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00",
+                ByteBufUtils.bytesToHexString(actual));
+        Assert.assertEquals("Wrong instruction type", 5, output.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
+        output.skipBytes(4);
+        Assert.assertEquals("Wrong instruction type", 6, output.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction meter-id", 42, output.readUnsignedInt());
+        Assert.assertEquals("Wrong instruction type", 3, output.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 32, output.readUnsignedShort());
+        output.skipBytes(4);
+        Assert.assertEquals("Wrong action type", 0, output.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 16, output.readUnsignedShort());
+        Assert.assertEquals("Wrong action type", 45, output.readUnsignedInt());
+        Assert.assertEquals("Wrong action type", 55, output.readUnsignedShort());
+        output.skipBytes(6);
+        Assert.assertEquals("Wrong action type", 23, output.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
+        Assert.assertEquals("Wrong action type", 64, output.readUnsignedByte());
+        output.skipBytes(3);
+        Assert.assertEquals("Wrong instruction type", 4, output.readUnsignedShort());
+        Assert.assertEquals("Wrong instruction length", 24, output.readUnsignedShort());
+        output.skipBytes(4);
+        Assert.assertEquals("Wrong action type", 17, output.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
+        Assert.assertEquals("Wrong action ethertype", 14, output.readUnsignedShort());
+        output.skipBytes(2);
+        Assert.assertEquals("Wrong action type", 27, output.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
+        output.skipBytes(4);
+        Assert.assertTrue("Not all data were read", output.readableBytes() == 0);
+    }
+
+    private static List<Ports> createPortList() {
+        PortsBuilder builder = new PortsBuilder();
+        builder.setPortNo(1L);
+        builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
+        builder.setName("Port name");
+        builder.setConfig(new PortConfig(true, false, true, false));
+        builder.setState(new PortState(true, false, true));
+        builder.setCurrentFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false,
+                true, false, true, false, true, false));
+        builder.setAdvertisedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false,
+                true, false, true, false, true, false));
+        builder.setSupportedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false,
+                true, false, true, false, true, false));
+        builder.setPeerFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true,
+                false, true, false, true, false));
+        builder.setCurrSpeed(1234L);
+        builder.setMaxSpeed(1234L);
+        List<Ports> list = new ArrayList<>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static PortConfig createPortConfig(long input) {
+        final Boolean _portDown = ((input) & (1 << 0)) > 0;
+        final Boolean _noRecv = ((input) & (1 << 2)) > 0;
+        final Boolean _noFwd = ((input) & (1 << 5)) > 0;
+        final Boolean _noPacketIn = ((input) & (1 << 6)) > 0;
+        return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);
+    }
+
+    private static PortFeatures createPortFeatures(long input) {
+        final Boolean _10mbHd = ((input) & (1 << 0)) > 0;
+        final Boolean _10mbFd = ((input) & (1 << 1)) > 0;
+        final Boolean _100mbHd = ((input) & (1 << 2)) > 0;
+        final Boolean _100mbFd = ((input) & (1 << 3)) > 0;
+        final Boolean _1gbHd = ((input) & (1 << 4)) > 0;
+        final Boolean _1gbFd = ((input) & (1 << 5)) > 0;
+        final Boolean _10gbFd = ((input) & (1 << 6)) > 0;
+        final Boolean _40gbFd = ((input) & (1 << 7)) > 0;
+        final Boolean _100gbFd = ((input) & (1 << 8)) > 0;
+        final Boolean _1tbFd = ((input) & (1 << 9)) > 0;
+        final Boolean _other = ((input) & (1 << 10)) > 0;
+        final Boolean _copper = ((input) & (1 << 11)) > 0;
+        final Boolean _fiber = ((input) & (1 << 12)) > 0;
+        final Boolean _autoneg = ((input) & (1 << 13)) > 0;
+        final Boolean _pause = ((input) & (1 << 14)) > 0;
+        final Boolean _pauseAsym = ((input) & (1 << 15)) > 0;
+        return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _1tbFd,
+                _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym);
+    }
+
+    private static PortState createPortState(long input) {
+        final Boolean one = ((input) & (1 << 0)) > 0;
+        final Boolean two = ((input) & (1 << 1)) > 0;
+        final Boolean three = ((input) & (1 << 2)) > 0;
+        return new PortState(two, one, three);
+    }
+
+    private static List<Bands> decodeBandsList(ByteBuf input) {
+        List<Bands> bandsList = new ArrayList<>();
+        BandsBuilder bandsBuilder = new BandsBuilder();
+        MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
+        MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
+        dropBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
+        input.skipBytes(Short.SIZE / Byte.SIZE);
+        dropBand.setRate(input.readUnsignedInt());
+        dropBand.setBurstSize(input.readUnsignedInt());
+        dropCaseBuilder.setMeterBandDrop(dropBand.build());
+        bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
+        MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
+        MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
+        dscpRemarkBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
+        input.skipBytes(Short.SIZE / Byte.SIZE);
+        dscpRemarkBand.setRate(input.readUnsignedInt());
+        dscpRemarkBand.setBurstSize(input.readUnsignedInt());
+        dscpRemarkBand.setPrecLevel((short) 3);
+        dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
+        bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
+        return bandsList;
+    }
+
+    private static List<MeterConfig> createMeterConfig() {
+        MeterConfigBuilder builder = new MeterConfigBuilder();
+        builder.setFlags(new MeterFlags(true, false, true, false));
+        builder.setMeterId(new MeterId(1L));
+        builder.setBands(createBandsList());
+        List<MeterConfig> list = new ArrayList<>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static MeterBandTypeBitmap createMeterBandTypeBitmap(int input) {
+        final Boolean one = ((input) & (1 << 0)) > 0;
+        final Boolean two = ((input) & (1 << 1)) > 0;
+        return new MeterBandTypeBitmap(one, two);
+    }
+
+    private static List<Bands> createBandsList() {
+        List<Bands> bandsList = new ArrayList<>();
+        BandsBuilder bandsBuilder = new BandsBuilder();
+        MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
+        MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
+        dropBand.setType(MeterBandType.OFPMBTDROP);
+        dropBand.setRate(1L);
+        dropBand.setBurstSize(2L);
+        dropCaseBuilder.setMeterBandDrop(dropBand.build());
+        bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
+        MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
+        MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
+        dscpRemarkBand.setType(MeterBandType.OFPMBTDSCPREMARK);
+        dscpRemarkBand.setRate(1L);
+        dscpRemarkBand.setBurstSize(2L);
+        dscpRemarkBand.setPrecLevel((short) 3);
+        dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
+        bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
+        return bandsList;
+    }
+
+    private static MeterFlags createMeterFlags(int input) {
+        final Boolean one = ((input) & (1 << 0)) > 0;
+        final Boolean two = ((input) & (1 << 1)) > 0;
+        final Boolean three = ((input) & (1 << 2)) > 0;
+        final Boolean four = ((input) & (1 << 3)) > 0;
+        return new MeterFlags(three, one, two, four);
+    }
+
+    private static List<MeterStats> createMeterStats() {
+        MeterStatsBuilder builder = new MeterStatsBuilder();
+        builder.setMeterId(new MeterId(1L));
+        builder.setFlowCount(1L);
+        builder.setPacketInCount(BigInteger.valueOf(1L));
+        builder.setByteInCount(BigInteger.valueOf(1L));
+        builder.setDurationSec(1L);
+        builder.setDurationNsec(1L);
+        builder.setMeterBandStats(createMeterBandStats());
+        List<MeterStats> list = new ArrayList<>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<MeterBandStats> createMeterBandStats() {
+        MeterBandStatsBuilder builder = new MeterBandStatsBuilder();
+        builder.setPacketBandCount(BigInteger.valueOf(1L));
+        builder.setByteBandCount(BigInteger.valueOf(1L));
+        List<MeterBandStats> list = new ArrayList<>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static ActionType createActionType(int input) {
+        final Boolean one = ((input) & (1 << 0)) > 0;
+        final Boolean two = ((input) & (1 << 1)) > 0;
+        final Boolean three = ((input) & (1 << 2)) > 0;
+        final Boolean four = ((input) & (1 << 3)) > 0;
+        final Boolean five = ((input) & (1 << 4)) > 0;
+        final Boolean six = ((input) & (1 << 5)) > 0;
+        final Boolean seven = ((input) & (1 << 6)) > 0;
+        final Boolean eight = ((input) & (1 << 7)) > 0;
+        final Boolean nine = ((input) & (1 << 8)) > 0;
+        final Boolean ten = ((input) & (1 << 9)) > 0;
+        final Boolean eleven = ((input) & (1 << 10)) > 0;
+        final Boolean twelve = ((input) & (1 << 11)) > 0;
+        final Boolean thirteen = ((input) & (1 << 12)) > 0;
+        final Boolean fourteen = ((input) & (1 << 13)) > 0;
+        final Boolean fifthteen = ((input) & (1 << 14)) > 0;
+        final Boolean sixteen = ((input) & (1 << 15)) > 0;
+        final Boolean seventeen = ((input) & (1 << 16)) > 0;
+        return new ActionType(three, two, five, thirteen, seventeen, eleven, one, nine, sixteen, seven, eight,
+                fifthteen, six, fourteen, four, twelve, ten);
+    }
+
+    private static GroupCapabilities createGroupCapabilities(int input) {
+        final Boolean one = ((input) & (1 << 0)) > 0;
+        final Boolean two = ((input) & (1 << 1)) > 0;
+        final Boolean three = ((input) & (1 << 2)) > 0;
+        final Boolean four = ((input) & (1 << 3)) > 0;
+        return new GroupCapabilities(three, four, two, one);
+    }
+
+    private static GroupTypes createGroupTypes(int input) {
+        final Boolean one = ((input) & (1 << 0)) > 0;
+        final Boolean two = ((input) & (1 << 1)) > 0;
+        final Boolean three = ((input) & (1 << 2)) > 0;
+        final Boolean four = ((input) & (1 << 3)) > 0;
+        return new GroupTypes(one, four, three, two);
+    }
+
+    private static List<ActionType> createActionType() {
+        ActionType actionType1 = new ActionType(true, false, true, false, true, false, true, false, true, false, true,
+                false, true, false, true, false, true);
+        ActionType actionType2 = new ActionType(true, false, false, false, true, false, true, false, true, false, true,
+                false, true, false, true, true, true);
+        ActionType actionType3 = new ActionType(true, false, true, false, true, false, true, false, true, false, true,
+                false, true, false, true, false, true);
+        ActionType actionType4 = new ActionType(true, false, true, false, true, false, true, false, true, false, true,
+                false, true, false, true, false, true);
+        List<ActionType> list = new ArrayList<>();
+        list.add(actionType1);
+        list.add(actionType2);
+        list.add(actionType3);
+        list.add(actionType4);
+        return list;
+
+    }
+
+    private static List<GroupDesc> createGroupDesc() {
+        GroupDescBuilder builder = new GroupDescBuilder();
+        builder.setType(GroupType.forValue(1));
+        builder.setGroupId(new GroupId(1L));
+        builder.setBucketsList(createBucketsList());
+        List<GroupDesc> list = new ArrayList<>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<GroupStats> createGroupStats() {
+        GroupStatsBuilder builder = new GroupStatsBuilder();
+        builder.setGroupId(new GroupId(1L));
+        builder.setRefCount(1L);
+        builder.setPacketCount(BigInteger.valueOf(1L));
+        builder.setByteCount(BigInteger.valueOf(1L));
+        builder.setDurationSec(1L);
+        builder.setDurationNsec(1L);
+        builder.setBucketStats(createBucketStats());
+        List<GroupStats> list = new ArrayList<>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<BucketsList> createBucketsList() {
+        BucketsListBuilder builder = new BucketsListBuilder();
+        builder.setWeight(1);
+        builder.setWatchPort(new PortNumber(1L));
+        builder.setWatchGroup(1L);
+        builder.setAction(createActionList());
+        List<BucketsList> list = new ArrayList<>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<Action> createActionList() {
+        List<Action> actions = new ArrayList<>();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
+        OutputActionBuilder outputBuilder = new OutputActionBuilder();
+        outputBuilder.setPort(new PortNumber(45L));
+        outputBuilder.setMaxLength(55);
+        caseBuilder.setOutputAction(outputBuilder.build());
+        actionBuilder.setActionChoice(caseBuilder.build());
+        actions.add(actionBuilder.build());
+        actionBuilder = new ActionBuilder();
+        SetNwTtlCaseBuilder ttlCaseBuilder = new SetNwTtlCaseBuilder();
+        SetNwTtlActionBuilder ttlActionBuilder = new SetNwTtlActionBuilder();
+        ttlActionBuilder.setNwTtl((short) 64);
+        ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build());
+        actionBuilder.setActionChoice(ttlCaseBuilder.build());
+        actions.add(actionBuilder.build());
+        return actions;
+    }
+
+    private static List<BucketStats> createBucketStats() {
+        BucketStatsBuilder builder = new BucketStatsBuilder();
+        builder.setPacketCount(BigInteger.valueOf(1L));
+        builder.setByteCount(BigInteger.valueOf(1L));
+        List<BucketStats> list = new ArrayList<>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<QueueStats> createQueueStats() {
+        QueueStatsBuilder builder = new QueueStatsBuilder();
+        builder.setPortNo(1L);
+        builder.setQueueId(1L);
+        builder.setTxBytes(BigInteger.valueOf(1L));
+        builder.setTxPackets(BigInteger.valueOf(1L));
+        builder.setTxErrors(BigInteger.valueOf(1L));
+        builder.setDurationSec(1L);
+        builder.setDurationNsec(1L);
+        List<QueueStats> list = new ArrayList<>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<PortStats> createPortStats() {
+        PortStatsBuilder builder = new PortStatsBuilder();
+        builder.setPortNo(1L);
+        builder.setRxPackets(BigInteger.valueOf(1L));
+        builder.setTxPackets(BigInteger.valueOf(1L));
+        builder.setRxBytes(BigInteger.valueOf(1L));
+        builder.setTxBytes(BigInteger.valueOf(1L));
+        builder.setRxDropped(BigInteger.valueOf(1L));
+        builder.setTxDropped(BigInteger.valueOf(1L));
+        builder.setRxErrors(BigInteger.valueOf(1L));
+        builder.setTxErrors(BigInteger.valueOf(1L));
+        builder.setRxFrameErr(BigInteger.valueOf(1L));
+        builder.setRxOverErr(BigInteger.valueOf(1L));
+        builder.setRxCrcErr(BigInteger.valueOf(1L));
+        builder.setCollisions(BigInteger.valueOf(1L));
+        builder.setDurationSec(1L);
+        builder.setDurationNsec(1L);
+        List<PortStats> list = new ArrayList<PortStats>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<TableStats> createTableStats() {
+        TableStatsBuilder builder = new TableStatsBuilder();
+        builder.setTableId((short) 1);
+        builder.setActiveCount(1L);
+        builder.setLookupCount(BigInteger.valueOf(1L));
+        builder.setMatchedCount(BigInteger.valueOf(1L));
+        List<TableStats> list = new ArrayList<TableStats>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<FlowStats> createFlowStats() {
+        FlowStatsBuilder builder = new FlowStatsBuilder();
+        builder.setTableId((short) 1);
+        builder.setDurationSec(1L);
+        builder.setDurationNsec(1L);
+        builder.setPriority(1);
+        builder.setIdleTimeout(1);
+        builder.setHardTimeout(1);
+        builder.setCookie(BigInteger.valueOf(1234L));
+        builder.setPacketCount(BigInteger.valueOf(1234L));
+        builder.setByteCount(BigInteger.valueOf(1234L));
+        MatchBuilder matchBuilder = new MatchBuilder();
+        matchBuilder.setType(OxmMatchType.class);
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(InPhyPort.class);
+        entriesBuilder.setHasMask(false);
+        InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
+        InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
+        inPhyPortBuilder.setPortNumber(new PortNumber(42L));
+        inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
+        entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
+        entries.add(entriesBuilder.build());
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(IpEcn.class);
+        entriesBuilder.setHasMask(false);
+        IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
+        IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
+        ipEcnBuilder.setEcn((short) 4);
+        ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
+        entries.add(entriesBuilder.build());
+        matchBuilder.setMatchEntry(entries);
+        builder.setMatch(matchBuilder.build());
+        List<Instruction> instructions = new ArrayList<>();
+        // Goto_table instruction
+        InstructionBuilder builderInstruction = new InstructionBuilder();
+        GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();
+        GotoTableBuilder instructionBuilder = new GotoTableBuilder();
+        instructionBuilder.setTableId((short) 5);
+        gotoCaseBuilder.setGotoTable(instructionBuilder.build());
+        builderInstruction.setInstructionChoice(gotoCaseBuilder.build());
+        instructions.add(builderInstruction.build());
+        // Write_metadata instruction
+        builderInstruction = new InstructionBuilder();
+        WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
+        WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
+        metadataBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07"));
+        metadataBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00"));
+        metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
+        builderInstruction.setInstructionChoice(metadataCaseBuilder.build());
+        instructions.add(builderInstruction.build());
+        // Clear_actions instruction
+        builderInstruction = new InstructionBuilder();
+        builderInstruction.setInstructionChoice(new ClearActionsCaseBuilder().build());
+        instructions.add(builderInstruction.build());
+        // Meter instruction
+        builderInstruction = new InstructionBuilder();
+        MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
+        MeterBuilder meterBuilder = new MeterBuilder();
+        meterBuilder.setMeterId(42L);
+        meterCaseBuilder.setMeter(meterBuilder.build());
+        builderInstruction.setInstructionChoice(meterCaseBuilder.build());
+        instructions.add(builderInstruction.build());
+        // Write_actions instruction
+        builderInstruction = new InstructionBuilder();
+        WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
+        WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
+        List<Action> actions = new ArrayList<>();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
+        OutputActionBuilder outputBuilder = new OutputActionBuilder();
+        outputBuilder.setPort(new PortNumber(45L));
+        outputBuilder.setMaxLength(55);
+        caseBuilder.setOutputAction(outputBuilder.build());
+        actionBuilder.setActionChoice(caseBuilder.build());
+        actions.add(actionBuilder.build());
+        actionBuilder = new ActionBuilder();
+        SetNwTtlCaseBuilder ttlCaseBuilder = new SetNwTtlCaseBuilder();
+        SetNwTtlActionBuilder ttlActionBuilder = new SetNwTtlActionBuilder();
+        ttlActionBuilder.setNwTtl((short) 64);
+        ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build());
+        actionBuilder.setActionChoice(ttlCaseBuilder.build());
+        actions.add(actionBuilder.build());
+        writeActionsBuilder.setAction(actions);
+        writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
+        builderInstruction.setInstructionChoice(writeActionsCaseBuilder.build());
+        instructions.add(builderInstruction.build());
+        // Apply_actions instruction
+        builderInstruction = new InstructionBuilder();
+        ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
+        ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
+        actions = new ArrayList<>();
+        actionBuilder = new ActionBuilder();
+        PushVlanCaseBuilder vlanCaseBuilder = new PushVlanCaseBuilder();
+        PushVlanActionBuilder vlanBuilder = new PushVlanActionBuilder();
+        vlanBuilder.setEthertype(new EtherType(new EtherType(14)));
+        vlanCaseBuilder.setPushVlanAction(vlanBuilder.build());
+        actionBuilder.setActionChoice(vlanCaseBuilder.build());
+        actions.add(actionBuilder.build());
+        actionBuilder = new ActionBuilder();
+        actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
+        actions.add(actionBuilder.build());
+        applyActionsBuilder.setAction(actions);
+        applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
+        builderInstruction.setInstructionChoice(applyActionsCaseBuilder.build());
+        instructions.add(builderInstruction.build());
+        builder.setInstruction(instructions);
+        List<FlowStats> list = new ArrayList<FlowStats>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static MultipartRequestFlags createMultipartRequestFlags(int input) {
+        final Boolean one = ((input) & (1 << 0)) > 0;
+        return new MultipartRequestFlags(one);
+    }
+
+    private static MultipartReplyDescCase decodeDescBody(ByteBuf output) {
+        MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder();
+        MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder();
+        byte[] mfrDesc = new byte[256];
+        output.readBytes(mfrDesc);
+        desc.setMfrDesc(new String(mfrDesc).trim());
+        byte[] hwDesc = new byte[256];
+        output.readBytes(hwDesc);
+        desc.setHwDesc(new String(hwDesc).trim());
+        byte[] swDesc = new byte[256];
+        output.readBytes(swDesc);
+        desc.setSwDesc(new String(swDesc).trim());
+        byte[] serialNumber = new byte[32];
+        output.readBytes(serialNumber);
+        desc.setSerialNum(new String(serialNumber).trim());
+        byte[] dpDesc = new byte[256];
+        output.readBytes(dpDesc);
+        desc.setDpDesc(new String(dpDesc).trim());
+        descCase.setMultipartReplyDesc(desc.build());
+        return descCase.build();
+    }
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..7ec4e44
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10BarrierReplyMessageFactoryTest {
+    private OFSerializer<BarrierOutput> factory;
+    private static final byte MESSAGE_TYPE = 19;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierOutput.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        BarrierOutputBuilder builder = new BarrierOutputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        BarrierOutput message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 8);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..dc2758b
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10FeaturesReplyMessageFactoryTest {
+    private OFSerializer<GetFeaturesOutput> factory;
+    private static final byte MESSAGE_TYPE = 6;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, GetFeaturesOutput.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setDatapathId(BigInteger.valueOf(1L));
+        builder.setBuffers(1L);
+        builder.setTables((short) 1);
+        builder.setCapabilitiesV10(new CapabilitiesV10(true, false, true, false, true, false, true, false));
+        builder.setActionsV10(
+                new ActionTypeV10(true, false, true, false, true, false, true, false, true, false, true, false, true));
+        builder.setPhyPort(createPorts());
+        GetFeaturesOutput message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 80);
+        Assert.assertEquals("Wrong datapath id", message.getDatapathId().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong n buffers", message.getBuffers().longValue(), serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong n tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(3);
+        Assert.assertEquals("Wrong capabilities", message.getCapabilitiesV10(),
+                createCapabilities(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong actions", message.getActionsV10(), createActionsV10(serializedBuffer.readInt()));
+        PhyPort port = message.getPhyPort().get(0);
+        Assert.assertEquals("Wrong port No", port.getPortNo().intValue(), serializedBuffer.readShort());
+        byte[] address = new byte[6];
+        serializedBuffer.readBytes(address);
+        Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(),
+                new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
+        byte[] name = new byte[16];
+        serializedBuffer.readBytes(name);
+        Assert.assertEquals("Wrong name", port.getName(), new String(name).trim());
+        Assert.assertEquals("Wrong config", port.getConfigV10(), createPortConfig(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong state", port.getStateV10(), createPortState(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong current", port.getCurrentFeaturesV10(),
+                createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong advertised", port.getAdvertisedFeaturesV10(),
+                createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong supported", port.getSupportedFeaturesV10(),
+                createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong peer", port.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
+
+    }
+
+    private static List<PhyPort> createPorts() {
+        List<PhyPort> ports = new ArrayList<>();
+        PhyPortBuilder builder = new PhyPortBuilder();
+        builder.setPortNo(1L);
+        builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
+        builder.setName("Port name");
+        builder.setConfigV10(new PortConfigV10(true, false, true, false, true, false, true));
+        builder.setStateV10(new PortStateV10(true, false, true, false, true, false, true, false));
+        builder.setCurrentFeaturesV10(
+                new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
+        builder.setAdvertisedFeaturesV10(
+                new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
+        builder.setSupportedFeaturesV10(
+                new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
+        builder.setPeerFeaturesV10(
+                new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
+        ports.add(builder.build());
+        return ports;
+    }
+
+    private static PortConfigV10 createPortConfig(long input) {
+        final Boolean _portDown = ((input) & (1 << 0)) > 0;
+        final Boolean _noStp = ((input) & (1 << 1)) > 0;
+        final Boolean _noRecv = ((input) & (1 << 2)) > 0;
+        final Boolean _noRecvStp = ((input) & (1 << 3)) > 0;
+        final Boolean _noFlood = ((input) & (1 << 4)) > 0;
+        final Boolean _noFwd = ((input) & (1 << 5)) > 0;
+        final Boolean _noPacketIn = ((input) & (1 << 6)) > 0;
+        return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown);
+    }
+
+    private static PortFeaturesV10 createPortFeatures(long input) {
+        final Boolean _10mbHd = ((input) & (1 << 0)) > 0;
+        final Boolean _10mbFd = ((input) & (1 << 1)) > 0;
+        final Boolean _100mbHd = ((input) & (1 << 2)) > 0;
+        final Boolean _100mbFd = ((input) & (1 << 3)) > 0;
+        final Boolean _1gbHd = ((input) & (1 << 4)) > 0;
+        final Boolean _1gbFd = ((input) & (1 << 5)) > 0;
+        final Boolean _10gbFd = ((input) & (1 << 6)) > 0;
+        final Boolean _copper = ((input) & (1 << 7)) > 0;
+        final Boolean _fiber = ((input) & (1 << 8)) > 0;
+        final Boolean _autoneg = ((input) & (1 << 9)) > 0;
+        final Boolean _pause = ((input) & (1 << 10)) > 0;
+        final Boolean _pauseAsym = ((input) & (1 << 11)) > 0;
+        return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _autoneg, _copper,
+                _fiber, _pause, _pauseAsym);
+    }
+
+    private static PortStateV10 createPortState(long input) {
+        final Boolean _linkDown = ((input) & (1 << 0)) > 0;
+        final Boolean _blocked = ((input) & (1 << 1)) > 0;
+        final Boolean _live = ((input) & (1 << 2)) > 0;
+        final Boolean _stpListen = ((input) & (1 << 3)) > 0;
+        final Boolean _stpLearn = ((input) & (1 << 4)) > 0;
+        final Boolean _stpForward = ((input) & (1 << 5)) > 0;
+        final Boolean _stpBlock = ((input) & (1 << 6)) > 0;
+        final Boolean _stpMask = ((input) & (1 << 7)) > 0;
+        return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask);
+    }
+
+    private static CapabilitiesV10 createCapabilities(long input) {
+        Boolean _oFPCFLOWSTATS = ((input) & (1 << 0)) > 0;
+        Boolean _oFPCTABLESTATS = ((input) & (1 << 1)) > 0;
+        Boolean _oFPCPORTSTATS = ((input) & (1 << 2)) > 0;
+        Boolean _oFPCSTP = ((input) & (1 << 3)) > 0;
+        Boolean _oFPCRESERVED = ((input) & (1 << 4)) > 0;
+        Boolean _oFPCIPREASM = ((input) & (1 << 5)) > 0;
+        Boolean _oFPCQUEUESTATS = ((input) & (1 << 6)) > 0;
+        Boolean _oFPCARPMATCHIP = ((input) & (1 << 7)) > 0;
+        return new CapabilitiesV10(_oFPCARPMATCHIP, _oFPCFLOWSTATS, _oFPCIPREASM, _oFPCPORTSTATS, _oFPCQUEUESTATS,
+                _oFPCRESERVED, _oFPCSTP, _oFPCTABLESTATS);
+    }
+
+    private static ActionTypeV10 createActionsV10(long input) {
+        Boolean _oFPATOUTPUT = ((input) & (1 << 0)) > 0;
+        Boolean _oFPATSETVLANVID = ((input) & (1 << 1)) > 0;
+        Boolean _oFPATSETVLANPCP = ((input) & (1 << 2)) > 0;
+        Boolean _oFPATSTRIPVLAN = ((input) & (1 << 3)) > 0;
+        Boolean _oFPATSETDLSRC = ((input) & (1 << 4)) > 0;
+        Boolean _oFPATSETDLDST = ((input) & (1 << 5)) > 0;
+        Boolean _oFPATSETNWSRC = ((input) & (1 << 6)) > 0;
+        Boolean _oFPATSETNWDST = ((input) & (1 << 7)) > 0;
+        Boolean _oFPATSETNWTOS = ((input) & (1 << 8)) > 0;
+        Boolean _oFPATSETTPSRC = ((input) & (1 << 9)) > 0;
+        Boolean _oFPATSETTPDST = ((input) & (1 << 10)) > 0;
+        Boolean _oFPATENQUEUE = ((input) & (1 << 11)) > 0;
+        Boolean _oFPATVENDOR = ((input) & (1 << 12)) > 0;
+        return new ActionTypeV10(_oFPATENQUEUE, _oFPATOUTPUT, _oFPATSETDLDST, _oFPATSETDLSRC, _oFPATSETNWDST,
+                _oFPATSETNWSRC, _oFPATSETNWTOS, _oFPATSETTPDST, _oFPATSETTPSRC, _oFPATSETVLANPCP, _oFPATSETVLANVID,
+                _oFPATSTRIPVLAN, _oFPATVENDOR);
+
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..fdd24fe
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.math.BigInteger;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10FlowRemovedMessageFactoryTest {
+    private OFSerializer<FlowRemovedMessage> factory;
+    private static final byte MESSAGE_TYPE = 11;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, FlowRemovedMessage.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        MatchV10Builder matchBuilder = new MatchV10Builder();
+        matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
+        matchBuilder.setNwSrcMask((short) 0);
+        matchBuilder.setNwDstMask((short) 0);
+        matchBuilder.setInPort(58);
+        matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
+        matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff"));
+        matchBuilder.setDlVlan(18);
+        matchBuilder.setDlVlanPcp((short) 5);
+        matchBuilder.setDlType(42);
+        matchBuilder.setNwTos((short) 4);
+        matchBuilder.setNwProto((short) 7);
+        matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));
+        matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));
+        matchBuilder.setTpSrc(6653);
+        matchBuilder.setTpDst(6633);
+        builder.setMatchV10(matchBuilder.build());
+        byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x01, 0x01, 0x04, 0x01 };
+        builder.setCookie(new BigInteger(1, cookie));
+        builder.setPriority(1);
+        builder.setReason(FlowRemovedReason.forValue(1));
+        builder.setDurationSec(1L);
+        builder.setDurationNsec(1L);
+        builder.setIdleTimeout(12);
+        builder.setPacketCount(BigInteger.valueOf(1L));
+        builder.setByteCount(BigInteger.valueOf(2L));
+        FlowRemovedMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 88);
+        Assert.assertEquals("Wrong wildcards", 3678463, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong inPort", 58, serializedBuffer.readUnsignedShort());
+        byte[] dlSrc = new byte[6];
+        serializedBuffer.readBytes(dlSrc);
+        Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
+        byte[] dlDst = new byte[6];
+        serializedBuffer.readBytes(dlDst);
+        Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst));
+        Assert.assertEquals("Wrong dlVlan", 18, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong dlVlanPcp", 5, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(1);
+        Assert.assertEquals("Wrong dlType", 42, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong nwTos", 4, serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong nwProto", 7, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(2);
+        Assert.assertEquals("Wrong nwSrc", 134744072, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong nwDst", 269488144, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong tpSrc", 6653, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong tpDst", 6633, serializedBuffer.readUnsignedShort());
+        byte[] cookieRead = new byte[8];
+        serializedBuffer.readBytes(cookieRead);
+        Assert.assertArrayEquals("Wrong cookie", cookie, cookieRead);
+        Assert.assertEquals("Wrong priority", 1, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong reason", 1, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(1);
+        Assert.assertEquals("Wrong duration", 1L, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong duration nsec", 1L, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong idle timeout", 12, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(2);
+        Assert.assertEquals("Wrong packet count", 1L, serializedBuffer.readLong());
+        Assert.assertEquals("Wrong byte count", 2L, serializedBuffer.readLong());
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..5d3c3a8
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10PacketInMessageFactoryTest {
+    private OFSerializer<PacketInMessage> factory;
+    private static final byte MESSAGE_TYPE = 10;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, PacketInMessage.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        PacketInMessageBuilder builder = new PacketInMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setBufferId(1L);
+        builder.setTotalLen(1);
+        builder.setInPort(1);
+        builder.setReason(PacketInReason.forValue(0));
+        byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
+        builder.setData(data);
+        PacketInMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 34);
+        Assert.assertEquals("Wrong buffer id", message.getBufferId().longValue(), serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong total len", message.getTotalLen().intValue(), serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong port in", message.getInPort().intValue(), serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(1);
+        Assert.assertArrayEquals("Wrong data", message.getData(),
+                serializedBuffer.readBytes(serializedBuffer.readableBytes()).array());
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..8f97bc8
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10PortStatusMessageFactoryTest {
+    private OFSerializer<PortStatusMessage> factory;
+    private static final byte MESSAGE_TYPE = 12;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, PortStatusMessage.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setReason(PortReason.forValue(1));
+        builder.setPortNo(1L);
+        builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
+        builder.setName("Port name");
+        builder.setConfigV10(new PortConfigV10(true, false, true, false, true, false, true));
+        builder.setStateV10(new PortStateV10(true, false, true, false, true, false, true, false));
+        builder.setCurrentFeaturesV10(
+                new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
+        builder.setAdvertisedFeaturesV10(
+                new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
+        builder.setSupportedFeaturesV10(
+                new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
+        builder.setPeerFeaturesV10(
+                new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
+        PortStatusMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 64);
+        Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(7);
+        Assert.assertEquals("Wrong port No", message.getPortNo().intValue(), serializedBuffer.readShort());
+        byte[] address = new byte[6];
+        serializedBuffer.readBytes(address);
+        Assert.assertEquals("Wrong MacAddress", message.getHwAddr().getValue().toLowerCase(),
+                new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
+        byte[] name = new byte[16];
+        serializedBuffer.readBytes(name);
+        Assert.assertEquals("Wrong name", message.getName(), new String(name).trim());
+        Assert.assertEquals("Wrong config", message.getConfigV10(), createPortConfig(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong state", message.getStateV10(), createPortState(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong current", message.getCurrentFeaturesV10(),
+                createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong advertised", message.getAdvertisedFeaturesV10(),
+                createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong supported", message.getSupportedFeaturesV10(),
+                createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong peer", message.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
+    }
+
+    private static PortConfigV10 createPortConfig(long input) {
+        final Boolean _portDown = ((input) & (1 << 0)) > 0;
+        final Boolean _noStp = ((input) & (1 << 1)) > 0;
+        final Boolean _noRecv = ((input) & (1 << 2)) > 0;
+        final Boolean _noRecvStp = ((input) & (1 << 3)) > 0;
+        final Boolean _noFlood = ((input) & (1 << 4)) > 0;
+        final Boolean _noFwd = ((input) & (1 << 5)) > 0;
+        final Boolean _noPacketIn = ((input) & (1 << 6)) > 0;
+        return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown);
+    }
+
+    private static PortFeaturesV10 createPortFeatures(long input) {
+        final Boolean _10mbHd = ((input) & (1 << 0)) > 0;
+        final Boolean _10mbFd = ((input) & (1 << 1)) > 0;
+        final Boolean _100mbHd = ((input) & (1 << 2)) > 0;
+        final Boolean _100mbFd = ((input) & (1 << 3)) > 0;
+        final Boolean _1gbHd = ((input) & (1 << 4)) > 0;
+        final Boolean _1gbFd = ((input) & (1 << 5)) > 0;
+        final Boolean _10gbFd = ((input) & (1 << 6)) > 0;
+        final Boolean _copper = ((input) & (1 << 7)) > 0;
+        final Boolean _fiber = ((input) & (1 << 8)) > 0;
+        final Boolean _autoneg = ((input) & (1 << 9)) > 0;
+        final Boolean _pause = ((input) & (1 << 10)) > 0;
+        final Boolean _pauseAsym = ((input) & (1 << 11)) > 0;
+        return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _autoneg, _copper,
+                _fiber, _pause, _pauseAsym);
+    }
+
+    private static PortStateV10 createPortState(long input) {
+        final Boolean _linkDown = ((input) & (1 << 0)) > 0;
+        final Boolean _blocked = ((input) & (1 << 1)) > 0;
+        final Boolean _live = ((input) & (1 << 2)) > 0;
+        final Boolean _stpListen = ((input) & (1 << 3)) > 0;
+        final Boolean _stpLearn = ((input) & (1 << 4)) > 0;
+        final Boolean _stpForward = ((input) & (1 << 5)) > 0;
+        final Boolean _stpBlock = ((input) & (1 << 6)) > 0;
+        final Boolean _stpMask = ((input) & (1 << 7)) > 0;
+        return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..c46d03d
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10QueueGetConfigReplyMessageFactoryTest {
+    private OFSerializer<GetQueueConfigOutput> factory;
+    private static final byte MESSAGE_TYPE = 21;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, GetQueueConfigOutput.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setPort(new PortNumber(1L));
+        builder.setQueues(createQueues());
+        GetQueueConfigOutput message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 40);
+        Assert.assertEquals("Wrong port", message.getPort().getValue().longValue(), serializedBuffer.readShort());
+        serializedBuffer.skipBytes(6);
+        Assert.assertEquals("Wrong queue Id", message.getQueues().get(0).getQueueId().getValue().longValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong length", 24, serializedBuffer.readShort());
+        serializedBuffer.skipBytes(2);
+        List<QueueProperty> properties = message.getQueues().get(0).getQueueProperty();
+        Assert.assertEquals("Wrong property", properties.get(0).getProperty().getIntValue(),
+                serializedBuffer.readShort());
+        Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort());
+        serializedBuffer.skipBytes(4);
+        RateQueueProperty rateQueueProperty = properties.get(0).getAugmentation(RateQueueProperty.class);
+        Assert.assertEquals("Wrong rate", rateQueueProperty.getRate().intValue(), serializedBuffer.readShort());
+        serializedBuffer.skipBytes(6);
+    }
+
+    private List<Queues> createQueues() {
+        List<Queues> list = new ArrayList<>();
+        QueuesBuilder builder = new QueuesBuilder();
+        builder.setQueueId(new QueueId(1L));
+        builder.setQueueProperty(createPropertiesList());
+
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<QueueProperty> createPropertiesList() {
+        List<QueueProperty> propertiesList = new ArrayList<>();
+        QueuePropertyBuilder pb = new QueuePropertyBuilder();
+        pb.setProperty(QueueProperties.forValue(1));
+        RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();
+        rateBuilder.setRate(5);
+        pb.addAugmentation(RateQueueProperty.class, rateBuilder.build());
+        propertiesList.add(pb.build());
+        return propertiesList;
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..eff1c0f
--- /dev/null
@@ -0,0 +1,413 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class OF10StatsReplyMessageFactoryTest {
+    private OFSerializer<MultipartReplyMessage> factory;
+    private static final byte MESSAGE_TYPE = 17;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartReplyMessage.class));
+    }
+
+    @Test
+    public void testDescBodySerialize() throws Exception {
+        MultipartReplyMessageBuilder builder;
+        builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(0));
+        MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder();
+        MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder();
+        desc.setMfrDesc("Test");
+        desc.setHwDesc("Test");
+        desc.setSwDesc("Test");
+        desc.setSerialNum("12345");
+        desc.setDpDesc("Test");
+        descCase.setMultipartReplyDesc(desc.build());
+        builder.setMultipartReplyBody(descCase.build());
+        MultipartReplyMessage message = builder.build();
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 1068);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPDESC.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        Assert.assertEquals("Wrong desc body", message.getMultipartReplyBody(), decodeDescBody(serializedBuffer));
+    }
+
+    @Test
+    public void testFlowBodySerialize() throws Exception {
+        MultipartReplyMessageBuilder builder;
+        builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(1));
+        MultipartReplyFlowCaseBuilder flowCase = new MultipartReplyFlowCaseBuilder();
+        MultipartReplyFlowBuilder flow = new MultipartReplyFlowBuilder();
+        flow.setFlowStats(createFlowStats());
+        flowCase.setMultipartReplyFlow(flow.build());
+        builder.setMultipartReplyBody(flowCase.build());
+        MultipartReplyMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 108);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPFLOW.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        FlowStats flowStats = flow.getFlowStats().get(0);
+        Assert.assertEquals("Wrong length", 96, serializedBuffer.readShort());
+        Assert.assertEquals("Wrong Table ID", flowStats.getTableId().intValue(), serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(1);
+        Assert.assertEquals("Wrong wildcards", 3678463, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong inPort", 58, serializedBuffer.readUnsignedShort());
+        byte[] dlSrc = new byte[6];
+        serializedBuffer.readBytes(dlSrc);
+        Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
+        byte[] dlDst = new byte[6];
+        serializedBuffer.readBytes(dlDst);
+        Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst));
+        Assert.assertEquals("Wrong dlVlan", 18, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong dlVlanPcp", 5, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(1);
+        Assert.assertEquals("Wrong dlType", 42, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong nwTos", 4, serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong nwProto", 7, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(2);
+        Assert.assertEquals("Wrong nwSrc", 134744072, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong nwDst", 269488144, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong tpSrc", 6653, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong tpDst", 6633, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong duration sec", flowStats.getDurationSec().intValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong duration nsec", flowStats.getDurationNsec().intValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong priority", flowStats.getPriority().intValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong idle timeout", flowStats.getIdleTimeout().intValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong hard timeout", flowStats.getHardTimeout().intValue(), serializedBuffer.readShort());
+        serializedBuffer.skipBytes(6);
+        Assert.assertEquals("Wrong cookie", flowStats.getCookie().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong Packet count", flowStats.getPacketCount().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong Byte count", flowStats.getByteCount().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong action type", 0, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 8, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong port", 42, serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong maxlength", 50, serializedBuffer.readUnsignedShort());
+    }
+
+    @Test
+    public void testAggregateBodySerialize() throws Exception {
+        MultipartReplyMessageBuilder builder;
+        builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(2));
+        MultipartReplyAggregateCaseBuilder aggregateCase = new MultipartReplyAggregateCaseBuilder();
+        MultipartReplyAggregateBuilder aggregate = new MultipartReplyAggregateBuilder();
+        aggregate.setPacketCount(BigInteger.valueOf(1234L));
+        aggregate.setByteCount(BigInteger.valueOf(1234L));
+        aggregate.setFlowCount(1L);
+        aggregateCase.setMultipartReplyAggregate(aggregate.build());
+        builder.setMultipartReplyBody(aggregateCase.build());
+        MultipartReplyMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 36);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPAGGREGATE.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        Assert.assertEquals("Wrong Packet count", 1234L, serializedBuffer.readLong());
+        Assert.assertEquals("Wrong Byte count", 1234L, serializedBuffer.readLong());
+        Assert.assertEquals("Wrong flow count", 1L, serializedBuffer.readInt());
+        serializedBuffer.skipBytes(4);
+    }
+
+    @Test
+    public void testTableBodySerialize() throws Exception {
+        MultipartReplyMessageBuilder builder;
+        builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(3));
+        MultipartReplyTableCaseBuilder tableCase = new MultipartReplyTableCaseBuilder();
+        MultipartReplyTableBuilder table = new MultipartReplyTableBuilder();
+        table.setTableStats(createTableStats());
+        tableCase.setMultipartReplyTable(table.build());
+        builder.setMultipartReplyBody(tableCase.build());
+        MultipartReplyMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 60);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLE.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        Assert.assertEquals("Wrong table id", 1, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(3);
+        Assert.assertEquals("Wrong name", "Table name", ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 16));
+        Assert.assertEquals("Wrong wildcards", 3145983, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong max entries", 1L, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong active count", 1L, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong lookup count", 1234L, serializedBuffer.readLong());
+        Assert.assertEquals("Wrong matched count", 1234L, serializedBuffer.readLong());
+    }
+
+    @Test
+    public void testPortStatsBodySerialize() throws Exception {
+        MultipartReplyMessageBuilder builder;
+        builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(4));
+        MultipartReplyPortStatsCaseBuilder portStatsCase = new MultipartReplyPortStatsCaseBuilder();
+        MultipartReplyPortStatsBuilder portStats = new MultipartReplyPortStatsBuilder();
+        portStats.setPortStats(createPortStats());
+        portStatsCase.setMultipartReplyPortStats(portStats.build());
+        builder.setMultipartReplyBody(portStatsCase.build());
+        MultipartReplyMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 118);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTSTATS.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        MultipartReplyPortStatsCase body = (MultipartReplyPortStatsCase) message.getMultipartReplyBody();
+        MultipartReplyPortStats messageOutput = body.getMultipartReplyPortStats();
+        PortStats portStatsOutput = messageOutput.getPortStats().get(0);
+        Assert.assertEquals("Wrong port no", portStatsOutput.getPortNo().intValue(), serializedBuffer.readInt());
+        serializedBuffer.skipBytes(6);
+        Assert.assertEquals("Wrong rx packets", portStatsOutput.getRxPackets().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx packets", portStatsOutput.getTxPackets().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx bytes", portStatsOutput.getRxBytes().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx bytes", portStatsOutput.getTxBytes().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx dropped", portStatsOutput.getRxDropped().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx dropped", portStatsOutput.getTxDropped().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx errors", portStatsOutput.getRxErrors().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx errors", portStatsOutput.getTxErrors().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx frame err", portStatsOutput.getRxFrameErr().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx over err", portStatsOutput.getRxOverErr().longValue(),
+                serializedBuffer.readLong());
+        Assert.assertEquals("Wrong rx crc err", portStatsOutput.getRxCrcErr().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong collisions", portStatsOutput.getCollisions().longValue(),
+                serializedBuffer.readLong());
+    }
+
+    @Test
+    public void testQueueBodySerialize() throws Exception {
+        MultipartReplyMessageBuilder builder;
+        builder = new MultipartReplyMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setType(MultipartType.forValue(5));
+        MultipartReplyQueueCaseBuilder queueCase = new MultipartReplyQueueCaseBuilder();
+        MultipartReplyQueueBuilder queue = new MultipartReplyQueueBuilder();
+        queue.setQueueStats(createQueueStats());
+        queueCase.setMultipartReplyQueue(queue.build());
+        builder.setMultipartReplyBody(queueCase.build());
+        MultipartReplyMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 44);
+        Assert.assertEquals("Wrong type", MultipartType.OFPMPQUEUE.getIntValue(), serializedBuffer.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(),
+                createMultipartRequestFlags(serializedBuffer.readShort()));
+        MultipartReplyQueueCase body = (MultipartReplyQueueCase) message.getMultipartReplyBody();
+        MultipartReplyQueue messageOutput = body.getMultipartReplyQueue();
+        QueueStats queueStats = messageOutput.getQueueStats().get(0);
+        Assert.assertEquals("Wrong length", 32, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(2);
+        Assert.assertEquals("Wrong queue id", queueStats.getQueueId().intValue(), serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong tx bytes", queueStats.getTxBytes().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx packets", queueStats.getTxPackets().longValue(), serializedBuffer.readLong());
+        Assert.assertEquals("Wrong tx errors", queueStats.getTxErrors().longValue(), serializedBuffer.readLong());
+    }
+
+    private static List<QueueStats> createQueueStats() {
+        QueueStatsBuilder builder = new QueueStatsBuilder();
+        builder.setQueueId(1L);
+        builder.setTxBytes(BigInteger.valueOf(1L));
+        builder.setTxPackets(BigInteger.valueOf(1L));
+        builder.setTxErrors(BigInteger.valueOf(1L));
+        List<QueueStats> list = new ArrayList<>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<PortStats> createPortStats() {
+        PortStatsBuilder builder = new PortStatsBuilder();
+        builder.setPortNo(1L);
+        builder.setRxPackets(BigInteger.valueOf(1L));
+        builder.setTxPackets(BigInteger.valueOf(1L));
+        builder.setRxBytes(BigInteger.valueOf(1L));
+        builder.setTxBytes(BigInteger.valueOf(1L));
+        builder.setRxDropped(BigInteger.valueOf(1L));
+        builder.setTxDropped(BigInteger.valueOf(1L));
+        builder.setRxErrors(BigInteger.valueOf(1L));
+        builder.setTxErrors(BigInteger.valueOf(1L));
+        builder.setRxFrameErr(BigInteger.valueOf(1L));
+        builder.setRxOverErr(BigInteger.valueOf(1L));
+        builder.setRxCrcErr(BigInteger.valueOf(1L));
+        builder.setCollisions(BigInteger.valueOf(1L));
+        List<PortStats> list = new ArrayList<PortStats>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<TableStats> createTableStats() {
+        TableStatsBuilder builder = new TableStatsBuilder();
+        builder.setTableId((short) 1);
+        builder.setName("Table name");
+        builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
+        builder.setMaxEntries(1L);
+        builder.setActiveCount(1L);
+        builder.setLookupCount(BigInteger.valueOf(1234L));
+        builder.setMatchedCount(BigInteger.valueOf(1234L));
+        List<TableStats> list = new ArrayList<>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static List<FlowStats> createFlowStats() {
+        FlowStatsBuilder builder = new FlowStatsBuilder();
+        builder.setTableId((short) 1);
+        MatchV10Builder matchBuilder = new MatchV10Builder();
+        matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
+        matchBuilder.setNwSrcMask((short) 0);
+        matchBuilder.setNwDstMask((short) 0);
+        matchBuilder.setInPort(58);
+        matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
+        matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff"));
+        matchBuilder.setDlVlan(18);
+        matchBuilder.setDlVlanPcp((short) 5);
+        matchBuilder.setDlType(42);
+        matchBuilder.setNwTos((short) 4);
+        matchBuilder.setNwProto((short) 7);
+        matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));
+        matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));
+        matchBuilder.setTpSrc(6653);
+        matchBuilder.setTpDst(6633);
+        builder.setMatchV10(matchBuilder.build());
+        builder.setDurationSec(1L);
+        builder.setDurationNsec(2L);
+        builder.setPriority(1);
+        builder.setIdleTimeout(1);
+        builder.setHardTimeout(1);
+        builder.setCookie(BigInteger.valueOf(1234L));
+        builder.setPacketCount(BigInteger.valueOf(1234L));
+        builder.setByteCount(BigInteger.valueOf(1234L));
+        List<Action> actions = new ArrayList<>();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
+        OutputActionBuilder outputBuilder = new OutputActionBuilder();
+        outputBuilder.setPort(new PortNumber(42L));
+        outputBuilder.setMaxLength(50);
+        caseBuilder.setOutputAction(outputBuilder.build());
+        actionBuilder.setActionChoice(caseBuilder.build());
+        actions.add(actionBuilder.build());
+        builder.setAction(actions);
+        List<FlowStats> list = new ArrayList<FlowStats>();
+        list.add(builder.build());
+        return list;
+    }
+
+    private static MultipartRequestFlags createMultipartRequestFlags(int input) {
+        final Boolean one = ((input) & (1 << 0)) > 0;
+        return new MultipartRequestFlags(one);
+    }
+
+    private static MultipartReplyDescCase decodeDescBody(ByteBuf output) {
+        MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder();
+        MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder();
+        byte[] mfrDesc = new byte[256];
+        output.readBytes(mfrDesc);
+        desc.setMfrDesc(new String(mfrDesc).trim());
+        byte[] hwDesc = new byte[256];
+        output.readBytes(hwDesc);
+        desc.setHwDesc(new String(hwDesc).trim());
+        byte[] swDesc = new byte[256];
+        output.readBytes(swDesc);
+        desc.setSwDesc(new String(swDesc).trim());
+        byte[] serialNumber = new byte[32];
+        output.readBytes(serialNumber);
+        desc.setSerialNum(new String(serialNumber).trim());
+        byte[] dpDesc = new byte[256];
+        output.readBytes(dpDesc);
+        desc.setDpDesc(new String(dpDesc).trim());
+        descCase.setMultipartReplyDesc(desc.build());
+        return descCase.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..550e9c7
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class PacketInMessageFactoryTest {
+    private OFSerializer<PacketInMessage> factory;
+    private static final byte MESSAGE_TYPE = 10;
+    private static final byte PADDING = 2;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, PacketInMessage.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        PacketInMessageBuilder builder = new PacketInMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setBufferId(256L);
+        builder.setTotalLen(10);
+        builder.setReason(PacketInReason.forValue(0));
+        builder.setTableId(new TableId(1L));
+        byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
+        builder.setCookie(new BigInteger(1, cookie));
+        MatchBuilder matchBuilder = new MatchBuilder();
+        matchBuilder.setType(OxmMatchType.class);
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(InPhyPort.class);
+        entriesBuilder.setHasMask(false);
+        InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
+        InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
+        inPhyPortBuilder.setPortNumber(new PortNumber(42L));
+        inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
+        entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
+        entries.add(entriesBuilder.build());
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(IpEcn.class);
+        entriesBuilder.setHasMask(false);
+        IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
+        IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
+        ipEcnBuilder.setEcn((short) 4);
+        ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
+        entries.add(entriesBuilder.build());
+        matchBuilder.setMatchEntry(entries);
+        builder.setMatch(matchBuilder.build());
+        byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
+        builder.setData(data);
+        PacketInMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 66);
+        Assert.assertEquals("Wrong BufferId", message.getBufferId().longValue(), serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong actions length", message.getTotalLen().intValue(),
+                serializedBuffer.readUnsignedShort());
+        Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte());
+        Assert.assertEquals("Wrong tableId", message.getTableId().getValue().intValue(),
+                serializedBuffer.readUnsignedByte());
+        cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        serializedBuffer.readBytes(cookie);
+        Assert.assertEquals("Wrong cookie", message.getCookie(), new BigInteger(1, cookie));
+        Assert.assertEquals("Wrong match type", 1, serializedBuffer.readUnsignedShort());
+        serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort());
+        short fieldAndMask = serializedBuffer.readUnsignedByte();
+        Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
+        Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);
+        serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+        Assert.assertEquals("Wrong oxm value", 42, serializedBuffer.readUnsignedInt());
+        Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort());
+        fieldAndMask = serializedBuffer.readUnsignedByte();
+        Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
+        Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);
+        serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+        Assert.assertEquals("Wrong oxm value", 4, serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(7);
+        serializedBuffer.skipBytes(PADDING);
+        Assert.assertArrayEquals("Wrong data", message.getData(),
+                serializedBuffer.readBytes(serializedBuffer.readableBytes()).array());
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..dd87250
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class PortStatusMessageFactoryTest {
+    private OFSerializer<PortStatusMessage> factory;
+    private static final byte MESSAGE_TYPE = 12;
+    private static final byte PADDING = 7;
+    private static final byte PORT_PADDING_1 = 4;
+    private static final byte PORT_PADDING_2 = 2;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, PortStatusMessage.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setReason(PortReason.forValue(1));
+        builder.setPortNo(1L);
+        builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
+        builder.setName("Port name");
+        builder.setConfig(new PortConfig(true, false, true, false));
+        builder.setState(new PortState(true, false, true));
+        builder.setCurrentFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false,
+                true, false, true, false, true, false));
+        builder.setAdvertisedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false,
+                true, false, true, false, true, false));
+        builder.setSupportedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false,
+                true, false, true, false, true, false));
+        builder.setPeerFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true,
+                false, true, false, true, false));
+        builder.setCurrSpeed(1234L);
+        builder.setMaxSpeed(1234L);
+        PortStatusMessage message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80);
+        Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte());
+        serializedBuffer.skipBytes(PADDING);
+        Assert.assertEquals("Wrong PortNo", message.getPortNo().intValue(), serializedBuffer.readUnsignedInt());
+        serializedBuffer.skipBytes(PORT_PADDING_1);
+        byte[] address = new byte[6];
+        serializedBuffer.readBytes(address);
+        Assert.assertEquals("Wrong MacAddress", message.getHwAddr().getValue().toLowerCase(),
+                new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
+        serializedBuffer.skipBytes(PORT_PADDING_2);
+        byte[] name = new byte[16];
+        serializedBuffer.readBytes(name);
+        Assert.assertEquals("Wrong name", message.getName(), new String(name).trim());
+        Assert.assertEquals("Wrong config", message.getConfig(), createPortConfig(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong state", message.getState(), createPortState(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong current", message.getCurrentFeatures(),
+                createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong advertised", message.getAdvertisedFeatures(),
+                createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong supported", message.getSupportedFeatures(),
+                createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong peer", message.getPeerFeatures(), createPortFeatures(serializedBuffer.readInt()));
+        Assert.assertEquals("Wrong Current speed", message.getCurrSpeed().longValue(), serializedBuffer.readInt());
+        Assert.assertEquals("Wrong Max speed", message.getMaxSpeed().longValue(), serializedBuffer.readInt());
+    }
+
+    private static PortConfig createPortConfig(long input) {
+        final Boolean _portDown = ((input) & (1 << 0)) > 0;
+        final Boolean _noRecv = ((input) & (1 << 2)) > 0;
+        final Boolean _noFwd = ((input) & (1 << 5)) > 0;
+        final Boolean _noPacketIn = ((input) & (1 << 6)) > 0;
+        return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);
+    }
+
+    private static PortFeatures createPortFeatures(long input) {
+        final Boolean _10mbHd = ((input) & (1 << 0)) > 0;
+        final Boolean _10mbFd = ((input) & (1 << 1)) > 0;
+        final Boolean _100mbHd = ((input) & (1 << 2)) > 0;
+        final Boolean _100mbFd = ((input) & (1 << 3)) > 0;
+        final Boolean _1gbHd = ((input) & (1 << 4)) > 0;
+        final Boolean _1gbFd = ((input) & (1 << 5)) > 0;
+        final Boolean _10gbFd = ((input) & (1 << 6)) > 0;
+        final Boolean _40gbFd = ((input) & (1 << 7)) > 0;
+        final Boolean _100gbFd = ((input) & (1 << 8)) > 0;
+        final Boolean _1tbFd = ((input) & (1 << 9)) > 0;
+        final Boolean _other = ((input) & (1 << 10)) > 0;
+        final Boolean _copper = ((input) & (1 << 11)) > 0;
+        final Boolean _fiber = ((input) & (1 << 12)) > 0;
+        final Boolean _autoneg = ((input) & (1 << 13)) > 0;
+        final Boolean _pause = ((input) & (1 << 14)) > 0;
+        final Boolean _pauseAsym = ((input) & (1 << 15)) > 0;
+        return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _1tbFd,
+                _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym);
+    }
+
+    private static PortState createPortState(long input) {
+        final Boolean one = ((input) & (1 << 0)) > 0;
+        final Boolean two = ((input) & (1 << 1)) > 0;
+        final Boolean three = ((input) & (1 << 2)) > 0;
+        return new PortState(two, one, three);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..c69a0da
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class QueueGetConfigReplyMessageFactoryTest {
+    private OFSerializer<GetQueueConfigOutput> factory;
+    private static final byte MESSAGE_TYPE = 23;
+    private static final byte PADDING = 4;
+    private static final byte QUEUE_PADDING = 6;
+    private static final byte PROPERTY_HEADER_PADDING = 4;
+    private static final byte PROPERTY_RATE_PADDING = 6;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, GetQueueConfigOutput.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setPort(new PortNumber(0x00010203L));
+        builder.setQueues(createQueuesList());
+        GetQueueConfigOutput message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80);
+        Assert.assertEquals("Wrong port", message.getPort().getValue().longValue(), serializedBuffer.readInt());
+        serializedBuffer.skipBytes(PADDING);
+
+        Assert.assertEquals("Wrong queue Id", message.getQueues().get(0).getQueueId().getValue().longValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong port", message.getQueues().get(0).getPort().getValue().longValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong length", 32, serializedBuffer.readShort());
+        serializedBuffer.skipBytes(QUEUE_PADDING);
+        List<QueueProperty> properties = message.getQueues().get(0).getQueueProperty();
+        Assert.assertEquals("Wrong property", properties.get(0).getProperty().getIntValue(),
+                serializedBuffer.readShort());
+        Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort());
+        serializedBuffer.skipBytes(PROPERTY_HEADER_PADDING);
+        RateQueueProperty rateQueueProperty = properties.get(0).getAugmentation(RateQueueProperty.class);
+        Assert.assertEquals("Wrong rate", rateQueueProperty.getRate().intValue(), serializedBuffer.readShort());
+        serializedBuffer.skipBytes(PROPERTY_RATE_PADDING);
+
+        Assert.assertEquals("Wrong queue Id", message.getQueues().get(1).getQueueId().getValue().longValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong queue Id", message.getQueues().get(1).getPort().getValue().longValue(),
+                serializedBuffer.readInt());
+        Assert.assertEquals("Wrong length", 32, serializedBuffer.readShort());
+        serializedBuffer.skipBytes(QUEUE_PADDING);
+        List<QueueProperty> propertiesTwo = message.getQueues().get(1).getQueueProperty();
+        Assert.assertEquals("Wrong property", propertiesTwo.get(0).getProperty().getIntValue(),
+                serializedBuffer.readShort());
+        Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort());
+        serializedBuffer.skipBytes(PROPERTY_HEADER_PADDING);
+        RateQueueProperty rateQueuePropertyTwo = propertiesTwo.get(0).getAugmentation(RateQueueProperty.class);
+        Assert.assertEquals("Wrong rate", rateQueuePropertyTwo.getRate().intValue(), serializedBuffer.readShort());
+        serializedBuffer.skipBytes(PROPERTY_RATE_PADDING);
+
+    }
+
+    private static List<Queues> createQueuesList() {
+        List<Queues> queuesList = new ArrayList<>();
+        for (int i = 1; i < 3; i++) {
+            QueuesBuilder qb = new QueuesBuilder();
+            qb.setQueueId(new QueueId((long) i));
+            qb.setPort(new PortNumber((long) i));
+            qb.setQueueProperty(createPropertiesList());
+            queuesList.add(qb.build());
+        }
+        return queuesList;
+    }
+
+    private static List<QueueProperty> createPropertiesList() {
+        List<QueueProperty> propertiesList = new ArrayList<>();
+        QueuePropertyBuilder pb = new QueuePropertyBuilder();
+        pb.setProperty(QueueProperties.forValue(2));
+        RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();
+        rateBuilder.setRate(5);
+        pb.addAugmentation(RateQueueProperty.class, rateBuilder.build());
+        propertiesList.add(pb.build());
+        return propertiesList;
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..8ed5855
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015 NetIDE Consortium and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.math.BigInteger;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder;
+
+/**
+ * @author giuseppex.petralia@intel.com
+ *
+ */
+public class RoleReplyMessageFactoryTest {
+    private OFSerializer<RoleRequestOutput> factory;
+    private static final byte MESSAGE_TYPE = 25;
+    private static final byte PADDING = 4;
+
+    @Before
+    public void startUp() {
+        SerializerRegistry registry = new SerializerRegistryImpl();
+        registry.init();
+        factory = registry
+                .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, RoleRequestOutput.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        RoleRequestOutputBuilder builder = new RoleRequestOutputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setRole(ControllerRole.forValue(0));
+        builder.setGenerationId(BigInteger.valueOf(1L));
+        RoleRequestOutput message = builder.build();
+
+        ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        factory.serialize(message, serializedBuffer);
+        BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24);
+        Assert.assertEquals("Wrong role", message.getRole().getIntValue(),
+                ControllerRole.forValue((int) serializedBuffer.readUnsignedInt()).getIntValue());
+        serializedBuffer.skipBytes(PADDING);
+        byte[] genId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        serializedBuffer.readBytes(genId);
+        Assert.assertEquals("Wrong generation ID", message.getGenerationId(), new BigInteger(1, genId));
+    }
+}