InstructionDeserializer split into separate deserializers 98/6598/2
authorMichal Polkorab <michal.polkorab@pantheon.sk>
Tue, 29 Apr 2014 13:50:04 +0000 (15:50 +0200)
committerMichal Polkorab <michal.polkorab@pantheon.sk>
Wed, 30 Apr 2014 11:51:16 +0000 (13:51 +0200)
 - created List deserialization classes
 - added default experimenter deserializer intialization
 - created default experimenter instruction deserializer
 - MessageDeserializerRegistryHelper renamed to SimpleDeserializerRegistryHelper
  + unified its use for simple (MessageCodeKey) deserializers
 - updated unit tests

Change-Id: I3f428fdd81f39a4cf96a826e208fee067e9c0b6f
Signed-off-by: Michal Polkorab <michal.polkorab@pantheon.sk>
37 files changed:
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DefaultExperimenterDeserializerInitializer.java [new file with mode: 0644]
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/InstructionDeserializerInitializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/OF13ExperimenterInstructionDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/DecodingUtils.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedTypeKeyMakerFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializer.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java [moved from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MessageDeserializerRegistryHelper.java with 85% similarity]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java

diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DefaultExperimenterDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DefaultExperimenterDeserializerInitializer.java
new file mode 100644 (file)
index 0000000..d32d53d
--- /dev/null
@@ -0,0 +1,33 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.OF13ExperimenterInstructionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class DefaultExperimenterDeserializerInitializer {\r
+\r
+    /**\r
+     * Registers default experimenter deserializers\r
+     * @param registry registry to be filled with deserializers\r
+     */\r
+    public static void registerDeserializers(DeserializerRegistry registry) {\r
+        SimpleDeserializerRegistryHelper helper =\r
+                new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry);\r
+        helper.registerDeserializer(EncodeConstants.EXPERIMENTER_VALUE,\r
+                Instruction.class, new OF13ExperimenterInstructionDeserializer());\r
+    }\r
+}\r
index 803973107ad39afb992e9ff82e5c39cc9a8c1d58..6a08db8c40262137b2eadfdcc9e1b0c5df6e8389 100644 (file)
@@ -17,12 +17,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionsDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.InstructionsDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.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.oxm.rev130731.match.grouping.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
 
@@ -52,11 +50,13 @@ public class DeserializerRegistryImpl implements DeserializerRegistry {
                 EncodeConstants.EMPTY_VALUE, Match.class), new MatchDeserializer());
         registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
                 EncodeConstants.EMPTY_VALUE, Action.class), new ActionsDeserializer());
-        registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
-                EncodeConstants.EMPTY_VALUE, Instruction.class), new InstructionsDeserializer());
 
         // register match entry deserializers
         MatchEntryDeserializerInitializer.registerMatchEntryDeserializers(this);
+        //register instruction deserializers
+        InstructionDeserializerInitializer.registerDeserializers(this);
+        // register default experimenter deserializers
+        DefaultExperimenterDeserializerInitializer.registerDeserializers(this);
     }
 
     @Override
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java
new file mode 100644 (file)
index 0000000..e600915
--- /dev/null
@@ -0,0 +1,43 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ApplyActionsInstructionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ClearActionsInstructionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.GoToTableInstructionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.MeterInstructionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteActionsInstructionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteMetadataInstructionDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class InstructionDeserializerInitializer {\r
+\r
+    /**\r
+     * Registers instruction deserializers\r
+     * @param registry registry to be filled with deserializers\r
+     */\r
+    public static void registerDeserializers(DeserializerRegistry registry) {\r
+        // register OF v1.3 instruction deserializers\r
+        SimpleDeserializerRegistryHelper helper =\r
+                new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry);\r
+        helper.registerDeserializer(1, Instruction.class, new GoToTableInstructionDeserializer());\r
+        helper.registerDeserializer(2, Instruction.class, new WriteMetadataInstructionDeserializer());\r
+        helper.registerDeserializer(3, Instruction.class, new WriteActionsInstructionDeserializer());\r
+        helper.registerDeserializer(4, Instruction.class, new ApplyActionsInstructionDeserializer());\r
+        helper.registerDeserializer(5, Instruction.class, new ClearActionsInstructionDeserializer());\r
+        helper.registerDeserializer(6, Instruction.class, new MeterInstructionDeserializer());\r
+    }\r
+}\r
index 1ccd04b1755075d5af445624bce416c346da005a..29ef0f568936321558f0c14f4e2edcae42442476 100644 (file)
@@ -35,7 +35,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.Por
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory;\r
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.openflowjava.protocol.impl.util.MessageDeserializerRegistryHelper;\r
+import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;\r
@@ -63,35 +63,35 @@ public class MessageDerializerInitializer {
      */\r
     public static void registerMessageDeserializers(DeserializerRegistry registry) {\r
         // register OF v1.0 message deserializers\r
-        MessageDeserializerRegistryHelper helper =\r
-                new MessageDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry);\r
-        helper.registerMessageDeserializer(0, HelloMessage.class, new OF10HelloMessageFactory());\r
-        helper.registerMessageDeserializer(1, ErrorMessage.class, new OF10ErrorMessageFactory());\r
-        helper.registerMessageDeserializer(2, EchoRequestMessage.class, new OF10EchoRequestMessageFactory());\r
-        helper.registerMessageDeserializer(3, EchoOutput.class, new OF10EchoReplyMessageFactory());\r
-        helper.registerMessageDeserializer(6, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory());\r
-        helper.registerMessageDeserializer(8, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory());\r
-        helper.registerMessageDeserializer(10, PacketInMessage.class, new OF10PacketInMessageFactory());\r
-        helper.registerMessageDeserializer(11, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory());\r
-        helper.registerMessageDeserializer(12, PortStatusMessage.class, new OF10PortStatusMessageFactory());\r
-        helper.registerMessageDeserializer(17, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory());\r
-        helper.registerMessageDeserializer(19, BarrierOutput.class, new OF10BarrierReplyMessageFactory());\r
-        helper.registerMessageDeserializer(21, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory());\r
+        SimpleDeserializerRegistryHelper helper =\r
+                new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry);\r
+        helper.registerDeserializer(0, HelloMessage.class, new OF10HelloMessageFactory());\r
+        helper.registerDeserializer(1, ErrorMessage.class, new OF10ErrorMessageFactory());\r
+        helper.registerDeserializer(2, EchoRequestMessage.class, new OF10EchoRequestMessageFactory());\r
+        helper.registerDeserializer(3, EchoOutput.class, new OF10EchoReplyMessageFactory());\r
+        helper.registerDeserializer(6, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory());\r
+        helper.registerDeserializer(8, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory());\r
+        helper.registerDeserializer(10, PacketInMessage.class, new OF10PacketInMessageFactory());\r
+        helper.registerDeserializer(11, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory());\r
+        helper.registerDeserializer(12, PortStatusMessage.class, new OF10PortStatusMessageFactory());\r
+        helper.registerDeserializer(17, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory());\r
+        helper.registerDeserializer(19, BarrierOutput.class, new OF10BarrierReplyMessageFactory());\r
+        helper.registerDeserializer(21, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory());\r
         // register Of v1.3 message deserializers\r
-        helper = new MessageDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry);\r
-        helper.registerMessageDeserializer(0, HelloMessage.class, new HelloMessageFactory());\r
-        helper.registerMessageDeserializer(1, ErrorMessage.class, new ErrorMessageFactory());\r
-        helper.registerMessageDeserializer(2, EchoRequestMessage.class, new EchoRequestMessageFactory());\r
-        helper.registerMessageDeserializer(3, EchoOutput.class, new EchoReplyMessageFactory());\r
-        helper.registerMessageDeserializer(6, GetFeaturesOutput.class, new FeaturesReplyMessageFactory());\r
-        helper.registerMessageDeserializer(8, GetConfigOutput.class, new GetConfigReplyMessageFactory());\r
-        helper.registerMessageDeserializer(10, PacketInMessage.class, new PacketInMessageFactory());\r
-        helper.registerMessageDeserializer(11, FlowRemovedMessage.class, new FlowRemovedMessageFactory());\r
-        helper.registerMessageDeserializer(12, PortStatusMessage.class, new PortStatusMessageFactory());\r
-        helper.registerMessageDeserializer(19, MultipartReplyMessage.class, new MultipartReplyMessageFactory());\r
-        helper.registerMessageDeserializer(21, BarrierOutput.class, new BarrierReplyMessageFactory());\r
-        helper.registerMessageDeserializer(23, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory());\r
-        helper.registerMessageDeserializer(25, RoleRequestOutput.class, new RoleReplyMessageFactory());\r
-        helper.registerMessageDeserializer(27, GetAsyncOutput.class, new GetAsyncReplyMessageFactory());\r
+        helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry);\r
+        helper.registerDeserializer(0, HelloMessage.class, new HelloMessageFactory());\r
+        helper.registerDeserializer(1, ErrorMessage.class, new ErrorMessageFactory());\r
+        helper.registerDeserializer(2, EchoRequestMessage.class, new EchoRequestMessageFactory());\r
+        helper.registerDeserializer(3, EchoOutput.class, new EchoReplyMessageFactory());\r
+        helper.registerDeserializer(6, GetFeaturesOutput.class, new FeaturesReplyMessageFactory());\r
+        helper.registerDeserializer(8, GetConfigOutput.class, new GetConfigReplyMessageFactory());\r
+        helper.registerDeserializer(10, PacketInMessage.class, new PacketInMessageFactory());\r
+        helper.registerDeserializer(11, FlowRemovedMessage.class, new FlowRemovedMessageFactory());\r
+        helper.registerDeserializer(12, PortStatusMessage.class, new PortStatusMessageFactory());\r
+        helper.registerDeserializer(19, MultipartReplyMessage.class, new MultipartReplyMessageFactory());\r
+        helper.registerDeserializer(21, BarrierOutput.class, new BarrierReplyMessageFactory());\r
+        helper.registerDeserializer(23, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory());\r
+        helper.registerDeserializer(25, RoleRequestOutput.class, new RoleReplyMessageFactory());\r
+        helper.registerDeserializer(27, GetAsyncOutput.class, new GetAsyncReplyMessageFactory());\r
     }\r
 }\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/OF13ExperimenterInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/OF13ExperimenterInstructionDeserializer.java
new file mode 100644 (file)
index 0000000..8cc0692
--- /dev/null
@@ -0,0 +1,57 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OF13ExperimenterInstructionDeserializer implements OFDeserializer<Instruction>,\r
+        HeaderDeserializer<Instruction> {\r
+\r
+    @Override\r
+    public Instruction deserializeHeader(ByteBuf input) {\r
+        InstructionBuilder builder = new InstructionBuilder();\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        builder.setType(Experimenter.class);\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();\r
+        expBuilder.setExperimenter(input.readUnsignedInt());\r
+        return builder.build();\r
+    }\r
+\r
+    @Override\r
+    public Instruction deserialize(ByteBuf input) {\r
+        InstructionBuilder builder = new InstructionBuilder();\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        builder.setType(Experimenter.class);\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();\r
+        expBuilder.setExperimenter(input.readUnsignedInt());\r
+        if (input.readableBytes() > 0) {\r
+            byte[] data = new byte[input.readableBytes()];\r
+            input.readBytes(data);\r
+            expBuilder.setData(data);\r
+        }\r
+        builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());\r
+        return builder.build();\r
+    }\r
+\r
+}\r
index 002e979e16498766c3f5b80474d5aeae01310f04..1ff7ee5d1391a548072dc3eba341508aa0e9aa7e 100644 (file)
@@ -16,12 +16,13 @@ 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.HeaderDeserializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
-import org.opendaylight.openflowjava.protocol.impl.util.DecodingUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
 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.rev131002.ActionRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder;
@@ -56,6 +57,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 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.rev130731.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
 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;
@@ -284,10 +286,10 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
             OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(
                     EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
             flowStatsBuilder.setMatch(matchDeserializer.deserialize(subInput));
-            OFDeserializer<Instruction> insDeserializer = registry.getDeserializer(new MessageCodeKey(
-                    EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Instruction.class));
-            List<Instruction> instructions = DecodingUtils.deserializeList(
-                    subInput.readableBytes(), subInput, insDeserializer);
+            CodeKeyMaker keyMaker = CodeKeyMakerFactory
+                    .createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
+            List<Instruction> instructions = ListDeserializer.deserializeList(
+                    EncodeConstants.OF13_VERSION_ID, subInput.readableBytes(), subInput, keyMaker, registry);
             flowStatsBuilder.setInstruction(instructions);
             flowStatsList.add(flowStatsBuilder.build());
         }
@@ -387,10 +389,9 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
             if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS)
                     || type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
                 InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
-                HeaderDeserializer<Instruction> insDeserializer = registry.getDeserializer(new MessageCodeKey(
-                        EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Instruction.class));
-                List<Instruction> instructions = DecodingUtils.deserializeHeaders(
-                        propertyLength - COMMON_PROPERTY_LENGTH, input, insDeserializer);
+                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)
@@ -411,10 +412,9 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
                     || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS)
                     || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
                 ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
-                HeaderDeserializer<Action> deserializer = registry.getDeserializer(new MessageCodeKey(
-                        EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Action.class));
-                List<Action> actions = DecodingUtils.deserializeHeaders(
-                        propertyLength - COMMON_PROPERTY_LENGTH, input, deserializer);
+                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)
@@ -424,8 +424,11 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
                     || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD)
                     || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {
                 OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
-                oxmBuilder.setMatchEntries(DecodingUtils.deserializeMatchEntryHeaders(
-                        propertyLength - COMMON_PROPERTY_LENGTH, input, registry));
+                CodeKeyMaker keyMaker = CodeKeyMakerFactory
+                        .createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
+                List<MatchEntries> entries = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID,
+                        propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
+                oxmBuilder.setMatchEntries(entries);
                 builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
             } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)
                     || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {
@@ -848,11 +851,10 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
                 bucketsBuilder.setWatchPort(new PortNumber(input.readUnsignedInt()));
                 bucketsBuilder.setWatchGroup(input.readUnsignedInt());
                 input.skipBytes(PADDING_IN_BUCKETS_HEADER);
-                OFDeserializer<Action> deserializer = registry.getDeserializer(new MessageCodeKey(
-                        EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Action.class));
-                List<Action> actionsList = DecodingUtils.deserializeList(
-                        bucketsLength - BUCKETS_HEADER_LENGTH, input, deserializer);
-                bucketsBuilder.setAction(actionsList);
+                CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
+                List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
+                        bucketsLength - BUCKETS_HEADER_LENGTH, input, keyMaker, registry);
+                bucketsBuilder.setAction(actions);
                 bucketsList.add(bucketsBuilder.build());
                 actualLength += bucketsLength;
             }
index b1550cee01ebda6fe9d913d57685ff132b46e7ed..4cf0b1d6eae5a5c97bbeaaf908d7040eae664c0a 100644 (file)
@@ -19,8 +19,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegi
 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
-import org.opendaylight.openflowjava.protocol.impl.util.DecodingUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
@@ -161,10 +163,9 @@ public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartRep
             byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(byteCount);
             flowStatsBuilder.setByteCount(new BigInteger(1, byteCount));
-            OFDeserializer<Action> deserializer = registry.getDeserializer(new MessageCodeKey(
-                    EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, Action.class));
-            List<Action> actions = DecodingUtils.deserializeList(length - LENGTH_OF_FLOW_STATS,
-                    input, deserializer);
+            CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);
+            List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID,
+                    length - LENGTH_OF_FLOW_STATS, input, keyMaker, registry);
             flowStatsBuilder.setAction(actions);
             flowStatsList.add(flowStatsBuilder.build());
         }
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java
new file mode 100644 (file)
index 0000000..224b3a6
--- /dev/null
@@ -0,0 +1,65 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import java.util.List;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;\r
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;\r
+import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractActionInstructionDeserializer extends AbstractInstructionDeserializer\r
+        implements DeserializerRegistryInjector {\r
+\r
+    private DeserializerRegistry registry;\r
+\r
+    @Override\r
+    public Instruction deserialize(ByteBuf input) {\r
+        InstructionBuilder builder = new InstructionBuilder();\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        builder.setType(getType());\r
+        int instructionLength = input.readUnsignedShort();\r
+        input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);\r
+        ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder();\r
+        int length = instructionLength - InstructionConstants.STANDARD_INSTRUCTION_LENGTH;\r
+        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+        List<Action> actions = ListDeserializer.deserializeList(\r
+                EncodeConstants.OF13_VERSION_ID, length, input, keyMaker, getRegistry());\r
+        actionsBuilder.setAction(actions);\r
+        builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());\r
+        return builder.build();\r
+    }\r
+\r
+    protected abstract Class<? extends InstructionBase> getType();\r
+\r
+    protected DeserializerRegistry getRegistry() {\r
+        return registry;\r
+    }\r
+\r
+    @Override\r
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {\r
+        this.registry = deserializerRegistry;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java
new file mode 100644 (file)
index 0000000..ff6da00
--- /dev/null
@@ -0,0 +1,66 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractInstructionDeserializer implements OFDeserializer<Instruction>,\r
+        HeaderDeserializer<Instruction> {\r
+\r
+    @Override\r
+    public Instruction deserializeHeader(ByteBuf rawMessage) {\r
+        InstructionBuilder builder = processHeader(rawMessage);\r
+        rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        return builder.build();\r
+    }\r
+\r
+    protected InstructionBuilder processHeader(ByteBuf input) {\r
+        InstructionBuilder builder = new InstructionBuilder();\r
+        int type = input.readUnsignedShort();\r
+        switch (type) {\r
+        case 1:\r
+            builder.setType(GotoTable.class);\r
+            break;\r
+        case 2:\r
+            builder.setType(WriteMetadata.class);\r
+            break;\r
+        case 3:\r
+            builder.setType(WriteActions.class);\r
+            break;\r
+        case 4:\r
+            builder.setType(ApplyActions.class);\r
+            break;\r
+        case 5:\r
+            builder.setType(ClearActions.class);\r
+            break;\r
+        case 6:\r
+            builder.setType(Meter.class);\r
+            break;\r
+        default:\r
+            throw new IllegalStateException("Unknown instruction type received, type: " + type);\r
+        }\r
+        return builder;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java
new file mode 100644 (file)
index 0000000..7b6319c
--- /dev/null
@@ -0,0 +1,25 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends InstructionBase> getType() {\r
+        return ApplyActions.class;\r
+    }\r
+\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java
new file mode 100644 (file)
index 0000000..7cb26fd
--- /dev/null
@@ -0,0 +1,42 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class ClearActionsInstructionDeserializer extends AbstractInstructionDeserializer {\r
+\r
+    @Override\r
+    public Instruction deserialize(ByteBuf input) {\r
+        InstructionBuilder builder = super.processHeader(input);\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);\r
+        ActionsInstructionBuilder actionsBuilder = \r
+                new ActionsInstructionBuilder();\r
+        List<Action> actions = new ArrayList<>();\r
+        actionsBuilder.setAction(actions);\r
+        builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());\r
+        return builder.build();\r
+    }\r
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java
new file mode 100644 (file)
index 0000000..d3ed865
--- /dev/null
@@ -0,0 +1,39 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class GoToTableInstructionDeserializer extends AbstractInstructionDeserializer {\r
+\r
+    @Override\r
+    public Instruction deserialize(ByteBuf input) {\r
+        InstructionBuilder builder = new InstructionBuilder();\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        builder.setType(GotoTable.class);\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder();\r
+        tableBuilder.setTableId(input.readUnsignedByte());\r
+        builder.addAugmentation(TableIdInstruction.class, tableBuilder.build());\r
+        input.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE);\r
+        return builder.build();\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java
new file mode 100644 (file)
index 0000000..074fff4
--- /dev/null
@@ -0,0 +1,38 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class MeterInstructionDeserializer extends AbstractInstructionDeserializer {\r
+\r
+    @Override\r
+    public Instruction deserialize(ByteBuf input) {\r
+        InstructionBuilder builder = new InstructionBuilder();\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        builder.setType(Meter.class);\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder();\r
+        meterBuilder.setMeterId(input.readUnsignedInt());\r
+        builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build());\r
+        return builder.build();\r
+    }\r
+\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java
new file mode 100644 (file)
index 0000000..311e5ea
--- /dev/null
@@ -0,0 +1,25 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class WriteActionsInstructionDeserializer extends AbstractActionInstructionDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends InstructionBase> getType() {\r
+        return WriteActions.class;\r
+    }\r
+\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java
new file mode 100644 (file)
index 0000000..2dce411
--- /dev/null
@@ -0,0 +1,44 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class WriteMetadataInstructionDeserializer extends AbstractInstructionDeserializer {\r
+\r
+    @Override\r
+    public Instruction deserialize(ByteBuf input) {\r
+        InstructionBuilder builder = new InstructionBuilder();\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        builder.setType(WriteMetadata.class);\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        input.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA);\r
+        MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder();\r
+        byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
+        input.readBytes(metadata);\r
+        metadataBuilder.setMetadata(metadata);\r
+        byte[] metadata_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
+        input.readBytes(metadata_mask);\r
+        metadataBuilder.setMetadataMask(metadata_mask);\r
+        builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build());\r
+        return builder.build();\r
+    }\r
+}\r
index eb343d43eee1cbc9e96c40e99b735c007dec30b2..ddb5ccd81c5dca0346e92bfe7c7cf111e2128011 100644 (file)
@@ -53,7 +53,7 @@ public class FlowModInputMessageFactory implements OFSerializer<FlowModInput>, S
         registry.<Match, OFSerializer<Match>>getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class))
             .serialize(message.getMatch(), outBuffer);
         ListSerializer.serializeList(message.getInstruction(), EnhancedTypeKeyMakerFactory
-                .createInstructionKeyBuilder(EncodeConstants.OF13_VERSION_ID), registry, outBuffer);
+                .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, outBuffer);
         ByteBufUtils.updateOFHeaderLength(outBuffer);
     }
 
index e4fb088e33e753ef85255c7c2f682ff98063275e..925e78dab8d43373d7fbe86c6663f52a2e5c7c54 100644 (file)
@@ -54,7 +54,7 @@ public class GroupModInputMessageFactory implements OFSerializer<GroupModInput>,
                 outBuffer.writeInt(currentBucket.getWatchGroup().intValue());
                 ByteBufUtils.padBuffer(PADDING_IN_BUCKET, outBuffer);
                 ListSerializer.serializeList(currentBucket.getAction(), EnhancedTypeKeyMakerFactory
-                        .createActionKeyBuilder(EncodeConstants.OF13_VERSION_ID), registry, outBuffer);
+                        .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, outBuffer);
                 outBuffer.setShort(bucketLengthIndex, outBuffer.writerIndex() - bucketLengthIndex);
             }
         }
index e671dc5baf6ca870f1b9bf27d504ba61c2e79273..31b2905143602f51718483e951e3bee8fb776e5d 100644 (file)
@@ -363,7 +363,7 @@ public class MultipartRequestInputFactory implements OFSerializer<MultipartReque
             padding = paddingNeeded(length);
             output.writeShort(length);
             EnhancedTypeKeyMaker<Instruction> keyMaker = EnhancedTypeKeyMakerFactory
-                    .createInstructionKeyBuilder(EncodeConstants.OF13_VERSION_ID);
+                    .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID);
             ListSerializer.serializeHeaderList(instructions, keyMaker, registry, output);
         } else {
             padding = paddingNeeded(length);
@@ -421,7 +421,7 @@ public class MultipartRequestInputFactory implements OFSerializer<MultipartReque
             padding += paddingNeeded(length);
             output.writeShort(length);
             EnhancedTypeKeyMaker<Action> keyMaker = EnhancedTypeKeyMakerFactory
-                    .createActionKeyBuilder(EncodeConstants.OF13_VERSION_ID);
+                    .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID);
             ListSerializer.serializeHeaderList(actions, keyMaker, registry, output);
         } else {
             padding = paddingNeeded(length);
index 2ab21093f94e629c2e234f0ee8af0b562c5bcf84..a85842c3777d8e95b286ae4aa84240acc3d24173 100644 (file)
@@ -49,7 +49,7 @@ public class OF10FlowModInputMessageFactory implements OFSerializer<FlowModInput
         outBuffer.writeShort(message.getOutPort().getValue().intValue());
         outBuffer.writeShort(createFlowModFlagsBitmask(message.getFlagsV10()));
         ListSerializer.serializeList(message.getAction(), EnhancedTypeKeyMakerFactory
-                .createActionKeyBuilder(EncodeConstants.OF10_VERSION_ID), registry, outBuffer);
+                .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, outBuffer);
         ByteBufUtils.updateOFHeaderLength(outBuffer);
     }
 
index 85a57c2e92ab1da3234eaea0f30d14279e6e5bca..68b54dd9b5d7017be635e645f5fd9acbb5138e47 100644 (file)
@@ -37,7 +37,7 @@ public class OF10PacketOutInputMessageFactory implements OFSerializer<PacketOutI
         outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
         int actionsStartIndex = outBuffer.writerIndex();
         ListSerializer.serializeList(message.getAction(), EnhancedTypeKeyMakerFactory
-                .createActionKeyBuilder(EncodeConstants.OF10_VERSION_ID), registry, outBuffer);
+                .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, outBuffer);
         outBuffer.setShort(actionsLengthIndex, outBuffer.writerIndex() - actionsStartIndex);
         byte[] data = message.getData();
         if (data != null) {
index a5620b8f70aa15118fcbb4e6dad66345fd097621..daea2ac586e46c16ccedbc0f98e642b8cf006fba 100644 (file)
@@ -41,7 +41,7 @@ public class PacketOutInputMessageFactory implements OFSerializer<PacketOutInput
         ByteBufUtils.padBuffer(PADDING_IN_PACKET_OUT_MESSAGE, outBuffer);
         int actionsStartIndex = outBuffer.writerIndex();
         ListSerializer.serializeList(message.getAction(), EnhancedTypeKeyMakerFactory
-                .createActionKeyBuilder(EncodeConstants.OF13_VERSION_ID), registry, outBuffer);
+                .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, outBuffer);
         outBuffer.setShort(actionsLengthIndex, outBuffer.writerIndex() - actionsStartIndex);
         byte[] data = message.getData();
         if (data != null) {
index b9f3c1ce62d8ec13fb895ba38a9623bb8b0835b2..d696d24ec442b5bb34ee747340caa07eab0ed905 100644 (file)
@@ -42,7 +42,7 @@ public abstract class AbstractActionInstructionSerializer extends AbstractInstru
             outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);\r
             ByteBufUtils.padBuffer(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION, outBuffer);\r
             ListSerializer.serializeList(actions, EnhancedTypeKeyMakerFactory\r
-                    .createActionKeyBuilder(EncodeConstants.OF13_VERSION_ID), getRegistry(), outBuffer);\r
+                    .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), getRegistry(), outBuffer);\r
             int instructionLength = outBuffer.writerIndex() - startIndex;\r
             outBuffer.setShort(lengthIndex, instructionLength);\r
         } else {\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java
new file mode 100644 (file)
index 0000000..490251c
--- /dev/null
@@ -0,0 +1,35 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ * @param <T> type the key maker is based on \r
+ */\r
+public abstract class AbstractCodeKeyMaker implements CodeKeyMaker {\r
+\r
+    private short version;\r
+\r
+    /**\r
+     * @param version openflow wire version\r
+     */\r
+    public AbstractCodeKeyMaker(short version) {\r
+        this.version = version;\r
+        \r
+    }\r
+\r
+    /**\r
+     * @return the version\r
+     */\r
+    public short getVersion() {\r
+        return version;\r
+    }\r
+\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java
new file mode 100644 (file)
index 0000000..bd5fff2
--- /dev/null
@@ -0,0 +1,26 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ */\r
+public interface CodeKeyMaker {\r
+\r
+    /**\r
+     * @param input buffer that will be the needed data gathered from\r
+     * @return key for deserializer lookup\r
+     */\r
+    public abstract MessageCodeKey make(ByteBuf input);\r
+\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java
new file mode 100644 (file)
index 0000000..f400212
--- /dev/null
@@ -0,0 +1,72 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class CodeKeyMakerFactory {\r
+\r
+    /**\r
+     * @param version\r
+     * @return\r
+     */\r
+    public static CodeKeyMaker createMatchEntriesKeyMaker(short version) {\r
+        return new AbstractCodeKeyMaker(version) {\r
+            @Override\r
+            public MessageCodeKey make(ByteBuf input) {\r
+                int oxmClass = input.getUnsignedShort(input.readerIndex());\r
+                int oxmField = input.getUnsignedByte(input.readerIndex()\r
+                        + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;\r
+                return new EnhancedMessageCodeKey(getVersion(), oxmClass,\r
+                        oxmField, MatchEntries.class);\r
+            }\r
+        };\r
+    }\r
+\r
+    /**\r
+     * @param version\r
+     * @return\r
+     */\r
+    public static CodeKeyMaker createActionsKeyMaker(short version) {\r
+        return new AbstractCodeKeyMaker(version) {\r
+            @Override\r
+            public MessageCodeKey make(ByteBuf input) {\r
+                // EncodeConstants.EMPTY_VALUE used as temporary value\r
+                // until action deserializers are split\r
+//                int type = input.getUnsignedShort(input.readerIndex());\r
+//                return new MessageCodeKey(getVersion(), type, Action.class);\r
+                return new MessageCodeKey(getVersion(), EncodeConstants.EMPTY_VALUE, Action.class);\r
+            }\r
+        };\r
+    }\r
+\r
+    /**\r
+     * @param version\r
+     * @return\r
+     */\r
+    public static CodeKeyMaker createInstructionsKeyMaker(short version) {\r
+        return new AbstractCodeKeyMaker(version) {\r
+            @Override\r
+            public MessageCodeKey make(ByteBuf input) {\r
+                int type = input.getUnsignedShort(input.readerIndex());\r
+                return new MessageCodeKey(getVersion(), type, Instruction.class);\r
+            }\r
+        };\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/DecodingUtils.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/DecodingUtils.java
deleted file mode 100644 (file)
index 1f03295..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*\r
- * Copyright (c) 2013 Pantheon Technologies s.r.o. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public abstract class DecodingUtils {\r
-\r
-    /**\r
-     * Deserializes lists of actions or instructions\r
-     * @param length length of list (in bytes)\r
-     * @param input input bytebuf\r
-     * @param deserializer \r
-     *  false in case of whole body deserialization\r
-     * @return List of actions or instructions\r
-     */\r
-    @SuppressWarnings("unchecked")\r
-    public static <E extends DataObject> List<E> deserializeList(int length, ByteBuf input,\r
-            OFGeneralDeserializer deserializer) {\r
-        List<E> list = new ArrayList<>();\r
-        int startIndex = input.readerIndex();\r
-        OFDeserializer<E> actionsDeserializer = (OFDeserializer<E>) deserializer;\r
-        while ((input.readerIndex() - startIndex) < length) {\r
-            list.add(actionsDeserializer.deserialize(input));\r
-        }\r
-        return list;\r
-    }\r
-\r
-    /**\r
-     * Deserializes action or instruction headers\r
-     * @param length length of list (in bytes)\r
-     * @param input input bytebuf\r
-     * @param deserializer \r
-     *  false in case of whole body deserialization\r
-     * @return List of action or instruction headers\r
-     */\r
-    @SuppressWarnings("unchecked")\r
-    public static <E extends DataObject> List<E> deserializeHeaders(int length, ByteBuf input,\r
-            OFGeneralDeserializer deserializer) {\r
-        List<E> list = new ArrayList<>();\r
-        int startIndex = input.readerIndex();\r
-        HeaderDeserializer<E> instructionsDeserializer = (HeaderDeserializer<E>) deserializer;\r
-        while ((input.readerIndex() - startIndex) < length) {\r
-            list.add(instructionsDeserializer.deserializeHeader(input));\r
-        }\r
-        return list;\r
-    }\r
-\r
-    /**\r
-     * Deserializes match entry headers\r
-     * @param length length of list (in bytes)\r
-     * @param input input bytebuf\r
-     * @param registry registry with deserializers\r
-     *  false in case of whole body deserialization\r
-     * @return List of match entry headers\r
-     */\r
-    public static List<MatchEntries> deserializeMatchEntryHeaders(int length, ByteBuf input,\r
-            DeserializerRegistry registry) {\r
-        List<MatchEntries> list = new ArrayList<>();\r
-        int startIndex = input.readerIndex();\r
-        while ((input.readerIndex() - startIndex) < length) {\r
-            int oxmClass = input.getUnsignedShort(input.readerIndex());\r
-            int oxmField = input.getUnsignedByte(input.readerIndex()\r
-                    + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >> 1;\r
-        HeaderDeserializer<MatchEntries> deserializer = registry.getDeserializer(\r
-                new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, oxmClass,\r
-                        oxmField, MatchEntries.class));\r
-        list.add(deserializer.deserializeHeader(input));\r
-        }\r
-        return list;\r
-    }\r
-\r
-    /**\r
-     * Deserializes list of match entries\r
-     * @param length length of list (in bytes)\r
-     * @param input input bytebuf\r
-     * @param registry registry with deserializers\r
-     *  false in case of whole body deserialization\r
-     * @return List of match entries\r
-     */\r
-    public static List<MatchEntries> deserializeMatchEntries(int length, ByteBuf input,\r
-            DeserializerRegistry registry) {\r
-        List<MatchEntries> list = new ArrayList<>();\r
-        int startIndex = input.readerIndex();\r
-        while ((input.readerIndex() - startIndex) < length) {\r
-            int oxmClass = input.getUnsignedShort(input.readerIndex());\r
-            int oxmField = input.getUnsignedByte(input.readerIndex()\r
-                    + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >> 1;\r
-        OFDeserializer<MatchEntries> deserializer = registry.getDeserializer(\r
-                new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, oxmClass,\r
-                        oxmField, MatchEntries.class));\r
-        list.add(deserializer.deserialize(input));\r
-        }\r
-        return list;\r
-    }\r
-}\r
index 7c8e80e7b0f23a7a28641c87bf6707dfd1bb4969..08a9b5ec8c33dff058168910f69541787ab65c7e 100644 (file)
@@ -24,7 +24,7 @@ public abstract class EnhancedTypeKeyMakerFactory {
      *  in lookup key\r
      * @return lookup key\r
      */\r
-    public static EnhancedTypeKeyMaker<MatchEntries> createMatchEntriesKeyBuilder(short version) {\r
+    public static EnhancedTypeKeyMaker<MatchEntries> createMatchEntriesKeyMaker(short version) {\r
         return new AbstractEnhancedTypeKeyMaker<MatchEntries>(version) {\r
             @Override\r
             public EnhancedMessageTypeKey<?, ?> make(MatchEntries entry) {\r
@@ -39,7 +39,7 @@ public abstract class EnhancedTypeKeyMakerFactory {
      *  in lookup key\r
      * @return lookup key\r
      */\r
-    public static EnhancedTypeKeyMaker<Action> createActionKeyBuilder(short version) {\r
+    public static EnhancedTypeKeyMaker<Action> createActionKeyMaker(short version) {\r
         return new AbstractEnhancedTypeKeyMaker<Action>(version) {\r
             @Override\r
             public EnhancedMessageTypeKey<?, ?> make(Action entry) {\r
@@ -53,7 +53,7 @@ public abstract class EnhancedTypeKeyMakerFactory {
      *  in lookup key\r
      * @return lookup key\r
      */\r
-    public static EnhancedTypeKeyMaker<Instruction> createInstructionKeyBuilder(short version) {\r
+    public static EnhancedTypeKeyMaker<Instruction> createInstructionKeyMaker(short version) {\r
         return new AbstractEnhancedTypeKeyMaker<Instruction>(version) {\r
             @Override\r
             public EnhancedMessageTypeKey<?, ?> make(Instruction entry) {\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializer.java
deleted file mode 100644 (file)
index 820c7fa..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.util;
-
-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.HeaderDeserializer;
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
-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;
-
-/**
- * Deserializes ofp_instruction (OpenFlow v1.3) structures
- * @author michal.polkorab
- * @author timotej.kubas
- */
-public class InstructionsDeserializer implements OFDeserializer<Instruction>,
-        HeaderDeserializer<Instruction>, DeserializerRegistryInjector {
-    
-    private static final byte WRITE_APPLY_CLEAR_ACTION_LENGTH = 8;
-    private static final byte GOTO_TABLE_PADDING = 3;
-    private static final byte WRITE_METADATA_PADDING = 4;
-    private static final byte ACTIONS_RELATED_INSTRUCTION_PADDING = 4;
-    private DeserializerRegistry registry;
-
-    @Override
-    public Instruction deserialize(ByteBuf input) {
-        InstructionBuilder builder = new InstructionBuilder();
-        int type = input.readUnsignedShort();
-        switch (type) {
-        case 1:
-            createGotoTableInstruction(builder, input);
-            break;
-        case 2:
-            createMetadataInstruction(builder, input);
-            break;
-        case 3:
-            builder.setType(WriteActions.class);
-            createActionRelatedInstruction(input, builder);
-            break;
-        case 4:
-            builder.setType(ApplyActions.class);
-            createActionRelatedInstruction(input, builder);
-            break;
-        case 5:
-            builder.setType(ClearActions.class);
-            createActionRelatedInstruction(input, builder);
-            break;
-        case 6:
-            builder.setType(Meter.class);
-            input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-            MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder();
-            meterBuilder.setMeterId(input.readUnsignedInt());
-            builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build());
-            break;
-        case 65535:
-            builder.setType(Experimenter.class);
-            OFDeserializer<ExperimenterInstruction> deserializer = registry.getDeserializer(
-                    new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, type, ExperimenterInstruction.class));
-            ExperimenterInstruction expInstruction = deserializer.deserialize(input);
-            builder.addAugmentation(ExperimenterInstruction.class, expInstruction);
-            break;
-        default:
-            break;
-        }
-        return builder.build();
-    }
-
-    @Override
-    public Instruction deserializeHeader(ByteBuf input) {
-        InstructionBuilder builder = new InstructionBuilder();
-        int type = input.readUnsignedShort();
-        switch (type) {
-        case 1:
-            builder.setType(GotoTable.class);
-            break;
-        case 2:
-            builder.setType(WriteMetadata.class);
-            break;
-        case 3:
-            builder.setType(WriteActions.class);
-            break;
-        case 4:
-            builder.setType(ApplyActions.class);
-            break;
-        case 5:
-            builder.setType(ClearActions.class);
-            break;
-        case 6:
-            builder.setType(Meter.class);
-            break;
-        case 65535:
-            builder.setType(Experimenter.class);
-            ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();
-            expBuilder.setExperimenter(input.readUnsignedInt());
-            builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());
-            break;
-        default:
-            break;
-        }
-        return builder.build();
-    }
-
-    private static void createGotoTableInstruction(InstructionBuilder builder,
-            ByteBuf input) {
-        builder.setType(GotoTable.class);
-        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-        TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder();
-        tableBuilder.setTableId(input.readUnsignedByte());
-        builder.addAugmentation(TableIdInstruction.class, tableBuilder.build());
-        input.skipBytes(GOTO_TABLE_PADDING);
-    }
-    
-    private static void createMetadataInstruction(InstructionBuilder builder,
-            ByteBuf input) {
-        builder.setType(WriteMetadata.class);
-        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-        input.skipBytes(WRITE_METADATA_PADDING);
-        MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder();
-        byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
-        input.readBytes(metadata);
-        metadataBuilder.setMetadata(metadata);
-        byte[] metadata_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
-        input.readBytes(metadata_mask);
-        metadataBuilder.setMetadataMask(metadata_mask);
-        builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build());
-    }
-    
-    private void createActionRelatedInstruction(ByteBuf input, InstructionBuilder builder) {
-        int instructionLength = input.readUnsignedShort();
-        input.skipBytes(ACTIONS_RELATED_INSTRUCTION_PADDING);
-        ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder();
-        OFDeserializer<Action> deserializer = registry.getDeserializer(new MessageCodeKey(
-                EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Action.class));
-        List<Action> actions = DecodingUtils.deserializeList(
-                instructionLength - WRITE_APPLY_CLEAR_ACTION_LENGTH, input, deserializer);
-        actionsBuilder.setAction(actions);
-        builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
-    }
-
-    @Override
-    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
-        registry = deserializerRegistry;
-    }
-}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java
new file mode 100644 (file)
index 0000000..160f3be
--- /dev/null
@@ -0,0 +1,74 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class ListDeserializer {\r
+\r
+    /**\r
+     * Deserializes items into list\r
+     * @param version openflow wire version\r
+     * @param length length of list in ByteBuf (bytes)\r
+     * @param input input buffer\r
+     * @param keyMaker creates keys for deserializer lookup\r
+     * @param registry stores deserializers\r
+     * @return list of items\r
+     */\r
+    public static <E extends DataObject> List<E> deserializeList(short version, int length,\r
+            ByteBuf input, CodeKeyMaker keyMaker, DeserializerRegistry registry) {\r
+        List<E> items = null;\r
+        if (input.readableBytes() > 0) {\r
+            items = new ArrayList<>();\r
+            int startIndex = input.readerIndex();\r
+            while ((input.readerIndex() - startIndex) < length){\r
+                OFDeserializer<E> deserializer = registry.getDeserializer(keyMaker.make(input));\r
+                E item = deserializer.deserialize(input);\r
+                items.add(item);\r
+            }\r
+        }\r
+        return items;\r
+    }\r
+\r
+    /**\r
+     * Deserializes headers of items into list\r
+     * @param version openflow wire version\r
+     * @param length length of list in ByteBuf (bytes)\r
+     * @param input input buffer\r
+     * @param keyMaker creates keys for deserializer lookup\r
+     * @param registry stores deserializers\r
+     * @return list of items\r
+     */\r
+    public static <E extends DataObject> List<E> deserializeHeaders(short version, int length,\r
+            ByteBuf input, CodeKeyMaker keyMaker, DeserializerRegistry registry) {\r
+        List<E> items = null;\r
+        if (input.readableBytes() > 0) {\r
+            items = new ArrayList<>();\r
+            int startIndex = input.readerIndex();\r
+            while ((input.readerIndex() - startIndex) < length){\r
+                HeaderDeserializer<E> deserializer = registry.getDeserializer(keyMaker.make(input));\r
+                E item = deserializer.deserializeHeader(input);\r
+                items.add(item);\r
+            }\r
+        }\r
+        return items;\r
+    }\r
+}\r
index 0128c99754110fa9c6cf945857e172f4f95f88a9..e33a1c487426d6e9232b8f0c0a94c72e635ea782 100644 (file)
@@ -10,6 +10,8 @@ package org.opendaylight.openflowjava.protocol.impl.util;
 
 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;
@@ -17,6 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
 
 /**
  * Deserializes ofp_match (OpenFlow v1.3) and its oxm_fields structures
@@ -44,8 +47,11 @@ public class MatchDeserializer implements OFDeserializer<Match>,
             default:
                 break;
             }
-            builder.setMatchEntries(DecodingUtils.deserializeMatchEntries(
-                    length - 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES, input, registry));
+            CodeKeyMaker keyMaker = CodeKeyMakerFactory
+                    .createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
+            List<MatchEntries> entries = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
+                    length - 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES, input, keyMaker, registry);
+            builder.setMatchEntries(entries);
             int paddingRemainder = length % EncodeConstants.PADDING;
             if (paddingRemainder != 0) {
                 input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
@@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeseria
  * @author michal.polkorab\r
  *\r
  */\r
-public class MessageDeserializerRegistryHelper {\r
+public class SimpleDeserializerRegistryHelper {\r
 \r
     private short version;\r
     private DeserializerRegistry registry;\r
@@ -24,7 +24,7 @@ public class MessageDeserializerRegistryHelper {
      * @param version wire protocol version\r
      * @param deserializerRegistry registry to be filled with message deserializers\r
      */\r
-    public MessageDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) {\r
+    public SimpleDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) {\r
         this.version = version;\r
         this.registry = deserializerRegistry;\r
     }\r
@@ -35,7 +35,7 @@ public class MessageDeserializerRegistryHelper {
      *  by given deserializer\r
      * @param deserializer deserializer instance\r
      */\r
-    public void registerMessageDeserializer(int code,\r
+    public void registerDeserializer(int code,\r
             Class<?> deserializedObjectClass, OFGeneralDeserializer deserializer) {\r
         registry.registerDeserializer(new MessageCodeKey(version, code,\r
                 deserializedObjectClass), deserializer);\r
index 02aaabb2aaa07e3e28cb3acdcaa5d80045be5f25..440a57d7d97d62d677a8b0c769f238437e05f280 100644 (file)
@@ -15,8 +15,6 @@ import org.junit.Assert;
 import org.junit.Before;\r
 import org.junit.Test;\r
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;\r
@@ -40,18 +38,15 @@ public class ActionsDeserializerTest {
 \r
     private static final Logger LOGGER = LoggerFactory\r
             .getLogger(ActionsDeserializerTest.class);\r
-    private OFDeserializer<Action> actionDeserializer;\r
+    private DeserializerRegistry registry;\r
 \r
     /**\r
      * Initializes deserializer registry and lookups correct deserializer\r
      */\r
     @Before\r
     public void startUp() {\r
-        DeserializerRegistry registry = new DeserializerRegistryImpl();\r
+        registry = new DeserializerRegistryImpl();\r
         registry.init();\r
-        actionDeserializer = registry.getDeserializer(\r
-                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,\r
-                        EncodeConstants.EMPTY_VALUE, Action.class));\r
     }\r
 \r
     /**\r
@@ -79,9 +74,9 @@ public class ActionsDeserializerTest {
         message.skipBytes(4); // skip XID\r
         LOGGER.info("bytes: " + message.readableBytes());\r
         \r
-        \r
-        List<Action> actions = DecodingUtils.deserializeList(message.readableBytes(),\r
-                message, actionDeserializer);\r
+        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+        List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,\r
+                message.readableBytes(), message, keyMaker, registry);\r
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
                 + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName());\r
         Assert.assertEquals("Wrong action port", 1,\r
index 53e95088fa7b80c6c0f84f74df9e09f3711b65e4..1d7231d057b874597ab6f6572647aae67c209f84 100644 (file)
@@ -15,8 +15,6 @@ import org.junit.Assert;
 import org.junit.Before;\r
 import org.junit.Test;\r
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;\r
@@ -36,18 +34,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
  */\r
 public class InstructionsDeserializerTest {\r
 \r
-    private OFDeserializer<Instruction> insDeserializer;\r
+\r
+    private DeserializerRegistry registry;\r
 \r
     /**\r
      * Initializes deserializer registry and lookups correct deserializer\r
      */\r
     @Before\r
     public void startUp() {\r
-        DeserializerRegistry registry = new DeserializerRegistryImpl();\r
+        registry = new DeserializerRegistryImpl();\r
         registry.init();\r
-        insDeserializer = registry.getDeserializer(\r
-                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,\r
-                        EncodeConstants.EMPTY_VALUE, Instruction.class));\r
     }\r
 \r
     /**\r
@@ -62,8 +58,9 @@ public class InstructionsDeserializerTest {
         \r
         message.skipBytes(4); // skip XID\r
         \r
-        List<Instruction> instructions = DecodingUtils.deserializeList(\r
-                message.readableBytes(), message, insDeserializer);\r
+        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+        List<Instruction> instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,\r
+                message.readableBytes(), message, keyMaker, registry);\r
         Instruction i1 = instructions.get(0);\r
         Assert.assertEquals("Wrong type - i1", "org.opendaylight.yang.gen.v1.urn."\r
                 + "opendaylight.openflow.common.instruction.rev130731.GotoTable", i1.getType().getName());\r
index af7ee7aadd28206f7b7a65b406e8f8c716c70f83..9da4762951b729247df149d59306c88f7ec03647 100644 (file)
@@ -15,8 +15,6 @@ import org.junit.Assert;
 import org.junit.Before;\r
 import org.junit.Test;\r
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;\r
@@ -35,18 +33,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
  */\r
 public class OF10ActionsDeserializerTest {\r
 \r
-    private OFDeserializer<Action> actionsDeserializer;\r
+    private DeserializerRegistry registry;\r
 \r
     /**\r
      * Initializes deserializer registry and lookups correct deserializer\r
      */\r
     @Before\r
     public void startUp() {\r
-        DeserializerRegistry registry = new DeserializerRegistryImpl();\r
+        registry = new DeserializerRegistryImpl();\r
         registry.init();\r
-        actionsDeserializer = registry.getDeserializer(\r
-                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE,\r
-                        Action.class));\r
     }\r
 \r
     /**\r
@@ -68,8 +63,9 @@ public class OF10ActionsDeserializerTest {
                 + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30");\r
         \r
         message.skipBytes(4); // skip XID\r
-        List<Action> actions = DecodingUtils.deserializeList(message.readableBytes(),\r
-                message, actionsDeserializer);\r
+        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);\r
+        List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID,\r
+                message.readableBytes(), message, keyMaker, registry);\r
         Assert.assertEquals("Wrong number of actions", 12, actions.size());\r
         Action action1 = actions.get(0);\r
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight"\r
index b2d814c70c45f8264e1117581b9897361a2ffdb4..b1cd11bb79e70de59c5da8a8ff029032ac1a1287 100644 (file)
@@ -170,7 +170,7 @@ public class OF10ActionsSerializerTest {
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
         ListSerializer.serializeList(actions, EnhancedTypeKeyMakerFactory\r
-                .createActionKeyBuilder(EncodeConstants.OF10_VERSION_ID), registry, out);\r
+                .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, out);\r
         \r
         Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());\r
         Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());\r
index 9b9d30a30e0ec2725ae0f5ee46d8b5717f3f96e7..0e14df0b6339fc1ce5e7fee9f09c50926a6843c4 100644 (file)
@@ -194,7 +194,7 @@ public class OF13ActionsSerializerTest {
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
         ListSerializer.serializeList(actions, EnhancedTypeKeyMakerFactory\r
-                .createActionKeyBuilder(EncodeConstants.OF13_VERSION_ID), registry, out);\r
+                .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out);\r
         \r
         Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());\r
         Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());\r
index 5dc7b2a48f04ea24e0f9ffebbcd5e37264b253a9..329559de5d3893f89f91701d030bf708d431cd45 100644 (file)
@@ -143,7 +143,7 @@ public class OF13InstructionsSerializerTest {
         \r
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
         ListSerializer.serializeList(instructions, EnhancedTypeKeyMakerFactory\r
-                .createInstructionKeyBuilder(EncodeConstants.OF13_VERSION_ID), registry, out);\r
+                .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out);\r
         \r
         Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort());\r
         Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort());\r