Extensibility support (deserialization part) 00/6000/6
authorMichal Polkorab <michal.polkorab@pantheon.sk>
Wed, 9 Apr 2014 06:19:47 +0000 (08:19 +0200)
committerMichal Polkorab <michal.polkorab@pantheon.sk>
Thu, 17 Apr 2014 12:50:48 +0000 (14:50 +0200)
Signed-off-by: Michal Polkorab <michal.polkorab@pantheon.sk>
Change-Id: Ic73091b01614e76087b30ad79dbf9b6f8b39545c

144 files changed:
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java [new file with mode: 0644]
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java [new file with mode: 0644]
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java [new file with mode: 0644]
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java [new file with mode: 0644]
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java [new file with mode: 0644]
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java [moved from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/OFDeserializer.java with 59% similarity]
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DecoderTable.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKey.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKey.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactory.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/factories/OF10VendorMessageFactory.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/DecodingUtils.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EncodeConstants.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializer.java
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/MatchEntryDeserializerRegistryHelper.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MessageDeserializerRegistryHelper.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OxmMatchConstants.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java [deleted file]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java [new file with mode: 0644]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10VendorMessageFactoryTest.java [deleted file]
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java
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/BufferHelper.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtilsTest.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/MatchDeserializerTest.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/OF10MatchDeserializerTest.java
openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/IntegrationTest.java
openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java

diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java
new file mode 100644 (file)
index 0000000..665fa57
--- /dev/null
@@ -0,0 +1,34 @@
+/*\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.api.extensibility;\r
+\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public interface DeserializerRegistry {\r
+\r
+    /**\r
+     * Initializes deserializers\r
+     */\r
+    public void init();\r
+\r
+    /**\r
+     * @param key used for deserializer lookup\r
+     * @return deserializer found\r
+     */\r
+    public <SERIALIZER_TYPE extends OFGeneralDeserializer>\r
+            SERIALIZER_TYPE getDeserializer(MessageCodeKey key);\r
+\r
+    /**\r
+     * @param key used to registry lookup\r
+     * @param deserializer deserializer instance\r
+     */\r
+    public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer);\r
+}\r
diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java
new file mode 100644 (file)
index 0000000..5f029a2
--- /dev/null
@@ -0,0 +1,21 @@
+/*\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.api.extensibility;\r
+\r
+/**\r
+ * Injects registry\r
+ * @author michal.polkorab\r
+ */\r
+public interface DeserializerRegistryInjector {\r
+\r
+    /**\r
+     * Injects deserializer registry into deserializer\r
+     * @param deserializerRegistry\r
+     */\r
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry);\r
+}\r
diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java
new file mode 100644 (file)
index 0000000..509c386
--- /dev/null
@@ -0,0 +1,48 @@
+/*\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.api.extensibility;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class EnhancedMessageCodeKey extends MessageCodeKey {\r
+\r
+    private int msgType2;\r
+\r
+    /**\r
+     * Constructor\r
+     * @param version wire protocol version\r
+     * @param value used as distinguisher\r
+     * @param value2 used as detailed distinguisher\r
+     * @param clazz class of object that is going to be deserialized\r
+     */\r
+    public EnhancedMessageCodeKey(short version, int value, int value2, Class<?> clazz) {\r
+        super(version, value, clazz);\r
+        this.msgType2 = value2;\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        if (this == obj)\r
+            return true;\r
+        if (!super.equals(obj))\r
+            return false;\r
+        if (getClass() != obj.getClass())\r
+            return false;\r
+        EnhancedMessageCodeKey other = (EnhancedMessageCodeKey) obj;\r
+        if (msgType2 != other.msgType2)\r
+            return false;\r
+        return true;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return super.toString() + " msgType2: " + msgType2;\r
+    }\r
+}\r
diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java
new file mode 100644 (file)
index 0000000..205c769
--- /dev/null
@@ -0,0 +1,27 @@
+/*\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.api.extensibility;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ * @param <E> \r
+ */\r
+public interface HeaderDeserializer<E extends DataObject> extends OFGeneralDeserializer {\r
+\r
+    /**\r
+     * Deserializes byte message headers\r
+     * \r
+     * @param rawMessage message as bytes in ByteBuf\r
+     * @return POJO/DTO\r
+     */\r
+    public E deserializeHeader(ByteBuf rawMessage);\r
+}\r
diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java
new file mode 100644 (file)
index 0000000..5ebcde2
--- /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
+package org.opendaylight.openflowjava.protocol.api.extensibility;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ */\r
+public class MessageCodeKey {\r
+\r
+    private short msgVersion;\r
+    private int msgType;\r
+    private Class<?> clazz;\r
+\r
+    /**\r
+     * Constructor\r
+     * @param version wire protocol version\r
+     * @param value used as distinguisher\r
+     * @param clazz class of object that is going to be deserialized\r
+     */\r
+    public MessageCodeKey(short version, int value, Class<?> clazz) {\r
+        this.msgVersion = version;\r
+        this.msgType = value;\r
+        this.clazz = clazz;\r
+    }\r
+\r
+    @Override\r
+    public int hashCode() {\r
+        final int prime = 31;\r
+        int result = 1;\r
+        result = prime * result + ((clazz == null) ? 0 : clazz.hashCode());\r
+        result = prime * result + msgType;\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        if (this == obj)\r
+            return true;\r
+        if (obj == null)\r
+            return false;\r
+        if (getClass() != obj.getClass())\r
+            return false;\r
+        MessageCodeKey other = (MessageCodeKey) obj;\r
+        if (clazz == null) {\r
+            if (other.clazz != null)\r
+                return false;\r
+        } else if (!clazz.equals(other.clazz))\r
+            return false;\r
+        if (msgType != other.msgType)\r
+            return false;\r
+        if (msgVersion != other.msgVersion)\r
+            return false;\r
+        return true;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return "msgVersion: " + msgVersion + " class: " + clazz.getName() + " msgType: " + msgType;\r
+    }\r
+}\r
@@ -6,28 +6,25 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.openflowjava.protocol.impl.deserialization;
-
-import org.opendaylight.yangtools.yang.binding.DataObject;
+package org.opendaylight.openflowjava.protocol.api.extensibility;
 
 import io.netty.buffer.ByteBuf;
 
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
 /**
  * Uniform interface for deserializing factories
  * @author michal.polkorab
  * @author timotej.kubas
  * @param <E> message code type
  */
-public interface OFDeserializer<E extends DataObject> {
+public interface OFDeserializer<E extends DataObject> extends OFGeneralDeserializer {
 
     /**
      * Transforms byte message into POJO/DTO (of type E).
-     * Assumes that input ByteBuf's readerIndex is pointing on length in OpenFlow header
      * 
-     * @param rawMessage message as bytes in ByteBuf
-     * @param version version of used OF Protocol
-     * @return HelloMessage as DataObject
+     * @param message message as bytes in ByteBuf
+     * @return POJO/DTO
      */
-    public abstract E bufferToMessage(ByteBuf rawMessage, short version);
-
+    public E deserialize(ByteBuf message);
 }
diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralDeserializer.java
new file mode 100644 (file)
index 0000000..bedb267
--- /dev/null
@@ -0,0 +1,17 @@
+/*\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.api.extensibility;\r
+\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ */\r
+public interface OFGeneralDeserializer {\r
+\r
+    // empty unifying interface\r
+}\r
index a8bceeeac2156806be8331f72bc8173579a07d3d..e1dabb49eab268478d0ec43df34b1414a743421e 100644 (file)
@@ -15,9 +15,14 @@ import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHan
 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.slf4j.Logger;
@@ -40,6 +45,8 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider {
     private ConnectionConfiguration connConfig;
     private SerializationFactory serializationFactory;
     private SerializerRegistry serializerRegistry;
+    private DeserializerRegistry deserializerRegistry;
+    private DeserializationFactory deserializationFactory;
 
     /** Constructor */
     public SwitchConnectionProviderImpl() {
@@ -47,6 +54,10 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider {
         serializerRegistry.init();
         serializationFactory = new SerializationFactory();
         serializationFactory.setSerializerTable(serializerRegistry);
+        deserializerRegistry = new DeserializerRegistryImpl();
+        deserializerRegistry.init();
+        deserializationFactory = new DeserializationFactory();
+        deserializationFactory.setRegistry(deserializerRegistry);
     }
 
     @Override
@@ -106,6 +117,7 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider {
         boolean tlsSupported = FEATURE_SUPPORT.REQUIRED.equals(connConfig.getTlsSupport());
         server.setEncryption(tlsSupported);
         server.setSerializationFactory(serializationFactory);
+        server.setDeserializationFactory(deserializationFactory);
         return server;
     }
 
@@ -122,6 +134,12 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider {
         serializerRegistry.registerSerializer(key, serializer);
     }
 
+    @Override
+    public void registerDeserializer(MessageCodeKey key,
+            OFGeneralDeserializer deserializer) {
+        deserializerRegistry.registerDeserializer(key, deserializer);
+    }
+
     @Override
     public void close() throws Exception {
         shutdown();
index 9c706a8848712ecf87a439054cec2dbda98c611d..a1f9fb948bc69aab821c931127fc1a9c8d043c65 100644 (file)
@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
 public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class);
+    private DeserializationFactory deserializationFactory;
 
     /**
      * Constructor of class
@@ -43,7 +44,7 @@ public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
         }
         DataObject dataObject = null;
         try {
-            dataObject = DeserializationFactory.bufferToMessage(msg.getMessageBuffer(),
+            dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),
                     msg.getVersion());
         } catch(Exception e) {
             LOGGER.error("Message deserialization failed");
@@ -57,4 +58,12 @@ public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
         msg.getMessageBuffer().release();
         out.add(dataObject);
     }
+
+    /**
+     * @param deserializationFactory
+     */
+    public void setDeserializationFactory(DeserializationFactory deserializationFactory) {
+        this.deserializationFactory = deserializationFactory;
+    }
+
 }
index 5a35864b4184f429daa3585dbdb7208090ba5fd3..184aec137df3414ee55e3952dad6c4ea6be7e6a1 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterF
 import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade;
 import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -38,6 +39,7 @@ public class PublishingChannelInitializer extends ChannelInitializer<SocketChann
     private long switchIdleTimeout;
     private boolean encryption;
     private SerializationFactory serializationFactory;
+    private DeserializationFactory deserializationFactory;
 
     /**
      * default ctor
@@ -75,7 +77,9 @@ public class PublishingChannelInitializer extends ChannelInitializer<SocketChann
             }
             ch.pipeline().addLast(COMPONENT_NAMES.OF_FRAME_DECODER.name(), new OFFrameDecoder());
             ch.pipeline().addLast(COMPONENT_NAMES.OF_VERSION_DETECTOR.name(), new OFVersionDetector());
-            ch.pipeline().addLast(COMPONENT_NAMES.OF_DECODER.name(), new OFDecoder());
+            OFDecoder ofDecoder = new OFDecoder();
+            ofDecoder.setDeserializationFactory(deserializationFactory);
+            ch.pipeline().addLast(COMPONENT_NAMES.OF_DECODER.name(), ofDecoder);
             OFEncoder ofEncoder = new OFEncoder();
             ofEncoder.setSerializationFactory(serializationFactory);
             ch.pipeline().addLast(COMPONENT_NAMES.OF_ENCODER.name(), ofEncoder);
@@ -130,4 +134,12 @@ public class PublishingChannelInitializer extends ChannelInitializer<SocketChann
     public void setSerializationFactory(SerializationFactory serializationFactory) {
         this.serializationFactory = serializationFactory;
     }
+    
+    /**
+     * @param deserializationFactory
+     */
+    public void setDeserializationFactory(DeserializationFactory deserializationFactory) {
+        this.deserializationFactory = deserializationFactory;
+    }
+
 }
index 4e9b2bfd3e946c4b28bfda7dc9244fad903c7e11..2b5f6792c3638c40690ebd2fea2a163f4eb865cb 100644 (file)
@@ -23,6 +23,7 @@ import java.net.InetSocketAddress;
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
 import org.opendaylight.openflowjava.protocol.impl.connection.ServerFacade;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -224,11 +225,19 @@ public class TcpHandler implements ServerFacade {
     public void setEncryption(boolean tlsSupported) {
         channelInitializer.setEncryption(tlsSupported);
     }
-    
+
     /**
      * @param sf serialization factory
      */
     public void setSerializationFactory(SerializationFactory sf) {
         channelInitializer.setSerializationFactory(sf);
     }
+
+    /**
+     * @param factory
+     */
+    public void setDeserializationFactory(DeserializationFactory factory) {
+        channelInitializer.setDeserializationFactory(factory);
+    }
+
 }
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DecoderTable.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DecoderTable.java
deleted file mode 100644 (file)
index 759cb13..0000000
+++ /dev/null
@@ -1,144 +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.deserialization;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ExperimenterMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowRemovedMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10VendorMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketInMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-
-/**
- * Stores and provides correct decoders for received messages
- * @author michal.polkorab
- * 
- *  <pre>         
- *  Type   Message
- *   0: HELLO
- *   1: ERROR
- *   2: ECHO_REQUEST
- *   3: ECHO_REPLY
- *   4: EXPERIMENTER
- *   5: FEATURES_REQUEST
- *   6: FEATURES_REPLY
- *   7: GET_CONFIG_REQUEST
- *   8: GET_CONFIG_REPLY
- *   9: SET_CONFIG
- *   10: PACKET_IN
- *   11: FLOW_REMOVED
- *   12: PORT_STATUS
- *   13: PACKET_OUT
- *   14: FLOW_MOD
- *   15: GROUP_MOD
- *   16: PORT_MOD
- *   17: TABLE_MOD
- *   18: MULTIPART_REQUEST
- *   19: MULTIPART_REPLY
- *   20: BARRIER_REQUEST
- *   21: BARRIER_REPLY
- *   22: QUEUE_GET_CONFIG_REQUEST
- *   23: QUEUE_GET_CONFIG_REPLY
- *   24: ROLE_REQUEST
- *   25: ROLE_REPLY    
- *   26: GET_ASYNC_REQUEST
- *   27: GET_ASYNC_REPLY
- *   28: SET_ASYNC
- *   29: METER_MOD
- *   </pre>
- */
-public class DecoderTable {
-    
-    private static final short OF10 = EncodeConstants.OF10_VERSION_ID;
-    private static final short OF13 = EncodeConstants.OF13_VERSION_ID;
-    private Map<MessageTypeCodeKey, OFDeserializer<?>> table;
-    private static DecoderTable instance;
-    
-    
-    private DecoderTable() {
-        // do nothing
-    }
-    
-    /**
-     * @return singleton instance
-     */
-    public static synchronized DecoderTable getInstance() {
-        if (instance == null) {
-            instance = new DecoderTable();
-            instance.init();
-        }
-        return instance;
-    }
-    
-    /**
-     * Decoder table provisioning
-     */
-    public void init() {
-        table = new HashMap<>();
-        table.put(new MessageTypeCodeKey(OF10, (short) 0), OF10HelloMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 1), OF10ErrorMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 2), EchoRequestMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 3), EchoReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 4), OF10VendorMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 6), OF10FeaturesReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 8), GetConfigReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 10), OF10PacketInMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 11), OF10FlowRemovedMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 12), OF10PortStatusMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 17), OF10StatsReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 19), BarrierReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF10, (short) 21), OF10QueueGetConfigReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 0), HelloMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 1), ErrorMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 2), EchoRequestMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 3), EchoReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 4), ExperimenterMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 6), FeaturesReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 8), GetConfigReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 10), PacketInMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 11), FlowRemovedMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 12), PortStatusMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 19), MultipartReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 21), BarrierReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 23), QueueGetConfigReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 25), RoleReplyMessageFactory.getInstance());
-        table.put(new MessageTypeCodeKey(OF13, (short) 27), GetAsyncReplyMessageFactory.getInstance());
-    }
-    
-    /**
-     * @param msgTypeKey
-     * @return decoder for given message types
-     */
-    public OFDeserializer<?> getDecoder(MessageTypeCodeKey msgTypeKey) {
-        return table.get(msgTypeKey);
-    }
-
-}
index 4daadffc7a42af656bc20af8fa14428487df81ef..1d827c0f88186c5f292a48d4a562cf3d48feb311 100644 (file)
@@ -10,38 +10,59 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization;
 
 import io.netty.buffer.ByteBuf;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * @author michal.polkorab
  * @author timotej.kubas
  */
-public abstract class DeserializationFactory {
-    
-    private static final Logger LOGGER = LoggerFactory
-            .getLogger(DeserializationFactory.class);
+public class DeserializationFactory {
+
+    private DeserializerRegistry registry;
+    private Map<TypeToClassKey, Class<?>> messageClassMap;
+
+    /**
+     * Constructor
+     */
+    public DeserializationFactory() {
+        messageClassMap = new HashMap<>();
+        initTypeToClassMapping();
+    }
 
     /**
      * Transforms ByteBuf into correct POJO message
-     * @param rawMessage 
+     * @param rawMessage
      * @param version version decoded from OpenFlow protocol message
      * @return correct POJO as DataObject
      */
-    public static DataObject bufferToMessage(ByteBuf rawMessage, short version) {
+    public DataObject deserialize(ByteBuf rawMessage, short version) {
         DataObject dataObject = null;
-        short type = rawMessage.readUnsignedByte();
+        int type = rawMessage.readUnsignedByte();
+        Class<?> clazz = messageClassMap.get(new TypeToClassKey(version, type));
         rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-
-        MessageTypeCodeKey msgTypeCodeKey = new MessageTypeCodeKey(version, type);
-        OFDeserializer<?> decoder = DecoderTable.getInstance().getDecoder(msgTypeCodeKey);
-        if (decoder != null) {
-            dataObject = decoder.bufferToMessage(rawMessage, version);
-        } else {
-            LOGGER.warn("No correct decoder found in DecoderTable for arguments: " + msgTypeCodeKey.toString());
+        OFDeserializer<DataObject> deserializer = registry.getDeserializer(
+                new MessageCodeKey(version, type, clazz));
+        if (deserializer != null) {
+            dataObject = deserializer.deserialize(rawMessage);
         }
         return dataObject;
     }
+
+    /**
+     * @param registry
+     */
+    public void setRegistry(DeserializerRegistry registry) {
+        this.registry = registry;
+    }
+
+    private void initTypeToClassMapping() {
+        TypeToClassMapInitializer.initializeTypeToClassMap(messageClassMap);
+    }
 }
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java
new file mode 100644 (file)
index 0000000..8039731
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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.deserialization;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+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;
+
+/**
+ * Stores and registers deserializers
+ * @author michal.polkorab
+ */
+public class DeserializerRegistryImpl implements DeserializerRegistry {
+    
+    private Map<MessageCodeKey, OFGeneralDeserializer> registry;
+
+    /**
+     * Decoder table provisioning
+     */
+    @Override
+    public void init() {
+        registry = new HashMap<>();
+        // register message deserializers
+        MessageDerializerInitializer.registerMessageDeserializers(this);
+
+        // register common structure deserializers
+        registerDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,
+                EncodeConstants.EMPTY_VALUE, MatchV10.class), new OF10MatchDeserializer());
+        registerDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,
+                EncodeConstants.EMPTY_VALUE, Action.class), new OF10ActionsDeserializer());
+        registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
+                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);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public <DESERIALIZER_TYPE extends OFGeneralDeserializer> DESERIALIZER_TYPE getDeserializer(
+            MessageCodeKey key) {
+        OFGeneralDeserializer deserializer = registry.get(key);
+        if (deserializer == null) {
+            throw new NullPointerException("Deserializer for key: " + key.toString()
+                    + " was not found");
+        }
+        return (DESERIALIZER_TYPE) deserializer;
+    }
+
+    @Override
+    public void registerDeserializer(MessageCodeKey key,
+            OFGeneralDeserializer deserializer) {
+        if ((key == null) || (deserializer == null)) {
+            throw new NullPointerException("MessageCodeKey or Deserializer is null");
+        }
+        if (deserializer instanceof DeserializerRegistryInjector) {
+            ((DeserializerRegistryInjector) deserializer).injectDeserializerRegistry(this);
+        }
+        registry.put(key, deserializer);
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java
new file mode 100644 (file)
index 0000000..8d904de
--- /dev/null
@@ -0,0 +1,111 @@
+/*\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.deserialization;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpOpDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpShaDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpSpaDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpThaDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpTpaDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthDstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthSrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthTypeDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4CodeDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4TypeDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6CodeDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6TypeDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPhyPortDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPortDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpDscpDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpEcnDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpProtoDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4DstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4SrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6DstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6ExtHdrDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6FlabelDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdSllDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTargetDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTllDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6SrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMetadataDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsBosDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsLabelDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsTcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmPbbIsidDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpDstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpSrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpDstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpSrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTunnelIdDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpDstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpSrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanPcpDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanVidDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.MatchEntryDeserializerRegistryHelper;\r
+import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class MatchEntryDeserializerInitializer {\r
+\r
+    /**\r
+     * Registers match entry deserializers\r
+     * @param registry registry to be filled with deserializers\r
+     */\r
+    public static void registerMatchEntryDeserializers(DeserializerRegistry registry) {\r
+        // register OpenflowBasicClass match entry deserializers\r
+        MatchEntryDeserializerRegistryHelper helper =\r
+                new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID,\r
+                        OxmMatchConstants.OPENFLOW_BASIC_CLASS, registry);\r
+        helper.register(OxmMatchConstants.IN_PORT, new OxmInPortDeserializer());\r
+        helper.register(OxmMatchConstants.IN_PHY_PORT, new OxmInPhyPortDeserializer());\r
+        helper.register(OxmMatchConstants.METADATA, new OxmMetadataDeserializer());\r
+        helper.register(OxmMatchConstants.ETH_DST, new OxmEthDstDeserializer());\r
+        helper.register(OxmMatchConstants.ETH_SRC, new OxmEthSrcDeserializer());\r
+        helper.register(OxmMatchConstants.ETH_TYPE, new OxmEthTypeDeserializer());\r
+        helper.register(OxmMatchConstants.VLAN_VID, new OxmVlanVidDeserializer());\r
+        helper.register(OxmMatchConstants.VLAN_PCP, new OxmVlanPcpDeserializer());\r
+        helper.register(OxmMatchConstants.IP_DSCP, new OxmIpDscpDeserializer());\r
+        helper.register(OxmMatchConstants.IP_ECN, new OxmIpEcnDeserializer());\r
+        helper.register(OxmMatchConstants.IP_PROTO, new OxmIpProtoDeserializer());\r
+        helper.register(OxmMatchConstants.IPV4_SRC, new OxmIpv4SrcDeserializer());\r
+        helper.register(OxmMatchConstants.IPV4_DST, new OxmIpv4DstDeserializer());\r
+        helper.register(OxmMatchConstants.TCP_SRC, new OxmTcpSrcDeserializer());\r
+        helper.register(OxmMatchConstants.TCP_DST, new OxmTcpDstDeserializer());\r
+        helper.register(OxmMatchConstants.UDP_SRC, new OxmUdpSrcDeserializer());\r
+        helper.register(OxmMatchConstants.UDP_DST, new OxmUdpDstDeserializer());\r
+        helper.register(OxmMatchConstants.SCTP_SRC, new OxmSctpSrcDeserializer());\r
+        helper.register(OxmMatchConstants.SCTP_DST, new OxmSctpDstDeserializer());\r
+        helper.register(OxmMatchConstants.ICMPV4_TYPE, new OxmIcmpv4TypeDeserializer());\r
+        helper.register(OxmMatchConstants.ICMPV4_CODE, new OxmIcmpv4CodeDeserializer());\r
+        helper.register(OxmMatchConstants.ARP_OP, new OxmArpOpDeserializer());\r
+        helper.register(OxmMatchConstants.ARP_SPA, new OxmArpSpaDeserializer());\r
+        helper.register(OxmMatchConstants.ARP_TPA, new OxmArpTpaDeserializer());\r
+        helper.register(OxmMatchConstants.ARP_SHA, new OxmArpShaDeserializer());\r
+        helper.register(OxmMatchConstants.ARP_THA, new OxmArpThaDeserializer());\r
+        helper.register(OxmMatchConstants.IPV6_SRC, new OxmIpv6SrcDeserializer());\r
+        helper.register(OxmMatchConstants.IPV6_DST, new OxmIpv6DstDeserializer());\r
+        helper.register(OxmMatchConstants.IPV6_FLABEL, new OxmIpv6FlabelDeserializer());\r
+        helper.register(OxmMatchConstants.ICMPV6_TYPE, new OxmIcmpv6TypeDeserializer());\r
+        helper.register(OxmMatchConstants.ICMPV6_CODE, new OxmIcmpv6CodeDeserializer());\r
+        helper.register(OxmMatchConstants.IPV6_ND_TARGET, new OxmIpv6NdTargetDeserializer());\r
+        helper.register(OxmMatchConstants.IPV6_ND_SLL, new OxmIpv6NdSllDeserializer());\r
+        helper.register(OxmMatchConstants.IPV6_ND_TLL, new OxmIpv6NdTllDeserializer());\r
+        helper.register(OxmMatchConstants.MPLS_LABEL, new OxmMplsLabelDeserializer());\r
+        helper.register(OxmMatchConstants.MPLS_TC, new OxmMplsTcDeserializer());\r
+        helper.register(OxmMatchConstants.MPLS_BOS, new OxmMplsBosDeserializer());\r
+        helper.register(OxmMatchConstants.PBB_ISID, new OxmPbbIsidDeserializer());\r
+        helper.register(OxmMatchConstants.TUNNEL_ID, new OxmTunnelIdDeserializer());\r
+        helper.register(OxmMatchConstants.IPV6_EXTHDR, new OxmIpv6ExtHdrDeserializer());\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java
new file mode 100644 (file)
index 0000000..1ccd04b
--- /dev/null
@@ -0,0 +1,97 @@
+/*\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.deserialization;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowRemovedMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoRequestMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketInMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.MessageDeserializerRegistryHelper;\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
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class MessageDerializerInitializer {\r
+\r
+    /**\r
+     * Registers message deserializers\r
+     * @param registry registry to be filled with deserializers\r
+     */\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
+        // 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
+    }\r
+}\r
index 96fb3e70100f7459f5dde5e6cf2cad615b257d6a..bb4368abc2ae25dd4ba7c751e0cdfb230d043dcf 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization;
 
 
 /**
- * Class used as a key in {@link DecoderTable}
+ * Class used as a key in {@link DeserializerRegistryImpl}
  * @author michal.polkorab
  * @author timotej.kubas
  */
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKey.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKey.java
new file mode 100644 (file)
index 0000000..8be2df3
--- /dev/null
@@ -0,0 +1,52 @@
+/*\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.deserialization;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class TypeToClassKey {\r
+\r
+    private short version;\r
+    private int type;\r
+\r
+    /**\r
+     * Constructor\r
+     * @param version wire protocol version\r
+     * @param type message type / code\r
+     */\r
+    public TypeToClassKey(short version, int type) {\r
+        this.version = version;\r
+        this.type = type;\r
+    }\r
+\r
+    @Override\r
+    public int hashCode() {\r
+        final int prime = 31;\r
+        int result = 1;\r
+        result = prime * result + type;\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        if (this == obj)\r
+            return true;\r
+        if (obj == null)\r
+            return false;\r
+        if (getClass() != obj.getClass())\r
+            return false;\r
+        TypeToClassKey other = (TypeToClassKey) obj;\r
+        if (type != other.type)\r
+            return false;\r
+        if (version != other.version)\r
+            return false;\r
+        return true;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java
new file mode 100644 (file)
index 0000000..6e193e2
--- /dev/null
@@ -0,0 +1,75 @@
+/*\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.deserialization;\r
+\r
+import java.util.Map;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper;\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
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class TypeToClassMapInitializer {\r
+\r
+    /**\r
+     * Initializes type to class map\r
+     * @param messageClassMap\r
+     */\r
+    public static void initializeTypeToClassMap(Map<TypeToClassKey, Class<?>> messageClassMap) {\r
+        // init OF v1.0 mapping\r
+        TypeToClassInitHelper helper = \r
+                new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap);\r
+        helper.registerTypeToClass((short) 0, HelloMessage.class);\r
+        helper.registerTypeToClass((short) 1, ErrorMessage.class);\r
+        helper.registerTypeToClass((short) 2, EchoRequestMessage.class);\r
+        helper.registerTypeToClass((short) 3, EchoOutput.class);\r
+        helper.registerTypeToClass((short) 4, ExperimenterMessage.class);\r
+        helper.registerTypeToClass((short) 6, GetFeaturesOutput.class);\r
+        helper.registerTypeToClass((short) 8, GetConfigOutput.class);\r
+        helper.registerTypeToClass((short) 10, PacketInMessage.class);\r
+        helper.registerTypeToClass((short) 11, FlowRemovedMessage.class);\r
+        helper.registerTypeToClass((short) 12, PortStatusMessage.class);\r
+        helper.registerTypeToClass((short) 17, MultipartReplyMessage.class);\r
+        helper.registerTypeToClass((short) 19, BarrierOutput.class);\r
+        helper.registerTypeToClass((short) 21, GetQueueConfigOutput.class);\r
+        // init OF v1.0 mapping\r
+        helper = new TypeToClassInitHelper(EncodeConstants.OF13_VERSION_ID, messageClassMap);\r
+        helper.registerTypeToClass((short) 0, HelloMessage.class);\r
+        helper.registerTypeToClass((short) 1, ErrorMessage.class);\r
+        helper.registerTypeToClass((short) 2, EchoRequestMessage.class);\r
+        helper.registerTypeToClass((short) 3, EchoOutput.class);\r
+        helper.registerTypeToClass((short) 4, ExperimenterMessage.class);\r
+        helper.registerTypeToClass((short) 6, GetFeaturesOutput.class);\r
+        helper.registerTypeToClass((short) 8, GetConfigOutput.class);\r
+        helper.registerTypeToClass((short) 10, PacketInMessage.class);\r
+        helper.registerTypeToClass((short) 11, FlowRemovedMessage.class);\r
+        helper.registerTypeToClass((short) 12, PortStatusMessage.class);\r
+        helper.registerTypeToClass((short) 19, MultipartReplyMessage.class);\r
+        helper.registerTypeToClass((short) 21, BarrierOutput.class);\r
+        helper.registerTypeToClass((short) 23, GetQueueConfigOutput.class);\r
+        helper.registerTypeToClass((short) 25, RoleRequestOutput.class);\r
+        helper.registerTypeToClass((short) 27, GetAsyncOutput.class);\r
+    }\r
+}\r
index 51c305cf11f8ece5df152c4c5463fafa851d77dc..7ac99c4f225a41f93efd3ab50a723baaba6b3e8e 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
 
@@ -19,31 +20,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * @author michal.polkorab
  * @author timotej.kubas
  */
-public class BarrierReplyMessageFactory implements
-        OFDeserializer<BarrierOutput> {
-
-    private static BarrierReplyMessageFactory instance;
-
-    private BarrierReplyMessageFactory() {
-        // do nothing, just singleton
-    }
-
-    /**
-     * @return singleton factory
-     */
-    public static synchronized BarrierReplyMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new BarrierReplyMessageFactory();
-        }
-        return instance;
-    }
+public class BarrierReplyMessageFactory implements OFDeserializer<BarrierOutput> {
 
     @Override
-    public BarrierOutput bufferToMessage(ByteBuf rawMessage, short version) {
+    public BarrierOutput deserialize(ByteBuf rawMessage) {
         BarrierOutputBuilder builder = new BarrierOutputBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         return builder.build();
     }
-
 }
index c5d5ab799e5615957f16f153aea55c1ae42dd649..5aca519fd62fd85acc88d55ed73adb5d6bec31cb 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;
 
@@ -21,26 +22,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class EchoReplyMessageFactory implements OFDeserializer<EchoOutput> {
 
-    private static EchoReplyMessageFactory instance;
-
-    private EchoReplyMessageFactory() {
-        // do nothing, just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized EchoReplyMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new EchoReplyMessageFactory();
-        }
-        return instance;
-    }
-    
     @Override
-    public EchoOutput bufferToMessage(ByteBuf rawMessage, short version) {
+    public EchoOutput deserialize(ByteBuf rawMessage) {
         EchoOutputBuilder builder = new EchoOutputBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         int remainingBytes = rawMessage.readableBytes();
         if (remainingBytes > 0) {
index 2ba5884dc62353f2c13483e4fb4c66e28f8876f2..6d2b767e71648c38139b4a14c3e11e031db573e1 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;
 
@@ -21,26 +22,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class EchoRequestMessageFactory implements OFDeserializer<EchoRequestMessage>{
 
-    private static EchoRequestMessageFactory instance;
-
-    private EchoRequestMessageFactory() {
-        // do nothing, just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized EchoRequestMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new EchoRequestMessageFactory();
-        }
-        return instance;
-    }
-
     @Override
-    public EchoRequestMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public EchoRequestMessage deserialize(ByteBuf rawMessage) {
         EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
         return builder.build();
index 09ec1088d69bcdb8a1e8ad5428b4bd9e3950fdf6..c3fdf8bae8cfc6bef03a9752753085bbd2819ed5 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterError;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterErrorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCode;
@@ -40,27 +41,11 @@ public class ErrorMessageFactory implements OFDeserializer<ErrorMessage> {
 
     private static final String UNKNOWN_CODE = "UNKNOWN_CODE";
     private static final String UNKNOWN_TYPE = "UNKNOWN_TYPE";
-    
-    private static ErrorMessageFactory instance;
-    
-    private ErrorMessageFactory() {
-        // do nothing, just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized ErrorMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new ErrorMessageFactory();
-        }
-        return instance;
-    }
-    
+
     @Override
-    public ErrorMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public ErrorMessage deserialize(ByteBuf rawMessage) {
         ErrorMessageBuilder builder = new ErrorMessageBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         int type = rawMessage.readUnsignedShort();
         ErrorType errorType = ErrorType.forValue(type);
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java
deleted file mode 100644 (file)
index f6dc0ea..0000000
+++ /dev/null
@@ -1,54 +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.deserialization.factories;
-
-import io.netty.buffer.ByteBuf;
-
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder;
-
-/**
- * Translates Experimenter messages
- * @author michal.polkorab, 
- * @author timotej.kubas
- */
-public class ExperimenterMessageFactory implements OFDeserializer<ExperimenterMessage>{
-
-    private static ExperimenterMessageFactory instance;
-    
-    private ExperimenterMessageFactory() {
-        //singleton
-    }
-    
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized ExperimenterMessageFactory getInstance(){
-        if (instance == null){
-           instance = new ExperimenterMessageFactory(); 
-        }
-        return instance;
-    }
-
-    @Override
-    public ExperimenterMessage bufferToMessage(ByteBuf rawMessage, short version) {
-        ExperimenterMessageBuilder builder = new ExperimenterMessageBuilder();
-        builder.setVersion(version);
-        builder.setXid(rawMessage.readUnsignedInt());
-        builder.setExperimenter(rawMessage.readUnsignedInt());
-        builder.setExpType(rawMessage.readUnsignedInt());
-        int remainingBytes = rawMessage.readableBytes();
-        if (remainingBytes > 0) {
-            builder.setData(rawMessage.readBytes(remainingBytes).array());
-        }
-        return builder.build();
-    }
-}
index 388a6e772c609d0b8616f14c88d1d306241efeec..ad08dc12623cc92d3fd52f1c9f4b97763712e51e 100644 (file)
@@ -12,7 +12,7 @@ import io.netty.buffer.ByteBuf;
 
 import java.math.BigInteger;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
@@ -24,29 +24,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * @author timotej.kubas
  */
 public class FeaturesReplyMessageFactory implements OFDeserializer<GetFeaturesOutput>{
-    
+
     private static final byte PADDING_IN_FEATURES_REPLY_HEADER = 2;
-    
-    private static FeaturesReplyMessageFactory instance;
 
-    private FeaturesReplyMessageFactory() {
-        // do nothing, just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized FeaturesReplyMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new FeaturesReplyMessageFactory();
-        }
-        return instance;
-    }
-    
     @Override
-    public GetFeaturesOutput bufferToMessage(ByteBuf rawMessage, short version) {
+    public GetFeaturesOutput deserialize(ByteBuf rawMessage) {
         GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         byte[] datapathId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
         rawMessage.readBytes(datapathId);
index 69d71d8d58e954ed7713ad5d4dbd5f29ef9e50c4..bfe552b9a2d154dab0fd7ad104b7b482e3b9b911 100644 (file)
@@ -12,11 +12,14 @@ import io.netty.buffer.ByteBuf;
 
 import java.math.BigInteger;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
 
@@ -25,28 +28,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * @author michal.polkorab
  * @author timotej.kubas
  */
-public class FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage> {
-    
-    private static FlowRemovedMessageFactory instance;
-    
-    private FlowRemovedMessageFactory() {
-        // singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized FlowRemovedMessageFactory getInstance(){
-        if(instance == null){
-            instance = new FlowRemovedMessageFactory();
-        }
-        return instance;
-    }
+public class FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage>,
+        DeserializerRegistryInjector {
+
+    private DeserializerRegistry registry;
 
     @Override
-    public FlowRemovedMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public FlowRemovedMessage deserialize(ByteBuf rawMessage) {
         FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
         rawMessage.readBytes(cookie);
@@ -64,7 +54,14 @@ public class FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMess
         byte[] byte_count = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
         rawMessage.readBytes(byte_count);
         builder.setByteCount(new BigInteger(1, byte_count));
-        builder.setMatch(MatchDeserializer.createMatch(rawMessage));
+        OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(
+                EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
+        builder.setMatch(matchDeserializer.deserialize(rawMessage));
         return builder.build();
     }
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
 }
index 2f482cf74efc74c7ff05a51a620c40efea81d7ea..c6156a0b530969a2db203b18eb0e90f8eee3d88c 100644 (file)
@@ -13,7 +13,8 @@ import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
@@ -32,28 +33,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * @author michal.polkorab
  */
 public class GetAsyncReplyMessageFactory implements OFDeserializer<GetAsyncOutput> {
-    
-    private static GetAsyncReplyMessageFactory instance;
+
     private static final byte SEPARATE_ROLES = 2;
-    
-    private GetAsyncReplyMessageFactory() {
-        // singleton
-    }
 
-    /**
-     * @return singleton factory
-     */
-    public static synchronized GetAsyncReplyMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new GetAsyncReplyMessageFactory();
-        }
-        return instance;
-    }
-    
     @Override
-    public GetAsyncOutput bufferToMessage(ByteBuf rawMessage, short version) {
+    public GetAsyncOutput deserialize(ByteBuf rawMessage) {
         GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         builder.setPacketInMask(decodePacketInMask(rawMessage));
         builder.setPortStatusMask(decodePortStatusMask(rawMessage));
index 95329132a4a8670244c9dd458e7cbf989cf010b1..5d193161bef2bf6f7ae89163014a8317b6d8e1bc 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder;
@@ -22,26 +23,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class GetConfigReplyMessageFactory implements OFDeserializer<GetConfigOutput> {
 
-    private static GetConfigReplyMessageFactory instance;
-    
-    private GetConfigReplyMessageFactory() {
-        // singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized GetConfigReplyMessageFactory getInstance(){
-        if(instance == null){
-            instance = new GetConfigReplyMessageFactory();
-        }
-        return instance;
-    }
-
     @Override
-    public GetConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {
+    public GetConfigOutput deserialize(ByteBuf rawMessage) {
         GetConfigOutputBuilder builder = new GetConfigOutputBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort()));
         builder.setMissSendLen(rawMessage.readUnsignedShort());
index 00e37b06ee0a30b67d18e5d80593c1938f04f666..f721ad12512874376454a8498fd4a40770e3ea7d 100644 (file)
@@ -13,7 +13,7 @@ import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
@@ -28,27 +28,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class HelloMessageFactory implements OFDeserializer<HelloMessage> {
 
-    private static HelloMessageFactory instance;
     private static final byte HELLO_ELEMENT_HEADER_SIZE = 4;
-
-    private HelloMessageFactory() {
-        // do nothing, just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized HelloMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new HelloMessageFactory();
-        }
-        return instance;
-    }
-    
     @Override
-    public HelloMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public HelloMessage deserialize(ByteBuf rawMessage) {
         HelloMessageBuilder builder = new HelloMessageBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         if (rawMessage.readableBytes() > 0) {
             builder.setElements(readElement(rawMessage));
index 3ef96147d95b848333fb223fbbddfc6826214b7a..002e979e16498766c3f5b80474d5aeae01310f04 100644 (file)
@@ -14,12 +14,14 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.util.ActionsDeserializer;
+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.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.InstructionsDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
 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;
@@ -34,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;
 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.common.types.rev130731.ActionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
@@ -52,6 +55,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.PortState;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
 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;
@@ -141,7 +145,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * @author timotej.kubas
  * @author michal.polkorab
  */
-public class MultipartReplyMessageFactory implements OFDeserializer<MultipartReplyMessage> {
+public class MultipartReplyMessageFactory implements OFDeserializer<MultipartReplyMessage>,
+        DeserializerRegistryInjector {
 
     private static final byte PADDING_IN_MULTIPART_REPLY_HEADER = 4;
     private static final int DESC_STR_LEN = 256;
@@ -173,28 +178,12 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
     private static final byte PADDING_IN_BUCKETS_HEADER = 4;
     private static final byte GROUP_DESC_HEADER_LENGTH = 8;
     private static final byte BUCKETS_HEADER_LENGTH = 16;
-
-    
-    private static MultipartReplyMessageFactory instance;
-
-    private MultipartReplyMessageFactory() {
-        // singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized MultipartReplyMessageFactory getInstance() {
-        if (instance == null){
-            instance = new MultipartReplyMessageFactory();
-        }
-        return instance;
-    }
+    private DeserializerRegistry registry;
 
     @Override
-    public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public MultipartReplyMessage deserialize(ByteBuf rawMessage) {
         MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         int type = rawMessage.readUnsignedShort();
         builder.setType(MultipartType.forValue(type));
@@ -266,7 +255,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
         return caseBuilder.build();
     }
     
-    private static MultipartReplyFlowCase setFlow(ByteBuf input) {
+    private MultipartReplyFlowCase setFlow(ByteBuf input) {
         MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder();
         MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
         List<FlowStats> flowStatsList = new ArrayList<>();
@@ -292,8 +281,14 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
             byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             subInput.readBytes(byteCount);
             flowStatsBuilder.setByteCount(new BigInteger(1, byteCount));
-            flowStatsBuilder.setMatch(MatchDeserializer.createMatch(subInput));
-            flowStatsBuilder.setInstruction(InstructionsDeserializer.createInstructions(subInput, subInput.readableBytes()));
+            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);
+            flowStatsBuilder.setInstruction(instructions);
             flowStatsList.add(flowStatsBuilder.build());
         }
         flowBuilder.setFlowStats(flowStatsList);
@@ -347,7 +342,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
         return caseBuilder.build();
     }
     
-    private static MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) {
+    private MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) {
         MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
         MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
         List<TableFeatures> features = new ArrayList<>();
@@ -379,7 +374,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
         return new TableConfig(deprecated);
     }
     
-    private static List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {
+    private List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {
         List<TableFeatureProperties> properties = new ArrayList<>();
         int tableFeaturesLength = length;
         while (tableFeaturesLength > 0) {
@@ -392,7 +387,11 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
             if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS)
                     || type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
                 InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
-                insBuilder.setInstruction(InstructionsDeserializer.createInstructionIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
+                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);
+                insBuilder.setInstruction(instructions);
                 builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());
             } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES)
                     || type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {
@@ -412,7 +411,11 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
                     || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS)
                     || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
                 ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
-                actionBuilder.setAction(ActionsDeserializer.createActionIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
+                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);
+                actionBuilder.setAction(actions);
                 builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());
             } else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH)
                     || type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS)
@@ -421,20 +424,19 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
                     || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD)
                     || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {
                 OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
-                oxmBuilder.setMatchEntries(MatchDeserializer.createMatchIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
+                oxmBuilder.setMatchEntries(DecodingUtils.deserializeMatchEntryHeaders(
+                        propertyLength - COMMON_PROPERTY_LENGTH, input, registry));
                 builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
             } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)
                     || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {
                 ExperimenterRelatedTableFeaturePropertyBuilder expBuilder = new ExperimenterRelatedTableFeaturePropertyBuilder();
                 expBuilder.setExperimenter(input.readUnsignedInt());
                 expBuilder.setExpType(input.readUnsignedInt());
-                int dataLength = propertyLength - COMMON_PROPERTY_LENGTH - 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES;
-                if (dataLength > 0) {
-                    byte[] data = new byte[dataLength];
-                    input.readBytes(data);
-                    expBuilder.setData(data);
-                }
-                builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, expBuilder.build());
+                OFDeserializer<ExperimenterRelatedTableFeatureProperty> propDeserializer = registry.getDeserializer(
+                        new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
+                                type.getIntValue(), ExperimenterRelatedTableFeatureProperty.class));
+                ExperimenterRelatedTableFeatureProperty expProp = propDeserializer.deserialize(input);
+                builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, expProp);
             }
             if (paddingRemainder != 0) {
                 input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
@@ -827,7 +829,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
         return new GroupTypes(OFPGT_ALL, OFPGT_FF, OFPGT_INDIRECT, OFPGT_SELECT);
     }
     
-    private static MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) {
+    private MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) {
         MultipartReplyGroupDescCaseBuilder caseBuilder = new MultipartReplyGroupDescCaseBuilder();
         MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
         List<GroupDesc> groupDescsList = new ArrayList<>();
@@ -846,8 +848,10 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
                 bucketsBuilder.setWatchPort(new PortNumber(input.readUnsignedInt()));
                 bucketsBuilder.setWatchGroup(input.readUnsignedInt());
                 input.skipBytes(PADDING_IN_BUCKETS_HEADER);
-                List<Action> actionsList = ActionsDeserializer
-                        .createActions(input, bucketsLength - BUCKETS_HEADER_LENGTH);
+                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);
                 bucketsList.add(bucketsBuilder.build());
                 actualLength += bucketsLength;
@@ -859,5 +863,10 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
         caseBuilder.setMultipartReplyGroupDesc(builder.build());
         return caseBuilder.build();
     }
-    
+
+    @Override
+    public void injectDeserializerRegistry(
+            DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
 }
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..68ddd12
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
+
+/**
+ * Translates BarrierReply messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10BarrierReplyMessageFactory implements OFDeserializer<BarrierOutput> {
+
+    @Override
+    public BarrierOutput deserialize(ByteBuf rawMessage) {
+        BarrierOutputBuilder builder = new BarrierOutputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        return builder.build();
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..a6b0bd1
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;
+
+/**
+ * Translates EchoReply messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10EchoReplyMessageFactory implements OFDeserializer<EchoOutput> {
+
+    @Override
+    public EchoOutput deserialize(ByteBuf rawMessage) {
+        EchoOutputBuilder builder = new EchoOutputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        int remainingBytes = rawMessage.readableBytes();
+        if (remainingBytes > 0) {
+            builder.setData(rawMessage.readBytes(remainingBytes).array());
+        }
+        return builder.build();
+    }
+
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java
new file mode 100644 (file)
index 0000000..cd83b03
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;
+
+/**
+ * Translates EchoRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10EchoRequestMessageFactory implements OFDeserializer<EchoRequestMessage>{
+
+    @Override
+    public EchoRequestMessage deserialize(ByteBuf rawMessage) {
+        EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
+        return builder.build();
+    }
+}
index 5d3f874f1c5614c37589c584a5c648148dee5e33..d5b8a7fec24097e16697007b6954c05d4f363cf5 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCodeV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadRequestCodeV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorTypeV10;
@@ -27,29 +28,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class OF10ErrorMessageFactory implements OFDeserializer<ErrorMessage> {
 
-       private static final String UNKNOWN_TYPE = "UNKNOWN_TYPE";
+    private static final String UNKNOWN_TYPE = "UNKNOWN_TYPE";
     private static final String UNKNOWN_CODE = "UNKNOWN_CODE";
-    
-    private static OF10ErrorMessageFactory instance;
-    
-    private OF10ErrorMessageFactory() {
-        // do nothing, just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized OF10ErrorMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new OF10ErrorMessageFactory();
-        }
-        return instance;
-    }
-    
+
     @Override
-    public ErrorMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public ErrorMessage deserialize(ByteBuf rawMessage) {
         ErrorMessageBuilder builder = new ErrorMessageBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         int type = rawMessage.readUnsignedShort();
         ErrorTypeV10 errorType = ErrorTypeV10.forValue(type);
index ea859a2d53fe95aff9fd56ec826877ee986d2b4d..dc61607bbb78a675044f218831017b6dbae0058c 100644 (file)
@@ -14,7 +14,7 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
@@ -35,27 +35,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class OF10FeaturesReplyMessageFactory implements OFDeserializer<GetFeaturesOutput> {
     
     private static final byte PADDING_IN_FEATURES_REPLY_HEADER = 3;
-    
-    private static OF10FeaturesReplyMessageFactory instance;
 
-    private OF10FeaturesReplyMessageFactory() {
-        // do nothing, just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized OF10FeaturesReplyMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new OF10FeaturesReplyMessageFactory();
-        }
-        return instance;
-    }
-    
     @Override
-    public GetFeaturesOutput bufferToMessage(ByteBuf rawMessage, short version) {
+    public GetFeaturesOutput deserialize(ByteBuf rawMessage) {
         GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         byte[] datapathId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
         rawMessage.readBytes(datapathId);
index dad45419bdbbc8959b35e7b2a0127161358e1d3b..32e09c4fc36a6b53904b9dfd8df9eb4129bfef5a 100644 (file)
@@ -12,10 +12,13 @@ import io.netty.buffer.ByteBuf;
 
 import java.math.BigInteger;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
 
@@ -23,34 +26,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * Translates FlowRemoved messages (OpenFlow v1.0)
  * @author michal.polkorab
  */
-public class OF10FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage> {
+public class OF10FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage>,
+        DeserializerRegistryInjector {
 
     private static final byte PADDING_IN_FLOW_REMOVED_MESSAGE = 1;
     private static final byte PADDING_IN_FLOW_REMOVED_MESSAGE_2 = 2;
-    
-    
-    private static OF10FlowRemovedMessageFactory instance;
-    
-    private OF10FlowRemovedMessageFactory() {
-        // singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized OF10FlowRemovedMessageFactory getInstance(){
-        if(instance == null){
-            instance = new OF10FlowRemovedMessageFactory();
-        }
-        return instance;
-    }
+    private DeserializerRegistry registry;
 
     @Override
-    public FlowRemovedMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public FlowRemovedMessage deserialize(ByteBuf rawMessage) {
         FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
-        builder.setMatchV10(OF10MatchDeserializer.createMatchV10(rawMessage));
+        OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
+        builder.setMatchV10(matchDeserializer.deserialize(rawMessage));
         byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
         rawMessage.readBytes(cookie);
         builder.setCookie(new BigInteger(1, cookie));
@@ -70,5 +60,8 @@ public class OF10FlowRemovedMessageFactory implements OFDeserializer<FlowRemoved
         return builder.build();
     }
 
-    
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
 }
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java
new file mode 100644 (file)
index 0000000..5e54892
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder;
+
+/**
+ * Translates GetConfigReply messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10GetConfigReplyMessageFactory implements OFDeserializer<GetConfigOutput> {
+
+    @Override
+    public GetConfigOutput deserialize(ByteBuf rawMessage) {
+        GetConfigOutputBuilder builder = new GetConfigOutputBuilder();
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort()));
+        builder.setMissSendLen(rawMessage.readUnsignedShort());
+        return builder.build();
+    }
+}
index cefb7f1a9ebbeded0a5d51c1c2a8ea37b59ccef8..a71dddbcdeaf08e21958c14dda907f2e91dbb57b 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder;
 
@@ -19,27 +20,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * @author michal.polkorab
  */
 public class OF10HelloMessageFactory implements OFDeserializer<HelloMessage> {
-    
-private static OF10HelloMessageFactory instance;
-    
-    private OF10HelloMessageFactory() {
-        // do nothing, just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized OF10HelloMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new OF10HelloMessageFactory();
-        }
-        return instance;
-    }
-    
+
     @Override
-    public HelloMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public HelloMessage deserialize(ByteBuf rawMessage) {
         HelloMessageBuilder builder = new HelloMessageBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         if (rawMessage.readableBytes() > 0) {
             rawMessage.skipBytes(rawMessage.readableBytes());
index 814bd502045cf48be689dc52592a6362bf8ba033..8302fa37ca3c8d85c61028656c689a2e9f43438c 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;
@@ -23,26 +24,10 @@ public class OF10PacketInMessageFactory implements OFDeserializer<PacketInMessag
 
     private static final byte PADDING_IN_PACKET_IN_HEADER = 1;
 
-    private static OF10PacketInMessageFactory instance;
-    
-    private OF10PacketInMessageFactory() {
-        // Singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized OF10PacketInMessageFactory getInstance(){
-        if(instance == null){
-            instance = new OF10PacketInMessageFactory();
-        }
-        return instance;
-    }
-
     @Override
-    public PacketInMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public PacketInMessage deserialize(ByteBuf rawMessage) {
         PacketInMessageBuilder builder = new PacketInMessageBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         builder.setBufferId(rawMessage.readUnsignedInt());
         builder.setTotalLen(rawMessage.readUnsignedShort());
index 5d6036ad228f9c13ec815b7b20f5ec774ee48cb6..3d0489a8659955d3adec406a815bcf866e3ef313 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
@@ -29,26 +29,10 @@ public class OF10PortStatusMessageFactory implements OFDeserializer<PortStatusMe
 
     private static final byte PADDING_IN_PORT_STATUS_HEADER = 7;
 
-    private static OF10PortStatusMessageFactory instance;
-    
-    private OF10PortStatusMessageFactory() {
-        // Singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized OF10PortStatusMessageFactory getInstance(){
-        if(instance == null){
-            instance = new OF10PortStatusMessageFactory();
-        }
-        return instance;
-    }
-    
     @Override
-    public PortStatusMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public PortStatusMessage deserialize(ByteBuf rawMessage) {
         PortStatusMessageBuilder builder = new PortStatusMessageBuilder(); 
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
         rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);
index 10e34d8e81fadfad13fbe4d00b1351fde1868a79..1dcad3fd68a6b86ce65c6e64249852b5ad2b5999 100644 (file)
@@ -13,7 +13,8 @@ import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
@@ -38,28 +39,10 @@ public class OF10QueueGetConfigReplyMessageFactory implements OFDeserializer<Get
     private static final byte PADDING_IN_RATE_QUEUE_PROPERTY = 6;
     private static final byte PACKET_QUEUE_HEADER_LENGTH = 8;
 
-    private static OF10QueueGetConfigReplyMessageFactory instance;
-    
-    private OF10QueueGetConfigReplyMessageFactory() {
-        // singleton
-    }
-    
-    /**
-     * 
-     * @return singleton factory
-     */
-    public static synchronized OF10QueueGetConfigReplyMessageFactory getInstance(){
-        
-        if(instance == null){
-            instance = new OF10QueueGetConfigReplyMessageFactory();
-        }
-        return instance;
-    }
-    
     @Override
-    public GetQueueConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {
+    public GetQueueConfigOutput deserialize(ByteBuf rawMessage) {
         GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
         builder.setXid((rawMessage.readUnsignedInt()));
         builder.setPort(new PortNumber((long) rawMessage.readUnsignedShort()));
         rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER);
index a78d464394d7f7d2925423dff298c1104fdb20eb..b1550cee01ebda6fe9d913d57685ff132b46e7ed 100644 (file)
@@ -14,13 +14,18 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+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.EncodeConstants;
-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.types.rev130731.MultipartRequestFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
@@ -57,7 +62,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * Translates StatsReply messages (OpenFlow v1.0)
  * @author michal.polkorab
  */
-public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartReplyMessage> {
+public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartReplyMessage>,
+        DeserializerRegistryInjector {
 
     private static final int DESC_STR_LEN = 256;
     private static final int SERIAL_NUM_LEN = 32;
@@ -70,27 +76,12 @@ public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartRep
     private static final byte PADDING_IN_QUEUE_HEADER = 2;
     private static final byte LENGTH_OF_FLOW_STATS = 88;
     private static final int TABLE_STATS_LENGTH = 64;
-    
-    private static OF10StatsReplyMessageFactory instance;
-    
-    private OF10StatsReplyMessageFactory() {
-        // singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized OF10StatsReplyMessageFactory getInstance() {
-        if (instance == null){
-            instance = new OF10StatsReplyMessageFactory();
-        }
-        return instance;
-    }
+    private DeserializerRegistry registry;
 
     @Override
-    public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public MultipartReplyMessage deserialize(ByteBuf rawMessage) {
         MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         int type = rawMessage.readUnsignedShort();
         builder.setType(MultipartType.forValue(type));
@@ -143,7 +134,7 @@ public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartRep
         return caseBuilder.build();
     }
     
-    private static MultipartReplyFlowCase setFlow(ByteBuf input) {
+    private MultipartReplyFlowCase setFlow(ByteBuf input) {
         MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder();
         MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
         List<FlowStats> flowStatsList = new ArrayList<>();
@@ -152,7 +143,9 @@ public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartRep
             int length = input.readUnsignedShort();
             flowStatsBuilder.setTableId(input.readUnsignedByte());
             input.skipBytes(PADDING_IN_FLOW_STATS_HEADER);
-            flowStatsBuilder.setMatchV10(OF10MatchDeserializer.createMatchV10(input));
+            OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(
+                    new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
+            flowStatsBuilder.setMatchV10(matchDeserializer.deserialize(input));
             flowStatsBuilder.setDurationSec(input.readUnsignedInt());
             flowStatsBuilder.setDurationNsec(input.readUnsignedInt());
             flowStatsBuilder.setPriority(input.readUnsignedShort());
@@ -168,8 +161,11 @@ 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));
-            flowStatsBuilder.setAction(OF10ActionsDeserializer
-                    .createActionsList(input, length - LENGTH_OF_FLOW_STATS));
+            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);
+            flowStatsBuilder.setAction(actions);
             flowStatsList.add(flowStatsBuilder.build());
         }
         flowBuilder.setFlowStats(flowStatsList);
@@ -308,4 +304,9 @@ public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartRep
         caseBuilder.setMultipartReplyExperimenter(builder.build());
         return caseBuilder.build();
     }
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
 }
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10VendorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10VendorMessageFactory.java
deleted file mode 100644 (file)
index 4c81719..0000000
+++ /dev/null
@@ -1,51 +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.deserialization.factories;
-
-import io.netty.buffer.ByteBuf;
-
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder;
-
-/**
- * Translates Vendor messages (OpenFlow v1.0)
- * @author michal.polkorab
- */
-public class OF10VendorMessageFactory implements OFDeserializer<ExperimenterMessage> {
-
-private static OF10VendorMessageFactory instance;
-    
-    private OF10VendorMessageFactory() {
-        //singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized OF10VendorMessageFactory getInstance(){
-        if (instance == null){
-           instance = new OF10VendorMessageFactory(); 
-        }
-        return instance;
-    }
-
-    @Override
-    public ExperimenterMessage bufferToMessage(ByteBuf rawMessage, short version) {
-        ExperimenterMessageBuilder builder = new ExperimenterMessageBuilder();
-        builder.setVersion(version);
-        builder.setXid(rawMessage.readUnsignedInt());
-        builder.setExperimenter(rawMessage.readUnsignedInt());
-        int remainingBytes = rawMessage.readableBytes();
-        if (remainingBytes > 0) {
-            builder.setData(rawMessage.readBytes(remainingBytes).array());
-        }
-        return builder.build();
-    }
-}
index d9f299635c54f0bd7a3cd693a3df8eb9375b7534..819e1568646a71156371459f47400c4e8558054f 100644 (file)
@@ -12,11 +12,14 @@ import io.netty.buffer.ByteBuf;
 
 import java.math.BigInteger;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;
 
@@ -25,29 +28,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * @author michal.polkorab
  * @author timotej.kubas
  */
-public class PacketInMessageFactory implements OFDeserializer<PacketInMessage> {
+public class PacketInMessageFactory implements OFDeserializer<PacketInMessage>,
+        DeserializerRegistryInjector {
 
-    private static PacketInMessageFactory instance;
     private static final byte PADDING_IN_PACKET_IN_HEADER = 2;
-    
-    private PacketInMessageFactory() {
-        // Singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized PacketInMessageFactory getInstance(){
-        if(instance == null){
-            instance = new PacketInMessageFactory();
-        }
-        return instance;
-    }
+    private DeserializerRegistry registry;
 
     @Override
-    public PacketInMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public PacketInMessage deserialize(ByteBuf rawMessage) {
         PacketInMessageBuilder builder = new PacketInMessageBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         builder.setBufferId(rawMessage.readUnsignedInt());
         builder.setTotalLen(rawMessage.readUnsignedShort());
@@ -56,9 +46,16 @@ public class PacketInMessageFactory implements OFDeserializer<PacketInMessage> {
         byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
         rawMessage.readBytes(cookie);
         builder.setCookie(new BigInteger(1, cookie));
-        builder.setMatch(MatchDeserializer.createMatch(rawMessage)); 
+        OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(
+                EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
+        builder.setMatch(matchDeserializer.deserialize(rawMessage));
         rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER);
         builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
         return builder.build();
     }
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
 }
index cb0469474c98b209d62b84a3e7d2361af61c3c4c..80c6d27ca0745e98a95186410645250bb981e32f 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
@@ -28,29 +28,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class PortStatusMessageFactory implements OFDeserializer<PortStatusMessage> {
 
-    private static PortStatusMessageFactory instance;
     private static final byte PADDING_IN_PORT_STATUS_HEADER = 7;
     private static final byte PADDING_IN_OFP_PORT_HEADER_1 = 4;
     private static final byte PADDING_IN_OFP_PORT_HEADER_2 = 2;
-    
-    private PortStatusMessageFactory() {
-        // Singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized PortStatusMessageFactory getInstance(){
-        if(instance == null){
-            instance = new PortStatusMessageFactory();
-        }
-        return instance;
-    }
-    
+
     @Override
-    public PortStatusMessage bufferToMessage(ByteBuf rawMessage, short version) {
+    public PortStatusMessage deserialize(ByteBuf rawMessage) {
         PortStatusMessageBuilder builder = new PortStatusMessageBuilder(); 
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
         rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);
@@ -107,5 +92,4 @@ public class PortStatusMessageFactory implements OFDeserializer<PortStatusMessag
         final Boolean _noPacketIn = ((input) & (1<<6)) != 0;
         return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);
     }
-    
 }
index b442a49a6c4cd27b0ef9f1d848d6098c01d3490d..ecdbfa3792eb09ad9a5bdd3afad7a23cd945d56b 100644 (file)
@@ -13,7 +13,7 @@ import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueuePropertyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
@@ -42,28 +42,10 @@ public class QueueGetConfigReplyMessageFactory implements OFDeserializer<GetQueu
     private static final int PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY = 4;
     private static final byte PACKET_QUEUE_LENGTH = 16;
 
-    private static QueueGetConfigReplyMessageFactory instance;
-    
-    private QueueGetConfigReplyMessageFactory() {
-        // singleton
-    }
-    
-    /**
-     * 
-     * @return singleton factory
-     */
-    public static synchronized QueueGetConfigReplyMessageFactory getInstance(){
-        
-        if(instance == null){
-            instance = new QueueGetConfigReplyMessageFactory();
-        }
-        return instance;
-    }
-    
     @Override
-    public GetQueueConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {
+    public GetQueueConfigOutput deserialize(ByteBuf rawMessage) {
         GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid((rawMessage.readUnsignedInt()));
         builder.setPort(new PortNumber(rawMessage.readUnsignedInt()));
         rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER);
index 3ccb2589176ca4bb412a7ac496c9b2fa533184d2..eaee8f389d3458e3af9240cf21df743d36d1a2a6 100644 (file)
@@ -12,7 +12,8 @@ import io.netty.buffer.ByteBuf;
 
 import java.math.BigInteger;
 
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder;
@@ -23,28 +24,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * @author michal.polkorab
  */
 public class RoleReplyMessageFactory implements OFDeserializer<RoleRequestOutput>{
-    private static RoleReplyMessageFactory instance;
+
     private static final byte PADDING_IN_ROLE_REPLY_HEADER = 4;
-    
-    private RoleReplyMessageFactory() {
-        // singleton
-    }
-    
-    /**
-     * 
-     * @return singleton factory
-     */
-    public static synchronized RoleReplyMessageFactory getInstance(){
-        if(instance == null){
-            instance = new RoleReplyMessageFactory();
-        }
-        return instance;
-    }
 
     @Override
-    public RoleRequestOutput bufferToMessage(ByteBuf rawMessage, short version) {
+    public RoleRequestOutput deserialize(ByteBuf rawMessage) {
         RoleRequestOutputBuilder builder = new RoleRequestOutputBuilder();
-        builder.setVersion(version);
+        builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
         builder.setXid(rawMessage.readUnsignedInt());
         builder.setRole(ControllerRole.forValue((int) rawMessage.readUnsignedInt()));
         rawMessage.skipBytes(PADDING_IN_ROLE_REPLY_HEADER);
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java
new file mode 100644 (file)
index 0000000..7e19d9c
--- /dev/null
@@ -0,0 +1,52 @@
+/*\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.deserialization.match;\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.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\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.Ipv4AddressMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+import com.google.common.base.Joiner;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmIpv4AddressDeserializer extends AbstractOxmMatchEntryDeserializer \r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addIpv4AddressAugmentation(builder, input);\r
+        if (builder.isHasMask()) {\r
+            OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
+        }\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addIpv4AddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) {\r
+        Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();\r
+        List<String> groups = new ArrayList<>();\r
+        for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {\r
+            groups.add(Short.toString(input.readUnsignedByte()));\r
+        }\r
+        Joiner joiner = Joiner.on(".");\r
+        ipv4AddressBuilder.setIpv4Address(new Ipv4Address(joiner.join(groups)));\r
+        builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java
new file mode 100644 (file)
index 0000000..bd9f3b8
--- /dev/null
@@ -0,0 +1,53 @@
+/*\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.deserialization.match;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+import com.google.common.base.Joiner;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmIpv6AddressDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addIpv6AddressAugmentation(builder, input);\r
+        if (builder.isHasMask()) {\r
+            OxmMaskDeserializer.addMaskAugmentation(builder, input,\r
+                    EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);\r
+        }\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addIpv6AddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) {\r
+        Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder();\r
+        List<String> groups = new ArrayList<>();\r
+        for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV6_ADDRESS; i++) {\r
+            groups.add(String.format("%04X", input.readUnsignedShort()));\r
+        }\r
+        Joiner joiner = Joiner.on(":");\r
+        ipv6AddressBuilder.setIpv6Address(new Ipv6Address(joiner.join(groups)));\r
+        builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java
new file mode 100644 (file)
index 0000000..58b431b
--- /dev/null
@@ -0,0 +1,45 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmMacAddressDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addMacAddressAugmentation(builder, input);\r
+        if (builder.isHasMask()) {\r
+            OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.MAC_ADDRESS_LENGTH);\r
+        }\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addMacAddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) {\r
+        MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder();\r
+        byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];\r
+        input.readBytes(address);\r
+        macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));\r
+        builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build());\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java
new file mode 100644 (file)
index 0000000..99c0f8c
--- /dev/null
@@ -0,0 +1,64 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmMatchEntryDeserializer implements HeaderDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserializeHeader(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        return builder.build();\r
+    }\r
+\r
+    /**\r
+     * @return oxm_field class\r
+     */\r
+    protected abstract Class<? extends MatchField> getOxmField();\r
+\r
+    /**\r
+     * @return oxm_class class\r
+     */\r
+    protected abstract Class<? extends Clazz> getOxmClass();\r
+\r
+    /**\r
+     * Prepares match entry header - sets oxm_class, oxm_field, hasMask\r
+     *  + sets the buffer.readerIndex() to the end of match entry \r
+     *  - where augmentation starts\r
+     * @param oxm_class oxm class type\r
+     * @param oxm_field oxm field type\r
+     * @param input input bytebuf\r
+     * @return MatchEntriesBuilder which can be filled with MatchEntry augmentation\r
+     */\r
+    protected MatchEntriesBuilder processHeader(Class<? extends Clazz> oxm_class,\r
+            Class<? extends MatchField> oxm_field, ByteBuf input) {\r
+        MatchEntriesBuilder builder = new MatchEntriesBuilder();\r
+        builder.setOxmClass(oxm_class);\r
+        // skip oxm_class (provided)\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        builder.setOxmMatchField(oxm_field);\r
+        boolean hasMask = (input.readUnsignedByte() & 1) != 0;\r
+        builder.setHasMask(hasMask);\r
+        // skip match entry length - not needed\r
+        input.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
+        return builder;\r
+    }\r
+    \r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java
new file mode 100644 (file)
index 0000000..abf757f
--- /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
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\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.MetadataMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmMetadataDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addMetadataAugmentation(builder, input);\r
+        if (builder.isHasMask()) {\r
+            OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
+        }\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf input) {\r
+        MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder();\r
+        byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
+        input.readBytes(metadataBytes);\r
+        metadata.setMetadata(metadataBytes);\r
+        builder.addAugmentation(MetadataMatchEntry.class, metadata.build());\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java
new file mode 100644 (file)
index 0000000..4320300
--- /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
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmPortDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addPortAugmentation(builder, input);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf input) {\r
+        PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder();\r
+        portBuilder.setPort(new PortNumber(input.readUnsignedShort()));\r
+        builder.addAugmentation(PortMatchEntry.class, portBuilder.build());\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java
new file mode 100644 (file)
index 0000000..bd88623
--- /dev/null
@@ -0,0 +1,34 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmPortNumberDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder();\r
+        port.setPortNumber(new PortNumber(input.readUnsignedInt()));\r
+        builder.addAugmentation(PortNumberMatchEntry.class, port.build());\r
+        return builder.build();\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java
new file mode 100644 (file)
index 0000000..dc01fbc
--- /dev/null
@@ -0,0 +1,51 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmArpOpDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addArpOpAugmentation(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addArpOpAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+        OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder();\r
+        opcodeBuilder.setOpCode(input.readUnsignedShort());\r
+        builder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return ArpOp.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java
new file mode 100644 (file)
index 0000000..a4f9750
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmArpShaDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return ArpSha.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java
new file mode 100644 (file)
index 0000000..8c750fe
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmArpSpaDeserializer extends AbstractOxmIpv4AddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return ArpSpa.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java
new file mode 100644 (file)
index 0000000..c3c7771
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmArpThaDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return ArpTha.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java
new file mode 100644 (file)
index 0000000..a8039f5
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmArpTpaDeserializer extends AbstractOxmIpv4AddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return ArpTpa.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java
new file mode 100644 (file)
index 0000000..bb80686
--- /dev/null
@@ -0,0 +1,31 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmEthDstDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return EthDst.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java
new file mode 100644 (file)
index 0000000..216b7bf
--- /dev/null
@@ -0,0 +1,31 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmEthSrcDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return EthSrc.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java
new file mode 100644 (file)
index 0000000..e1c4eb7
--- /dev/null
@@ -0,0 +1,52 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmEthTypeDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addEthTypeAugmentation(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addEthTypeAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+        EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder();\r
+        ethertypeBuilder.setEthType(new EtherType(input.readUnsignedShort()));\r
+        builder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return EthType.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java
new file mode 100644 (file)
index 0000000..a52885a
--- /dev/null
@@ -0,0 +1,53 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIcmpv4CodeDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addIcmpv4CodeAugmentation(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addIcmpv4CodeAugmentation(ByteBuf input,\r
+            MatchEntriesBuilder builder) {\r
+        Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder();\r
+        icmpv4CodeBuilder.setIcmpv4Code(input.readUnsignedByte());\r
+        builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Icmpv4Code.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java
new file mode 100644 (file)
index 0000000..5b3c3db
--- /dev/null
@@ -0,0 +1,52 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIcmpv4TypeDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addIcmpv4TypeAugmentation(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addIcmpv4TypeAugmentation(ByteBuf input,\r
+            MatchEntriesBuilder builder) {\r
+        Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder();\r
+        icmpv4TypeBuilder.setIcmpv4Type(input.readUnsignedByte());\r
+        builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Icmpv4Type.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java
new file mode 100644 (file)
index 0000000..2c3bd5f
--- /dev/null
@@ -0,0 +1,52 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIcmpv6CodeDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addIcmpv6CodeAugmentation(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addIcmpv6CodeAugmentation(ByteBuf input,\r
+            MatchEntriesBuilder builder) {\r
+        Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder();\r
+        icmpv6CodeBuilder.setIcmpv6Code(input.readUnsignedByte());\r
+        builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Icmpv6Code.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java
new file mode 100644 (file)
index 0000000..5d47823
--- /dev/null
@@ -0,0 +1,47 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIcmpv6TypeDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder();\r
+        icmpv6TypeBuilder.setIcmpv6Type(input.readUnsignedByte());\r
+        builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build());\r
+        return builder.build();\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Icmpv6Type.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java
new file mode 100644 (file)
index 0000000..dfb050a
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmInPhyPortDeserializer extends AbstractOxmPortNumberDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return InPhyPort.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java
new file mode 100644 (file)
index 0000000..3bc97ee
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmInPortDeserializer extends AbstractOxmPortNumberDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return InPort.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java
new file mode 100644 (file)
index 0000000..decbe54
--- /dev/null
@@ -0,0 +1,52 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpDscpDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addIpDscpAugmentation(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addIpDscpAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+        DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder();\r
+        dscpBuilder.setDscp(new Dscp(input.readUnsignedByte()));\r
+        builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return IpDscp.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java
new file mode 100644 (file)
index 0000000..de06e65
--- /dev/null
@@ -0,0 +1,51 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpEcnDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addIpEcnAugmentation(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addIpEcnAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+        EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder();\r
+        ecnBuilder.setEcn(input.readUnsignedByte());\r
+        builder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return IpEcn.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java
new file mode 100644 (file)
index 0000000..52314f5
--- /dev/null
@@ -0,0 +1,51 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpProtoDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addIpProtoAugmentation(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addIpProtoAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+        ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder();\r
+        protoNumberBuilder.setProtocolNumber(input.readUnsignedByte());\r
+        builder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return IpProto.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java
new file mode 100644 (file)
index 0000000..98b924d
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv4DstDeserializer extends AbstractOxmIpv4AddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Ipv4Dst.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java
new file mode 100644 (file)
index 0000000..e24720e
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv4SrcDeserializer extends AbstractOxmIpv4AddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Ipv4Src.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java
new file mode 100644 (file)
index 0000000..e4599a0
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6DstDeserializer extends AbstractOxmIpv6AddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Ipv6Dst.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java
new file mode 100644 (file)
index 0000000..eb8b6d7
--- /dev/null
@@ -0,0 +1,67 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\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.PseudoFieldMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6ExtHdrDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addIpv6ExtHdrAugmentation(input, builder);\r
+        if (builder.isHasMask()) {\r
+            OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        }\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addIpv6ExtHdrAugmentation(ByteBuf input,\r
+            MatchEntriesBuilder builder) {\r
+        PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder();\r
+        int bitmap = input.readUnsignedShort();\r
+        final Boolean NONEXT = ((bitmap) & (1<<0)) != 0;\r
+        final Boolean ESP = ((bitmap) & (1<<1)) != 0;\r
+        final Boolean AUTH = ((bitmap) & (1<<2)) != 0;\r
+        final Boolean DEST = ((bitmap) & (1<<3)) != 0;\r
+        final Boolean FRAG = ((bitmap) & (1<<4)) != 0;\r
+        final Boolean ROUTER = ((bitmap) & (1<<5)) != 0;\r
+        final Boolean HOP = ((bitmap) & (1<<6)) != 0;\r
+        final Boolean UNREP = ((bitmap) & (1<<7)) != 0;\r
+        final Boolean UNSEQ = ((bitmap) & (1<<8)) != 0;\r
+        pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(AUTH, DEST, ESP, FRAG, HOP, NONEXT, ROUTER, UNREP, UNSEQ));\r
+        builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Ipv6Exthdr.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java
new file mode 100644 (file)
index 0000000..3b96a6f
--- /dev/null
@@ -0,0 +1,58 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6FlabelDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addIpv6FlabelAugmentation(input, builder);\r
+        if (builder.isHasMask()) {\r
+            OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
+        }\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addIpv6FlabelAugmentation(ByteBuf input,\r
+            MatchEntriesBuilder builder) {\r
+        Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder();\r
+        ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(input.readUnsignedInt()));\r
+        builder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Ipv6Flabel.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java
new file mode 100644 (file)
index 0000000..053b36f
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6NdSllDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Ipv6NdSll.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java
new file mode 100644 (file)
index 0000000..0a47593
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6NdTargetDeserializer extends AbstractOxmIpv6AddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Ipv6NdTarget.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java
new file mode 100644 (file)
index 0000000..ea7d4c6
--- /dev/null
@@ -0,0 +1,31 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6NdTllDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Ipv6NdTll.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java
new file mode 100644 (file)
index 0000000..8135b81
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6SrcDeserializer extends AbstractOxmIpv6AddressDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Ipv6Src.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java
new file mode 100644 (file)
index 0000000..d4246fd
--- /dev/null
@@ -0,0 +1,36 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmMaskDeserializer {\r
+\r
+    /**\r
+     * Appends mask to match entry (match entry builder)\r
+     * @param builder builder which the mask will append to\r
+     * @param input input ByteBuf\r
+     * @param matchEntryLength mask length\r
+     */\r
+    public static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf input,\r
+            int matchEntryLength) {\r
+        MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();\r
+        byte[] mask = new byte[matchEntryLength];\r
+        input.readBytes(mask);\r
+        maskBuilder.setMask(mask);\r
+        builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java
new file mode 100644 (file)
index 0000000..7bbc6eb
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmMetadataDeserializer extends AbstractOxmMetadataDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return Metadata.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java
new file mode 100644 (file)
index 0000000..ad39e04
--- /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
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmMplsBosDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addMplsBosDeserializer(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+\r
+    private static void addMplsBosDeserializer(ByteBuf input,\r
+            MatchEntriesBuilder builder) {\r
+        BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder();\r
+        if (input.readUnsignedByte() != 0) {\r
+            bosBuilder.setBos(true);\r
+        } else {\r
+            bosBuilder.setBos(false);\r
+        }\r
+        builder.addAugmentation(BosMatchEntry.class, bosBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return MplsBos.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java
new file mode 100644 (file)
index 0000000..794f6ea
--- /dev/null
@@ -0,0 +1,52 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmMplsLabelDeserializer extends AbstractOxmMatchEntryDeserializer\r
+implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addMplsLabelAugmentation(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addMplsLabelAugmentation(ByteBuf input,\r
+            MatchEntriesBuilder builder) {\r
+        MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder();\r
+        mplsLabelBuilder.setMplsLabel(input.readUnsignedInt());\r
+        builder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return MplsLabel.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java
new file mode 100644 (file)
index 0000000..22ed95e
--- /dev/null
@@ -0,0 +1,52 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmMplsTcDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addMplsTcAugmentation(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addMplsTcAugmentation(ByteBuf input,\r
+            MatchEntriesBuilder builder) {\r
+        TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder();\r
+        tcBuilder.setTc(input.readUnsignedByte());\r
+        builder.addAugmentation(TcMatchEntry.class, tcBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return MplsTc.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java
new file mode 100644 (file)
index 0000000..1dfdd71
--- /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
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\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.IsidMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmPbbIsidDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addPbbIsidAugmentation(input, builder);\r
+        if (builder.isHasMask()) {\r
+            OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_3_BYTES);\r
+        }\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addPbbIsidAugmentation(ByteBuf input,\r
+            MatchEntriesBuilder builder) {\r
+        IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder();\r
+        Integer isid = input.readUnsignedMedium();\r
+        isidBuilder.setIsid(isid.longValue());\r
+        builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return PbbIsid.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java
new file mode 100644 (file)
index 0000000..074eaf3
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmSctpDstDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return SctpDst.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java
new file mode 100644 (file)
index 0000000..ea5e3b4
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmSctpSrcDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return SctpSrc.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java
new file mode 100644 (file)
index 0000000..cb8faba
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmTcpDstDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return TcpDst.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java
new file mode 100644 (file)
index 0000000..9d357c9
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmTcpSrcDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return TcpSrc.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java
new file mode 100644 (file)
index 0000000..0947e51
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmTunnelIdDeserializer extends AbstractOxmMetadataDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return TunnelId.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java
new file mode 100644 (file)
index 0000000..f95e4b5
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmUdpDstDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return UdpDst.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java
new file mode 100644 (file)
index 0000000..6690268
--- /dev/null
@@ -0,0 +1,30 @@
+/*\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.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmUdpSrcDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return UdpSrc.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java
new file mode 100644 (file)
index 0000000..35bd420
--- /dev/null
@@ -0,0 +1,51 @@
+/*\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.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmVlanPcpDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addVlanPcpAugmentation(input, builder);\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addVlanPcpAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+        VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder();\r
+        vlanPcpBuilder.setVlanPcp(input.readUnsignedByte());\r
+        builder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return VlanPcp.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java
new file mode 100644 (file)
index 0000000..e5156fe
--- /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
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\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.VlanVidMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmVlanVidDeserializer extends AbstractOxmMatchEntryDeserializer\r
+        implements OFDeserializer<MatchEntries> {\r
+\r
+    @Override\r
+    public MatchEntries deserialize(ByteBuf input) {\r
+        MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+        addVlanVidAugmentation(input, builder);\r
+        if (builder.isHasMask()) {\r
+            OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        }\r
+        return builder.build();\r
+    }\r
+\r
+    private static void addVlanVidAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+        VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();\r
+        int vidEntryValue = input.readUnsignedShort();\r
+        vlanVidBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit\r
+        vlanVidBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit\r
+        builder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends MatchField> getOxmField() {\r
+        return VlanVid.class;\r
+    }\r
+\r
+    @Override\r
+    protected Class<? extends Clazz> getOxmClass() {\r
+        return OpenflowBasicClass.class;\r
+    }\r
+}\r
index 42e6a74d02cf0ec47d63ab2529780232b0834617..16e9808fb9d62483698e762da009c8bfe8c20afc 100644 (file)
@@ -13,10 +13,15 @@ import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;
+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.EthertypeAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
@@ -53,176 +58,161 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
 
 /**
  * Deserializes ofp_actions (OpenFlow v1.3)
  * @author timotej.kubas
  * @author michal.polkorab
  */
-public class ActionsDeserializer {
+public class ActionsDeserializer implements OFDeserializer<Action>,
+        HeaderDeserializer<Action>, DeserializerRegistryInjector {
     
-    private static final byte ACTION_HEADER_LENGTH = 4;
     private static final byte PADDING_IN_ACTIONS_HEADER = 4;
     private static final byte PADDING_IN_OUTPUT_ACTIONS_HEADER = 6;
     private static final byte PADDING_IN_SET_MPLS_TTL_ACTIONS_HEADER = 3;
     private static final byte PADDING_IN_PUSH_VLAN_ACTIONS_HEADER = 2;
     private static final byte PADDING_IN_NW_TTL_ACTIONS_HEADER = 3;
-    private static final byte EXPERIMENTER_ACTION_HEADER_LENGTH = 8;
-    
-    /**
-     * Creates list of actions (OpenFlow v1.3)
-     * @param input input ByteBuf
-     * @param actionsLength length of buckets
-     * @return ActionsList
-     */
-    public static List<Action> createActions(ByteBuf input, int actionsLength) {
-        List<Action> actions = new ArrayList<>();
-        int length = 0;
-        while (length < actionsLength) {
-            int type = input.readUnsignedShort();
-            int currentActionLength = input.readUnsignedShort();
-            ActionBuilder actionBuilder = new ActionBuilder();
-            switch(type) {
-            case 0:
-                actions.add(createOutputAction(input, actionBuilder));
-                break;
-            case 11:
-                actions.add(createCopyTtlOutAction(input, actionBuilder));
-                break;
-            case 12:
-                actions.add(createCopyTtlInAction(input, actionBuilder));
-                break;
-            case 15:
-                actions.add(createSetMplsTtlAction(input, actionBuilder));
-                break;
-            case 16:
-                actions.add(createDecMplsTtlOutAction(input, actionBuilder));
-                break;
-            case 17:
-                actions.add(createPushVlanAction(input, actionBuilder));
-                break;
-            case 18:
-                actions.add(createPopVlanAction(input, actionBuilder));
-                break;
-            case 19:
-                actions.add(createPushMplsAction(input, actionBuilder));
-                break;
-            case 20:
-                actions.add(createPopMplsAction(input, actionBuilder));
-                break;
-            case 21:
-                actions.add(createSetQueueAction(input, actionBuilder));
-                break;
-            case 22:
-                actions.add(createGroupAction(input, actionBuilder));
-                break;
-            case 23:
-                actions.add(createSetNwTtlAction(input, actionBuilder));
-                break;
-            case 24:
-                actions.add(createDecNwTtlAction(input, actionBuilder));
-                break;
-            case 25:
-                actions.add(createSetFieldAction(input, actionBuilder, currentActionLength));
-                break;
-            case 26:
-                actions.add(createPushPbbAction(input, actionBuilder));
-                break;
-            case 27:
-                actions.add(createPopPbbAction(input, actionBuilder));
-                break;
-            case 0xFFFF:
-                actions.add(createExperimenterAction(input, actionBuilder, currentActionLength));
-                break;
-            default:
-                break;
-            }
-            length += currentActionLength;
-        } 
-        return actions;
+    private DeserializerRegistry registry;
+
+    @Override
+    public Action deserialize(ByteBuf input) {
+        Action action = null;
+        ActionBuilder actionBuilder = new ActionBuilder();
+        int type = input.getUnsignedShort(input.readerIndex());
+        switch(type) {
+        case 0:
+            action = createOutputAction(input, actionBuilder);
+            break;
+        case 11:
+            action = createCopyTtlOutAction(input, actionBuilder);
+            break;
+        case 12:
+            action = createCopyTtlInAction(input, actionBuilder);
+            break;
+        case 15:
+            action = createSetMplsTtlAction(input, actionBuilder);
+            break;
+        case 16:
+            action = createDecMplsTtlOutAction(input, actionBuilder);
+            break;
+        case 17:
+            action = createPushVlanAction(input, actionBuilder);
+            break;
+        case 18:
+            action = createPopVlanAction(input, actionBuilder);
+            break;
+        case 19:
+            action = createPushMplsAction(input, actionBuilder);
+            break;
+        case 20:
+            action = createPopMplsAction(input, actionBuilder);
+            break;
+        case 21:
+            action = createSetQueueAction(input, actionBuilder);
+            break;
+        case 22:
+            action = createGroupAction(input, actionBuilder);
+            break;
+        case 23:
+            action = createSetNwTtlAction(input, actionBuilder);
+            break;
+        case 24:
+            action = createDecNwTtlAction(input, actionBuilder);
+            break;
+        case 25:
+            action = createSetFieldAction(input, actionBuilder);
+            break;
+        case 26:
+            action = createPushPbbAction(input, actionBuilder);
+            break;
+        case 27:
+            action = createPopPbbAction(input, actionBuilder);
+            break;
+        case 0xFFFF:
+            OFDeserializer<ExperimenterAction> expDeserializer = registry.getDeserializer(
+                    new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0xFFFF, ExperimenterAction.class));
+            ExperimenterAction expAction = expDeserializer.deserialize(input);
+            actionBuilder.addAugmentation(ExperimenterAction.class, expAction);
+            break;
+        default:
+            break;
+        }
+        return action;
     }
 
-    /**
-     * Creates action ids - actions without values (OpenFlow v1.3)
-     * @param input input ByteBuf
-     * @param actionsLength length of actions
-     * @return ActionsList
-     */
-    public static List<Action> createActionIds(ByteBuf input, int actionsLength) {
-        List<Action> actionsList = new ArrayList<>();
-        int length = 0;
+    @Override
+    public Action deserializeHeader(ByteBuf input) {
         ActionBuilder builder;
-        while (length < actionsLength) {
-            builder = new ActionBuilder();
-            int type = input.readUnsignedShort();
-            int currentActionLength = input.readUnsignedShort();
-            switch(type) {
-            case 0:
-                builder.setType(Output.class);
-                break;
-            case 11:
-                builder.setType(CopyTtlOut.class);
-                break;
-            case 12:
-                builder.setType(CopyTtlIn.class);
-                break;
-            case 15:
-                builder.setType(SetMplsTtl.class);
-                break;
-            case 16:
-                builder.setType(DecMplsTtl.class);
-                break;
-            case 17:
-                builder.setType(PushVlan.class);
-                break;
-            case 18:
-                builder.setType(PopVlan.class);
-                break;
-            case 19:
-                builder.setType(PushMpls.class);
-                break;
-            case 20:
-                builder.setType(PopMpls.class);
-                break;
-            case 21:
-                builder.setType(SetQueue.class);
-                break;
-            case 22:
-                builder.setType(Group.class);
-                break;
-            case 23:
-                builder.setType(SetNwTtl.class);
-                break;
-            case 24:
-                builder.setType(DecNwTtl.class);
-                break;
-            case 25:
-                builder.setType(SetField.class);
-                break; 
-            case 26:
-                builder.setType(PushPbb.class);
-                break;
-            case 27:
-                builder.setType(PopPbb.class);
-                break;
-            case 0xFFFF:
-                builder.setType(Experimenter.class);
-                ExperimenterActionBuilder experimenter = new ExperimenterActionBuilder();
-                experimenter.setExperimenter(input.readUnsignedInt());
-                builder.addAugmentation(ExperimenterAction.class, experimenter.build());
-                break;
-            default: 
-                break;
-            }
-            actionsList.add(builder.build());
-            length += currentActionLength;
-        } 
-        return actionsList;
+        builder = new ActionBuilder();
+        int type = input.readUnsignedShort();
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        switch(type) {
+        case 0:
+            builder.setType(Output.class);
+            break;
+        case 11:
+            builder.setType(CopyTtlOut.class);
+            break;
+        case 12:
+            builder.setType(CopyTtlIn.class);
+            break;
+        case 15:
+            builder.setType(SetMplsTtl.class);
+            break;
+        case 16:
+            builder.setType(DecMplsTtl.class);
+            break;
+        case 17:
+            builder.setType(PushVlan.class);
+            break;
+        case 18:
+            builder.setType(PopVlan.class);
+            break;
+        case 19:
+            builder.setType(PushMpls.class);
+            break;
+        case 20:
+            builder.setType(PopMpls.class);
+            break;
+        case 21:
+            builder.setType(SetQueue.class);
+            break;
+        case 22:
+            builder.setType(Group.class);
+            break;
+        case 23:
+            builder.setType(SetNwTtl.class);
+            break;
+        case 24:
+            builder.setType(DecNwTtl.class);
+            break;
+        case 25:
+            builder.setType(SetField.class);
+            break; 
+        case 26:
+            builder.setType(PushPbb.class);
+            break;
+        case 27:
+            builder.setType(PopPbb.class);
+            break;
+        case 0xFFFF:
+            HeaderDeserializer<ExperimenterAction> expDeserializer = registry.getDeserializer(
+                    new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0xFFFF, ExperimenterAction.class));
+            ExperimenterAction expAction = expDeserializer.deserializeHeader(input);
+            builder.setType(Experimenter.class);
+            builder.addAugmentation(ExperimenterAction.class, expAction);
+            break;
+        default: 
+            break;
+        }
+        return builder.build();
     }
 
     private static Action createEmptyHeader(Class<? extends ActionBase> action,
             ByteBuf in, ActionBuilder actionBuilder) {
         actionBuilder.setType(action);
+        in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         in.skipBytes(PADDING_IN_ACTIONS_HEADER);
         return actionBuilder.build();
     }
@@ -253,6 +243,7 @@ public class ActionsDeserializer {
     
     private static Action createOutputAction(ByteBuf in, ActionBuilder actionBuilder) {
         actionBuilder.setType(Output.class);
+        in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         PortActionBuilder port = new PortActionBuilder();
         port.setPort(new PortNumber(in.readUnsignedInt()));
         actionBuilder.addAugmentation(PortAction.class, port.build());
@@ -265,6 +256,7 @@ public class ActionsDeserializer {
     
     private static Action createSetMplsTtlAction(ByteBuf in, ActionBuilder actionBuilder) {
         actionBuilder.setType(SetMplsTtl.class);
+        in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder();
         mplsTtl.setMplsTtl(in.readUnsignedByte());
         actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build());
@@ -275,6 +267,7 @@ public class ActionsDeserializer {
     private static Action createPushAction(Class<? extends ActionBase> action,
             ByteBuf in, ActionBuilder actionBuilder) {
         actionBuilder.setType(action);
+        in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         EthertypeActionBuilder etherType = new EthertypeActionBuilder();
         etherType.setEthertype(new EtherType(in.readUnsignedShort()));
         actionBuilder.addAugmentation(EthertypeAction.class, etherType.build());
@@ -300,6 +293,7 @@ public class ActionsDeserializer {
     
     private static Action createSetQueueAction(ByteBuf in, ActionBuilder actionBuilder) {
         actionBuilder.setType(SetQueue.class);
+        in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         QueueIdActionBuilder queueId = new QueueIdActionBuilder();
         queueId.setQueueId(in.readUnsignedInt());
         actionBuilder.addAugmentation(QueueIdAction.class, queueId.build());
@@ -308,28 +302,16 @@ public class ActionsDeserializer {
     
     private static Action createGroupAction(ByteBuf in, ActionBuilder actionBuilder) {
         actionBuilder.setType(Group.class);
+        in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         GroupIdActionBuilder group = new GroupIdActionBuilder();
         group.setGroupId(in.readUnsignedInt());
         actionBuilder.addAugmentation(GroupIdAction.class, group.build());
         return actionBuilder.build();
     }
-    
-    private static Action createExperimenterAction(ByteBuf in, ActionBuilder actionBuilder, int actionLength) {
-        actionBuilder.setType(Experimenter.class);
-        ExperimenterActionBuilder experimenter = new ExperimenterActionBuilder();
-        experimenter.setExperimenter(in.readUnsignedInt());
-        int dataLength = actionLength - EXPERIMENTER_ACTION_HEADER_LENGTH;
-        if (dataLength > 0) {
-            byte[] data = new byte[dataLength];
-            in.readBytes(data);
-            experimenter.setData(data);
-        }
-        actionBuilder.addAugmentation(ExperimenterAction.class, experimenter.build());
-        return actionBuilder.build();
-    }
-    
+
     private static Action createSetNwTtlAction(ByteBuf in, ActionBuilder actionBuilder) {
         actionBuilder.setType(SetNwTtl.class);
+        in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         NwTtlActionBuilder nwTtl = new NwTtlActionBuilder();
         nwTtl.setNwTtl(in.readUnsignedByte());
         actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build());
@@ -337,11 +319,31 @@ public class ActionsDeserializer {
         return actionBuilder.build();
     }
     
-    private static Action createSetFieldAction(ByteBuf in, ActionBuilder actionBuilder, int actionLength) {
+    private Action createSetFieldAction(ByteBuf in, ActionBuilder actionBuilder) {
         actionBuilder.setType(SetField.class);
+        int startIndex = in.readerIndex();
+        in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder();
-        matchEntries.setMatchEntries(MatchDeserializer.createMatchEntry(in, actionLength  - ACTION_HEADER_LENGTH));
+        int oxmClass = in.getUnsignedShort(in.readerIndex());
+        // get oxm_field & hasMask byte and extract the field value
+        int oxmField = in.getUnsignedByte(in.readerIndex()
+                + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
+        OFDeserializer<MatchEntries> matchDeserializer = registry.getDeserializer(
+                new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, oxmClass,
+                        oxmField, MatchEntries.class));
+        List<MatchEntries> entry = new ArrayList<>();
+        entry.add(matchDeserializer.deserialize(in));
+        matchEntries.setMatchEntries(entry);
         actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build());
+        int paddingRemainder = (in.readerIndex() - startIndex) % EncodeConstants.PADDING;
+        if (paddingRemainder != 0) {
+            in.skipBytes(EncodeConstants.PADDING - paddingRemainder);
+        }
         return actionBuilder.build();
     }
+
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
+    }
 }
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
new file mode 100644 (file)
index 0000000..1f03295
--- /dev/null
@@ -0,0 +1,116 @@
+/*\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 7097b0c9f09ecea1bf186c020c7ea7b7dcabc147..65631fcdb2d60326014c5894b2f80b2e3fe6f28e 100644 (file)
@@ -47,6 +47,9 @@ public abstract class EncodeConstants {
     /** Length of 3 bytes */
     public static final byte SIZE_OF_3_BYTES = 3;
 
+    /** Empty (zero) int value */
+    public static final int EMPTY_VALUE = 0;
+
 
     /** OF v1.0 maximal port name length */
     public static final byte MAX_PORT_NAME_LENGTH = 16;
index f678d87f2568d5b26c2064440000e09b4e447655..820c7fa7094dec72060e8139326caf6006940627 100644 (file)
@@ -10,9 +10,13 @@ package org.opendaylight.openflowjava.protocol.impl.util;
 
 import io.netty.buffer.ByteBuf;
 
-import java.util.ArrayList;
 import java.util.List;
 
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.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;
@@ -23,6 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002
 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;
@@ -38,127 +43,97 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
  * @author michal.polkorab
  * @author timotej.kubas
  */
-public abstract class InstructionsDeserializer {
+public class InstructionsDeserializer implements OFDeserializer<Instruction>,
+        HeaderDeserializer<Instruction>, DeserializerRegistryInjector {
     
     private static final byte WRITE_APPLY_CLEAR_ACTION_LENGTH = 8;
-    private static final byte EXPERIMENTER_HEADER_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;
 
-    /**
-     * Creates list of instructions
-     * @param input
-     * @param length
-     * @return list of ofp_instruction
-     */
-    public static List<Instruction> createInstructions(ByteBuf input, int length) {
-        List<Instruction> instructions = new ArrayList<>();
-        if (input.readableBytes() != 0) {
-            int lengthOfInstructions = length;
-            while (lengthOfInstructions > 0) {
-                InstructionBuilder builder = new InstructionBuilder();
-                int type = input.readUnsignedShort();
-                int instructionLength = input.readUnsignedShort();
-                lengthOfInstructions -= instructionLength;
-                switch (type) {
-                case 1:
-                    createGotoTableInstruction(builder, input);
-                    break;
-                case 2:
-                    createMetadataInstruction(builder, input);
-                    break;
-                case 3:
-                    builder.setType(WriteActions.class);
-                    createActionRelatedInstruction(input, builder, instructionLength - WRITE_APPLY_CLEAR_ACTION_LENGTH);
-                    break;
-                case 4:
-                    builder.setType(ApplyActions.class);
-                    createActionRelatedInstruction(input, builder, instructionLength - WRITE_APPLY_CLEAR_ACTION_LENGTH);
-                    break;
-                case 5:
-                    builder.setType(ClearActions.class);
-                    createActionRelatedInstruction(input, builder, instructionLength - WRITE_APPLY_CLEAR_ACTION_LENGTH);
-                    break;
-                case 6:
-                    builder.setType(Meter.class);
-                    MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder();
-                    meterBuilder.setMeterId(input.readUnsignedInt());
-                    builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build());
-                    break;
-                case 65535:
-                    builder.setType(Experimenter.class);
-                    ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();
-                    expBuilder.setExperimenter(input.readUnsignedInt());
-                    int dataLength = instructionLength - EXPERIMENTER_HEADER_LENGTH;
-                    if (dataLength > 0) {
-                        byte[] data = new byte[dataLength];
-                        input.readBytes(data);
-                        expBuilder.setData(data);
-                    }
-                    builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());
-                    break;
-                default:
-                    break;
-                }
-                instructions.add(builder.build());
-            }
+    @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 instructions;
+        return builder.build();
     }
 
-    /**
-     * Creates instruction ids (instructions without values)
-     * @param input
-     * @param length
-     * @return list of ofp_instruction without values
-     */
-    public static List<Instruction> createInstructionIds(ByteBuf input, int length) {
-        List<Instruction> instructions = new ArrayList<>();
-        if (input.readableBytes() != 0) {
-            int lengthOfInstructions = length;
-            while (lengthOfInstructions > 0) {
-                InstructionBuilder builder = new InstructionBuilder();
-                int type = input.readUnsignedShort();
-                int instructionLength = input.readUnsignedShort();
-                lengthOfInstructions -= instructionLength;
-                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;
-                }
-                instructions.add(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 instructions;
+        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());
@@ -167,8 +142,9 @@ public abstract class InstructionsDeserializer {
     
     private static void createMetadataInstruction(InstructionBuilder builder,
             ByteBuf input) {
-        input.skipBytes(WRITE_METADATA_PADDING);
         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);
@@ -179,12 +155,20 @@ public abstract class InstructionsDeserializer {
         builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build());
     }
     
-    private static void createActionRelatedInstruction(ByteBuf input,
-            InstructionBuilder builder, int actionsLength) {
+    private void createActionRelatedInstruction(ByteBuf input, InstructionBuilder builder) {
+        int instructionLength = input.readUnsignedShort();
         input.skipBytes(ACTIONS_RELATED_INSTRUCTION_PADDING);
         ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder();
-        actionsBuilder.setAction(ActionsDeserializer.createActions(input, actionsLength));
+        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;
+    }
 }
index fe05bf92da45c72c1188dd51f637376120b1c5ab..0128c99754110fa9c6cf945857e172f4f95f88a9 100644 (file)
@@ -10,135 +10,30 @@ package org.opendaylight.openflowjava.protocol.impl.util;
 
 import io.netty.buffer.ByteBuf;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
-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.BosMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
 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;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
-
-import com.google.common.base.Joiner;
 
 /**
  * Deserializes ofp_match (OpenFlow v1.3) and its oxm_fields structures
  * @author timotej.kubas
  * @author michal.polkorab
  */
-public abstract class MatchDeserializer {
+public class MatchDeserializer implements OFDeserializer<Match>,
+        DeserializerRegistryInjector {
+
+    private DeserializerRegistry registry;
 
-    /**
-     * Creates match
-     * @param in input ByteBuf
-     * @return ofp_match (OpenFlow v1.3)
-     */
-    public static Match createMatch(ByteBuf in) {
-        if (in.readableBytes() > 0) {
+    @Override
+    public Match deserialize(ByteBuf input) {
+        if (input.readableBytes() > 0) {
             MatchBuilder builder = new MatchBuilder();
-            int type = in.readUnsignedShort();
-            int length = in.readUnsignedShort();
+            int type = input.readUnsignedShort();
+            int length = input.readUnsignedShort();
             switch (type) {
             case 0:
                 builder.setType(StandardMatchType.class);
@@ -149,402 +44,19 @@ public abstract class MatchDeserializer {
             default:
                 break;
             }
-            builder.setMatchEntries(createMatchEntries(in, length - 2 * (EncodeConstants.SIZE_OF_SHORT_IN_BYTES)));
+            builder.setMatchEntries(DecodingUtils.deserializeMatchEntries(
+                    length - 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES, input, registry));
             int paddingRemainder = length % EncodeConstants.PADDING;
             if (paddingRemainder != 0) {
-                in.skipBytes(EncodeConstants.PADDING - paddingRemainder);
+                input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
             }
             return builder.build();
         }
         return null;
     }
 
-    /**
-     * Deserializes single match entry (oxm_field)
-     * @param in input ByteBuf
-     * @param matchLength length of match entry
-     * @return MatchEntriesList list containing one match entry
-     */
-    public static List<MatchEntries> createMatchEntry(ByteBuf in, int matchLength) {
-        return createMatchEntriesInternal(in, matchLength, true);
-    }
-
-    /**
-     * @param in input ByteBuf
-     * @param matchLength length of match entries
-     * @return MatchEntriesList list of match entries
-     */
-    public static List<MatchEntries> createMatchEntries(ByteBuf in, int matchLength) {
-        return createMatchEntriesInternal(in, matchLength, false);
-    }
-
-    private static List<MatchEntries> createMatchEntriesInternal(ByteBuf in, int matchLength, boolean oneEntry) {
-        List<MatchEntries> matchEntriesList = new ArrayList<>();
-        int currLength = 0;
-        while(currLength < matchLength) {
-            MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
-            switch (in.readUnsignedShort()) {
-            case 0x0000:
-                        matchEntriesBuilder.setOxmClass(Nxm0Class.class);
-                        break;
-            case 0x0001:
-                        matchEntriesBuilder.setOxmClass(Nxm1Class.class);
-                        break;
-            case 0x8000:
-                        matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
-                        break;
-            case 0xFFFF:
-                        matchEntriesBuilder.setOxmClass(ExperimenterClass.class);
-                        break;
-            default:
-                        break;
-            }
-
-            int fieldAndMask = in.readUnsignedByte();
-            boolean hasMask = (fieldAndMask & 1) != 0;
-            matchEntriesBuilder.setHasMask(hasMask);
-            int matchField =  fieldAndMask >> 1;
-            int matchEntryLength = in.readUnsignedByte();
-            currLength += EncodeConstants.SIZE_OF_SHORT_IN_BYTES +
-                    (2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES) + matchEntryLength;
-
-            switch(matchField) {
-            case 0:
-                matchEntriesBuilder.setOxmMatchField(InPort.class);
-                PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder();
-                port.setPortNumber(new PortNumber(in.readUnsignedInt()));
-                matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, port.build());
-                break;
-            case 1:
-                matchEntriesBuilder.setOxmMatchField(InPhyPort.class);
-                PortNumberMatchEntryBuilder phyPort = new PortNumberMatchEntryBuilder();
-                phyPort.setPortNumber(new PortNumber(in.readUnsignedInt()));
-                matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, phyPort.build());
-                break;
-            case 2:
-                matchEntriesBuilder.setOxmMatchField(Metadata.class);
-                addMetadataAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
-                }
-                break;
-            case 3:
-                matchEntriesBuilder.setOxmMatchField(EthDst.class);
-                addMacAddressAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
-                }
-                break;
-            case 4:
-                matchEntriesBuilder.setOxmMatchField(EthSrc.class);
-                addMacAddressAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
-                }
-                break;
-            case 5:
-                matchEntriesBuilder.setOxmMatchField(EthType.class);
-                EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder();
-                ethertypeBuilder.setEthType(new EtherType(in.readUnsignedShort()));
-                matchEntriesBuilder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build());
-                break;
-            case 6:
-                matchEntriesBuilder.setOxmMatchField(VlanVid.class);
-                VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
-                int vidEntryValue = in.readUnsignedShort();
-                vlanVidBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit
-                vlanVidBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit
-                matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-                }
-                break;
-            case 7:
-                matchEntriesBuilder.setOxmMatchField(VlanPcp.class);
-                VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder();
-                vlanPcpBuilder.setVlanPcp(in.readUnsignedByte());
-                matchEntriesBuilder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build());
-                break;
-            case 8:
-                matchEntriesBuilder.setOxmMatchField(IpDscp.class);
-                DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder();
-                dscpBuilder.setDscp(new Dscp(in.readUnsignedByte()));
-                matchEntriesBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build());
-                break;
-            case 9:
-                matchEntriesBuilder.setOxmMatchField(IpEcn.class);
-                EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder();
-                ecnBuilder.setEcn(in.readUnsignedByte());
-                matchEntriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build());
-                break;
-            case 10:
-                matchEntriesBuilder.setOxmMatchField(IpProto.class);
-                ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder();
-                protoNumberBuilder.setProtocolNumber(in.readUnsignedByte());
-                matchEntriesBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build());
-                break;
-            case 11:
-                matchEntriesBuilder.setOxmMatchField(Ipv4Src.class);
-                addIpv4AddressAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
-                }
-                break;
-            case 12:
-                matchEntriesBuilder.setOxmMatchField(Ipv4Dst.class);
-                addIpv4AddressAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
-                }
-                break;
-            case 13:
-                matchEntriesBuilder.setOxmMatchField(TcpSrc.class);
-                addPortAugmentation(matchEntriesBuilder, in);
-                break;
-            case 14:
-                matchEntriesBuilder.setOxmMatchField(TcpDst.class);
-                addPortAugmentation(matchEntriesBuilder, in);
-                break;
-            case 15:
-                matchEntriesBuilder.setOxmMatchField(UdpSrc.class);
-                addPortAugmentation(matchEntriesBuilder, in);
-                break;
-            case 16:
-                matchEntriesBuilder.setOxmMatchField(UdpDst.class);
-                addPortAugmentation(matchEntriesBuilder, in);
-                break;
-            case 17:
-                matchEntriesBuilder.setOxmMatchField(SctpSrc.class);
-                addPortAugmentation(matchEntriesBuilder, in);
-                break;
-            case 18:
-                matchEntriesBuilder.setOxmMatchField(SctpDst.class);
-                addPortAugmentation(matchEntriesBuilder, in);
-                break;
-            case 19:
-                matchEntriesBuilder.setOxmMatchField(Icmpv4Type.class);
-                Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder();
-                icmpv4TypeBuilder.setIcmpv4Type(in.readUnsignedByte());
-                matchEntriesBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build());
-                break;
-            case 20:
-                matchEntriesBuilder.setOxmMatchField(Icmpv4Code.class);
-                Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder();
-                icmpv4CodeBuilder.setIcmpv4Code(in.readUnsignedByte());
-                matchEntriesBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build());
-                break;
-            case 21:
-                matchEntriesBuilder.setOxmMatchField(ArpOp.class);
-                OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder();
-                opcodeBuilder.setOpCode(in.readUnsignedShort());
-                matchEntriesBuilder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build());
-                break;
-            case 22:
-                matchEntriesBuilder.setOxmMatchField(ArpSpa.class);
-                addIpv4AddressAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
-                }
-                break;
-            case 23:
-                matchEntriesBuilder.setOxmMatchField(ArpTpa.class);
-                addIpv4AddressAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
-                }
-                break;
-            case 24:
-                matchEntriesBuilder.setOxmMatchField(ArpSha.class);
-                addMacAddressAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
-                }
-                break;
-            case 25:
-                matchEntriesBuilder.setOxmMatchField(ArpTha.class);
-                addMacAddressAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
-                }
-                break;
-            case 26:
-                matchEntriesBuilder.setOxmMatchField(Ipv6Src.class);
-                addIpv6AddressAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
-                }
-                break;
-            case 27:
-                matchEntriesBuilder.setOxmMatchField(Ipv6Dst.class);
-                addIpv6AddressAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
-                }
-                break;
-            case 28:
-                matchEntriesBuilder.setOxmMatchField(Ipv6Flabel.class);
-                Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder();
-                ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(in.readUnsignedInt()));
-                matchEntriesBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build());
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
-                }
-                break;
-            case 29:
-                matchEntriesBuilder.setOxmMatchField(Icmpv6Type.class);
-                Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder();
-                icmpv6TypeBuilder.setIcmpv6Type(in.readUnsignedByte());
-                matchEntriesBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build());
-                break;
-            case 30:
-                matchEntriesBuilder.setOxmMatchField(Icmpv6Code.class);
-                Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder();
-                icmpv6CodeBuilder.setIcmpv6Code(in.readUnsignedByte());
-                matchEntriesBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build());
-                break;
-            case 31:
-                matchEntriesBuilder.setOxmMatchField(Ipv6NdTarget.class);
-                addIpv6AddressAugmentation(matchEntriesBuilder, in);
-                break;
-            case 32:
-                matchEntriesBuilder.setOxmMatchField(Ipv6NdSll.class);
-                addMacAddressAugmentation(matchEntriesBuilder, in);
-                break;
-            case 33:
-                matchEntriesBuilder.setOxmMatchField(Ipv6NdTll.class);
-                addMacAddressAugmentation(matchEntriesBuilder, in);
-                break;
-            case 34:
-                matchEntriesBuilder.setOxmMatchField(MplsLabel.class);
-                MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder();
-                mplsLabelBuilder.setMplsLabel(in.readUnsignedInt());
-                matchEntriesBuilder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build());
-                break;
-            case 35:
-                matchEntriesBuilder.setOxmMatchField(MplsTc.class);
-                TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder();
-                tcBuilder.setTc(in.readUnsignedByte());
-                matchEntriesBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build());
-                break;
-            case 36:
-                matchEntriesBuilder.setOxmMatchField(MplsBos.class);
-                BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder();
-                if (in.readUnsignedByte() != 0) {
-                    bosBuilder.setBos(true);
-                } else {
-                    bosBuilder.setBos(false);
-                }
-                matchEntriesBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build());
-                break;
-            case 37:
-                matchEntriesBuilder.setOxmMatchField(PbbIsid.class);
-                IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder();
-                Integer isid = in.readUnsignedMedium();
-                isidBuilder.setIsid(isid.longValue());
-                matchEntriesBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build());
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_3_BYTES);
-                }
-                break;
-            case 38:
-                matchEntriesBuilder.setOxmMatchField(TunnelId.class);
-                addMetadataAugmentation(matchEntriesBuilder, in);
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
-                }
-                break;
-            case 39:
-                matchEntriesBuilder.setOxmMatchField(Ipv6Exthdr.class);
-                PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder();
-                int bitmap = in.readUnsignedShort();
-                final Boolean NONEXT = ((bitmap) & (1<<0)) != 0;
-                final Boolean ESP = ((bitmap) & (1<<1)) != 0;
-                final Boolean AUTH = ((bitmap) & (1<<2)) != 0;
-                final Boolean DEST = ((bitmap) & (1<<3)) != 0;
-                final Boolean FRAG = ((bitmap) & (1<<4)) != 0;
-                final Boolean ROUTER = ((bitmap) & (1<<5)) != 0;
-                final Boolean HOP = ((bitmap) & (1<<6)) != 0;
-                final Boolean UNREP = ((bitmap) & (1<<7)) != 0;
-                final Boolean UNSEQ = ((bitmap) & (1<<8)) != 0;
-                pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(AUTH, DEST, ESP, FRAG, HOP, NONEXT, ROUTER, UNREP, UNSEQ));
-                matchEntriesBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build());
-                if (hasMask) {
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-                }
-                break;
-            default:
-                break;
-            }
-          matchEntriesList.add(matchEntriesBuilder.build());
-          if (oneEntry) {
-              break;
-          }
-        }
-        if ((matchLength - currLength) > 0) {
-            in.skipBytes(matchLength - currLength);
-        }
-        return matchEntriesList;
-    }
-
-    /** Decodes oxm ids
-     * @param in input ByteBuf
-     * @param matchLength match entries length
-     * @return list of match ids
-     */
-    public static List<MatchEntries> createMatchIds(ByteBuf in, int matchLength) {
-        return MatchIdsDeserializer.createOxmIds(in, matchLength);
-    }
-
-    private static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf in, int matchEntryLength) {
-        MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();
-        byte[] mask = new byte[matchEntryLength];
-        in.readBytes(mask);
-        maskBuilder.setMask(mask);
-        builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());
-    }
-
-    private static void addIpv6AddressAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
-        Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder();
-        List<String> groups = new ArrayList<>();
-        for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV6_ADDRESS; i++) {
-            groups.add(String.format("%04X", in.readUnsignedShort()));
-        }
-        Joiner joiner = Joiner.on(":");
-        ipv6AddressBuilder.setIpv6Address(new Ipv6Address(joiner.join(groups)));
-        builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());
-    }
-
-    private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
-        MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder();
-        byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
-        in.readBytes(metadataBytes);
-        metadata.setMetadata(metadataBytes);
-        builder.addAugmentation(MetadataMatchEntry.class, metadata.build());
-    }
-
-    private static void addIpv4AddressAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
-        Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();
-        List<String> groups = new ArrayList<>();
-        for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {
-            groups.add(Short.toString(in.readUnsignedByte()));
-        }
-        Joiner joiner = Joiner.on(".");
-        ipv4AddressBuilder.setIpv4Address(new Ipv4Address(joiner.join(groups)));
-        builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());
-    }
-
-    private static void addMacAddressAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
-        MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder();
-        byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
-        in.readBytes(address);
-        macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));
-        builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build());
-    }
-
-    private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
-        PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder();
-        portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.
-                xml.ns.yang.ietf.inet.types.rev100924.PortNumber(in.readUnsignedShort()));
-        builder.addAugmentation(PortMatchEntry.class, portBuilder.build());
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        this.registry = deserializerRegistry;
     }
 }
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java
new file mode 100644 (file)
index 0000000..102d1f0
--- /dev/null
@@ -0,0 +1,47 @@
+/*\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 org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;\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
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class MatchEntryDeserializerRegistryHelper {\r
+\r
+    private short version;\r
+    private DeserializerRegistry registry;\r
+    private int oxmClass;\r
+\r
+    /**\r
+     * @param version wire protocol version\r
+     * @param oxmClass oxm_class that will be used for match entry deserializer\r
+     *  registration\r
+     * @param deserializerRegistry registry to be filled with message deserializers\r
+     */\r
+    public MatchEntryDeserializerRegistryHelper(short version, int oxmClass,\r
+            DeserializerRegistry deserializerRegistry) {\r
+        this.version = version;\r
+        this.oxmClass = oxmClass;\r
+        this.registry = deserializerRegistry;\r
+    }\r
+\r
+    /**\r
+     * Registers match entry deserializer under provided oxmfield ()\r
+     * @param oxmField oxm_field value/code\r
+     * @param deserializer deserializer instance\r
+     */\r
+    public void register(int oxmField, OFGeneralDeserializer deserializer) {\r
+        registry.registerDeserializer(new EnhancedMessageCodeKey(version, oxmClass,\r
+                oxmField, MatchEntries.class), deserializer);\r
+    }\r
+}\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MessageDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MessageDeserializerRegistryHelper.java
new file mode 100644 (file)
index 0000000..e31dea3
--- /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
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\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.OFGeneralDeserializer;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class MessageDeserializerRegistryHelper {\r
+\r
+    private short version;\r
+    private DeserializerRegistry registry;\r
+\r
+    /**\r
+     * @param version wire protocol version\r
+     * @param deserializerRegistry registry to be filled with message deserializers\r
+     */\r
+    public MessageDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) {\r
+        this.version = version;\r
+        this.registry = deserializerRegistry;\r
+    }\r
+\r
+    /**\r
+     * @param code code / value to distinguish between deserializers\r
+     * @param deserializedObjectClass class of object that will be deserialized\r
+     *  by given deserializer\r
+     * @param deserializer deserializer instance\r
+     */\r
+    public void registerMessageDeserializer(int code,\r
+            Class<?> deserializedObjectClass, OFGeneralDeserializer deserializer) {\r
+        registry.registerDeserializer(new MessageCodeKey(version, code,\r
+                deserializedObjectClass), deserializer);\r
+    }\r
+}\r
index 64372b1eb1f579a87d8c49a4f7506356c4b7510e..75be481a9226f273bacb5bf124555bb84beaba6b 100644 (file)
@@ -13,12 +13,15 @@ import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
@@ -34,7 +37,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc;
@@ -57,7 +59,8 @@ import com.google.common.base.Joiner;
  * Deserializes ofp_action (OpenFlow v1.0) structures
  * @author michal.polkorab
  */
-public abstract class OF10ActionsDeserializer {
+public class OF10ActionsDeserializer implements OFDeserializer<Action>,
+        DeserializerRegistryInjector {
     
     private static final byte PADDING_IN_SET_VLAN_VID_ACTION = 2;
     private static final byte PADDING_IN_SET_VLAN_PCP_ACTION = 3;
@@ -66,41 +69,12 @@ public abstract class OF10ActionsDeserializer {
     private static final byte PADDING_IN_NW_TOS_ACTION = 3;
     private static final byte PADDING_IN_TP_ACTION = 2;
     private static final byte PADDING_IN_ENQUEUE_ACTION = 6;
+    private DeserializerRegistry registry;
 
-    /**
-     * Creates list of actions (OpenFlow v1.0) from ofp_action structures
-     * @param input input ByteBuf
-     * @return ActionsList list of actions
-     */
-    public static List<Action> createActionsList(ByteBuf input) {
-        List<Action> actions = new ArrayList<>();
-        while (input.readableBytes() > 0) {
-            int type = input.readUnsignedShort();
-            input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-            actions.add(decodeAction(input, type));
-        } 
-        return actions;
-    }
-
-    /**
-     * Creates list of actions (OpenFlow v1.0) from ofp_action structures, which are not the last structure
-     * in message
-     * @param input input ByteBuf
-     * @param actionsLength length of actions
-     * @return ActionsList list of actions
-     */
-    public static List<Action> createActionsList(ByteBuf input, int actionsLength) {
-        List<Action> actions = new ArrayList<>();
-        int currentLength = 0;
-        while (currentLength < actionsLength) {
-            int type = input.readUnsignedShort();
-            currentLength += input.readUnsignedShort();
-            actions.add(decodeAction(input, type));
-        } 
-        return actions;
-    }
-
-    private static Action decodeAction(ByteBuf input, int type) {
+    @Override
+    public Action deserialize(ByteBuf input) {
+        int type = input.readUnsignedShort();
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         ActionBuilder actionsBuilder = new ActionBuilder();
         Action actionsList = null;
         switch(type) {
@@ -141,7 +115,9 @@ public abstract class OF10ActionsDeserializer {
             actionsList = createEnqueueAction(input, actionsBuilder);
             break;
         case 0xFFFF:
-            actionsList = createExperimenterAction(input, actionsBuilder);
+            OFDeserializer<ExperimenterAction> expDeserializer = registry.getDeserializer(
+                    new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 0xFFFF, ExperimenterAction.class));
+            expDeserializer.deserialize(input);
             break;
         default:
             break;
@@ -270,12 +246,8 @@ public abstract class OF10ActionsDeserializer {
         return builder.build();
     }
 
-    private static Action createExperimenterAction(ByteBuf input, ActionBuilder builder) {
-        builder.setType(Experimenter.class);
-        ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder();
-        expBuilder.setExperimenter(input.readUnsignedInt());
-        builder.addAugmentation(ExperimenterAction.class, expBuilder.build());
-        return builder.build();
+    @Override
+    public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+        registry = deserializerRegistry;
     }
-
 }
index 88fc3129c201893477bb96bfb4da86fe8dfe99b5..393f42ba4926bbec7c1f066168a710adb0f5cd37 100644 (file)
@@ -13,6 +13,7 @@ import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
@@ -25,8 +26,8 @@ import com.google.common.base.Joiner;
  * Deserializes ofp_match (OpenFlow v1.0) structure
  * @author michal.polkorab
  */
-public abstract class OF10MatchDeserializer {
-    
+public class OF10MatchDeserializer implements OFDeserializer<MatchV10> {
+
     private static final byte PADDING_IN_MATCH = 1;
     private static final byte PADDING_IN_MATCH_2 = 2;
     private static final byte NW_SRC_BITS = 6;
@@ -36,48 +37,44 @@ public abstract class OF10MatchDeserializer {
     private static final byte NW_DST_SHIFT = 14;
     private static final int NW_DST_MASK = ((1 << NW_DST_BITS) - 1) << NW_DST_SHIFT;
 
-    /**
-     * Creates ofp_match (OpenFlow v1.0) structure
-     * @param rawMessage ByteBuf with input data
-     * @return ofp_match (OpenFlow v1.0)
-     */
-    public static MatchV10 createMatchV10(ByteBuf rawMessage) {
+    @Override
+    public MatchV10 deserialize(ByteBuf input) {
         MatchV10Builder builder = new MatchV10Builder();
-        long wildcards = rawMessage.readUnsignedInt();
+        long wildcards = input.readUnsignedInt();
         builder.setWildcards(createWildcards(wildcards));
         builder.setNwSrcMask(decodeNwSrcMask(wildcards));
         builder.setNwDstMask(decodeNwDstMask(wildcards));
-        builder.setInPort(rawMessage.readUnsignedShort());
+        builder.setInPort(input.readUnsignedShort());
         byte[] dlSrc = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
-        rawMessage.readBytes(dlSrc);
+        input.readBytes(dlSrc);
         builder.setDlSrc(new MacAddress(ByteBufUtils.macAddressToString(dlSrc)));
         byte[] dlDst = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
-        rawMessage.readBytes(dlDst);
+        input.readBytes(dlDst);
         builder.setDlDst(new MacAddress(ByteBufUtils.macAddressToString(dlDst)));
 
-        builder.setDlVlan(rawMessage.readUnsignedShort());
-        builder.setDlVlanPcp(rawMessage.readUnsignedByte());
-        rawMessage.skipBytes(PADDING_IN_MATCH);
-        builder.setDlType(rawMessage.readUnsignedShort());
-        builder.setNwTos(rawMessage.readUnsignedByte());
-        builder.setNwProto(rawMessage.readUnsignedByte());
-        rawMessage.skipBytes(PADDING_IN_MATCH_2);
+        builder.setDlVlan(input.readUnsignedShort());
+        builder.setDlVlanPcp(input.readUnsignedByte());
+        input.skipBytes(PADDING_IN_MATCH);
+        builder.setDlType(input.readUnsignedShort());
+        builder.setNwTos(input.readUnsignedByte());
+        builder.setNwProto(input.readUnsignedByte());
+        input.skipBytes(PADDING_IN_MATCH_2);
         List<String> srcGroups = new ArrayList<>();
         for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {
-            srcGroups.add(Short.toString(rawMessage.readUnsignedByte()));
+            srcGroups.add(Short.toString(input.readUnsignedByte()));
         }
         Joiner joiner = Joiner.on(".");
         builder.setNwSrc(new Ipv4Address(joiner.join(srcGroups)));
         List<String> dstGroups = new ArrayList<>();
         for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {
-            dstGroups.add(Short.toString(rawMessage.readUnsignedByte()));
+            dstGroups.add(Short.toString(input.readUnsignedByte()));
         }
         builder.setNwDst(new Ipv4Address(joiner.join(dstGroups)));
-        builder.setTpSrc(rawMessage.readUnsignedShort());
-        builder.setTpDst(rawMessage.readUnsignedShort());
+        builder.setTpSrc(input.readUnsignedShort());
+        builder.setTpDst(input.readUnsignedShort());
         return builder.build();
     }
-    
+
     /**
      * Decodes FlowWildcards
      * @param input input ByteBuf
@@ -115,5 +112,4 @@ public abstract class OF10MatchDeserializer {
     public static short decodeNwDstMask(long input) {
         return (short) Math.max(32 - ((input & NW_DST_MASK) >> NW_DST_SHIFT), 0);
     }
-    
 }
index 9e3f829d21998e32231d3340d7d69a1c32ac097c..408cbb6975c06ccc552264233a23902157da26a0 100644 (file)
@@ -22,7 +22,7 @@ public abstract class OxmMatchConstants {
     public static final int OPENFLOW_BASIC_CLASS = 0x8000;\r
     /** Experimenter class */\r
     public static final int EXPERIMENTER_CLASS = 0xFFFF;\r
-    \r
+\r
     /** Switch input port */\r
     public static final int IN_PORT = 0;\r
     /** Switch physical input port */\r
@@ -103,4 +103,4 @@ public abstract class OxmMatchConstants {
     public static final int TUNNEL_ID = 38;\r
     /** IPv6 Extension Header pseudo-field */\r
     public static final int IPV6_EXTHDR = 39;\r
-}\r
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java
new file mode 100644 (file)
index 0000000..246c410
--- /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
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import java.util.Map;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.TypeToClassKey;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class TypeToClassInitHelper {\r
+\r
+    private short version;\r
+    private Map<TypeToClassKey, Class<?>> messageClassMap;\r
+\r
+    /**\r
+     * Constructor\r
+     * @param version protocol wire version\r
+     * @param messageClassMap map which stores type to class mapping\r
+     */\r
+    public TypeToClassInitHelper(short version, Map<TypeToClassKey, \r
+            Class<?>> messageClassMap) {\r
+        this.version = version;\r
+        this.messageClassMap = messageClassMap;\r
+    }\r
+\r
+    /**\r
+     * Registers Class int the type to class mapping\r
+     * @param type code value for message type / class\r
+     * @param clazz corresponding code -> class\r
+     */\r
+    public void registerTypeToClass(short type, Class<?> clazz) {\r
+        messageClassMap.put(new TypeToClassKey(version, type), clazz);\r
+    }\r
+}\r
index 51c700e74a612f18f5bd9a847c8ad006f8815e8c..8bc381a8faffcb67e3e16e41b8c593f05e4e544d 100644 (file)
@@ -10,8 +10,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
 
 /**
@@ -20,27 +26,28 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class BarrierReplyMessageFactoryTest {
 
+    private OFDeserializer<BarrierOutput> barrierFactory;
+
     /**
-     * Testing of {@link BarrierReplyMessageFactory} for correct translation into POJO
+     * Initializes deserializer registry and lookups correct deserializer
      */
-    @Test
-    public void test() {
-        ByteBuf bb = BufferHelper.buildBuffer();
-        BarrierOutput builtByFactory = BufferHelper.decodeV13(
-                BarrierReplyMessageFactory.getInstance(), bb);
-
-        BufferHelper.checkHeaderV13(builtByFactory);
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        barrierFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 21, BarrierOutput.class));
     }
-    
+
     /**
      * Testing of {@link BarrierReplyMessageFactory} for correct translation into POJO
      */
     @Test
-    public void testV10() {
+    public void test() {
         ByteBuf bb = BufferHelper.buildBuffer();
-        BarrierOutput builtByFactory = BufferHelper.decodeV10(
-                BarrierReplyMessageFactory.getInstance(), bb);
+        BarrierOutput builtByFactory = BufferHelper.deserialize(
+                barrierFactory, bb);
 
-        BufferHelper.checkHeaderV10(builtByFactory);
+        BufferHelper.checkHeaderV13(builtByFactory);
     }
 }
index b257d9d74ddffa03aaaa52026dcad1ef77fb6774..ae184295647c858eab0aa539a8a5a72701a1f20a 100644 (file)
@@ -11,9 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
 
 /**
@@ -22,56 +27,40 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class EchoReplyMessageFactoryTest {
 
-    /**
-     * Testing {@link EchoReplyMessageFactory} for correct translation into POJO
-     */
-    @Test
-    public void testWithEmptyDataField() {
-        ByteBuf bb = BufferHelper.buildBuffer();
-        EchoOutput builtByFactory = BufferHelper.decodeV13(
-                EchoReplyMessageFactory.getInstance(), bb);
+    private OFDeserializer<EchoOutput> echoFactory;
 
-        BufferHelper.checkHeaderV13(builtByFactory);
-    }
-    
     /**
-     * Testing {@link EchoReplyMessageFactory} for correct translation into POJO
+     * Initializes deserializer registry and lookups correct deserializer
      */
-    @Test
-    public void testWithDataFieldSet() {
-        byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
-        ByteBuf bb = BufferHelper.buildBuffer(data);
-        EchoOutput builtByFactory = BufferHelper.decodeV13(
-                EchoReplyMessageFactory.getInstance(), bb);
-        
-        BufferHelper.checkHeaderV13(builtByFactory);
-        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        echoFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 3, EchoOutput.class));
     }
-    
+
     /**
      * Testing {@link EchoReplyMessageFactory} for correct translation into POJO
      */
     @Test
-    public void testWithEmptyDataFieldV10() {
+    public void testWithEmptyDataField() {
         ByteBuf bb = BufferHelper.buildBuffer();
-        EchoOutput builtByFactory = BufferHelper.decodeV10(
-                EchoReplyMessageFactory.getInstance(), bb);
+        EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb);
 
-        BufferHelper.checkHeaderV10(builtByFactory);
+        BufferHelper.checkHeaderV13(builtByFactory);
     }
     
     /**
      * Testing {@link EchoReplyMessageFactory} for correct translation into POJO
      */
     @Test
-    public void testWithDataFieldSetV10() {
+    public void testWithDataFieldSet() {
         byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
         ByteBuf bb = BufferHelper.buildBuffer(data);
-        EchoOutput builtByFactory = BufferHelper.decodeV10(
-                EchoReplyMessageFactory.getInstance(), bb);
+        EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb);
         
-        BufferHelper.checkHeaderV10(builtByFactory);
+        BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
     }
-
 }
index bcb125342b8867ebf49ae9072dbbcfb4f74629ef..7b6a6305e2e83b007751f239471f4dbe75042f88 100644 (file)
@@ -11,9 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
 
 /**
@@ -22,56 +27,40 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class EchoRequestMessageFactoryTest {
 
-    /**
-     * Testing {@link EchoRequestMessageFactory} for correct translation into POJO
-     */
-    @Test
-    public void testWithEmptyDataField() {
-        ByteBuf bb = BufferHelper.buildBuffer();
-        EchoRequestMessage builtByFactory = BufferHelper.decodeV13(
-                EchoRequestMessageFactory.getInstance(), bb);
+    private OFDeserializer<EchoRequestMessage> echoFactory;
 
-        BufferHelper.checkHeaderV13(builtByFactory);
-    }
-    
     /**
-     * Testing {@link EchoRequestMessageFactory} for correct translation into POJO
+     * Initializes deserializer registry and lookups correct deserializer
      */
-    @Test
-    public void testWithDataFieldSet() {
-        byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
-        ByteBuf bb = BufferHelper.buildBuffer(data);
-        EchoRequestMessage builtByFactory = BufferHelper.decodeV13(
-                EchoRequestMessageFactory.getInstance(), bb);
-
-        BufferHelper.checkHeaderV13(builtByFactory);
-        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        echoFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 2, EchoRequestMessage.class));
     }
-    
+
     /**
      * Testing {@link EchoRequestMessageFactory} for correct translation into POJO
      */
     @Test
-    public void testWithEmptyDataFieldV10() {
+    public void testWithEmptyDataField() {
         ByteBuf bb = BufferHelper.buildBuffer();
-        EchoRequestMessage builtByFactory = BufferHelper.decodeV10(
-                EchoRequestMessageFactory.getInstance(), bb);
+        EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb);
 
-        BufferHelper.checkHeaderV10(builtByFactory);
+        BufferHelper.checkHeaderV13(builtByFactory);
     }
     
     /**
      * Testing {@link EchoRequestMessageFactory} for correct translation into POJO
      */
     @Test
-    public void testWithDataFieldSetV10() {
+    public void testWithDataFieldSet() {
         byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
         ByteBuf bb = BufferHelper.buildBuffer(data);
-        EchoRequestMessage builtByFactory = BufferHelper.decodeV10(
-                EchoRequestMessageFactory.getInstance(), bb);
+        EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb);
 
-        BufferHelper.checkHeaderV10(builtByFactory);
+        BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
     }
-
 }
index e139a77ad1ef912cceab1cce9d74cea76887eab4..5df6b7719b987544f162d68c94dfe2e91934eca0 100644 (file)
@@ -11,8 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
 
 /**
@@ -21,14 +27,26 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class ErrorMessageFactoryTest {
 
+    private OFDeserializer<ErrorMessage> errorFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        errorFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 1, ErrorMessage.class));
+    }
+
     /**
      * Test of {@link ErrorMessageFactory} for correct translation into POJO
      */
     @Test
     public void testWithoutData() {
         ByteBuf bb = BufferHelper.buildBuffer("00 01 00 02");
-        ErrorMessage builtByFactory = BufferHelper.decodeV13(
-                ErrorMessageFactory.getInstance(), bb);
+        ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue());
@@ -44,8 +62,7 @@ public class ErrorMessageFactoryTest {
     @Test
     public void testWithData() {
         ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 01 02 03");
-        ErrorMessage builtByFactory = BufferHelper.decodeV13(
-                ErrorMessageFactory.getInstance(), bb);
+        ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue());
@@ -61,8 +78,7 @@ public class ErrorMessageFactoryTest {
     @Test
     public void testWithIncorrectTypeEnum() {
         ByteBuf bb = BufferHelper.buildBuffer("00 20 00 05 00 01 02 03");
-        ErrorMessage builtByFactory = BufferHelper.decodeV13(
-                ErrorMessageFactory.getInstance(), bb);
+        ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 32, builtByFactory.getType().intValue());
@@ -78,8 +94,7 @@ public class ErrorMessageFactoryTest {
     @Test
     public void testWithIncorrectCodeEnum() {
         ByteBuf bb = BufferHelper.buildBuffer("00 03 00 10 00 01 02 03");
-        ErrorMessage builtByFactory = BufferHelper.decodeV13(
-                ErrorMessageFactory.getInstance(), bb);
+        ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java
deleted file mode 100644 (file)
index 3f861bb..0000000
+++ /dev/null
@@ -1,38 +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.deserialization.factories;
-
-import io.netty.buffer.ByteBuf;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
-
-/**
- * @author michal.polkorab
- *
- */
-public class ExperimenterMessageFactoryTest {
-
-    /**
-     * Testing {@link ExperimenterMessageFactory} for correct translation into POJO
-     */
-    @Test
-    public void test() {
-        ByteBuf bb = BufferHelper.buildBuffer("01 02 03 04 01 02 03 04");
-        ExperimenterMessage builtByFactory = BufferHelper.decodeV13(
-                ExperimenterMessageFactory.getInstance(), bb);
-
-        BufferHelper.checkHeaderV13(builtByFactory);
-        Assert.assertEquals("Wrong experimenter", 0x01020304L, builtByFactory.getExperimenter().longValue());
-        Assert.assertEquals("Wrong expType", 0x01020304L, builtByFactory.getExpType().longValue());
-    }
-
-}
index be6dc48c98468a9f0f1e7b2231f23b149e442b3f..c12a4ec6b41a7affab345506e5d96690a1d1a7db 100644 (file)
@@ -11,8 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 
@@ -22,6 +28,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class FeaturesReplyMessageFactoryTest {
 
+    private OFDeserializer<GetFeaturesOutput> featuresFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        featuresFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 6, GetFeaturesOutput.class));
+    }
+
     /**
      * Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO
      */
@@ -29,8 +48,7 @@ public class FeaturesReplyMessageFactoryTest {
     public void test() {
         ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00"
                 + " 00 01 41 00 01 02 03");
-        GetFeaturesOutput builtByFactory = BufferHelper.decodeV13(
-                FeaturesReplyMessageFactory.getInstance(), bb);
+        GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
index 4682c14760a817b6dc46b3dd60ea1c7a1876aac5..cc5709d15a0ac7420c68df0fe46c4906fe476f87 100644 (file)
@@ -11,8 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
 
@@ -22,6 +28,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class FlowRemovedMessageFactoryTest {
 
+    private OFDeserializer<FlowRemovedMessage> flowFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        flowFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 11, FlowRemovedMessage.class));
+    }
+
     /**
      * Testing {@link FlowRemovedMessageFactory} for correct translation into POJO
      */
@@ -29,7 +48,7 @@ public class FlowRemovedMessageFactoryTest {
     public void test(){
         ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 03 02 04 00 00 00 02"
                 + " 00 00 00 05 00 01 00 03 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07");
-        FlowRemovedMessage builtByFactory = BufferHelper.decodeV13(FlowRemovedMessageFactory.getInstance(), bb);
+        FlowRemovedMessage builtByFactory = BufferHelper.deserialize(flowFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
         
index 0326720dac3c0b471bf4c60eb521e267b75f4823..8cc9f8cd8626b2abc9a1fa8460553ec3cf41d026 100644 (file)
@@ -14,8 +14,14 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
@@ -32,7 +38,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  *
  */
 public class GetAsyncReplyMessageFactoryTest {
-    
+
+    private OFDeserializer<GetAsyncOutput> asyncFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        asyncFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 27, GetAsyncOutput.class));
+    }
 
     /**
      * Testing {@link GetAsyncReplyMessageFactory} for correct translation into POJO
@@ -45,7 +63,7 @@ public class GetAsyncReplyMessageFactoryTest {
                                               "00 00 00 00 "+
                                               "00 00 00 03 "+
                                               "00 00 00 0A");
-        GetAsyncOutput builtByFactory = BufferHelper.decodeV13(GetAsyncReplyMessageFactory.getInstance(), bb);
+        GetAsyncOutput builtByFactory = BufferHelper.deserialize(asyncFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong packetInMask",createPacketInMask(), 
index 3e39ecb742778aecf6b4bb37857f790de87fffa5..13bbb2a8abe1a241764c29f13c85837681c1ef11 100644 (file)
@@ -11,8 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
 
 /**
@@ -21,14 +27,26 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class GetConfigReplyMessageFactoryTest {
 
+    private OFDeserializer<GetConfigOutput> configFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        configFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 8, GetConfigOutput.class));
+    }
+
     /**
      * Testing {@link GetConfigReplyMessageFactory} for correct translation into POJO
      */
     @Test
     public void test() {
         ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03");
-        GetConfigOutput builtByFactory = BufferHelper.decodeV13(
-                GetConfigReplyMessageFactory.getInstance(), bb);
+        GetConfigOutput builtByFactory = BufferHelper.deserialize(configFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue()); 
index 0ab67a9ae871efd5cf5bcbd7648a4c5ae3d68c44..d8bd93ee07767a407d85f26400a65800c160b660 100644 (file)
@@ -8,14 +8,20 @@
 
 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
+import io.netty.buffer.ByteBuf;
+
 import java.util.ArrayList;
 import java.util.List;
 
-import io.netty.buffer.ByteBuf;
-
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;
@@ -29,6 +35,18 @@ public class HelloMessageFactoryTest {
 
     /** Number of currently supported version / codec */
     public static final Short VERSION_YET_SUPPORTED = 0x04;
+    private OFDeserializer<HelloMessage> helloFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        helloFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0, HelloMessage.class));
+    }
 
     /**
      * Testing {@link HelloMessageFactory} for correct translation into POJO
@@ -41,8 +59,7 @@ public class HelloMessageFactoryTest {
                                             + "00 00 00 00 " // bitmap 2
                                             + "00 00 00 00"  // padding
                 );
-        HelloMessage builtByFactory = BufferHelper.decodeV13(
-                HelloMessageFactory.getInstance(), bb);
+        HelloMessage builtByFactory = BufferHelper.deserialize(helloFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
         List<Elements> element = createElement();
index db08791a8f50740ef828e10ff436cc9ff3f74f99..cf39f0fd4612b3e195b456c29c565dcfbd8fbdec 100644 (file)
@@ -13,9 +13,15 @@ import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 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.EthertypeAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
@@ -94,6 +100,19 @@ import org.slf4j.LoggerFactory;
  */
 public class MultipartReplyMessageFactoryTest {
 
+    private OFDeserializer<MultipartReplyMessage> multipartFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        multipartFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class));
+    }
+
     private static final Logger LOGGER = LoggerFactory
             .getLogger(MultipartReplyMessageFactoryTest.class);
     
@@ -136,7 +155,7 @@ public class MultipartReplyMessageFactoryTest {
         bb.writeBytes(dpDescBytes);
         ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb);
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());
@@ -189,7 +208,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 01 00 08 06 00 00 00 "+
                                               "00 01 00 08 06 00 00 00");
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
@@ -229,7 +248,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 00 00 00"//pad
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());
@@ -260,7 +279,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "AF 01 01 01 01 01 01 01"//matchedCount
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
@@ -302,7 +321,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 00 00 04"//durationNsec
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());
@@ -365,7 +384,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 00 00 04"//durationNsec
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
@@ -421,7 +440,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "FF 02 02 02 02 02 02 02"//byteCountBucket_2.2
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
@@ -489,7 +508,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 00"//pad
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
@@ -526,7 +545,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "FF 03 03 03 03 03 03 03"//byteBandCount_03
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
@@ -603,7 +622,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "FF 03 03 03 03 03 03 03"//byteBandCount_13
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
@@ -704,7 +723,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 00 00 04"//meterBandExperimenter.experimenter
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
@@ -774,7 +793,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 00 00"//meterBandDscp01.pad
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
@@ -832,7 +851,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 00 01 01 00 00 01 01"
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 0xFFFF, builtByFactory.getType().getIntValue());
@@ -874,7 +893,7 @@ public class MultipartReplyMessageFactoryTest {
                                                 );
         bb.writeBytes(bb2.copy(4, bb2.readableBytes()-4));//excluding version and xid
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
@@ -945,7 +964,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 08 "+//copyTTLIntLen
                                               "00 00 00 00"//copyTTLInPad
                                               );
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
@@ -1024,7 +1043,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 00"//pushPbbPad
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
@@ -1111,7 +1130,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 00 00 00"//decNwTtlPad
                                               );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
@@ -1187,7 +1206,7 @@ public class MultipartReplyMessageFactoryTest {
                                               "00 00 00 00"
                 );
         
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..2d7ee04
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10BarrierReplyMessageFactoryTest {
+
+    private OFDeserializer<BarrierOutput> barrierFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        barrierFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 19, BarrierOutput.class));
+    }
+
+    /**
+     * Testing of {@link OF10BarrierReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testV10() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        BarrierOutput builtByFactory = BufferHelper.deserialize(
+                barrierFactory, bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..cdfd644
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10EchoReplyMessageFactoryTest {
+
+    private OFDeserializer<EchoOutput> echoFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        echoFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 3, EchoOutput.class));
+    }
+
+    /**
+     * Testing {@link OF10EchoReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testWithEmptyDataFieldV10() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+    }
+    
+    /**
+     * Testing {@link OF10EchoReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testWithDataFieldSetV10() {
+        byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
+        ByteBuf bb = BufferHelper.buildBuffer(data);
+        EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb);
+        
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
+    }
+}
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..efcd8af
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10EchoRequestMessageFactoryTest {
+
+    private OFDeserializer<EchoRequestMessage> echoFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        echoFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 2, EchoRequestMessage.class));
+    }
+
+    /**
+     * Testing {@link OF10EchoReplyMessageFactoryTest} for correct translation into POJO
+     */
+    @Test
+    public void testWithEmptyDataFieldV10() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+    }
+    
+    /**
+     * Testing {@link OF10EchoReplyMessageFactoryTest} for correct translation into POJO
+     */
+    @Test
+    public void testWithDataFieldSetV10() {
+        byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
+        ByteBuf bb = BufferHelper.buildBuffer(data);
+        EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
+    }
+}
index 43e6d37df2e9753878e21d1ff8f0a2c8b662cd8b..68a49b2cdcdf8e2f442389461a4847e82f3134f0 100644 (file)
@@ -11,23 +11,40 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
 
 /**
  * @author michal.polkorab
  */
 public class OF10ErrorMessageFactoryTest {
+    private OFDeserializer<ErrorMessage> errorFactory;
 
-       /**
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        errorFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 1, ErrorMessage.class));
+    }
+
+    /**
      * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO
      */
        @Test
        public void testWithoutData() {
                ByteBuf bb = BufferHelper.buildBuffer("00 01 00 02");
-               ErrorMessage builtByFactory = BufferHelper.decodeV10(
-                               OF10ErrorMessageFactory.getInstance(), bb);
+               ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
 
                BufferHelper.checkHeaderV10(builtByFactory);
                Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue());
@@ -43,8 +60,7 @@ public class OF10ErrorMessageFactoryTest {
        @Test
        public void testWithData() {
                ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 01 02 03");
-               ErrorMessage builtByFactory = BufferHelper.decodeV10(
-                               OF10ErrorMessageFactory.getInstance(), bb);
+               ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
 
                BufferHelper.checkHeaderV10(builtByFactory);
                Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue());
@@ -60,8 +76,7 @@ public class OF10ErrorMessageFactoryTest {
        @Test
        public void testWithIncorrectTypeEnum() {
                ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 05 00 01 02 03");
-               ErrorMessage builtByFactory = BufferHelper.decodeV10(
-                               OF10ErrorMessageFactory.getInstance(), bb);
+               ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
 
                BufferHelper.checkHeaderV10(builtByFactory);
                Assert.assertEquals("Wrong type", 10, builtByFactory.getType().intValue());
@@ -77,8 +92,7 @@ public class OF10ErrorMessageFactoryTest {
        @Test
        public void testWithIncorrectCodeEnum() {
                ByteBuf bb = BufferHelper.buildBuffer("00 03 00 06 00 01 02 03");
-               ErrorMessage builtByFactory = BufferHelper.decodeV10(
-                               OF10ErrorMessageFactory.getInstance(), bb);
+               ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
 
                BufferHelper.checkHeaderV10(builtByFactory);
                Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());
index bb955efdd6fbeb378e3021e27ec9388db262de9f..d9b50ee8432b6ac8083d39e62cfde0f4a9582d7f 100644 (file)
@@ -11,8 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10;
@@ -28,6 +34,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class OF10FeaturesReplyMessageFactoryTest {
 
+    private OFDeserializer<GetFeaturesOutput> featuresFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        featuresFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, GetFeaturesOutput.class));
+    }
+
     /**
      * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO
      */
@@ -37,8 +56,7 @@ public class OF10FeaturesReplyMessageFactoryTest {
                 + "00 00 00 8B 00 00 03 B5 "
                 + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 01 01 "
                 + "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88");
-        GetFeaturesOutput builtByFactory = BufferHelper.decodeV10(
-                OF10FeaturesReplyMessageFactory.getInstance(), bb);
+        GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
 
         BufferHelper.checkHeaderV10(builtByFactory);
         Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
@@ -77,8 +95,7 @@ public class OF10FeaturesReplyMessageFactoryTest {
                 + "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88 "
                 + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 01 01 "
                 + "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88 ");
-        GetFeaturesOutput builtByFactory = BufferHelper.decodeV10(
-                OF10FeaturesReplyMessageFactory.getInstance(), bb);
+        GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
 
         BufferHelper.checkHeaderV10(builtByFactory);
         Assert.assertEquals("Wrong ports size", 2, builtByFactory.getPhyPort().size());
@@ -91,8 +108,7 @@ public class OF10FeaturesReplyMessageFactoryTest {
     public void testWithTwoPortsSet() {
         ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 "
                 + "00 00 00 8B 00 00 03 B5");
-        GetFeaturesOutput builtByFactory = BufferHelper.decodeV10(
-                OF10FeaturesReplyMessageFactory.getInstance(), bb);
+        GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
 
         BufferHelper.checkHeaderV10(builtByFactory);
         Assert.assertEquals("Wrong ports size", 0, builtByFactory.getPhyPort().size());
index 3a9ec1a690caf2cbfddf3d57ecd773d8884594af..fc99ebb38e0108b3c5c119a349df392facc0fcdf 100644 (file)
@@ -10,8 +10,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
 
 /**
@@ -19,7 +25,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class OF10FlowRemovedMessageFactoryTest {
 
-       /**
+    private OFDeserializer<FlowRemovedMessage> flowFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        flowFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 11, FlowRemovedMessage.class));
+    }
+
+    /**
      * Testing {@link OF10FlowRemovedMessageFactory} for correct translation into POJO
      */
     @Test
@@ -29,7 +48,7 @@ public class OF10FlowRemovedMessageFactoryTest {
                 + "50 50 20 20 "// match
                 + "00 01 02 03 04 05 06 07 00 03 01 00 00 00 00 02 "
                 + "00 00 00 05 00 08 00 00 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07");//41
-        FlowRemovedMessage builtByFactory = BufferHelper.decodeV10(OF10FlowRemovedMessageFactory.getInstance(), bb);
+        FlowRemovedMessage builtByFactory = BufferHelper.deserialize(flowFactory, bb);
 
         BufferHelper.checkHeaderV10(builtByFactory);
         Assert.assertEquals("Wrong cookie", 0x0001020304050607L, builtByFactory.getCookie().longValue());
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..727ea08
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10GetConfigReplyMessageFactoryTest {
+
+    private OFDeserializer<GetConfigOutput> configFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        configFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 8, GetConfigOutput.class));
+    }
+
+    /**
+     * Testing {@link OF10GetConfigReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03");
+        GetConfigOutput builtByFactory = BufferHelper.deserialize(configFactory, bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue()); 
+        Assert.assertEquals("Wrong missSendLen", 0x03, builtByFactory.getMissSendLen().intValue());
+    }
+    
+}
index 5c08bf4d70cf7ef4230001a9d102e61ddaca402d..0015f3fde2b07e9eb1898cc510c0d30973a83022 100644 (file)
@@ -11,8 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
 
 /**
@@ -20,14 +26,27 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class OF10HelloMessageFactoryTest {
 
-       /**
+    private OFDeserializer<HelloMessage> helloFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        helloFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 0, HelloMessage.class));
+    }
+
+    /**
      * Testing {@link OF10HelloMessageFactory} for correct translation into POJO
      */
     @Test
     public void testWithoutElements() {
         ByteBuf bb = BufferHelper.buildBuffer();
-        HelloMessage builtByFactory = BufferHelper.decodeV10(
-                OF10HelloMessageFactory.getInstance(), bb);
+        HelloMessage builtByFactory = BufferHelper.deserialize(
+                helloFactory, bb);
 
         BufferHelper.checkHeaderV10(builtByFactory);
         Assert.assertNull("Wrong elements", builtByFactory.getElements());
@@ -44,8 +63,8 @@ public class OF10HelloMessageFactoryTest {
                                             + "00 00 00 00 " // bitmap 2
                                             + "00 00 00 00"  // padding
                 );
-        HelloMessage builtByFactory = BufferHelper.decodeV10(
-                OF10HelloMessageFactory.getInstance(), bb);
+        HelloMessage builtByFactory = BufferHelper.deserialize(
+                helloFactory, bb);
 
         BufferHelper.checkHeaderV10(builtByFactory);
         Assert.assertNull("Wrong elements", builtByFactory.getElements());
index 51f5cdcfc047108dcaf81f0f0a6107e6afe50c48..aac062535a779b5dc921961782b189a946f770ad 100644 (file)
@@ -10,21 +10,43 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
 
+/**
+ * @author michal.polkorab
+ */
 public class OF10PacketInMessageFactoryTest {
 
-       /**
+    private OFDeserializer<PacketInMessage> packetInFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        packetInFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 10, PacketInMessage.class));
+    }
+
+    /**
      * Testing {@link OF10PacketInMessageFactory} for correct translation into POJO
      */
     @Test
     public void test(){
         ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 02 00 00 01 02 03 04");
-        PacketInMessage builtByFactory = BufferHelper.decodeV10(OF10PacketInMessageFactory.getInstance(), bb); 
+        PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb); 
         
         BufferHelper.checkHeaderV10(builtByFactory);
         Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());
index d4fa28bf711f89fa9155dce96babbd6fddaa0b0c..424584130f59e03f53c510263e20c3bd70f7e1fe 100644 (file)
@@ -11,8 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
@@ -26,6 +32,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class OF10PortStatusMessageFactoryTest {
 
+    private OFDeserializer<PortStatusMessage> statusFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        statusFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 12, PortStatusMessage.class));
+    }
+
     /**
      * Testing {@link OF10PortStatusMessageFactory} for correct translation into POJO
      */
@@ -34,7 +53,7 @@ public class OF10PortStatusMessageFactoryTest {
         ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00 00 00 00 00 "
                 + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 "
                 + "00 00 00 00 15 00 00 01 01 00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88");
-        PortStatusMessage builtByFactory = BufferHelper.decodeV10(OF10PortStatusMessageFactory.getInstance(), bb);
+        PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb);
         
         BufferHelper.checkHeaderV10(builtByFactory);
         Assert.assertEquals("Wrong reason", PortReason.OFPPRADD, builtByFactory.getReason());
index 216e5d37f7f5042b41304b4a27024b38ea64b3bc..0e9b7f53a8d5d614188cdb6b51a0d4c42b5b3a9f 100644 (file)
@@ -11,8 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
@@ -24,6 +30,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class OF10QueueGetConfigReplyMessageFactoryTest {
 
+    private OFDeserializer<GetQueueConfigOutput> queueFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        queueFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 21, GetQueueConfigOutput.class));
+    }
+
     /**
      * Testing of {@link OF10QueueGetConfigReplyMessageFactory} for correct
      * translation into POJO
@@ -34,8 +53,8 @@ public class OF10QueueGetConfigReplyMessageFactoryTest {
                 + "00 00 00 08 00 10 00 00 00 00 00 08 00 00 00 00 "
                 + "00 00 00 02 00 28 00 00 00 01 00 10 00 00 00 00 00 20 00 00 00 00 00 00 "
                 + "00 01 00 10 00 00 00 00 00 30 00 00 00 00 00 00");
-        GetQueueConfigOutput builtByFactory = BufferHelper.decodeV10(
-                OF10QueueGetConfigReplyMessageFactory.getInstance(), bb);
+        GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(
+                queueFactory, bb);
 
         BufferHelper.checkHeaderV10(builtByFactory);
         Assert.assertEquals("Wrong port", 1, builtByFactory.getPort().getValue().intValue());
index 553ac79f43075dfe29578fb7ee85542ef9c98808..bc6b996ed443d0b498c78d3a027ea0896c5d8c2e 100644 (file)
@@ -12,9 +12,15 @@ import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;\r
 \r
 import org.junit.Assert;\r
+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.openflowjava.protocol.impl.util.BufferHelper;\r
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;\r
@@ -42,6 +48,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */\r
 public class OF10StatsReplyMessageFactoryTest {\r
 \r
+    private OFDeserializer<MultipartReplyMessage> statsFactory;\r
+\r
+    /**\r
+     * Initializes deserializer registry and lookups correct deserializer\r
+     */\r
+    @Before\r
+    public void startUp() {\r
+        DeserializerRegistry registry = new DeserializerRegistryImpl();\r
+        registry.init();\r
+        statsFactory = registry.getDeserializer(\r
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 17, MultipartReplyMessage.class));\r
+    }\r
+\r
     /**\r
      * Testing OF10StatsReplyMessageFactory (Desc) for correct deserialization\r
      */\r
@@ -81,7 +100,7 @@ public class OF10StatsReplyMessageFactoryTest {
         bb.writeBytes(dpDescBytes);\r
         ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb);\r
         \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
         \r
         BufferHelper.checkHeaderV10(builtByFactory);\r
         Assert.assertEquals("Wrong type", 0, builtByFactory.getType().getIntValue());\r
@@ -108,8 +127,7 @@ public class OF10StatsReplyMessageFactoryTest {
                 + "FF 01 02 03 04 05 06 07 FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 "\r
                 + "00 00 00 08 00 01 00 02 00 01 00 08 00 03 00 00");\r
         \r
-        MultipartReplyMessage builtByFactory = \r
-                BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
 \r
         BufferHelper.checkHeaderV10(builtByFactory);\r
         Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());\r
@@ -152,8 +170,7 @@ public class OF10StatsReplyMessageFactoryTest {
         ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 "\r
                 + "FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 00 00 00 30 00 00 00 00");\r
         \r
-        MultipartReplyMessage builtByFactory = \r
-                BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
 \r
         BufferHelper.checkHeaderV10(builtByFactory);\r
         Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());\r
@@ -180,7 +197,7 @@ public class OF10StatsReplyMessageFactoryTest {
                 + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "\r
                 + "00 00 00 30 00 00 00 10 FF 01 01 01 01 01 01 01 FF 01 01 01 01 01 01 00");\r
 \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
 \r
         BufferHelper.checkHeaderV10(builtByFactory);\r
         Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());\r
@@ -219,7 +236,7 @@ public class OF10StatsReplyMessageFactoryTest {
                 + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 "\r
                 + "FF 02 03 02 03 02 03 02 ");\r
 \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
 \r
         BufferHelper.checkHeaderV10(builtByFactory);\r
         Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());\r
@@ -277,7 +294,7 @@ public class OF10StatsReplyMessageFactoryTest {
                 + "FF 02 02 02 02 02 02 02 "\r
                 + "FF 02 03 02 03 02 03 02 ");\r
 \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+        MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
 \r
         BufferHelper.checkHeaderV10(builtByFactory);\r
         Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());\r
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10VendorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10VendorMessageFactoryTest.java
deleted file mode 100644 (file)
index 7dc2e86..0000000
+++ /dev/null
@@ -1,35 +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.deserialization.factories;
-
-import io.netty.buffer.ByteBuf;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
-
-/**
- * @author michal.polkorab
- */
-public class OF10VendorMessageFactoryTest {
-
-       /**
-     * Testing {@link OF10VendorMessageFactory} for correct translation into POJO
-     */
-    @Test
-    public void test() {
-        ByteBuf bb = BufferHelper.buildBuffer("01 02 03 04");
-        ExperimenterMessage builtByFactory = BufferHelper.decodeV10(
-                OF10VendorMessageFactory.getInstance(), bb);
-
-        BufferHelper.checkHeaderV10(builtByFactory);
-        Assert.assertEquals("Wrong experimenter", 0x01020304L, builtByFactory.getExperimenter().longValue());
-    }
-}
index 6a3a35f07f8306c2b842c6767e9b7e7c62ddd41f..21889a080005f464416ccfcb4d198dac563aa807 100644 (file)
@@ -11,14 +11,18 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * @author timotej.kubas
@@ -26,9 +30,19 @@ import org.slf4j.LoggerFactory;
  */
 public class PacketInMessageFactoryTest {
 
-    private static final Logger LOGGER = LoggerFactory
-            .getLogger(PacketInMessageFactoryTest.class);
-    
+    private OFDeserializer<PacketInMessage> packetInFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        packetInFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 10, PacketInMessage.class));
+    }
+
     /**
      * Testing {@link PacketInMessageFactory} for correct translation into POJO
      */
@@ -36,7 +50,7 @@ public class PacketInMessageFactoryTest {
     public void test(){
         ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 04 00 01 02 03 04 05 06 07 00 01 00 0C"
                 + " 80 00 02 04 00 00 00 01 00 00 00 00 00 00 01 02 03 04");
-        PacketInMessage builtByFactory = BufferHelper.decodeV13(PacketInMessageFactory.getInstance(), bb); 
+        PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb); 
         
         BufferHelper.checkHeaderV13(builtByFactory);
         
index accefd271a7122bf0f9b30914a6909a821959775..647fd9e2fe11c748383049c0c75054ecf2d93c79 100644 (file)
@@ -12,8 +12,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
@@ -26,6 +32,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class PortStatusMessageFactoryTest {
 
+    private OFDeserializer<PortStatusMessage> statusFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        statusFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 12, PortStatusMessage.class));
+    }
+
     /**
      * Testing {@link PortStatusMessageFactory} for correct translation into POJO
      */
@@ -48,7 +67,7 @@ public class PortStatusMessageFactoryTest {
                                               "00 00 00 80" //max speed
                                               );
         
-        PortStatusMessage builtByFactory = BufferHelper.decodeV13(PortStatusMessageFactory.getInstance(), bb);
+        PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb);
         
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());
index 4d8cb22849121be8f444f090989ce2408368a1f2..048e2371586f2e2bd2ca8324a5e32dd10b91e24a 100644 (file)
@@ -14,8 +14,14 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
@@ -33,6 +39,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class QueueGetConfigReplyMessageFactoryMultiTest {
 
+    private OFDeserializer<GetQueueConfigOutput> queueFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        queueFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 23, GetQueueConfigOutput.class));
+    }
+
     /**
      * Testing of {@link QueueGetConfigReplyMessageFactory} for correct
      * translation into POJO
@@ -61,8 +80,8 @@ public class QueueGetConfigReplyMessageFactoryMultiTest {
                 "00 00 00 00 00 00 " // pad
         );
 
-        GetQueueConfigOutput builtByFactory = BufferHelper.decodeV13(
-                QueueGetConfigReplyMessageFactory.getInstance(), bb);
+        GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(
+                queueFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong port", 66051L, builtByFactory.getPort().getValue().longValue());
index 157e8d7fa402ca203354927c61447f057de68a03..6e9099d34fb8ee77de39bf707ace3050e6054f14 100644 (file)
@@ -14,8 +14,14 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
@@ -33,13 +39,26 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class QueueGetConfigReplyMessageFactoryTest {
 
+    private OFDeserializer<GetQueueConfigOutput> queueFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        queueFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 23, GetQueueConfigOutput.class));
+    }
+
     /**
      * Testing {@link QueueGetConfigReplyMessageFactory} for correct translation into POJO
      */
     @Test
     public void test(){
         ByteBuf bb = BufferHelper.buildBuffer("00 00 00 03 00 00 00 00 00 00 00 01 00 00 00 03 00 20 00 00 00 00 00 00 00 02 00 10 00 00 00 00 00 05 00 00 00 00 00 00");
-        GetQueueConfigOutput builtByFactory = BufferHelper.decodeV13(QueueGetConfigReplyMessageFactory.getInstance(), bb);
+        GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(queueFactory, bb);
         BufferHelper.checkHeaderV13(builtByFactory);
         Assert.assertEquals("Wrong port", 3L, builtByFactory.getPort().getValue().longValue());
         Assert.assertEquals("Wrong queues", builtByFactory.getQueues(), createQueuesList());
index 2d7ff94e6c31f6f4857d9c4c53c89d5bc723881e..707958481649b18d0de902d26a8e270af2afc092 100644 (file)
@@ -11,8 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
 
 /**
@@ -21,13 +27,26 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class RoleReplyMessageFactoryTest {
 
+    private OFDeserializer<RoleRequestOutput> roleFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        roleFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 25, RoleRequestOutput.class));
+    }
+
    /**
     * Testing of {@link RoleReplyMessageFactory} for correct translation into POJO
     */
     @Test
     public void test(){
         ByteBuf bb = BufferHelper.buildBuffer("00 00 00 02 00 00 00 00 00 01 02 03 04 05 06 07");
-        RoleRequestOutput builtByFactory = BufferHelper.decodeV13(RoleReplyMessageFactory.getInstance(), bb);
+        RoleRequestOutput builtByFactory = BufferHelper.deserialize(roleFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
        
index a63edea95735bf90c54ff2624fd5b25cf1e71df5..02aaabb2aaa07e3e28cb3acdcaa5d80045be5f25 100644 (file)
@@ -12,9 +12,13 @@ import io.netty.buffer.ByteBuf;
 import java.util.List;\r
 \r
 import org.junit.Assert;\r
+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.ExperimenterAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;\r
@@ -36,6 +40,20 @@ public class ActionsDeserializerTest {
 \r
     private static final Logger LOGGER = LoggerFactory\r
             .getLogger(ActionsDeserializerTest.class);\r
+    private OFDeserializer<Action> actionDeserializer;\r
+\r
+    /**\r
+     * Initializes deserializer registry and lookups correct deserializer\r
+     */\r
+    @Before\r
+    public void startUp() {\r
+        DeserializerRegistry 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
      * Testing actions deserialization\r
      */\r
@@ -56,12 +74,14 @@ public class ActionsDeserializerTest {
                 + "00 18 00 08 00 00 00 00 "\r
                 + "00 19 00 10 80 00 02 04 00 00 00 0B 00 00 00 00 "\r
                 + "00 1A 00 08 00 0A 00 00 "\r
-                + "00 1B 00 08 00 00 00 00 "\r
-                + "FF FF 00 10 00 00 00 08 00 01 02 03 04 05 06 07");\r
+                + "00 1B 00 08 00 00 00 00");\r
         \r
         message.skipBytes(4); // skip XID\r
         LOGGER.info("bytes: " + message.readableBytes());\r
-        List<Action> actions = ActionsDeserializer.createActions(message, message.readableBytes());\r
+        \r
+        \r
+        List<Action> actions = DecodingUtils.deserializeList(message.readableBytes(),\r
+                message, actionDeserializer);\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
@@ -123,12 +143,6 @@ public class ActionsDeserializerTest {
                 actions.get(14).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue());\r
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
                 + "openflow.common.action.rev130731.PopPbb", actions.get(15).getType().getName());\r
-        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
-                + "openflow.common.action.rev130731.Experimenter", actions.get(16).getType().getName());\r
-        Assert.assertEquals("Wrong experimenter", 8, actions.get(16).getAugmentation(ExperimenterAction.class)\r
-                .getExperimenter().intValue());\r
-        Assert.assertArrayEquals("Wrong data", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, actions.get(16)\r
-                .getAugmentation(ExperimenterAction.class).getData());\r
         Assert.assertTrue("Unread data in message", message.readableBytes() == 0);\r
     }\r
 \r
index 92777a8e9167ceb73119ed3c622b13f698d77c5b..8a40cf2a29403d3e4fb2d923f41646f93d5f28e0 100644 (file)
@@ -15,7 +15,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
 import org.junit.Assert;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
@@ -125,29 +125,15 @@ public abstract class BufferHelper {
         Method m2 = builder.getClass().getMethod("setXid", Long.class);
         m2.invoke(builder, BufferHelper.DEFAULT_XID);
     }
-    
-    /**
-     * Use version 1.3 for decoding message
-     * @param decoder decoder instance
-     * @param bb data input buffer
-     * @return message decoded pojo
-     */
-    public static <E extends DataObject> E decodeV13(OFDeserializer<E> decoder, ByteBuf bb) {
-        return bufferToMessage(decoder, EncodeConstants.OF13_VERSION_ID, bb);
-    }
-    
+
     /**
-     * Use version 1.0 for decoding message
+     * Decode message
      * @param decoder decoder instance
      * @param bb data input buffer
      * @return message decoded pojo
      */
-    public static <E extends DataObject> E decodeV10(OFDeserializer<E> decoder, ByteBuf bb) {
-        return bufferToMessage(decoder, EncodeConstants.OF10_VERSION_ID, bb);
-    }
-    
-    private static <E extends DataObject> E bufferToMessage(OFDeserializer<E> decoder, short version, ByteBuf bb) {
-        return decoder.bufferToMessage(bb, version);
+    public static <E extends DataObject> E deserialize(OFDeserializer<E> decoder, ByteBuf bb) {
+        return decoder.deserialize(bb);
     }
 
 }
index c7a5ee97987b26a66346779737595f246f9664f0..61282953b6d568a14dbbee78c028f23e304fb605 100644 (file)
@@ -142,7 +142,7 @@ public class ByteBufUtilsTest {
     }
     
     /**
-     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+     * Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
      */
     @Test
     public void testFillBitmaskByEmptyList() {
@@ -162,7 +162,7 @@ public class ByteBufUtilsTest {
     }
     
     /**
-     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+     * Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
      */
     @Test
     public void testFillBitmaskByFullList() {
@@ -177,7 +177,7 @@ public class ByteBufUtilsTest {
     }
     
     /**
-     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+     * Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
      */
     @Test
     public void testFillBitmaskByZeroList() {
@@ -192,7 +192,7 @@ public class ByteBufUtilsTest {
     }
     
     /**
-     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+     * Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
      */
     @Test
     public void testFillBitmaskFromRandomList() {
index d65b95525be6390c6544a5e07c0f9434f77afc01..53e95088fa7b80c6c0f84f74df9e09f3711b65e4 100644 (file)
@@ -12,7 +12,12 @@ import io.netty.buffer.ByteBuf;
 import java.util.List;\r
 \r
 import org.junit.Assert;\r
+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
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
@@ -30,7 +35,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
  *\r
  */\r
 public class InstructionsDeserializerTest {\r
-    \r
+\r
+    private OFDeserializer<Instruction> insDeserializer;\r
+\r
+    /**\r
+     * Initializes deserializer registry and lookups correct deserializer\r
+     */\r
+    @Before\r
+    public void startUp() {\r
+        DeserializerRegistry 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
      * Testing instructions translation\r
      */\r
@@ -42,7 +61,9 @@ public class InstructionsDeserializerTest {
                 + "00 16 00 08 00 00 00 50 00 04 00 18 00 00 00 00 00 15 00 08 00 00 00 25 00 0F 00 08 05 00 00 00");\r
         \r
         message.skipBytes(4); // skip XID\r
-        List<Instruction> instructions = InstructionsDeserializer.createInstructions(message, message.readableBytes());\r
+        \r
+        List<Instruction> instructions = DecodingUtils.deserializeList(\r
+                message.readableBytes(), message, insDeserializer);\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 4de1c3a88ca3407ccec1d60355a0b1de0ee4152f..d4cdc802ae75c6fe272819d6c8995cdb36c71c72 100644 (file)
@@ -12,7 +12,13 @@ import io.netty.buffer.ByteBuf;
 import java.util.List;\r
 \r
 import org.junit.Assert;\r
+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.EnhancedMessageCodeKey;\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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
@@ -49,7 +55,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpT
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;\r
@@ -72,8 +77,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Meta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;\r
@@ -94,16 +97,32 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.
  *\r
  */\r
 public class MatchDeserializerTest {\r
-    \r
+\r
+    private OFDeserializer<Match> matchDeserializer;\r
+    private DeserializerRegistry registry;\r
+\r
+    /**\r
+     * Initializes deserializer registry and lookups correct deserializer\r
+     */\r
+    @Before\r
+    public void startUp() {\r
+        registry = new DeserializerRegistryImpl();\r
+        registry.init();\r
+        matchDeserializer = registry.getDeserializer(\r
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,\r
+                        EncodeConstants.EMPTY_VALUE, Match.class));\r
+    }\r
+\r
     /**\r
      * Testing Ipv4 address deserialization\r
      */\r
     @Test\r
     public void testIpv4Address() {\r
         ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03");\r
-        \r
-        List<MatchEntries> list = MatchDeserializer.createMatchEntry(buffer, 8);\r
-        MatchEntries entry = list.get(0);\r
+\r
+        OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(\r
+                new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 12, MatchEntries.class));\r
+        MatchEntries entry = entryDeserializer.deserialize(buffer);\r
         Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"),\r
                 entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
     }\r
@@ -115,8 +134,9 @@ public class MatchDeserializerTest {
     public void testIpv6Address() {\r
         ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07");\r
         \r
-        List<MatchEntries> list = MatchDeserializer.createMatchEntry(buffer, 20);\r
-        MatchEntries entry = list.get(0);\r
+        OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(\r
+                new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 26, MatchEntries.class));\r
+        MatchEntries entry = entryDeserializer.deserialize(buffer);\r
         Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"),\r
                 entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
     }\r
@@ -128,9 +148,9 @@ public class MatchDeserializerTest {
     public void testMatch() {\r
         ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 01 AC "\r
                 + "80 00 00 04 00 00 00 01 "\r
-                + "00 00 02 04 00 00 00 02 "\r
-                + "00 01 05 10 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 04 "\r
-                + "FF FF 07 0C 00 00 00 00 00 05 00 00 00 00 00 06 "\r
+                + "80 00 02 04 00 00 00 02 "\r
+                + "80 00 05 10 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 04 "\r
+                + "80 00 07 0C 00 00 00 00 00 05 00 00 00 00 00 06 "\r
                 + "80 00 09 0C 00 00 00 00 00 07 00 00 00 00 00 08 "\r
                 + "80 00 0A 02 00 09 "\r
                 + "80 00 0D 04 00 0A 00 0B "\r
@@ -171,7 +191,7 @@ public class MatchDeserializerTest {
                 + "80 00 4F 04 01 66 03 04 "\r
                 + "00 00 00 00");\r
 \r
-        Match match = MatchDeserializer.createMatch(buffer);\r
+        Match match = matchDeserializer.deserialize(buffer);\r
         Assert.assertEquals("Wrong match type", OxmMatchType.class, match.getType());\r
         Assert.assertEquals("Wrong match entries size", 40, match.getMatchEntries().size());\r
         List<MatchEntries> entries = match.getMatchEntries();\r
@@ -182,13 +202,13 @@ public class MatchDeserializerTest {
         Assert.assertEquals("Wrong entry value", 1,\r
                 entry0.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
         MatchEntries entry1 = entries.get(1);\r
-        Assert.assertEquals("Wrong entry class", Nxm0Class.class, entry1.getOxmClass());\r
+        Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry1.getOxmClass());\r
         Assert.assertEquals("Wrong entry field", InPhyPort.class, entry1.getOxmMatchField());\r
         Assert.assertEquals("Wrong entry hasMask", false, entry1.isHasMask());\r
         Assert.assertEquals("Wrong entry value", 2,\r
                 entry1.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
         MatchEntries entry2 = entries.get(2);\r
-        Assert.assertEquals("Wrong entry class", Nxm1Class.class, entry2.getOxmClass());\r
+        Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry2.getOxmClass());\r
         Assert.assertEquals("Wrong entry field", Metadata.class, entry2.getOxmMatchField());\r
         Assert.assertEquals("Wrong entry hasMask", true, entry2.isHasMask());\r
         Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), \r
@@ -196,7 +216,7 @@ public class MatchDeserializerTest {
         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"), \r
                 entry2.getAugmentation(MaskMatchEntry.class).getMask());\r
         MatchEntries entry3 = entries.get(3);\r
-        Assert.assertEquals("Wrong entry class", ExperimenterClass.class, entry3.getOxmClass());\r
+        Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry3.getOxmClass());\r
         Assert.assertEquals("Wrong entry field", EthDst.class, entry3.getOxmMatchField());\r
         Assert.assertEquals("Wrong entry hasMask", true, entry3.isHasMask());\r
         Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"), \r
index 62b00a8fd60d2d8259626a527af575bbf2a7eadb..af7ee7aadd28206f7b7a65b406e8f8c716c70f83 100644 (file)
@@ -12,10 +12,14 @@ import io.netty.buffer.ByteBuf;
 import java.util.List;\r
 \r
 import org.junit.Assert;\r
+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
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;\r
@@ -31,6 +35,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
  */\r
 public class OF10ActionsDeserializerTest {\r
 \r
+    private OFDeserializer<Action> actionsDeserializer;\r
+\r
+    /**\r
+     * Initializes deserializer registry and lookups correct deserializer\r
+     */\r
+    @Before\r
+    public void startUp() {\r
+        DeserializerRegistry 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
      * Testing correct deserialization of actions (OF v1.0)\r
      */\r
@@ -47,12 +65,12 @@ public class OF10ActionsDeserializerTest {
                 + "00 08 00 08 01 00 00 00 "\r
                 + "00 09 00 08 00 02 00 00 "\r
                 + "00 0A 00 08 00 03 00 00 "\r
-                + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30 "\r
-                + "FF FF 00 08 00 00 12 34");\r
+                + "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 = OF10ActionsDeserializer.createActionsList(message);\r
-        Assert.assertEquals("Wrong number of actions", 13, actions.size());\r
+        List<Action> actions = DecodingUtils.deserializeList(message.readableBytes(),\r
+                message, actionsDeserializer);\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
                 + ".openflow.common.action.rev130731.Output", action1.getType().getName());\r
@@ -114,11 +132,6 @@ public class OF10ActionsDeserializerTest {
                 .getPort().getValue().intValue());\r
         Assert.assertEquals("Wrong queue-id", 48,\r
                 action12.getAugmentation(QueueIdAction.class).getQueueId().intValue());\r
-        Action action13 = actions.get(12);\r
-        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight"\r
-                + ".openflow.common.action.rev130731.Experimenter", action13.getType().getName());\r
-        Assert.assertEquals("Wrong port", 4660, action13.getAugmentation(ExperimenterAction.class)\r
-                .getExperimenter().intValue());\r
     }\r
 \r
 }\r
index 61da809fe65e3e8b6705dfe071de7e31b67c223c..55e129e694f8f4084264500abd89b8da83960665 100644 (file)
@@ -11,7 +11,12 @@ package org.opendaylight.openflowjava.protocol.impl.util;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
@@ -23,6 +28,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.matc
  */
 public class OF10MatchDeserializerTest {
 
+    private OFDeserializer<MatchV10> matchDeserializer;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        matchDeserializer = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
+    }
+
     /**
      * Testing correct deserialization of ofp_match
      */
@@ -32,7 +50,7 @@ public class OF10MatchDeserializerTest {
                 + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 "
                 + "50 50 20 20");
         message.skipBytes(4); // skip XID
-        MatchV10 match = OF10MatchDeserializer.createMatchV10(message);
+        MatchV10 match = matchDeserializer.deserialize(message);
         Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, true, false,
                 false, true, false, true, true, false), match.getWildcards());
         Assert.assertEquals("Wrong srcMask", 24, match.getNwSrcMask().shortValue());
@@ -60,7 +78,7 @@ public class OF10MatchDeserializerTest {
                 + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 "
                 + "50 50 20 20");
         message.skipBytes(4); // skip XID
-        MatchV10 match = OF10MatchDeserializer.createMatchV10(message);
+        MatchV10 match = matchDeserializer.deserialize(message);
         Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(true, true, true, true,
                 true, true, true, true, true, true), match.getWildcards());
         Assert.assertEquals("Wrong srcMask", 0, match.getNwSrcMask().shortValue());
index 2a7a89768c7cfc9ce4bcc937c6cd2da3b610976c..7cbae3f0ae4a24b9e2b5091dba5b014365a189ef 100644 (file)
@@ -18,7 +18,6 @@ import java.util.concurrent.TimeUnit;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration.FEATURE_SUPPORT;
 import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent;
 import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioFactory;
index 8b4b958aee25793c8ebb176f7231e7fd35381111..a61f10330c01a7adb3305409ee55918b336083a4 100644 (file)
@@ -13,6 +13,8 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfigura
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
 import com.google.common.util.concurrent.ListenableFuture;
@@ -54,4 +56,12 @@ public interface SwitchConnectionProvider extends AutoCloseable {
      */
     public  <E extends DataObject> void registerCustomSerializer(MessageTypeKey<E> key,
             OFSerializer<E> serializer);
+            
+    /**
+     * Registers custom deserializer
+     * @param key used for deserializer lookup
+     * @param deserializer deserializer instance
+     */
+    public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer);
+
 }