Copyright update 02/3602/3
authorMichal Polkorab <michal.polkorab@pantheon.sk>
Tue, 10 Dec 2013 09:29:24 +0000 (10:29 +0100)
committerMichal Polkorab <michal.polkorab@pantheon.sk>
Tue, 10 Dec 2013 14:56:30 +0000 (15:56 +0100)
Signed-off-by: Michal Polkorab <michal.polkorab@pantheon.sk>
Change-Id: I44fde82346500c0c054b51b0eb21ef56a97be022

174 files changed:
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionReadyListener.java
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ListeningStatusProvider.java
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java
openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/util/BinContentTest.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/Activator.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionFacade.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageConsumer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/OnlineProvider.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKey.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ShutdownProvider.java
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/DelegatingInboundHandler.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandler.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/OFEncoder.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.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/core/TlsDetector.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageWrapper.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DecoderTable.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java
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/OFDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java
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/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/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
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/serialization/EncoderTable.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageTypeKey.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/OFSerializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10VendorInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactory.java
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/ActionsSerializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtils.java
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/InstructionsSerializer.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/MatchSerializer.java
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/OF10ActionsSerializer.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/OF10MatchSerializer.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DummyDecoder.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TlsDetectorTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java
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/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/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/OF10VendorMessageFactoryTest.java
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/serialization/factories/BarrierInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10VendorInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java
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/MatchSerializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java
openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/IntegrationTest.java
openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/MockPlugin.java
openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/TestingConnConfigImpl.java
openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientEvent.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SleepEvent.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java

index 74a9bdccf204393e185d68239da65fc97b7ba319..cb3edd1ff78c7092f5c2a9ee86c5b7e060f3e54a 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.api.connection;
 
index a42b000c267694f87e26229630580418840054cd..c5ca795caa960d99395b9431a200ad82b0ffbd0b 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.api.connection;
 
index 215acef6d166fed502c03cea778ec1300682cd50..55152fb747f13fe898ddcec38b02ed2c5575fc2e 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.api.connection;
 
 /**
index 761a74ebad351592fad067290fdefaddf8ce923b..6de6675b98323b213814b1256136d7d134f780dd 100644 (file)
@@ -1,5 +1,5 @@
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * 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,
index 532bfa9f780119b8c61bb5202fbcb977af9abc7b..82dd0f0e33517f13d43fe4cebcecf32dba9408ee 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.api.connection;
 
index 6227070f4a37f32e7591b0d4f3a25c939d9d6db2..171a684d2c237c84137c4e51965fd3a2f47ad87b 100644 (file)
@@ -1,25 +1,32 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.api.util;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public abstract class BinContent {\r
-\r
-    /**\r
-     * @param value\r
-     * @return int part wrapped in long\r
-     */\r
-    public static long intToUnsignedLong(int value) {\r
-        return value & 0x00000000ffffffffL;\r
-    }\r
-    \r
-    /**\r
-     * @param value\r
-     * @return long cut into int\r
-     */\r
-    public static int longToSignedInt(long value) {\r
-        return (int) value;\r
-    }\r
-}\r
+/*
+ * 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.api.util;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public abstract class BinContent {
+
+    /**
+     * @param value
+     * @return int part wrapped in long
+     */
+    public static long intToUnsignedLong(int value) {
+        return value & 0x00000000ffffffffL;
+    }
+    
+    /**
+     * @param value
+     * @return long cut into int
+     */
+    public static int longToSignedInt(long value) {
+        return (int) value;
+    }
+}
index 18ec2269ab5bae957f55ed4d8d16777aebfc85d8..af09e0cb545f595ecdba26f2408ae22da863a89b 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others.  All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
 package org.opendaylight.openflowjava.protocol.api.util;\r
 \r
 import junit.framework.Assert;\r
index 5bd98c6e62963be6116bb51ae2d60c05ef4dd67e..f028d7871ce9b53318efd03aa49b07979527d7cf 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.connection;
 
 import java.util.Hashtable;
index 754a2d9d5eb584975f2bf3b2ab39961eefdf94be..241d12984c087ab965b440aec5b44f7d1b175ad6 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.connection;
 
index 7fe138c43616b19fd7a807280fde6f35cee45542..e3822dd63912d58132e4aa3120c63ba25826a1cb 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.connection;
 
index 3e72d7864fba3fcd70c796d1b02fd4ecf4dd4d2c..fc6d9e920c208e03da762b60e8cfe780a87e0b83 100644 (file)
@@ -1,13 +1,20 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-\r
-package org.opendaylight.openflowjava.protocol.impl.connection;\r
-\r
-import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;\r
-\r
-/**\r
- * @author michal.polkorab\r
- */\r
-public interface ConnectionFacade extends MessageConsumer, ConnectionAdapter {\r
-\r
- // empty unifying superinterface\r
-}\r
+/*
+ * 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.connection;
+
+import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
+
+/**
+ * @author michal.polkorab
+ */
+public interface ConnectionFacade extends MessageConsumer, ConnectionAdapter {
+
+ // empty unifying superinterface
+}
index 8a80ff57b45046c0009d45cdf32516479c68a231..fe833311bc20724b6f64acc25eae3c3fc82e391f 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.connection;
 
index e189920c201cbad907afcc043b614d1c4af3f701..e828d9ae8bda57ad3d6a09f787e2b66262c8b9f7 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.connection;
 
index 71e1df1fa2f707875c5c45c162f9f13761dbf07a..a01098d4ccbcdb80b95871e442c9b2d05984702a 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.connection;
 
index 1d089921b8e240d6b6f2b8ed299b1ec7c7910588..84c84df724f71a88a63f999ac618f033c1175921 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.connection;
 
index 58d4c271f91806d03b1400f0cf5c3922707e6c3a..21870cc4d524d875f33ec7a0ec0e3996e3d880fb 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.connection;
 
index 3547db2ac1abd84b69d6dc25c0a0ca9d76a7fce6..d9e9f64ef7abad9cf751e243cf62b36e402b43a3 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.connection;
 
index e0daecb2620c1acda34bcbfdda033dfac95d54f5..4279bcbbe498c619f2844a7d61ce24357e16765a 100644 (file)
@@ -1,64 +1,71 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.core;\r
-\r
-import io.netty.channel.ChannelHandlerContext;\r
-import io.netty.channel.ChannelInboundHandlerAdapter;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterImpl;\r
-import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder;\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * Holds reference to {@link ConnectionAdapterImpl} and passes messages for further processing.\r
- * Also informs on switch disconnection.\r
- * @author michal.polkorab\r
- */\r
-public class DelegatingInboundHandler extends ChannelInboundHandlerAdapter {\r
-\r
-    private static final Logger LOGGER = LoggerFactory.getLogger(DelegatingInboundHandler.class);\r
-    \r
-    protected MessageConsumer consumer;\r
-    private boolean inactiveMessageSent = false;\r
-    \r
-    /** \r
-     * Constructs class + creates and sets MessageConsumer\r
-     * @param connectionAdapter reference for adapter communicating with upper layers outside library\r
-     */\r
-    public DelegatingInboundHandler(MessageConsumer connectionAdapter) {\r
-        LOGGER.debug("Creating DelegatingInboundHandler");\r
-        consumer = connectionAdapter;\r
-    }\r
-    \r
-    @Override\r
-    public void channelRead(ChannelHandlerContext ctx, final Object msg)\r
-            throws Exception {\r
-        LOGGER.debug("Reading");\r
-        consumer.consume((DataObject) msg);\r
-    }\r
-    \r
-    @Override\r
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {\r
-        LOGGER.info("Channel inactive");\r
-        if (!inactiveMessageSent) {\r
-            DisconnectEventBuilder builder = new DisconnectEventBuilder();\r
-            builder.setInfo("Channel inactive");\r
-            consumer.consume(builder.build());\r
-            inactiveMessageSent = true;\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {\r
-        LOGGER.info("Channel unregistered");\r
-        if (!inactiveMessageSent) {\r
-            DisconnectEventBuilder builder = new DisconnectEventBuilder();\r
-            builder.setInfo("Channel unregistered");\r
-            consumer.consume(builder.build());\r
-            inactiveMessageSent = true;\r
-        }\r
-    }\r
-    \r
-}\r
+/*
+ * 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.core;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+
+import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterImpl;
+import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Holds reference to {@link ConnectionAdapterImpl} and passes messages for further processing.
+ * Also informs on switch disconnection.
+ * @author michal.polkorab
+ */
+public class DelegatingInboundHandler extends ChannelInboundHandlerAdapter {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(DelegatingInboundHandler.class);
+    
+    protected MessageConsumer consumer;
+    private boolean inactiveMessageSent = false;
+    
+    /** 
+     * Constructs class + creates and sets MessageConsumer
+     * @param connectionAdapter reference for adapter communicating with upper layers outside library
+     */
+    public DelegatingInboundHandler(MessageConsumer connectionAdapter) {
+        LOGGER.debug("Creating DelegatingInboundHandler");
+        consumer = connectionAdapter;
+    }
+    
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, final Object msg)
+            throws Exception {
+        LOGGER.debug("Reading");
+        consumer.consume((DataObject) msg);
+    }
+    
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        LOGGER.info("Channel inactive");
+        if (!inactiveMessageSent) {
+            DisconnectEventBuilder builder = new DisconnectEventBuilder();
+            builder.setInfo("Channel inactive");
+            consumer.consume(builder.build());
+            inactiveMessageSent = true;
+        }
+    }
+
+    @Override
+    public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
+        LOGGER.info("Channel unregistered");
+        if (!inactiveMessageSent) {
+            DisconnectEventBuilder builder = new DisconnectEventBuilder();
+            builder.setInfo("Channel unregistered");
+            consumer.consume(builder.build());
+            inactiveMessageSent = true;
+        }
+    }
+    
+}
index 8d5ca853c8f992d6ac632f62d1dfc89d9c2887d5..65af251677882578339809afe7c1d07d8778f99a 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.core;
 
 import java.util.concurrent.TimeUnit;
index d0d3996204be5f2f38cde6be3fe6c8bd8219c86c..af04a525dcefd5d25a4eb05d832cac890a31d5c8 100644 (file)
@@ -1,54 +1,61 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.core;\r
-\r
-import io.netty.channel.ChannelHandlerContext;\r
-import io.netty.handler.codec.MessageToMessageDecoder;\r
-\r
-import java.util.List;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * Transforms OpenFlow Protocol messages to POJOs\r
- * @author michal.polkorab\r
- */\r
-public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {\r
-\r
-    private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class);\r
-\r
-    /**\r
-     * Constructor of class\r
-     */\r
-    public OFDecoder() {\r
-        LOGGER.debug("Creating OF 1.3 Decoder");\r
-    }\r
-\r
-    @Override\r
-    protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg,\r
-            List<Object> out) throws Exception {\r
-        if (LOGGER.isDebugEnabled()) {\r
-            LOGGER.debug("VersionMessageWrapper received");\r
-            LOGGER.debug("buffer size: " + msg.getMessageBuffer().readableBytes());\r
-            LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));\r
-        }\r
-        DataObject dataObject = null;\r
-        try {\r
-            dataObject = DeserializationFactory.bufferToMessage(msg.getMessageBuffer(),\r
-                    msg.getVersion());\r
-        } catch(Exception e) {\r
-            LOGGER.error("Message deserialization failed");\r
-            LOGGER.error(e.getMessage(), e);\r
-            return;\r
-        }\r
-        if (dataObject == null) {\r
-            LOGGER.warn("Translated POJO is null");\r
-            return;\r
-        }\r
-        msg.getMessageBuffer().release();\r
-        out.add(dataObject);\r
-    }\r
-}\r
+/*
+ * 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.core;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.MessageToMessageDecoder;
+
+import java.util.List;
+
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Transforms OpenFlow Protocol messages to POJOs
+ * @author michal.polkorab
+ */
+public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class);
+
+    /**
+     * Constructor of class
+     */
+    public OFDecoder() {
+        LOGGER.debug("Creating OF 1.3 Decoder");
+    }
+
+    @Override
+    protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg,
+            List<Object> out) throws Exception {
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("VersionMessageWrapper received");
+            LOGGER.debug("buffer size: " + msg.getMessageBuffer().readableBytes());
+            LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
+        }
+        DataObject dataObject = null;
+        try {
+            dataObject = DeserializationFactory.bufferToMessage(msg.getMessageBuffer(),
+                    msg.getVersion());
+        } catch(Exception e) {
+            LOGGER.error("Message deserialization failed");
+            LOGGER.error(e.getMessage(), e);
+            return;
+        }
+        if (dataObject == null) {
+            LOGGER.warn("Translated POJO is null");
+            return;
+        }
+        msg.getMessageBuffer().release();
+        out.add(dataObject);
+    }
+}
index 9a0cdbb1c9ae3960a0acb9a6ac05ac6b63b0c150..3c77e64ea2db23d659c02dd704e07d16bfdbad4d 100644 (file)
@@ -1,46 +1,53 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.core;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.channel.ChannelHandlerContext;\r
-import io.netty.handler.codec.MessageToByteEncoder;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * Transforms OpenFlow Protocol messages to POJOs\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class OFEncoder extends MessageToByteEncoder<OfHeader> {\r
-\r
-    private static final Logger LOGGER = LoggerFactory.getLogger(OFEncoder.class);\r
-    \r
-    /** Constructor of class */\r
-    public OFEncoder() {\r
-        LOGGER.debug("Creating OF13Encoder");\r
-    }\r
-    \r
-    @Override\r
-    protected void encode(ChannelHandlerContext ctx, OfHeader msg, ByteBuf out)\r
-            throws Exception {\r
-        LOGGER.debug("Encoding");\r
-        try {\r
-            SerializationFactory.messageToBuffer(msg.getVersion(), out, msg);\r
-        } catch(Exception e) {\r
-            LOGGER.error("Message serialization failed");\r
-            LOGGER.error(e.getMessage(), e);\r
-            return;\r
-        }\r
-        if (out.readableBytes() > 0) {\r
-            out.retain();\r
-            ctx.writeAndFlush(out);\r
-        } else {\r
-            LOGGER.warn("Translated buffer is empty");\r
-        }\r
-    }\r
-\r
-}\r
+/*
+ * 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.core;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.MessageToByteEncoder;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Transforms OpenFlow Protocol messages to POJOs
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OFEncoder extends MessageToByteEncoder<OfHeader> {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(OFEncoder.class);
+    
+    /** Constructor of class */
+    public OFEncoder() {
+        LOGGER.debug("Creating OF13Encoder");
+    }
+    
+    @Override
+    protected void encode(ChannelHandlerContext ctx, OfHeader msg, ByteBuf out)
+            throws Exception {
+        LOGGER.debug("Encoding");
+        try {
+            SerializationFactory.messageToBuffer(msg.getVersion(), out, msg);
+        } catch(Exception e) {
+            LOGGER.error("Message serialization failed");
+            LOGGER.error(e.getMessage(), e);
+            return;
+        }
+        if (out.readableBytes() > 0) {
+            out.retain();
+            ctx.writeAndFlush(out);
+        } else {
+            LOGGER.warn("Translated buffer is empty");
+        }
+    }
+
+}
index c342e9d56bcf74ec323348822db5b95d2b4c73aa..7a3e105a705a70b1c6bc70ee3bb19e8eeee0e978 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.core;
 
index 9026dcc68d957b0b3cc323b7462896c5880d6f94..671b8dd97fa730a3d1a831c569d30b9e5dd2a110 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.core;
 
 import io.netty.buffer.ByteBuf;
index 5e481dc0e355414d702e0d5a32f5451ed0c43766..1fd9cb9c973fc27eb1a7e3daa957a6d73f6d7fed 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.core;
 
 import io.netty.channel.Channel;
index 1f79536263e1ba99505725230c1a272f5724b124..082721881236adb6f871eb5b3f436e88c4d09ecb 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.core;
 
 import java.security.KeyStore;
index 8d4e23744a0d7a31650a456468a726ace8753d84..3868e734afccd7333dd8da87e61f5863de235a31 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.core;
 
 import java.io.InputStream;
index 36e1fdaf1ce36541d9ccd920b5df4011c33a31bb..69f2db68d4c57b94a1c6a49ec50a35862da35070 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.core;
 
 import javax.net.ssl.ManagerFactoryParameters;
index 3c74cf3030d35e510a460e100db2bbbfca4ef637..941518d69c8de81600ec4582f1c5635a04971f2a 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.core;
 
 import io.netty.bootstrap.ServerBootstrap;
index 2ce089bada950bc2bf440aa8fc48dfa11c35aa04..93b296d0f2461f514d7ac3851a21d77fe3f2e14d 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.core;
 
 import io.netty.buffer.ByteBuf;
index fc41b8e7148df403e8f7ecfbb6b4f9ff5df587e7..f04ae92d2c987d85b389f4f632e8773f9b651ddb 100644 (file)
@@ -1,40 +1,47 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.core;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-/**\r
- * Wraps received messages (includes version)\r
- * @author michal.polkorab\r
- */\r
-public class VersionMessageWrapper {\r
-\r
-    private short version;\r
-    private ByteBuf messageBuffer;\r
-    \r
-    /**\r
-     * Constructor\r
-     * @param version version decoded in {@link OFVersionDetector}\r
-     * @param messageBuffer message received from {@link OFFrameDecoder}\r
-     */\r
-    public VersionMessageWrapper(short version, ByteBuf messageBuffer) {\r
-        this.version = version;\r
-        this.messageBuffer = messageBuffer;\r
-    }\r
-\r
-    /**\r
-     * @return the version version decoded in {@link OFVersionDetector}\r
-     */\r
-    public short getVersion() {\r
-        return version;\r
-    }\r
-\r
-    /**\r
-     * @return the messageBuffer message received from {@link OFFrameDecoder}\r
-     */\r
-    public ByteBuf getMessageBuffer() {\r
-        return messageBuffer;\r
-    }\r
-    \r
-    \r
-}\r
+/*
+ * 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.core;
+
+import io.netty.buffer.ByteBuf;
+
+/**
+ * Wraps received messages (includes version)
+ * @author michal.polkorab
+ */
+public class VersionMessageWrapper {
+
+    private short version;
+    private ByteBuf messageBuffer;
+    
+    /**
+     * Constructor
+     * @param version version decoded in {@link OFVersionDetector}
+     * @param messageBuffer message received from {@link OFFrameDecoder}
+     */
+    public VersionMessageWrapper(short version, ByteBuf messageBuffer) {
+        this.version = version;
+        this.messageBuffer = messageBuffer;
+    }
+
+    /**
+     * @return the version version decoded in {@link OFVersionDetector}
+     */
+    public short getVersion() {
+        return version;
+    }
+
+    /**
+     * @return the messageBuffer message received from {@link OFFrameDecoder}
+     */
+    public ByteBuf getMessageBuffer() {
+        return messageBuffer;
+    }
+    
+    
+}
index 0013b433984bcc1338f57195c17b8497878ca87c..e1734405208e5a9ce4ee3d67cbfd5259599d263d 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\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.ExperimenterMessageFactory;\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.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.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.OF10VendorMessageFactory;\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
-\r
-/**\r
- * Stores and provides correct decoders for received messages\r
- * @author michal.polkorab\r
- * \r
- *  <pre>         \r
- *  Type   Message\r
- *   0: HELLO\r
- *   1: ERROR\r
- *   2: ECHO_REQUEST\r
- *   3: ECHO_REPLY\r
- *   4: EXPERIMENTER\r
- *   5: FEATURES_REQUEST\r
- *   6: FEATURES_REPLY\r
- *   7: GET_CONFIG_REQUEST\r
- *   8: GET_CONFIG_REPLY\r
- *   9: SET_CONFIG\r
- *   10: PACKET_IN\r
- *   11: FLOW_REMOVED\r
- *   12: PORT_STATUS\r
- *   13: PACKET_OUT\r
- *   14: FLOW_MOD\r
- *   15: GROUP_MOD\r
- *   16: PORT_MOD\r
- *   17: TABLE_MOD\r
- *   18: MULTIPART_REQUEST\r
- *   19: MULTIPART_REPLY\r
- *   20: BARRIER_REQUEST\r
- *   21: BARRIER_REPLY\r
- *   22: QUEUE_GET_CONFIG_REQUEST\r
- *   23: QUEUE_GET_CONFIG_REPLY\r
- *   24: ROLE_REQUEST\r
- *   25: ROLE_REPLY    \r
- *   26: GET_ASYNC_REQUEST\r
- *   27: GET_ASYNC_REPLY\r
- *   28: SET_ASYNC\r
- *   29: METER_MOD\r
- *   </pre>\r
- */\r
-public class DecoderTable {\r
-    \r
-    private static final short OF10 = EncodeConstants.OF10_VERSION_ID;\r
-    private static final short OF13 = EncodeConstants.OF13_VERSION_ID;\r
-    private Map<MessageTypeCodeKey, OFDeserializer<?>> table;\r
-    private static DecoderTable instance;\r
-    \r
-    \r
-    private DecoderTable() {\r
-        // do nothing\r
-    }\r
-    \r
-    /**\r
-     * @return singleton instance\r
-     */\r
-    public static synchronized DecoderTable getInstance() {\r
-        if (instance == null) {\r
-            instance = new DecoderTable();\r
-            instance.init();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    /**\r
-     * Decoder table provisioning\r
-     */\r
-    public void init() {\r
-        table = new HashMap<>();\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 0), OF10HelloMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 1), OF10ErrorMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 2), EchoRequestMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 3), EchoReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 4), OF10VendorMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 6), OF10FeaturesReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 8), GetConfigReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 10), OF10PacketInMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 11), OF10FlowRemovedMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 12), OF10PortStatusMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 16), OF10StatsReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 18), BarrierReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF10, (short) 20), OF10QueueGetConfigReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 0), HelloMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 1), ErrorMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 2), EchoRequestMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 3), EchoReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 4), ExperimenterMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 6), FeaturesReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 8), GetConfigReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 10), PacketInMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 11), FlowRemovedMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 12), PortStatusMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 19), MultipartReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 21), BarrierReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 23), QueueGetConfigReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 25), RoleReplyMessageFactory.getInstance());\r
-        table.put(new MessageTypeCodeKey(OF13, (short) 27), GetAsyncReplyMessageFactory.getInstance());\r
-    }\r
-    \r
-    /**\r
-     * @param msgTypeKey\r
-     * @return decoder for given message types\r
-     */\r
-    public OFDeserializer<?> getDecoder(MessageTypeCodeKey msgTypeKey) {\r
-        return table.get(msgTypeKey);\r
-    }\r
-\r
-}\r
+/*
+ * 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) 16), OF10StatsReplyMessageFactory.getInstance());
+        table.put(new MessageTypeCodeKey(OF10, (short) 18), BarrierReplyMessageFactory.getInstance());
+        table.put(new MessageTypeCodeKey(OF10, (short) 20), 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 a6b9b8f76a3a80f1dee346cdec9557b77e8e1a81..4daadffc7a42af656bc20af8fa14428487df81ef 100644 (file)
@@ -1,40 +1,47 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public abstract class DeserializationFactory {\r
-    \r
-    private static final Logger LOGGER = LoggerFactory\r
-            .getLogger(DeserializationFactory.class);\r
-\r
-    /**\r
-     * Transforms ByteBuf into correct POJO message\r
-     * @param rawMessage \r
-     * @param version version decoded from OpenFlow protocol message\r
-     * @return correct POJO as DataObject\r
-     */\r
-    public static DataObject bufferToMessage(ByteBuf rawMessage, short version) {\r
-        DataObject dataObject = null;\r
-        short type = rawMessage.readUnsignedByte();\r
-        rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-\r
-        MessageTypeCodeKey msgTypeCodeKey = new MessageTypeCodeKey(version, type);\r
-        OFDeserializer<?> decoder = DecoderTable.getInstance().getDecoder(msgTypeCodeKey);\r
-        if (decoder != null) {\r
-            dataObject = decoder.bufferToMessage(rawMessage, version);\r
-        } else {\r
-            LOGGER.warn("No correct decoder found in DecoderTable for arguments: " + msgTypeCodeKey.toString());\r
-        }\r
-        return dataObject;\r
-    }\r
-}\r
+/*
+ * 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 io.netty.buffer.ByteBuf;
+
+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);
+
+    /**
+     * Transforms ByteBuf into correct POJO message
+     * @param rawMessage 
+     * @param version version decoded from OpenFlow protocol message
+     * @return correct POJO as DataObject
+     */
+    public static DataObject bufferToMessage(ByteBuf rawMessage, short version) {
+        DataObject dataObject = null;
+        short type = rawMessage.readUnsignedByte();
+        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());
+        }
+        return dataObject;
+    }
+}
index dd71c4a2e5c9d4115be4d5d27b2e3e4ad0f600ee..96fb3e70100f7459f5dde5e6cf2cad615b257d6a 100644 (file)
@@ -1,63 +1,70 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
-\r
-\r
-/**\r
- * Class used as a key in {@link DecoderTable}\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class MessageTypeCodeKey {\r
-\r
-    private final short msgType;\r
-    private final short msgVersion;\r
-\r
-    /**\r
-     * @param msgVersion protocol version\r
-     * @param msgType type code of message\r
-     */\r
-    public MessageTypeCodeKey(short msgVersion, short msgType) {\r
-        this.msgType = msgType;\r
-        this.msgVersion = msgVersion;\r
-    }\r
-\r
-    /**\r
-     * @return the msgType\r
-     */\r
-    public short getMsgType() {\r
-        return msgType;\r
-    }\r
-\r
-    /**\r
-     * @return the msgVersion\r
-     */\r
-    public short getMsgVersion() {\r
-        return msgVersion;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result + msgType;\r
-        result = prime * result + msgVersion;\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
-        MessageTypeCodeKey other = (MessageTypeCodeKey) obj;\r
-        if (msgType != other.msgType)\r
-            return false;\r
-        if (msgVersion != other.msgVersion)\r
-            return false;\r
-        return true;\r
-    }\r
-    \r
-}\r
+/*
+ * 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;
+
+
+/**
+ * Class used as a key in {@link DecoderTable}
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class MessageTypeCodeKey {
+
+    private final short msgType;
+    private final short msgVersion;
+
+    /**
+     * @param msgVersion protocol version
+     * @param msgType type code of message
+     */
+    public MessageTypeCodeKey(short msgVersion, short msgType) {
+        this.msgType = msgType;
+        this.msgVersion = msgVersion;
+    }
+
+    /**
+     * @return the msgType
+     */
+    public short getMsgType() {
+        return msgType;
+    }
+
+    /**
+     * @return the msgVersion
+     */
+    public short getMsgVersion() {
+        return msgVersion;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + msgType;
+        result = prime * result + msgVersion;
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        MessageTypeCodeKey other = (MessageTypeCodeKey) obj;
+        if (msgType != other.msgType)
+            return false;
+        if (msgVersion != other.msgVersion)
+            return false;
+        return true;
+    }
+    
+}
index 8f64ed3dea80bdf4fa648c3889b4089d00129bb5..c4df5df0697ad401477db5d9e84ab0661afbecdb 100644 (file)
@@ -1,26 +1,33 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
-\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-/**\r
- * Uniform interface for deserializing factories\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- * @param <E> message code type\r
- */\r
-public interface OFDeserializer<E extends DataObject> {\r
-\r
-    /**\r
-     * Transforms byte message into POJO/DTO (of type E).\r
-     * Assumes that input ByteBuf's readerIndex is pointing on length in OpenFlow header\r
-     * \r
-     * @param rawMessage message as bytes in ByteBuf\r
-     * @param version version of used OF Protocol\r
-     * @return HelloMessage as DataObject\r
-     */\r
-    public abstract E bufferToMessage(ByteBuf rawMessage, short version);\r
-\r
-}\r
+/*
+ * 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 org.opendaylight.yangtools.yang.binding.DataObject;
+
+import io.netty.buffer.ByteBuf;
+
+/**
+ * Uniform interface for deserializing factories
+ * @author michal.polkorab
+ * @author timotej.kubas
+ * @param <E> message code type
+ */
+public interface OFDeserializer<E extends DataObject> {
+
+    /**
+     * 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
+     */
+    public abstract E bufferToMessage(ByteBuf rawMessage, short version);
+
+}
index e2402b47766ff9bcc6b5e2c4bb13e3af816c42b9..51c305cf11f8ece5df152c4c5463fafa851d77dc 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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;
index 0c591bb5589626d7f02835707abfcdb17c1f043f..c5d5ab799e5615957f16f153aea55c1ae42dd649 100644 (file)
@@ -1,45 +1,52 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;\r
-\r
-/**\r
- * Translates EchoReply messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class EchoReplyMessageFactory implements OFDeserializer<EchoOutput> {\r
-\r
-    private static EchoReplyMessageFactory instance;\r
-\r
-    private EchoReplyMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized EchoReplyMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new EchoReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public EchoOutput bufferToMessage(ByteBuf rawMessage, short version) {\r
-        EchoOutputBuilder builder = new EchoOutputBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        int remainingBytes = rawMessage.readableBytes();\r
-        if (remainingBytes > 0) {\r
-            builder.setData(rawMessage.readBytes(remainingBytes).array());\r
-        }\r
-        return builder.build();\r
-    }\r
-\r
-}\r
+/*
+ * 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.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 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) {
+        EchoOutputBuilder builder = new EchoOutputBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        int remainingBytes = rawMessage.readableBytes();
+        if (remainingBytes > 0) {
+            builder.setData(rawMessage.readBytes(remainingBytes).array());
+        }
+        return builder.build();
+    }
+
+}
index 5ff67d7fa57b96e24140ed5ba8df67deeffbf741..2ba5884dc62353f2c13483e4fb4c66e28f8876f2 100644 (file)
@@ -1,41 +1,48 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;\r
-\r
-/**\r
- * Translates EchoRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class EchoRequestMessageFactory implements OFDeserializer<EchoRequestMessage>{\r
-\r
-    private static EchoRequestMessageFactory instance;\r
-\r
-    private EchoRequestMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized EchoRequestMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new EchoRequestMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public EchoRequestMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());\r
-        return builder.build();\r
-    }\r
-}\r
+/*
+ * 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.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 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) {
+        EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
+        return builder.build();
+    }
+}
index 3463855bafd1ef70f7a88f83b23054210d72df45..09ec1088d69bcdb8a1e8ad5428b4bd9e3950fdf6 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterError;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterErrorBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadInstructionCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadMatchCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadRequestCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFailedCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModFailedCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloFailedCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModFailedCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortModFailedCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueOpFailedCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.RoleRequestFailedCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFailedCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesFailedCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableModFailedCode;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;\r
-\r
-/**\r
- * Translates Error messages\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class ErrorMessageFactory implements OFDeserializer<ErrorMessage> {\r
-\r
-    private static final String UNKNOWN_CODE = "UNKNOWN_CODE";\r
-    private static final String UNKNOWN_TYPE = "UNKNOWN_TYPE";\r
-    \r
-    private static ErrorMessageFactory instance;\r
-    \r
-    private ErrorMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized ErrorMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new ErrorMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public ErrorMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        ErrorMessageBuilder builder = new ErrorMessageBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        int type = rawMessage.readUnsignedShort();\r
-        ErrorType errorType = ErrorType.forValue(type);\r
-        decodeType(builder, errorType, type);\r
-        decodeCode(rawMessage, builder, errorType);\r
-        if (rawMessage.readableBytes() > 0) {\r
-            builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());\r
-        }\r
-        return builder.build();\r
-    }\r
-    \r
-    private static void decodeType(ErrorMessageBuilder builder, ErrorType type, int readValue) {\r
-        if (type != null) {\r
-            builder.setType(type.getIntValue());\r
-            builder.setTypeString(type.name());\r
-        } else {\r
-            builder.setType(readValue);\r
-            builder.setTypeString(UNKNOWN_TYPE);\r
-        }\r
-    }\r
-\r
-    private static void decodeCode(ByteBuf rawMessage, ErrorMessageBuilder builder,\r
-            ErrorType type) {\r
-        int code = rawMessage.readUnsignedShort();\r
-        if (type != null) {\r
-            switch (type) {\r
-            case HELLOFAILED:\r
-            {\r
-                HelloFailedCode errorCode = HelloFailedCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case BADREQUEST:\r
-            {\r
-                BadRequestCode errorCode = BadRequestCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case BADACTION:\r
-            {\r
-                BadActionCode errorCode = BadActionCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case BADINSTRUCTION:\r
-            {\r
-                BadInstructionCode errorCode = BadInstructionCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case BADMATCH:\r
-            {\r
-                BadMatchCode errorCode = BadMatchCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case FLOWMODFAILED:\r
-            {\r
-                FlowModFailedCode errorCode = FlowModFailedCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case GROUPMODFAILED:\r
-            {\r
-                GroupModFailedCode errorCode = GroupModFailedCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case PORTMODFAILED:\r
-            {\r
-                PortModFailedCode errorCode = PortModFailedCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case TABLEMODFAILED:\r
-            {\r
-                TableModFailedCode errorCode = TableModFailedCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case QUEUEOPFAILED:\r
-            {\r
-                QueueOpFailedCode errorCode = QueueOpFailedCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case SWITCHCONFIGFAILED:\r
-            {\r
-                SwitchConfigFailedCode errorCode = SwitchConfigFailedCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case ROLEREQUESTFAILED:\r
-            {\r
-                RoleRequestFailedCode errorCode = RoleRequestFailedCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case METERMODFAILED:\r
-            {\r
-                MeterModFailedCode errorCode = MeterModFailedCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case TABLEFEATURESFAILED:\r
-            {\r
-                TableFeaturesFailedCode errorCode = TableFeaturesFailedCode.forValue(code);\r
-                if (errorCode != null) {\r
-                    setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                } else {\r
-                    setUnknownCode(builder, code);\r
-                }\r
-                break;\r
-            }\r
-            case EXPERIMENTER:\r
-                ExperimenterErrorBuilder expBuilder = new ExperimenterErrorBuilder();\r
-                expBuilder.setExpType(code);\r
-                expBuilder.setExperimenter(rawMessage.readUnsignedInt());\r
-                builder.addAugmentation(ExperimenterError.class, expBuilder.build());\r
-                break;\r
-            default:\r
-                setUnknownCode(builder, code);\r
-                break;\r
-            }\r
-        } else {\r
-            setUnknownCode(builder, code);\r
-        }\r
-    }\r
-    \r
-    private static void setUnknownCode(ErrorMessageBuilder builder, int readValue) {\r
-        builder.setCode(readValue);\r
-        builder.setCodeString(UNKNOWN_CODE);\r
-    }\r
-    \r
-    private static void setCode(ErrorMessageBuilder builder, int code, String codeString) {\r
-        builder.setCode(code);\r
-        builder.setCodeString(codeString);\r
-    }\r
-\r
-}\r
+/*
+ * 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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadInstructionCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadMatchCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadRequestCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFailedCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModFailedCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloFailedCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModFailedCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortModFailedCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueOpFailedCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.RoleRequestFailedCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFailedCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesFailedCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableModFailedCode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;
+
+/**
+ * Translates Error messages
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+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) {
+        ErrorMessageBuilder builder = new ErrorMessageBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        int type = rawMessage.readUnsignedShort();
+        ErrorType errorType = ErrorType.forValue(type);
+        decodeType(builder, errorType, type);
+        decodeCode(rawMessage, builder, errorType);
+        if (rawMessage.readableBytes() > 0) {
+            builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
+        }
+        return builder.build();
+    }
+    
+    private static void decodeType(ErrorMessageBuilder builder, ErrorType type, int readValue) {
+        if (type != null) {
+            builder.setType(type.getIntValue());
+            builder.setTypeString(type.name());
+        } else {
+            builder.setType(readValue);
+            builder.setTypeString(UNKNOWN_TYPE);
+        }
+    }
+
+    private static void decodeCode(ByteBuf rawMessage, ErrorMessageBuilder builder,
+            ErrorType type) {
+        int code = rawMessage.readUnsignedShort();
+        if (type != null) {
+            switch (type) {
+            case HELLOFAILED:
+            {
+                HelloFailedCode errorCode = HelloFailedCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case BADREQUEST:
+            {
+                BadRequestCode errorCode = BadRequestCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case BADACTION:
+            {
+                BadActionCode errorCode = BadActionCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case BADINSTRUCTION:
+            {
+                BadInstructionCode errorCode = BadInstructionCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case BADMATCH:
+            {
+                BadMatchCode errorCode = BadMatchCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case FLOWMODFAILED:
+            {
+                FlowModFailedCode errorCode = FlowModFailedCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case GROUPMODFAILED:
+            {
+                GroupModFailedCode errorCode = GroupModFailedCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case PORTMODFAILED:
+            {
+                PortModFailedCode errorCode = PortModFailedCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case TABLEMODFAILED:
+            {
+                TableModFailedCode errorCode = TableModFailedCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case QUEUEOPFAILED:
+            {
+                QueueOpFailedCode errorCode = QueueOpFailedCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case SWITCHCONFIGFAILED:
+            {
+                SwitchConfigFailedCode errorCode = SwitchConfigFailedCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case ROLEREQUESTFAILED:
+            {
+                RoleRequestFailedCode errorCode = RoleRequestFailedCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case METERMODFAILED:
+            {
+                MeterModFailedCode errorCode = MeterModFailedCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case TABLEFEATURESFAILED:
+            {
+                TableFeaturesFailedCode errorCode = TableFeaturesFailedCode.forValue(code);
+                if (errorCode != null) {
+                    setCode(builder, errorCode.getIntValue(), errorCode.name());
+                } else {
+                    setUnknownCode(builder, code);
+                }
+                break;
+            }
+            case EXPERIMENTER:
+                ExperimenterErrorBuilder expBuilder = new ExperimenterErrorBuilder();
+                expBuilder.setExpType(code);
+                expBuilder.setExperimenter(rawMessage.readUnsignedInt());
+                builder.addAugmentation(ExperimenterError.class, expBuilder.build());
+                break;
+            default:
+                setUnknownCode(builder, code);
+                break;
+            }
+        } else {
+            setUnknownCode(builder, code);
+        }
+    }
+    
+    private static void setUnknownCode(ErrorMessageBuilder builder, int readValue) {
+        builder.setCode(readValue);
+        builder.setCodeString(UNKNOWN_CODE);
+    }
+    
+    private static void setCode(ErrorMessageBuilder builder, int code, String codeString) {
+        builder.setCode(code);
+        builder.setCodeString(codeString);
+    }
+
+}
index f12985919e494177e84b8ee202bf09b1b2125a54..f6dc0ea1c368cf590571659b36fa4e478cd0afef 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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;
index 8ab3ae80d0eb497bd114d6a36e385e748e0119be..c9cef55a0cce89594bd8e63ef11ea418ca1964c2 100644 (file)
@@ -1,67 +1,74 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.math.BigInteger;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;\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.GetFeaturesOutputBuilder;\r
-\r
-/**\r
- * Translates FeaturesReply messages\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class FeaturesReplyMessageFactory implements OFDeserializer<GetFeaturesOutput>{\r
-    \r
-    private static final byte PADDING_IN_FEATURES_REPLY_HEADER = 2;\r
-    \r
-    private static FeaturesReplyMessageFactory instance;\r
-\r
-    private FeaturesReplyMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized FeaturesReplyMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new FeaturesReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public GetFeaturesOutput bufferToMessage(ByteBuf rawMessage, short version) {\r
-        GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        byte[] datapathId = new byte[Long.SIZE/Byte.SIZE];\r
-        rawMessage.readBytes(datapathId);\r
-        builder.setDatapathId(new BigInteger(datapathId));\r
-        builder.setBuffers(rawMessage.readUnsignedInt());\r
-        builder.setTables(rawMessage.readUnsignedByte());\r
-        builder.setAuxiliaryId(rawMessage.readUnsignedByte());\r
-        rawMessage.skipBytes(PADDING_IN_FEATURES_REPLY_HEADER);\r
-        builder.setCapabilities(createCapabilities(rawMessage.readUnsignedInt()));\r
-        builder.setReserved(rawMessage.readUnsignedInt());\r
-        return builder.build();\r
-    }\r
-\r
-    private static Capabilities createCapabilities(long input) {\r
-        final Boolean FLOW_STATS = (input & (1 << 0)) != 0;\r
-        final Boolean TABLE_STATS = (input & (1 << 1)) != 0;\r
-        final Boolean PORT_STATS = (input & (1 << 2)) != 0;\r
-        final Boolean GROUP_STATS = (input & (1 << 3)) != 0;\r
-        final Boolean IP_REASM = (input & (1 << 5)) != 0;\r
-        final Boolean QUEUE_STATS = (input & (1 << 6)) != 0;\r
-        final Boolean PORT_BLOCKED = (input & (1 << 8)) != 0;\r
-        return new Capabilities(FLOW_STATS, GROUP_STATS, IP_REASM,\r
-                PORT_BLOCKED, PORT_STATS, QUEUE_STATS, TABLE_STATS);\r
-    }\r
-\r
-}\r
+/*
+ * 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 java.math.BigInteger;
+
+import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
+
+/**
+ * Translates FeaturesReply messages
+ * @author michal.polkorab
+ * @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) {
+        GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        byte[] datapathId = new byte[Long.SIZE/Byte.SIZE];
+        rawMessage.readBytes(datapathId);
+        builder.setDatapathId(new BigInteger(datapathId));
+        builder.setBuffers(rawMessage.readUnsignedInt());
+        builder.setTables(rawMessage.readUnsignedByte());
+        builder.setAuxiliaryId(rawMessage.readUnsignedByte());
+        rawMessage.skipBytes(PADDING_IN_FEATURES_REPLY_HEADER);
+        builder.setCapabilities(createCapabilities(rawMessage.readUnsignedInt()));
+        builder.setReserved(rawMessage.readUnsignedInt());
+        return builder.build();
+    }
+
+    private static Capabilities createCapabilities(long input) {
+        final Boolean FLOW_STATS = (input & (1 << 0)) != 0;
+        final Boolean TABLE_STATS = (input & (1 << 1)) != 0;
+        final Boolean PORT_STATS = (input & (1 << 2)) != 0;
+        final Boolean GROUP_STATS = (input & (1 << 3)) != 0;
+        final Boolean IP_REASM = (input & (1 << 5)) != 0;
+        final Boolean QUEUE_STATS = (input & (1 << 6)) != 0;
+        final Boolean PORT_BLOCKED = (input & (1 << 8)) != 0;
+        return new Capabilities(FLOW_STATS, GROUP_STATS, IP_REASM,
+                PORT_BLOCKED, PORT_STATS, QUEUE_STATS, TABLE_STATS);
+    }
+
+}
index 24f15ff1460b329e81e93cab480769d6561c70dd..7df6835cd902277a9512f8f7547c54e2cb817fd2 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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;
index 30584823b32e218f78f26fee906743c29096a357..2f482cf74efc74c7ff05a51a620c40efea81d7ea 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder;\r
-\r
-/**\r
- * Translates GetAsyncReply messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class GetAsyncReplyMessageFactory implements OFDeserializer<GetAsyncOutput> {\r
-    \r
-    private static GetAsyncReplyMessageFactory instance;\r
-    private static final byte SEPARATE_ROLES = 2;\r
-    \r
-    private GetAsyncReplyMessageFactory() {\r
-        // singleton\r
-    }\r
-\r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized GetAsyncReplyMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new GetAsyncReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public GetAsyncOutput bufferToMessage(ByteBuf rawMessage, short version) {\r
-        GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        builder.setPacketInMask(decodePacketInMask(rawMessage));\r
-        builder.setPortStatusMask(decodePortStatusMask(rawMessage));\r
-        builder.setFlowRemovedMask(decodeFlowRemovedMask(rawMessage));\r
-        return builder.build();\r
-    }\r
-    \r
-    private static List<PacketInMask> decodePacketInMask(ByteBuf input) {\r
-        List<PacketInMask> inMasks = new ArrayList<>();\r
-        PacketInMaskBuilder maskBuilder;\r
-        for (int i = 0; i < SEPARATE_ROLES; i++) {\r
-            maskBuilder = new PacketInMaskBuilder();\r
-            maskBuilder.setMask(decodePacketInReasons(input.readUnsignedInt()));\r
-            inMasks.add(maskBuilder.build()); \r
-        }\r
-        return inMasks;\r
-    }\r
-    \r
-    private static List<PortStatusMask> decodePortStatusMask(ByteBuf input) {\r
-        List<PortStatusMask> inMasks = new ArrayList<>();\r
-        PortStatusMaskBuilder maskBuilder;\r
-        for (int i = 0; i < SEPARATE_ROLES; i++) {\r
-            maskBuilder = new PortStatusMaskBuilder();\r
-            maskBuilder.setMask(decodePortReasons(input.readUnsignedInt()));\r
-            inMasks.add(maskBuilder.build());\r
-        }\r
-        return inMasks;\r
-    }\r
-    \r
-    private static List<FlowRemovedMask> decodeFlowRemovedMask(ByteBuf input) {\r
-        List<FlowRemovedMask> inMasks = new ArrayList<>();\r
-        FlowRemovedMaskBuilder maskBuilder;\r
-        for (int i = 0; i < SEPARATE_ROLES; i++) {\r
-            maskBuilder = new FlowRemovedMaskBuilder();\r
-            maskBuilder.setMask(decodeFlowRemovedReasons(input.readUnsignedInt()));\r
-            inMasks.add(maskBuilder.build());\r
-        }\r
-        return inMasks;\r
-    }\r
-    \r
-    private static List<PacketInReason> decodePacketInReasons(long input) {\r
-        List<PacketInReason> reasons = new ArrayList<>();\r
-        if ((input & (1 << 0)) != 0) {\r
-            reasons.add(PacketInReason.OFPRNOMATCH);\r
-        }\r
-        if ((input & (1 << 1)) != 0) {\r
-            reasons.add(PacketInReason.OFPRACTION);\r
-        }\r
-        if ((input & (1 << 2)) != 0) {\r
-            reasons.add(PacketInReason.OFPRINVALIDTTL);\r
-        }\r
-        return reasons;\r
-    }\r
-    \r
-    private static List<PortReason> decodePortReasons(long input) {\r
-        List<PortReason> reasons = new ArrayList<>();\r
-        if ((input & (1 << 0)) != 0) {\r
-            reasons.add(PortReason.OFPPRADD);\r
-        }\r
-        if ((input & (1 << 1)) != 0) {\r
-            reasons.add(PortReason.OFPPRDELETE);\r
-        }\r
-        if ((input & (1 << 2)) != 0) {\r
-            reasons.add(PortReason.OFPPRMODIFY);\r
-        }\r
-        return reasons;\r
-    }\r
-    \r
-    private static List<FlowRemovedReason> decodeFlowRemovedReasons(long input) {\r
-        List<FlowRemovedReason> reasons = new ArrayList<>();\r
-        if ((input & (1 << 0)) != 0) {\r
-            reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT);\r
-        }\r
-        if ((input & (1 << 1)) != 0) {\r
-            reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);\r
-        }\r
-        if ((input & (1 << 2)) != 0) {\r
-            reasons.add(FlowRemovedReason.OFPRRDELETE);\r
-        }\r
-        if ((input & (1 << 3)) != 0) {\r
-            reasons.add(FlowRemovedReason.OFPRRGROUPDELETE);\r
-        }\r
-        return reasons;\r
-    }\r
-}\r
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder;
+
+/**
+ * Translates GetAsyncReply messages
+ * @author timotej.kubas
+ * @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) {
+        GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setPacketInMask(decodePacketInMask(rawMessage));
+        builder.setPortStatusMask(decodePortStatusMask(rawMessage));
+        builder.setFlowRemovedMask(decodeFlowRemovedMask(rawMessage));
+        return builder.build();
+    }
+    
+    private static List<PacketInMask> decodePacketInMask(ByteBuf input) {
+        List<PacketInMask> inMasks = new ArrayList<>();
+        PacketInMaskBuilder maskBuilder;
+        for (int i = 0; i < SEPARATE_ROLES; i++) {
+            maskBuilder = new PacketInMaskBuilder();
+            maskBuilder.setMask(decodePacketInReasons(input.readUnsignedInt()));
+            inMasks.add(maskBuilder.build()); 
+        }
+        return inMasks;
+    }
+    
+    private static List<PortStatusMask> decodePortStatusMask(ByteBuf input) {
+        List<PortStatusMask> inMasks = new ArrayList<>();
+        PortStatusMaskBuilder maskBuilder;
+        for (int i = 0; i < SEPARATE_ROLES; i++) {
+            maskBuilder = new PortStatusMaskBuilder();
+            maskBuilder.setMask(decodePortReasons(input.readUnsignedInt()));
+            inMasks.add(maskBuilder.build());
+        }
+        return inMasks;
+    }
+    
+    private static List<FlowRemovedMask> decodeFlowRemovedMask(ByteBuf input) {
+        List<FlowRemovedMask> inMasks = new ArrayList<>();
+        FlowRemovedMaskBuilder maskBuilder;
+        for (int i = 0; i < SEPARATE_ROLES; i++) {
+            maskBuilder = new FlowRemovedMaskBuilder();
+            maskBuilder.setMask(decodeFlowRemovedReasons(input.readUnsignedInt()));
+            inMasks.add(maskBuilder.build());
+        }
+        return inMasks;
+    }
+    
+    private static List<PacketInReason> decodePacketInReasons(long input) {
+        List<PacketInReason> reasons = new ArrayList<>();
+        if ((input & (1 << 0)) != 0) {
+            reasons.add(PacketInReason.OFPRNOMATCH);
+        }
+        if ((input & (1 << 1)) != 0) {
+            reasons.add(PacketInReason.OFPRACTION);
+        }
+        if ((input & (1 << 2)) != 0) {
+            reasons.add(PacketInReason.OFPRINVALIDTTL);
+        }
+        return reasons;
+    }
+    
+    private static List<PortReason> decodePortReasons(long input) {
+        List<PortReason> reasons = new ArrayList<>();
+        if ((input & (1 << 0)) != 0) {
+            reasons.add(PortReason.OFPPRADD);
+        }
+        if ((input & (1 << 1)) != 0) {
+            reasons.add(PortReason.OFPPRDELETE);
+        }
+        if ((input & (1 << 2)) != 0) {
+            reasons.add(PortReason.OFPPRMODIFY);
+        }
+        return reasons;
+    }
+    
+    private static List<FlowRemovedReason> decodeFlowRemovedReasons(long input) {
+        List<FlowRemovedReason> reasons = new ArrayList<>();
+        if ((input & (1 << 0)) != 0) {
+            reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
+        }
+        if ((input & (1 << 1)) != 0) {
+            reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
+        }
+        if ((input & (1 << 2)) != 0) {
+            reasons.add(FlowRemovedReason.OFPRRDELETE);
+        }
+        if ((input & (1 << 3)) != 0) {
+            reasons.add(FlowRemovedReason.OFPRRGROUPDELETE);
+        }
+        return reasons;
+    }
+}
index 011e5ba43c5b19947e9ae5614406a8901bc5b77a..95329132a4a8670244c9dd458e7cbf989cf010b1 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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;
index 1523159f09d34681484b9e24c1137ac7b593a433..eeb9893e29cbe50f1700aa64d2599b47d89c85b9 100644 (file)
@@ -1,85 +1,92 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\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.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.HelloInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder;\r
-\r
-/**\r
- * Translates Hello messages\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class HelloMessageFactory implements OFDeserializer<HelloMessage> {\r
-\r
-    private static HelloMessageFactory instance;\r
-    \r
-    private HelloMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized HelloMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new HelloMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public HelloMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        HelloMessageBuilder builder = new HelloMessageBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        if (rawMessage.readableBytes() > 0) {\r
-            builder.setElements(readElement(rawMessage));\r
-        }\r
-        return builder.build();\r
-    }\r
-    \r
-    private static List<Elements> readElement(ByteBuf input) {\r
-        List<Elements> elementsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            ElementsBuilder elementsBuilder = new ElementsBuilder();\r
-            int type = input.readUnsignedShort();\r
-            int elementLength = input.readUnsignedShort();\r
-            if (type == HelloElementType.VERSIONBITMAP.getIntValue()) {\r
-                elementsBuilder.setType(HelloElementType.forValue(type));\r
-                int[] versionBitmap = new int[(elementLength - HelloInputMessageFactory.HELLO_ELEMENT_HEADER_SIZE) / 4];\r
-                for (int i = 0; i < versionBitmap.length; i++) {\r
-                    versionBitmap[i] = (int) input.readUnsignedInt();\r
-                }\r
-                elementsBuilder.setVersionBitmap(readVersionBitmap(versionBitmap));\r
-                int paddingRemainder = elementLength % EncodeConstants.PADDING;\r
-                if (paddingRemainder != 0) {\r
-                    input.readBytes(EncodeConstants.PADDING - paddingRemainder);\r
-                }\r
-            }\r
-            elementsList.add(elementsBuilder.build());\r
-        }\r
-        return elementsList;\r
-    }\r
-    \r
-    private static List<Boolean> readVersionBitmap(int[] input){\r
-        List<Boolean> versionBitmapList = new ArrayList<>();\r
-        for (int i = 0; i < input.length; i++) {\r
-            int mask = input[i];\r
-            for (int j = 0; j < Integer.SIZE; j++) {\r
-                    versionBitmapList.add((mask & (1<<j)) != 0);\r
-            }\r
-        }\r
-        return versionBitmapList;\r
-    }\r
-}\r
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.HelloInputMessageFactory;
+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.HelloMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder;
+
+/**
+ * Translates Hello messages
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class HelloMessageFactory implements OFDeserializer<HelloMessage> {
+
+    private static HelloMessageFactory instance;
+    
+    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) {
+        HelloMessageBuilder builder = new HelloMessageBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        if (rawMessage.readableBytes() > 0) {
+            builder.setElements(readElement(rawMessage));
+        }
+        return builder.build();
+    }
+    
+    private static List<Elements> readElement(ByteBuf input) {
+        List<Elements> elementsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            ElementsBuilder elementsBuilder = new ElementsBuilder();
+            int type = input.readUnsignedShort();
+            int elementLength = input.readUnsignedShort();
+            if (type == HelloElementType.VERSIONBITMAP.getIntValue()) {
+                elementsBuilder.setType(HelloElementType.forValue(type));
+                int[] versionBitmap = new int[(elementLength - HelloInputMessageFactory.HELLO_ELEMENT_HEADER_SIZE) / 4];
+                for (int i = 0; i < versionBitmap.length; i++) {
+                    versionBitmap[i] = (int) input.readUnsignedInt();
+                }
+                elementsBuilder.setVersionBitmap(readVersionBitmap(versionBitmap));
+                int paddingRemainder = elementLength % EncodeConstants.PADDING;
+                if (paddingRemainder != 0) {
+                    input.readBytes(EncodeConstants.PADDING - paddingRemainder);
+                }
+            }
+            elementsList.add(elementsBuilder.build());
+        }
+        return elementsList;
+    }
+    
+    private static List<Boolean> readVersionBitmap(int[] input){
+        List<Boolean> versionBitmapList = new ArrayList<>();
+        for (int i = 0; i < input.length; i++) {
+            int mask = input[i];
+            for (int j = 0; j < Integer.SIZE; j++) {
+                    versionBitmapList.add((mask & (1<<j)) != 0);
+            }
+        }
+        return versionBitmapList;
+    }
+}
index 1ebff03675c253c4979b660d4e9cf922f8b2b8aa..f82ec53ea5917cd2af5bad11b8c17ac9e494e6eb 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ActionsDeserializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.openflowjava.protocol.impl.util.InstructionsDeserializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;\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.ActionRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeaturePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeaturePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeaturePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;\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.MultipartReplyMessageBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsListBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregate;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlow;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroup;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTable;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow.FlowStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow.FlowStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.GroupStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.GroupStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc.GroupDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc.GroupDescBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.group.stats.BucketStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.group.stats.BucketStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.MeterStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.MeterStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config.MeterConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config.MeterConfigBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config.meter.config.Bands;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config.meter.config.BandsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.meter.stats.MeterBandStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.meter.stats.MeterBandStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc.PortsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats.PortStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats.PortStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue.QueueStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue.QueueStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.TableStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.TableStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features.TableFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features.TableFeaturesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeatureProperties;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeaturePropertiesBuilder;\r
-\r
-/**\r
- * Translates MultipartReply messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class MultipartReplyMessageFactory implements OFDeserializer<MultipartReplyMessage> {\r
-\r
-    private static final byte PADDING_IN_MULTIPART_REPLY_HEADER = 4;\r
-    private static final int DESC_STR_LEN = 256;\r
-    private static final int SERIAL_NUM_LEN = 32;\r
-    private static final byte PADDING_IN_FLOW_STATS_HEADER_01 = 1;\r
-    private static final byte PADDING_IN_FLOW_STATS_HEADER_02 = 4;\r
-    private static final byte PADDING_IN_AGGREGATE_HEADER = 4;\r
-    private static final byte PADDING_IN_TABLE_HEADER = 3;\r
-    private static final byte PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES = 5;\r
-    private static final byte MAX_TABLE_NAME_LENGTH = 32;\r
-    private static final byte MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH = 64;\r
-    private static final byte COMMON_PROPERTY_LENGTH = 4;\r
-    private static final byte PADDING_IN_PORT_STATS_HEADER = 4;\r
-    private static final byte PADDING_IN_GROUP_HEADER_01 = 2;\r
-    private static final byte PADDING_IN_GROUP_HEADER_02 = 4;\r
-    private static final byte BUCKET_COUNTER_LENGTH = 16;\r
-    private static final byte GROUP_BODY_LENGTH = 40;\r
-    private static final byte PADDING_IN_METER_FEATURES_HEADER = 2;\r
-    private static final byte PADDING_IN_METER_STATS_HEADER = 6;\r
-    private static final byte METER_BAND_STATS_LENGTH = 16;\r
-    private static final byte METER_BODY_LENGTH = 40;\r
-    private static final byte METER_CONFIG_LENGTH = 8;\r
-    private static final byte PADDING_IN_METER_BAND_DROP_HEADER = 4;\r
-    private static final byte PADDING_IN_METER_BAND_DSCP_HEADER = 3;\r
-    private static final byte PADDING_IN_PORT_DESC_HEADER_01 = 4;\r
-    private static final byte PADDING_IN_PORT_DESC_HEADER_02 = 2;\r
-    private static final byte MAX_PORT_NAME_LEN = 16;\r
-    private static final int GROUP_TYPES = 4;\r
-    private static final byte PADDING_IN_GROUP_DESC_HEADER = 1;\r
-    private static final byte PADDING_IN_BUCKETS_HEADER = 4;\r
-    private static final byte GROUP_DESC_HEADER_LENGTH = 8;\r
-    private static final byte BUCKETS_HEADER_LENGTH = 16;\r
-\r
-    \r
-    private static MultipartReplyMessageFactory instance;\r
-\r
-    private MultipartReplyMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized MultipartReplyMessageFactory getInstance() {\r
-        if (instance == null){\r
-            instance = new MultipartReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        int type = rawMessage.readUnsignedShort();\r
-        builder.setType(MultipartType.forValue(type));\r
-        builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0));\r
-        rawMessage.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);\r
-\r
-        switch (type) {\r
-        case 0:  builder.setMultipartReplyBody(setDesc(rawMessage));\r
-                 break;\r
-        case 1:  builder.setMultipartReplyBody(setFlow(rawMessage));\r
-                 break;\r
-        case 2:  builder.setMultipartReplyBody(setAggregate(rawMessage));\r
-                 break;\r
-        case 3:  builder.setMultipartReplyBody(setTable(rawMessage));\r
-                 break;         \r
-        case 4:  builder.setMultipartReplyBody(setPortStats(rawMessage));\r
-                 break;\r
-        case 5:  builder.setMultipartReplyBody(setQueue(rawMessage));\r
-                 break;         \r
-        case 6:  builder.setMultipartReplyBody(setGroup(rawMessage));\r
-                 break;\r
-        case 7:  builder.setMultipartReplyBody(setGroupDesc(rawMessage));\r
-                 break;\r
-        case 8:  builder.setMultipartReplyBody(setGroupFeatures(rawMessage));\r
-                 break;\r
-        case 9:  builder.setMultipartReplyBody(setMeter(rawMessage));\r
-                 break;\r
-        case 10: builder.setMultipartReplyBody(setMeterConfig(rawMessage));\r
-                 break;\r
-        case 11: builder.setMultipartReplyBody(setMeterFeatures(rawMessage));\r
-                 break;\r
-        case 12: builder.setMultipartReplyBody(setTableFeatures(rawMessage));\r
-                 break;\r
-        case 13: builder.setMultipartReplyBody(setPortDesc(rawMessage));\r
-                 break;\r
-        case 0xFFFF: builder.setMultipartReplyBody(setExperimenter(rawMessage));\r
-                 break;\r
-        default: \r
-                 break;\r
-        }\r
-        \r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyDesc setDesc(ByteBuf input) {\r
-        MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder();\r
-        byte[] mfrDescBytes = new byte[DESC_STR_LEN];\r
-        input.readBytes(mfrDescBytes);\r
-        String mfrDesc = new String(mfrDescBytes);\r
-        descBuilder.setMfrDesc(mfrDesc.trim());\r
-        byte[] hwDescBytes = new byte[DESC_STR_LEN];\r
-        input.readBytes(hwDescBytes);\r
-        String hwDesc = new String(hwDescBytes);\r
-        descBuilder.setHwDesc(hwDesc.trim());\r
-        byte[] swDescBytes = new byte[DESC_STR_LEN];\r
-        input.readBytes(swDescBytes);\r
-        String swDesc = new String(swDescBytes);\r
-        descBuilder.setSwDesc(swDesc.trim());\r
-        byte[] serialNumBytes = new byte[SERIAL_NUM_LEN];\r
-        input.readBytes(serialNumBytes);\r
-        String serialNum = new String(serialNumBytes);\r
-        descBuilder.setSerialNum(serialNum.trim());\r
-        byte[] dpDescBytes = new byte[DESC_STR_LEN];\r
-        input.readBytes(dpDescBytes);\r
-        String dpDesc = new String(dpDescBytes);\r
-        descBuilder.setDpDesc(dpDesc.trim());\r
-        return descBuilder.build();\r
-    }\r
-    \r
-    private static MultipartReplyFlow setFlow(ByteBuf input) {\r
-        MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();\r
-        List<FlowStats> flowStatsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder();\r
-            input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-            flowStatsBuilder.setTableId(input.readUnsignedByte());\r
-            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);\r
-            flowStatsBuilder.setDurationSec(input.readUnsignedInt());\r
-            flowStatsBuilder.setDurationNsec(input.readUnsignedInt());\r
-            flowStatsBuilder.setPriority(input.readUnsignedShort());\r
-            flowStatsBuilder.setIdleTimeout(input.readUnsignedShort());\r
-            flowStatsBuilder.setHardTimeout(input.readUnsignedShort());\r
-            flowStatsBuilder.setFlags(createFlowModFlagsFromBitmap(input.readShort()));\r
-            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);\r
-            byte[] cookie = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(cookie);\r
-            flowStatsBuilder.setCookie(new BigInteger(cookie));\r
-            byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(packetCount);\r
-            flowStatsBuilder.setPacketCount(new BigInteger(packetCount));\r
-            byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(byteCount);\r
-            flowStatsBuilder.setByteCount(new BigInteger(byteCount));\r
-            flowStatsBuilder.setMatch(MatchDeserializer.createMatch(input));\r
-            flowStatsBuilder.setInstructions(InstructionsDeserializer.createInstructions(input, input.readableBytes()));\r
-            flowStatsList.add(flowStatsBuilder.build());\r
-        }\r
-        flowBuilder.setFlowStats(flowStatsList);\r
-        return flowBuilder.build();\r
-    }\r
-    \r
-    private static FlowModFlags createFlowModFlagsFromBitmap(short input){\r
-        final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) != 0;\r
-        final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) != 0;\r
-        final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) != 0; \r
-        final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) != 0;\r
-        final Boolean _oFPFFNOBYTCOUNTS = (input & (1 << 4)) != 0;\r
-        return new FlowModFlags(_oFPFFCHECKOVERLAP, _oFPFFNOBYTCOUNTS, _oFPFFNOPKTCOUNTS, _oFPFFRESETCOUNTS, _oFPFFSENDFLOWREM);\r
-    }\r
-    \r
-    private static MultipartReplyAggregate setAggregate(ByteBuf input) {\r
-        MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();\r
-        byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];\r
-        input.readBytes(packetCount);\r
-        builder.setPacketCount(new BigInteger(packetCount));\r
-        byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];\r
-        input.readBytes(byteCount);\r
-        builder.setByteCount(new BigInteger(byteCount));\r
-        builder.setFlowCount(input.readUnsignedInt());\r
-        input.skipBytes(PADDING_IN_AGGREGATE_HEADER);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyTable setTable(ByteBuf input) {\r
-        MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();\r
-        List<TableStats> tableStatsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            TableStatsBuilder tableStatsBuilder = new TableStatsBuilder();\r
-            tableStatsBuilder.setTableId(input.readUnsignedByte());\r
-            input.skipBytes(PADDING_IN_TABLE_HEADER);\r
-            tableStatsBuilder.setActiveCount(input.readUnsignedInt());\r
-            byte[] lookupCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(lookupCount);\r
-            tableStatsBuilder.setLookupCount(new BigInteger(lookupCount));\r
-            byte[] matchedCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(matchedCount);\r
-            tableStatsBuilder.setMatchedCount(new BigInteger(matchedCount));\r
-            tableStatsList.add(tableStatsBuilder.build());\r
-        }\r
-        builder.setTableStats(tableStatsList);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyTableFeatures setTableFeatures(ByteBuf input) {\r
-        MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();\r
-        List<TableFeatures> features = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();\r
-            int length = input.readUnsignedShort();\r
-            featuresBuilder.setTableId(input.readUnsignedByte());\r
-            input.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);\r
-            featuresBuilder.setName(input.readBytes(MAX_TABLE_NAME_LENGTH).toString());\r
-            byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
-            input.readBytes(metadataMatch);\r
-            featuresBuilder.setMetadataMatch(metadataMatch);\r
-            byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
-            input.readBytes(metadataWrite);\r
-            featuresBuilder.setMetadataWrite(metadataWrite);\r
-            featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));\r
-            featuresBuilder.setMaxEntries(input.readUnsignedInt());\r
-            featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input, \r
-                    length - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH));\r
-            features.add(featuresBuilder.build());\r
-        }\r
-        builder.setTableFeatures(features);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static TableConfig createTableConfig(long input) {\r
-        boolean deprecated = (input & 3) != 0;\r
-        return new TableConfig(deprecated);\r
-    }\r
-    \r
-    private static List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {\r
-        List<TableFeatureProperties> properties = new ArrayList<>();\r
-        int tableFeaturesLength = length;\r
-        while (tableFeaturesLength > 0) {\r
-            TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder();\r
-            TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort());\r
-            builder.setType(type);\r
-            int propertyLength = input.readUnsignedShort();\r
-            tableFeaturesLength -= propertyLength;\r
-            if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS)\r
-                    || type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {\r
-                InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();\r
-                insBuilder.setInstructions(InstructionsDeserializer.createInstructions(input, propertyLength - COMMON_PROPERTY_LENGTH));\r
-                builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());\r
-            } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES)\r
-                    || type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {\r
-                propertyLength -= COMMON_PROPERTY_LENGTH;\r
-                NextTableRelatedTableFeaturePropertyBuilder tableBuilder = new NextTableRelatedTableFeaturePropertyBuilder();\r
-                List<NextTableIds> ids = new ArrayList<>();\r
-                while (propertyLength > 0) {\r
-                    NextTableIdsBuilder nextTableIdsBuilder = new NextTableIdsBuilder();\r
-                    nextTableIdsBuilder.setTableId(input.readUnsignedByte());\r
-                    ids.add(nextTableIdsBuilder.build());\r
-                }\r
-                tableBuilder.setNextTableIds(ids);\r
-                builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, tableBuilder.build());\r
-            } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONS)\r
-                    || type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS)\r
-                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS)\r
-                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {\r
-                ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();\r
-                actionBuilder.setActionsList(ActionsDeserializer.createActionsList(input, propertyLength - COMMON_PROPERTY_LENGTH));\r
-                builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());\r
-            } else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH)\r
-                    || type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS)\r
-                    || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELD)\r
-                    || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS)\r
-                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD)\r
-                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {\r
-                OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
-                oxmBuilder.setMatchEntries(MatchDeserializer.createMatchEntries(input, propertyLength - COMMON_PROPERTY_LENGTH));\r
-                builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
-            } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)\r
-                    || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {\r
-                final byte EXPERIMENTER_PROPERTY_LENGTH = 12;\r
-                ExperimenterRelatedTableFeaturePropertyBuilder expBuilder = new ExperimenterRelatedTableFeaturePropertyBuilder();\r
-                expBuilder.setExperimenter(input.readUnsignedInt());\r
-                expBuilder.setExpType(input.readUnsignedInt());\r
-                byte[] data = new byte[propertyLength - EXPERIMENTER_PROPERTY_LENGTH];\r
-                input.readBytes(data);\r
-                expBuilder.setData(data);\r
-                builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, expBuilder.build());\r
-            }\r
-            properties.add(builder.build());\r
-        }\r
-        return properties;\r
-    }\r
-    \r
-    private static MultipartReplyPortStats setPortStats(ByteBuf input) {\r
-        MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder();\r
-        List<PortStats> portStatsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            PortStatsBuilder portStatsBuilder = new PortStatsBuilder();\r
-            portStatsBuilder.setPortNo(input.readUnsignedInt());\r
-            input.skipBytes(PADDING_IN_PORT_STATS_HEADER);\r
-            byte[] rxPackets = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxPackets);\r
-            portStatsBuilder.setRxPackets(new BigInteger(rxPackets));\r
-            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txPackets);\r
-            portStatsBuilder.setTxPackets(new BigInteger(txPackets));\r
-            byte[] rxBytes = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxBytes);\r
-            portStatsBuilder.setRxBytes(new BigInteger(rxBytes));\r
-            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txBytes);\r
-            portStatsBuilder.setTxBytes(new BigInteger(txBytes));\r
-            byte[] rxDropped = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxDropped);\r
-            portStatsBuilder.setRxDropped(new BigInteger(rxDropped));\r
-            byte[] txDropped = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txDropped);\r
-            portStatsBuilder.setTxDropped(new BigInteger(txDropped));\r
-            byte[] rxErrors = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxErrors);\r
-            portStatsBuilder.setRxErrors(new BigInteger(rxErrors));\r
-            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txErrors);\r
-            portStatsBuilder.setTxErrors(new BigInteger(txErrors));\r
-            byte[] rxFrameErr = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxFrameErr);\r
-            portStatsBuilder.setRxFrameErr(new BigInteger(rxFrameErr));\r
-            byte[] rxOverErr = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxOverErr);\r
-            portStatsBuilder.setRxOverErr(new BigInteger(rxOverErr));\r
-            byte[] rxCrcErr = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxCrcErr);\r
-            portStatsBuilder.setRxCrcErr(new BigInteger(rxCrcErr));\r
-            byte[] collisions = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(collisions);\r
-            portStatsBuilder.setCollisions(new BigInteger(collisions));\r
-            portStatsBuilder.setDurationSec(input.readUnsignedInt());\r
-            portStatsBuilder.setDurationNsec(input.readUnsignedInt());\r
-            portStatsList.add(portStatsBuilder.build());\r
-        }\r
-        builder.setPortStats(portStatsList);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyQueue setQueue(ByteBuf input) {\r
-        MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder();\r
-        List<QueueStats> queueStatsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder();\r
-            queueStatsBuilder.setPortNo(input.readUnsignedInt());\r
-            queueStatsBuilder.setQueueId(input.readUnsignedInt());\r
-            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txBytes);\r
-            queueStatsBuilder.setTxBytes(new BigInteger(txBytes));\r
-            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txPackets);\r
-            queueStatsBuilder.setTxPackets(new BigInteger(txPackets));\r
-            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txErrors);\r
-            queueStatsBuilder.setTxErrors(new BigInteger(txErrors));\r
-            queueStatsBuilder.setDurationSec(input.readUnsignedInt());\r
-            queueStatsBuilder.setDurationNsec(input.readUnsignedInt());\r
-            queueStatsList.add(queueStatsBuilder.build());\r
-        }\r
-        builder.setQueueStats(queueStatsList);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyGroup setGroup(ByteBuf input) {\r
-        MultipartReplyGroupBuilder builder = new MultipartReplyGroupBuilder();\r
-        List<GroupStats> groupStatsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();\r
-            int bodyLength = input.readUnsignedShort();\r
-            input.skipBytes(PADDING_IN_GROUP_HEADER_01);\r
-            groupStatsBuilder.setGroupId(new GroupId(input.readUnsignedInt()));\r
-            groupStatsBuilder.setRefCount(input.readUnsignedInt());\r
-            input.skipBytes(PADDING_IN_GROUP_HEADER_02);\r
-            byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(packetCount);\r
-            groupStatsBuilder.setPacketCount(new BigInteger(packetCount));\r
-            byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(byteCount);\r
-            groupStatsBuilder.setByteCount(new BigInteger(byteCount));\r
-            groupStatsBuilder.setDurationSec(input.readUnsignedInt());\r
-            groupStatsBuilder.setDurationNsec(input.readUnsignedInt());\r
-            int actualLength = GROUP_BODY_LENGTH;\r
-            List<BucketStats> bucketStatsList = new ArrayList<>();\r
-            while (actualLength < bodyLength) {\r
-                BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();\r
-                byte[] packetCountBucket = new byte[Long.SIZE/Byte.SIZE];\r
-                input.readBytes(packetCountBucket);\r
-                bucketStatsBuilder.setPacketCount(new BigInteger(packetCountBucket));\r
-                byte[] byteCountBucket = new byte[Long.SIZE/Byte.SIZE];\r
-                input.readBytes(byteCountBucket);\r
-                bucketStatsBuilder.setByteCount(new BigInteger(byteCountBucket));\r
-                bucketStatsList.add(bucketStatsBuilder.build());\r
-                actualLength += BUCKET_COUNTER_LENGTH;\r
-            } \r
-            groupStatsBuilder.setBucketStats(bucketStatsList);\r
-            groupStatsList.add(groupStatsBuilder.build());\r
-        }\r
-        builder.setGroupStats(groupStatsList);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyMeterFeatures setMeterFeatures(ByteBuf input) {\r
-        MultipartReplyMeterFeaturesBuilder builder = new MultipartReplyMeterFeaturesBuilder();\r
-        builder.setMaxMeter(input.readUnsignedInt());\r
-        builder.setBandTypes(createMeterBandsBitmap(input.readUnsignedInt()));\r
-        builder.setCapabilities(createMeterFlags(input.readUnsignedInt()));\r
-        builder.setMaxBands(input.readUnsignedByte());\r
-        builder.setMaxColor(input.readUnsignedByte());\r
-        input.skipBytes(PADDING_IN_METER_FEATURES_HEADER);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MeterFlags createMeterFlags(long input){\r
-        final Boolean _oFPMFKBPS = (input & (1 << 0)) != 0;\r
-        final Boolean _oFPMFPKTPS = (input & (1 << 1)) != 0;\r
-        final Boolean _oFPMFBURST = (input & (1 << 2)) != 0;\r
-        final Boolean _oFPMFSTATS = (input & (1 << 3)) != 0;\r
-        return new MeterFlags(_oFPMFBURST, _oFPMFKBPS, _oFPMFPKTPS, _oFPMFSTATS);\r
-    }\r
-    \r
-    private static MeterBandTypeBitmap createMeterBandsBitmap(long input) {\r
-        final Boolean _oFPMBTDROP = (input & (1 << 0)) != 0;\r
-        final Boolean _oFPMBTDSCPREMARK = (input & (1 << 1)) != 0;\r
-        return new MeterBandTypeBitmap(_oFPMBTDROP, _oFPMBTDSCPREMARK);\r
-    }\r
-    \r
-    private static MultipartReplyMeter setMeter(ByteBuf input) {\r
-        MultipartReplyMeterBuilder builder = new MultipartReplyMeterBuilder();\r
-        List<MeterStats> meterStatsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            MeterStatsBuilder meterStatsBuilder = new MeterStatsBuilder();\r
-            meterStatsBuilder.setMeterId(new MeterId(input.readUnsignedInt()));\r
-            int meterStatsBodyLength = input.readUnsignedShort();\r
-            input.skipBytes(PADDING_IN_METER_STATS_HEADER);\r
-            meterStatsBuilder.setFlowCount(input.readUnsignedInt());\r
-            byte[] packetInCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(packetInCount);\r
-            meterStatsBuilder.setPacketInCount(new BigInteger(packetInCount));\r
-            byte[] byteInCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(byteInCount);\r
-            meterStatsBuilder.setByteInCount(new BigInteger(byteInCount));\r
-            meterStatsBuilder.setDurationSec(input.readUnsignedInt());\r
-            meterStatsBuilder.setDurationNsec(input.readUnsignedInt());\r
-            int actualLength = METER_BODY_LENGTH;\r
-            List<MeterBandStats> meterBandStatsList = new ArrayList<>();\r
-            while (actualLength < meterStatsBodyLength) {\r
-                MeterBandStatsBuilder meterBandStatsBuilder = new MeterBandStatsBuilder();\r
-                byte[] packetBandCount = new byte[Long.SIZE/Byte.SIZE];\r
-                input.readBytes(packetBandCount);\r
-                meterBandStatsBuilder.setPacketBandCount(new BigInteger(packetBandCount));\r
-                byte[] byteBandCount = new byte[Long.SIZE/Byte.SIZE];\r
-                input.readBytes(byteBandCount);\r
-                meterBandStatsBuilder.setByteBandCount(new BigInteger(byteBandCount));\r
-                meterBandStatsList.add(meterBandStatsBuilder.build());\r
-                actualLength += METER_BAND_STATS_LENGTH;\r
-            }\r
-            meterStatsBuilder.setMeterBandStats(meterBandStatsList);\r
-            meterStatsList.add(meterStatsBuilder.build());\r
-        }\r
-        builder.setMeterStats(meterStatsList);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyMeterConfig setMeterConfig(ByteBuf input) {\r
-        MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder();\r
-        List<MeterConfig> meterConfigList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();\r
-            int meterConfigBodyLength = input.readUnsignedShort();\r
-            meterConfigBuilder.setFlags(createMeterFlags(input.readUnsignedShort()));\r
-            meterConfigBuilder.setMeterId(new MeterId(input.readUnsignedInt()));\r
-            int actualLength = METER_CONFIG_LENGTH;\r
-            List<Bands> bandsList = new ArrayList<>();\r
-            while (actualLength < meterConfigBodyLength) {\r
-                BandsBuilder bandsBuilder = new BandsBuilder();\r
-                int bandType = input.readUnsignedShort();\r
-                switch (bandType) {\r
-                    case 1:\r
-                        MeterBandDropBuilder bandDropBuilder = new MeterBandDropBuilder();\r
-                        bandDropBuilder.setType(MeterBandType.forValue(bandType));\r
-                        actualLength += input.readUnsignedShort();\r
-                        bandDropBuilder.setRate(input.readUnsignedInt());\r
-                        bandDropBuilder.setBurstSize(input.readUnsignedInt());\r
-                        input.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);\r
-                        bandsBuilder.setMeterBand(bandDropBuilder.build());\r
-                        break;\r
-                    case 2:\r
-                        MeterBandDscpRemarkBuilder bandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder();\r
-                        bandDscpRemarkBuilder.setType(MeterBandType.forValue(bandType));\r
-                        actualLength += input.readUnsignedShort();\r
-                        bandDscpRemarkBuilder.setRate(input.readUnsignedInt());\r
-                        bandDscpRemarkBuilder.setBurstSize(input.readUnsignedInt());\r
-                        bandDscpRemarkBuilder.setPrecLevel(input.readUnsignedByte());\r
-                        input.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);\r
-                        bandsBuilder.setMeterBand(bandDscpRemarkBuilder.build());\r
-                        break;\r
-                    case 0xFFFF:\r
-                        MeterBandExperimenterBuilder bandExperimenterBuilder = new MeterBandExperimenterBuilder();\r
-                        bandExperimenterBuilder.setType(MeterBandType.forValue(bandType));\r
-                        actualLength += input.readUnsignedShort();\r
-                        bandExperimenterBuilder.setRate(input.readUnsignedInt());\r
-                        bandExperimenterBuilder.setBurstSize(input.readUnsignedInt());\r
-                        bandExperimenterBuilder.setExperimenter(input.readUnsignedInt());\r
-                        bandsBuilder.setMeterBand(bandExperimenterBuilder.build());\r
-                        break;\r
-                    default:\r
-                        break;\r
-                }\r
-                bandsList.add(bandsBuilder.build());\r
-            }\r
-            meterConfigBuilder.setBands(bandsList);\r
-            meterConfigList.add(meterConfigBuilder.build());\r
-        }\r
-        builder.setMeterConfig(meterConfigList);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyExperimenter setExperimenter(ByteBuf input) {\r
-        MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder();\r
-        builder.setExperimenter(input.readUnsignedInt());\r
-        builder.setExpType(input.readUnsignedInt());\r
-        byte[] data = new byte[input.readableBytes()];\r
-        input.readBytes(data);\r
-        builder.setData(data);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyPortDesc setPortDesc(ByteBuf input) {\r
-        MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();\r
-        List<Ports> portsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            PortsBuilder portsBuilder = new PortsBuilder();\r
-            portsBuilder.setPortNo(input.readUnsignedInt());\r
-            input.skipBytes(PADDING_IN_PORT_DESC_HEADER_01);\r
-            byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];\r
-            input.readBytes(hwAddress);\r
-            portsBuilder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(hwAddress)));\r
-            input.skipBytes(PADDING_IN_PORT_DESC_HEADER_02);\r
-            byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN];\r
-            input.readBytes(portNameBytes);\r
-            String portName = new String(portNameBytes);\r
-            portsBuilder.setName(portName.trim());\r
-            portsBuilder.setConfig(createPortConfig(input.readUnsignedInt()));\r
-            portsBuilder.setState(createPortState(input.readUnsignedInt()));\r
-            portsBuilder.setCurrentFeatures(createPortFeatures(input.readUnsignedInt()));\r
-            portsBuilder.setAdvertisedFeatures(createPortFeatures(input.readUnsignedInt()));\r
-            portsBuilder.setSupportedFeatures(createPortFeatures(input.readUnsignedInt()));\r
-            portsBuilder.setPeerFeatures(createPortFeatures(input.readUnsignedInt()));\r
-            portsBuilder.setCurrSpeed(input.readUnsignedInt());\r
-            portsBuilder.setMaxSpeed(input.readUnsignedInt());\r
-            portsList.add(portsBuilder.build());\r
-        }\r
-        builder.setPorts(portsList);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static PortConfig createPortConfig(long input){\r
-        final Boolean _portDown   = ((input) & (1<<0)) != 0;\r
-        final Boolean _noRecv    = ((input) & (1<<2)) != 0;\r
-        final Boolean _noFwd       = ((input) & (1<<5)) != 0;\r
-        final Boolean _noPacketIn = ((input) & (1<<6)) != 0;\r
-        return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);\r
-    }\r
-    \r
-    private static PortState createPortState(long input){\r
-        final Boolean _linkDown = ((input) & (1<<0)) != 0;\r
-        final Boolean _blocked  = ((input) & (1<<1)) != 0;\r
-        final Boolean _live     = ((input) & (1<<2)) != 0;\r
-        return new PortState(_blocked, _linkDown, _live);\r
-    }\r
-    \r
-    private static PortFeatures createPortFeatures(long input){\r
-        final Boolean _10mbHd = ((input) & (1<<0)) != 0;\r
-        final Boolean _10mbFd = ((input) & (1<<1)) != 0;\r
-        final Boolean _100mbHd = ((input) & (1<<2)) != 0;\r
-        final Boolean _100mbFd = ((input) & (1<<3)) != 0;\r
-        final Boolean _1gbHd = ((input) & (1<<4)) != 0;\r
-        final Boolean _1gbFd = ((input) & (1<<5)) != 0;\r
-        final Boolean _10gbFd = ((input) & (1<<6)) != 0;\r
-        final Boolean _40gbFd = ((input) & (1<<7)) != 0;\r
-        final Boolean _100gbFd = ((input) & (1<<8)) != 0;\r
-        final Boolean _1tbFd = ((input) & (1<<9)) != 0;\r
-        final Boolean _other = ((input) & (1<<10)) != 0;\r
-        final Boolean _copper = ((input) & (1<<11)) != 0;\r
-        final Boolean _fiber = ((input) & (1<<12)) != 0;\r
-        final Boolean _autoneg = ((input) & (1<<13)) != 0;\r
-        final Boolean _pause = ((input) & (1<<14)) != 0;\r
-        final Boolean _pauseAsym = ((input) & (1<<15)) != 0;\r
-        return new PortFeatures(_10mbHd, _10mbFd, _100mbHd, _100mbFd, _1gbHd, _1gbFd, _10gbFd,\r
-                _40gbFd, _100gbFd, _1tbFd, _other, _copper, _fiber, _autoneg, _pause, _pauseAsym);\r
-    }\r
-    \r
-    private static MultipartReplyBody setGroupFeatures(ByteBuf rawMessage) {\r
-        MultipartReplyGroupFeaturesBuilder featuresBuilder = new MultipartReplyGroupFeaturesBuilder();\r
-        featuresBuilder.setTypes(createGroupType(rawMessage.readUnsignedInt()));\r
-        featuresBuilder.setCapabilities(createCapabilities(rawMessage.readUnsignedInt()));\r
-        List<Long> maxGroupsList = new ArrayList<>();\r
-        for (int i = 0; i < GROUP_TYPES ; i++) {\r
-            maxGroupsList.add(rawMessage.readUnsignedInt());\r
-        }\r
-        featuresBuilder.setMaxGroups(maxGroupsList);\r
-        List<ActionType> actionBitmaps = new ArrayList<>();\r
-        for (int i = 0; i < GROUP_TYPES ; i++) {\r
-            actionBitmaps.add(createActionBitmap(rawMessage.readUnsignedInt()));\r
-        }\r
-        featuresBuilder.setActionsBitmap(actionBitmaps);\r
-        return featuresBuilder.build();\r
-    }\r
-    \r
-    private static ActionType createActionBitmap(long input) {\r
-        final Boolean OFPAT_OUTPUT = ((input) & (1<<0)) != 0;\r
-        final Boolean OFPAT_COPY_TTL_OUT = ((input) & (1<<1)) != 0;\r
-        final Boolean OFPAT_COPY_TTL_IN = ((input) & (1<<2)) != 0;\r
-        final Boolean OFPAT_SET_MPLS_TTL = ((input) & (1<<3)) != 0;\r
-        final Boolean OFPAT_DEC_MPLS_TTL = ((input) & (1<<4)) != 0;\r
-        final Boolean OFPAT_PUSH_VLAN = ((input) & (1<<5)) != 0;\r
-        final Boolean OFPAT_POP_VLAN = ((input) & (1<<6)) != 0;\r
-        final Boolean OFPAT_PUSH_MPLS = ((input) & (1<<7)) != 0;\r
-        final Boolean OFPAT_POP_MPLS = ((input) & (1<<8)) != 0;\r
-        final Boolean OFPAT_SET_QUEUE = ((input) & (1<<9)) != 0;\r
-        final Boolean OFPAT_GROUP = ((input) & (1<<10)) != 0;\r
-        final Boolean OFPAT_SET_NW_TTL = ((input) & (1<<11)) != 0;\r
-        final Boolean OFPAT_DEC_NW_TTL = ((input) & (1<<12)) != 0;\r
-        final Boolean OFPAT_SET_FIELD = ((input) & (1<<13)) != 0;\r
-        final Boolean OFPAT_PUSH_PBB = ((input) & (1<<14)) != 0;\r
-        final Boolean OFPAT_POP_PBB = ((input) & (1<<15)) != 0;\r
-        final Boolean OFPAT_EXPERIMENTER = ((input) & (1<<16)) != 0;\r
-        return new ActionType(OFPAT_COPY_TTL_IN, OFPAT_COPY_TTL_OUT, OFPAT_DEC_MPLS_TTL,\r
-                OFPAT_DEC_NW_TTL, OFPAT_EXPERIMENTER, OFPAT_GROUP, OFPAT_OUTPUT, OFPAT_POP_MPLS,\r
-                OFPAT_POP_PBB, OFPAT_POP_VLAN, OFPAT_PUSH_MPLS, OFPAT_PUSH_PBB, OFPAT_PUSH_VLAN,\r
-                OFPAT_SET_FIELD, OFPAT_SET_MPLS_TTL, OFPAT_SET_NW_TTL, OFPAT_SET_QUEUE);\r
-    }\r
-\r
-    private static GroupCapabilities createCapabilities(long input) {\r
-        final Boolean OFOFPGFC_SELECT_WEIGHT = ((input) & (1<<0)) != 0;\r
-        final Boolean OFPGFC_SELECT_LIVENESS = ((input) & (1<<1)) != 0;\r
-        final Boolean OFPGFC_CHAINING = ((input) & (1<<2)) != 0;\r
-        final Boolean OFPGFC_CHAINING_CHECKS = ((input) & (1<<3)) != 0;\r
-        return new GroupCapabilities(OFPGFC_CHAINING, OFPGFC_CHAINING_CHECKS, OFPGFC_SELECT_LIVENESS, OFOFPGFC_SELECT_WEIGHT);\r
-    }\r
-\r
-    private static GroupTypes createGroupType(long input) {\r
-        final Boolean OFPGT_ALL = ((input) & (1<<0)) != 0;\r
-        final Boolean OFPGT_SELECT = ((input) & (1<<1)) != 0;\r
-        final Boolean OFPGT_INDIRECT = ((input) & (1<<2)) != 0;\r
-        final Boolean OFPGT_FF = ((input) & (1<<3)) != 0;\r
-        return new GroupTypes(OFPGT_ALL, OFPGT_FF, OFPGT_INDIRECT, OFPGT_SELECT);\r
-    }\r
-    \r
-    private static MultipartReplyGroupDesc setGroupDesc(ByteBuf input) {\r
-        MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();\r
-        List<GroupDesc> groupDescsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            GroupDescBuilder groupDescBuilder = new GroupDescBuilder();\r
-            int bodyLength = input.readUnsignedShort();\r
-            groupDescBuilder.setType(GroupType.forValue(input.readUnsignedByte()));\r
-            input.skipBytes(PADDING_IN_GROUP_DESC_HEADER);\r
-            groupDescBuilder.setGroupId(new GroupId(input.readUnsignedInt()));\r
-            int actualLength = GROUP_DESC_HEADER_LENGTH;\r
-            List<BucketsList> bucketsList = new ArrayList<>();\r
-            while (actualLength < bodyLength) {\r
-                BucketsListBuilder bucketsBuilder = new BucketsListBuilder();\r
-                int bucketsLength = input.readUnsignedShort();\r
-                bucketsBuilder.setWeight(input.readUnsignedShort());\r
-                bucketsBuilder.setWatchPort(new PortNumber(input.readUnsignedInt()));\r
-                bucketsBuilder.setWatchGroup(input.readUnsignedInt());\r
-                input.skipBytes(PADDING_IN_BUCKETS_HEADER);\r
-                List<ActionsList> actionsList = ActionsDeserializer\r
-                        .createActionsList(input, bucketsLength - BUCKETS_HEADER_LENGTH);\r
-                bucketsBuilder.setActionsList(actionsList);\r
-                bucketsList.add(bucketsBuilder.build());\r
-                actualLength += bucketsLength;\r
-            }\r
-            groupDescBuilder.setBucketsList(bucketsList);\r
-            groupDescsList.add(groupDescBuilder.build());\r
-        }\r
-        builder.setGroupDesc(groupDescsList);\r
-        return builder.build();\r
-    }\r
-    \r
-}\r
+/*
+ * 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 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.impl.util.ByteBufUtils;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeaturePropertyBuilder;
+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.ActionsList;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.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.BucketsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow.FlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow.FlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.GroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.GroupStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc.GroupDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc.GroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.group.stats.BucketStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.group.stats.BucketStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.MeterStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.MeterStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config.MeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config.MeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config.meter.config.Bands;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config.meter.config.BandsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.meter.stats.MeterBandStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.meter.stats.MeterBandStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc.PortsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats.PortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats.PortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue.QueueStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue.QueueStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.TableStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.TableStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeatureProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeaturePropertiesBuilder;
+
+/**
+ * Translates MultipartReply messages
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class MultipartReplyMessageFactory implements OFDeserializer<MultipartReplyMessage> {
+
+    private static final byte PADDING_IN_MULTIPART_REPLY_HEADER = 4;
+    private static final int DESC_STR_LEN = 256;
+    private static final int SERIAL_NUM_LEN = 32;
+    private static final byte PADDING_IN_FLOW_STATS_HEADER_01 = 1;
+    private static final byte PADDING_IN_FLOW_STATS_HEADER_02 = 4;
+    private static final byte PADDING_IN_AGGREGATE_HEADER = 4;
+    private static final byte PADDING_IN_TABLE_HEADER = 3;
+    private static final byte PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES = 5;
+    private static final byte MAX_TABLE_NAME_LENGTH = 32;
+    private static final byte MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH = 64;
+    private static final byte COMMON_PROPERTY_LENGTH = 4;
+    private static final byte PADDING_IN_PORT_STATS_HEADER = 4;
+    private static final byte PADDING_IN_GROUP_HEADER_01 = 2;
+    private static final byte PADDING_IN_GROUP_HEADER_02 = 4;
+    private static final byte BUCKET_COUNTER_LENGTH = 16;
+    private static final byte GROUP_BODY_LENGTH = 40;
+    private static final byte PADDING_IN_METER_FEATURES_HEADER = 2;
+    private static final byte PADDING_IN_METER_STATS_HEADER = 6;
+    private static final byte METER_BAND_STATS_LENGTH = 16;
+    private static final byte METER_BODY_LENGTH = 40;
+    private static final byte METER_CONFIG_LENGTH = 8;
+    private static final byte PADDING_IN_METER_BAND_DROP_HEADER = 4;
+    private static final byte PADDING_IN_METER_BAND_DSCP_HEADER = 3;
+    private static final byte PADDING_IN_PORT_DESC_HEADER_01 = 4;
+    private static final byte PADDING_IN_PORT_DESC_HEADER_02 = 2;
+    private static final byte MAX_PORT_NAME_LEN = 16;
+    private static final int GROUP_TYPES = 4;
+    private static final byte PADDING_IN_GROUP_DESC_HEADER = 1;
+    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;
+    }
+
+    @Override
+    public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        int type = rawMessage.readUnsignedShort();
+        builder.setType(MultipartType.forValue(type));
+        builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0));
+        rawMessage.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);
+
+        switch (type) {
+        case 0:  builder.setMultipartReplyBody(setDesc(rawMessage));
+                 break;
+        case 1:  builder.setMultipartReplyBody(setFlow(rawMessage));
+                 break;
+        case 2:  builder.setMultipartReplyBody(setAggregate(rawMessage));
+                 break;
+        case 3:  builder.setMultipartReplyBody(setTable(rawMessage));
+                 break;         
+        case 4:  builder.setMultipartReplyBody(setPortStats(rawMessage));
+                 break;
+        case 5:  builder.setMultipartReplyBody(setQueue(rawMessage));
+                 break;         
+        case 6:  builder.setMultipartReplyBody(setGroup(rawMessage));
+                 break;
+        case 7:  builder.setMultipartReplyBody(setGroupDesc(rawMessage));
+                 break;
+        case 8:  builder.setMultipartReplyBody(setGroupFeatures(rawMessage));
+                 break;
+        case 9:  builder.setMultipartReplyBody(setMeter(rawMessage));
+                 break;
+        case 10: builder.setMultipartReplyBody(setMeterConfig(rawMessage));
+                 break;
+        case 11: builder.setMultipartReplyBody(setMeterFeatures(rawMessage));
+                 break;
+        case 12: builder.setMultipartReplyBody(setTableFeatures(rawMessage));
+                 break;
+        case 13: builder.setMultipartReplyBody(setPortDesc(rawMessage));
+                 break;
+        case 0xFFFF: builder.setMultipartReplyBody(setExperimenter(rawMessage));
+                 break;
+        default: 
+                 break;
+        }
+        
+        return builder.build();
+    }
+    
+    private static MultipartReplyDesc setDesc(ByteBuf input) {
+        MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder();
+        byte[] mfrDescBytes = new byte[DESC_STR_LEN];
+        input.readBytes(mfrDescBytes);
+        String mfrDesc = new String(mfrDescBytes);
+        descBuilder.setMfrDesc(mfrDesc.trim());
+        byte[] hwDescBytes = new byte[DESC_STR_LEN];
+        input.readBytes(hwDescBytes);
+        String hwDesc = new String(hwDescBytes);
+        descBuilder.setHwDesc(hwDesc.trim());
+        byte[] swDescBytes = new byte[DESC_STR_LEN];
+        input.readBytes(swDescBytes);
+        String swDesc = new String(swDescBytes);
+        descBuilder.setSwDesc(swDesc.trim());
+        byte[] serialNumBytes = new byte[SERIAL_NUM_LEN];
+        input.readBytes(serialNumBytes);
+        String serialNum = new String(serialNumBytes);
+        descBuilder.setSerialNum(serialNum.trim());
+        byte[] dpDescBytes = new byte[DESC_STR_LEN];
+        input.readBytes(dpDescBytes);
+        String dpDesc = new String(dpDescBytes);
+        descBuilder.setDpDesc(dpDesc.trim());
+        return descBuilder.build();
+    }
+    
+    private static MultipartReplyFlow setFlow(ByteBuf input) {
+        MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
+        List<FlowStats> flowStatsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder();
+            input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            flowStatsBuilder.setTableId(input.readUnsignedByte());
+            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);
+            flowStatsBuilder.setDurationSec(input.readUnsignedInt());
+            flowStatsBuilder.setDurationNsec(input.readUnsignedInt());
+            flowStatsBuilder.setPriority(input.readUnsignedShort());
+            flowStatsBuilder.setIdleTimeout(input.readUnsignedShort());
+            flowStatsBuilder.setHardTimeout(input.readUnsignedShort());
+            flowStatsBuilder.setFlags(createFlowModFlagsFromBitmap(input.readShort()));
+            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
+            byte[] cookie = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(cookie);
+            flowStatsBuilder.setCookie(new BigInteger(cookie));
+            byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(packetCount);
+            flowStatsBuilder.setPacketCount(new BigInteger(packetCount));
+            byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(byteCount);
+            flowStatsBuilder.setByteCount(new BigInteger(byteCount));
+            flowStatsBuilder.setMatch(MatchDeserializer.createMatch(input));
+            flowStatsBuilder.setInstructions(InstructionsDeserializer.createInstructions(input, input.readableBytes()));
+            flowStatsList.add(flowStatsBuilder.build());
+        }
+        flowBuilder.setFlowStats(flowStatsList);
+        return flowBuilder.build();
+    }
+    
+    private static FlowModFlags createFlowModFlagsFromBitmap(short input){
+        final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) != 0;
+        final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) != 0;
+        final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) != 0; 
+        final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) != 0;
+        final Boolean _oFPFFNOBYTCOUNTS = (input & (1 << 4)) != 0;
+        return new FlowModFlags(_oFPFFCHECKOVERLAP, _oFPFFNOBYTCOUNTS, _oFPFFNOPKTCOUNTS, _oFPFFRESETCOUNTS, _oFPFFSENDFLOWREM);
+    }
+    
+    private static MultipartReplyAggregate setAggregate(ByteBuf input) {
+        MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();
+        byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];
+        input.readBytes(packetCount);
+        builder.setPacketCount(new BigInteger(packetCount));
+        byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];
+        input.readBytes(byteCount);
+        builder.setByteCount(new BigInteger(byteCount));
+        builder.setFlowCount(input.readUnsignedInt());
+        input.skipBytes(PADDING_IN_AGGREGATE_HEADER);
+        return builder.build();
+    }
+    
+    private static MultipartReplyTable setTable(ByteBuf input) {
+        MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();
+        List<TableStats> tableStatsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            TableStatsBuilder tableStatsBuilder = new TableStatsBuilder();
+            tableStatsBuilder.setTableId(input.readUnsignedByte());
+            input.skipBytes(PADDING_IN_TABLE_HEADER);
+            tableStatsBuilder.setActiveCount(input.readUnsignedInt());
+            byte[] lookupCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(lookupCount);
+            tableStatsBuilder.setLookupCount(new BigInteger(lookupCount));
+            byte[] matchedCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(matchedCount);
+            tableStatsBuilder.setMatchedCount(new BigInteger(matchedCount));
+            tableStatsList.add(tableStatsBuilder.build());
+        }
+        builder.setTableStats(tableStatsList);
+        return builder.build();
+    }
+    
+    private static MultipartReplyTableFeatures setTableFeatures(ByteBuf input) {
+        MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
+        List<TableFeatures> features = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
+            int length = input.readUnsignedShort();
+            featuresBuilder.setTableId(input.readUnsignedByte());
+            input.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);
+            featuresBuilder.setName(input.readBytes(MAX_TABLE_NAME_LENGTH).toString());
+            byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            input.readBytes(metadataMatch);
+            featuresBuilder.setMetadataMatch(metadataMatch);
+            byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            input.readBytes(metadataWrite);
+            featuresBuilder.setMetadataWrite(metadataWrite);
+            featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));
+            featuresBuilder.setMaxEntries(input.readUnsignedInt());
+            featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input, 
+                    length - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH));
+            features.add(featuresBuilder.build());
+        }
+        builder.setTableFeatures(features);
+        return builder.build();
+    }
+    
+    private static TableConfig createTableConfig(long input) {
+        boolean deprecated = (input & 3) != 0;
+        return new TableConfig(deprecated);
+    }
+    
+    private static List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {
+        List<TableFeatureProperties> properties = new ArrayList<>();
+        int tableFeaturesLength = length;
+        while (tableFeaturesLength > 0) {
+            TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder();
+            TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort());
+            builder.setType(type);
+            int propertyLength = input.readUnsignedShort();
+            tableFeaturesLength -= propertyLength;
+            if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
+                InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
+                insBuilder.setInstructions(InstructionsDeserializer.createInstructions(input, propertyLength - COMMON_PROPERTY_LENGTH));
+                builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());
+            } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES)
+                    || type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {
+                propertyLength -= COMMON_PROPERTY_LENGTH;
+                NextTableRelatedTableFeaturePropertyBuilder tableBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
+                List<NextTableIds> ids = new ArrayList<>();
+                while (propertyLength > 0) {
+                    NextTableIdsBuilder nextTableIdsBuilder = new NextTableIdsBuilder();
+                    nextTableIdsBuilder.setTableId(input.readUnsignedByte());
+                    ids.add(nextTableIdsBuilder.build());
+                }
+                tableBuilder.setNextTableIds(ids);
+                builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, tableBuilder.build());
+            } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
+                ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
+                actionBuilder.setActionsList(ActionsDeserializer.createActionsList(input, propertyLength - COMMON_PROPERTY_LENGTH));
+                builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());
+            } else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH)
+                    || type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELD)
+                    || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS)
+                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD)
+                    || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {
+                OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+                oxmBuilder.setMatchEntries(MatchDeserializer.createMatchEntries(input, propertyLength - COMMON_PROPERTY_LENGTH));
+                builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+            } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)
+                    || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {
+                final byte EXPERIMENTER_PROPERTY_LENGTH = 12;
+                ExperimenterRelatedTableFeaturePropertyBuilder expBuilder = new ExperimenterRelatedTableFeaturePropertyBuilder();
+                expBuilder.setExperimenter(input.readUnsignedInt());
+                expBuilder.setExpType(input.readUnsignedInt());
+                byte[] data = new byte[propertyLength - EXPERIMENTER_PROPERTY_LENGTH];
+                input.readBytes(data);
+                expBuilder.setData(data);
+                builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, expBuilder.build());
+            }
+            properties.add(builder.build());
+        }
+        return properties;
+    }
+    
+    private static MultipartReplyPortStats setPortStats(ByteBuf input) {
+        MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder();
+        List<PortStats> portStatsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            PortStatsBuilder portStatsBuilder = new PortStatsBuilder();
+            portStatsBuilder.setPortNo(input.readUnsignedInt());
+            input.skipBytes(PADDING_IN_PORT_STATS_HEADER);
+            byte[] rxPackets = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxPackets);
+            portStatsBuilder.setRxPackets(new BigInteger(rxPackets));
+            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txPackets);
+            portStatsBuilder.setTxPackets(new BigInteger(txPackets));
+            byte[] rxBytes = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxBytes);
+            portStatsBuilder.setRxBytes(new BigInteger(rxBytes));
+            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txBytes);
+            portStatsBuilder.setTxBytes(new BigInteger(txBytes));
+            byte[] rxDropped = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxDropped);
+            portStatsBuilder.setRxDropped(new BigInteger(rxDropped));
+            byte[] txDropped = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txDropped);
+            portStatsBuilder.setTxDropped(new BigInteger(txDropped));
+            byte[] rxErrors = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxErrors);
+            portStatsBuilder.setRxErrors(new BigInteger(rxErrors));
+            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txErrors);
+            portStatsBuilder.setTxErrors(new BigInteger(txErrors));
+            byte[] rxFrameErr = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxFrameErr);
+            portStatsBuilder.setRxFrameErr(new BigInteger(rxFrameErr));
+            byte[] rxOverErr = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxOverErr);
+            portStatsBuilder.setRxOverErr(new BigInteger(rxOverErr));
+            byte[] rxCrcErr = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxCrcErr);
+            portStatsBuilder.setRxCrcErr(new BigInteger(rxCrcErr));
+            byte[] collisions = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(collisions);
+            portStatsBuilder.setCollisions(new BigInteger(collisions));
+            portStatsBuilder.setDurationSec(input.readUnsignedInt());
+            portStatsBuilder.setDurationNsec(input.readUnsignedInt());
+            portStatsList.add(portStatsBuilder.build());
+        }
+        builder.setPortStats(portStatsList);
+        return builder.build();
+    }
+    
+    private static MultipartReplyQueue setQueue(ByteBuf input) {
+        MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder();
+        List<QueueStats> queueStatsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder();
+            queueStatsBuilder.setPortNo(input.readUnsignedInt());
+            queueStatsBuilder.setQueueId(input.readUnsignedInt());
+            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txBytes);
+            queueStatsBuilder.setTxBytes(new BigInteger(txBytes));
+            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txPackets);
+            queueStatsBuilder.setTxPackets(new BigInteger(txPackets));
+            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txErrors);
+            queueStatsBuilder.setTxErrors(new BigInteger(txErrors));
+            queueStatsBuilder.setDurationSec(input.readUnsignedInt());
+            queueStatsBuilder.setDurationNsec(input.readUnsignedInt());
+            queueStatsList.add(queueStatsBuilder.build());
+        }
+        builder.setQueueStats(queueStatsList);
+        return builder.build();
+    }
+    
+    private static MultipartReplyGroup setGroup(ByteBuf input) {
+        MultipartReplyGroupBuilder builder = new MultipartReplyGroupBuilder();
+        List<GroupStats> groupStatsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();
+            int bodyLength = input.readUnsignedShort();
+            input.skipBytes(PADDING_IN_GROUP_HEADER_01);
+            groupStatsBuilder.setGroupId(new GroupId(input.readUnsignedInt()));
+            groupStatsBuilder.setRefCount(input.readUnsignedInt());
+            input.skipBytes(PADDING_IN_GROUP_HEADER_02);
+            byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(packetCount);
+            groupStatsBuilder.setPacketCount(new BigInteger(packetCount));
+            byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(byteCount);
+            groupStatsBuilder.setByteCount(new BigInteger(byteCount));
+            groupStatsBuilder.setDurationSec(input.readUnsignedInt());
+            groupStatsBuilder.setDurationNsec(input.readUnsignedInt());
+            int actualLength = GROUP_BODY_LENGTH;
+            List<BucketStats> bucketStatsList = new ArrayList<>();
+            while (actualLength < bodyLength) {
+                BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();
+                byte[] packetCountBucket = new byte[Long.SIZE/Byte.SIZE];
+                input.readBytes(packetCountBucket);
+                bucketStatsBuilder.setPacketCount(new BigInteger(packetCountBucket));
+                byte[] byteCountBucket = new byte[Long.SIZE/Byte.SIZE];
+                input.readBytes(byteCountBucket);
+                bucketStatsBuilder.setByteCount(new BigInteger(byteCountBucket));
+                bucketStatsList.add(bucketStatsBuilder.build());
+                actualLength += BUCKET_COUNTER_LENGTH;
+            } 
+            groupStatsBuilder.setBucketStats(bucketStatsList);
+            groupStatsList.add(groupStatsBuilder.build());
+        }
+        builder.setGroupStats(groupStatsList);
+        return builder.build();
+    }
+    
+    private static MultipartReplyMeterFeatures setMeterFeatures(ByteBuf input) {
+        MultipartReplyMeterFeaturesBuilder builder = new MultipartReplyMeterFeaturesBuilder();
+        builder.setMaxMeter(input.readUnsignedInt());
+        builder.setBandTypes(createMeterBandsBitmap(input.readUnsignedInt()));
+        builder.setCapabilities(createMeterFlags(input.readUnsignedInt()));
+        builder.setMaxBands(input.readUnsignedByte());
+        builder.setMaxColor(input.readUnsignedByte());
+        input.skipBytes(PADDING_IN_METER_FEATURES_HEADER);
+        return builder.build();
+    }
+    
+    private static MeterFlags createMeterFlags(long input){
+        final Boolean _oFPMFKBPS = (input & (1 << 0)) != 0;
+        final Boolean _oFPMFPKTPS = (input & (1 << 1)) != 0;
+        final Boolean _oFPMFBURST = (input & (1 << 2)) != 0;
+        final Boolean _oFPMFSTATS = (input & (1 << 3)) != 0;
+        return new MeterFlags(_oFPMFBURST, _oFPMFKBPS, _oFPMFPKTPS, _oFPMFSTATS);
+    }
+    
+    private static MeterBandTypeBitmap createMeterBandsBitmap(long input) {
+        final Boolean _oFPMBTDROP = (input & (1 << 0)) != 0;
+        final Boolean _oFPMBTDSCPREMARK = (input & (1 << 1)) != 0;
+        return new MeterBandTypeBitmap(_oFPMBTDROP, _oFPMBTDSCPREMARK);
+    }
+    
+    private static MultipartReplyMeter setMeter(ByteBuf input) {
+        MultipartReplyMeterBuilder builder = new MultipartReplyMeterBuilder();
+        List<MeterStats> meterStatsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            MeterStatsBuilder meterStatsBuilder = new MeterStatsBuilder();
+            meterStatsBuilder.setMeterId(new MeterId(input.readUnsignedInt()));
+            int meterStatsBodyLength = input.readUnsignedShort();
+            input.skipBytes(PADDING_IN_METER_STATS_HEADER);
+            meterStatsBuilder.setFlowCount(input.readUnsignedInt());
+            byte[] packetInCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(packetInCount);
+            meterStatsBuilder.setPacketInCount(new BigInteger(packetInCount));
+            byte[] byteInCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(byteInCount);
+            meterStatsBuilder.setByteInCount(new BigInteger(byteInCount));
+            meterStatsBuilder.setDurationSec(input.readUnsignedInt());
+            meterStatsBuilder.setDurationNsec(input.readUnsignedInt());
+            int actualLength = METER_BODY_LENGTH;
+            List<MeterBandStats> meterBandStatsList = new ArrayList<>();
+            while (actualLength < meterStatsBodyLength) {
+                MeterBandStatsBuilder meterBandStatsBuilder = new MeterBandStatsBuilder();
+                byte[] packetBandCount = new byte[Long.SIZE/Byte.SIZE];
+                input.readBytes(packetBandCount);
+                meterBandStatsBuilder.setPacketBandCount(new BigInteger(packetBandCount));
+                byte[] byteBandCount = new byte[Long.SIZE/Byte.SIZE];
+                input.readBytes(byteBandCount);
+                meterBandStatsBuilder.setByteBandCount(new BigInteger(byteBandCount));
+                meterBandStatsList.add(meterBandStatsBuilder.build());
+                actualLength += METER_BAND_STATS_LENGTH;
+            }
+            meterStatsBuilder.setMeterBandStats(meterBandStatsList);
+            meterStatsList.add(meterStatsBuilder.build());
+        }
+        builder.setMeterStats(meterStatsList);
+        return builder.build();
+    }
+    
+    private static MultipartReplyMeterConfig setMeterConfig(ByteBuf input) {
+        MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder();
+        List<MeterConfig> meterConfigList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();
+            int meterConfigBodyLength = input.readUnsignedShort();
+            meterConfigBuilder.setFlags(createMeterFlags(input.readUnsignedShort()));
+            meterConfigBuilder.setMeterId(new MeterId(input.readUnsignedInt()));
+            int actualLength = METER_CONFIG_LENGTH;
+            List<Bands> bandsList = new ArrayList<>();
+            while (actualLength < meterConfigBodyLength) {
+                BandsBuilder bandsBuilder = new BandsBuilder();
+                int bandType = input.readUnsignedShort();
+                switch (bandType) {
+                    case 1:
+                        MeterBandDropBuilder bandDropBuilder = new MeterBandDropBuilder();
+                        bandDropBuilder.setType(MeterBandType.forValue(bandType));
+                        actualLength += input.readUnsignedShort();
+                        bandDropBuilder.setRate(input.readUnsignedInt());
+                        bandDropBuilder.setBurstSize(input.readUnsignedInt());
+                        input.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
+                        bandsBuilder.setMeterBand(bandDropBuilder.build());
+                        break;
+                    case 2:
+                        MeterBandDscpRemarkBuilder bandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder();
+                        bandDscpRemarkBuilder.setType(MeterBandType.forValue(bandType));
+                        actualLength += input.readUnsignedShort();
+                        bandDscpRemarkBuilder.setRate(input.readUnsignedInt());
+                        bandDscpRemarkBuilder.setBurstSize(input.readUnsignedInt());
+                        bandDscpRemarkBuilder.setPrecLevel(input.readUnsignedByte());
+                        input.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
+                        bandsBuilder.setMeterBand(bandDscpRemarkBuilder.build());
+                        break;
+                    case 0xFFFF:
+                        MeterBandExperimenterBuilder bandExperimenterBuilder = new MeterBandExperimenterBuilder();
+                        bandExperimenterBuilder.setType(MeterBandType.forValue(bandType));
+                        actualLength += input.readUnsignedShort();
+                        bandExperimenterBuilder.setRate(input.readUnsignedInt());
+                        bandExperimenterBuilder.setBurstSize(input.readUnsignedInt());
+                        bandExperimenterBuilder.setExperimenter(input.readUnsignedInt());
+                        bandsBuilder.setMeterBand(bandExperimenterBuilder.build());
+                        break;
+                    default:
+                        break;
+                }
+                bandsList.add(bandsBuilder.build());
+            }
+            meterConfigBuilder.setBands(bandsList);
+            meterConfigList.add(meterConfigBuilder.build());
+        }
+        builder.setMeterConfig(meterConfigList);
+        return builder.build();
+    }
+    
+    private static MultipartReplyExperimenter setExperimenter(ByteBuf input) {
+        MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder();
+        builder.setExperimenter(input.readUnsignedInt());
+        builder.setExpType(input.readUnsignedInt());
+        byte[] data = new byte[input.readableBytes()];
+        input.readBytes(data);
+        builder.setData(data);
+        return builder.build();
+    }
+    
+    private static MultipartReplyPortDesc setPortDesc(ByteBuf input) {
+        MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
+        List<Ports> portsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            PortsBuilder portsBuilder = new PortsBuilder();
+            portsBuilder.setPortNo(input.readUnsignedInt());
+            input.skipBytes(PADDING_IN_PORT_DESC_HEADER_01);
+            byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
+            input.readBytes(hwAddress);
+            portsBuilder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(hwAddress)));
+            input.skipBytes(PADDING_IN_PORT_DESC_HEADER_02);
+            byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN];
+            input.readBytes(portNameBytes);
+            String portName = new String(portNameBytes);
+            portsBuilder.setName(portName.trim());
+            portsBuilder.setConfig(createPortConfig(input.readUnsignedInt()));
+            portsBuilder.setState(createPortState(input.readUnsignedInt()));
+            portsBuilder.setCurrentFeatures(createPortFeatures(input.readUnsignedInt()));
+            portsBuilder.setAdvertisedFeatures(createPortFeatures(input.readUnsignedInt()));
+            portsBuilder.setSupportedFeatures(createPortFeatures(input.readUnsignedInt()));
+            portsBuilder.setPeerFeatures(createPortFeatures(input.readUnsignedInt()));
+            portsBuilder.setCurrSpeed(input.readUnsignedInt());
+            portsBuilder.setMaxSpeed(input.readUnsignedInt());
+            portsList.add(portsBuilder.build());
+        }
+        builder.setPorts(portsList);
+        return builder.build();
+    }
+    
+    private static PortConfig createPortConfig(long input){
+        final Boolean _portDown   = ((input) & (1<<0)) != 0;
+        final Boolean _noRecv    = ((input) & (1<<2)) != 0;
+        final Boolean _noFwd       = ((input) & (1<<5)) != 0;
+        final Boolean _noPacketIn = ((input) & (1<<6)) != 0;
+        return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);
+    }
+    
+    private static PortState createPortState(long input){
+        final Boolean _linkDown = ((input) & (1<<0)) != 0;
+        final Boolean _blocked  = ((input) & (1<<1)) != 0;
+        final Boolean _live     = ((input) & (1<<2)) != 0;
+        return new PortState(_blocked, _linkDown, _live);
+    }
+    
+    private static PortFeatures createPortFeatures(long input){
+        final Boolean _10mbHd = ((input) & (1<<0)) != 0;
+        final Boolean _10mbFd = ((input) & (1<<1)) != 0;
+        final Boolean _100mbHd = ((input) & (1<<2)) != 0;
+        final Boolean _100mbFd = ((input) & (1<<3)) != 0;
+        final Boolean _1gbHd = ((input) & (1<<4)) != 0;
+        final Boolean _1gbFd = ((input) & (1<<5)) != 0;
+        final Boolean _10gbFd = ((input) & (1<<6)) != 0;
+        final Boolean _40gbFd = ((input) & (1<<7)) != 0;
+        final Boolean _100gbFd = ((input) & (1<<8)) != 0;
+        final Boolean _1tbFd = ((input) & (1<<9)) != 0;
+        final Boolean _other = ((input) & (1<<10)) != 0;
+        final Boolean _copper = ((input) & (1<<11)) != 0;
+        final Boolean _fiber = ((input) & (1<<12)) != 0;
+        final Boolean _autoneg = ((input) & (1<<13)) != 0;
+        final Boolean _pause = ((input) & (1<<14)) != 0;
+        final Boolean _pauseAsym = ((input) & (1<<15)) != 0;
+        return new PortFeatures(_10mbHd, _10mbFd, _100mbHd, _100mbFd, _1gbHd, _1gbFd, _10gbFd,
+                _40gbFd, _100gbFd, _1tbFd, _other, _copper, _fiber, _autoneg, _pause, _pauseAsym);
+    }
+    
+    private static MultipartReplyBody setGroupFeatures(ByteBuf rawMessage) {
+        MultipartReplyGroupFeaturesBuilder featuresBuilder = new MultipartReplyGroupFeaturesBuilder();
+        featuresBuilder.setTypes(createGroupType(rawMessage.readUnsignedInt()));
+        featuresBuilder.setCapabilities(createCapabilities(rawMessage.readUnsignedInt()));
+        List<Long> maxGroupsList = new ArrayList<>();
+        for (int i = 0; i < GROUP_TYPES ; i++) {
+            maxGroupsList.add(rawMessage.readUnsignedInt());
+        }
+        featuresBuilder.setMaxGroups(maxGroupsList);
+        List<ActionType> actionBitmaps = new ArrayList<>();
+        for (int i = 0; i < GROUP_TYPES ; i++) {
+            actionBitmaps.add(createActionBitmap(rawMessage.readUnsignedInt()));
+        }
+        featuresBuilder.setActionsBitmap(actionBitmaps);
+        return featuresBuilder.build();
+    }
+    
+    private static ActionType createActionBitmap(long input) {
+        final Boolean OFPAT_OUTPUT = ((input) & (1<<0)) != 0;
+        final Boolean OFPAT_COPY_TTL_OUT = ((input) & (1<<1)) != 0;
+        final Boolean OFPAT_COPY_TTL_IN = ((input) & (1<<2)) != 0;
+        final Boolean OFPAT_SET_MPLS_TTL = ((input) & (1<<3)) != 0;
+        final Boolean OFPAT_DEC_MPLS_TTL = ((input) & (1<<4)) != 0;
+        final Boolean OFPAT_PUSH_VLAN = ((input) & (1<<5)) != 0;
+        final Boolean OFPAT_POP_VLAN = ((input) & (1<<6)) != 0;
+        final Boolean OFPAT_PUSH_MPLS = ((input) & (1<<7)) != 0;
+        final Boolean OFPAT_POP_MPLS = ((input) & (1<<8)) != 0;
+        final Boolean OFPAT_SET_QUEUE = ((input) & (1<<9)) != 0;
+        final Boolean OFPAT_GROUP = ((input) & (1<<10)) != 0;
+        final Boolean OFPAT_SET_NW_TTL = ((input) & (1<<11)) != 0;
+        final Boolean OFPAT_DEC_NW_TTL = ((input) & (1<<12)) != 0;
+        final Boolean OFPAT_SET_FIELD = ((input) & (1<<13)) != 0;
+        final Boolean OFPAT_PUSH_PBB = ((input) & (1<<14)) != 0;
+        final Boolean OFPAT_POP_PBB = ((input) & (1<<15)) != 0;
+        final Boolean OFPAT_EXPERIMENTER = ((input) & (1<<16)) != 0;
+        return new ActionType(OFPAT_COPY_TTL_IN, OFPAT_COPY_TTL_OUT, OFPAT_DEC_MPLS_TTL,
+                OFPAT_DEC_NW_TTL, OFPAT_EXPERIMENTER, OFPAT_GROUP, OFPAT_OUTPUT, OFPAT_POP_MPLS,
+                OFPAT_POP_PBB, OFPAT_POP_VLAN, OFPAT_PUSH_MPLS, OFPAT_PUSH_PBB, OFPAT_PUSH_VLAN,
+                OFPAT_SET_FIELD, OFPAT_SET_MPLS_TTL, OFPAT_SET_NW_TTL, OFPAT_SET_QUEUE);
+    }
+
+    private static GroupCapabilities createCapabilities(long input) {
+        final Boolean OFOFPGFC_SELECT_WEIGHT = ((input) & (1<<0)) != 0;
+        final Boolean OFPGFC_SELECT_LIVENESS = ((input) & (1<<1)) != 0;
+        final Boolean OFPGFC_CHAINING = ((input) & (1<<2)) != 0;
+        final Boolean OFPGFC_CHAINING_CHECKS = ((input) & (1<<3)) != 0;
+        return new GroupCapabilities(OFPGFC_CHAINING, OFPGFC_CHAINING_CHECKS, OFPGFC_SELECT_LIVENESS, OFOFPGFC_SELECT_WEIGHT);
+    }
+
+    private static GroupTypes createGroupType(long input) {
+        final Boolean OFPGT_ALL = ((input) & (1<<0)) != 0;
+        final Boolean OFPGT_SELECT = ((input) & (1<<1)) != 0;
+        final Boolean OFPGT_INDIRECT = ((input) & (1<<2)) != 0;
+        final Boolean OFPGT_FF = ((input) & (1<<3)) != 0;
+        return new GroupTypes(OFPGT_ALL, OFPGT_FF, OFPGT_INDIRECT, OFPGT_SELECT);
+    }
+    
+    private static MultipartReplyGroupDesc setGroupDesc(ByteBuf input) {
+        MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
+        List<GroupDesc> groupDescsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            GroupDescBuilder groupDescBuilder = new GroupDescBuilder();
+            int bodyLength = input.readUnsignedShort();
+            groupDescBuilder.setType(GroupType.forValue(input.readUnsignedByte()));
+            input.skipBytes(PADDING_IN_GROUP_DESC_HEADER);
+            groupDescBuilder.setGroupId(new GroupId(input.readUnsignedInt()));
+            int actualLength = GROUP_DESC_HEADER_LENGTH;
+            List<BucketsList> bucketsList = new ArrayList<>();
+            while (actualLength < bodyLength) {
+                BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
+                int bucketsLength = input.readUnsignedShort();
+                bucketsBuilder.setWeight(input.readUnsignedShort());
+                bucketsBuilder.setWatchPort(new PortNumber(input.readUnsignedInt()));
+                bucketsBuilder.setWatchGroup(input.readUnsignedInt());
+                input.skipBytes(PADDING_IN_BUCKETS_HEADER);
+                List<ActionsList> actionsList = ActionsDeserializer
+                        .createActionsList(input, bucketsLength - BUCKETS_HEADER_LENGTH);
+                bucketsBuilder.setActionsList(actionsList);
+                bucketsList.add(bucketsBuilder.build());
+                actualLength += bucketsLength;
+            }
+            groupDescBuilder.setBucketsList(bucketsList);
+            groupDescsList.add(groupDescBuilder.build());
+        }
+        builder.setGroupDesc(groupDescsList);
+        return builder.build();
+    }
+    
+}
index e9e37284e9c66c16cadc05e5230280b06411aace..5d3f874f1c5614c37589c584a5c648148dee5e33 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCodeV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadRequestCodeV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorTypeV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFailedCodeV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloFailedCodeV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortModFailedCodeV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueOpFailedCodeV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;\r
-\r
-/**\r
- * Translates Error messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10ErrorMessageFactory implements OFDeserializer<ErrorMessage> {\r
-\r
-       private static final String UNKNOWN_TYPE = "UNKNOWN_TYPE";\r
-    private static final String UNKNOWN_CODE = "UNKNOWN_CODE";\r
-    \r
-    private static OF10ErrorMessageFactory instance;\r
-    \r
-    private OF10ErrorMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10ErrorMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10ErrorMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public ErrorMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        ErrorMessageBuilder builder = new ErrorMessageBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        int type = rawMessage.readUnsignedShort();\r
-        ErrorTypeV10 errorType = ErrorTypeV10.forValue(type);\r
-        decodeType(builder, errorType, type);\r
-        decodeCode(rawMessage, builder, errorType);\r
-        if (rawMessage.readableBytes() > 0) {\r
-            builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());\r
-        }\r
-        return builder.build();\r
-    }\r
-    \r
-    private static void decodeType(ErrorMessageBuilder builder, ErrorTypeV10 type, int readValue) {\r
-        if (type != null) {\r
-            builder.setType(type.getIntValue());\r
-            builder.setTypeString(type.name());\r
-        } else {\r
-            builder.setType(readValue);\r
-            builder.setTypeString(UNKNOWN_TYPE);\r
-        }\r
-    }\r
-\r
-    private static void decodeCode(ByteBuf rawMessage, ErrorMessageBuilder builder,\r
-            ErrorTypeV10 type) {\r
-        int code = rawMessage.readUnsignedShort();\r
-       if (type != null) {\r
-               switch (type) {\r
-               case HELLOFAILED:\r
-               {\r
-                       HelloFailedCodeV10 errorCode = HelloFailedCodeV10.forValue(code);\r
-                       if (errorCode != null) {\r
-                               setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                       } else {\r
-                               setUnknownCode(builder, code);\r
-                       }\r
-                       break;\r
-               }\r
-               case BADREQUEST:\r
-               {\r
-                       BadRequestCodeV10 errorCode = BadRequestCodeV10.forValue(code);\r
-                       if (errorCode != null) {\r
-                               setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                       } else {\r
-                               setUnknownCode(builder, code);\r
-                       }\r
-                       break;\r
-               }\r
-               case BADACTION:\r
-               {\r
-                       BadActionCodeV10 errorCode = BadActionCodeV10.forValue(code);\r
-                       if (errorCode != null) {\r
-                               setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                       } else {\r
-                               setUnknownCode(builder, code);\r
-                       }\r
-                       break;\r
-               }\r
-               case FLOWMODFAILED:\r
-               {\r
-                       FlowModFailedCodeV10 errorCode = FlowModFailedCodeV10.forValue(code);\r
-                       if (errorCode != null) {\r
-                               setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                       } else {\r
-                               setUnknownCode(builder, code);\r
-                       }\r
-                       break;\r
-               }\r
-               case PORTMODFAILED:\r
-               {\r
-                       PortModFailedCodeV10 errorCode = PortModFailedCodeV10.forValue(code);\r
-                       if (errorCode != null) {\r
-                               setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                       } else {\r
-                               setUnknownCode(builder, code);\r
-                       }\r
-                       break;\r
-               }\r
-               case QUEUEOPFAILED:\r
-               {\r
-                       QueueOpFailedCodeV10 errorCode = QueueOpFailedCodeV10.forValue(code);\r
-                       if (errorCode != null) {\r
-                               setCode(builder, errorCode.getIntValue(), errorCode.name());\r
-                       } else {\r
-                               setUnknownCode(builder, code);\r
-                       }\r
-                       break;\r
-               }\r
-               default:\r
-                       setUnknownCode(builder, code);\r
-                       break;\r
-               }\r
-       } else {\r
-               setUnknownCode(builder, code);\r
-       }\r
-    }\r
-    \r
-    private static void setUnknownCode(ErrorMessageBuilder builder, int readValue) {\r
-       builder.setCode(readValue);\r
-               builder.setCodeString(UNKNOWN_CODE);\r
-    }\r
-    \r
-    private static void setCode(ErrorMessageBuilder builder, int code, String codeString) {\r
-       builder.setCode(code);\r
-               builder.setCodeString(codeString);\r
-    }\r
-\r
-}\r
+/*
+ * 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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFailedCodeV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloFailedCodeV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortModFailedCodeV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueOpFailedCodeV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;
+
+/**
+ * Translates Error messages (OpenFlow v1.0)
+ * @author michal.polkorab
+ */
+public class OF10ErrorMessageFactory implements OFDeserializer<ErrorMessage> {
+
+       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) {
+        ErrorMessageBuilder builder = new ErrorMessageBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        int type = rawMessage.readUnsignedShort();
+        ErrorTypeV10 errorType = ErrorTypeV10.forValue(type);
+        decodeType(builder, errorType, type);
+        decodeCode(rawMessage, builder, errorType);
+        if (rawMessage.readableBytes() > 0) {
+            builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
+        }
+        return builder.build();
+    }
+    
+    private static void decodeType(ErrorMessageBuilder builder, ErrorTypeV10 type, int readValue) {
+        if (type != null) {
+            builder.setType(type.getIntValue());
+            builder.setTypeString(type.name());
+        } else {
+            builder.setType(readValue);
+            builder.setTypeString(UNKNOWN_TYPE);
+        }
+    }
+
+    private static void decodeCode(ByteBuf rawMessage, ErrorMessageBuilder builder,
+            ErrorTypeV10 type) {
+        int code = rawMessage.readUnsignedShort();
+       if (type != null) {
+               switch (type) {
+               case HELLOFAILED:
+               {
+                       HelloFailedCodeV10 errorCode = HelloFailedCodeV10.forValue(code);
+                       if (errorCode != null) {
+                               setCode(builder, errorCode.getIntValue(), errorCode.name());
+                       } else {
+                               setUnknownCode(builder, code);
+                       }
+                       break;
+               }
+               case BADREQUEST:
+               {
+                       BadRequestCodeV10 errorCode = BadRequestCodeV10.forValue(code);
+                       if (errorCode != null) {
+                               setCode(builder, errorCode.getIntValue(), errorCode.name());
+                       } else {
+                               setUnknownCode(builder, code);
+                       }
+                       break;
+               }
+               case BADACTION:
+               {
+                       BadActionCodeV10 errorCode = BadActionCodeV10.forValue(code);
+                       if (errorCode != null) {
+                               setCode(builder, errorCode.getIntValue(), errorCode.name());
+                       } else {
+                               setUnknownCode(builder, code);
+                       }
+                       break;
+               }
+               case FLOWMODFAILED:
+               {
+                       FlowModFailedCodeV10 errorCode = FlowModFailedCodeV10.forValue(code);
+                       if (errorCode != null) {
+                               setCode(builder, errorCode.getIntValue(), errorCode.name());
+                       } else {
+                               setUnknownCode(builder, code);
+                       }
+                       break;
+               }
+               case PORTMODFAILED:
+               {
+                       PortModFailedCodeV10 errorCode = PortModFailedCodeV10.forValue(code);
+                       if (errorCode != null) {
+                               setCode(builder, errorCode.getIntValue(), errorCode.name());
+                       } else {
+                               setUnknownCode(builder, code);
+                       }
+                       break;
+               }
+               case QUEUEOPFAILED:
+               {
+                       QueueOpFailedCodeV10 errorCode = QueueOpFailedCodeV10.forValue(code);
+                       if (errorCode != null) {
+                               setCode(builder, errorCode.getIntValue(), errorCode.name());
+                       } else {
+                               setUnknownCode(builder, code);
+                       }
+                       break;
+               }
+               default:
+                       setUnknownCode(builder, code);
+                       break;
+               }
+       } else {
+               setUnknownCode(builder, code);
+       }
+    }
+    
+    private static void setUnknownCode(ErrorMessageBuilder builder, int readValue) {
+       builder.setCode(readValue);
+               builder.setCodeString(UNKNOWN_CODE);
+    }
+    
+    private static void setCode(ErrorMessageBuilder builder, int code, String codeString) {
+       builder.setCode(code);
+               builder.setCodeString(codeString);
+    }
+
+}
index 7c6dc262a265e53466724d7d9eace891f7ff7432..6c5117830172e00e1ba20053eef0f96e96a715b1 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.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.common.types.rev130731.ActionTypeV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;\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.GetFeaturesOutputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder;\r
-\r
-/**\r
- * Translates FeaturesReply messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10FeaturesReplyMessageFactory implements OFDeserializer<GetFeaturesOutput> {\r
-    \r
-    private static final byte PADDING_IN_FEATURES_REPLY_HEADER = 3;\r
-    \r
-    private static OF10FeaturesReplyMessageFactory instance;\r
-\r
-    private OF10FeaturesReplyMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10FeaturesReplyMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10FeaturesReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public GetFeaturesOutput bufferToMessage(ByteBuf rawMessage, short version) {\r
-        GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        byte[] datapathId = new byte[Long.SIZE/Byte.SIZE];\r
-        rawMessage.readBytes(datapathId);\r
-        builder.setDatapathId(new BigInteger(datapathId));\r
-        builder.setBuffers(rawMessage.readUnsignedInt());\r
-        builder.setTables(rawMessage.readUnsignedByte());\r
-        rawMessage.skipBytes(PADDING_IN_FEATURES_REPLY_HEADER);\r
-        builder.setCapabilitiesV10(createCapabilitiesV10(rawMessage.readUnsignedInt()));\r
-        builder.setActionsV10(createActionsV10(rawMessage.readUnsignedInt()));\r
-        List<PhyPort> ports = new ArrayList<>();\r
-        while (rawMessage.readableBytes() > 0) {\r
-            ports.add(deserializePort(rawMessage));\r
-        }\r
-        builder.setPhyPort(ports);\r
-        return builder.build();\r
-    }\r
-\r
-    private static CapabilitiesV10 createCapabilitiesV10(long input) {\r
-        final Boolean FLOW_STATS = (input & (1 << 0)) != 0;\r
-        final Boolean TABLE_STATS = (input & (1 << 1)) != 0;\r
-        final Boolean PORT_STATS = (input & (1 << 2)) != 0;\r
-        final Boolean STP = (input & (1 << 3)) != 0;\r
-        final Boolean RESERVED = (input & (1 << 4)) != 0;\r
-        final Boolean IP_REASM = (input & (1 << 5)) != 0;\r
-        final Boolean QUEUE_STATS = (input & (1 << 6)) != 0;\r
-        final Boolean ARP_MATCH_IP = (input & (1 << 7)) != 0;\r
-        return new CapabilitiesV10(ARP_MATCH_IP, FLOW_STATS, IP_REASM,\r
-                PORT_STATS, QUEUE_STATS, RESERVED, STP, TABLE_STATS);\r
-    }\r
-    \r
-    private static ActionTypeV10 createActionsV10(long input) {\r
-        final Boolean OUTPUT = (input & (1 << 0)) != 0;\r
-        final Boolean SET_VLAN_VID = (input & (1 << 1)) != 0;\r
-        final Boolean SET_VLAN_PCP = (input & (1 << 2)) != 0;\r
-        final Boolean STRIP_VLAN = (input & (1 << 3)) != 0;\r
-        final Boolean SET_DL_SRC = (input & (1 << 4)) != 0;\r
-        final Boolean SET_DL_DST = (input & (1 << 5)) != 0;\r
-        final Boolean SET_NW_SRC = (input & (1 << 6)) != 0;\r
-        final Boolean SET_NW_DST = (input & (1 << 7)) != 0;\r
-        final Boolean SET_NW_TOS = (input & (1 << 8)) != 0;\r
-        final Boolean SET_TP_SRC = (input & (1 << 9)) != 0;\r
-        final Boolean SET_TP_DST = (input & (1 << 10)) != 0;\r
-        final Boolean ENQUEUE = (input & (1 << 11)) != 0;\r
-        final Boolean VENDOR = (input & (1 << 12)) != 0;\r
-        return new ActionTypeV10(ENQUEUE, OUTPUT, SET_DL_DST, SET_DL_SRC,\r
-                SET_NW_DST, SET_NW_SRC, SET_NW_TOS, SET_TP_DST, SET_TP_SRC,\r
-                SET_VLAN_PCP, SET_VLAN_VID, STRIP_VLAN, VENDOR);\r
-    }\r
-    \r
-    private static PhyPort deserializePort(ByteBuf rawMessage) {\r
-        PhyPortBuilder builder = new PhyPortBuilder();\r
-        builder.setPortNo((long) rawMessage.readUnsignedShort());\r
-        byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];\r
-        rawMessage.readBytes(address);\r
-        builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(address)));\r
-        builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH));\r
-        builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt()));\r
-        builder.setStateV10(createPortState(rawMessage.readUnsignedInt()));\r
-        builder.setCurrentFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));\r
-        builder.setAdvertisedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));\r
-        builder.setSupportedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));\r
-        builder.setPeerFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));\r
-        return builder.build();\r
-    }\r
-\r
-    \r
-    \r
-    private static PortStateV10 createPortState(long input){\r
-        final Boolean _linkDown = ((input) & (1<<0)) != 0;\r
-        final Boolean _blocked = ((input) & (1<<1)) != 0;\r
-        final Boolean _live = ((input) & (1<<2)) != 0;\r
-        final Boolean _stpListen = ((input) & (0<<8)) != 0;\r
-        final Boolean _stpLearn = ((input) & (1<<8)) != 0;\r
-        final Boolean _stpForward = ((input) & (1<<9)) != 0; // equals 2 << 8\r
-        final Boolean _stpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8\r
-        final Boolean _stpMask = ((input) & (1<<10)) != 0; // equals 4 << 8\r
-        return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask);\r
-    }\r
-    \r
-    private static PortConfigV10 createPortConfig(long input){\r
-        final Boolean _portDown = ((input) & (1<<0)) != 0;\r
-        final Boolean _noStp = ((input) & (1<<1)) != 0;\r
-        final Boolean _noRecv = ((input) & (1<<2)) != 0;\r
-        final Boolean _noRecvStp = ((input) & (1<<3)) != 0;\r
-        final Boolean _noFlood = ((input) & (1<<4)) != 0;\r
-        final Boolean _noFwd  = ((input) & (1<<5)) != 0;\r
-        final Boolean _noPacketIn = ((input) & (1<<6)) != 0;\r
-        return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown);\r
-    }\r
-    \r
-    private static PortFeaturesV10 createPortFeatures(long input){\r
-        final Boolean _10mbHd = ((input) & (1<<0)) != 0;\r
-        final Boolean _10mbFd = ((input) & (1<<1)) != 0;\r
-        final Boolean _100mbHd = ((input) & (1<<2)) != 0;\r
-        final Boolean _100mbFd = ((input) & (1<<3)) != 0;\r
-        final Boolean _1gbHd = ((input) & (1<<4)) != 0;\r
-        final Boolean _1gbFd = ((input) & (1<<5)) != 0;\r
-        final Boolean _10gbFd = ((input) & (1<<6)) != 0;\r
-        final Boolean _copper = ((input) & (1<<7)) != 0;\r
-        final Boolean _fiber = ((input) & (1<<8)) != 0;\r
-        final Boolean _autoneg = ((input) & (1<<9)) != 0;\r
-        final Boolean _pause = ((input) & (1<<10)) != 0;\r
-        final Boolean _pauseAsym = ((input) & (1<<11)) != 0;\r
-        return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd,\r
-                _1gbFd, _1gbHd, _autoneg, _copper, _fiber, _pause, _pauseAsym);\r
-    }\r
-    \r
-}\r
+/*
+ * 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 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.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.common.types.rev130731.ActionTypeV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder;
+
+/**
+ * Translates FeaturesReply messages (OpenFlow v1.0)
+ * @author michal.polkorab
+ */
+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) {
+        GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        byte[] datapathId = new byte[Long.SIZE/Byte.SIZE];
+        rawMessage.readBytes(datapathId);
+        builder.setDatapathId(new BigInteger(datapathId));
+        builder.setBuffers(rawMessage.readUnsignedInt());
+        builder.setTables(rawMessage.readUnsignedByte());
+        rawMessage.skipBytes(PADDING_IN_FEATURES_REPLY_HEADER);
+        builder.setCapabilitiesV10(createCapabilitiesV10(rawMessage.readUnsignedInt()));
+        builder.setActionsV10(createActionsV10(rawMessage.readUnsignedInt()));
+        List<PhyPort> ports = new ArrayList<>();
+        while (rawMessage.readableBytes() > 0) {
+            ports.add(deserializePort(rawMessage));
+        }
+        builder.setPhyPort(ports);
+        return builder.build();
+    }
+
+    private static CapabilitiesV10 createCapabilitiesV10(long input) {
+        final Boolean FLOW_STATS = (input & (1 << 0)) != 0;
+        final Boolean TABLE_STATS = (input & (1 << 1)) != 0;
+        final Boolean PORT_STATS = (input & (1 << 2)) != 0;
+        final Boolean STP = (input & (1 << 3)) != 0;
+        final Boolean RESERVED = (input & (1 << 4)) != 0;
+        final Boolean IP_REASM = (input & (1 << 5)) != 0;
+        final Boolean QUEUE_STATS = (input & (1 << 6)) != 0;
+        final Boolean ARP_MATCH_IP = (input & (1 << 7)) != 0;
+        return new CapabilitiesV10(ARP_MATCH_IP, FLOW_STATS, IP_REASM,
+                PORT_STATS, QUEUE_STATS, RESERVED, STP, TABLE_STATS);
+    }
+    
+    private static ActionTypeV10 createActionsV10(long input) {
+        final Boolean OUTPUT = (input & (1 << 0)) != 0;
+        final Boolean SET_VLAN_VID = (input & (1 << 1)) != 0;
+        final Boolean SET_VLAN_PCP = (input & (1 << 2)) != 0;
+        final Boolean STRIP_VLAN = (input & (1 << 3)) != 0;
+        final Boolean SET_DL_SRC = (input & (1 << 4)) != 0;
+        final Boolean SET_DL_DST = (input & (1 << 5)) != 0;
+        final Boolean SET_NW_SRC = (input & (1 << 6)) != 0;
+        final Boolean SET_NW_DST = (input & (1 << 7)) != 0;
+        final Boolean SET_NW_TOS = (input & (1 << 8)) != 0;
+        final Boolean SET_TP_SRC = (input & (1 << 9)) != 0;
+        final Boolean SET_TP_DST = (input & (1 << 10)) != 0;
+        final Boolean ENQUEUE = (input & (1 << 11)) != 0;
+        final Boolean VENDOR = (input & (1 << 12)) != 0;
+        return new ActionTypeV10(ENQUEUE, OUTPUT, SET_DL_DST, SET_DL_SRC,
+                SET_NW_DST, SET_NW_SRC, SET_NW_TOS, SET_TP_DST, SET_TP_SRC,
+                SET_VLAN_PCP, SET_VLAN_VID, STRIP_VLAN, VENDOR);
+    }
+    
+    private static PhyPort deserializePort(ByteBuf rawMessage) {
+        PhyPortBuilder builder = new PhyPortBuilder();
+        builder.setPortNo((long) rawMessage.readUnsignedShort());
+        byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
+        rawMessage.readBytes(address);
+        builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(address)));
+        builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH));
+        builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt()));
+        builder.setStateV10(createPortState(rawMessage.readUnsignedInt()));
+        builder.setCurrentFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
+        builder.setAdvertisedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
+        builder.setSupportedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
+        builder.setPeerFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
+        return builder.build();
+    }
+
+    
+    
+    private static PortStateV10 createPortState(long input){
+        final Boolean _linkDown = ((input) & (1<<0)) != 0;
+        final Boolean _blocked = ((input) & (1<<1)) != 0;
+        final Boolean _live = ((input) & (1<<2)) != 0;
+        final Boolean _stpListen = ((input) & (0<<8)) != 0;
+        final Boolean _stpLearn = ((input) & (1<<8)) != 0;
+        final Boolean _stpForward = ((input) & (1<<9)) != 0; // equals 2 << 8
+        final Boolean _stpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8
+        final Boolean _stpMask = ((input) & (1<<10)) != 0; // equals 4 << 8
+        return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask);
+    }
+    
+    private static PortConfigV10 createPortConfig(long input){
+        final Boolean _portDown = ((input) & (1<<0)) != 0;
+        final Boolean _noStp = ((input) & (1<<1)) != 0;
+        final Boolean _noRecv = ((input) & (1<<2)) != 0;
+        final Boolean _noRecvStp = ((input) & (1<<3)) != 0;
+        final Boolean _noFlood = ((input) & (1<<4)) != 0;
+        final Boolean _noFwd  = ((input) & (1<<5)) != 0;
+        final Boolean _noPacketIn = ((input) & (1<<6)) != 0;
+        return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown);
+    }
+    
+    private static PortFeaturesV10 createPortFeatures(long input){
+        final Boolean _10mbHd = ((input) & (1<<0)) != 0;
+        final Boolean _10mbFd = ((input) & (1<<1)) != 0;
+        final Boolean _100mbHd = ((input) & (1<<2)) != 0;
+        final Boolean _100mbFd = ((input) & (1<<3)) != 0;
+        final Boolean _1gbHd = ((input) & (1<<4)) != 0;
+        final Boolean _1gbFd = ((input) & (1<<5)) != 0;
+        final Boolean _10gbFd = ((input) & (1<<6)) != 0;
+        final Boolean _copper = ((input) & (1<<7)) != 0;
+        final Boolean _fiber = ((input) & (1<<8)) != 0;
+        final Boolean _autoneg = ((input) & (1<<9)) != 0;
+        final Boolean _pause = ((input) & (1<<10)) != 0;
+        final Boolean _pauseAsym = ((input) & (1<<11)) != 0;
+        return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd,
+                _1gbFd, _1gbHd, _autoneg, _copper, _fiber, _pause, _pauseAsym);
+    }
+    
+}
index b25b993a98e475432dbdae30e3268c5ba0ef58d8..76ac6e1d02b6eaf9299878ffca51bde876dc8796 100644 (file)
@@ -1,66 +1,73 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.math.BigInteger;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;\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.FlowRemovedMessageBuilder;\r
-\r
-/**\r
- * Translates FlowRemoved messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage> {\r
-\r
-    private static final byte PADDING_IN_FLOW_REMOVED_MESSAGE = 1;\r
-    private static final byte PADDING_IN_FLOW_REMOVED_MESSAGE_2 = 2;\r
-    \r
-    \r
-    private static OF10FlowRemovedMessageFactory instance;\r
-    \r
-    private OF10FlowRemovedMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10FlowRemovedMessageFactory getInstance(){\r
-        if(instance == null){\r
-            instance = new OF10FlowRemovedMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public FlowRemovedMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        builder.setMatchV10(OF10MatchDeserializer.createMatchV10(rawMessage));\r
-        byte[] cookie = new byte[Long.SIZE/Byte.SIZE];\r
-        rawMessage.readBytes(cookie);\r
-        builder.setCookie(new BigInteger(cookie));\r
-        builder.setPriority(rawMessage.readUnsignedShort());\r
-        builder.setReason(FlowRemovedReason.forValue(rawMessage.readUnsignedByte()));\r
-        rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE);\r
-        builder.setDurationSec(rawMessage.readUnsignedInt());\r
-        builder.setDurationNsec(rawMessage.readUnsignedInt());\r
-        builder.setIdleTimeout(rawMessage.readUnsignedShort());\r
-        rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE_2);\r
-        byte[] packet_count = new byte[Long.SIZE/Byte.SIZE];\r
-        rawMessage.readBytes(packet_count);\r
-        builder.setPacketCount(new BigInteger(packet_count));\r
-        byte[] byte_count = new byte[Long.SIZE/Byte.SIZE];\r
-        rawMessage.readBytes(byte_count);\r
-        builder.setByteCount(new BigInteger(byte_count));\r
-        return builder.build();\r
-    }\r
-\r
-    \r
-}\r
+/*
+ * 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 java.math.BigInteger;
+
+import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+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.protocol.rev130731.FlowRemovedMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
+
+/**
+ * Translates FlowRemoved messages (OpenFlow v1.0)
+ * @author michal.polkorab
+ */
+public class OF10FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage> {
+
+    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;
+    }
+
+    @Override
+    public FlowRemovedMessage bufferToMessage(ByteBuf rawMessage, short version) {
+        FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setMatchV10(OF10MatchDeserializer.createMatchV10(rawMessage));
+        byte[] cookie = new byte[Long.SIZE/Byte.SIZE];
+        rawMessage.readBytes(cookie);
+        builder.setCookie(new BigInteger(cookie));
+        builder.setPriority(rawMessage.readUnsignedShort());
+        builder.setReason(FlowRemovedReason.forValue(rawMessage.readUnsignedByte()));
+        rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE);
+        builder.setDurationSec(rawMessage.readUnsignedInt());
+        builder.setDurationNsec(rawMessage.readUnsignedInt());
+        builder.setIdleTimeout(rawMessage.readUnsignedShort());
+        rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE_2);
+        byte[] packet_count = new byte[Long.SIZE/Byte.SIZE];
+        rawMessage.readBytes(packet_count);
+        builder.setPacketCount(new BigInteger(packet_count));
+        byte[] byte_count = new byte[Long.SIZE/Byte.SIZE];
+        rawMessage.readBytes(byte_count);
+        builder.setByteCount(new BigInteger(byte_count));
+        return builder.build();
+    }
+
+    
+}
index 0301b80335bdb786bef3f1dd41a86d331d589bec..cefb7f1a9ebbeded0a5d51c1c2a8ea37b59ccef8 100644 (file)
@@ -1,43 +1,50 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder;\r
-\r
-/**\r
- * Translates Hello messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10HelloMessageFactory implements OFDeserializer<HelloMessage> {\r
-    \r
-private static OF10HelloMessageFactory instance;\r
-    \r
-    private OF10HelloMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10HelloMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10HelloMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public HelloMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        HelloMessageBuilder builder = new HelloMessageBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        if (rawMessage.readableBytes() > 0) {\r
-            rawMessage.skipBytes(rawMessage.readableBytes());\r
-        }\r
-        return builder.build();\r
-    }\r
-\r
-}\r
+/*
+ * 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.HelloMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder;
+
+/**
+ * Translates Hello messages (OpenFlow v1.0)
+ * @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) {
+        HelloMessageBuilder builder = new HelloMessageBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        if (rawMessage.readableBytes() > 0) {
+            rawMessage.skipBytes(rawMessage.readableBytes());
+        }
+        return builder.build();
+    }
+
+}
index e7d5c6ea7b9ffcdbb4289560a35b06bd9196b23c..814bd502045cf48be689dc52592a6362bf8ba033 100644 (file)
@@ -1,51 +1,58 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;\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.PacketInMessageBuilder;\r
-\r
-/**\r
- * Translates PacketIn messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10PacketInMessageFactory implements OFDeserializer<PacketInMessage> {\r
-\r
-    private static final byte PADDING_IN_PACKET_IN_HEADER = 1;\r
-\r
-    private static OF10PacketInMessageFactory instance;\r
-    \r
-    private OF10PacketInMessageFactory() {\r
-        // Singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10PacketInMessageFactory getInstance(){\r
-        if(instance == null){\r
-            instance = new OF10PacketInMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public PacketInMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        PacketInMessageBuilder builder = new PacketInMessageBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        builder.setBufferId(rawMessage.readUnsignedInt());\r
-        builder.setTotalLen(rawMessage.readUnsignedShort());\r
-        builder.setInPort(rawMessage.readUnsignedShort());\r
-        builder.setReason(PacketInReason.forValue(rawMessage.readUnsignedByte()));\r
-        rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER);\r
-        int remainingBytes = rawMessage.readableBytes();\r
-        if (remainingBytes > 0) {\r
-            builder.setData(rawMessage.readBytes(remainingBytes).array());\r
-        }\r
-        return builder.build();\r
-    }\r
-}\r
+/*
+ * 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.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;
+
+/**
+ * Translates PacketIn messages (OpenFlow v1.0)
+ * @author michal.polkorab
+ */
+public class OF10PacketInMessageFactory implements OFDeserializer<PacketInMessage> {
+
+    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) {
+        PacketInMessageBuilder builder = new PacketInMessageBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setBufferId(rawMessage.readUnsignedInt());
+        builder.setTotalLen(rawMessage.readUnsignedShort());
+        builder.setInPort(rawMessage.readUnsignedShort());
+        builder.setReason(PacketInReason.forValue(rawMessage.readUnsignedByte()));
+        rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER);
+        int remainingBytes = rawMessage.readableBytes();
+        if (remainingBytes > 0) {
+            builder.setData(rawMessage.readBytes(remainingBytes).array());
+        }
+        return builder.build();
+    }
+}
index 9958effc7636786e2bb0fd528e6e428591c22a38..5d6036ad228f9c13ec815b7b20f5ec774ee48cb6 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.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.common.types.rev130731.PortConfigV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;\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.PortStatusMessageBuilder;\r
-\r
-/**\r
- * Translates PortStatus messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10PortStatusMessageFactory implements OFDeserializer<PortStatusMessage> {\r
-\r
-    private static final byte PADDING_IN_PORT_STATUS_HEADER = 7;\r
-\r
-    private static OF10PortStatusMessageFactory instance;\r
-    \r
-    private OF10PortStatusMessageFactory() {\r
-        // Singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10PortStatusMessageFactory getInstance(){\r
-        if(instance == null){\r
-            instance = new OF10PortStatusMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public PortStatusMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        PortStatusMessageBuilder builder = new PortStatusMessageBuilder(); \r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));\r
-        rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);\r
-        deserializePort(rawMessage, builder);\r
-        return builder.build();\r
-    }\r
-\r
-    private static PortStateV10 createPortState(long input){\r
-        final Boolean _linkDown = ((input) & (1<<0)) != 0;\r
-        final Boolean _blocked = ((input) & (1<<1)) != 0;\r
-        final Boolean _live = ((input) & (1<<2)) != 0;\r
-        final Boolean _stpListen = ((input) & (0<<8)) != 0;\r
-        final Boolean _stpLearn = ((input) & (1<<8)) != 0;\r
-        final Boolean _stpForward = ((input) & (1<<9)) != 0; // equals 2 << 8\r
-        final Boolean _stpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8\r
-        final Boolean _stpMask = ((input) & (1<<10)) != 0; // equals 4 << 8\r
-        return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask);\r
-    }\r
-    \r
-    private static PortConfigV10 createPortConfig(long input){\r
-        final Boolean _portDown = ((input) & (1<<0)) != 0;\r
-        final Boolean _noStp = ((input) & (1<<1)) != 0;\r
-        final Boolean _noRecv = ((input) & (1<<2)) != 0;\r
-        final Boolean _noRecvStp = ((input) & (1<<3)) != 0;\r
-        final Boolean _noFlood = ((input) & (1<<4)) != 0;\r
-        final Boolean _noFwd  = ((input) & (1<<5)) != 0;\r
-        final Boolean _noPacketIn = ((input) & (1<<6)) != 0;\r
-        return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown);\r
-    }\r
-    \r
-    private static PortFeaturesV10 createPortFeatures(long input){\r
-        final Boolean _10mbHd = ((input) & (1<<0)) != 0;\r
-        final Boolean _10mbFd = ((input) & (1<<1)) != 0;\r
-        final Boolean _100mbHd = ((input) & (1<<2)) != 0;\r
-        final Boolean _100mbFd = ((input) & (1<<3)) != 0;\r
-        final Boolean _1gbHd = ((input) & (1<<4)) != 0;\r
-        final Boolean _1gbFd = ((input) & (1<<5)) != 0;\r
-        final Boolean _10gbFd = ((input) & (1<<6)) != 0;\r
-        final Boolean _copper = ((input) & (1<<7)) != 0;\r
-        final Boolean _fiber = ((input) & (1<<8)) != 0;\r
-        final Boolean _autoneg = ((input) & (1<<9)) != 0;\r
-        final Boolean _pause = ((input) & (1<<10)) != 0;\r
-        final Boolean _pauseAsym = ((input) & (1<<11)) != 0;\r
-        return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd,\r
-                _1gbFd, _1gbHd, _autoneg, _copper, _fiber, _pause, _pauseAsym);\r
-    }\r
-    \r
-    private static void deserializePort(ByteBuf rawMessage, PortStatusMessageBuilder builder) {\r
-        builder.setPortNo((long) rawMessage.readUnsignedShort());\r
-        byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];\r
-        rawMessage.readBytes(address);\r
-        builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(address)));\r
-        builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH));\r
-        builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt()));\r
-        builder.setStateV10(createPortState(rawMessage.readUnsignedInt()));\r
-        builder.setCurrentFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));\r
-        builder.setAdvertisedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));\r
-        builder.setSupportedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));\r
-        builder.setPeerFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));\r
-    }\r
-}\r
+/*
+ * 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.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.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder;
+
+/**
+ * Translates PortStatus messages (OpenFlow v1.0)
+ * @author michal.polkorab
+ */
+public class OF10PortStatusMessageFactory implements OFDeserializer<PortStatusMessage> {
+
+    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) {
+        PortStatusMessageBuilder builder = new PortStatusMessageBuilder(); 
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
+        rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);
+        deserializePort(rawMessage, builder);
+        return builder.build();
+    }
+
+    private static PortStateV10 createPortState(long input){
+        final Boolean _linkDown = ((input) & (1<<0)) != 0;
+        final Boolean _blocked = ((input) & (1<<1)) != 0;
+        final Boolean _live = ((input) & (1<<2)) != 0;
+        final Boolean _stpListen = ((input) & (0<<8)) != 0;
+        final Boolean _stpLearn = ((input) & (1<<8)) != 0;
+        final Boolean _stpForward = ((input) & (1<<9)) != 0; // equals 2 << 8
+        final Boolean _stpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8
+        final Boolean _stpMask = ((input) & (1<<10)) != 0; // equals 4 << 8
+        return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask);
+    }
+    
+    private static PortConfigV10 createPortConfig(long input){
+        final Boolean _portDown = ((input) & (1<<0)) != 0;
+        final Boolean _noStp = ((input) & (1<<1)) != 0;
+        final Boolean _noRecv = ((input) & (1<<2)) != 0;
+        final Boolean _noRecvStp = ((input) & (1<<3)) != 0;
+        final Boolean _noFlood = ((input) & (1<<4)) != 0;
+        final Boolean _noFwd  = ((input) & (1<<5)) != 0;
+        final Boolean _noPacketIn = ((input) & (1<<6)) != 0;
+        return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown);
+    }
+    
+    private static PortFeaturesV10 createPortFeatures(long input){
+        final Boolean _10mbHd = ((input) & (1<<0)) != 0;
+        final Boolean _10mbFd = ((input) & (1<<1)) != 0;
+        final Boolean _100mbHd = ((input) & (1<<2)) != 0;
+        final Boolean _100mbFd = ((input) & (1<<3)) != 0;
+        final Boolean _1gbHd = ((input) & (1<<4)) != 0;
+        final Boolean _1gbFd = ((input) & (1<<5)) != 0;
+        final Boolean _10gbFd = ((input) & (1<<6)) != 0;
+        final Boolean _copper = ((input) & (1<<7)) != 0;
+        final Boolean _fiber = ((input) & (1<<8)) != 0;
+        final Boolean _autoneg = ((input) & (1<<9)) != 0;
+        final Boolean _pause = ((input) & (1<<10)) != 0;
+        final Boolean _pauseAsym = ((input) & (1<<11)) != 0;
+        return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd,
+                _1gbFd, _1gbHd, _autoneg, _copper, _fiber, _pause, _pauseAsym);
+    }
+    
+    private static void deserializePort(ByteBuf rawMessage, PortStatusMessageBuilder builder) {
+        builder.setPortNo((long) rawMessage.readUnsignedShort());
+        byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
+        rawMessage.readBytes(address);
+        builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(address)));
+        builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH));
+        builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt()));
+        builder.setStateV10(createPortState(rawMessage.readUnsignedInt()));
+        builder.setCurrentFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
+        builder.setAdvertisedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
+        builder.setSupportedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
+        builder.setPeerFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt()));
+    }
+}
index 72943a141117336573a3e94ac8faf118f25f53e2..10e34d8e81fadfad13fbe4d00b1351fde1868a79 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;\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.GetQueueConfigOutputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;\r
-\r
-/**\r
- * Translates QueueGetConfigReply messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10QueueGetConfigReplyMessageFactory implements OFDeserializer<GetQueueConfigOutput> {\r
-\r
-    private static final byte PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER = 6;\r
-    private static final byte PADDING_IN_PACKET_QUEUE_HEADER = 2;\r
-    private static final byte PADDING_IN_QUEUE_PROPERTY_HEADER = 4;\r
-    private static final byte PADDING_IN_RATE_QUEUE_PROPERTY = 6;\r
-    private static final byte PACKET_QUEUE_HEADER_LENGTH = 8;\r
-\r
-    private static OF10QueueGetConfigReplyMessageFactory instance;\r
-    \r
-    private OF10QueueGetConfigReplyMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * \r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10QueueGetConfigReplyMessageFactory getInstance(){\r
-        \r
-        if(instance == null){\r
-            instance = new OF10QueueGetConfigReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public GetQueueConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {\r
-        GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid((rawMessage.readUnsignedInt()));\r
-        builder.setPort(new PortNumber((long) rawMessage.readUnsignedShort()));\r
-        rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER);\r
-        builder.setQueues(createQueuesList(rawMessage));\r
-        return builder.build();\r
-    }\r
-    \r
-    private static List<Queues> createQueuesList(ByteBuf input){\r
-        List<Queues> queuesList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            QueuesBuilder queueBuilder = new QueuesBuilder();\r
-            queueBuilder.setQueueId(new QueueId(input.readUnsignedInt()));\r
-            int length = input.readUnsignedShort();\r
-            input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER);\r
-            queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_HEADER_LENGTH));\r
-            queuesList.add(queueBuilder.build());\r
-        } \r
-        return queuesList;\r
-    }\r
-    \r
-    private static List<QueueProperty> createPropertiesList(ByteBuf input, int length){\r
-        int propertiesLength = length;\r
-        List<QueueProperty> propertiesList = new ArrayList<>();\r
-        while (propertiesLength > 0) {\r
-            QueuePropertyBuilder propertiesBuilder = new QueuePropertyBuilder();\r
-            QueueProperties property = QueueProperties.forValue(input.readUnsignedShort());\r
-            propertiesBuilder.setProperty(property);\r
-            propertiesLength -= input.readUnsignedShort();\r
-            input.skipBytes(PADDING_IN_QUEUE_PROPERTY_HEADER);\r
-            if (property.equals(QueueProperties.OFPQTMINRATE)) {\r
-                RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();\r
-                rateBuilder.setRate(input.readUnsignedShort());\r
-                propertiesBuilder.addAugmentation(RateQueueProperty.class, rateBuilder.build());\r
-                input.skipBytes(PADDING_IN_RATE_QUEUE_PROPERTY);\r
-            }\r
-            propertiesList.add(propertiesBuilder.build());\r
-        }\r
-        return propertiesList;\r
-    }\r
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;
+
+/**
+ * Translates QueueGetConfigReply messages (OpenFlow v1.0)
+ * @author michal.polkorab
+ */
+public class OF10QueueGetConfigReplyMessageFactory implements OFDeserializer<GetQueueConfigOutput> {
+
+    private static final byte PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER = 6;
+    private static final byte PADDING_IN_PACKET_QUEUE_HEADER = 2;
+    private static final byte PADDING_IN_QUEUE_PROPERTY_HEADER = 4;
+    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) {
+        GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
+        builder.setVersion(version);
+        builder.setXid((rawMessage.readUnsignedInt()));
+        builder.setPort(new PortNumber((long) rawMessage.readUnsignedShort()));
+        rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER);
+        builder.setQueues(createQueuesList(rawMessage));
+        return builder.build();
+    }
+    
+    private static List<Queues> createQueuesList(ByteBuf input){
+        List<Queues> queuesList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            QueuesBuilder queueBuilder = new QueuesBuilder();
+            queueBuilder.setQueueId(new QueueId(input.readUnsignedInt()));
+            int length = input.readUnsignedShort();
+            input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER);
+            queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_HEADER_LENGTH));
+            queuesList.add(queueBuilder.build());
+        } 
+        return queuesList;
+    }
+    
+    private static List<QueueProperty> createPropertiesList(ByteBuf input, int length){
+        int propertiesLength = length;
+        List<QueueProperty> propertiesList = new ArrayList<>();
+        while (propertiesLength > 0) {
+            QueuePropertyBuilder propertiesBuilder = new QueuePropertyBuilder();
+            QueueProperties property = QueueProperties.forValue(input.readUnsignedShort());
+            propertiesBuilder.setProperty(property);
+            propertiesLength -= input.readUnsignedShort();
+            input.skipBytes(PADDING_IN_QUEUE_PROPERTY_HEADER);
+            if (property.equals(QueueProperties.OFPQTMINRATE)) {
+                RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();
+                rateBuilder.setRate(input.readUnsignedShort());
+                propertiesBuilder.addAugmentation(RateQueueProperty.class, rateBuilder.build());
+                input.skipBytes(PADDING_IN_RATE_QUEUE_PROPERTY);
+            }
+            propertiesList.add(propertiesBuilder.build());
+        }
+        return propertiesList;
+    }
 } 
\ No newline at end of file
index bbff2e372c463a45af180e723a30ba2f663db48f..b88876564bd7de3ff2bbabdef5690f95006c657d 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsDeserializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregate;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlow;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTable;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow.FlowStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow.FlowStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats.PortStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats.PortStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue.QueueStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue.QueueStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.TableStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.TableStatsBuilder;\r
-\r
-/**\r
- * Translates StatsReply messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartReplyMessage> {\r
-\r
-    private static final int DESC_STR_LEN = 256;\r
-    private static final int SERIAL_NUM_LEN = 32;\r
-    private static final byte PADDING_IN_FLOW_STATS_HEADER = 1;\r
-    private static final byte PADDING_IN_FLOW_STATS_HEADER_02 = 6;\r
-    private static final byte PADDING_IN_AGGREGATE_HEADER = 4;\r
-    private static final byte PADDING_IN_TABLE_HEADER = 3;\r
-    private static final byte MAX_TABLE_NAME_LENGTH = 32;\r
-    private static final byte PADDING_IN_PORT_STATS_HEADER = 6;\r
-    private static final byte PADDING_IN_QUEUE_HEADER = 2;\r
-\r
-    private static OF10StatsReplyMessageFactory instance;\r
-    \r
-    private OF10StatsReplyMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10StatsReplyMessageFactory getInstance() {\r
-        if (instance == null){\r
-            instance = new OF10StatsReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        int type = rawMessage.readUnsignedShort();\r
-        builder.setType(MultipartType.forValue(type));\r
-        builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0));\r
-        switch (type) {\r
-        case 0:  builder.setMultipartReplyBody(setDesc(rawMessage));\r
-            break;\r
-        case 1:  builder.setMultipartReplyBody(setFlow(rawMessage));\r
-            break;\r
-        case 2:  builder.setMultipartReplyBody(setAggregate(rawMessage));\r
-            break;\r
-        case 3:  builder.setMultipartReplyBody(setTable(rawMessage));\r
-            break;         \r
-        case 4:  builder.setMultipartReplyBody(setPortStats(rawMessage));\r
-            break;\r
-        case 5:  builder.setMultipartReplyBody(setQueue(rawMessage));\r
-            break;         \r
-        case 0xFFFF: builder.setMultipartReplyBody(setExperimenter(rawMessage));\r
-            break;\r
-        default: \r
-            break;\r
-        }\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyDesc setDesc(ByteBuf input) {\r
-        MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder();\r
-        byte[] mfrDescBytes = new byte[DESC_STR_LEN];\r
-        input.readBytes(mfrDescBytes);\r
-        String mfrDesc = new String(mfrDescBytes);\r
-        descBuilder.setMfrDesc(mfrDesc.trim());\r
-        byte[] hwDescBytes = new byte[DESC_STR_LEN];\r
-        input.readBytes(hwDescBytes);\r
-        String hwDesc = new String(hwDescBytes);\r
-        descBuilder.setHwDesc(hwDesc.trim());\r
-        byte[] swDescBytes = new byte[DESC_STR_LEN];\r
-        input.readBytes(swDescBytes);\r
-        String swDesc = new String(swDescBytes);\r
-        descBuilder.setSwDesc(swDesc.trim());\r
-        byte[] serialNumBytes = new byte[SERIAL_NUM_LEN];\r
-        input.readBytes(serialNumBytes);\r
-        String serialNum = new String(serialNumBytes);\r
-        descBuilder.setSerialNum(serialNum.trim());\r
-        byte[] dpDescBytes = new byte[DESC_STR_LEN];\r
-        input.readBytes(dpDescBytes);\r
-        String dpDesc = new String(dpDescBytes);\r
-        descBuilder.setDpDesc(dpDesc.trim());\r
-        return descBuilder.build();\r
-    }\r
-    \r
-    private static MultipartReplyFlow setFlow(ByteBuf input) {\r
-        MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();\r
-        List<FlowStats> flowStatsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder();\r
-            input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-            flowStatsBuilder.setTableId(input.readUnsignedByte());\r
-            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER);\r
-            flowStatsBuilder.setMatchV10(OF10MatchDeserializer.createMatchV10(input));\r
-            flowStatsBuilder.setDurationSec(input.readUnsignedInt());\r
-            flowStatsBuilder.setDurationNsec(input.readUnsignedInt());\r
-            flowStatsBuilder.setPriority(input.readUnsignedShort());\r
-            flowStatsBuilder.setIdleTimeout(input.readUnsignedShort());\r
-            flowStatsBuilder.setHardTimeout(input.readUnsignedShort());\r
-            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);\r
-            byte[] cookie = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(cookie);\r
-            flowStatsBuilder.setCookie(new BigInteger(cookie));\r
-            byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(packetCount);\r
-            flowStatsBuilder.setPacketCount(new BigInteger(packetCount));\r
-            byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(byteCount);\r
-            flowStatsBuilder.setByteCount(new BigInteger(byteCount));\r
-            flowStatsBuilder.setActionsList(OF10ActionsDeserializer.createActionsList(input));\r
-            flowStatsList.add(flowStatsBuilder.build());\r
-        }\r
-        flowBuilder.setFlowStats(flowStatsList);\r
-        return flowBuilder.build();\r
-    }\r
-    \r
-    private static MultipartReplyAggregate setAggregate(ByteBuf input) {\r
-        MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();\r
-        byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];\r
-        input.readBytes(packetCount);\r
-        builder.setPacketCount(new BigInteger(packetCount));\r
-        byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];\r
-        input.readBytes(byteCount);\r
-        builder.setByteCount(new BigInteger(byteCount));\r
-        builder.setFlowCount(input.readUnsignedInt());\r
-        input.skipBytes(PADDING_IN_AGGREGATE_HEADER);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyTable setTable(ByteBuf input) {\r
-        MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();\r
-        List<TableStats> tableStatsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            TableStatsBuilder tableStatsBuilder = new TableStatsBuilder();\r
-            tableStatsBuilder.setTableId(input.readUnsignedByte());\r
-            input.skipBytes(PADDING_IN_TABLE_HEADER);\r
-            tableStatsBuilder.setName(input.readBytes(MAX_TABLE_NAME_LENGTH).toString());\r
-            tableStatsBuilder.setActiveCount(input.readUnsignedInt());\r
-            byte[] lookupCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(lookupCount);\r
-            tableStatsBuilder.setLookupCount(new BigInteger(lookupCount));\r
-            byte[] matchedCount = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(matchedCount);\r
-            tableStatsBuilder.setMatchedCount(new BigInteger(matchedCount));\r
-            tableStatsList.add(tableStatsBuilder.build());\r
-        }\r
-        builder.setTableStats(tableStatsList);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyPortStats setPortStats(ByteBuf input) {\r
-        MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder();\r
-        List<PortStats> portStatsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            PortStatsBuilder portStatsBuilder = new PortStatsBuilder();\r
-            portStatsBuilder.setPortNo((long) input.readUnsignedShort());\r
-            input.skipBytes(PADDING_IN_PORT_STATS_HEADER);\r
-            byte[] rxPackets = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxPackets);\r
-            portStatsBuilder.setRxPackets(new BigInteger(rxPackets));\r
-            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txPackets);\r
-            portStatsBuilder.setTxPackets(new BigInteger(txPackets));\r
-            byte[] rxBytes = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxBytes);\r
-            portStatsBuilder.setRxBytes(new BigInteger(rxBytes));\r
-            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txBytes);\r
-            portStatsBuilder.setTxBytes(new BigInteger(txBytes));\r
-            byte[] rxDropped = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxDropped);\r
-            portStatsBuilder.setRxDropped(new BigInteger(rxDropped));\r
-            byte[] txDropped = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txDropped);\r
-            portStatsBuilder.setTxDropped(new BigInteger(txDropped));\r
-            byte[] rxErrors = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxErrors);\r
-            portStatsBuilder.setRxErrors(new BigInteger(rxErrors));\r
-            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txErrors);\r
-            portStatsBuilder.setTxErrors(new BigInteger(txErrors));\r
-            byte[] rxFrameErr = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxFrameErr);\r
-            portStatsBuilder.setRxFrameErr(new BigInteger(rxFrameErr));\r
-            byte[] rxOverErr = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxOverErr);\r
-            portStatsBuilder.setRxOverErr(new BigInteger(rxOverErr));\r
-            byte[] rxCrcErr = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(rxCrcErr);\r
-            portStatsBuilder.setRxCrcErr(new BigInteger(rxCrcErr));\r
-            byte[] collisions = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(collisions);\r
-            portStatsBuilder.setCollisions(new BigInteger(collisions));\r
-        }\r
-        builder.setPortStats(portStatsList);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyQueue setQueue(ByteBuf input) {\r
-        MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder();\r
-        List<QueueStats> queueStatsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder();\r
-            queueStatsBuilder.setPortNo((long) input.readUnsignedShort());\r
-            input.skipBytes(PADDING_IN_QUEUE_HEADER);\r
-            queueStatsBuilder.setQueueId(input.readUnsignedInt());\r
-            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txBytes);\r
-            queueStatsBuilder.setTxBytes(new BigInteger(txBytes));\r
-            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txPackets);\r
-            queueStatsBuilder.setTxPackets(new BigInteger(txPackets));\r
-            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];\r
-            input.readBytes(txErrors);\r
-            queueStatsBuilder.setTxErrors(new BigInteger(txErrors));\r
-            queueStatsList.add(queueStatsBuilder.build());\r
-        }\r
-        builder.setQueueStats(queueStatsList);\r
-        return builder.build();\r
-    }\r
-    \r
-    private static MultipartReplyExperimenter setExperimenter(ByteBuf input) {\r
-        MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder();\r
-        builder.setExperimenter(input.readUnsignedInt());\r
-        byte[] data = new byte[Long.SIZE/Byte.SIZE];\r
-        input.readBytes(data);\r
-        builder.setData(data);\r
-        return builder.build();\r
-    }\r
-}\r
+/*
+ * 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 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.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.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.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.MultipartReplyAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow.FlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow.FlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats.PortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats.PortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue.QueueStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue.QueueStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.TableStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.TableStatsBuilder;
+
+/**
+ * Translates StatsReply messages (OpenFlow v1.0)
+ * @author michal.polkorab
+ */
+public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartReplyMessage> {
+
+    private static final int DESC_STR_LEN = 256;
+    private static final int SERIAL_NUM_LEN = 32;
+    private static final byte PADDING_IN_FLOW_STATS_HEADER = 1;
+    private static final byte PADDING_IN_FLOW_STATS_HEADER_02 = 6;
+    private static final byte PADDING_IN_AGGREGATE_HEADER = 4;
+    private static final byte PADDING_IN_TABLE_HEADER = 3;
+    private static final byte MAX_TABLE_NAME_LENGTH = 32;
+    private static final byte PADDING_IN_PORT_STATS_HEADER = 6;
+    private static final byte PADDING_IN_QUEUE_HEADER = 2;
+
+    private static OF10StatsReplyMessageFactory instance;
+    
+    private OF10StatsReplyMessageFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized OF10StatsReplyMessageFactory getInstance() {
+        if (instance == null){
+            instance = new OF10StatsReplyMessageFactory();
+        }
+        return instance;
+    }
+
+    @Override
+    public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) {
+        MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        int type = rawMessage.readUnsignedShort();
+        builder.setType(MultipartType.forValue(type));
+        builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0));
+        switch (type) {
+        case 0:  builder.setMultipartReplyBody(setDesc(rawMessage));
+            break;
+        case 1:  builder.setMultipartReplyBody(setFlow(rawMessage));
+            break;
+        case 2:  builder.setMultipartReplyBody(setAggregate(rawMessage));
+            break;
+        case 3:  builder.setMultipartReplyBody(setTable(rawMessage));
+            break;         
+        case 4:  builder.setMultipartReplyBody(setPortStats(rawMessage));
+            break;
+        case 5:  builder.setMultipartReplyBody(setQueue(rawMessage));
+            break;         
+        case 0xFFFF: builder.setMultipartReplyBody(setExperimenter(rawMessage));
+            break;
+        default: 
+            break;
+        }
+        return builder.build();
+    }
+    
+    private static MultipartReplyDesc setDesc(ByteBuf input) {
+        MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder();
+        byte[] mfrDescBytes = new byte[DESC_STR_LEN];
+        input.readBytes(mfrDescBytes);
+        String mfrDesc = new String(mfrDescBytes);
+        descBuilder.setMfrDesc(mfrDesc.trim());
+        byte[] hwDescBytes = new byte[DESC_STR_LEN];
+        input.readBytes(hwDescBytes);
+        String hwDesc = new String(hwDescBytes);
+        descBuilder.setHwDesc(hwDesc.trim());
+        byte[] swDescBytes = new byte[DESC_STR_LEN];
+        input.readBytes(swDescBytes);
+        String swDesc = new String(swDescBytes);
+        descBuilder.setSwDesc(swDesc.trim());
+        byte[] serialNumBytes = new byte[SERIAL_NUM_LEN];
+        input.readBytes(serialNumBytes);
+        String serialNum = new String(serialNumBytes);
+        descBuilder.setSerialNum(serialNum.trim());
+        byte[] dpDescBytes = new byte[DESC_STR_LEN];
+        input.readBytes(dpDescBytes);
+        String dpDesc = new String(dpDescBytes);
+        descBuilder.setDpDesc(dpDesc.trim());
+        return descBuilder.build();
+    }
+    
+    private static MultipartReplyFlow setFlow(ByteBuf input) {
+        MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
+        List<FlowStats> flowStatsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder();
+            input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            flowStatsBuilder.setTableId(input.readUnsignedByte());
+            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER);
+            flowStatsBuilder.setMatchV10(OF10MatchDeserializer.createMatchV10(input));
+            flowStatsBuilder.setDurationSec(input.readUnsignedInt());
+            flowStatsBuilder.setDurationNsec(input.readUnsignedInt());
+            flowStatsBuilder.setPriority(input.readUnsignedShort());
+            flowStatsBuilder.setIdleTimeout(input.readUnsignedShort());
+            flowStatsBuilder.setHardTimeout(input.readUnsignedShort());
+            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
+            byte[] cookie = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(cookie);
+            flowStatsBuilder.setCookie(new BigInteger(cookie));
+            byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(packetCount);
+            flowStatsBuilder.setPacketCount(new BigInteger(packetCount));
+            byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(byteCount);
+            flowStatsBuilder.setByteCount(new BigInteger(byteCount));
+            flowStatsBuilder.setActionsList(OF10ActionsDeserializer.createActionsList(input));
+            flowStatsList.add(flowStatsBuilder.build());
+        }
+        flowBuilder.setFlowStats(flowStatsList);
+        return flowBuilder.build();
+    }
+    
+    private static MultipartReplyAggregate setAggregate(ByteBuf input) {
+        MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();
+        byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];
+        input.readBytes(packetCount);
+        builder.setPacketCount(new BigInteger(packetCount));
+        byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];
+        input.readBytes(byteCount);
+        builder.setByteCount(new BigInteger(byteCount));
+        builder.setFlowCount(input.readUnsignedInt());
+        input.skipBytes(PADDING_IN_AGGREGATE_HEADER);
+        return builder.build();
+    }
+    
+    private static MultipartReplyTable setTable(ByteBuf input) {
+        MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();
+        List<TableStats> tableStatsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            TableStatsBuilder tableStatsBuilder = new TableStatsBuilder();
+            tableStatsBuilder.setTableId(input.readUnsignedByte());
+            input.skipBytes(PADDING_IN_TABLE_HEADER);
+            tableStatsBuilder.setName(input.readBytes(MAX_TABLE_NAME_LENGTH).toString());
+            tableStatsBuilder.setActiveCount(input.readUnsignedInt());
+            byte[] lookupCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(lookupCount);
+            tableStatsBuilder.setLookupCount(new BigInteger(lookupCount));
+            byte[] matchedCount = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(matchedCount);
+            tableStatsBuilder.setMatchedCount(new BigInteger(matchedCount));
+            tableStatsList.add(tableStatsBuilder.build());
+        }
+        builder.setTableStats(tableStatsList);
+        return builder.build();
+    }
+    
+    private static MultipartReplyPortStats setPortStats(ByteBuf input) {
+        MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder();
+        List<PortStats> portStatsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            PortStatsBuilder portStatsBuilder = new PortStatsBuilder();
+            portStatsBuilder.setPortNo((long) input.readUnsignedShort());
+            input.skipBytes(PADDING_IN_PORT_STATS_HEADER);
+            byte[] rxPackets = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxPackets);
+            portStatsBuilder.setRxPackets(new BigInteger(rxPackets));
+            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txPackets);
+            portStatsBuilder.setTxPackets(new BigInteger(txPackets));
+            byte[] rxBytes = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxBytes);
+            portStatsBuilder.setRxBytes(new BigInteger(rxBytes));
+            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txBytes);
+            portStatsBuilder.setTxBytes(new BigInteger(txBytes));
+            byte[] rxDropped = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxDropped);
+            portStatsBuilder.setRxDropped(new BigInteger(rxDropped));
+            byte[] txDropped = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txDropped);
+            portStatsBuilder.setTxDropped(new BigInteger(txDropped));
+            byte[] rxErrors = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxErrors);
+            portStatsBuilder.setRxErrors(new BigInteger(rxErrors));
+            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txErrors);
+            portStatsBuilder.setTxErrors(new BigInteger(txErrors));
+            byte[] rxFrameErr = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxFrameErr);
+            portStatsBuilder.setRxFrameErr(new BigInteger(rxFrameErr));
+            byte[] rxOverErr = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxOverErr);
+            portStatsBuilder.setRxOverErr(new BigInteger(rxOverErr));
+            byte[] rxCrcErr = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(rxCrcErr);
+            portStatsBuilder.setRxCrcErr(new BigInteger(rxCrcErr));
+            byte[] collisions = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(collisions);
+            portStatsBuilder.setCollisions(new BigInteger(collisions));
+        }
+        builder.setPortStats(portStatsList);
+        return builder.build();
+    }
+    
+    private static MultipartReplyQueue setQueue(ByteBuf input) {
+        MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder();
+        List<QueueStats> queueStatsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder();
+            queueStatsBuilder.setPortNo((long) input.readUnsignedShort());
+            input.skipBytes(PADDING_IN_QUEUE_HEADER);
+            queueStatsBuilder.setQueueId(input.readUnsignedInt());
+            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txBytes);
+            queueStatsBuilder.setTxBytes(new BigInteger(txBytes));
+            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txPackets);
+            queueStatsBuilder.setTxPackets(new BigInteger(txPackets));
+            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];
+            input.readBytes(txErrors);
+            queueStatsBuilder.setTxErrors(new BigInteger(txErrors));
+            queueStatsList.add(queueStatsBuilder.build());
+        }
+        builder.setQueueStats(queueStatsList);
+        return builder.build();
+    }
+    
+    private static MultipartReplyExperimenter setExperimenter(ByteBuf input) {
+        MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder();
+        builder.setExperimenter(input.readUnsignedInt());
+        byte[] data = new byte[Long.SIZE/Byte.SIZE];
+        input.readBytes(data);
+        builder.setData(data);
+        return builder.build();
+    }
+}
index e0fbe7aa238a369fa56b90c64cb3675834823d94..4c817198a1fdd403a2514a20631c0e828d6aa3ab 100644 (file)
@@ -1,44 +1,51 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder;\r
-\r
-/**\r
- * Translates Vendor messages (OpenFlow v1.0)\r
- * @author michal.polkorab\r
- */\r
-public class OF10VendorMessageFactory implements OFDeserializer<ExperimenterMessage> {\r
-\r
-private static OF10VendorMessageFactory instance;\r
-    \r
-    private OF10VendorMessageFactory() {\r
-        //singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10VendorMessageFactory getInstance(){\r
-        if (instance == null){\r
-           instance = new OF10VendorMessageFactory(); \r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public ExperimenterMessage bufferToMessage(ByteBuf rawMessage, short version) {\r
-        ExperimenterMessageBuilder builder = new ExperimenterMessageBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        builder.setExperimenter(rawMessage.readUnsignedInt());\r
-        int remainingBytes = rawMessage.readableBytes();\r
-        if (remainingBytes > 0) {\r
-            builder.setData(rawMessage.readBytes(remainingBytes).array());\r
-        }\r
-        return builder.build();\r
-    }\r
-}\r
+/*
+ * 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 0a45ef73fa7310c02755c432698fe987199cbbd9..fec070016ca5aa5fd8383c9bad5b904fb3f5d644 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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;
index da8b5e57719a181d66a032953fff85b1ff8edc80..1252e4ebda19e2fcc4fa23e4d72f7f7a1ccc15a4 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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;
index 3cccbe519e3548d8e85268f71195522b15e34e91..b442a49a6c4cd27b0ef9f1d848d6098c01d3490d 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueuePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;\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.GetQueueConfigOutputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;\r
-\r
-/**\r
- * Translates QueueGetConfigReply messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class QueueGetConfigReplyMessageFactory implements OFDeserializer<GetQueueConfigOutput> {\r
-\r
-    private static final byte PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER = 4;\r
-    private static final byte PADDING_IN_PACKET_QUEUE_HEADER = 6;\r
-    private static final byte PADDING_IN_QUEUE_PROPERTY_HEADER = 4;\r
-    private static final int PADDING_IN_RATE_QUEUE_PROPERTY = 6;\r
-    private static final int PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY = 4;\r
-    private static final byte PACKET_QUEUE_LENGTH = 16;\r
-\r
-    private static QueueGetConfigReplyMessageFactory instance;\r
-    \r
-    private QueueGetConfigReplyMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * \r
-     * @return singleton factory\r
-     */\r
-    public static synchronized QueueGetConfigReplyMessageFactory getInstance(){\r
-        \r
-        if(instance == null){\r
-            instance = new QueueGetConfigReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public GetQueueConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {\r
-        GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid((rawMessage.readUnsignedInt()));\r
-        builder.setPort(new PortNumber(rawMessage.readUnsignedInt()));\r
-        rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER);\r
-        builder.setQueues(createQueuesList(rawMessage));\r
-        return builder.build();\r
-    }\r
-    \r
-    private static List<Queues> createQueuesList(ByteBuf input){\r
-        List<Queues> queuesList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            QueuesBuilder queueBuilder = new QueuesBuilder();\r
-            queueBuilder.setQueueId(new QueueId(input.readUnsignedInt()));\r
-            queueBuilder.setPort(new PortNumber(input.readUnsignedInt()));\r
-            int length = input.readUnsignedShort();\r
-            input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER);\r
-            queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_LENGTH));\r
-            queuesList.add(queueBuilder.build());\r
-        } \r
-        return queuesList;\r
-    }\r
-    \r
-    private static List<QueueProperty> createPropertiesList(ByteBuf input, int length){\r
-        int propertiesLength = length;\r
-        List<QueueProperty> propertiesList = new ArrayList<>();\r
-        while (propertiesLength > 0) {\r
-            QueuePropertyBuilder propertiesBuilder = new QueuePropertyBuilder();\r
-            QueueProperties property = QueueProperties.forValue(input.readUnsignedShort());\r
-            propertiesBuilder.setProperty(property);\r
-            int currentPropertyLength = input.readUnsignedShort();\r
-            propertiesLength -= currentPropertyLength;\r
-            input.skipBytes(PADDING_IN_QUEUE_PROPERTY_HEADER);\r
-            if (property.equals(QueueProperties.OFPQTMINRATE) || property.equals(QueueProperties.OFPQTMAXRATE)) {\r
-                RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();\r
-                rateBuilder.setRate(input.readUnsignedShort());\r
-                propertiesBuilder.addAugmentation(RateQueueProperty.class, rateBuilder.build());\r
-                input.skipBytes(PADDING_IN_RATE_QUEUE_PROPERTY);\r
-            } else if (property.equals(QueueProperties.OFPQTEXPERIMENTER)) {\r
-                ExperimenterQueuePropertyBuilder expBuilder = new ExperimenterQueuePropertyBuilder();\r
-                expBuilder.setExperimenter(input.readUnsignedInt());\r
-                input.skipBytes(PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY);\r
-                expBuilder.setData(input.readBytes(currentPropertyLength\r
-                        - EncodeConstants.SIZE_OF_INT_IN_BYTES - PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY).array());\r
-                propertiesBuilder.addAugmentation(RateQueueProperty.class, expBuilder.build());\r
-            }\r
-            propertiesList.add(propertiesBuilder.build());\r
-        }\r
-        return propertiesList;\r
-    }\r
-\r
-}\r
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.openflowjava.protocol.impl.deserialization.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;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;
+
+/**
+ * Translates QueueGetConfigReply messages
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class QueueGetConfigReplyMessageFactory implements OFDeserializer<GetQueueConfigOutput> {
+
+    private static final byte PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER = 4;
+    private static final byte PADDING_IN_PACKET_QUEUE_HEADER = 6;
+    private static final byte PADDING_IN_QUEUE_PROPERTY_HEADER = 4;
+    private static final int PADDING_IN_RATE_QUEUE_PROPERTY = 6;
+    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) {
+        GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
+        builder.setVersion(version);
+        builder.setXid((rawMessage.readUnsignedInt()));
+        builder.setPort(new PortNumber(rawMessage.readUnsignedInt()));
+        rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER);
+        builder.setQueues(createQueuesList(rawMessage));
+        return builder.build();
+    }
+    
+    private static List<Queues> createQueuesList(ByteBuf input){
+        List<Queues> queuesList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            QueuesBuilder queueBuilder = new QueuesBuilder();
+            queueBuilder.setQueueId(new QueueId(input.readUnsignedInt()));
+            queueBuilder.setPort(new PortNumber(input.readUnsignedInt()));
+            int length = input.readUnsignedShort();
+            input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER);
+            queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_LENGTH));
+            queuesList.add(queueBuilder.build());
+        } 
+        return queuesList;
+    }
+    
+    private static List<QueueProperty> createPropertiesList(ByteBuf input, int length){
+        int propertiesLength = length;
+        List<QueueProperty> propertiesList = new ArrayList<>();
+        while (propertiesLength > 0) {
+            QueuePropertyBuilder propertiesBuilder = new QueuePropertyBuilder();
+            QueueProperties property = QueueProperties.forValue(input.readUnsignedShort());
+            propertiesBuilder.setProperty(property);
+            int currentPropertyLength = input.readUnsignedShort();
+            propertiesLength -= currentPropertyLength;
+            input.skipBytes(PADDING_IN_QUEUE_PROPERTY_HEADER);
+            if (property.equals(QueueProperties.OFPQTMINRATE) || property.equals(QueueProperties.OFPQTMAXRATE)) {
+                RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();
+                rateBuilder.setRate(input.readUnsignedShort());
+                propertiesBuilder.addAugmentation(RateQueueProperty.class, rateBuilder.build());
+                input.skipBytes(PADDING_IN_RATE_QUEUE_PROPERTY);
+            } else if (property.equals(QueueProperties.OFPQTEXPERIMENTER)) {
+                ExperimenterQueuePropertyBuilder expBuilder = new ExperimenterQueuePropertyBuilder();
+                expBuilder.setExperimenter(input.readUnsignedInt());
+                input.skipBytes(PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY);
+                expBuilder.setData(input.readBytes(currentPropertyLength
+                        - EncodeConstants.SIZE_OF_INT_IN_BYTES - PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY).array());
+                propertiesBuilder.addAugmentation(RateQueueProperty.class, expBuilder.build());
+            }
+            propertiesList.add(propertiesBuilder.build());
+        }
+        return propertiesList;
+    }
+
+}
index d09aa7a19663ff0a0c5c392dd916856b8b6668d3..9f9fec9a02fb88c6e2b41884713e57e0fbf2db1c 100644 (file)
@@ -1,49 +1,56 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.math.BigInteger;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder;\r
-\r
-/**\r
- * Translates RoleReply messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class RoleReplyMessageFactory implements OFDeserializer<RoleRequestOutput>{\r
-    private static RoleReplyMessageFactory instance;\r
-    private static final byte PADDING_IN_ROLE_REPLY_HEADER = 4;\r
-    \r
-    private RoleReplyMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * \r
-     * @return singleton factory\r
-     */\r
-    public static synchronized RoleReplyMessageFactory getInstance(){\r
-        if(instance == null){\r
-            instance = new RoleReplyMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public RoleRequestOutput bufferToMessage(ByteBuf rawMessage, short version) {\r
-        RoleRequestOutputBuilder builder = new RoleRequestOutputBuilder();\r
-        builder.setVersion(version);\r
-        builder.setXid(rawMessage.readUnsignedInt());\r
-        builder.setRole(ControllerRole.forValue((int) rawMessage.readUnsignedInt()));\r
-        rawMessage.skipBytes(PADDING_IN_ROLE_REPLY_HEADER);\r
-        byte[] generationID = new byte[8];\r
-        rawMessage.readBytes(generationID);\r
-        builder.setGenerationId(new BigInteger(generationID));\r
-        return builder.build();\r
-    }\r
-}\r
+/*
+ * 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 java.math.BigInteger;
+
+import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+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;
+
+/**
+ * Translates RoleReply messages
+ * @author timotej.kubas
+ * @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) {
+        RoleRequestOutputBuilder builder = new RoleRequestOutputBuilder();
+        builder.setVersion(version);
+        builder.setXid(rawMessage.readUnsignedInt());
+        builder.setRole(ControllerRole.forValue((int) rawMessage.readUnsignedInt()));
+        rawMessage.skipBytes(PADDING_IN_ROLE_REPLY_HEADER);
+        byte[] generationID = new byte[8];
+        rawMessage.readBytes(generationID);
+        builder.setGenerationId(new BigInteger(generationID));
+        return builder.build();
+    }
+}
index b26d4257e5f37a777b1d75ecb26676635b50cefb..3a1e0d0686bf79ee0ed79bbe545e54391531f6af 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoReplyInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.ExperimenterInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.FlowModInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetAsyncRequestMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetConfigInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetFeaturesInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetQueueConfigInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GroupModInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.HelloInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MeterModInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10BarrierInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FlowModInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10HelloInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PacketOutInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PortModInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10QueueGetConfigInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10VendorInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PacketOutInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PortModInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.RoleRequestInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetAsyncInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetConfigMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-\r
-/**\r
- * Stores and provides correct encoders for received messages\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class EncoderTable {\r
-\r
-    private static final short OF10 = EncodeConstants.OF10_VERSION_ID;\r
-    private static final short OF13 = EncodeConstants.OF13_VERSION_ID;\r
-    private static EncoderTable instance;\r
-    private Map<MessageTypeKey<?>, OFSerializer<?>> table;\r
-\r
-\r
-    private EncoderTable() {\r
-        // do nothing\r
-    }\r
-\r
-    /**\r
-     * @return singleton instance\r
-     */\r
-    public static synchronized EncoderTable getInstance() {\r
-        if (instance == null) {\r
-            instance = new EncoderTable();\r
-            instance.init();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    /**\r
-     * Encoder table provisioning\r
-     */\r
-    public void init() {\r
-        table = new HashMap<>();\r
-        table.put(new MessageTypeKey<>(OF10, BarrierInput.class), OF10BarrierInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, EchoInput.class), EchoInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, EchoReplyInput.class), EchoReplyInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, ExperimenterInput.class), OF10VendorInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, FlowModInput.class), OF10FlowModInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, GetConfigInput.class), GetConfigInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, GetFeaturesInput.class), GetFeaturesInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, GetQueueConfigInput.class), OF10QueueGetConfigInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, HelloInput.class), OF10HelloInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, MultipartRequestInput.class), OF10StatsRequestInputFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, PacketOutInput.class), OF10PacketOutInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, PortModInput.class), OF10PortModInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF10, SetConfigInput.class), SetConfigMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, BarrierInput.class), BarrierInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, EchoInput.class), EchoInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, EchoReplyInput.class), EchoReplyInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, ExperimenterInput.class), ExperimenterInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, FlowModInput.class), FlowModInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, GetAsyncInput.class), GetAsyncRequestMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, GetConfigInput.class), GetConfigInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, GetFeaturesInput.class), GetFeaturesInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, GetQueueConfigInput.class), GetQueueConfigInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, GroupModInput.class), GroupModInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, HelloInput.class), HelloInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, MeterModInput.class), MeterModInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, MultipartRequestInput.class), MultipartRequestInputFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, PacketOutInput.class), PacketOutInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, PortModInput.class), PortModInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, RoleRequestInput.class), RoleRequestInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, SetAsyncInput.class), SetAsyncInputMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, SetConfigInput.class), SetConfigMessageFactory.getInstance());\r
-        table.put(new MessageTypeKey<>(OF13, TableModInput.class), TableModInputMessageFactory.getInstance());\r
-    }\r
-\r
-    /**\r
-     * @param msgTypeKey\r
-     * @return encoder for current type of message (msgTypeKey)\r
-     */\r
-    @SuppressWarnings("unchecked")\r
-    public <E extends DataObject> OFSerializer<E> getEncoder(MessageTypeKey<E> msgTypeKey) {\r
-        return (OFSerializer<E>) table.get(msgTypeKey);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoReplyInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.ExperimenterInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.FlowModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetAsyncRequestMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetConfigInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetFeaturesInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetQueueConfigInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GroupModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.HelloInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MeterModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10BarrierInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FlowModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10HelloInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PacketOutInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PortModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10QueueGetConfigInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10VendorInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PacketOutInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PortModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.RoleRequestInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetAsyncInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetConfigMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+/**
+ * Stores and provides correct encoders for received messages
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class EncoderTable {
+
+    private static final short OF10 = EncodeConstants.OF10_VERSION_ID;
+    private static final short OF13 = EncodeConstants.OF13_VERSION_ID;
+    private static EncoderTable instance;
+    private Map<MessageTypeKey<?>, OFSerializer<?>> table;
+
+
+    private EncoderTable() {
+        // do nothing
+    }
+
+    /**
+     * @return singleton instance
+     */
+    public static synchronized EncoderTable getInstance() {
+        if (instance == null) {
+            instance = new EncoderTable();
+            instance.init();
+        }
+        return instance;
+    }
+
+    /**
+     * Encoder table provisioning
+     */
+    public void init() {
+        table = new HashMap<>();
+        table.put(new MessageTypeKey<>(OF10, BarrierInput.class), OF10BarrierInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, EchoInput.class), EchoInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, EchoReplyInput.class), EchoReplyInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, ExperimenterInput.class), OF10VendorInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, FlowModInput.class), OF10FlowModInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, GetConfigInput.class), GetConfigInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, GetFeaturesInput.class), GetFeaturesInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, GetQueueConfigInput.class), OF10QueueGetConfigInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, HelloInput.class), OF10HelloInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, MultipartRequestInput.class), OF10StatsRequestInputFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, PacketOutInput.class), OF10PacketOutInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, PortModInput.class), OF10PortModInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF10, SetConfigInput.class), SetConfigMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, BarrierInput.class), BarrierInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, EchoInput.class), EchoInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, EchoReplyInput.class), EchoReplyInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, ExperimenterInput.class), ExperimenterInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, FlowModInput.class), FlowModInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, GetAsyncInput.class), GetAsyncRequestMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, GetConfigInput.class), GetConfigInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, GetFeaturesInput.class), GetFeaturesInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, GetQueueConfigInput.class), GetQueueConfigInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, GroupModInput.class), GroupModInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, HelloInput.class), HelloInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, MeterModInput.class), MeterModInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, MultipartRequestInput.class), MultipartRequestInputFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, PacketOutInput.class), PacketOutInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, PortModInput.class), PortModInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, RoleRequestInput.class), RoleRequestInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, SetAsyncInput.class), SetAsyncInputMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, SetConfigInput.class), SetConfigMessageFactory.getInstance());
+        table.put(new MessageTypeKey<>(OF13, TableModInput.class), TableModInputMessageFactory.getInstance());
+    }
+
+    /**
+     * @param msgTypeKey
+     * @return encoder for current type of message (msgTypeKey)
+     */
+    @SuppressWarnings("unchecked")
+    public <E extends DataObject> OFSerializer<E> getEncoder(MessageTypeKey<E> msgTypeKey) {
+        return (OFSerializer<E>) table.get(msgTypeKey);
+    }
+
+}
index 56a1661bb5537f43a89a2fd5f72a965136d86650..38cdcda9ecd4d6e527acf780c9f1f768c84cc300 100644 (file)
@@ -1,73 +1,80 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization;\r
-\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-\r
-/**\r
- * Class used as a key in {@link EncoderTable}\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- * @param <E> message type (class)\r
- */\r
-public class MessageTypeKey<E extends DataObject> {\r
-\r
-    private final Class<E> msgType;\r
-    private final short msgVersion;\r
-    \r
-    /**\r
-     * @param msgVersion protocol version\r
-     * @param msgType type of message\r
-     */\r
-    public MessageTypeKey(short msgVersion, Class<E> msgType) {\r
-        super();\r
-        this.msgType = msgType;\r
-        this.msgVersion = msgVersion;\r
-    }\r
-    \r
-    /**\r
-     * @return msgVersion\r
-     */\r
-    public short getMsgVersion() {\r
-        return msgVersion;\r
-    }\r
-\r
-    /**\r
-     * @return the msgType\r
-     */\r
-    public Class<E> getMsgType() {\r
-        return msgType;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return "msgVersion: " + msgVersion + " msgType: " + msgType.getName();\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result + msgVersion;\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
-        MessageTypeKey<?> other = (MessageTypeKey<?>) obj;\r
-        if (msgType == null) {\r
-            if (other.msgType != null)\r
-                return false;\r
-        } else if (!other.msgType.isAssignableFrom(msgType))\r
-            return false;\r
-        if (msgVersion != other.msgVersion)\r
-            return false;\r
-        return true;\r
-    }\r
\r
-}\r
+/*
+ * 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.serialization;
+
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+/**
+ * Class used as a key in {@link EncoderTable}
+ * @author michal.polkorab
+ * @author timotej.kubas
+ * @param <E> message type (class)
+ */
+public class MessageTypeKey<E extends DataObject> {
+
+    private final Class<E> msgType;
+    private final short msgVersion;
+    
+    /**
+     * @param msgVersion protocol version
+     * @param msgType type of message
+     */
+    public MessageTypeKey(short msgVersion, Class<E> msgType) {
+        super();
+        this.msgType = msgType;
+        this.msgVersion = msgVersion;
+    }
+    
+    /**
+     * @return msgVersion
+     */
+    public short getMsgVersion() {
+        return msgVersion;
+    }
+
+    /**
+     * @return the msgType
+     */
+    public Class<E> getMsgType() {
+        return msgType;
+    }
+
+    @Override
+    public String toString() {
+        return "msgVersion: " + msgVersion + " msgType: " + msgType.getName();
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + msgVersion;
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        MessageTypeKey<?> other = (MessageTypeKey<?>) obj;
+        if (msgType == null) {
+            if (other.msgType != null)
+                return false;
+        } else if (!other.msgType.isAssignableFrom(msgType))
+            return false;
+        if (msgVersion != other.msgVersion)
+            return false;
+        return true;
+    }
+}
index 2c88d0a0c766794ff993a80dcf392f56c0f20020..f514f14015edecd260f066bf8cc6615dae8bfae6 100644 (file)
@@ -1,35 +1,42 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-\r
-/**\r
- * Uniform interface for serializing factories\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- * @param <E> message type\r
- */\r
-public interface OFSerializer <E extends DataObject> {\r
-\r
-    /**\r
-     * Transforms POJO/DTO into byte message (ByteBuf).\r
-     * @param version version of used OF Protocol\r
-     * @param out ByteBuf used for output\r
-     * @param message message that will be transformed into ByteBuf\r
-     */\r
-    public abstract void messageToBuffer(short version, ByteBuf out, E message);\r
-    \r
-    /**\r
-     * Compute length of received message\r
-     * @param message \r
-     * @return computed length\r
-     */\r
-    public abstract int computeLength(E message);\r
-    \r
-    /**\r
-     * @return message code type\r
-     */\r
-    public byte getMessageType();\r
-}\r
+/*
+ * 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.serialization;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+/**
+ * Uniform interface for serializing factories
+ * @author michal.polkorab
+ * @author timotej.kubas
+ * @param <E> message type
+ */
+public interface OFSerializer <E extends DataObject> {
+
+    /**
+     * Transforms POJO/DTO into byte message (ByteBuf).
+     * @param version version of used OF Protocol
+     * @param out ByteBuf used for output
+     * @param message message that will be transformed into ByteBuf
+     */
+    public abstract void messageToBuffer(short version, ByteBuf out, E message);
+    
+    /**
+     * Compute length of received message
+     * @param message 
+     * @return computed length
+     */
+    public abstract int computeLength(E message);
+    
+    /**
+     * @return message code type
+     */
+    public byte getMessageType();
+}
index 6ed701a967c85de7dc8fdf222323d3cf36a817cc..18449f70a38096b0d89008edd63b70ff7e5a1021 100644 (file)
@@ -1,34 +1,41 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class SerializationFactory {\r
-\r
-    private static final Logger LOGGER = LoggerFactory\r
-            .getLogger(SerializationFactory.class);\r
-    /**\r
-     * Transforms POJO message into ByteBuf\r
-     * @param version version used for encoding received message\r
-     * @param out ByteBuf for storing and sending transformed message\r
-     * @param message POJO message\r
-     */\r
-    public static <E extends DataObject> void messageToBuffer(short version, ByteBuf out, E message) {\r
-        @SuppressWarnings("unchecked")\r
-        MessageTypeKey<E> msgTypeKey = new MessageTypeKey<>(version, (Class<E>) message.getClass());\r
-        OFSerializer<E> encoder = EncoderTable.getInstance().getEncoder(msgTypeKey);\r
-        if (encoder != null) {\r
-            encoder.messageToBuffer(version, out, message);\r
-        } else {\r
-            LOGGER.warn("No correct encoder found in EncoderTable for arguments: " + msgTypeKey.toString());\r
-        }\r
-    }\r
-}\r
+/*
+ * 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.serialization;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class SerializationFactory {
+
+    private static final Logger LOGGER = LoggerFactory
+            .getLogger(SerializationFactory.class);
+    /**
+     * Transforms POJO message into ByteBuf
+     * @param version version used for encoding received message
+     * @param out ByteBuf for storing and sending transformed message
+     * @param message POJO message
+     */
+    public static <E extends DataObject> void messageToBuffer(short version, ByteBuf out, E message) {
+        @SuppressWarnings("unchecked")
+        MessageTypeKey<E> msgTypeKey = new MessageTypeKey<>(version, (Class<E>) message.getClass());
+        OFSerializer<E> encoder = EncoderTable.getInstance().getEncoder(msgTypeKey);
+        if (encoder != null) {
+            encoder.messageToBuffer(version, out, message);
+        } else {
+            LOGGER.warn("No correct encoder found in EncoderTable for arguments: " + msgTypeKey.toString());
+        }
+    }
+}
index 9253410dca42e0d1de250057423433aface4e0c2..def001427fed9ba7e16e284a6a45a4db3409ac82 100644 (file)
@@ -1,50 +1,57 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;\r
-\r
-/**\r
- * Translates BarrierRequest messages\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class BarrierInputMessageFactory implements OFSerializer<BarrierInput> {\r
-\r
-    /** Code type of BarrierRequest message */\r
-    public static final byte MESSAGE_TYPE = 20;\r
-    private static BarrierInputMessageFactory instance;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-    \r
-    private BarrierInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized BarrierInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new BarrierInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, BarrierInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(BarrierInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+
+/**
+ * Translates BarrierRequest messages
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class BarrierInputMessageFactory implements OFSerializer<BarrierInput> {
+
+    /** Code type of BarrierRequest message */
+    public static final byte MESSAGE_TYPE = 20;
+    private static BarrierInputMessageFactory instance;
+    private static final int MESSAGE_LENGTH = 8;
+    
+    private BarrierInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized BarrierInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new BarrierInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, BarrierInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+    }
+
+    @Override
+    public int computeLength(BarrierInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+}
index ef83d5c49d2d0da90d34f08cc89e10e27d4b34aa..9e1cfa5b95fca06918ad9feef7b6d9e60bedfcf2 100644 (file)
@@ -1,60 +1,67 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;\r
-\r
-/**\r
- * Translates EchoRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class EchoInputMessageFactory implements OFSerializer<EchoInput> {\r
-\r
-    /** Code type of EchoRequest message */\r
-    public static final byte MESSAGE_TYPE = 2;\r
-    private static EchoInputMessageFactory instance;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-    \r
-    private EchoInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized EchoInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new EchoInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, EchoInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            out.writeBytes(data);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(EchoInput message) {\r
-        int length = MESSAGE_LENGTH;\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            length += data.length;\r
-        }\r
-        return length;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-    \r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
+
+/**
+ * Translates EchoRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class EchoInputMessageFactory implements OFSerializer<EchoInput> {
+
+    /** Code type of EchoRequest message */
+    public static final byte MESSAGE_TYPE = 2;
+    private static EchoInputMessageFactory instance;
+    private static final int MESSAGE_LENGTH = 8;
+    
+    private EchoInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized EchoInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new EchoInputMessageFactory();
+        }
+        return instance;
+    }
+
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, EchoInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        byte[] data = message.getData();
+        if (data != null) {
+            out.writeBytes(data);
+        }
+    }
+
+    @Override
+    public int computeLength(EchoInput message) {
+        int length = MESSAGE_LENGTH;
+        byte[] data = message.getData();
+        if (data != null) {
+            length += data.length;
+        }
+        return length;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+    
+}
index 2c8effbecabf965f1360ccf20af7dc106eeb1180..3e76f8c03e332fc47f11b49e83aefbb39ad2501e 100644 (file)
@@ -1,60 +1,67 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;\r
-\r
-/**\r
- * Translates EchoReply messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class EchoReplyInputMessageFactory implements OFSerializer<EchoReplyInput>{\r
-\r
-    /** Code type of EchoReply message */\r
-    public static final byte MESSAGE_TYPE = 3;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-    private static EchoReplyInputMessageFactory instance;\r
-    \r
-    private EchoReplyInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized EchoReplyInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new EchoReplyInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            EchoReplyInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            out.writeBytes(data);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(EchoReplyInput message) {\r
-        int length = MESSAGE_LENGTH;\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            length += data.length;\r
-        }\r
-        return length;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;
+
+/**
+ * Translates EchoReply messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class EchoReplyInputMessageFactory implements OFSerializer<EchoReplyInput>{
+
+    /** Code type of EchoReply message */
+    public static final byte MESSAGE_TYPE = 3;
+    private static final int MESSAGE_LENGTH = 8;
+    private static EchoReplyInputMessageFactory instance;
+    
+    private EchoReplyInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized EchoReplyInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new EchoReplyInputMessageFactory();
+        }
+        return instance;
+    }
+
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            EchoReplyInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        byte[] data = message.getData();
+        if (data != null) {
+            out.writeBytes(data);
+        }
+    }
+
+    @Override
+    public int computeLength(EchoReplyInput message) {
+        int length = MESSAGE_LENGTH;
+        byte[] data = message.getData();
+        if (data != null) {
+            length += data.length;
+        }
+        return length;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+}
index 60f116b84405d699b6a0f50009a90628c8cf2a45..ff24b6e055cb7f984cc731d334ee402d6bd43e8b 100644 (file)
@@ -1,64 +1,71 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
-\r
-/**\r
- * Translates Experimenter messages\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class ExperimenterInputMessageFactory implements OFSerializer<ExperimenterInput>{\r
-\r
-    /** Code type of Experimenter message */\r
-    public static final byte MESSAGE_TYPE = 4;\r
-    private static final byte MESSAGE_LENGTH = 8;\r
-    private static ExperimenterInputMessageFactory instance;\r
-    \r
-    private ExperimenterInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized ExperimenterInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new ExperimenterInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            ExperimenterInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeInt(message.getExperimenter().intValue());\r
-        out.writeInt(message.getExpType().intValue());\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            out.writeBytes(data);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(ExperimenterInput message) {\r
-        int length = MESSAGE_LENGTH + 2 * (EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            length += data.length;\r
-        }\r
-        return length;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-    \r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+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.protocol.rev130731.ExperimenterInput;
+
+/**
+ * Translates Experimenter messages
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class ExperimenterInputMessageFactory implements OFSerializer<ExperimenterInput>{
+
+    /** Code type of Experimenter message */
+    public static final byte MESSAGE_TYPE = 4;
+    private static final byte MESSAGE_LENGTH = 8;
+    private static ExperimenterInputMessageFactory instance;
+    
+    private ExperimenterInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized ExperimenterInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new ExperimenterInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            ExperimenterInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeInt(message.getExperimenter().intValue());
+        out.writeInt(message.getExpType().intValue());
+        byte[] data = message.getData();
+        if (data != null) {
+            out.writeBytes(data);
+        }
+    }
+
+    @Override
+    public int computeLength(ExperimenterInput message) {
+        int length = MESSAGE_LENGTH + 2 * (EncodeConstants.SIZE_OF_INT_IN_BYTES);
+        byte[] data = message.getData();
+        if (data != null) {
+            length += data.length;
+        }
+        return length;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+    
+}
index 511f1622a31d7e490de7916b88533c95d1923c57..cb2a5f74bef6e412485feb95d34d44d3262b9420 100644 (file)
@@ -1,85 +1,92 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.InstructionsSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.MatchSerializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
-\r
-/**\r
- * Translates FlowMod messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class FlowModInputMessageFactory implements OFSerializer<FlowModInput> {\r
-    private static final byte MESSAGE_TYPE = 14;\r
-    private static final byte PADDING_IN_FLOW_MOD_MESSAGE = 2;\r
-    private static final int MESSAGE_LENGTH = 48;\r
-    private static FlowModInputMessageFactory instance;\r
-   \r
-    private FlowModInputMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized FlowModInputMessageFactory getInstance() {\r
-        if(instance == null) {\r
-            instance = new FlowModInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, FlowModInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeLong(message.getCookie().longValue());\r
-        out.writeLong(message.getCookieMask().longValue());\r
-        out.writeByte(message.getTableId().getValue().byteValue());\r
-        out.writeByte(message.getCommand().getIntValue());\r
-        out.writeShort(message.getIdleTimeout().intValue());\r
-        out.writeShort(message.getHardTimeout().intValue());\r
-        out.writeShort(message.getPriority());\r
-        out.writeInt(message.getBufferId().intValue());\r
-        out.writeInt(message.getOutPort().getValue().intValue());\r
-        out.writeInt(message.getOutGroup().intValue());\r
-        out.writeShort(createFlowModFlagsBitmask(message.getFlags()));\r
-        ByteBufUtils.padBuffer(PADDING_IN_FLOW_MOD_MESSAGE, out);\r
-        MatchSerializer.encodeMatch(message.getMatch(), out);\r
-        InstructionsSerializer.encodeInstructions(message.getInstructions(), out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(FlowModInput message) {\r
-        return MESSAGE_LENGTH + MatchSerializer.computeMatchLength(message.getMatch())\r
-                + InstructionsSerializer.computeInstructionsLength(message.getInstructions());\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-    private static int createFlowModFlagsBitmask(FlowModFlags flags) {\r
-        int flowModFlagBitmask = 0;\r
-        Map<Integer, Boolean> flowModFlagsMap = new HashMap<>();\r
-        flowModFlagsMap.put(0, flags.isOFPFFSENDFLOWREM());\r
-        flowModFlagsMap.put(1, flags.isOFPFFCHECKOVERLAP());\r
-        flowModFlagsMap.put(2, flags.isOFPFFRESETCOUNTS());\r
-        flowModFlagsMap.put(3, flags.isOFPFFNOPKTCOUNTS());\r
-        flowModFlagsMap.put(4, flags.isOFPFFNOBYTCOUNTS());\r
-        \r
-        flowModFlagBitmask = ByteBufUtils.fillBitMaskFromMap(flowModFlagsMap);\r
-        return flowModFlagBitmask;\r
-    }\r
-    \r
-    \r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionsSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.MatchSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+
+/**
+ * Translates FlowMod messages
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class FlowModInputMessageFactory implements OFSerializer<FlowModInput> {
+    private static final byte MESSAGE_TYPE = 14;
+    private static final byte PADDING_IN_FLOW_MOD_MESSAGE = 2;
+    private static final int MESSAGE_LENGTH = 48;
+    private static FlowModInputMessageFactory instance;
+   
+    private FlowModInputMessageFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized FlowModInputMessageFactory getInstance() {
+        if(instance == null) {
+            instance = new FlowModInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, FlowModInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeLong(message.getCookie().longValue());
+        out.writeLong(message.getCookieMask().longValue());
+        out.writeByte(message.getTableId().getValue().byteValue());
+        out.writeByte(message.getCommand().getIntValue());
+        out.writeShort(message.getIdleTimeout().intValue());
+        out.writeShort(message.getHardTimeout().intValue());
+        out.writeShort(message.getPriority());
+        out.writeInt(message.getBufferId().intValue());
+        out.writeInt(message.getOutPort().getValue().intValue());
+        out.writeInt(message.getOutGroup().intValue());
+        out.writeShort(createFlowModFlagsBitmask(message.getFlags()));
+        ByteBufUtils.padBuffer(PADDING_IN_FLOW_MOD_MESSAGE, out);
+        MatchSerializer.encodeMatch(message.getMatch(), out);
+        InstructionsSerializer.encodeInstructions(message.getInstructions(), out);
+    }
+
+    @Override
+    public int computeLength(FlowModInput message) {
+        return MESSAGE_LENGTH + MatchSerializer.computeMatchLength(message.getMatch())
+                + InstructionsSerializer.computeInstructionsLength(message.getInstructions());
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+    private static int createFlowModFlagsBitmask(FlowModFlags flags) {
+        int flowModFlagBitmask = 0;
+        Map<Integer, Boolean> flowModFlagsMap = new HashMap<>();
+        flowModFlagsMap.put(0, flags.isOFPFFSENDFLOWREM());
+        flowModFlagsMap.put(1, flags.isOFPFFCHECKOVERLAP());
+        flowModFlagsMap.put(2, flags.isOFPFFRESETCOUNTS());
+        flowModFlagsMap.put(3, flags.isOFPFFNOPKTCOUNTS());
+        flowModFlagsMap.put(4, flags.isOFPFFNOBYTCOUNTS());
+        
+        flowModFlagBitmask = ByteBufUtils.fillBitMaskFromMap(flowModFlagsMap);
+        return flowModFlagBitmask;
+    }
+    
+    
+}
index e1f3a8cc37e603ab5b7d5ef8a9bd7d5f84ed0844..a4a1a59e06a5045d21ab4648fae7ee7469e308fb 100644 (file)
@@ -1,50 +1,57 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;\r
-\r
-/**\r
- * Translates GetAsyncRequest messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class GetAsyncRequestMessageFactory implements OFSerializer<GetAsyncInput> {\r
-    private static final byte MESSAGE_TYPE = 26;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-    private static GetAsyncRequestMessageFactory instance;\r
-    \r
-    private GetAsyncRequestMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized GetAsyncRequestMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new GetAsyncRequestMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            GetAsyncInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-    }\r
-    \r
-    @Override\r
-    public int computeLength(GetAsyncInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-    \r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;
+
+/**
+ * Translates GetAsyncRequest messages
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class GetAsyncRequestMessageFactory implements OFSerializer<GetAsyncInput> {
+    private static final byte MESSAGE_TYPE = 26;
+    private static final int MESSAGE_LENGTH = 8;
+    private static GetAsyncRequestMessageFactory instance;
+    
+    private GetAsyncRequestMessageFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized GetAsyncRequestMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new GetAsyncRequestMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            GetAsyncInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+    }
+    
+    @Override
+    public int computeLength(GetAsyncInput message) {
+        return MESSAGE_LENGTH;
+    }
+    
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+}
index bea1eeb6f4c74fb46faf8417e45ebe4cdbb939cc..23898ff89f7c18fb3ceb901ba6090920e7c19d1e 100644 (file)
@@ -1,52 +1,59 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;\r
-\r
-/**\r
- * Translates GetConfigRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class GetConfigInputMessageFactory implements OFSerializer<GetConfigInput> {\r
-\r
-    /** Code type of GetConfigRequest message */\r
-    public static final byte MESSAGE_TYPE = 7;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-    private static GetConfigInputMessageFactory instance;\r
-    \r
-    private GetConfigInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized GetConfigInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new GetConfigInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            GetConfigInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(GetConfigInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;
+
+/**
+ * Translates GetConfigRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class GetConfigInputMessageFactory implements OFSerializer<GetConfigInput> {
+
+    /** Code type of GetConfigRequest message */
+    public static final byte MESSAGE_TYPE = 7;
+    private static final int MESSAGE_LENGTH = 8;
+    private static GetConfigInputMessageFactory instance;
+    
+    private GetConfigInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized GetConfigInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new GetConfigInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            GetConfigInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+    }
+
+    @Override
+    public int computeLength(GetConfigInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+}
index ff29f4d5adfc13d7f67421601b9e99ed42213df2..d1f82df2c01271413881bfca4c96fb4422bceccf 100644 (file)
@@ -1,52 +1,59 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;\r
-\r
-/**\r
- * Translates FeaturesRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class GetFeaturesInputMessageFactory implements OFSerializer<GetFeaturesInput>{\r
-\r
-    /** Code type of FeaturesRequest message */\r
-    public static final byte MESSAGE_TYPE = 5;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-    private static GetFeaturesInputMessageFactory instance;\r
-    \r
-    private GetFeaturesInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized GetFeaturesInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new GetFeaturesInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            GetFeaturesInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(GetFeaturesInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
+
+/**
+ * Translates FeaturesRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class GetFeaturesInputMessageFactory implements OFSerializer<GetFeaturesInput>{
+
+    /** Code type of FeaturesRequest message */
+    public static final byte MESSAGE_TYPE = 5;
+    private static final int MESSAGE_LENGTH = 8;
+    private static GetFeaturesInputMessageFactory instance;
+    
+    private GetFeaturesInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized GetFeaturesInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new GetFeaturesInputMessageFactory();
+        }
+        return instance;
+    }
+
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            GetFeaturesInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+    }
+
+    @Override
+    public int computeLength(GetFeaturesInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+}
index d5c8d5b19945848af02a3fbb2577f05477f54451..5a87ec368e70f5dd97f6ab40cf3940f8b150dee1 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.serialization.factories;
 
 import io.netty.buffer.ByteBuf;
index 0f9b09ee304fa78f7897bf51da826668adbcd35d..a9a2c510d2b3d801a12dfc0f5b9053e9aad2e56d 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.List;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ActionsSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsList;\r
-\r
-/**\r
- * Translates GroupMod messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class GroupModInputMessageFactory implements OFSerializer<GroupModInput> {\r
-    private static final byte MESSAGE_TYPE = 15;\r
-    private static final int MESSAGE_LENGTH = 16;\r
-    private static final byte PADDING_IN_GROUP_MOD_MESSAGE = 1;\r
-    private static final byte LENGTH_OF_BUCKET_STRUCTURE = 16;\r
-    private static final byte PADDING_IN_BUCKET = 4;\r
-    private static GroupModInputMessageFactory instance;\r
-\r
-    private GroupModInputMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized GroupModInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new GroupModInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            GroupModInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeShort(message.getCommand().getIntValue());\r
-        out.writeByte(message.getType().getIntValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_GROUP_MOD_MESSAGE, out);\r
-        out.writeInt(message.getGroupId().getValue().intValue());\r
-        encodeBuckets(message.getBucketsList(), out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(GroupModInput message) {\r
-        return MESSAGE_LENGTH + computeLengthOfBuckets(message.getBucketsList());\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-    \r
-    private static void encodeBuckets(List<BucketsList> buckets, ByteBuf outBuffer) {\r
-        if (buckets != null) {\r
-            for (BucketsList currentBucket : buckets) {\r
-                outBuffer.writeShort(computeLengthOfBucket(currentBucket));\r
-                outBuffer.writeShort(currentBucket.getWeight().shortValue());\r
-                outBuffer.writeInt(currentBucket.getWatchPort().getValue().intValue());\r
-                outBuffer.writeInt(currentBucket.getWatchGroup().intValue());\r
-                ByteBufUtils.padBuffer(PADDING_IN_BUCKET, outBuffer);\r
-                ActionsSerializer.encodeActions(currentBucket.getActionsList(), outBuffer);\r
-            }\r
-        }\r
-    }\r
-    \r
-    private static int computeLengthOfBucket(BucketsList bucket) {\r
-        int lengthOfBuckets = 0;\r
-        if (bucket != null) {\r
-            lengthOfBuckets = LENGTH_OF_BUCKET_STRUCTURE + ActionsSerializer.computeLengthOfActions(bucket.getActionsList());\r
-        }\r
-        return lengthOfBuckets;\r
-    }\r
-    \r
-    private static int computeLengthOfBuckets(List<BucketsList> buckets) {\r
-        int lengthOfBuckets = 0;\r
-        if (buckets != null) {\r
-            for (BucketsList currentBucket : buckets) {\r
-                lengthOfBuckets += LENGTH_OF_BUCKET_STRUCTURE + ActionsSerializer.computeLengthOfActions(currentBucket.getActionsList());\r
-            }\r
-        }\r
-        return lengthOfBuckets;\r
-    }\r
-\r
-    \r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.List;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionsSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsList;
+
+/**
+ * Translates GroupMod messages
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class GroupModInputMessageFactory implements OFSerializer<GroupModInput> {
+    private static final byte MESSAGE_TYPE = 15;
+    private static final int MESSAGE_LENGTH = 16;
+    private static final byte PADDING_IN_GROUP_MOD_MESSAGE = 1;
+    private static final byte LENGTH_OF_BUCKET_STRUCTURE = 16;
+    private static final byte PADDING_IN_BUCKET = 4;
+    private static GroupModInputMessageFactory instance;
+
+    private GroupModInputMessageFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized GroupModInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new GroupModInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            GroupModInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeShort(message.getCommand().getIntValue());
+        out.writeByte(message.getType().getIntValue());
+        ByteBufUtils.padBuffer(PADDING_IN_GROUP_MOD_MESSAGE, out);
+        out.writeInt(message.getGroupId().getValue().intValue());
+        encodeBuckets(message.getBucketsList(), out);
+    }
+
+    @Override
+    public int computeLength(GroupModInput message) {
+        return MESSAGE_LENGTH + computeLengthOfBuckets(message.getBucketsList());
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+    
+    private static void encodeBuckets(List<BucketsList> buckets, ByteBuf outBuffer) {
+        if (buckets != null) {
+            for (BucketsList currentBucket : buckets) {
+                outBuffer.writeShort(computeLengthOfBucket(currentBucket));
+                outBuffer.writeShort(currentBucket.getWeight().shortValue());
+                outBuffer.writeInt(currentBucket.getWatchPort().getValue().intValue());
+                outBuffer.writeInt(currentBucket.getWatchGroup().intValue());
+                ByteBufUtils.padBuffer(PADDING_IN_BUCKET, outBuffer);
+                ActionsSerializer.encodeActions(currentBucket.getActionsList(), outBuffer);
+            }
+        }
+    }
+    
+    private static int computeLengthOfBucket(BucketsList bucket) {
+        int lengthOfBuckets = 0;
+        if (bucket != null) {
+            lengthOfBuckets = LENGTH_OF_BUCKET_STRUCTURE + ActionsSerializer.computeLengthOfActions(bucket.getActionsList());
+        }
+        return lengthOfBuckets;
+    }
+    
+    private static int computeLengthOfBuckets(List<BucketsList> buckets) {
+        int lengthOfBuckets = 0;
+        if (buckets != null) {
+            for (BucketsList currentBucket : buckets) {
+                lengthOfBuckets += LENGTH_OF_BUCKET_STRUCTURE + ActionsSerializer.computeLengthOfActions(currentBucket.getActionsList());
+            }
+        }
+        return lengthOfBuckets;
+    }
+
+    
+}
index 1a35932809efe910cd2b250f58d5e25c78de9ce8..a0ffc2dd9354268dabd26e99cc1aeaf010889baa 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.List;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * Translates Hello messages\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class HelloInputMessageFactory implements OFSerializer<HelloInput>{\r
-\r
-    /** Code type of Hello message */\r
-    private static final byte MESSAGE_TYPE = 0;\r
-    private static int MESSAGE_LENGTH = 8;\r
-    /** Size of hello element header (in bytes) */\r
-    public static final byte HELLO_ELEMENT_HEADER_SIZE = 4;\r
-    private static HelloInputMessageFactory instance;\r
-    \r
-    private static final Logger LOGGER = LoggerFactory\r
-            .getLogger(HelloInputMessageFactory.class);\r
-    \r
-    \r
-    private HelloInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized HelloInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new HelloInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, HelloInput message) {\r
-        int startWriterIndex = out.writerIndex();\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        encodeElementsList(message, out);\r
-        int endWriterIndex = out.writerIndex();\r
-        int writtenBytesDiff = computeLength(message) - (endWriterIndex - startWriterIndex);\r
-        LOGGER.debug("writtenbytes: " + writtenBytesDiff);\r
-        ByteBufUtils.padBuffer(writtenBytesDiff, out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(HelloInput message) {\r
-        int length = MESSAGE_LENGTH;\r
-        List<Elements> elements = message.getElements();\r
-        if (elements != null) {\r
-            for (Elements element : elements) {\r
-                if (HelloElementType.VERSIONBITMAP.equals(element.getType())) {\r
-                    int bitmapLength = computeVersionBitmapLength(element);\r
-                    int paddingRemainder = bitmapLength % EncodeConstants.PADDING;\r
-                    if (paddingRemainder != 0) {\r
-                        bitmapLength += EncodeConstants.PADDING - paddingRemainder;\r
-                    }\r
-                    length += bitmapLength;\r
-                }\r
-            }\r
-        }\r
-        return length;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-    \r
-    private static void encodeElementsList(HelloInput message, ByteBuf output) {\r
-        int[] versionBitmap;\r
-        if (message.getElements() != null) {\r
-            for (Elements currElement : message.getElements()) {\r
-                output.writeShort(currElement.getType().getIntValue());\r
-                if (currElement.getType().equals(HelloElementType.VERSIONBITMAP)) {\r
-                    short bitmapLength = computeVersionBitmapLength(currElement);\r
-                    output.writeShort(bitmapLength);\r
-                    versionBitmap = ByteBufUtils.fillBitMaskFromList(currElement.getVersionBitmap());\r
-                    LOGGER.debug("vbs: " + versionBitmap.length);\r
-                    LOGGER.debug("Version bitmap (below):");\r
-                    for (int i = 0; i < versionBitmap.length; i++) {\r
-                        LOGGER.debug(Integer.toBinaryString(versionBitmap[i]));\r
-                        output.writeInt(versionBitmap[i]);\r
-                    }\r
-                    int padding = bitmapLength - versionBitmap.length * 4 - HELLO_ELEMENT_HEADER_SIZE;\r
-                    ByteBufUtils.padBuffer(padding , output);\r
-                }\r
-            } \r
-        }\r
-    }\r
-    \r
-    private static short computeVersionBitmapLength(Elements element) {\r
-        short elementlength = HELLO_ELEMENT_HEADER_SIZE;\r
-        if (!element.getVersionBitmap().isEmpty()) {\r
-            elementlength += ((element.getVersionBitmap().size() - 1) / Integer.SIZE + 1) * (EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-        }\r
-        return elementlength;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.List;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+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.HelloElementType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Translates Hello messages
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class HelloInputMessageFactory implements OFSerializer<HelloInput>{
+
+    /** Code type of Hello message */
+    private static final byte MESSAGE_TYPE = 0;
+    private static int MESSAGE_LENGTH = 8;
+    /** Size of hello element header (in bytes) */
+    public static final byte HELLO_ELEMENT_HEADER_SIZE = 4;
+    private static HelloInputMessageFactory instance;
+    
+    private static final Logger LOGGER = LoggerFactory
+            .getLogger(HelloInputMessageFactory.class);
+    
+    
+    private HelloInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized HelloInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new HelloInputMessageFactory();
+        }
+        return instance;
+    }
+
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, HelloInput message) {
+        int startWriterIndex = out.writerIndex();
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        encodeElementsList(message, out);
+        int endWriterIndex = out.writerIndex();
+        int writtenBytesDiff = computeLength(message) - (endWriterIndex - startWriterIndex);
+        LOGGER.debug("writtenbytes: " + writtenBytesDiff);
+        ByteBufUtils.padBuffer(writtenBytesDiff, out);
+    }
+
+    @Override
+    public int computeLength(HelloInput message) {
+        int length = MESSAGE_LENGTH;
+        List<Elements> elements = message.getElements();
+        if (elements != null) {
+            for (Elements element : elements) {
+                if (HelloElementType.VERSIONBITMAP.equals(element.getType())) {
+                    int bitmapLength = computeVersionBitmapLength(element);
+                    int paddingRemainder = bitmapLength % EncodeConstants.PADDING;
+                    if (paddingRemainder != 0) {
+                        bitmapLength += EncodeConstants.PADDING - paddingRemainder;
+                    }
+                    length += bitmapLength;
+                }
+            }
+        }
+        return length;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+    
+    private static void encodeElementsList(HelloInput message, ByteBuf output) {
+        int[] versionBitmap;
+        if (message.getElements() != null) {
+            for (Elements currElement : message.getElements()) {
+                output.writeShort(currElement.getType().getIntValue());
+                if (currElement.getType().equals(HelloElementType.VERSIONBITMAP)) {
+                    short bitmapLength = computeVersionBitmapLength(currElement);
+                    output.writeShort(bitmapLength);
+                    versionBitmap = ByteBufUtils.fillBitMaskFromList(currElement.getVersionBitmap());
+                    LOGGER.debug("vbs: " + versionBitmap.length);
+                    LOGGER.debug("Version bitmap (below):");
+                    for (int i = 0; i < versionBitmap.length; i++) {
+                        LOGGER.debug(Integer.toBinaryString(versionBitmap[i]));
+                        output.writeInt(versionBitmap[i]);
+                    }
+                    int padding = bitmapLength - versionBitmap.length * 4 - HELLO_ELEMENT_HEADER_SIZE;
+                    ByteBufUtils.padBuffer(padding , output);
+                }
+            } 
+        }
+    }
+    
+    private static short computeVersionBitmapLength(Elements element) {
+        short elementlength = HELLO_ELEMENT_HEADER_SIZE;
+        if (!element.getVersionBitmap().isEmpty()) {
+            elementlength += ((element.getVersionBitmap().size() - 1) / Integer.SIZE + 1) * (EncodeConstants.SIZE_OF_INT_IN_BYTES);
+        }
+        return elementlength;
+    }
+}
index 30c91ab28699cdbbdfd0948e8f19dbfb09a35648..71e318c78ff5fb1a56ee5e3849db834e923bb96d 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterBandCommons;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDrop;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemark;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands;\r
-\r
-/**\r
- * Translates MeterMod messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class MeterModInputMessageFactory implements OFSerializer<MeterModInput> {\r
-    private static final byte MESSAGE_TYPE = 29;\r
-    private static final int MESSAGE_LENGTH = 16;\r
-    private static final short LENGTH_OF_METER_BANDS = 16;\r
-    private static final short PADDING_IN_METER_BAND_DROP = 4;\r
-    private static final short PADDING_IN_METER_BAND_DSCP_REMARK = 3;\r
-    private static MeterModInputMessageFactory instance;\r
-    \r
-    private MeterModInputMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized MeterModInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new MeterModInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            MeterModInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeShort(message.getCommand().getIntValue());\r
-        out.writeShort(createMeterFlagsBitmask(message.getFlags()));\r
-        out.writeInt(message.getMeterId().getValue().intValue());\r
-        encodeBands(message.getBands(), out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(MeterModInput message) {\r
-        int length = MESSAGE_LENGTH;\r
-        if (message.getBands() != null) {\r
-            length += message.getBands().size() * LENGTH_OF_METER_BANDS;\r
-        }\r
-        return length;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-    private static int createMeterFlagsBitmask(MeterFlags flags) {\r
-        int meterFlagBitmask = 0;\r
-        Map<Integer, Boolean> meterModFlagsMap = new HashMap<>();\r
-        meterModFlagsMap.put(0, flags.isOFPMFKBPS());\r
-        meterModFlagsMap.put(1, flags.isOFPMFPKTPS());\r
-        meterModFlagsMap.put(2, flags.isOFPMFBURST());\r
-        meterModFlagsMap.put(3, flags.isOFPMFSTATS());\r
-        \r
-        meterFlagBitmask = ByteBufUtils.fillBitMaskFromMap(meterModFlagsMap);\r
-        return meterFlagBitmask;\r
-    }\r
-    \r
-    private static void encodeBands(List<Bands> bands, ByteBuf outBuffer) {\r
-        if (bands != null) {\r
-            for (Bands currentBand : bands) {\r
-                MeterBand meterBand = currentBand.getMeterBand();\r
-                writeBandCommonFields((MeterBandCommons) meterBand, outBuffer);\r
-                if (meterBand instanceof MeterBandDrop) {\r
-                    ByteBufUtils.padBuffer(PADDING_IN_METER_BAND_DROP, outBuffer);\r
-                } else if (meterBand instanceof MeterBandDscpRemark) {\r
-                    MeterBandDscpRemark dscpRemarkBand = (MeterBandDscpRemark) meterBand;\r
-                    outBuffer.writeByte(dscpRemarkBand.getPrecLevel());\r
-                    ByteBufUtils.padBuffer(PADDING_IN_METER_BAND_DSCP_REMARK, outBuffer);\r
-                } else if (meterBand instanceof MeterBandExperimenter) {\r
-                    MeterBandExperimenter experimenterBand = (MeterBandExperimenter) meterBand;\r
-                    outBuffer.writeInt(experimenterBand.getExperimenter().intValue());\r
-                }\r
-            }\r
-        }\r
-    }\r
-    \r
-    private static void writeBandCommonFields(MeterBandCommons meterBand, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(meterBand.getType().getIntValue());\r
-        outBuffer.writeShort(LENGTH_OF_METER_BANDS);\r
-        outBuffer.writeInt(meterBand.getRate().intValue());\r
-        outBuffer.writeInt(meterBand.getBurstSize().intValue());\r
-    }\r
-    \r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterBandCommons;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDrop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemark;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands;
+
+/**
+ * Translates MeterMod messages
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class MeterModInputMessageFactory implements OFSerializer<MeterModInput> {
+    private static final byte MESSAGE_TYPE = 29;
+    private static final int MESSAGE_LENGTH = 16;
+    private static final short LENGTH_OF_METER_BANDS = 16;
+    private static final short PADDING_IN_METER_BAND_DROP = 4;
+    private static final short PADDING_IN_METER_BAND_DSCP_REMARK = 3;
+    private static MeterModInputMessageFactory instance;
+    
+    private MeterModInputMessageFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized MeterModInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new MeterModInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            MeterModInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeShort(message.getCommand().getIntValue());
+        out.writeShort(createMeterFlagsBitmask(message.getFlags()));
+        out.writeInt(message.getMeterId().getValue().intValue());
+        encodeBands(message.getBands(), out);
+    }
+
+    @Override
+    public int computeLength(MeterModInput message) {
+        int length = MESSAGE_LENGTH;
+        if (message.getBands() != null) {
+            length += message.getBands().size() * LENGTH_OF_METER_BANDS;
+        }
+        return length;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+    private static int createMeterFlagsBitmask(MeterFlags flags) {
+        int meterFlagBitmask = 0;
+        Map<Integer, Boolean> meterModFlagsMap = new HashMap<>();
+        meterModFlagsMap.put(0, flags.isOFPMFKBPS());
+        meterModFlagsMap.put(1, flags.isOFPMFPKTPS());
+        meterModFlagsMap.put(2, flags.isOFPMFBURST());
+        meterModFlagsMap.put(3, flags.isOFPMFSTATS());
+        
+        meterFlagBitmask = ByteBufUtils.fillBitMaskFromMap(meterModFlagsMap);
+        return meterFlagBitmask;
+    }
+    
+    private static void encodeBands(List<Bands> bands, ByteBuf outBuffer) {
+        if (bands != null) {
+            for (Bands currentBand : bands) {
+                MeterBand meterBand = currentBand.getMeterBand();
+                writeBandCommonFields((MeterBandCommons) meterBand, outBuffer);
+                if (meterBand instanceof MeterBandDrop) {
+                    ByteBufUtils.padBuffer(PADDING_IN_METER_BAND_DROP, outBuffer);
+                } else if (meterBand instanceof MeterBandDscpRemark) {
+                    MeterBandDscpRemark dscpRemarkBand = (MeterBandDscpRemark) meterBand;
+                    outBuffer.writeByte(dscpRemarkBand.getPrecLevel());
+                    ByteBufUtils.padBuffer(PADDING_IN_METER_BAND_DSCP_REMARK, outBuffer);
+                } else if (meterBand instanceof MeterBandExperimenter) {
+                    MeterBandExperimenter experimenterBand = (MeterBandExperimenter) meterBand;
+                    outBuffer.writeInt(experimenterBand.getExperimenter().intValue());
+                }
+            }
+        }
+    }
+    
+    private static void writeBandCommonFields(MeterBandCommons meterBand, ByteBuf outBuffer) {
+        outBuffer.writeShort(meterBand.getType().getIntValue());
+        outBuffer.writeShort(LENGTH_OF_METER_BANDS);
+        outBuffer.writeInt(meterBand.getRate().intValue());
+        outBuffer.writeInt(meterBand.getBurstSize().intValue());
+    }
+    
+}
index 5a17239b6213768c9a319bd52d6c1de267d17c04..d982f3f44b5113f5e737159d87a6584ffcb9b37d 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ActionsSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.openflowjava.protocol.impl.util.InstructionsSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.MatchSerializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregate;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlow;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroup;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTable;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features.TableFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeatureProperties;\r
-\r
-/**\r
- * Translates MultipartRequest messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class MultipartRequestInputFactory implements OFSerializer<MultipartRequestInput> {\r
-    private static final byte MESSAGE_TYPE = 18;\r
-    private static final int MESSAGE_LENGTH = 16;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = 4;\r
-    private static final byte TABLE_FEAT_HEADER_LENGTH = 4;\r
-    private static MultipartRequestInputFactory instance;\r
-    private static final byte INSTRUCTIONS_CODE = 0;\r
-    private static final byte INSTRUCTIONS_MISS_CODE = 1;\r
-    private static final byte NEXT_TABLE_CODE = 2;\r
-    private static final byte NEXT_TABLE_MISS_CODE = 3;\r
-    private static final byte WRITE_ACTIONS_CODE = 4;\r
-    private static final byte WRITE_ACTIONS_MISS_CODE = 5;\r
-    private static final byte APPLY_ACTIONS_CODE = 6;\r
-    private static final byte APPLY_ACTIONS_MISS_CODE = 7;\r
-    private static final byte MATCH_CODE = 8;\r
-    private static final byte WILDCARDS_CODE = 10;\r
-    private static final byte WRITE_SETFIELD_CODE = 12;\r
-    private static final byte WRITE_SETFIELD_MISS_CODE = 13;\r
-    private static final byte APPLY_SETFIELD_CODE = 14;\r
-    private static final byte APPLY_SETFIELD_MISS_CODE = 15;\r
-    private static final int EXPERIMENTER_CODE = 65534; // 0xFFFE\r
-    private static final int EXPERIMENTER_MISS_CODE = 65535; // 0xFFFF\r
-    private static final byte FLOW_BODY_LENGTH = 32;\r
-    private static final byte AGGREGATE_BODY_LENGTH = 32;\r
-    private static final byte PORT_STATS_BODY_LENGTH = 8;\r
-    private static final byte QUEUE_BODY_LENGTH = 8;\r
-    private static final byte GROUP_BODY_LENGTH = 8;\r
-    private static final byte METER_BODY_LENGTH = 8;\r
-    private static final byte METER_CONFIG_BODY_LENGTH = 8;\r
-    private static final byte EXPERIMENTER_BODY_LENGTH = 8;\r
-    private static final byte TABLE_FEATURES_LENGTH = 64;\r
-    private static final byte STRUCTURE_HEADER_LENGTH = 4;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01 = 3;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02 = 4;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_01 = 3;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_02 = 4;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY = 4;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_GROUP_BODY = 4;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_METER_BODY = 4;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY = 4;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY = 5;\r
-    \r
-\r
-\r
-    private MultipartRequestInputFactory() {\r
-        // singleton\r
-    }\r
-\r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized MultipartRequestInputFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new MultipartRequestInputFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            MultipartRequestInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeShort(message.getType().getIntValue());\r
-        out.writeShort(createMultipartRequestFlagsBitmask(message.getFlags()));\r
-        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_MESSAGE, out);\r
-\r
-        if (message.getMultipartRequestBody() instanceof MultipartRequestDesc ){\r
-            encodeDescBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestFlow) {\r
-            encodeFlowBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestAggregate) {\r
-            encodeAggregateBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestTable) {\r
-            encodeTableBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestPortStats) {\r
-            encodePortStatsBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestQueue) {\r
-            encodeQueueBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestGroup) {\r
-            encodeGroupStatsBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestGroupDesc) {\r
-            encodeGroupDescBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestGroupFeatures) {\r
-            encodeGroupFeaturesBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestMeter) {\r
-            encodeMeterBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestMeterConfig) {\r
-            encodeMeterConfigBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestMeterFeatures) {\r
-            encodeMeterFeaturesBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestTableFeatures) {\r
-            encodeTableFeaturesBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestPortDesc) {\r
-            encodePortDescBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestExperimenter) {\r
-            encodeExperimenterBody(message.getMultipartRequestBody(), out);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(MultipartRequestInput message) {\r
-        return MESSAGE_LENGTH + computeBodyLength(message);\r
-    }\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-    /**\r
-     *\r
-     * @param message\r
-     * @return length of MultipartRequestMessage\r
-     */\r
-    public int computeBodyLength(MultipartRequestInput message) {\r
-        int length = 0;\r
-        MultipartType type = message.getType();\r
-        if (type.equals(MultipartType.OFPMPFLOW)) {\r
-            MultipartRequestFlow body = (MultipartRequestFlow) message.getMultipartRequestBody();\r
-            length += FLOW_BODY_LENGTH + MatchSerializer.computeMatchLength(body.getMatch());\r
-        } else if (type.equals(MultipartType.OFPMPAGGREGATE)) {\r
-            MultipartRequestAggregate body = (MultipartRequestAggregate) message.getMultipartRequestBody();\r
-            length += AGGREGATE_BODY_LENGTH + MatchSerializer.computeMatchLength(body.getMatch());\r
-        } else if (type.equals(MultipartType.OFPMPPORTSTATS)) {\r
-            length += PORT_STATS_BODY_LENGTH;\r
-        } else if (type.equals(MultipartType.OFPMPQUEUE)) {\r
-            length += QUEUE_BODY_LENGTH;\r
-        } else if (type.equals(MultipartType.OFPMPGROUP)) {\r
-            length += GROUP_BODY_LENGTH;\r
-        } else if (type.equals(MultipartType.OFPMPMETER)) {\r
-            length += METER_BODY_LENGTH;\r
-        } else if (type.equals(MultipartType.OFPMPMETERCONFIG)) {\r
-            length += METER_CONFIG_BODY_LENGTH;\r
-        } else if (type.equals(MultipartType.OFPMPTABLEFEATURES)) {\r
-            MultipartRequestTableFeatures body = (MultipartRequestTableFeatures) message.getMultipartRequestBody();\r
-            length += computeTableFeaturesLength(body);\r
-        } else if (type.equals(MultipartType.OFPMPEXPERIMENTER)) {\r
-            MultipartRequestExperimenter body = (MultipartRequestExperimenter) message.getMultipartRequestBody();\r
-            length += EXPERIMENTER_BODY_LENGTH;\r
-            if (body.getData() != null) {\r
-                length += body.getData().length;\r
-            }\r
-        }\r
-        return length;\r
-    }\r
-\r
-    private static int computeTableFeaturesLength(MultipartRequestTableFeatures body) {\r
-        int length = 0;\r
-        if (body != null && body.getTableFeatures() != null) {\r
-            List<TableFeatures> tableFeatures = body.getTableFeatures();\r
-            for (TableFeatures feature : tableFeatures) {\r
-                length += TABLE_FEATURES_LENGTH;\r
-                List<TableFeatureProperties> featureProperties = feature.getTableFeatureProperties();\r
-                if (featureProperties != null) {\r
-                    for (TableFeatureProperties featProp : featureProperties) {\r
-                        length += TABLE_FEAT_HEADER_LENGTH;\r
-                        if (featProp.getAugmentation(InstructionRelatedTableFeatureProperty.class) != null) {\r
-                            InstructionRelatedTableFeatureProperty property =\r
-                                    featProp.getAugmentation(InstructionRelatedTableFeatureProperty.class);\r
-                            length += property.getInstructions().size() * STRUCTURE_HEADER_LENGTH;\r
-                        } else if (featProp.getAugmentation(NextTableRelatedTableFeatureProperty.class) != null) {\r
-                            NextTableRelatedTableFeatureProperty property =\r
-                                    featProp.getAugmentation(NextTableRelatedTableFeatureProperty.class);\r
-                            length += property.getNextTableIds().size();\r
-                        } else if (featProp.getAugmentation(ActionRelatedTableFeatureProperty.class) != null) {\r
-                            ActionRelatedTableFeatureProperty property =\r
-                                    featProp.getAugmentation(ActionRelatedTableFeatureProperty.class);\r
-                            length += property.getActionsList().size() * STRUCTURE_HEADER_LENGTH;\r
-                        } else if (featProp.getAugmentation(OxmRelatedTableFeatureProperty.class) != null) {\r
-                            OxmRelatedTableFeatureProperty property =\r
-                                    featProp.getAugmentation(OxmRelatedTableFeatureProperty.class);\r
-                            length += property.getMatchEntries().size() * STRUCTURE_HEADER_LENGTH;\r
-                        } else if (featProp.getAugmentation(ExperimenterRelatedTableFeatureProperty.class) != null) {\r
-                            ExperimenterRelatedTableFeatureProperty property =\r
-                                    featProp.getAugmentation(ExperimenterRelatedTableFeatureProperty.class);\r
-                            length += 2 * (EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                            if (property.getData() != null) {\r
-                                length += property.getData().length;\r
-                            }\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return length;\r
-    }\r
-\r
-    private static int createMultipartRequestFlagsBitmask(MultipartRequestFlags flags) {\r
-        int multipartRequestFlagsBitmask = 0;\r
-        Map<Integer, Boolean> multipartRequestFlagsMap = new HashMap<>();\r
-        multipartRequestFlagsMap.put(0, flags.isOFPMPFREQMORE());\r
-\r
-        multipartRequestFlagsBitmask = ByteBufUtils.fillBitMaskFromMap(multipartRequestFlagsMap);\r
-        return multipartRequestFlagsBitmask;\r
-    }\r
-\r
-    /**\r
-     * @param multipartRequestBody\r
-     * @param output\r
-     */\r
-    private void encodeDescBody(MultipartRequestBody multipartRequestBody,\r
-            ByteBuf output) {\r
-        // The body of MultiPartRequestDesc is empty\r
-    }\r
-\r
-    /**\r
-     * @param multipartRequestBody\r
-     * @param out\r
-     */\r
-    private void encodeTableBody(MultipartRequestBody multipartRequestBody,\r
-            ByteBuf out) {\r
-     // The body of MultiPartTable is empty\r
-    }\r
-\r
-    /**\r
-     * @param multipartRequestBody\r
-     * @param out\r
-     */\r
-    private void encodeGroupDescBody(MultipartRequestBody multipartRequestBody,\r
-            ByteBuf out) {\r
-     // The body of MultiPartRequestGroupDesc is empty\r
-    }\r
-\r
-    /**\r
-     * @param multipartRequestBody\r
-     * @param out\r
-     */\r
-    private void encodeGroupFeaturesBody(\r
-            MultipartRequestBody multipartRequestBody, ByteBuf out) {\r
-     // The body of MultiPartRequestGroupFeatures is empty\r
-    }\r
-\r
-    /**\r
-     * @param multipartRequestBody\r
-     * @param out\r
-     */\r
-    private void encodeMeterFeaturesBody(\r
-            MultipartRequestBody multipartRequestBody, ByteBuf out) {\r
-     // The body of MultiPartMeterFeatures is empty\r
-    }\r
-\r
-    /**\r
-     * @param multipartRequestBody\r
-     * @param out\r
-     */\r
-    private void encodePortDescBody(MultipartRequestBody multipartRequestBody,\r
-            ByteBuf out) {\r
-     // The body of MultiPartPortDesc is empty\r
-    }\r
-\r
-    private static void encodeFlowBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestFlow flow = (MultipartRequestFlow) multipartRequestBody;\r
-        output.writeByte(flow.getTableId().byteValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01, output);\r
-        output.writeInt(flow.getOutPort().intValue());\r
-        output.writeInt(flow.getOutGroup().intValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02, output);\r
-        output.writeLong(flow.getCookie().longValue());\r
-        output.writeLong(flow.getCookieMask().longValue());\r
-        MatchSerializer.encodeMatch(flow.getMatch(), output);\r
-    }\r
-\r
-    private static void encodeAggregateBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestAggregate aggregate = (MultipartRequestAggregate) multipartRequestBody;\r
-        output.writeByte(aggregate.getTableId().byteValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_01, output);\r
-        output.writeInt(aggregate.getOutPort().intValue());\r
-        output.writeInt(aggregate.getOutGroup().intValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_02, output);\r
-        output.writeLong(aggregate.getCookie().longValue());\r
-        output.writeLong(aggregate.getCookieMask().longValue());\r
-        MatchSerializer.encodeMatch(aggregate.getMatch(), output);\r
-    }\r
-\r
-    private static void encodePortStatsBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestPortStats portstats = (MultipartRequestPortStats) multipartRequestBody;\r
-        output.writeInt(portstats.getPortNo().intValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY, output);\r
-    }\r
-\r
-    private static void encodeQueueBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestQueue queue = (MultipartRequestQueue) multipartRequestBody;\r
-        output.writeInt(queue.getPortNo().intValue());\r
-        output.writeInt(queue.getQueueId().intValue());\r
-    }\r
-\r
-    private static void encodeGroupStatsBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestGroup groupStats = (MultipartRequestGroup) multipartRequestBody;\r
-        output.writeInt(groupStats.getGroupId().getValue().intValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_GROUP_BODY, output);\r
-    }\r
-\r
-    private static void encodeMeterBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestMeter meter = (MultipartRequestMeter) multipartRequestBody;\r
-        output.writeInt(meter.getMeterId().getValue().intValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_METER_BODY, output);\r
-    }\r
-\r
-    private static void encodeMeterConfigBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestMeterConfig meterConfig = (MultipartRequestMeterConfig) multipartRequestBody;\r
-        output.writeInt(meterConfig.getMeterId().getValue().intValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY, output);\r
-    }\r
-\r
-    private static void encodeExperimenterBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestExperimenter experimenter = (MultipartRequestExperimenter) multipartRequestBody;\r
-        output.writeInt(experimenter.getExperimenter().intValue());\r
-        output.writeInt(experimenter.getExpType().intValue());\r
-        byte[] data = experimenter.getData();\r
-        if (data != null) {\r
-            output.writeBytes(data);\r
-        }\r
-    }\r
-\r
-    private static void encodeTableFeaturesBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        if (multipartRequestBody != null) {\r
-            MultipartRequestTableFeatures tableFeatures = (MultipartRequestTableFeatures) multipartRequestBody;\r
-            if(tableFeatures.getTableFeatures() != null) {\r
-                for (TableFeatures currTableFeature : tableFeatures.getTableFeatures()) {\r
-                    output.writeByte(currTableFeature.getTableId());\r
-                    ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY, output);\r
-                    output.writeBytes(currTableFeature.getName().getBytes());\r
-                    ByteBufUtils.padBuffer((32 - currTableFeature.getName().getBytes().length), output);\r
-                    output.writeLong(currTableFeature.getMetadataMatch().longValue());\r
-                    output.writeLong(currTableFeature.getMetadataWrite().longValue());\r
-                    output.writeInt(createTableConfigBitmask(currTableFeature.getConfig()));\r
-                    output.writeInt(currTableFeature.getMaxEntries().intValue());\r
-                    writeTableFeatureProperties(output, currTableFeature.getTableFeatureProperties());\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private static void writeTableFeatureProperties(ByteBuf output, List<TableFeatureProperties> props) {\r
-        if (props != null) {\r
-            for (TableFeatureProperties property : props) {\r
-                TableFeaturesPropType type = property.getType();\r
-                if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS)) {\r
-                    writeInstructionRelatedTableProperty(output, property, INSTRUCTIONS_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {\r
-                    writeInstructionRelatedTableProperty(output, property, INSTRUCTIONS_MISS_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES)) {\r
-                    writeNextTableRelatedTableProperty(output, property, NEXT_TABLE_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {\r
-                    writeNextTableRelatedTableProperty(output, property, NEXT_TABLE_MISS_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONS)) {\r
-                    writeActionsRelatedTableProperty(output, property, WRITE_ACTIONS_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS)) {\r
-                    writeActionsRelatedTableProperty(output, property, WRITE_ACTIONS_MISS_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS)) {\r
-                    writeActionsRelatedTableProperty(output, property, APPLY_ACTIONS_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {\r
-                    writeActionsRelatedTableProperty(output, property, APPLY_ACTIONS_MISS_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH)) {\r
-                    writeOxmRelatedTableProperty(output, property, MATCH_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS)) {\r
-                    writeOxmRelatedTableProperty(output, property, WILDCARDS_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELD)) {\r
-                    writeOxmRelatedTableProperty(output, property, WRITE_SETFIELD_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS)) {\r
-                    writeOxmRelatedTableProperty(output, property, WRITE_SETFIELD_MISS_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD)) {\r
-                    writeOxmRelatedTableProperty(output, property, APPLY_SETFIELD_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {\r
-                    writeOxmRelatedTableProperty(output, property, APPLY_SETFIELD_MISS_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)) {\r
-                    writeExperimenterRelatedTableProperty(output, property, EXPERIMENTER_CODE);\r
-                } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {\r
-                    writeExperimenterRelatedTableProperty(output, property, EXPERIMENTER_MISS_CODE);\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private static void writeInstructionRelatedTableProperty(ByteBuf output,\r
-            TableFeatureProperties property, byte code) {\r
-        output.writeShort(code);\r
-        List<Instructions> instructions = property.\r
-                getAugmentation(InstructionRelatedTableFeatureProperty.class).getInstructions();\r
-        int length = TABLE_FEAT_HEADER_LENGTH;\r
-        if (instructions != null) {\r
-        output.writeShort(InstructionsSerializer.computeInstructionsLength(instructions)\r
-                + TABLE_FEAT_HEADER_LENGTH);\r
-        InstructionsSerializer.encodeInstructions(instructions, output);\r
-        } else {\r
-            output.writeShort(length);\r
-        }\r
-    }\r
-\r
-    private static void writeNextTableRelatedTableProperty(ByteBuf output,\r
-            TableFeatureProperties property, byte code) {\r
-        output.writeShort(code);\r
-        List<NextTableIds> nextTableIds = property.\r
-                getAugmentation(NextTableRelatedTableFeatureProperty.class).getNextTableIds();\r
-        int length = TABLE_FEAT_HEADER_LENGTH;\r
-        if (nextTableIds != null) {\r
-            output.writeShort(length + nextTableIds.size());\r
-            for (NextTableIds next : nextTableIds) {\r
-                output.writeByte(next.getTableId());\r
-            }\r
-        } else {\r
-            output.writeShort(length);\r
-        }\r
-    }\r
-\r
-    private static void writeActionsRelatedTableProperty(ByteBuf output,\r
-            TableFeatureProperties property, byte code) {\r
-        output.writeShort(code);\r
-        List<ActionsList> actions = property.\r
-                getAugmentation(ActionRelatedTableFeatureProperty.class).getActionsList();\r
-        int length = TABLE_FEAT_HEADER_LENGTH;\r
-        if (actions != null) {\r
-        output.writeShort(ActionsSerializer.computeLengthOfActions(actions)\r
-                + TABLE_FEAT_HEADER_LENGTH);\r
-        ActionsSerializer.encodeActions(actions, output);\r
-        } else {\r
-            output.writeShort(length);\r
-        }\r
-    }\r
-\r
-    private static void writeOxmRelatedTableProperty(ByteBuf output,\r
-            TableFeatureProperties property, byte code) {\r
-        output.writeShort(code);\r
-        List<MatchEntries> entries = property.\r
-                getAugmentation(OxmRelatedTableFeatureProperty.class).getMatchEntries();\r
-        int length = TABLE_FEAT_HEADER_LENGTH;\r
-        if (entries != null) {\r
-        output.writeShort(MatchSerializer.computeMatchEntriesLength(entries)\r
-                + TABLE_FEAT_HEADER_LENGTH);\r
-        MatchSerializer.encodeMatchEntries(entries, output);\r
-        } else {\r
-            output.writeShort(length);\r
-        }\r
-    }\r
-\r
-    private static void writeExperimenterRelatedTableProperty(ByteBuf output,\r
-            TableFeatureProperties property, int code) {\r
-        output.writeShort(code);\r
-        ExperimenterRelatedTableFeatureProperty exp = property.\r
-                getAugmentation(ExperimenterRelatedTableFeatureProperty.class);\r
-        byte[] data = exp.getData();\r
-        int length = TABLE_FEAT_HEADER_LENGTH + 2 * (EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-        if (data != null) {\r
-            output.writeShort(length + data.length);\r
-            output.writeInt(exp.getExperimenter().intValue());\r
-            output.writeInt(exp.getExpType().intValue());\r
-            output.writeBytes(data);\r
-        } else {\r
-            output.writeShort(length);\r
-            output.writeInt(exp.getExperimenter().intValue());\r
-            output.writeInt(exp.getExpType().intValue());\r
-        }\r
-    }\r
-\r
-    private static int createTableConfigBitmask(TableConfig tableConfig) {\r
-        int tableConfigBitmask = 0;\r
-        Map<Integer, Boolean> tableConfigMap = new HashMap<>();\r
-        tableConfigMap.put(3, tableConfig.isOFPTCDEPRECATEDMASK());\r
-\r
-        tableConfigBitmask = ByteBufUtils.fillBitMaskFromMap(tableConfigMap);\r
-        return tableConfigBitmask;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionsSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionsSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.MatchSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty;
+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.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeatureProperties;
+
+/**
+ * Translates MultipartRequest messages
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class MultipartRequestInputFactory implements OFSerializer<MultipartRequestInput> {
+    private static final byte MESSAGE_TYPE = 18;
+    private static final int MESSAGE_LENGTH = 16;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = 4;
+    private static final byte TABLE_FEAT_HEADER_LENGTH = 4;
+    private static MultipartRequestInputFactory instance;
+    private static final byte INSTRUCTIONS_CODE = 0;
+    private static final byte INSTRUCTIONS_MISS_CODE = 1;
+    private static final byte NEXT_TABLE_CODE = 2;
+    private static final byte NEXT_TABLE_MISS_CODE = 3;
+    private static final byte WRITE_ACTIONS_CODE = 4;
+    private static final byte WRITE_ACTIONS_MISS_CODE = 5;
+    private static final byte APPLY_ACTIONS_CODE = 6;
+    private static final byte APPLY_ACTIONS_MISS_CODE = 7;
+    private static final byte MATCH_CODE = 8;
+    private static final byte WILDCARDS_CODE = 10;
+    private static final byte WRITE_SETFIELD_CODE = 12;
+    private static final byte WRITE_SETFIELD_MISS_CODE = 13;
+    private static final byte APPLY_SETFIELD_CODE = 14;
+    private static final byte APPLY_SETFIELD_MISS_CODE = 15;
+    private static final int EXPERIMENTER_CODE = 65534; // 0xFFFE
+    private static final int EXPERIMENTER_MISS_CODE = 65535; // 0xFFFF
+    private static final byte FLOW_BODY_LENGTH = 32;
+    private static final byte AGGREGATE_BODY_LENGTH = 32;
+    private static final byte PORT_STATS_BODY_LENGTH = 8;
+    private static final byte QUEUE_BODY_LENGTH = 8;
+    private static final byte GROUP_BODY_LENGTH = 8;
+    private static final byte METER_BODY_LENGTH = 8;
+    private static final byte METER_CONFIG_BODY_LENGTH = 8;
+    private static final byte EXPERIMENTER_BODY_LENGTH = 8;
+    private static final byte TABLE_FEATURES_LENGTH = 64;
+    private static final byte STRUCTURE_HEADER_LENGTH = 4;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01 = 3;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02 = 4;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_01 = 3;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_02 = 4;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY = 4;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_GROUP_BODY = 4;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_METER_BODY = 4;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY = 4;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY = 5;
+    
+
+
+    private MultipartRequestInputFactory() {
+        // singleton
+    }
+
+    /**
+     * @return singleton factory
+     */
+    public static synchronized MultipartRequestInputFactory getInstance() {
+        if (instance == null) {
+            instance = new MultipartRequestInputFactory();
+        }
+        return instance;
+    }
+
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            MultipartRequestInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeShort(message.getType().getIntValue());
+        out.writeShort(createMultipartRequestFlagsBitmask(message.getFlags()));
+        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_MESSAGE, out);
+
+        if (message.getMultipartRequestBody() instanceof MultipartRequestDesc ){
+            encodeDescBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestFlow) {
+            encodeFlowBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestAggregate) {
+            encodeAggregateBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestTable) {
+            encodeTableBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestPortStats) {
+            encodePortStatsBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestQueue) {
+            encodeQueueBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestGroup) {
+            encodeGroupStatsBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestGroupDesc) {
+            encodeGroupDescBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestGroupFeatures) {
+            encodeGroupFeaturesBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestMeter) {
+            encodeMeterBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestMeterConfig) {
+            encodeMeterConfigBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestMeterFeatures) {
+            encodeMeterFeaturesBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestTableFeatures) {
+            encodeTableFeaturesBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestPortDesc) {
+            encodePortDescBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestExperimenter) {
+            encodeExperimenterBody(message.getMultipartRequestBody(), out);
+        }
+    }
+
+    @Override
+    public int computeLength(MultipartRequestInput message) {
+        return MESSAGE_LENGTH + computeBodyLength(message);
+    }
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+    /**
+     *
+     * @param message
+     * @return length of MultipartRequestMessage
+     */
+    public int computeBodyLength(MultipartRequestInput message) {
+        int length = 0;
+        MultipartType type = message.getType();
+        if (type.equals(MultipartType.OFPMPFLOW)) {
+            MultipartRequestFlow body = (MultipartRequestFlow) message.getMultipartRequestBody();
+            length += FLOW_BODY_LENGTH + MatchSerializer.computeMatchLength(body.getMatch());
+        } else if (type.equals(MultipartType.OFPMPAGGREGATE)) {
+            MultipartRequestAggregate body = (MultipartRequestAggregate) message.getMultipartRequestBody();
+            length += AGGREGATE_BODY_LENGTH + MatchSerializer.computeMatchLength(body.getMatch());
+        } else if (type.equals(MultipartType.OFPMPPORTSTATS)) {
+            length += PORT_STATS_BODY_LENGTH;
+        } else if (type.equals(MultipartType.OFPMPQUEUE)) {
+            length += QUEUE_BODY_LENGTH;
+        } else if (type.equals(MultipartType.OFPMPGROUP)) {
+            length += GROUP_BODY_LENGTH;
+        } else if (type.equals(MultipartType.OFPMPMETER)) {
+            length += METER_BODY_LENGTH;
+        } else if (type.equals(MultipartType.OFPMPMETERCONFIG)) {
+            length += METER_CONFIG_BODY_LENGTH;
+        } else if (type.equals(MultipartType.OFPMPTABLEFEATURES)) {
+            MultipartRequestTableFeatures body = (MultipartRequestTableFeatures) message.getMultipartRequestBody();
+            length += computeTableFeaturesLength(body);
+        } else if (type.equals(MultipartType.OFPMPEXPERIMENTER)) {
+            MultipartRequestExperimenter body = (MultipartRequestExperimenter) message.getMultipartRequestBody();
+            length += EXPERIMENTER_BODY_LENGTH;
+            if (body.getData() != null) {
+                length += body.getData().length;
+            }
+        }
+        return length;
+    }
+
+    private static int computeTableFeaturesLength(MultipartRequestTableFeatures body) {
+        int length = 0;
+        if (body != null && body.getTableFeatures() != null) {
+            List<TableFeatures> tableFeatures = body.getTableFeatures();
+            for (TableFeatures feature : tableFeatures) {
+                length += TABLE_FEATURES_LENGTH;
+                List<TableFeatureProperties> featureProperties = feature.getTableFeatureProperties();
+                if (featureProperties != null) {
+                    for (TableFeatureProperties featProp : featureProperties) {
+                        length += TABLE_FEAT_HEADER_LENGTH;
+                        if (featProp.getAugmentation(InstructionRelatedTableFeatureProperty.class) != null) {
+                            InstructionRelatedTableFeatureProperty property =
+                                    featProp.getAugmentation(InstructionRelatedTableFeatureProperty.class);
+                            length += property.getInstructions().size() * STRUCTURE_HEADER_LENGTH;
+                        } else if (featProp.getAugmentation(NextTableRelatedTableFeatureProperty.class) != null) {
+                            NextTableRelatedTableFeatureProperty property =
+                                    featProp.getAugmentation(NextTableRelatedTableFeatureProperty.class);
+                            length += property.getNextTableIds().size();
+                        } else if (featProp.getAugmentation(ActionRelatedTableFeatureProperty.class) != null) {
+                            ActionRelatedTableFeatureProperty property =
+                                    featProp.getAugmentation(ActionRelatedTableFeatureProperty.class);
+                            length += property.getActionsList().size() * STRUCTURE_HEADER_LENGTH;
+                        } else if (featProp.getAugmentation(OxmRelatedTableFeatureProperty.class) != null) {
+                            OxmRelatedTableFeatureProperty property =
+                                    featProp.getAugmentation(OxmRelatedTableFeatureProperty.class);
+                            length += property.getMatchEntries().size() * STRUCTURE_HEADER_LENGTH;
+                        } else if (featProp.getAugmentation(ExperimenterRelatedTableFeatureProperty.class) != null) {
+                            ExperimenterRelatedTableFeatureProperty property =
+                                    featProp.getAugmentation(ExperimenterRelatedTableFeatureProperty.class);
+                            length += 2 * (EncodeConstants.SIZE_OF_INT_IN_BYTES);
+                            if (property.getData() != null) {
+                                length += property.getData().length;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return length;
+    }
+
+    private static int createMultipartRequestFlagsBitmask(MultipartRequestFlags flags) {
+        int multipartRequestFlagsBitmask = 0;
+        Map<Integer, Boolean> multipartRequestFlagsMap = new HashMap<>();
+        multipartRequestFlagsMap.put(0, flags.isOFPMPFREQMORE());
+
+        multipartRequestFlagsBitmask = ByteBufUtils.fillBitMaskFromMap(multipartRequestFlagsMap);
+        return multipartRequestFlagsBitmask;
+    }
+
+    /**
+     * @param multipartRequestBody
+     * @param output
+     */
+    private void encodeDescBody(MultipartRequestBody multipartRequestBody,
+            ByteBuf output) {
+        // The body of MultiPartRequestDesc is empty
+    }
+
+    /**
+     * @param multipartRequestBody
+     * @param out
+     */
+    private void encodeTableBody(MultipartRequestBody multipartRequestBody,
+            ByteBuf out) {
+     // The body of MultiPartTable is empty
+    }
+
+    /**
+     * @param multipartRequestBody
+     * @param out
+     */
+    private void encodeGroupDescBody(MultipartRequestBody multipartRequestBody,
+            ByteBuf out) {
+     // The body of MultiPartRequestGroupDesc is empty
+    }
+
+    /**
+     * @param multipartRequestBody
+     * @param out
+     */
+    private void encodeGroupFeaturesBody(
+            MultipartRequestBody multipartRequestBody, ByteBuf out) {
+     // The body of MultiPartRequestGroupFeatures is empty
+    }
+
+    /**
+     * @param multipartRequestBody
+     * @param out
+     */
+    private void encodeMeterFeaturesBody(
+            MultipartRequestBody multipartRequestBody, ByteBuf out) {
+     // The body of MultiPartMeterFeatures is empty
+    }
+
+    /**
+     * @param multipartRequestBody
+     * @param out
+     */
+    private void encodePortDescBody(MultipartRequestBody multipartRequestBody,
+            ByteBuf out) {
+     // The body of MultiPartPortDesc is empty
+    }
+
+    private static void encodeFlowBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestFlow flow = (MultipartRequestFlow) multipartRequestBody;
+        output.writeByte(flow.getTableId().byteValue());
+        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01, output);
+        output.writeInt(flow.getOutPort().intValue());
+        output.writeInt(flow.getOutGroup().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02, output);
+        output.writeLong(flow.getCookie().longValue());
+        output.writeLong(flow.getCookieMask().longValue());
+        MatchSerializer.encodeMatch(flow.getMatch(), output);
+    }
+
+    private static void encodeAggregateBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestAggregate aggregate = (MultipartRequestAggregate) multipartRequestBody;
+        output.writeByte(aggregate.getTableId().byteValue());
+        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_01, output);
+        output.writeInt(aggregate.getOutPort().intValue());
+        output.writeInt(aggregate.getOutGroup().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_02, output);
+        output.writeLong(aggregate.getCookie().longValue());
+        output.writeLong(aggregate.getCookieMask().longValue());
+        MatchSerializer.encodeMatch(aggregate.getMatch(), output);
+    }
+
+    private static void encodePortStatsBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestPortStats portstats = (MultipartRequestPortStats) multipartRequestBody;
+        output.writeInt(portstats.getPortNo().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY, output);
+    }
+
+    private static void encodeQueueBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestQueue queue = (MultipartRequestQueue) multipartRequestBody;
+        output.writeInt(queue.getPortNo().intValue());
+        output.writeInt(queue.getQueueId().intValue());
+    }
+
+    private static void encodeGroupStatsBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestGroup groupStats = (MultipartRequestGroup) multipartRequestBody;
+        output.writeInt(groupStats.getGroupId().getValue().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_GROUP_BODY, output);
+    }
+
+    private static void encodeMeterBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestMeter meter = (MultipartRequestMeter) multipartRequestBody;
+        output.writeInt(meter.getMeterId().getValue().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_METER_BODY, output);
+    }
+
+    private static void encodeMeterConfigBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestMeterConfig meterConfig = (MultipartRequestMeterConfig) multipartRequestBody;
+        output.writeInt(meterConfig.getMeterId().getValue().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY, output);
+    }
+
+    private static void encodeExperimenterBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestExperimenter experimenter = (MultipartRequestExperimenter) multipartRequestBody;
+        output.writeInt(experimenter.getExperimenter().intValue());
+        output.writeInt(experimenter.getExpType().intValue());
+        byte[] data = experimenter.getData();
+        if (data != null) {
+            output.writeBytes(data);
+        }
+    }
+
+    private static void encodeTableFeaturesBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        if (multipartRequestBody != null) {
+            MultipartRequestTableFeatures tableFeatures = (MultipartRequestTableFeatures) multipartRequestBody;
+            if(tableFeatures.getTableFeatures() != null) {
+                for (TableFeatures currTableFeature : tableFeatures.getTableFeatures()) {
+                    output.writeByte(currTableFeature.getTableId());
+                    ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY, output);
+                    output.writeBytes(currTableFeature.getName().getBytes());
+                    ByteBufUtils.padBuffer((32 - currTableFeature.getName().getBytes().length), output);
+                    output.writeLong(currTableFeature.getMetadataMatch().longValue());
+                    output.writeLong(currTableFeature.getMetadataWrite().longValue());
+                    output.writeInt(createTableConfigBitmask(currTableFeature.getConfig()));
+                    output.writeInt(currTableFeature.getMaxEntries().intValue());
+                    writeTableFeatureProperties(output, currTableFeature.getTableFeatureProperties());
+                }
+            }
+        }
+    }
+
+    private static void writeTableFeatureProperties(ByteBuf output, List<TableFeatureProperties> props) {
+        if (props != null) {
+            for (TableFeatureProperties property : props) {
+                TableFeaturesPropType type = property.getType();
+                if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS)) {
+                    writeInstructionRelatedTableProperty(output, property, INSTRUCTIONS_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
+                    writeInstructionRelatedTableProperty(output, property, INSTRUCTIONS_MISS_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES)) {
+                    writeNextTableRelatedTableProperty(output, property, NEXT_TABLE_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {
+                    writeNextTableRelatedTableProperty(output, property, NEXT_TABLE_MISS_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONS)) {
+                    writeActionsRelatedTableProperty(output, property, WRITE_ACTIONS_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS)) {
+                    writeActionsRelatedTableProperty(output, property, WRITE_ACTIONS_MISS_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS)) {
+                    writeActionsRelatedTableProperty(output, property, APPLY_ACTIONS_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
+                    writeActionsRelatedTableProperty(output, property, APPLY_ACTIONS_MISS_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH)) {
+                    writeOxmRelatedTableProperty(output, property, MATCH_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS)) {
+                    writeOxmRelatedTableProperty(output, property, WILDCARDS_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELD)) {
+                    writeOxmRelatedTableProperty(output, property, WRITE_SETFIELD_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS)) {
+                    writeOxmRelatedTableProperty(output, property, WRITE_SETFIELD_MISS_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD)) {
+                    writeOxmRelatedTableProperty(output, property, APPLY_SETFIELD_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {
+                    writeOxmRelatedTableProperty(output, property, APPLY_SETFIELD_MISS_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)) {
+                    writeExperimenterRelatedTableProperty(output, property, EXPERIMENTER_CODE);
+                } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {
+                    writeExperimenterRelatedTableProperty(output, property, EXPERIMENTER_MISS_CODE);
+                }
+            }
+        }
+    }
+
+    private static void writeInstructionRelatedTableProperty(ByteBuf output,
+            TableFeatureProperties property, byte code) {
+        output.writeShort(code);
+        List<Instructions> instructions = property.
+                getAugmentation(InstructionRelatedTableFeatureProperty.class).getInstructions();
+        int length = TABLE_FEAT_HEADER_LENGTH;
+        if (instructions != null) {
+        output.writeShort(InstructionsSerializer.computeInstructionsLength(instructions)
+                + TABLE_FEAT_HEADER_LENGTH);
+        InstructionsSerializer.encodeInstructions(instructions, output);
+        } else {
+            output.writeShort(length);
+        }
+    }
+
+    private static void writeNextTableRelatedTableProperty(ByteBuf output,
+            TableFeatureProperties property, byte code) {
+        output.writeShort(code);
+        List<NextTableIds> nextTableIds = property.
+                getAugmentation(NextTableRelatedTableFeatureProperty.class).getNextTableIds();
+        int length = TABLE_FEAT_HEADER_LENGTH;
+        if (nextTableIds != null) {
+            output.writeShort(length + nextTableIds.size());
+            for (NextTableIds next : nextTableIds) {
+                output.writeByte(next.getTableId());
+            }
+        } else {
+            output.writeShort(length);
+        }
+    }
+
+    private static void writeActionsRelatedTableProperty(ByteBuf output,
+            TableFeatureProperties property, byte code) {
+        output.writeShort(code);
+        List<ActionsList> actions = property.
+                getAugmentation(ActionRelatedTableFeatureProperty.class).getActionsList();
+        int length = TABLE_FEAT_HEADER_LENGTH;
+        if (actions != null) {
+        output.writeShort(ActionsSerializer.computeLengthOfActions(actions)
+                + TABLE_FEAT_HEADER_LENGTH);
+        ActionsSerializer.encodeActions(actions, output);
+        } else {
+            output.writeShort(length);
+        }
+    }
+
+    private static void writeOxmRelatedTableProperty(ByteBuf output,
+            TableFeatureProperties property, byte code) {
+        output.writeShort(code);
+        List<MatchEntries> entries = property.
+                getAugmentation(OxmRelatedTableFeatureProperty.class).getMatchEntries();
+        int length = TABLE_FEAT_HEADER_LENGTH;
+        if (entries != null) {
+        output.writeShort(MatchSerializer.computeMatchEntriesLength(entries)
+                + TABLE_FEAT_HEADER_LENGTH);
+        MatchSerializer.encodeMatchEntries(entries, output);
+        } else {
+            output.writeShort(length);
+        }
+    }
+
+    private static void writeExperimenterRelatedTableProperty(ByteBuf output,
+            TableFeatureProperties property, int code) {
+        output.writeShort(code);
+        ExperimenterRelatedTableFeatureProperty exp = property.
+                getAugmentation(ExperimenterRelatedTableFeatureProperty.class);
+        byte[] data = exp.getData();
+        int length = TABLE_FEAT_HEADER_LENGTH + 2 * (EncodeConstants.SIZE_OF_INT_IN_BYTES);
+        if (data != null) {
+            output.writeShort(length + data.length);
+            output.writeInt(exp.getExperimenter().intValue());
+            output.writeInt(exp.getExpType().intValue());
+            output.writeBytes(data);
+        } else {
+            output.writeShort(length);
+            output.writeInt(exp.getExperimenter().intValue());
+            output.writeInt(exp.getExpType().intValue());
+        }
+    }
+
+    private static int createTableConfigBitmask(TableConfig tableConfig) {
+        int tableConfigBitmask = 0;
+        Map<Integer, Boolean> tableConfigMap = new HashMap<>();
+        tableConfigMap.put(3, tableConfig.isOFPTCDEPRECATEDMASK());
+
+        tableConfigBitmask = ByteBufUtils.fillBitMaskFromMap(tableConfigMap);
+        return tableConfigBitmask;
+    }
+}
index aaac85619cd578961ee8114378729739a4ac9dbb..e37adc61c001daee8a99d5546f0ecd3f539f8788 100644 (file)
@@ -1,49 +1,56 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;\r
-\r
-/**\r
- * Translates BarrierRequest messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10BarrierInputMessageFactory implements OFSerializer<BarrierInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 18;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-\r
-    private static OF10BarrierInputMessageFactory instance;\r
-    \r
-    private OF10BarrierInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10BarrierInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10BarrierInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, BarrierInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(BarrierInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+
+/**
+ * Translates BarrierRequest messages
+ * @author michal.polkorab
+ */
+public class OF10BarrierInputMessageFactory implements OFSerializer<BarrierInput> {
+
+    private static final byte MESSAGE_TYPE = 18;
+    private static final int MESSAGE_LENGTH = 8;
+
+    private static OF10BarrierInputMessageFactory instance;
+    
+    private OF10BarrierInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized OF10BarrierInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new OF10BarrierInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, BarrierInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+    }
+
+    @Override
+    public int computeLength(BarrierInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+}
index 7821cd4979ad354993b1c37f63fd822c8a1da9a4..e4c1d583c307c3a2b618004e0df2e1ca748420e7 100644 (file)
@@ -1,75 +1,82 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
-\r
-/**\r
- * Translates FlowMod messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10FlowModInputMessageFactory implements OFSerializer<FlowModInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 14;\r
-    private static final int MESSAGE_LENGTH = 72;\r
-    \r
-    private static OF10FlowModInputMessageFactory instance;\r
-   \r
-    private OF10FlowModInputMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10FlowModInputMessageFactory getInstance() {\r
-        if(instance == null) {\r
-            instance = new OF10FlowModInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, FlowModInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        OF10MatchSerializer.encodeMatchV10(out, message.getMatchV10());\r
-        out.writeLong(message.getCookie().longValue());\r
-        out.writeShort(message.getCommand().getIntValue());\r
-        out.writeShort(message.getIdleTimeout().intValue());\r
-        out.writeShort(message.getHardTimeout().intValue());\r
-        out.writeShort(message.getPriority());\r
-        out.writeInt(message.getBufferId().intValue());\r
-        out.writeShort(message.getOutPort().getValue().intValue());\r
-        out.writeShort(createFlowModFlagsBitmask(message.getFlagsV10()));\r
-        OF10ActionsSerializer.encodeActionsV10(out, message.getActionsList());\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(FlowModInput message) {\r
-        return MESSAGE_LENGTH + OF10ActionsSerializer.computeActionsLength(message.getActionsList());\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-    private static int createFlowModFlagsBitmask(FlowModFlagsV10 flags) {\r
-        int flowModFlagBitmask = 0;\r
-        Map<Integer, Boolean> flowModFlagsMap = new HashMap<>();\r
-        flowModFlagsMap.put(0, flags.isOFPFFSENDFLOWREM());\r
-        flowModFlagsMap.put(1, flags.isOFPFFCHECKOVERLAP());\r
-        flowModFlagsMap.put(2, flags.isOFPFFEMERG());\r
-        flowModFlagBitmask = ByteBufUtils.fillBitMaskFromMap(flowModFlagsMap);\r
-        return flowModFlagBitmask;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+
+/**
+ * Translates FlowMod messages
+ * @author michal.polkorab
+ */
+public class OF10FlowModInputMessageFactory implements OFSerializer<FlowModInput> {
+
+    private static final byte MESSAGE_TYPE = 14;
+    private static final int MESSAGE_LENGTH = 72;
+    
+    private static OF10FlowModInputMessageFactory instance;
+   
+    private OF10FlowModInputMessageFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized OF10FlowModInputMessageFactory getInstance() {
+        if(instance == null) {
+            instance = new OF10FlowModInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, FlowModInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        OF10MatchSerializer.encodeMatchV10(out, message.getMatchV10());
+        out.writeLong(message.getCookie().longValue());
+        out.writeShort(message.getCommand().getIntValue());
+        out.writeShort(message.getIdleTimeout().intValue());
+        out.writeShort(message.getHardTimeout().intValue());
+        out.writeShort(message.getPriority());
+        out.writeInt(message.getBufferId().intValue());
+        out.writeShort(message.getOutPort().getValue().intValue());
+        out.writeShort(createFlowModFlagsBitmask(message.getFlagsV10()));
+        OF10ActionsSerializer.encodeActionsV10(out, message.getActionsList());
+    }
+
+    @Override
+    public int computeLength(FlowModInput message) {
+        return MESSAGE_LENGTH + OF10ActionsSerializer.computeActionsLength(message.getActionsList());
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+    private static int createFlowModFlagsBitmask(FlowModFlagsV10 flags) {
+        int flowModFlagBitmask = 0;
+        Map<Integer, Boolean> flowModFlagsMap = new HashMap<>();
+        flowModFlagsMap.put(0, flags.isOFPFFSENDFLOWREM());
+        flowModFlagsMap.put(1, flags.isOFPFFCHECKOVERLAP());
+        flowModFlagsMap.put(2, flags.isOFPFFEMERG());
+        flowModFlagBitmask = ByteBufUtils.fillBitMaskFromMap(flowModFlagsMap);
+        return flowModFlagBitmask;
+    }
+}
index 8ca946966a8beedde113139bbfaaf51e6068abc5..68f1a2d4ed11f53a0eaa22bbe879e8632c6ffb8e 100644 (file)
@@ -1,48 +1,55 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;\r
-\r
-/**\r
- * Translates Hello messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10HelloInputMessageFactory implements OFSerializer<HelloInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 0;\r
-    private static int MESSAGE_LENGTH = 8;\r
-    private static OF10HelloInputMessageFactory instance;\r
-    \r
-    private OF10HelloInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10HelloInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10HelloInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, HelloInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(HelloInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;
+
+/**
+ * Translates Hello messages
+ * @author michal.polkorab
+ */
+public class OF10HelloInputMessageFactory implements OFSerializer<HelloInput> {
+
+    private static final byte MESSAGE_TYPE = 0;
+    private static int MESSAGE_LENGTH = 8;
+    private static OF10HelloInputMessageFactory instance;
+    
+    private OF10HelloInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized OF10HelloInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new OF10HelloInputMessageFactory();
+        }
+        return instance;
+    }
+
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, HelloInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+    }
+
+    @Override
+    public int computeLength(HelloInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+}
index d397f8a97621e08463f6631a7d9fd0d3523ad543..cf35ffff682e02126eb9e50489b97bbb0f8a5774 100644 (file)
@@ -1,65 +1,72 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsSerializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;\r
-\r
-/**\r
- * Translates PacketOut messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10PacketOutInputMessageFactory implements OFSerializer<PacketOutInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 13;\r
-    private static final int MESSAGE_LENGTH = 16;\r
-    \r
-    private static OF10PacketOutInputMessageFactory instance;\r
-    \r
-    private OF10PacketOutInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10PacketOutInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10PacketOutInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            PacketOutInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeInt(message.getBufferId().intValue());\r
-        out.writeShort(message.getInPort().getValue().intValue());\r
-        out.writeShort(OF10ActionsSerializer.computeActionsLength(message.getActionsList()));\r
-        OF10ActionsSerializer.encodeActionsV10(out, message.getActionsList());\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            out.writeBytes(data);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(PacketOutInput message) {\r
-        int length = MESSAGE_LENGTH + OF10ActionsSerializer.computeActionsLength(message.getActionsList());\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            length += data.length;\r
-        }\r
-        return length;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+
+/**
+ * Translates PacketOut messages
+ * @author michal.polkorab
+ */
+public class OF10PacketOutInputMessageFactory implements OFSerializer<PacketOutInput> {
+
+    private static final byte MESSAGE_TYPE = 13;
+    private static final int MESSAGE_LENGTH = 16;
+    
+    private static OF10PacketOutInputMessageFactory instance;
+    
+    private OF10PacketOutInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized OF10PacketOutInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new OF10PacketOutInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            PacketOutInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeInt(message.getBufferId().intValue());
+        out.writeShort(message.getInPort().getValue().intValue());
+        out.writeShort(OF10ActionsSerializer.computeActionsLength(message.getActionsList()));
+        OF10ActionsSerializer.encodeActionsV10(out, message.getActionsList());
+        byte[] data = message.getData();
+        if (data != null) {
+            out.writeBytes(data);
+        }
+    }
+
+    @Override
+    public int computeLength(PacketOutInput message) {
+        int length = MESSAGE_LENGTH + OF10ActionsSerializer.computeActionsLength(message.getActionsList());
+        byte[] data = message.getData();
+        if (data != null) {
+            length += data.length;
+        }
+        return length;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+}
index ef53543cdc9d6b0c3f6d464a3ce6ec2334482355..6cb8606b427998155ada8ee4d2c1b52488b416b6 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;\r
-\r
-/**\r
- * Translates PortMod messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10PortModInputMessageFactory implements OFSerializer<PortModInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 15;\r
-    private static final byte PADDING_IN_PORT_MOD_MESSAGE = 4;\r
-    private static final int MESSAGE_LENGTH = 32;\r
-    \r
-    private static OF10PortModInputMessageFactory instance;\r
-    \r
-    private OF10PortModInputMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10PortModInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10PortModInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, PortModInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeShort(message.getPortNo().getValue().intValue());\r
-        out.writeBytes(ByteBufUtils.macAddressToBytes(message.getHwAddress().getValue()));\r
-        out.writeInt(createPortConfigBitmask(message.getConfigV10()));\r
-        out.writeInt(createPortConfigBitmask(message.getMaskV10()));\r
-        out.writeInt(createPortFeaturesBitmask(message.getAdvertiseV10()));\r
-        ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE, out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(PortModInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-   \r
-    \r
-    /**\r
-     * @param config\r
-     * @return port config bitmask \r
-     */\r
-    private static int createPortConfigBitmask(PortConfigV10 config) {\r
-        int configBitmask = 0;\r
-        Map<Integer, Boolean> portConfigMap = new HashMap<>();\r
-        portConfigMap.put(0, config.isPortDown());\r
-        portConfigMap.put(1, config.isNoStp());\r
-        portConfigMap.put(2, config.isNoRecv());\r
-        portConfigMap.put(3, config.isNoRecvStp());\r
-        portConfigMap.put(4, config.isNoFlood());\r
-        portConfigMap.put(5, config.isNoFwd());\r
-        portConfigMap.put(6, config.isNoPacketIn());\r
-        \r
-        configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);\r
-        return configBitmask;\r
-    }\r
-    \r
-    private static int createPortFeaturesBitmask(PortFeaturesV10 feature) {\r
-        int configBitmask = 0;\r
-        Map<Integer, Boolean> portFeaturesMap = new HashMap<>();\r
-        portFeaturesMap.put(0, feature.is_10mbHd());\r
-        portFeaturesMap.put(1, feature.is_10mbFd());\r
-        portFeaturesMap.put(2, feature.is_100mbHd());\r
-        portFeaturesMap.put(3, feature.is_100mbFd());\r
-        portFeaturesMap.put(4, feature.is_1gbHd());\r
-        portFeaturesMap.put(5, feature.is_1gbFd());\r
-        portFeaturesMap.put(6, feature.is_10gbFd());\r
-        portFeaturesMap.put(7, feature.isCopper());\r
-        portFeaturesMap.put(8, feature.isFiber());\r
-        portFeaturesMap.put(9, feature.isAutoneg());\r
-        portFeaturesMap.put(10, feature.isPause());\r
-        portFeaturesMap.put(11, feature.isPauseAsym());\r
-        configBitmask = ByteBufUtils.fillBitMaskFromMap(portFeaturesMap);\r
-        return configBitmask;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+
+/**
+ * Translates PortMod messages
+ * @author michal.polkorab
+ */
+public class OF10PortModInputMessageFactory implements OFSerializer<PortModInput> {
+
+    private static final byte MESSAGE_TYPE = 15;
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE = 4;
+    private static final int MESSAGE_LENGTH = 32;
+    
+    private static OF10PortModInputMessageFactory instance;
+    
+    private OF10PortModInputMessageFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized OF10PortModInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new OF10PortModInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, PortModInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeShort(message.getPortNo().getValue().intValue());
+        out.writeBytes(ByteBufUtils.macAddressToBytes(message.getHwAddress().getValue()));
+        out.writeInt(createPortConfigBitmask(message.getConfigV10()));
+        out.writeInt(createPortConfigBitmask(message.getMaskV10()));
+        out.writeInt(createPortFeaturesBitmask(message.getAdvertiseV10()));
+        ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE, out);
+    }
+
+    @Override
+    public int computeLength(PortModInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+   
+    
+    /**
+     * @param config
+     * @return port config bitmask 
+     */
+    private static int createPortConfigBitmask(PortConfigV10 config) {
+        int configBitmask = 0;
+        Map<Integer, Boolean> portConfigMap = new HashMap<>();
+        portConfigMap.put(0, config.isPortDown());
+        portConfigMap.put(1, config.isNoStp());
+        portConfigMap.put(2, config.isNoRecv());
+        portConfigMap.put(3, config.isNoRecvStp());
+        portConfigMap.put(4, config.isNoFlood());
+        portConfigMap.put(5, config.isNoFwd());
+        portConfigMap.put(6, config.isNoPacketIn());
+        
+        configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);
+        return configBitmask;
+    }
+    
+    private static int createPortFeaturesBitmask(PortFeaturesV10 feature) {
+        int configBitmask = 0;
+        Map<Integer, Boolean> portFeaturesMap = new HashMap<>();
+        portFeaturesMap.put(0, feature.is_10mbHd());
+        portFeaturesMap.put(1, feature.is_10mbFd());
+        portFeaturesMap.put(2, feature.is_100mbHd());
+        portFeaturesMap.put(3, feature.is_100mbFd());
+        portFeaturesMap.put(4, feature.is_1gbHd());
+        portFeaturesMap.put(5, feature.is_1gbFd());
+        portFeaturesMap.put(6, feature.is_10gbFd());
+        portFeaturesMap.put(7, feature.isCopper());
+        portFeaturesMap.put(8, feature.isFiber());
+        portFeaturesMap.put(9, feature.isAutoneg());
+        portFeaturesMap.put(10, feature.isPause());
+        portFeaturesMap.put(11, feature.isPauseAsym());
+        configBitmask = ByteBufUtils.fillBitMaskFromMap(portFeaturesMap);
+        return configBitmask;
+    }
+}
index 5b83e7d810593b3c4fa184caa3fca1e1fafee790..462cbabfdd15b0227aa9ae4124fd8b56f0cc8f7d 100644 (file)
@@ -1,53 +1,60 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;\r
-\r
-/**\r
- * Translates QueueGetConfigRequest messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10QueueGetConfigInputMessageFactory implements OFSerializer<GetQueueConfigInput> {\r
-    \r
-    private static final byte MESSAGE_TYPE = 20;\r
-    private static final byte PADDING_IN_GET_QUEUE_CONFIG_MESSAGE = 2;\r
-    private static final int MESSAGE_LENGTH = 12;\r
-    \r
-    private static OF10QueueGetConfigInputMessageFactory instance;\r
-    \r
-    private OF10QueueGetConfigInputMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10QueueGetConfigInputMessageFactory getInstance(){\r
-        if(instance == null){\r
-            instance = new OF10QueueGetConfigInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, GetQueueConfigInput message){\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeShort(message.getPort().getValue().intValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_GET_QUEUE_CONFIG_MESSAGE, out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(GetQueueConfigInput message){\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
+
+/**
+ * Translates QueueGetConfigRequest messages
+ * @author michal.polkorab
+ */
+public class OF10QueueGetConfigInputMessageFactory implements OFSerializer<GetQueueConfigInput> {
+    
+    private static final byte MESSAGE_TYPE = 20;
+    private static final byte PADDING_IN_GET_QUEUE_CONFIG_MESSAGE = 2;
+    private static final int MESSAGE_LENGTH = 12;
+    
+    private static OF10QueueGetConfigInputMessageFactory instance;
+    
+    private OF10QueueGetConfigInputMessageFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized OF10QueueGetConfigInputMessageFactory getInstance(){
+        if(instance == null){
+            instance = new OF10QueueGetConfigInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, GetQueueConfigInput message){
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeShort(message.getPort().getValue().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_GET_QUEUE_CONFIG_MESSAGE, out);
+    }
+
+    @Override
+    public int computeLength(GetQueueConfigInput message){
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+}
index b0f81d66afee8d1c7cb9b11cb5836f2fcf11cbe4..85539b5d337bd4c09a1f950c375d53284d570a9c 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregate;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlow;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTable;\r
-\r
-/**\r
- * Translates StatsRequest messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10StatsRequestInputFactory implements OFSerializer<MultipartRequestInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 16;\r
-    private static final int MESSAGE_LENGTH = 12;\r
-    private static final byte FLOW_BODY_LENGTH = 44;\r
-    private static final byte AGGREGATE_BODY_LENGTH = 44;\r
-    private static final byte PORT_STATS_BODY_LENGTH = 8;\r
-    private static final byte QUEUE_BODY_LENGTH = 8;\r
-    private static final byte EXPERIMENTER_BODY_LENGTH = 4;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY = 1;\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_PORT_BODY = 6;\r
-    private static final byte PADING_IN_QUEUE_BODY = 2;\r
-\r
-    private static OF10StatsRequestInputFactory instance; \r
-    \r
-    private OF10StatsRequestInputFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10StatsRequestInputFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10StatsRequestInputFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            MultipartRequestInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeShort(message.getType().getIntValue());\r
-        out.writeShort(createMultipartRequestFlagsBitmask(message.getFlags()));\r
-        if (message.getMultipartRequestBody() instanceof MultipartRequestDesc) {\r
-            encodeDescBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestFlow) {\r
-            encodeFlowBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestAggregate) {\r
-            encodeAggregateBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestTable) {\r
-            encodeTableBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestPortStats) {\r
-            encodePortBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestQueue) {\r
-            encodeQueueBody(message.getMultipartRequestBody(), out);\r
-        } else if (message.getMultipartRequestBody() instanceof MultipartRequestExperimenter) {\r
-            encodeExperimenterBody(message.getMultipartRequestBody(), out);\r
-        }\r
-    }\r
-    \r
-    @Override\r
-    public int computeLength(MultipartRequestInput message) {\r
-        return MESSAGE_LENGTH + computeBodyLength(message);\r
-    }\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-    \r
-    /**\r
-     * \r
-     * @param message\r
-     * @return length of MultipartRequestMessage\r
-     */\r
-    public int computeBodyLength(MultipartRequestInput message) {\r
-        int length = 0;\r
-        MultipartType type = message.getType();\r
-        if (type.equals(MultipartType.OFPMPFLOW)) {\r
-            length += FLOW_BODY_LENGTH;\r
-        } else if (type.equals(MultipartType.OFPMPAGGREGATE)) {\r
-            length += AGGREGATE_BODY_LENGTH;\r
-        } else if (type.equals(MultipartType.OFPMPPORTSTATS)) {\r
-            length += PORT_STATS_BODY_LENGTH;\r
-        } else if (type.equals(MultipartType.OFPMPQUEUE)) {\r
-            length += QUEUE_BODY_LENGTH;\r
-        } else if (type.equals(MultipartType.OFPMPEXPERIMENTER)) {\r
-            MultipartRequestExperimenter body = (MultipartRequestExperimenter) message.getMultipartRequestBody();\r
-            length += EXPERIMENTER_BODY_LENGTH;\r
-            if (body.getData() != null) {\r
-                length += body.getData().length;\r
-            }\r
-        }\r
-        return length;\r
-    }\r
-    \r
-    private static int createMultipartRequestFlagsBitmask(MultipartRequestFlags flags) {\r
-        int multipartRequestFlagsBitmask = 0;\r
-        Map<Integer, Boolean> multipartRequestFlagsMap = new HashMap<>();\r
-        multipartRequestFlagsMap.put(0, flags.isOFPMPFREQMORE());\r
-        multipartRequestFlagsBitmask = ByteBufUtils.fillBitMaskFromMap(multipartRequestFlagsMap);\r
-        return multipartRequestFlagsBitmask;\r
-    }\r
-    \r
-    /**\r
-     * @param multipartRequestBody  \r
-     * @param output \r
-     */\r
-    private void encodeDescBody(MultipartRequestBody multipartRequestBody,\r
-            ByteBuf output) {\r
-        // The body of MultiPartRequestDesc is empty\r
-    }\r
-\r
-    /**\r
-     * @param multipartRequestBody\r
-     * @param out\r
-     */\r
-    private void encodeTableBody(MultipartRequestBody multipartRequestBody,\r
-            ByteBuf out) {\r
-     // The body of MultiPartTable is empty\r
-    }\r
-    \r
-    private static void encodeFlowBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        encodeFlowAndAggregateBody(multipartRequestBody, output);\r
-    }\r
-    \r
-    private static void encodeAggregateBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        encodeFlowAndAggregateBody(multipartRequestBody, output);\r
-    }\r
-\r
-    private static void encodeFlowAndAggregateBody(\r
-            MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestFlow flow = (MultipartRequestFlow) multipartRequestBody;\r
-        OF10MatchSerializer.encodeMatchV10(output, flow.getMatchV10());\r
-        output.writeByte(flow.getTableId().shortValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY, output);\r
-        output.writeShort(flow.getOutPort().intValue());\r
-    }\r
-    \r
-    private static void encodePortBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestPortStats portstats = (MultipartRequestPortStats) multipartRequestBody;\r
-        output.writeShort(portstats.getPortNo().intValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_PORT_BODY, output);\r
-    }\r
-    \r
-    private static void encodeQueueBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestQueue queue = (MultipartRequestQueue) multipartRequestBody;\r
-        output.writeShort(queue.getPortNo().intValue());\r
-        ByteBufUtils.padBuffer(PADING_IN_QUEUE_BODY, output);\r
-        output.writeInt(queue.getQueueId().intValue());\r
-    }\r
-    \r
-    private static void encodeExperimenterBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {\r
-        MultipartRequestExperimenter experimenter = (MultipartRequestExperimenter) multipartRequestBody;\r
-        output.writeInt(experimenter.getExperimenter().intValue());\r
-        output.writeBytes(experimenter.getData());\r
-    }\r
-    \r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTable;
+
+/**
+ * Translates StatsRequest messages
+ * @author michal.polkorab
+ */
+public class OF10StatsRequestInputFactory implements OFSerializer<MultipartRequestInput> {
+
+    private static final byte MESSAGE_TYPE = 16;
+    private static final int MESSAGE_LENGTH = 12;
+    private static final byte FLOW_BODY_LENGTH = 44;
+    private static final byte AGGREGATE_BODY_LENGTH = 44;
+    private static final byte PORT_STATS_BODY_LENGTH = 8;
+    private static final byte QUEUE_BODY_LENGTH = 8;
+    private static final byte EXPERIMENTER_BODY_LENGTH = 4;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY = 1;
+    private static final byte PADDING_IN_MULTIPART_REQUEST_PORT_BODY = 6;
+    private static final byte PADING_IN_QUEUE_BODY = 2;
+
+    private static OF10StatsRequestInputFactory instance; 
+    
+    private OF10StatsRequestInputFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized OF10StatsRequestInputFactory getInstance() {
+        if (instance == null) {
+            instance = new OF10StatsRequestInputFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            MultipartRequestInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeShort(message.getType().getIntValue());
+        out.writeShort(createMultipartRequestFlagsBitmask(message.getFlags()));
+        if (message.getMultipartRequestBody() instanceof MultipartRequestDesc) {
+            encodeDescBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestFlow) {
+            encodeFlowBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestAggregate) {
+            encodeAggregateBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestTable) {
+            encodeTableBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestPortStats) {
+            encodePortBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestQueue) {
+            encodeQueueBody(message.getMultipartRequestBody(), out);
+        } else if (message.getMultipartRequestBody() instanceof MultipartRequestExperimenter) {
+            encodeExperimenterBody(message.getMultipartRequestBody(), out);
+        }
+    }
+    
+    @Override
+    public int computeLength(MultipartRequestInput message) {
+        return MESSAGE_LENGTH + computeBodyLength(message);
+    }
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+    
+    /**
+     * 
+     * @param message
+     * @return length of MultipartRequestMessage
+     */
+    public int computeBodyLength(MultipartRequestInput message) {
+        int length = 0;
+        MultipartType type = message.getType();
+        if (type.equals(MultipartType.OFPMPFLOW)) {
+            length += FLOW_BODY_LENGTH;
+        } else if (type.equals(MultipartType.OFPMPAGGREGATE)) {
+            length += AGGREGATE_BODY_LENGTH;
+        } else if (type.equals(MultipartType.OFPMPPORTSTATS)) {
+            length += PORT_STATS_BODY_LENGTH;
+        } else if (type.equals(MultipartType.OFPMPQUEUE)) {
+            length += QUEUE_BODY_LENGTH;
+        } else if (type.equals(MultipartType.OFPMPEXPERIMENTER)) {
+            MultipartRequestExperimenter body = (MultipartRequestExperimenter) message.getMultipartRequestBody();
+            length += EXPERIMENTER_BODY_LENGTH;
+            if (body.getData() != null) {
+                length += body.getData().length;
+            }
+        }
+        return length;
+    }
+    
+    private static int createMultipartRequestFlagsBitmask(MultipartRequestFlags flags) {
+        int multipartRequestFlagsBitmask = 0;
+        Map<Integer, Boolean> multipartRequestFlagsMap = new HashMap<>();
+        multipartRequestFlagsMap.put(0, flags.isOFPMPFREQMORE());
+        multipartRequestFlagsBitmask = ByteBufUtils.fillBitMaskFromMap(multipartRequestFlagsMap);
+        return multipartRequestFlagsBitmask;
+    }
+    
+    /**
+     * @param multipartRequestBody  
+     * @param output 
+     */
+    private void encodeDescBody(MultipartRequestBody multipartRequestBody,
+            ByteBuf output) {
+        // The body of MultiPartRequestDesc is empty
+    }
+
+    /**
+     * @param multipartRequestBody
+     * @param out
+     */
+    private void encodeTableBody(MultipartRequestBody multipartRequestBody,
+            ByteBuf out) {
+     // The body of MultiPartTable is empty
+    }
+    
+    private static void encodeFlowBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        encodeFlowAndAggregateBody(multipartRequestBody, output);
+    }
+    
+    private static void encodeAggregateBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        encodeFlowAndAggregateBody(multipartRequestBody, output);
+    }
+
+    private static void encodeFlowAndAggregateBody(
+            MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestFlow flow = (MultipartRequestFlow) multipartRequestBody;
+        OF10MatchSerializer.encodeMatchV10(output, flow.getMatchV10());
+        output.writeByte(flow.getTableId().shortValue());
+        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY, output);
+        output.writeShort(flow.getOutPort().intValue());
+    }
+    
+    private static void encodePortBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestPortStats portstats = (MultipartRequestPortStats) multipartRequestBody;
+        output.writeShort(portstats.getPortNo().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_PORT_BODY, output);
+    }
+    
+    private static void encodeQueueBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestQueue queue = (MultipartRequestQueue) multipartRequestBody;
+        output.writeShort(queue.getPortNo().intValue());
+        ByteBufUtils.padBuffer(PADING_IN_QUEUE_BODY, output);
+        output.writeInt(queue.getQueueId().intValue());
+    }
+    
+    private static void encodeExperimenterBody(MultipartRequestBody multipartRequestBody, ByteBuf output) {
+        MultipartRequestExperimenter experimenter = (MultipartRequestExperimenter) multipartRequestBody;
+        output.writeInt(experimenter.getExperimenter().intValue());
+        output.writeBytes(experimenter.getData());
+    }
+    
+}
index d4c851e8f6b36e0fc1567caa5041fce9bcbf499e..49363c9c5834569cfbd8ea7edb120acd36fd50cc 100644 (file)
@@ -1,62 +1,69 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
-\r
-/**\r
- * Translates Vendor messages\r
- * @author michal.polkorab\r
- */\r
-public class OF10VendorInputMessageFactory implements OFSerializer<ExperimenterInput> {\r
-\r
-    private static final byte MESSAGE_TYPE = 4;\r
-    private static final byte MESSAGE_LENGTH = 8;\r
-    \r
-    private static OF10VendorInputMessageFactory instance;\r
-    \r
-    private OF10VendorInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized OF10VendorInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new OF10VendorInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            ExperimenterInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeInt(message.getExperimenter().intValue());\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            out.writeBytes(data);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(ExperimenterInput message) {\r
-        int length = MESSAGE_LENGTH + EncodeConstants.SIZE_OF_INT_IN_BYTES;\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            length += data.length;\r
-        }\r
-        return length;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-    \r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+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.protocol.rev130731.ExperimenterInput;
+
+/**
+ * Translates Vendor messages
+ * @author michal.polkorab
+ */
+public class OF10VendorInputMessageFactory implements OFSerializer<ExperimenterInput> {
+
+    private static final byte MESSAGE_TYPE = 4;
+    private static final byte MESSAGE_LENGTH = 8;
+    
+    private static OF10VendorInputMessageFactory instance;
+    
+    private OF10VendorInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized OF10VendorInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new OF10VendorInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            ExperimenterInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeInt(message.getExperimenter().intValue());
+        byte[] data = message.getData();
+        if (data != null) {
+            out.writeBytes(data);
+        }
+    }
+
+    @Override
+    public int computeLength(ExperimenterInput message) {
+        int length = MESSAGE_LENGTH + EncodeConstants.SIZE_OF_INT_IN_BYTES;
+        byte[] data = message.getData();
+        if (data != null) {
+            length += data.length;
+        }
+        return length;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+    
+}
index 02386440c233d58b9b1954575c956f01a4de16d3..4bdfec95ab682ec059e2658669a174779426e58e 100644 (file)
@@ -1,69 +1,76 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ActionsSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;\r
-\r
-/**\r
- * Translates PacketOut messages\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class PacketOutInputMessageFactory implements OFSerializer<PacketOutInput>{\r
-\r
-    /** Code type of PacketOut message */\r
-    public static final byte MESSAGE_TYPE = 13;\r
-    private static final int MESSAGE_LENGTH = 24;\r
-    private static final byte PADDING_IN_PACKET_OUT_MESSAGE = 6;\r
-    private static PacketOutInputMessageFactory instance;\r
-    \r
-    private PacketOutInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized PacketOutInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new PacketOutInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            PacketOutInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeInt(message.getBufferId().intValue());\r
-        out.writeInt(message.getInPort().getValue().intValue());\r
-        out.writeShort(ActionsSerializer.computeLengthOfActions(message.getActionsList()));\r
-        ByteBufUtils.padBuffer(PADDING_IN_PACKET_OUT_MESSAGE, out);\r
-        ActionsSerializer.encodeActions(message.getActionsList(), out);\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            out.writeBytes(data);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(PacketOutInput message) {\r
-        int length = MESSAGE_LENGTH;\r
-        length += ActionsSerializer.computeLengthOfActions(message.getActionsList());\r
-        byte[] data = message.getData();\r
-        if (data != null) {\r
-            length += data.length;\r
-        }\r
-        return length;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionsSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+
+/**
+ * Translates PacketOut messages
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class PacketOutInputMessageFactory implements OFSerializer<PacketOutInput>{
+
+    /** Code type of PacketOut message */
+    public static final byte MESSAGE_TYPE = 13;
+    private static final int MESSAGE_LENGTH = 24;
+    private static final byte PADDING_IN_PACKET_OUT_MESSAGE = 6;
+    private static PacketOutInputMessageFactory instance;
+    
+    private PacketOutInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized PacketOutInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new PacketOutInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            PacketOutInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeInt(message.getBufferId().intValue());
+        out.writeInt(message.getInPort().getValue().intValue());
+        out.writeShort(ActionsSerializer.computeLengthOfActions(message.getActionsList()));
+        ByteBufUtils.padBuffer(PADDING_IN_PACKET_OUT_MESSAGE, out);
+        ActionsSerializer.encodeActions(message.getActionsList(), out);
+        byte[] data = message.getData();
+        if (data != null) {
+            out.writeBytes(data);
+        }
+    }
+
+    @Override
+    public int computeLength(PacketOutInput message) {
+        int length = MESSAGE_LENGTH;
+        length += ActionsSerializer.computeLengthOfActions(message.getActionsList());
+        byte[] data = message.getData();
+        if (data != null) {
+            length += data.length;
+        }
+        return length;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+}
index e83cdb7d13394ff12cd2e1a61f84e675515c59e7..3a576660afb4e085fbedefac647d3f5ba807ad7e 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;\r
-\r
-/**\r
- * Translates PortMod messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class PortModInputMessageFactory implements OFSerializer<PortModInput> {\r
-    private static final byte MESSAGE_TYPE = 16;\r
-    private static final byte PADDING_IN_PORT_MOD_MESSAGE_01 = 4;\r
-    private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2;\r
-    private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4;\r
-    private static final int MESSAGE_LENGTH = 40;\r
-    private static PortModInputMessageFactory instance;\r
-    \r
-    private PortModInputMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized PortModInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new PortModInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, PortModInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeInt(message.getPortNo().getValue().intValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_01, out);\r
-        out.writeBytes(ByteBufUtils.macAddressToBytes(message.getHwAddress().getValue()));\r
-        ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_02, out);\r
-        out.writeInt(createPortConfigBitmask(message.getConfig()));\r
-        out.writeInt(createPortConfigBitmask(message.getMask()));\r
-        out.writeInt(createPortFeaturesBitmask(message.getAdvertise()));\r
-        ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_03, out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(PortModInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-   \r
-    \r
-    /**\r
-     * @param config\r
-     * @return port config bitmask \r
-     */\r
-    private static int createPortConfigBitmask(PortConfig config) {\r
-        int configBitmask = 0;\r
-        Map<Integer, Boolean> portConfigMap = new HashMap<>();\r
-        portConfigMap.put(0, config.isPortDown());\r
-        portConfigMap.put(2, config.isNoRecv());\r
-        portConfigMap.put(5, config.isNoFwd());\r
-        portConfigMap.put(6, config.isNoPacketIn());\r
-        \r
-        configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);\r
-        return configBitmask;\r
-    }\r
-    \r
-    private static int createPortFeaturesBitmask(PortFeatures feature) {\r
-        int configBitmask = 0;\r
-        Map<Integer, Boolean> portFeaturesMap = new HashMap<>();\r
-        portFeaturesMap.put(0, feature.is_10mbHd());\r
-        portFeaturesMap.put(1, feature.is_10mbFd());\r
-        portFeaturesMap.put(2, feature.is_100mbHd());\r
-        portFeaturesMap.put(3, feature.is_100mbFd());\r
-        portFeaturesMap.put(4, feature.is_1gbHd());\r
-        portFeaturesMap.put(5, feature.is_1gbFd());\r
-        portFeaturesMap.put(6, feature.is_10gbFd());\r
-        portFeaturesMap.put(7, feature.is_40gbFd());\r
-        portFeaturesMap.put(8, feature.is_100gbFd());\r
-        portFeaturesMap.put(9, feature.is_1tbFd());\r
-        portFeaturesMap.put(10, feature.isOther());\r
-        portFeaturesMap.put(11, feature.isCopper());\r
-        portFeaturesMap.put(12, feature.isFiber());\r
-        portFeaturesMap.put(13, feature.isAutoneg());\r
-        portFeaturesMap.put(14, feature.isPause());\r
-        portFeaturesMap.put(15, feature.isPauseAsym());\r
-        \r
-        configBitmask = ByteBufUtils.fillBitMaskFromMap(portFeaturesMap);\r
-        return configBitmask;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+
+/**
+ * Translates PortMod messages
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class PortModInputMessageFactory implements OFSerializer<PortModInput> {
+    private static final byte MESSAGE_TYPE = 16;
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_01 = 4;
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2;
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4;
+    private static final int MESSAGE_LENGTH = 40;
+    private static PortModInputMessageFactory instance;
+    
+    private PortModInputMessageFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized PortModInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new PortModInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, PortModInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeInt(message.getPortNo().getValue().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_01, out);
+        out.writeBytes(ByteBufUtils.macAddressToBytes(message.getHwAddress().getValue()));
+        ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_02, out);
+        out.writeInt(createPortConfigBitmask(message.getConfig()));
+        out.writeInt(createPortConfigBitmask(message.getMask()));
+        out.writeInt(createPortFeaturesBitmask(message.getAdvertise()));
+        ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_03, out);
+    }
+
+    @Override
+    public int computeLength(PortModInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+   
+    
+    /**
+     * @param config
+     * @return port config bitmask 
+     */
+    private static int createPortConfigBitmask(PortConfig config) {
+        int configBitmask = 0;
+        Map<Integer, Boolean> portConfigMap = new HashMap<>();
+        portConfigMap.put(0, config.isPortDown());
+        portConfigMap.put(2, config.isNoRecv());
+        portConfigMap.put(5, config.isNoFwd());
+        portConfigMap.put(6, config.isNoPacketIn());
+        
+        configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);
+        return configBitmask;
+    }
+    
+    private static int createPortFeaturesBitmask(PortFeatures feature) {
+        int configBitmask = 0;
+        Map<Integer, Boolean> portFeaturesMap = new HashMap<>();
+        portFeaturesMap.put(0, feature.is_10mbHd());
+        portFeaturesMap.put(1, feature.is_10mbFd());
+        portFeaturesMap.put(2, feature.is_100mbHd());
+        portFeaturesMap.put(3, feature.is_100mbFd());
+        portFeaturesMap.put(4, feature.is_1gbHd());
+        portFeaturesMap.put(5, feature.is_1gbFd());
+        portFeaturesMap.put(6, feature.is_10gbFd());
+        portFeaturesMap.put(7, feature.is_40gbFd());
+        portFeaturesMap.put(8, feature.is_100gbFd());
+        portFeaturesMap.put(9, feature.is_1tbFd());
+        portFeaturesMap.put(10, feature.isOther());
+        portFeaturesMap.put(11, feature.isCopper());
+        portFeaturesMap.put(12, feature.isFiber());
+        portFeaturesMap.put(13, feature.isAutoneg());
+        portFeaturesMap.put(14, feature.isPause());
+        portFeaturesMap.put(15, feature.isPauseAsym());
+        
+        configBitmask = ByteBufUtils.fillBitMaskFromMap(portFeaturesMap);
+        return configBitmask;
+    }
+}
index b60e14768ad3dbc199a226880676e8f5c821d1c3..285932d25a6c89c52f9276148c114fd3ca890f34 100644 (file)
@@ -1,56 +1,63 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;\r
-\r
-/**\r
- * Translates RoleRequest messages\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class RoleRequestInputMessageFactory implements OFSerializer<RoleRequestInput> {\r
-\r
-    /** Code type of RoleRequest message */\r
-    public static final byte MESSAGE_TYPE = 24;\r
-    private static final int MESSAGE_LENGTH = 24;\r
-    private static final byte PADDING_IN_ROLE_REQUEST_MESSAGE = 4;\r
-    private static RoleRequestInputMessageFactory instance;\r
-    \r
-    private RoleRequestInputMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized RoleRequestInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new RoleRequestInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            RoleRequestInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeInt(message.getRole().getIntValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_ROLE_REQUEST_MESSAGE, out);\r
-        out.writeLong(message.getGenerationId().longValue());\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(RoleRequestInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;
+
+/**
+ * Translates RoleRequest messages
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class RoleRequestInputMessageFactory implements OFSerializer<RoleRequestInput> {
+
+    /** Code type of RoleRequest message */
+    public static final byte MESSAGE_TYPE = 24;
+    private static final int MESSAGE_LENGTH = 24;
+    private static final byte PADDING_IN_ROLE_REQUEST_MESSAGE = 4;
+    private static RoleRequestInputMessageFactory instance;
+    
+    private RoleRequestInputMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized RoleRequestInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new RoleRequestInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            RoleRequestInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeInt(message.getRole().getIntValue());
+        ByteBufUtils.padBuffer(PADDING_IN_ROLE_REQUEST_MESSAGE, out);
+        out.writeLong(message.getGenerationId().longValue());
+    }
+
+    @Override
+    public int computeLength(RoleRequestInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+}
index e83c58995ece6eebb15fc27b260843f513b5dc9d..c647aaf708b53b605a9312d3e10b8eb59f498be6 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;\r
-\r
-/**\r
- * Translates SetAsync messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class SetAsyncInputMessageFactory implements OFSerializer<SetAsyncInput> {\r
-    private static final byte MESSAGE_TYPE = 28;\r
-    private static final int MESSAGE_LENGTH = 32; \r
-    private static SetAsyncInputMessageFactory instance;\r
-    \r
-\r
-    private SetAsyncInputMessageFactory() {\r
-        // singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized SetAsyncInputMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new SetAsyncInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            SetAsyncInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        encodePacketInMask(message.getPacketInMask(), out);\r
-        encodePortStatusMask(message.getPortStatusMask(), out);\r
-        encodeFlowRemovedMask(message.getFlowRemovedMask(), out);\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(SetAsyncInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-    \r
-    private static void encodePacketInMask(List<PacketInMask> packetInMask, ByteBuf outBuffer) {\r
-        if (packetInMask != null) {\r
-            for (PacketInMask currentPacketMask : packetInMask) {\r
-                List<PacketInReason> mask = currentPacketMask.getMask();\r
-                if (mask != null)  {\r
-                    Map<Integer, Boolean> packetInReasonMap = new HashMap<>();\r
-                    for (PacketInReason packetInReason : mask) {\r
-                        if (PacketInReason.OFPRNOMATCH.equals(packetInReason)) {\r
-                            packetInReasonMap.put(PacketInReason.OFPRNOMATCH.getIntValue(), true);\r
-                        } else if (PacketInReason.OFPRACTION.equals(packetInReason)) {\r
-                            packetInReasonMap.put(PacketInReason.OFPRACTION.getIntValue(), true);\r
-                        } else if (PacketInReason.OFPRINVALIDTTL.equals(packetInReason)) {\r
-                            packetInReasonMap.put(PacketInReason.OFPRINVALIDTTL.getIntValue(), true);\r
-                        }\r
-                    }\r
-                    outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(packetInReasonMap));\r
-                }\r
-            }\r
-        }\r
-    }\r
-    \r
-    private static void encodePortStatusMask(List<PortStatusMask> portStatusMask, ByteBuf outBuffer) {\r
-        if (portStatusMask != null) {\r
-            for (PortStatusMask currentPortStatusMask : portStatusMask) {\r
-                List<PortReason> mask = currentPortStatusMask.getMask();\r
-                if (mask != null)  {\r
-                    Map<Integer, Boolean> portStatusReasonMap = new HashMap<>();\r
-                    for (PortReason packetInReason : mask) {\r
-                        if (PortReason.OFPPRADD.equals(packetInReason)) {\r
-                            portStatusReasonMap.put(PortReason.OFPPRADD.getIntValue(), true);\r
-                        } else if (PortReason.OFPPRDELETE.equals(packetInReason)) {\r
-                            portStatusReasonMap.put(PortReason.OFPPRDELETE.getIntValue(), true);\r
-                        } else if (PortReason.OFPPRMODIFY.equals(packetInReason)) {\r
-                            portStatusReasonMap.put(PortReason.OFPPRMODIFY.getIntValue(), true);\r
-                        }\r
-                    }\r
-                    outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(portStatusReasonMap));\r
-                }\r
-            }\r
-        }\r
-    }\r
-    \r
-    private static void encodeFlowRemovedMask(List<FlowRemovedMask> flowRemovedMask, ByteBuf outBuffer) {\r
-        if (flowRemovedMask != null) {\r
-            for (FlowRemovedMask currentFlowRemovedMask : flowRemovedMask) {\r
-                List<FlowRemovedReason> mask = currentFlowRemovedMask.getMask();\r
-                if (mask != null)  {\r
-                    Map<Integer, Boolean> flowRemovedReasonMap = new HashMap<>();\r
-                    for (FlowRemovedReason packetInReason : mask) {\r
-                        if (FlowRemovedReason.OFPRRIDLETIMEOUT.equals(packetInReason)) {\r
-                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRIDLETIMEOUT.getIntValue(), true);\r
-                        } else if (FlowRemovedReason.OFPRRHARDTIMEOUT.equals(packetInReason)) {\r
-                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRHARDTIMEOUT.getIntValue(), true);\r
-                        } else if (FlowRemovedReason.OFPRRDELETE.equals(packetInReason)) {\r
-                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRDELETE.getIntValue(), true);\r
-                        } else if (FlowRemovedReason.OFPRRGROUPDELETE.equals(packetInReason)) {\r
-                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRGROUPDELETE.getIntValue(), true);\r
-                        }\r
-                    }\r
-                    outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(flowRemovedReasonMap));\r
-                }\r
-            }\r
-        }\r
-    }\r
-    \r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;
+
+/**
+ * Translates SetAsync messages
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class SetAsyncInputMessageFactory implements OFSerializer<SetAsyncInput> {
+    private static final byte MESSAGE_TYPE = 28;
+    private static final int MESSAGE_LENGTH = 32; 
+    private static SetAsyncInputMessageFactory instance;
+    
+
+    private SetAsyncInputMessageFactory() {
+        // singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized SetAsyncInputMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new SetAsyncInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            SetAsyncInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        encodePacketInMask(message.getPacketInMask(), out);
+        encodePortStatusMask(message.getPortStatusMask(), out);
+        encodeFlowRemovedMask(message.getFlowRemovedMask(), out);
+    }
+
+    @Override
+    public int computeLength(SetAsyncInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+    
+    private static void encodePacketInMask(List<PacketInMask> packetInMask, ByteBuf outBuffer) {
+        if (packetInMask != null) {
+            for (PacketInMask currentPacketMask : packetInMask) {
+                List<PacketInReason> mask = currentPacketMask.getMask();
+                if (mask != null)  {
+                    Map<Integer, Boolean> packetInReasonMap = new HashMap<>();
+                    for (PacketInReason packetInReason : mask) {
+                        if (PacketInReason.OFPRNOMATCH.equals(packetInReason)) {
+                            packetInReasonMap.put(PacketInReason.OFPRNOMATCH.getIntValue(), true);
+                        } else if (PacketInReason.OFPRACTION.equals(packetInReason)) {
+                            packetInReasonMap.put(PacketInReason.OFPRACTION.getIntValue(), true);
+                        } else if (PacketInReason.OFPRINVALIDTTL.equals(packetInReason)) {
+                            packetInReasonMap.put(PacketInReason.OFPRINVALIDTTL.getIntValue(), true);
+                        }
+                    }
+                    outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(packetInReasonMap));
+                }
+            }
+        }
+    }
+    
+    private static void encodePortStatusMask(List<PortStatusMask> portStatusMask, ByteBuf outBuffer) {
+        if (portStatusMask != null) {
+            for (PortStatusMask currentPortStatusMask : portStatusMask) {
+                List<PortReason> mask = currentPortStatusMask.getMask();
+                if (mask != null)  {
+                    Map<Integer, Boolean> portStatusReasonMap = new HashMap<>();
+                    for (PortReason packetInReason : mask) {
+                        if (PortReason.OFPPRADD.equals(packetInReason)) {
+                            portStatusReasonMap.put(PortReason.OFPPRADD.getIntValue(), true);
+                        } else if (PortReason.OFPPRDELETE.equals(packetInReason)) {
+                            portStatusReasonMap.put(PortReason.OFPPRDELETE.getIntValue(), true);
+                        } else if (PortReason.OFPPRMODIFY.equals(packetInReason)) {
+                            portStatusReasonMap.put(PortReason.OFPPRMODIFY.getIntValue(), true);
+                        }
+                    }
+                    outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(portStatusReasonMap));
+                }
+            }
+        }
+    }
+    
+    private static void encodeFlowRemovedMask(List<FlowRemovedMask> flowRemovedMask, ByteBuf outBuffer) {
+        if (flowRemovedMask != null) {
+            for (FlowRemovedMask currentFlowRemovedMask : flowRemovedMask) {
+                List<FlowRemovedReason> mask = currentFlowRemovedMask.getMask();
+                if (mask != null)  {
+                    Map<Integer, Boolean> flowRemovedReasonMap = new HashMap<>();
+                    for (FlowRemovedReason packetInReason : mask) {
+                        if (FlowRemovedReason.OFPRRIDLETIMEOUT.equals(packetInReason)) {
+                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRIDLETIMEOUT.getIntValue(), true);
+                        } else if (FlowRemovedReason.OFPRRHARDTIMEOUT.equals(packetInReason)) {
+                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRHARDTIMEOUT.getIntValue(), true);
+                        } else if (FlowRemovedReason.OFPRRDELETE.equals(packetInReason)) {
+                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRDELETE.getIntValue(), true);
+                        } else if (FlowRemovedReason.OFPRRGROUPDELETE.equals(packetInReason)) {
+                            flowRemovedReasonMap.put(FlowRemovedReason.OFPRRGROUPDELETE.getIntValue(), true);
+                        }
+                    }
+                    outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(flowRemovedReasonMap));
+                }
+            }
+        }
+    }
+    
 }
\ No newline at end of file
index 2c6f3795944955f29abb9f1f5d15d650c25d2e0f..5e7e628327bcd60e4e2a3b20862dd89b3f9c1792 100644 (file)
@@ -1,54 +1,61 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;\r
-\r
-/**\r
- * Translates SetConfig messages (both OpenFlow v1.0 and OpenFlow v1.3)\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class SetConfigMessageFactory implements OFSerializer<SetConfigInput> {\r
-\r
-    /** Code type of SetConfig message */\r
-    public static final byte MESSAGE_TYPE = 9;\r
-    private static final int MESSAGE_LENGTH = 12;\r
-    private static SetConfigMessageFactory instance;\r
-    \r
-    private SetConfigMessageFactory() {\r
-        // do nothing, just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized SetConfigMessageFactory getInstance() {\r
-        if (instance == null) {\r
-            instance = new SetConfigMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out,\r
-            SetConfigInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeShort(message.getFlags().getIntValue());\r
-        out.writeShort(message.getMissSendLen());\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(SetConfigInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
+
+/**
+ * Translates SetConfig messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class SetConfigMessageFactory implements OFSerializer<SetConfigInput> {
+
+    /** Code type of SetConfig message */
+    public static final byte MESSAGE_TYPE = 9;
+    private static final int MESSAGE_LENGTH = 12;
+    private static SetConfigMessageFactory instance;
+    
+    private SetConfigMessageFactory() {
+        // do nothing, just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized SetConfigMessageFactory getInstance() {
+        if (instance == null) {
+            instance = new SetConfigMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out,
+            SetConfigInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeShort(message.getFlags().getIntValue());
+        out.writeShort(message.getMissSendLen());
+    }
+
+    @Override
+    public int computeLength(SetConfigInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+
+}
index 1255b15909c9cbf60982cc2d5e0dccff771deab9..9c4e3b24f984c259822819fd9e8c34f3632e60f3 100644 (file)
@@ -1,67 +1,74 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;\r
-\r
-/**\r
- * Translates TableMod messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class TableModInputMessageFactory implements OFSerializer<TableModInput> {\r
-    private static final byte MESSAGE_TYPE = 17;\r
-    private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;\r
-    private static final int MESSAGE_LENGTH = 16;\r
-    private static TableModInputMessageFactory instance;\r
-    \r
-    private TableModInputMessageFactory() {\r
-        // just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized TableModInputMessageFactory getInstance() {\r
-        if(instance == null){\r
-            instance = new TableModInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, TableModInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeByte(message.getTableId().getValue().byteValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_TABLE_MOD_MESSAGE, out);\r
-        out.writeInt(createConfigBitmask(message.getConfig()));\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(TableModInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-    \r
-    /**\r
-     * @param tableConfig\r
-     * @return port config bitmask \r
-     */\r
-    private static int createConfigBitmask(TableConfig tableConfig) {\r
-        Map<Integer, Boolean> portConfigMap = new HashMap<>();\r
-        portConfigMap.put(3, tableConfig.isOFPTCDEPRECATEDMASK());\r
-        int configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);\r
-        return configBitmask;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
+
+/**
+ * Translates TableMod messages
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class TableModInputMessageFactory implements OFSerializer<TableModInput> {
+    private static final byte MESSAGE_TYPE = 17;
+    private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;
+    private static final int MESSAGE_LENGTH = 16;
+    private static TableModInputMessageFactory instance;
+    
+    private TableModInputMessageFactory() {
+        // just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized TableModInputMessageFactory getInstance() {
+        if(instance == null){
+            instance = new TableModInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, TableModInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeByte(message.getTableId().getValue().byteValue());
+        ByteBufUtils.padBuffer(PADDING_IN_TABLE_MOD_MESSAGE, out);
+        out.writeInt(createConfigBitmask(message.getConfig()));
+    }
+
+    @Override
+    public int computeLength(TableModInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+    
+    /**
+     * @param tableConfig
+     * @return port config bitmask 
+     */
+    private static int createConfigBitmask(TableConfig tableConfig) {
+        Map<Integer, Boolean> portConfigMap = new HashMap<>();
+        portConfigMap.put(3, tableConfig.isOFPTCDEPRECATEDMASK());
+        int configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);
+        return configBitmask;
+    }
+}
index bfa90f7fd98b1f861a537f1d9710bba7844de297..287c34a83fb83bdb23e8450cede50ab15f1f65ce 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\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.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;\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.GroupIdActionBuilder;\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.MaxLengthActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;\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.PortActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-\r
-/**\r
- * Deserializes ofp_actions (OpenFlow v1.3)\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public abstract class ActionsDeserializer {\r
-    \r
-    private static final byte ACTION_HEADER_LENGTH = 4;\r
-    private static final byte PADDING_IN_ACTIONS_HEADER = 4;\r
-    private static final byte PADDING_IN_OUTPUT_ACTIONS_HEADER = 6;\r
-    private static final byte PADDING_IN_SET_MPLS_TTL_ACTIONS_HEADER = 3;\r
-    private static final byte PADDING_IN_PUSH_VLAN_ACTIONS_HEADER = 2;\r
-    private static final byte PADDING_IN_NW_TTL_ACTIONS_HEADER = 3;\r
-    \r
-    /**\r
-     * Creates list of actions (OpenFlow v1.3)\r
-     * @param input input ByteBuf\r
-     * @param actionsLength length of buckets\r
-     * @return ActionsList\r
-     */\r
-    public static List<ActionsList> createActionsList(ByteBuf input, int actionsLength) {\r
-        ActionsListBuilder actionsListBuilder = new ActionsListBuilder();\r
-        List<ActionsList> actionsList = new ArrayList<>();\r
-        int length = 0;\r
-        while (length < actionsLength) {\r
-            int currentActionLength = 0;\r
-            switch(input.readUnsignedShort()) {\r
-            case 0: currentActionLength = input.readUnsignedShort(); //outputActionLength\r
-            actionsList.add(createOutputAction(input, actionsListBuilder));\r
-            break;\r
-            case 11: \r
-                currentActionLength = input.readUnsignedShort();//empty header length\r
-                actionsList.add(createCopyTtlOutAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 12: \r
-                currentActionLength = input.readUnsignedShort();//empty header length\r
-                actionsList.add(createCopyTtlInAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 15: \r
-                currentActionLength = input.readUnsignedShort();//empty header length\r
-                actionsList.add(createSetMplsTtlAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 16:                              \r
-                currentActionLength = input.readUnsignedShort();//empty header length\r
-                actionsList.add(createDecMplsTtlOutAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 17: \r
-                currentActionLength = input.readUnsignedShort();\r
-                actionsList.add(createPushVlanAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 18:                              \r
-                currentActionLength = input.readUnsignedShort();//empty header length\r
-                actionsList.add(createPopVlanAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 19: \r
-                currentActionLength = input.readUnsignedShort();//8\r
-                actionsList.add(createPushMplsAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 20: \r
-                currentActionLength = input.readUnsignedShort();//8\r
-                actionsList.add(createPopMplsAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 21: \r
-                currentActionLength = input.readUnsignedShort();\r
-                actionsList.add(createSetQueueAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 22: \r
-                currentActionLength = input.readUnsignedShort();//8\r
-                actionsList.add(createGroupAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 23: \r
-                currentActionLength = input.readUnsignedShort();//8\r
-                actionsList.add(createSetNwTtlAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 24:                              \r
-                currentActionLength = input.readUnsignedShort();//empty header length\r
-                actionsList.add(createDecNwTtlAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 25:\r
-                currentActionLength = input.readUnsignedShort();//8\r
-                actionsList.add(createSetFieldAction(input, actionsListBuilder, currentActionLength));\r
-                break; \r
-            case 26: \r
-                currentActionLength = input.readUnsignedShort();//8\r
-                actionsList.add(createPushPbbAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 27:                              \r
-                currentActionLength = input.readUnsignedShort();//empty header length\r
-                actionsList.add(createPopPbbAction(input, actionsListBuilder));\r
-                break;\r
-\r
-            case 0xFFFF: \r
-                currentActionLength = input.readUnsignedShort();\r
-                actionsList.add(createExperimenterAction(input, actionsListBuilder));\r
-                break;\r
-            default: \r
-                break;\r
-            }\r
-            length += currentActionLength;\r
-        } \r
-        return actionsList;\r
-    }\r
-    \r
-    private static ActionsList createEmptyHeader(Class<? extends org.opendaylight.yang.gen.v1.\r
-            urn.opendaylight.openflow.common.types.rev130731.Action> action,\r
-            ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(action);\r
-        in.skipBytes(PADDING_IN_ACTIONS_HEADER);\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        return actionsListBuilder.build();\r
-    }\r
-    \r
-    private static ActionsList createCopyTtlInAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        return createEmptyHeader(CopyTtlIn.class, in, actionsListBuilder);\r
-    }\r
-\r
-    private static ActionsList createCopyTtlOutAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        return createEmptyHeader(CopyTtlOut.class, in, actionsListBuilder);\r
-    }\r
-    \r
-    private static ActionsList createDecMplsTtlOutAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        return createEmptyHeader(DecMplsTtl.class, in, actionsListBuilder);\r
-    }\r
-    \r
-    private static ActionsList createPopVlanAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        return createEmptyHeader(PopVlan.class, in, actionsListBuilder);\r
-    }\r
-    \r
-    private static ActionsList createDecNwTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        return createEmptyHeader(DecNwTtl.class, in, actionsListBuilder);\r
-    }\r
-    \r
-    private static ActionsList createPopPbbAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        return createEmptyHeader(PopPbb.class, in, actionsListBuilder);\r
-    }\r
-    \r
-    private static ActionsList createOutputAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(Output.class);\r
-        PortActionBuilder port = new PortActionBuilder();\r
-        port.setPort(new PortNumber(in.readUnsignedInt()));\r
-        actionBuilder.addAugmentation(PortAction.class, port.build());\r
-        MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder();\r
-        maxLen.setMaxLength(in.readUnsignedShort());\r
-        actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        in.skipBytes(PADDING_IN_OUTPUT_ACTIONS_HEADER);\r
-        return actionsListBuilder.build();\r
-    }\r
-    \r
-    private static ActionsList createSetMplsTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetMplsTtl.class);\r
-        MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder();\r
-        mplsTtl.setMplsTtl(in.readUnsignedByte());\r
-        actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        in.skipBytes(PADDING_IN_SET_MPLS_TTL_ACTIONS_HEADER);\r
-        return actionsListBuilder.build();\r
-    }\r
-    \r
-    private static ActionsList createPushAction(Class<? extends org.opendaylight.yang.gen.\r
-            v1.urn.opendaylight.openflow.common.types.rev130731.Action> action,\r
-            ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(action);\r
-        EthertypeActionBuilder etherType = new EthertypeActionBuilder();\r
-        etherType.setEthertype(new EtherType(in.readUnsignedShort()));\r
-        actionBuilder.addAugmentation(EthertypeAction.class, etherType.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        in.skipBytes(PADDING_IN_PUSH_VLAN_ACTIONS_HEADER);\r
-        return actionsListBuilder.build();\r
-    }\r
-    \r
-    private static ActionsList createPushVlanAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        return createPushAction(PushVlan.class, in, actionsListBuilder);\r
-    }\r
-    \r
-    private static ActionsList createPushMplsAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        return createPushAction(PushMpls.class, in, actionsListBuilder);\r
-    }\r
-    \r
-    private static ActionsList createPopMplsAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        return createPushAction(PopMpls.class, in, actionsListBuilder);\r
-    }\r
-    \r
-    private static ActionsList createPushPbbAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        return createPushAction(PushPbb.class, in, actionsListBuilder);\r
-    }\r
-    \r
-    private static ActionsList createSetQueueAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetQueue.class);\r
-        QueueIdActionBuilder queueId = new QueueIdActionBuilder();\r
-        queueId.setQueueId(in.readUnsignedInt());\r
-        actionBuilder.addAugmentation(QueueIdAction.class, queueId.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        return actionsListBuilder.build();\r
-    }\r
-    \r
-    private static ActionsList createGroupAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(Group.class);\r
-        GroupIdActionBuilder group = new GroupIdActionBuilder();\r
-        group.setGroupId(in.readUnsignedInt());\r
-        actionBuilder.addAugmentation(GroupIdAction.class, group.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        return actionsListBuilder.build();\r
-    }\r
-    \r
-    private static ActionsList createExperimenterAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(Experimenter.class);\r
-        ExperimenterActionBuilder experimenter = new ExperimenterActionBuilder();\r
-        experimenter.setExperimenter(in.readUnsignedInt());\r
-        actionBuilder.addAugmentation(ExperimenterAction.class, experimenter.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        return actionsListBuilder.build();\r
-    }\r
-    \r
-    private static ActionsList createSetNwTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetNwTtl.class);\r
-        NwTtlActionBuilder nwTtl = new NwTtlActionBuilder();\r
-        nwTtl.setNwTtl(in.readUnsignedByte());\r
-        actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        in.skipBytes(PADDING_IN_NW_TTL_ACTIONS_HEADER);\r
-        return actionsListBuilder.build();\r
-    }\r
-    \r
-    private static ActionsList createSetFieldAction(ByteBuf in, ActionsListBuilder actionsListBuilder, int actionLength) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetField.class);\r
-        OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder();\r
-        matchEntries.setMatchEntries(MatchDeserializer.createMatchEntry(in, actionLength  - ACTION_HEADER_LENGTH));\r
-        actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        return actionsListBuilder.build();\r
-    }\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;
+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.Group;
+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.PopMpls;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+
+/**
+ * Deserializes ofp_actions (OpenFlow v1.3)
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public abstract class ActionsDeserializer {
+    
+    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;
+    
+    /**
+     * Creates list of actions (OpenFlow v1.3)
+     * @param input input ByteBuf
+     * @param actionsLength length of buckets
+     * @return ActionsList
+     */
+    public static List<ActionsList> createActionsList(ByteBuf input, int actionsLength) {
+        ActionsListBuilder actionsListBuilder = new ActionsListBuilder();
+        List<ActionsList> actionsList = new ArrayList<>();
+        int length = 0;
+        while (length < actionsLength) {
+            int currentActionLength = 0;
+            switch(input.readUnsignedShort()) {
+            case 0: currentActionLength = input.readUnsignedShort(); //outputActionLength
+            actionsList.add(createOutputAction(input, actionsListBuilder));
+            break;
+            case 11: 
+                currentActionLength = input.readUnsignedShort();//empty header length
+                actionsList.add(createCopyTtlOutAction(input, actionsListBuilder));
+                break;
+
+            case 12: 
+                currentActionLength = input.readUnsignedShort();//empty header length
+                actionsList.add(createCopyTtlInAction(input, actionsListBuilder));
+                break;
+
+            case 15: 
+                currentActionLength = input.readUnsignedShort();//empty header length
+                actionsList.add(createSetMplsTtlAction(input, actionsListBuilder));
+                break;
+
+            case 16:                              
+                currentActionLength = input.readUnsignedShort();//empty header length
+                actionsList.add(createDecMplsTtlOutAction(input, actionsListBuilder));
+                break;
+
+            case 17: 
+                currentActionLength = input.readUnsignedShort();
+                actionsList.add(createPushVlanAction(input, actionsListBuilder));
+                break;
+
+            case 18:                              
+                currentActionLength = input.readUnsignedShort();//empty header length
+                actionsList.add(createPopVlanAction(input, actionsListBuilder));
+                break;
+
+            case 19: 
+                currentActionLength = input.readUnsignedShort();//8
+                actionsList.add(createPushMplsAction(input, actionsListBuilder));
+                break;
+
+            case 20: 
+                currentActionLength = input.readUnsignedShort();//8
+                actionsList.add(createPopMplsAction(input, actionsListBuilder));
+                break;
+
+            case 21: 
+                currentActionLength = input.readUnsignedShort();
+                actionsList.add(createSetQueueAction(input, actionsListBuilder));
+                break;
+
+            case 22: 
+                currentActionLength = input.readUnsignedShort();//8
+                actionsList.add(createGroupAction(input, actionsListBuilder));
+                break;
+
+            case 23: 
+                currentActionLength = input.readUnsignedShort();//8
+                actionsList.add(createSetNwTtlAction(input, actionsListBuilder));
+                break;
+
+            case 24:                              
+                currentActionLength = input.readUnsignedShort();//empty header length
+                actionsList.add(createDecNwTtlAction(input, actionsListBuilder));
+                break;
+
+            case 25:
+                currentActionLength = input.readUnsignedShort();//8
+                actionsList.add(createSetFieldAction(input, actionsListBuilder, currentActionLength));
+                break; 
+            case 26: 
+                currentActionLength = input.readUnsignedShort();//8
+                actionsList.add(createPushPbbAction(input, actionsListBuilder));
+                break;
+
+            case 27:                              
+                currentActionLength = input.readUnsignedShort();//empty header length
+                actionsList.add(createPopPbbAction(input, actionsListBuilder));
+                break;
+
+            case 0xFFFF: 
+                currentActionLength = input.readUnsignedShort();
+                actionsList.add(createExperimenterAction(input, actionsListBuilder));
+                break;
+            default: 
+                break;
+            }
+            length += currentActionLength;
+        } 
+        return actionsList;
+    }
+    
+    private static ActionsList createEmptyHeader(Class<? extends org.opendaylight.yang.gen.v1.
+            urn.opendaylight.openflow.common.types.rev130731.Action> action,
+            ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(action);
+        in.skipBytes(PADDING_IN_ACTIONS_HEADER);
+        actionsListBuilder.setAction(actionBuilder.build());
+        return actionsListBuilder.build();
+    }
+    
+    private static ActionsList createCopyTtlInAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        return createEmptyHeader(CopyTtlIn.class, in, actionsListBuilder);
+    }
+
+    private static ActionsList createCopyTtlOutAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        return createEmptyHeader(CopyTtlOut.class, in, actionsListBuilder);
+    }
+    
+    private static ActionsList createDecMplsTtlOutAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        return createEmptyHeader(DecMplsTtl.class, in, actionsListBuilder);
+    }
+    
+    private static ActionsList createPopVlanAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        return createEmptyHeader(PopVlan.class, in, actionsListBuilder);
+    }
+    
+    private static ActionsList createDecNwTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        return createEmptyHeader(DecNwTtl.class, in, actionsListBuilder);
+    }
+    
+    private static ActionsList createPopPbbAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        return createEmptyHeader(PopPbb.class, in, actionsListBuilder);
+    }
+    
+    private static ActionsList createOutputAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(Output.class);
+        PortActionBuilder port = new PortActionBuilder();
+        port.setPort(new PortNumber(in.readUnsignedInt()));
+        actionBuilder.addAugmentation(PortAction.class, port.build());
+        MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder();
+        maxLen.setMaxLength(in.readUnsignedShort());
+        actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        in.skipBytes(PADDING_IN_OUTPUT_ACTIONS_HEADER);
+        return actionsListBuilder.build();
+    }
+    
+    private static ActionsList createSetMplsTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetMplsTtl.class);
+        MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder();
+        mplsTtl.setMplsTtl(in.readUnsignedByte());
+        actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        in.skipBytes(PADDING_IN_SET_MPLS_TTL_ACTIONS_HEADER);
+        return actionsListBuilder.build();
+    }
+    
+    private static ActionsList createPushAction(Class<? extends org.opendaylight.yang.gen.
+            v1.urn.opendaylight.openflow.common.types.rev130731.Action> action,
+            ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(action);
+        EthertypeActionBuilder etherType = new EthertypeActionBuilder();
+        etherType.setEthertype(new EtherType(in.readUnsignedShort()));
+        actionBuilder.addAugmentation(EthertypeAction.class, etherType.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        in.skipBytes(PADDING_IN_PUSH_VLAN_ACTIONS_HEADER);
+        return actionsListBuilder.build();
+    }
+    
+    private static ActionsList createPushVlanAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        return createPushAction(PushVlan.class, in, actionsListBuilder);
+    }
+    
+    private static ActionsList createPushMplsAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        return createPushAction(PushMpls.class, in, actionsListBuilder);
+    }
+    
+    private static ActionsList createPopMplsAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        return createPushAction(PopMpls.class, in, actionsListBuilder);
+    }
+    
+    private static ActionsList createPushPbbAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        return createPushAction(PushPbb.class, in, actionsListBuilder);
+    }
+    
+    private static ActionsList createSetQueueAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetQueue.class);
+        QueueIdActionBuilder queueId = new QueueIdActionBuilder();
+        queueId.setQueueId(in.readUnsignedInt());
+        actionBuilder.addAugmentation(QueueIdAction.class, queueId.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        return actionsListBuilder.build();
+    }
+    
+    private static ActionsList createGroupAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(Group.class);
+        GroupIdActionBuilder group = new GroupIdActionBuilder();
+        group.setGroupId(in.readUnsignedInt());
+        actionBuilder.addAugmentation(GroupIdAction.class, group.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        return actionsListBuilder.build();
+    }
+    
+    private static ActionsList createExperimenterAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(Experimenter.class);
+        ExperimenterActionBuilder experimenter = new ExperimenterActionBuilder();
+        experimenter.setExperimenter(in.readUnsignedInt());
+        actionBuilder.addAugmentation(ExperimenterAction.class, experimenter.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        return actionsListBuilder.build();
+    }
+    
+    private static ActionsList createSetNwTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetNwTtl.class);
+        NwTtlActionBuilder nwTtl = new NwTtlActionBuilder();
+        nwTtl.setNwTtl(in.readUnsignedByte());
+        actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        in.skipBytes(PADDING_IN_NW_TTL_ACTIONS_HEADER);
+        return actionsListBuilder.build();
+    }
+    
+    private static ActionsList createSetFieldAction(ByteBuf in, ActionsListBuilder actionsListBuilder, int actionLength) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetField.class);
+        OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder();
+        matchEntries.setMatchEntries(MatchDeserializer.createMatchEntry(in, actionLength  - ACTION_HEADER_LENGTH));
+        actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        return actionsListBuilder.build();
+    }
+}
index 69698c561183501c534ed6557226274d04520e0a..b635567806f76af612f59539600323e9c811a108 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.List;\r
-\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
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;\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.QueueIdAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;\r
-\r
-/**\r
- * Serializes ofp_actions (OpenFlow v1.3)\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public abstract class ActionsSerializer {\r
-\r
-    private static final byte OUTPUT_CODE = 0;\r
-    private static final byte COPY_TTL_OUT_CODE = 11;\r
-    private static final byte COPY_TTL_IN_CODE = 12;\r
-    private static final byte SET_MPLS_TTL_CODE = 15;\r
-    private static final byte DEC_MPLS_TTL_CODE = 16;\r
-    private static final byte PUSH_VLAN_CODE = 17;\r
-    private static final byte POP_VLAN_CODE = 18;\r
-    private static final byte PUSH_MPLS_CODE = 19;\r
-    private static final byte POP_MPLS_CODE = 20;\r
-    private static final byte SET_QUEUE_CODE = 21;\r
-    private static final byte GROUP_CODE = 22;\r
-    private static final byte SET_NW_TTL_CODE = 23;\r
-    private static final byte DEC_NW_TTL_CODE = 24;\r
-    private static final int SET_FIELD_CODE = 25;\r
-    private static final byte PUSH_PBB_CODE = 26;\r
-    private static final byte POP_PBB_CODE = 27;\r
-    private static final int EXPERIMENTER_CODE = 65535; // 0xFFFF\r
-    private static final byte OUTPUT_LENGTH = 16;\r
-    private static final byte SET_MPLS_TTL_LENGTH = 8;\r
-    private static final byte SET_QUEUE_LENGTH = 8;\r
-    private static final byte GROUP_LENGTH = 8;\r
-    private static final byte SET_NW_TTL_LENGTH = 8;\r
-    private static final byte EXPERIMENTER_LENGTH = 8;\r
-    private static final byte ACTION_HEADER_LENGTH = 8;\r
-    private static final byte LENGTH_OF_ETHERTYPE_ACTION = 8;\r
-    private static final byte LENGTH_OF_OTHER_ACTIONS = 8;\r
-    private static final byte SET_FIELD_HEADER_LENGTH = 4; // only type and length\r
-    private static final byte OUTPUT_PADDING = 6;\r
-    private static final byte SET_MPLS_TTL_PADDING = 3;\r
-    private static final byte SET_NW_TTL_PADDING = 3;\r
-    private static final byte PADDING_IN_ACTION_HEADER = 4;\r
-    private static final byte ETHERTYPE_ACTION_PADDING = 2;\r
-\r
-\r
-    /**\r
-     * Encodes actions to ByteBuf\r
-     * @param actionsList list of actions to be encoded\r
-     * @param outBuffer output ByteBuf\r
-     */\r
-    public static void encodeActions(List<ActionsList> actionsList, ByteBuf outBuffer) {\r
-        if (actionsList == null) {\r
-            return;\r
-        }\r
-        for (ActionsList list : actionsList) {\r
-            Action action = list.getAction();\r
-            if (action.getType().isAssignableFrom(Output.class)) {\r
-                encodeOutputAction(action, outBuffer);\r
-            } else if (action.getType().isAssignableFrom(CopyTtlOut.class)) {\r
-                encodeCopyTtlOutAction(outBuffer);\r
-            } else if (action.getType().isAssignableFrom(CopyTtlIn.class)) {\r
-                encodeCopyTtlInAction(outBuffer);\r
-            } else if (action.getType().isAssignableFrom(SetMplsTtl.class)) {\r
-                encodeSetMplsTtltAction(action, outBuffer);\r
-            } else if (action.getType().isAssignableFrom(DecMplsTtl.class)) {\r
-                encodeDecMplsTtlAction(outBuffer);\r
-            } else if (action.getType().isAssignableFrom(PushVlan.class)) {\r
-                encodePushVlanAction(action, outBuffer);\r
-            } else if (action.getType().isAssignableFrom(PopVlan.class)) {\r
-                encodePopVlanAction(outBuffer);\r
-            } else if (action.getType().isAssignableFrom(PushMpls.class)) {\r
-                encodePushMplsAction(action, outBuffer);\r
-            } else if (action.getType().isAssignableFrom(PopMpls.class)) {\r
-                encodePopMplsAction(action, outBuffer);\r
-            } else if (action.getType().isAssignableFrom(SetQueue.class)) {\r
-                encodeSetQueueAction(action, outBuffer);\r
-            } else if (action.getType().isAssignableFrom(Group.class)) {\r
-                encodeGroupAction(action, outBuffer);\r
-            } else if (action.getType().isAssignableFrom(SetNwTtl.class)) {\r
-                encodeSetNwTtlAction(action, outBuffer);\r
-            } else if (action.getType().isAssignableFrom(DecNwTtl.class)) {\r
-                encodeDecNwTtlAction(outBuffer);\r
-            } else if (action.getType().isAssignableFrom(SetField.class)) {\r
-                encodeSetFieldAction(action, outBuffer);\r
-            } else if (action.getType().isAssignableFrom(PushPbb.class)) {\r
-                encodePushPbbAction(action, outBuffer);\r
-            } else if (action.getType().isAssignableFrom(PopPbb.class)) {\r
-                encodePopPbbAction(outBuffer);\r
-            } else if (action.getType().isAssignableFrom(Experimenter.class)) {\r
-                encodeExperimenterAction(action, outBuffer);\r
-            } \r
-        }\r
-    }\r
-\r
-    private static void encodeOutputAction(Action action, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(OUTPUT_CODE);\r
-        outBuffer.writeShort(OUTPUT_LENGTH);\r
-        PortAction port = action.getAugmentation(PortAction.class);\r
-        outBuffer.writeInt(port.getPort().getValue().intValue());\r
-        MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class);\r
-        outBuffer.writeShort(maxlength.getMaxLength());\r
-        ByteBufUtils.padBuffer(OUTPUT_PADDING, outBuffer);\r
-    }\r
-\r
-    private static void encodeCopyTtlOutAction(ByteBuf outBuffer) {\r
-        outBuffer.writeShort(COPY_TTL_OUT_CODE);\r
-        encodeRestOfActionHeader(outBuffer);\r
-    }\r
-    \r
-    private static void encodeCopyTtlInAction(ByteBuf outBuffer) {\r
-        outBuffer.writeShort(COPY_TTL_IN_CODE);\r
-        encodeRestOfActionHeader(outBuffer);\r
-    }\r
-    \r
-    private static void encodeSetMplsTtltAction(Action action, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(SET_MPLS_TTL_CODE);\r
-        outBuffer.writeShort(SET_MPLS_TTL_LENGTH);\r
-        MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class);\r
-        outBuffer.writeByte(mplsTtl.getMplsTtl());\r
-        ByteBufUtils.padBuffer(SET_MPLS_TTL_PADDING, outBuffer);\r
-    }\r
-    \r
-    private static void encodeDecMplsTtlAction(ByteBuf outBuffer) {\r
-        outBuffer.writeShort(DEC_MPLS_TTL_CODE);\r
-        encodeRestOfActionHeader(outBuffer);\r
-    }\r
-    \r
-    private static void encodePushVlanAction(Action action, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(PUSH_VLAN_CODE);\r
-        encodeCommonEthertype(action, outBuffer);\r
-    }\r
-\r
-    private static void encodePopVlanAction(ByteBuf outBuffer) {\r
-        outBuffer.writeShort(POP_VLAN_CODE);\r
-        encodeRestOfActionHeader(outBuffer);\r
-    }\r
-    \r
-    private static void encodePushMplsAction(Action action, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(PUSH_MPLS_CODE);\r
-        encodeCommonEthertype(action, outBuffer);\r
-    }\r
-    \r
-    private static void encodePopMplsAction(Action action, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(POP_MPLS_CODE);\r
-        encodeCommonEthertype(action, outBuffer);\r
-    }\r
-    \r
-    private static void encodeSetQueueAction(Action action, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(SET_QUEUE_CODE);\r
-        outBuffer.writeShort(SET_QUEUE_LENGTH);\r
-        QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);\r
-        outBuffer.writeInt(queueId.getQueueId().intValue());\r
-    }\r
-\r
-    private static void encodeGroupAction(Action action, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(GROUP_CODE);\r
-        outBuffer.writeShort(GROUP_LENGTH);\r
-        GroupIdAction groupId = action.getAugmentation(GroupIdAction.class);\r
-        outBuffer.writeInt(groupId.getGroupId().intValue());\r
-    }\r
-    \r
-    private static void encodeSetNwTtlAction(Action action, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(SET_NW_TTL_CODE);\r
-        outBuffer.writeShort(SET_NW_TTL_LENGTH);\r
-        NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class);\r
-        outBuffer.writeByte(nwTtl.getNwTtl());\r
-        ByteBufUtils.padBuffer(SET_NW_TTL_PADDING, outBuffer);\r
-    }\r
-    \r
-    private static void encodeDecNwTtlAction(ByteBuf outBuffer) {\r
-        outBuffer.writeShort(DEC_NW_TTL_CODE);\r
-        encodeRestOfActionHeader(outBuffer);\r
-    }\r
-    \r
-    private static void encodeSetFieldAction(Action action, ByteBuf outBuffer) {\r
-        OxmFieldsAction oxmField = action.getAugmentation(OxmFieldsAction.class);\r
-        int length = MatchSerializer.computeMatchEntriesLength(oxmField.getMatchEntries()) + SET_FIELD_HEADER_LENGTH;\r
-        outBuffer.writeShort(SET_FIELD_CODE);\r
-        int paddingRemainder = length % EncodeConstants.PADDING;\r
-        if (paddingRemainder != 0) {\r
-            length += EncodeConstants.PADDING - paddingRemainder;\r
-        }\r
-        outBuffer.writeShort(length);\r
-        MatchSerializer.encodeMatchEntries(oxmField.getMatchEntries(), outBuffer);\r
-        ByteBufUtils.padBuffer(EncodeConstants.PADDING - paddingRemainder, outBuffer);\r
-    }\r
-    \r
-    private static void encodePushPbbAction(Action action, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(PUSH_PBB_CODE);\r
-        encodeCommonEthertype(action, outBuffer);\r
-    }\r
-    \r
-    private static void encodePopPbbAction(ByteBuf outBuffer) {\r
-        outBuffer.writeShort(POP_PBB_CODE);\r
-        encodeRestOfActionHeader(outBuffer);\r
-    }\r
-\r
-    private static void encodeExperimenterAction(Action action, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(EXPERIMENTER_CODE);\r
-        outBuffer.writeShort(EXPERIMENTER_LENGTH);\r
-        ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class);\r
-        outBuffer.writeInt(experimenter.getExperimenter().intValue());\r
-    }\r
-    \r
-    private static void encodeRestOfActionHeader(ByteBuf outBuffer) {\r
-        outBuffer.writeShort(ACTION_HEADER_LENGTH);\r
-        ByteBufUtils.padBuffer(PADDING_IN_ACTION_HEADER, outBuffer);\r
-    }\r
-    \r
-    private static void encodeCommonEthertype(Action action, ByteBuf outBuffer) {\r
-        EthertypeAction ethertype = action.getAugmentation(EthertypeAction.class);\r
-        outBuffer.writeShort(LENGTH_OF_ETHERTYPE_ACTION);\r
-        outBuffer.writeShort(ethertype.getEthertype().getValue());\r
-        ByteBufUtils.padBuffer(ETHERTYPE_ACTION_PADDING, outBuffer);\r
-    }\r
-    \r
-    /**\r
-     * Computes length of actions\r
-     * @param actionsList list of actions\r
-     * @return actions length\r
-     */\r
-    public static int computeLengthOfActions(List<ActionsList> actionsList) {\r
-        int lengthOfActions = 0;\r
-        if (actionsList != null) {\r
-            for (ActionsList list : actionsList) {\r
-                Action action = list.getAction();\r
-                if (action.getType().isAssignableFrom(Output.class)) {\r
-                    lengthOfActions += OUTPUT_LENGTH;\r
-                } else if (action.getType().isAssignableFrom(SetField.class)){\r
-                    List<MatchEntries> entries = action.getAugmentation(OxmFieldsAction.class).getMatchEntries();\r
-                    int actionLength = (2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES) + MatchSerializer.computeMatchEntriesLength(entries);\r
-                    lengthOfActions += actionLength;\r
-                    int paddingRemainder = actionLength % EncodeConstants.PADDING;\r
-                    if ((paddingRemainder) != 0) {\r
-                        lengthOfActions += EncodeConstants.PADDING - paddingRemainder;\r
-                    }\r
-                } else {\r
-                    lengthOfActions += LENGTH_OF_OTHER_ACTIONS;\r
-                }\r
-            }\r
-        }\r
-        return lengthOfActions;\r
-    }\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;
+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.Group;
+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.PopMpls;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
+
+/**
+ * Serializes ofp_actions (OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public abstract class ActionsSerializer {
+
+    private static final byte OUTPUT_CODE = 0;
+    private static final byte COPY_TTL_OUT_CODE = 11;
+    private static final byte COPY_TTL_IN_CODE = 12;
+    private static final byte SET_MPLS_TTL_CODE = 15;
+    private static final byte DEC_MPLS_TTL_CODE = 16;
+    private static final byte PUSH_VLAN_CODE = 17;
+    private static final byte POP_VLAN_CODE = 18;
+    private static final byte PUSH_MPLS_CODE = 19;
+    private static final byte POP_MPLS_CODE = 20;
+    private static final byte SET_QUEUE_CODE = 21;
+    private static final byte GROUP_CODE = 22;
+    private static final byte SET_NW_TTL_CODE = 23;
+    private static final byte DEC_NW_TTL_CODE = 24;
+    private static final int SET_FIELD_CODE = 25;
+    private static final byte PUSH_PBB_CODE = 26;
+    private static final byte POP_PBB_CODE = 27;
+    private static final int EXPERIMENTER_CODE = 65535; // 0xFFFF
+    private static final byte OUTPUT_LENGTH = 16;
+    private static final byte SET_MPLS_TTL_LENGTH = 8;
+    private static final byte SET_QUEUE_LENGTH = 8;
+    private static final byte GROUP_LENGTH = 8;
+    private static final byte SET_NW_TTL_LENGTH = 8;
+    private static final byte EXPERIMENTER_LENGTH = 8;
+    private static final byte ACTION_HEADER_LENGTH = 8;
+    private static final byte LENGTH_OF_ETHERTYPE_ACTION = 8;
+    private static final byte LENGTH_OF_OTHER_ACTIONS = 8;
+    private static final byte SET_FIELD_HEADER_LENGTH = 4; // only type and length
+    private static final byte OUTPUT_PADDING = 6;
+    private static final byte SET_MPLS_TTL_PADDING = 3;
+    private static final byte SET_NW_TTL_PADDING = 3;
+    private static final byte PADDING_IN_ACTION_HEADER = 4;
+    private static final byte ETHERTYPE_ACTION_PADDING = 2;
+
+
+    /**
+     * Encodes actions to ByteBuf
+     * @param actionsList list of actions to be encoded
+     * @param outBuffer output ByteBuf
+     */
+    public static void encodeActions(List<ActionsList> actionsList, ByteBuf outBuffer) {
+        if (actionsList == null) {
+            return;
+        }
+        for (ActionsList list : actionsList) {
+            Action action = list.getAction();
+            if (action.getType().isAssignableFrom(Output.class)) {
+                encodeOutputAction(action, outBuffer);
+            } else if (action.getType().isAssignableFrom(CopyTtlOut.class)) {
+                encodeCopyTtlOutAction(outBuffer);
+            } else if (action.getType().isAssignableFrom(CopyTtlIn.class)) {
+                encodeCopyTtlInAction(outBuffer);
+            } else if (action.getType().isAssignableFrom(SetMplsTtl.class)) {
+                encodeSetMplsTtltAction(action, outBuffer);
+            } else if (action.getType().isAssignableFrom(DecMplsTtl.class)) {
+                encodeDecMplsTtlAction(outBuffer);
+            } else if (action.getType().isAssignableFrom(PushVlan.class)) {
+                encodePushVlanAction(action, outBuffer);
+            } else if (action.getType().isAssignableFrom(PopVlan.class)) {
+                encodePopVlanAction(outBuffer);
+            } else if (action.getType().isAssignableFrom(PushMpls.class)) {
+                encodePushMplsAction(action, outBuffer);
+            } else if (action.getType().isAssignableFrom(PopMpls.class)) {
+                encodePopMplsAction(action, outBuffer);
+            } else if (action.getType().isAssignableFrom(SetQueue.class)) {
+                encodeSetQueueAction(action, outBuffer);
+            } else if (action.getType().isAssignableFrom(Group.class)) {
+                encodeGroupAction(action, outBuffer);
+            } else if (action.getType().isAssignableFrom(SetNwTtl.class)) {
+                encodeSetNwTtlAction(action, outBuffer);
+            } else if (action.getType().isAssignableFrom(DecNwTtl.class)) {
+                encodeDecNwTtlAction(outBuffer);
+            } else if (action.getType().isAssignableFrom(SetField.class)) {
+                encodeSetFieldAction(action, outBuffer);
+            } else if (action.getType().isAssignableFrom(PushPbb.class)) {
+                encodePushPbbAction(action, outBuffer);
+            } else if (action.getType().isAssignableFrom(PopPbb.class)) {
+                encodePopPbbAction(outBuffer);
+            } else if (action.getType().isAssignableFrom(Experimenter.class)) {
+                encodeExperimenterAction(action, outBuffer);
+            } 
+        }
+    }
+
+    private static void encodeOutputAction(Action action, ByteBuf outBuffer) {
+        outBuffer.writeShort(OUTPUT_CODE);
+        outBuffer.writeShort(OUTPUT_LENGTH);
+        PortAction port = action.getAugmentation(PortAction.class);
+        outBuffer.writeInt(port.getPort().getValue().intValue());
+        MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class);
+        outBuffer.writeShort(maxlength.getMaxLength());
+        ByteBufUtils.padBuffer(OUTPUT_PADDING, outBuffer);
+    }
+
+    private static void encodeCopyTtlOutAction(ByteBuf outBuffer) {
+        outBuffer.writeShort(COPY_TTL_OUT_CODE);
+        encodeRestOfActionHeader(outBuffer);
+    }
+    
+    private static void encodeCopyTtlInAction(ByteBuf outBuffer) {
+        outBuffer.writeShort(COPY_TTL_IN_CODE);
+        encodeRestOfActionHeader(outBuffer);
+    }
+    
+    private static void encodeSetMplsTtltAction(Action action, ByteBuf outBuffer) {
+        outBuffer.writeShort(SET_MPLS_TTL_CODE);
+        outBuffer.writeShort(SET_MPLS_TTL_LENGTH);
+        MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class);
+        outBuffer.writeByte(mplsTtl.getMplsTtl());
+        ByteBufUtils.padBuffer(SET_MPLS_TTL_PADDING, outBuffer);
+    }
+    
+    private static void encodeDecMplsTtlAction(ByteBuf outBuffer) {
+        outBuffer.writeShort(DEC_MPLS_TTL_CODE);
+        encodeRestOfActionHeader(outBuffer);
+    }
+    
+    private static void encodePushVlanAction(Action action, ByteBuf outBuffer) {
+        outBuffer.writeShort(PUSH_VLAN_CODE);
+        encodeCommonEthertype(action, outBuffer);
+    }
+
+    private static void encodePopVlanAction(ByteBuf outBuffer) {
+        outBuffer.writeShort(POP_VLAN_CODE);
+        encodeRestOfActionHeader(outBuffer);
+    }
+    
+    private static void encodePushMplsAction(Action action, ByteBuf outBuffer) {
+        outBuffer.writeShort(PUSH_MPLS_CODE);
+        encodeCommonEthertype(action, outBuffer);
+    }
+    
+    private static void encodePopMplsAction(Action action, ByteBuf outBuffer) {
+        outBuffer.writeShort(POP_MPLS_CODE);
+        encodeCommonEthertype(action, outBuffer);
+    }
+    
+    private static void encodeSetQueueAction(Action action, ByteBuf outBuffer) {
+        outBuffer.writeShort(SET_QUEUE_CODE);
+        outBuffer.writeShort(SET_QUEUE_LENGTH);
+        QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);
+        outBuffer.writeInt(queueId.getQueueId().intValue());
+    }
+
+    private static void encodeGroupAction(Action action, ByteBuf outBuffer) {
+        outBuffer.writeShort(GROUP_CODE);
+        outBuffer.writeShort(GROUP_LENGTH);
+        GroupIdAction groupId = action.getAugmentation(GroupIdAction.class);
+        outBuffer.writeInt(groupId.getGroupId().intValue());
+    }
+    
+    private static void encodeSetNwTtlAction(Action action, ByteBuf outBuffer) {
+        outBuffer.writeShort(SET_NW_TTL_CODE);
+        outBuffer.writeShort(SET_NW_TTL_LENGTH);
+        NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class);
+        outBuffer.writeByte(nwTtl.getNwTtl());
+        ByteBufUtils.padBuffer(SET_NW_TTL_PADDING, outBuffer);
+    }
+    
+    private static void encodeDecNwTtlAction(ByteBuf outBuffer) {
+        outBuffer.writeShort(DEC_NW_TTL_CODE);
+        encodeRestOfActionHeader(outBuffer);
+    }
+    
+    private static void encodeSetFieldAction(Action action, ByteBuf outBuffer) {
+        OxmFieldsAction oxmField = action.getAugmentation(OxmFieldsAction.class);
+        int length = MatchSerializer.computeMatchEntriesLength(oxmField.getMatchEntries()) + SET_FIELD_HEADER_LENGTH;
+        outBuffer.writeShort(SET_FIELD_CODE);
+        int paddingRemainder = length % EncodeConstants.PADDING;
+        if (paddingRemainder != 0) {
+            length += EncodeConstants.PADDING - paddingRemainder;
+        }
+        outBuffer.writeShort(length);
+        MatchSerializer.encodeMatchEntries(oxmField.getMatchEntries(), outBuffer);
+        ByteBufUtils.padBuffer(EncodeConstants.PADDING - paddingRemainder, outBuffer);
+    }
+    
+    private static void encodePushPbbAction(Action action, ByteBuf outBuffer) {
+        outBuffer.writeShort(PUSH_PBB_CODE);
+        encodeCommonEthertype(action, outBuffer);
+    }
+    
+    private static void encodePopPbbAction(ByteBuf outBuffer) {
+        outBuffer.writeShort(POP_PBB_CODE);
+        encodeRestOfActionHeader(outBuffer);
+    }
+
+    private static void encodeExperimenterAction(Action action, ByteBuf outBuffer) {
+        outBuffer.writeShort(EXPERIMENTER_CODE);
+        outBuffer.writeShort(EXPERIMENTER_LENGTH);
+        ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class);
+        outBuffer.writeInt(experimenter.getExperimenter().intValue());
+    }
+    
+    private static void encodeRestOfActionHeader(ByteBuf outBuffer) {
+        outBuffer.writeShort(ACTION_HEADER_LENGTH);
+        ByteBufUtils.padBuffer(PADDING_IN_ACTION_HEADER, outBuffer);
+    }
+    
+    private static void encodeCommonEthertype(Action action, ByteBuf outBuffer) {
+        EthertypeAction ethertype = action.getAugmentation(EthertypeAction.class);
+        outBuffer.writeShort(LENGTH_OF_ETHERTYPE_ACTION);
+        outBuffer.writeShort(ethertype.getEthertype().getValue());
+        ByteBufUtils.padBuffer(ETHERTYPE_ACTION_PADDING, outBuffer);
+    }
+    
+    /**
+     * Computes length of actions
+     * @param actionsList list of actions
+     * @return actions length
+     */
+    public static int computeLengthOfActions(List<ActionsList> actionsList) {
+        int lengthOfActions = 0;
+        if (actionsList != null) {
+            for (ActionsList list : actionsList) {
+                Action action = list.getAction();
+                if (action.getType().isAssignableFrom(Output.class)) {
+                    lengthOfActions += OUTPUT_LENGTH;
+                } else if (action.getType().isAssignableFrom(SetField.class)){
+                    List<MatchEntries> entries = action.getAugmentation(OxmFieldsAction.class).getMatchEntries();
+                    int actionLength = (2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES) + MatchSerializer.computeMatchEntriesLength(entries);
+                    lengthOfActions += actionLength;
+                    int paddingRemainder = actionLength % EncodeConstants.PADDING;
+                    if ((paddingRemainder) != 0) {
+                        lengthOfActions += EncodeConstants.PADDING - paddingRemainder;
+                    }
+                } else {
+                    lengthOfActions += LENGTH_OF_OTHER_ACTIONS;
+                }
+            }
+        }
+        return lengthOfActions;
+    }
+}
index 2e633386f9e30208ace3a41630b27397cb0667d4..a1dced8f4ef07356c15699f9bd12807f544de387 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Arrays;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Map.Entry;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\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.protocol.rev130731.OfHeader;\r
-\r
-import com.google.common.base.Joiner;\r
-\r
-/** Class for common operations on ByteBuf\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public abstract class ByteBufUtils {\r
-\r
-    /**\r
-     * Converts ByteBuf into String\r
-     * @param bb input ByteBuf\r
-     * @return String\r
-     */\r
-    public static String byteBufToHexString(ByteBuf bb) {\r
-        StringBuffer sb = new StringBuffer();\r
-        for (int i = 0; i < bb.readableBytes(); i++) {\r
-            short b = bb.getUnsignedByte(i);\r
-            sb.append(String.format("%02x ", b));\r
-        }\r
-        return sb.toString();\r
-    }\r
-    \r
-    /**\r
-     * Converts String into byte[]\r
-     * @param hexSrc input String\r
-     * @return byte[] filled with input data\r
-     */\r
-    public static byte[] hexStringToBytes(String hexSrc) {\r
-        return hexStringToBytes(hexSrc, true);\r
-    }\r
-    \r
-    /**\r
-     * Converts String into byte[]\r
-     * @param hexSrc input String\r
-     * @param withSpaces if there are spaces in string \r
-     * @return byte[] filled with input data\r
-     */\r
-    public static byte[] hexStringToBytes(String hexSrc, boolean withSpaces ) {\r
-        String splitPattern = "\\s+";\r
-        if (!withSpaces) {\r
-            splitPattern = "(?<=\\G.{2})";\r
-        }\r
-        \r
-        String[] byteChips = hexSrc.split(splitPattern);\r
-        byte[] result = new byte[byteChips.length];\r
-        for (int i = 0; i < byteChips.length; i++) {\r
-            result[i] = (byte) Short.parseShort(byteChips[i], 16);\r
-        }\r
-        return result;\r
-    }\r
-    \r
-    /**\r
-     * Creates ByteBuf filled with specified data\r
-     * @param hexSrc input String of bytes in hex format\r
-     * @return ByteBuf with specified hexString converted\r
-     */\r
-    public static ByteBuf hexStringToByteBuf(String hexSrc) {\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        hexStringToByteBuf(hexSrc, out);\r
-        return out;\r
-    }\r
-    \r
-    /**\r
-     * Creates ByteBuf filled with specified data\r
-     * @param hexSrc input String of bytes in hex format\r
-     * @param out ByteBuf with specified hexString converted\r
-     */\r
-    public static void hexStringToByteBuf(String hexSrc, ByteBuf out) {\r
-        out.writeBytes(hexStringToBytes(hexSrc));\r
-    }\r
-    \r
-    /**\r
-     * Fills specified ByteBuf with 0 (zeros) of desired length, used for padding\r
-     * @param length\r
-     * @param out ByteBuf to be padded\r
-     */\r
-    public static void padBuffer(int length, ByteBuf out) {\r
-        for (int i = 0; i < length; i++) {\r
-            out.writeByte(0);\r
-        }\r
-    }\r
-    \r
-    /**\r
-     * Create standard OF header\r
-     * @param factory serialization factory \r
-     * @param message POJO\r
-     * @param out writing buffer\r
-     */\r
-    public static <E extends OfHeader> void writeOFHeader(OFSerializer<E> factory, E message, ByteBuf out) { \r
-        out.writeByte(message.getVersion());\r
-        out.writeByte(factory.getMessageType());\r
-        out.writeShort(factory.computeLength(message));\r
-        out.writeInt(message.getXid().intValue());\r
-\r
-    }\r
-\r
-    /**\r
-     * Fills the bitmask from boolean map where key is bit position\r
-     * @param booleanMap bit to boolean mapping\r
-     * @return bit mask\r
-     */\r
-    public static int fillBitMaskFromMap(Map<Integer, Boolean> booleanMap) {\r
-        int bitmask = 0;\r
-        \r
-        for (Entry<Integer, Boolean> iterator : booleanMap.entrySet()) {\r
-            if (iterator.getValue() != null && iterator.getValue().booleanValue()) {\r
-                bitmask |= 1 << iterator.getKey();\r
-            }\r
-        }\r
-        return bitmask;\r
-    }\r
-    \r
-    /**\r
-     * Fills the bitmask from boolean list where key is bit position\r
-     * @param booleanList bit to boolean mapping\r
-     * @return bit mask\r
-     */\r
-    public static int[] fillBitMaskFromList(List<Boolean> booleanList) {\r
-        int[] bitmask;\r
-        int index = 0;\r
-        int arrayIndex = 0;\r
-        if ((booleanList.size() % Integer.SIZE) != 0) {\r
-            bitmask = new int[booleanList.size() / Integer.SIZE + 1];\r
-        } else {\r
-            bitmask = new int[booleanList.size() / Integer.SIZE];\r
-        }\r
-        for (Boolean currElement : booleanList) {\r
-            if (currElement != null && currElement.booleanValue()) {\r
-                bitmask[arrayIndex] |= 1 << index;\r
-            }\r
-            index++;\r
-            arrayIndex = index / Integer.SIZE;\r
-        }\r
-        return bitmask;\r
-    }\r
-\r
-    /**\r
-     * Converts byte array into String\r
-     * @param array input byte array\r
-     * @return String\r
-     */\r
-    public static String bytesToHexString(byte[] array) {\r
-        StringBuffer sb = new StringBuffer();\r
-        for (int i = 0; i < array.length; i++) {\r
-            short b = array[i];\r
-            sb.append(String.format("%02x ", b));\r
-        }\r
-        return sb.toString();\r
-    }\r
-    \r
-    /**\r
-     * Converts macAddress to byte array\r
-     * @param macAddress\r
-     * @return byte representation of mac address\r
-     * @see {@link MacAddress}\r
-     */\r
-    public static byte[] macAddressToBytes(String macAddress) {\r
-        String[] sequences = macAddress.split(":");\r
-        byte[] result = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];\r
-        for (int i = 0; i < sequences.length; i++) {\r
-             result[i] = (byte) Short.parseShort(sequences[i], 16);\r
-        }\r
-        return result;\r
-    }\r
-    \r
-    /**\r
-     * Converts mac address represented in bytes to String\r
-     * @param address\r
-     * @return String representation of mac address\r
-     * @see {@link MacAddress}\r
-     */\r
-    public static String macAddressToString(byte[] address) {\r
-        List<String> groups = new ArrayList<>();\r
-        for(int i=0; i < EncodeConstants.MAC_ADDRESS_LENGTH; i++){\r
-            groups.add(String.format("%02X", address[i]));\r
-        }\r
-        Joiner joiner = Joiner.on(":");\r
-        return joiner.join(groups); \r
-    }\r
-    \r
-    /**\r
-     * Reads and parses port name from ByteBuf\r
-     * @param rawMessage\r
-     * @param length maximal length of String\r
-     * @return String with name of port\r
-     */\r
-    public static String decodeNullTerminatedString(ByteBuf rawMessage, int length) {\r
-        byte[] name = new byte[EncodeConstants.MAX_PORT_NAME_LENGTH];\r
-        rawMessage.readBytes(name);\r
-        int index = 0;\r
-        for (int i = 0; i < name.length; i++) {\r
-            if (name[i] != 0) {\r
-                index++;\r
-            } else {\r
-                break;\r
-            }\r
-        }\r
-        byte[] correctName = Arrays.copyOf(name, index);\r
-        return new String(correctName);\r
-    }\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+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.protocol.rev130731.OfHeader;
+
+import com.google.common.base.Joiner;
+
+/** Class for common operations on ByteBuf
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public abstract class ByteBufUtils {
+
+    /**
+     * Converts ByteBuf into String
+     * @param bb input ByteBuf
+     * @return String
+     */
+    public static String byteBufToHexString(ByteBuf bb) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < bb.readableBytes(); i++) {
+            short b = bb.getUnsignedByte(i);
+            sb.append(String.format("%02x ", b));
+        }
+        return sb.toString();
+    }
+    
+    /**
+     * Converts String into byte[]
+     * @param hexSrc input String
+     * @return byte[] filled with input data
+     */
+    public static byte[] hexStringToBytes(String hexSrc) {
+        return hexStringToBytes(hexSrc, true);
+    }
+    
+    /**
+     * Converts String into byte[]
+     * @param hexSrc input String
+     * @param withSpaces if there are spaces in string 
+     * @return byte[] filled with input data
+     */
+    public static byte[] hexStringToBytes(String hexSrc, boolean withSpaces ) {
+        String splitPattern = "\\s+";
+        if (!withSpaces) {
+            splitPattern = "(?<=\\G.{2})";
+        }
+        
+        String[] byteChips = hexSrc.split(splitPattern);
+        byte[] result = new byte[byteChips.length];
+        for (int i = 0; i < byteChips.length; i++) {
+            result[i] = (byte) Short.parseShort(byteChips[i], 16);
+        }
+        return result;
+    }
+    
+    /**
+     * Creates ByteBuf filled with specified data
+     * @param hexSrc input String of bytes in hex format
+     * @return ByteBuf with specified hexString converted
+     */
+    public static ByteBuf hexStringToByteBuf(String hexSrc) {
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        hexStringToByteBuf(hexSrc, out);
+        return out;
+    }
+    
+    /**
+     * Creates ByteBuf filled with specified data
+     * @param hexSrc input String of bytes in hex format
+     * @param out ByteBuf with specified hexString converted
+     */
+    public static void hexStringToByteBuf(String hexSrc, ByteBuf out) {
+        out.writeBytes(hexStringToBytes(hexSrc));
+    }
+    
+    /**
+     * Fills specified ByteBuf with 0 (zeros) of desired length, used for padding
+     * @param length
+     * @param out ByteBuf to be padded
+     */
+    public static void padBuffer(int length, ByteBuf out) {
+        for (int i = 0; i < length; i++) {
+            out.writeByte(0);
+        }
+    }
+    
+    /**
+     * Create standard OF header
+     * @param factory serialization factory 
+     * @param message POJO
+     * @param out writing buffer
+     */
+    public static <E extends OfHeader> void writeOFHeader(OFSerializer<E> factory, E message, ByteBuf out) { 
+        out.writeByte(message.getVersion());
+        out.writeByte(factory.getMessageType());
+        out.writeShort(factory.computeLength(message));
+        out.writeInt(message.getXid().intValue());
+
+    }
+
+    /**
+     * Fills the bitmask from boolean map where key is bit position
+     * @param booleanMap bit to boolean mapping
+     * @return bit mask
+     */
+    public static int fillBitMaskFromMap(Map<Integer, Boolean> booleanMap) {
+        int bitmask = 0;
+        
+        for (Entry<Integer, Boolean> iterator : booleanMap.entrySet()) {
+            if (iterator.getValue() != null && iterator.getValue().booleanValue()) {
+                bitmask |= 1 << iterator.getKey();
+            }
+        }
+        return bitmask;
+    }
+    
+    /**
+     * Fills the bitmask from boolean list where key is bit position
+     * @param booleanList bit to boolean mapping
+     * @return bit mask
+     */
+    public static int[] fillBitMaskFromList(List<Boolean> booleanList) {
+        int[] bitmask;
+        int index = 0;
+        int arrayIndex = 0;
+        if ((booleanList.size() % Integer.SIZE) != 0) {
+            bitmask = new int[booleanList.size() / Integer.SIZE + 1];
+        } else {
+            bitmask = new int[booleanList.size() / Integer.SIZE];
+        }
+        for (Boolean currElement : booleanList) {
+            if (currElement != null && currElement.booleanValue()) {
+                bitmask[arrayIndex] |= 1 << index;
+            }
+            index++;
+            arrayIndex = index / Integer.SIZE;
+        }
+        return bitmask;
+    }
+
+    /**
+     * Converts byte array into String
+     * @param array input byte array
+     * @return String
+     */
+    public static String bytesToHexString(byte[] array) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < array.length; i++) {
+            short b = array[i];
+            sb.append(String.format("%02x ", b));
+        }
+        return sb.toString();
+    }
+    
+    /**
+     * Converts macAddress to byte array
+     * @param macAddress
+     * @return byte representation of mac address
+     * @see {@link MacAddress}
+     */
+    public static byte[] macAddressToBytes(String macAddress) {
+        String[] sequences = macAddress.split(":");
+        byte[] result = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
+        for (int i = 0; i < sequences.length; i++) {
+             result[i] = (byte) Short.parseShort(sequences[i], 16);
+        }
+        return result;
+    }
+    
+    /**
+     * Converts mac address represented in bytes to String
+     * @param address
+     * @return String representation of mac address
+     * @see {@link MacAddress}
+     */
+    public static String macAddressToString(byte[] address) {
+        List<String> groups = new ArrayList<>();
+        for(int i=0; i < EncodeConstants.MAC_ADDRESS_LENGTH; i++){
+            groups.add(String.format("%02X", address[i]));
+        }
+        Joiner joiner = Joiner.on(":");
+        return joiner.join(groups); 
+    }
+    
+    /**
+     * Reads and parses port name from ByteBuf
+     * @param rawMessage
+     * @param length maximal length of String
+     * @return String with name of port
+     */
+    public static String decodeNullTerminatedString(ByteBuf rawMessage, int length) {
+        byte[] name = new byte[EncodeConstants.MAX_PORT_NAME_LENGTH];
+        rawMessage.readBytes(name);
+        int index = 0;
+        for (int i = 0; i < name.length; i++) {
+            if (name[i] != 0) {
+                index++;
+            } else {
+                break;
+            }
+        }
+        byte[] correctName = Arrays.copyOf(name, index);
+        return new String(correctName);
+    }
+}
index 74d7ce310614041b36a0e8390c56a9327dce35da..098ba8d9fe506b7ccbbc3771bc6f68d97bcb91e7 100644 (file)
@@ -1,38 +1,45 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-/**\r
- * Stores common constants\r
- * @author michal.polkorab\r
- */\r
-public abstract class EncodeConstants {\r
-\r
-    /** Default OF padding (in bytes) */\r
-    public static final byte PADDING = EncodeConstants.SIZE_OF_LONG_IN_BYTES;\r
-    /** OpenFlow v1.0 wire protocol number */\r
-    public static final byte OF10_VERSION_ID = 0x01;\r
-    /** OpenFlow v1.0 wire protocol number */\r
-    public static final byte OF13_VERSION_ID = 0x04;\r
-    \r
-    /** Length of mac address */\r
-    public static final byte MAC_ADDRESS_LENGTH = 6;\r
-    /** Number of groups in ipv4 address */\r
-    public static final byte GROUPS_IN_IPV4_ADDRESS = 4;\r
-    /** Number of groups in ipv6 address */\r
-    public static final byte GROUPS_IN_IPV6_ADDRESS = 8;\r
-    /** Length of ipv6 address in bytes */\r
-    public static final byte SIZE_OF_IPV6_ADDRESS_IN_BYTES = (8 * Short.SIZE) / Byte.SIZE;\r
-    \r
-    /** Length of long in bytes */\r
-    public static final byte SIZE_OF_LONG_IN_BYTES = Long.SIZE / Byte.SIZE;\r
-    /** Length of int in bytes */\r
-    public static final byte SIZE_OF_INT_IN_BYTES = Integer.SIZE / Byte.SIZE;\r
-    /** Length of short in bytes */\r
-    public static final byte SIZE_OF_SHORT_IN_BYTES = Short.SIZE / Byte.SIZE;\r
-    /** Length of byte in bytes */\r
-    public static final byte SIZE_OF_BYTE_IN_BYTES = Byte.SIZE / Byte.SIZE;\r
-\r
-    \r
-    /** OF v1.0 maximal port name length */\r
-    public static final byte MAX_PORT_NAME_LENGTH = 16;\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+/**
+ * Stores common constants
+ * @author michal.polkorab
+ */
+public abstract class EncodeConstants {
+
+    /** Default OF padding (in bytes) */
+    public static final byte PADDING = EncodeConstants.SIZE_OF_LONG_IN_BYTES;
+    /** OpenFlow v1.0 wire protocol number */
+    public static final byte OF10_VERSION_ID = 0x01;
+    /** OpenFlow v1.0 wire protocol number */
+    public static final byte OF13_VERSION_ID = 0x04;
+    
+    /** Length of mac address */
+    public static final byte MAC_ADDRESS_LENGTH = 6;
+    /** Number of groups in ipv4 address */
+    public static final byte GROUPS_IN_IPV4_ADDRESS = 4;
+    /** Number of groups in ipv6 address */
+    public static final byte GROUPS_IN_IPV6_ADDRESS = 8;
+    /** Length of ipv6 address in bytes */
+    public static final byte SIZE_OF_IPV6_ADDRESS_IN_BYTES = (8 * Short.SIZE) / Byte.SIZE;
+    
+    /** Length of long in bytes */
+    public static final byte SIZE_OF_LONG_IN_BYTES = Long.SIZE / Byte.SIZE;
+    /** Length of int in bytes */
+    public static final byte SIZE_OF_INT_IN_BYTES = Integer.SIZE / Byte.SIZE;
+    /** Length of short in bytes */
+    public static final byte SIZE_OF_SHORT_IN_BYTES = Short.SIZE / Byte.SIZE;
+    /** Length of byte in bytes */
+    public static final byte SIZE_OF_BYTE_IN_BYTES = Byte.SIZE / Byte.SIZE;
+
+    
+    /** OF v1.0 maximal port name length */
+    public static final byte MAX_PORT_NAME_LENGTH = 16;
+}
index 078b5d8957e5bc5e7eccc81f62d34da9dfbff481..e77daca17ee53d37547f342804d3d3cadd07e129 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstructionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.InstructionsBuilder;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-/**\r
- * Deserializes ofp_instruction (OpenFlow v1.3) structures\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class InstructionsDeserializer {\r
-    \r
-    private static final byte WRITE_APPLY_CLEAR_ACTION_LENGTH = 8;\r
-    private static final byte EXPERIMENTER_HEADER_LENGTH = 8;\r
-    private static final byte GOTO_TABLE_PADDING = 3;\r
-    private static final byte WRITE_METADATA_PADDING = 4;\r
-    private static final byte ACTIONS_RELATED_INSTRUCTION_PADDING = 4;\r
-\r
-    /**\r
-     * Creates list of instructions\r
-     * @param input\r
-     * @param length\r
-     * @return list of ofp_instruction\r
-     */\r
-    public static List<Instructions> createInstructions(ByteBuf input, int length) {\r
-        List<Instructions> instructions = new ArrayList<>();\r
-        if (input.readableBytes() != 0) {\r
-            int lengthOfInstructions = length;\r
-            while (lengthOfInstructions > 0) {\r
-                InstructionsBuilder builder = new InstructionsBuilder();\r
-                int type = input.readUnsignedShort();\r
-                int instructionLength = input.readUnsignedShort();\r
-                lengthOfInstructions -= instructionLength;\r
-                switch (type) {\r
-                case 1:\r
-                    createGotoTableInstruction(builder, input);\r
-                    break;\r
-                case 2:\r
-                    createMetadataInstruction(builder, input);\r
-                    break;\r
-                case 3:\r
-                    builder.setType(WriteActions.class);\r
-                    createActionRelatedInstruction(input, builder, instructionLength - WRITE_APPLY_CLEAR_ACTION_LENGTH);\r
-                    break;\r
-                case 4:\r
-                    builder.setType(ApplyActions.class);\r
-                    createActionRelatedInstruction(input, builder, instructionLength - WRITE_APPLY_CLEAR_ACTION_LENGTH);\r
-                    break;\r
-                case 5:\r
-                    builder.setType(ClearActions.class);\r
-                    createActionRelatedInstruction(input, builder, instructionLength - WRITE_APPLY_CLEAR_ACTION_LENGTH);\r
-                    break;\r
-                case 6:\r
-                    builder.setType(Meter.class);\r
-                    MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder();\r
-                    meterBuilder.setMeterId(input.readUnsignedInt());\r
-                    builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build());\r
-                    break;\r
-                case 65535:\r
-                    builder.setType(Experimenter.class);\r
-                    ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();\r
-                    expBuilder.setExperimenter(input.readUnsignedInt());\r
-                    int dataLength = instructionLength - EXPERIMENTER_HEADER_LENGTH;\r
-                    if (dataLength > 0) {\r
-                        byte[] data = new byte[dataLength];\r
-                        input.readBytes(data);\r
-                        expBuilder.setData(data);\r
-                    }\r
-                    builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());\r
-                    break;\r
-                default:\r
-                    break;\r
-                }\r
-                instructions.add(builder.build());\r
-            }\r
-        }\r
-        return instructions;\r
-    }\r
-\r
-    private static void createGotoTableInstruction(InstructionsBuilder builder,\r
-            ByteBuf input) {\r
-        builder.setType(GotoTable.class);\r
-        TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder();\r
-        tableBuilder.setTableId(input.readUnsignedByte());\r
-        builder.addAugmentation(TableIdInstruction.class, tableBuilder.build());\r
-        input.skipBytes(GOTO_TABLE_PADDING);\r
-    }\r
-    \r
-    private static void createMetadataInstruction(InstructionsBuilder builder,\r
-            ByteBuf input) {\r
-        input.skipBytes(WRITE_METADATA_PADDING);\r
-        builder.setType(WriteMetadata.class);\r
-        MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder();\r
-        byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
-        input.readBytes(metadata);\r
-        metadataBuilder.setMetadata(metadata);\r
-        byte[] metadata_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
-        input.readBytes(metadata_mask);\r
-        metadataBuilder.setMetadata(metadata_mask);\r
-        builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build());\r
-    }\r
-    \r
-    private static void createActionRelatedInstruction(ByteBuf input,\r
-            InstructionsBuilder builder, int instructionLength) {\r
-        input.skipBytes(ACTIONS_RELATED_INSTRUCTION_PADDING);\r
-        ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder();\r
-        actionsBuilder.setActionsList(ActionsDeserializer.createActionsList(input, instructionLength));\r
-        builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.InstructionsBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+/**
+ * Deserializes ofp_instruction (OpenFlow v1.3) structures
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class InstructionsDeserializer {
+    
+    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;
+
+    /**
+     * Creates list of instructions
+     * @param input
+     * @param length
+     * @return list of ofp_instruction
+     */
+    public static List<Instructions> createInstructions(ByteBuf input, int length) {
+        List<Instructions> instructions = new ArrayList<>();
+        if (input.readableBytes() != 0) {
+            int lengthOfInstructions = length;
+            while (lengthOfInstructions > 0) {
+                InstructionsBuilder builder = new InstructionsBuilder();
+                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());
+            }
+        }
+        return instructions;
+    }
+
+    private static void createGotoTableInstruction(InstructionsBuilder builder,
+            ByteBuf input) {
+        builder.setType(GotoTable.class);
+        TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder();
+        tableBuilder.setTableId(input.readUnsignedByte());
+        builder.addAugmentation(TableIdInstruction.class, tableBuilder.build());
+        input.skipBytes(GOTO_TABLE_PADDING);
+    }
+    
+    private static void createMetadataInstruction(InstructionsBuilder builder,
+            ByteBuf input) {
+        input.skipBytes(WRITE_METADATA_PADDING);
+        builder.setType(WriteMetadata.class);
+        MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder();
+        byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        input.readBytes(metadata);
+        metadataBuilder.setMetadata(metadata);
+        byte[] metadata_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        input.readBytes(metadata_mask);
+        metadataBuilder.setMetadata(metadata_mask);
+        builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build());
+    }
+    
+    private static void createActionRelatedInstruction(ByteBuf input,
+            InstructionsBuilder builder, int instructionLength) {
+        input.skipBytes(ACTIONS_RELATED_INSTRUCTION_PADDING);
+        ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder();
+        actionsBuilder.setActionsList(ActionsDeserializer.createActionsList(input, instructionLength));
+        builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
+    }
+
+}
index e777525edfaa239b7eb784e3640790865da4a92a..020a5efe41de245a21ab5ddaf94ec2bdc7e50495 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.List;\r
-\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.ExperimenterInstruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Instruction;\r
-\r
-/**\r
- * Serializes ofp_instruction (OpenFlow v 1.3) structure\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public abstract class InstructionsSerializer {\r
-\r
-    private static final byte GOTO_TABLE_TYPE = 1;\r
-    private static final byte WRITE_METADATA_TYPE = 2;\r
-    private static final byte WRITE_ACTIONS_TYPE = 3;\r
-    private static final byte APPLY_ACTIONS_TYPE = 4;\r
-    private static final byte CLEAR_ACTIONS_TYPE = 5;\r
-    private static final byte METER_TYPE = 6;\r
-    private static final byte EXPERIMENTER_TYPE = 7;\r
-    private static final byte GOTO_TABLE_LENGTH = 8;\r
-    private static final byte WRITE_METADATA_LENGTH = 24;\r
-    private static final byte WRITE_ACTIONS_LENGTH = 8;\r
-    private static final byte APPLY_ACTIONS_LENGTH = 8;\r
-    private static final byte CLEAR_ACTIONS_LENGTH = 8;\r
-    private static final byte METER_LENGTH = 8;\r
-    private static final byte EXPERIMENTER_LENGTH = 8;\r
-    private static final byte PADDING_IN_GOTO_TABLE = 3;\r
-    private static final byte PADDING_IN_WRITE_METADATA = 4;\r
-    private static final byte PADDING_IN_CLEAR_ACTIONS = 4;\r
-    \r
-    /**\r
-     * Encodes instructions\r
-     * @param instructions List of instructions\r
-     * @param out output buffer\r
-     */\r
-    public static void encodeInstructions(List<Instructions> instructions, ByteBuf out) {\r
-        if (instructions != null) {\r
-            for (Instructions instruction : instructions) {\r
-                Class<? extends Instruction> type = instruction.getType();\r
-                if (type.isAssignableFrom(GotoTable.class)) {\r
-                    writeTypeAndLength(out, GOTO_TABLE_TYPE, GOTO_TABLE_LENGTH);\r
-                    out.writeByte(instruction.getAugmentation(TableIdInstruction.class).getTableId());\r
-                    ByteBufUtils.padBuffer(PADDING_IN_GOTO_TABLE, out);\r
-                } else if (type.isAssignableFrom(WriteMetadata.class)) {\r
-                    writeTypeAndLength(out, WRITE_METADATA_TYPE, WRITE_METADATA_LENGTH);\r
-                    ByteBufUtils.padBuffer(PADDING_IN_WRITE_METADATA, out);\r
-                    MetadataInstruction metadata = instruction.getAugmentation(MetadataInstruction.class);\r
-                    out.writeBytes(metadata.getMetadata());\r
-                    out.writeBytes(metadata.getMetadataMask());\r
-                } else if (type.isAssignableFrom(WriteActions.class)) {\r
-                    writeActionsInstruction(out, instruction, WRITE_ACTIONS_TYPE);\r
-                } else if (type.isAssignableFrom(ApplyActions.class)) {\r
-                    writeActionsInstruction(out, instruction, APPLY_ACTIONS_TYPE);\r
-                } else if (type.isAssignableFrom(ClearActions.class)) {\r
-                    writeTypeAndLength(out, CLEAR_ACTIONS_TYPE, CLEAR_ACTIONS_LENGTH);\r
-                    ByteBufUtils.padBuffer(PADDING_IN_CLEAR_ACTIONS, out);\r
-                } else if (type.isAssignableFrom(Meter.class)) {\r
-                    writeTypeAndLength(out, METER_TYPE, METER_LENGTH);\r
-                    out.writeInt(instruction.getAugmentation(MeterIdInstruction.class).getMeterId().intValue());\r
-                } else if (type.isAssignableFrom(Experimenter.class)) {\r
-                    ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class);\r
-                    byte[] data = experimenter.getData();\r
-                    writeTypeAndLength(out, EXPERIMENTER_TYPE, EXPERIMENTER_LENGTH + data.length);\r
-                    out.writeInt(experimenter.getExperimenter().intValue());\r
-                    out.writeBytes(data);\r
-                }\r
-            }\r
-        }\r
-        \r
-    }\r
-\r
-    private static void writeTypeAndLength(ByteBuf out, int type, int length) {\r
-        out.writeShort(type);\r
-        out.writeShort(length);\r
-    }\r
-\r
-    private static void writeActionsInstruction(ByteBuf out,\r
-            Instructions instruction, int type) {\r
-        final byte ACTIONS_INSTRUCTION_LENGTH = 8;\r
-        final byte PADDING_IN_ACTIONS_INSTRUCTION = 4;\r
-        out.writeShort(type);\r
-        List<ActionsList> actions = instruction.getAugmentation(ActionsInstruction.class).getActionsList();\r
-        out.writeShort(ACTIONS_INSTRUCTION_LENGTH + ActionsSerializer.computeLengthOfActions(actions));\r
-        ByteBufUtils.padBuffer(PADDING_IN_ACTIONS_INSTRUCTION, out);\r
-        ActionsSerializer.encodeActions(actions, out);\r
-    }\r
-    \r
-    /**\r
-     * Computes length of instructions\r
-     * @param instructions List of instructions\r
-     * @return length of instructions (in bytes)\r
-     */\r
-    public static int computeInstructionsLength(List<Instructions> instructions) {\r
-        int length = 0;\r
-        if (instructions != null) {\r
-            for (Instructions instruction : instructions) {\r
-                Class<? extends Instruction> type = instruction.getType();\r
-                if (type.isAssignableFrom(GotoTable.class)) {\r
-                    length += GOTO_TABLE_LENGTH;\r
-                } else if (type.isAssignableFrom(WriteMetadata.class)) {\r
-                    length += WRITE_METADATA_LENGTH;\r
-                } else if (type.isAssignableFrom(WriteActions.class)) {\r
-                    length += WRITE_ACTIONS_LENGTH + ActionsSerializer.computeLengthOfActions(\r
-                            instruction.getAugmentation(ActionsInstruction.class).getActionsList());\r
-                } else if (type.isAssignableFrom(ApplyActions.class)) {\r
-                    length += APPLY_ACTIONS_LENGTH + ActionsSerializer.computeLengthOfActions(\r
-                            instruction.getAugmentation(ActionsInstruction.class).getActionsList());\r
-                } else if (type.isAssignableFrom(ClearActions.class)) {\r
-                    length += CLEAR_ACTIONS_LENGTH;\r
-                } else if (type.isAssignableFrom(Meter.class)) {\r
-                    length += METER_LENGTH;\r
-                } else if (type.isAssignableFrom(Experimenter.class)) {\r
-                    ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class);\r
-                    byte[] data = experimenter.getData();\r
-                    length += EXPERIMENTER_LENGTH + data.length;\r
-                }\r
-            }\r
-        }\r
-        return length;\r
-    }\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Instruction;
+
+/**
+ * Serializes ofp_instruction (OpenFlow v 1.3) structure
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public abstract class InstructionsSerializer {
+
+    private static final byte GOTO_TABLE_TYPE = 1;
+    private static final byte WRITE_METADATA_TYPE = 2;
+    private static final byte WRITE_ACTIONS_TYPE = 3;
+    private static final byte APPLY_ACTIONS_TYPE = 4;
+    private static final byte CLEAR_ACTIONS_TYPE = 5;
+    private static final byte METER_TYPE = 6;
+    private static final byte EXPERIMENTER_TYPE = 7;
+    private static final byte GOTO_TABLE_LENGTH = 8;
+    private static final byte WRITE_METADATA_LENGTH = 24;
+    private static final byte WRITE_ACTIONS_LENGTH = 8;
+    private static final byte APPLY_ACTIONS_LENGTH = 8;
+    private static final byte CLEAR_ACTIONS_LENGTH = 8;
+    private static final byte METER_LENGTH = 8;
+    private static final byte EXPERIMENTER_LENGTH = 8;
+    private static final byte PADDING_IN_GOTO_TABLE = 3;
+    private static final byte PADDING_IN_WRITE_METADATA = 4;
+    private static final byte PADDING_IN_CLEAR_ACTIONS = 4;
+    
+    /**
+     * Encodes instructions
+     * @param instructions List of instructions
+     * @param out output buffer
+     */
+    public static void encodeInstructions(List<Instructions> instructions, ByteBuf out) {
+        if (instructions != null) {
+            for (Instructions instruction : instructions) {
+                Class<? extends Instruction> type = instruction.getType();
+                if (type.isAssignableFrom(GotoTable.class)) {
+                    writeTypeAndLength(out, GOTO_TABLE_TYPE, GOTO_TABLE_LENGTH);
+                    out.writeByte(instruction.getAugmentation(TableIdInstruction.class).getTableId());
+                    ByteBufUtils.padBuffer(PADDING_IN_GOTO_TABLE, out);
+                } else if (type.isAssignableFrom(WriteMetadata.class)) {
+                    writeTypeAndLength(out, WRITE_METADATA_TYPE, WRITE_METADATA_LENGTH);
+                    ByteBufUtils.padBuffer(PADDING_IN_WRITE_METADATA, out);
+                    MetadataInstruction metadata = instruction.getAugmentation(MetadataInstruction.class);
+                    out.writeBytes(metadata.getMetadata());
+                    out.writeBytes(metadata.getMetadataMask());
+                } else if (type.isAssignableFrom(WriteActions.class)) {
+                    writeActionsInstruction(out, instruction, WRITE_ACTIONS_TYPE);
+                } else if (type.isAssignableFrom(ApplyActions.class)) {
+                    writeActionsInstruction(out, instruction, APPLY_ACTIONS_TYPE);
+                } else if (type.isAssignableFrom(ClearActions.class)) {
+                    writeTypeAndLength(out, CLEAR_ACTIONS_TYPE, CLEAR_ACTIONS_LENGTH);
+                    ByteBufUtils.padBuffer(PADDING_IN_CLEAR_ACTIONS, out);
+                } else if (type.isAssignableFrom(Meter.class)) {
+                    writeTypeAndLength(out, METER_TYPE, METER_LENGTH);
+                    out.writeInt(instruction.getAugmentation(MeterIdInstruction.class).getMeterId().intValue());
+                } else if (type.isAssignableFrom(Experimenter.class)) {
+                    ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class);
+                    byte[] data = experimenter.getData();
+                    writeTypeAndLength(out, EXPERIMENTER_TYPE, EXPERIMENTER_LENGTH + data.length);
+                    out.writeInt(experimenter.getExperimenter().intValue());
+                    out.writeBytes(data);
+                }
+            }
+        }
+        
+    }
+
+    private static void writeTypeAndLength(ByteBuf out, int type, int length) {
+        out.writeShort(type);
+        out.writeShort(length);
+    }
+
+    private static void writeActionsInstruction(ByteBuf out,
+            Instructions instruction, int type) {
+        final byte ACTIONS_INSTRUCTION_LENGTH = 8;
+        final byte PADDING_IN_ACTIONS_INSTRUCTION = 4;
+        out.writeShort(type);
+        List<ActionsList> actions = instruction.getAugmentation(ActionsInstruction.class).getActionsList();
+        out.writeShort(ACTIONS_INSTRUCTION_LENGTH + ActionsSerializer.computeLengthOfActions(actions));
+        ByteBufUtils.padBuffer(PADDING_IN_ACTIONS_INSTRUCTION, out);
+        ActionsSerializer.encodeActions(actions, out);
+    }
+    
+    /**
+     * Computes length of instructions
+     * @param instructions List of instructions
+     * @return length of instructions (in bytes)
+     */
+    public static int computeInstructionsLength(List<Instructions> instructions) {
+        int length = 0;
+        if (instructions != null) {
+            for (Instructions instruction : instructions) {
+                Class<? extends Instruction> type = instruction.getType();
+                if (type.isAssignableFrom(GotoTable.class)) {
+                    length += GOTO_TABLE_LENGTH;
+                } else if (type.isAssignableFrom(WriteMetadata.class)) {
+                    length += WRITE_METADATA_LENGTH;
+                } else if (type.isAssignableFrom(WriteActions.class)) {
+                    length += WRITE_ACTIONS_LENGTH + ActionsSerializer.computeLengthOfActions(
+                            instruction.getAugmentation(ActionsInstruction.class).getActionsList());
+                } else if (type.isAssignableFrom(ApplyActions.class)) {
+                    length += APPLY_ACTIONS_LENGTH + ActionsSerializer.computeLengthOfActions(
+                            instruction.getAugmentation(ActionsInstruction.class).getActionsList());
+                } else if (type.isAssignableFrom(ClearActions.class)) {
+                    length += CLEAR_ACTIONS_LENGTH;
+                } else if (type.isAssignableFrom(Meter.class)) {
+                    length += METER_LENGTH;
+                } else if (type.isAssignableFrom(Experimenter.class)) {
+                    ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class);
+                    byte[] data = experimenter.getData();
+                    length += EXPERIMENTER_LENGTH + data.length;
+                }
+            }
+        }
+        return length;
+    }
+}
index 9df9d17d4e2ee67062a7e298505c0d7c556e0f1e..668d6e414208845e65c76fd768390363be5e5aa1 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;\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.BosMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder;\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.augments.rev131002.EcnMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder;\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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.augments.rev131002.PseudoFieldMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry.PseudoField;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder;\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.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.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.common.types.rev130731.EtherType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType;\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.ArpSha;\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.ArpTha;\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.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
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;\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.InPort;\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.IpEcn;\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.Ipv4Dst;\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.Ipv6Dst;\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.Ipv6Flabel;\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.Ipv6NdTarget;\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.Ipv6Src;\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.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
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;\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.VlanVid;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntriesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.MatchBuilder;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.google.common.base.Joiner;\r
-\r
-/**\r
- * Deserializes ofp_match (OpenFlow v1.3) and its oxm_fields structures\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public abstract class MatchDeserializer {\r
-\r
-    private static final Logger LOGGER = LoggerFactory.getLogger(MatchDeserializer.class);\r
-    \r
-    /**\r
-     * Creates match\r
-     * @param in input ByteBuf\r
-     * @return ofp_match (OpenFlow v1.3)\r
-     */\r
-    public static Match createMatch(ByteBuf in) {\r
-        if (in.readableBytes() > 0) {\r
-            MatchBuilder builder = new MatchBuilder();\r
-            int type = in.readUnsignedShort();\r
-            int length = in.readUnsignedShort();\r
-            switch (type) {\r
-            case 0:\r
-                builder.setType(StandardMatchType.class);\r
-                break;\r
-            case 1:\r
-                builder.setType(OxmMatchType.class);\r
-                break;\r
-            default:\r
-                break;\r
-            }\r
-            builder.setMatchEntries(createMatchEntries(in, length - 2 * (EncodeConstants.SIZE_OF_SHORT_IN_BYTES)));\r
-            int paddingRemainder = length % EncodeConstants.PADDING;\r
-            if (paddingRemainder != 0) {\r
-                in.skipBytes(EncodeConstants.PADDING - paddingRemainder);\r
-            }\r
-            return builder.build();\r
-        }\r
-        return null;\r
-    }\r
-    \r
-    /**\r
-     * Deserializes single match entry (oxm_field)\r
-     * @param in input ByteBuf\r
-     * @param matchLength length of match entry\r
-     * @return MatchEntriesList list containing one match entry\r
-     */\r
-    public static List<MatchEntries> createMatchEntry(ByteBuf in, int matchLength) {\r
-        return createMatchEntriesInternal(in, matchLength, true);\r
-    }\r
-    \r
-    /**\r
-     * @param in input ByteBuf\r
-     * @param matchLength length of match entries\r
-     * @return MatchEntriesList list of match entries\r
-     */\r
-    public static List<MatchEntries> createMatchEntries(ByteBuf in, int matchLength) {\r
-        return createMatchEntriesInternal(in, matchLength, false);\r
-    }\r
-    \r
-    private static List<MatchEntries> createMatchEntriesInternal(ByteBuf in, int matchLength, boolean oneEntry) {\r
-        List<MatchEntries> matchEntriesList = new ArrayList<>();\r
-        int currLength = 0;\r
-        while(currLength < matchLength) {\r
-            MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder(); \r
-            switch (in.readUnsignedShort()) { \r
-            case 0x0000:\r
-                        matchEntriesBuilder.setOxmClass(Nxm0Class.class);\r
-                        break;\r
-            case 0x0001:\r
-                        matchEntriesBuilder.setOxmClass(Nxm1Class.class);\r
-                        break;\r
-            case 0x8000:\r
-                        matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
-                        break;\r
-            case 0xFFFF:\r
-                        matchEntriesBuilder.setOxmClass(ExperimenterClass.class);\r
-                        break;\r
-            default:\r
-                        break;\r
-            }\r
-\r
-            int fieldAndMask = in.readUnsignedByte();\r
-            boolean hasMask = (fieldAndMask & 1) != 0;\r
-            matchEntriesBuilder.setHasMask(hasMask);\r
-            int matchField =  fieldAndMask >> 1;\r
-            int matchEntryLength = in.readUnsignedByte();\r
-            currLength += EncodeConstants.SIZE_OF_SHORT_IN_BYTES +\r
-                    (2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES) + matchEntryLength;\r
-            \r
-            switch(matchField) {\r
-            case 0: \r
-                matchEntriesBuilder.setOxmMatchField(InPort.class);\r
-                PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder();\r
-                port.setPortNumber(new PortNumber(in.readUnsignedInt())); \r
-                matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, port.build());\r
-                break;\r
-            case 1:\r
-                matchEntriesBuilder.setOxmMatchField(InPhyPort.class);\r
-                PortNumberMatchEntryBuilder phyPort = new PortNumberMatchEntryBuilder();\r
-                phyPort.setPortNumber(new PortNumber(in.readUnsignedInt())); \r
-                matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, phyPort.build());\r
-                break;\r
-            case 2:\r
-                matchEntriesBuilder.setOxmMatchField(Metadata.class);\r
-                addMetadataAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
-                }\r
-                break;\r
-            case 3:\r
-                matchEntriesBuilder.setOxmMatchField(EthDst.class);\r
-                addMacAddressAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
-                }\r
-                break;\r
-            case 4:\r
-                matchEntriesBuilder.setOxmMatchField(EthSrc.class);\r
-                addMacAddressAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
-                }\r
-                break;\r
-            case 5:\r
-                matchEntriesBuilder.setOxmMatchField(EthType.class);\r
-                EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder();\r
-                ethertypeBuilder.setEthType(new EtherType(in.readUnsignedShort()));\r
-                matchEntriesBuilder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build());\r
-                break;\r
-            case 6:\r
-                matchEntriesBuilder.setOxmMatchField(VlanVid.class);\r
-                VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();\r
-                int vidEntryValue = in.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
-                matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-                }\r
-                break;\r
-            case 7:\r
-                matchEntriesBuilder.setOxmMatchField(VlanPcp.class);\r
-                VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder();\r
-                vlanPcpBuilder.setVlanPcp(in.readUnsignedByte());\r
-                matchEntriesBuilder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build());\r
-                break;\r
-            case 8:\r
-                matchEntriesBuilder.setOxmMatchField(IpDscp.class);\r
-                DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder();\r
-                dscpBuilder.setDscp(new Dscp(in.readUnsignedByte()));\r
-                matchEntriesBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build());\r
-                break;\r
-            case 9:\r
-                matchEntriesBuilder.setOxmMatchField(IpEcn.class);\r
-                EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder();\r
-                ecnBuilder.setEcn(in.readUnsignedByte());\r
-                matchEntriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build());\r
-                break;\r
-            case 10:\r
-                matchEntriesBuilder.setOxmMatchField(IpProto.class);\r
-                ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder();\r
-                protoNumberBuilder.setProtocolNumber(in.readUnsignedByte());\r
-                matchEntriesBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build());\r
-                break;\r
-            case 11:\r
-                matchEntriesBuilder.setOxmMatchField(Ipv4Src.class);\r
-                LOGGER.warn("IPV4address(ipv4src): received but possible wrong deserialization");\r
-                addIpv4AddressAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                }\r
-                break;\r
-            case 12:\r
-                matchEntriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
-                LOGGER.warn("IPV4address(ipv4dst): received but possible wrong deserialization");\r
-                addIpv4AddressAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                }\r
-                break;\r
-            case 13:\r
-                matchEntriesBuilder.setOxmMatchField(TcpSrc.class);\r
-                addPortAugmentation(null, in);\r
-                break;\r
-            case 14:\r
-                matchEntriesBuilder.setOxmMatchField(TcpDst.class);\r
-                addPortAugmentation(null, in);\r
-                break;\r
-            case 15:\r
-                matchEntriesBuilder.setOxmMatchField(UdpSrc.class);\r
-                addPortAugmentation(null, in);\r
-                break;\r
-            case 16:\r
-                matchEntriesBuilder.setOxmMatchField(UdpDst.class);\r
-                addPortAugmentation(null, in);\r
-                break;\r
-            case 17:\r
-                matchEntriesBuilder.setOxmMatchField(SctpSrc.class);\r
-                addPortAugmentation(null, in);\r
-                break;\r
-            case 18:\r
-                matchEntriesBuilder.setOxmMatchField(SctpDst.class);\r
-                addPortAugmentation(null, in);\r
-                break;\r
-            case 19:\r
-                matchEntriesBuilder.setOxmMatchField(Icmpv4Type.class);\r
-                Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder();\r
-                icmpv4TypeBuilder.setIcmpv4Type(in.readUnsignedByte());\r
-                matchEntriesBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build());\r
-                break;\r
-            case 20:\r
-                matchEntriesBuilder.setOxmMatchField(Icmpv4Code.class);\r
-                Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder();\r
-                icmpv4CodeBuilder.setIcmpv4Code(in.readUnsignedByte());\r
-                matchEntriesBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build());\r
-                break;\r
-            case 21:\r
-                matchEntriesBuilder.setOxmMatchField(ArpOp.class);\r
-                OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder();\r
-                opcodeBuilder.setOpCode(in.readUnsignedShort());\r
-                matchEntriesBuilder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build());\r
-                break;\r
-            case 22:\r
-                matchEntriesBuilder.setOxmMatchField(ArpSpa.class);\r
-                LOGGER.warn("IPV4address(arpspa): received but possible wrong deserialization");\r
-                addIpv4AddressAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                }\r
-                break;\r
-            case 23:\r
-                matchEntriesBuilder.setOxmMatchField(ArpTpa.class);\r
-                LOGGER.warn("IPV4address(arptpa): received but possible wrong deserialization");\r
-                addIpv4AddressAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                }\r
-                break;\r
-            case 24:\r
-                matchEntriesBuilder.setOxmMatchField(ArpSha.class);\r
-                addMacAddressAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
-                }\r
-                break;\r
-            case 25:\r
-                matchEntriesBuilder.setOxmMatchField(ArpTha.class);\r
-                addMacAddressAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
-                }\r
-                break;\r
-            case 26:\r
-                matchEntriesBuilder.setOxmMatchField(Ipv6Src.class);\r
-                // TODO - ipv6address - check format with tests\r
-                LOGGER.warn("IPV6address(Ipv6Src): received but possible wrong deserialization");\r
-                addIpv6AddressAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);\r
-                }\r
-                break;\r
-            case 27:\r
-                matchEntriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
-                // TODO - ipv6address - check format with tests\r
-                LOGGER.warn("IPV6address(Ipv6Dst): received but possible wrong deserialization");\r
-                addIpv6AddressAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);\r
-                }\r
-                break;\r
-            case 28:\r
-                matchEntriesBuilder.setOxmMatchField(Ipv6Flabel.class);\r
-                Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder();\r
-                ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(in.readUnsignedInt()));\r
-                matchEntriesBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build());\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                }\r
-                break;\r
-            case 29:\r
-                matchEntriesBuilder.setOxmMatchField(Icmpv6Type.class);\r
-                Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder();\r
-                icmpv6TypeBuilder.setIcmpv6Type(in.readUnsignedByte());\r
-                matchEntriesBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build());\r
-                break;\r
-            case 30:\r
-                matchEntriesBuilder.setOxmMatchField(Icmpv6Code.class);\r
-                Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder();\r
-                icmpv6CodeBuilder.setIcmpv6Code(in.readUnsignedByte());\r
-                matchEntriesBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build());\r
-                break;\r
-            case 31:\r
-                matchEntriesBuilder.setOxmMatchField(Ipv6NdTarget.class);\r
-                // TODO - ipv6address - check format with tests\r
-                LOGGER.warn("IPV6address(Ipv6NdTarget): received but possible wrong deserialization");\r
-                addIpv6AddressAugmentation(matchEntriesBuilder, in);\r
-                break;\r
-            case 32:\r
-                matchEntriesBuilder.setOxmMatchField(Ipv6NdSll.class);\r
-                addMacAddressAugmentation(matchEntriesBuilder, in);\r
-                break;\r
-            case 33:\r
-                matchEntriesBuilder.setOxmMatchField(Ipv6NdTll.class);\r
-                addMacAddressAugmentation(matchEntriesBuilder, in);\r
-                break;\r
-            case 34:\r
-                matchEntriesBuilder.setOxmMatchField(MplsLabel.class);\r
-                MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder();\r
-                mplsLabelBuilder.setMplsLabel(in.readUnsignedInt());\r
-                matchEntriesBuilder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build());\r
-                break;\r
-            case 35:\r
-                matchEntriesBuilder.setOxmMatchField(MplsTc.class);\r
-                TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder();\r
-                tcBuilder.setTc(in.readUnsignedByte());\r
-                matchEntriesBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build());\r
-                break;\r
-            case 36:\r
-                matchEntriesBuilder.setOxmMatchField(MplsBos.class);\r
-                BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder();\r
-                if (in.readUnsignedByte() != 0) {\r
-                    bosBuilder.setBos(true);\r
-                } else {\r
-                    bosBuilder.setBos(false);\r
-                }\r
-                matchEntriesBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build());\r
-                break;\r
-            case 37:\r
-                matchEntriesBuilder.setOxmMatchField(PbbIsid.class);\r
-                IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder();\r
-                isidBuilder.setIsid(in.readUnsignedInt());\r
-                matchEntriesBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build());\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                }\r
-                break;\r
-            case 38:\r
-                matchEntriesBuilder.setOxmMatchField(TunnelId.class);\r
-                addMetadataAugmentation(matchEntriesBuilder, in);\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
-                }\r
-                break;\r
-            case 39:\r
-                matchEntriesBuilder.setOxmMatchField(Ipv6Exthdr.class);\r
-                PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder();\r
-                int bitmap = in.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 PseudoField(AUTH, DEST, ESP, FRAG, HOP, NONEXT, ROUTER, UNREP, UNSEQ));\r
-                matchEntriesBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build());\r
-                if (hasMask) {\r
-                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-                }\r
-                break;\r
-            default: \r
-                break;\r
-            }\r
-          matchEntriesList.add(matchEntriesBuilder.build());\r
-          if (oneEntry) {\r
-              break;\r
-          }\r
-        }\r
-        if ((matchLength - currLength) > 0) {\r
-            in.skipBytes(matchLength - currLength);\r
-        }\r
-        return matchEntriesList;\r
-    }\r
-\r
-    private static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf in, int matchEntryLength) {\r
-        MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();\r
-        byte[] mask = new byte[matchEntryLength];\r
-        in.readBytes(mask);\r
-        maskBuilder.setMask(mask);\r
-        builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
-    }\r
-\r
-    private static void addIpv6AddressAugmentation(MatchEntriesBuilder builder, ByteBuf in) {\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("X", in.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
-    private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf in) {\r
-        MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder();\r
-        byte[] metadataBytes = new byte[Long.SIZE/Byte.SIZE];\r
-        in.readBytes(metadataBytes);\r
-        metadata.setMetadata(metadataBytes); \r
-        builder.addAugmentation(MetadataMatchEntry.class, metadata.build());\r
-    }\r
-\r
-    private static void addIpv4AddressAugmentation(MatchEntriesBuilder builder, ByteBuf in) {\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(in.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
-    private static void addMacAddressAugmentation(MatchEntriesBuilder builder, ByteBuf in) {\r
-        MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder();\r
-        byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];\r
-        in.readBytes(address);\r
-        macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));\r
-        builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build());\r
-    }\r
-    \r
-    private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf in) {\r
-        PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder();\r
-        portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.\r
-                xml.ns.yang.ietf.inet.types.rev100924.PortNumber(in.readUnsignedShort()));\r
-        builder.addAugmentation(PortMatchEntry.class, portBuilder.build());\r
-    }\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.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.PseudoFieldMatchEntry.PseudoField;
+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.PortNumber;
+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.oxm.fields.MatchEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntriesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.MatchBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+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 {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(MatchDeserializer.class);
+    
+    /**
+     * Creates match
+     * @param in input ByteBuf
+     * @return ofp_match (OpenFlow v1.3)
+     */
+    public static Match createMatch(ByteBuf in) {
+        if (in.readableBytes() > 0) {
+            MatchBuilder builder = new MatchBuilder();
+            int type = in.readUnsignedShort();
+            int length = in.readUnsignedShort();
+            switch (type) {
+            case 0:
+                builder.setType(StandardMatchType.class);
+                break;
+            case 1:
+                builder.setType(OxmMatchType.class);
+                break;
+            default:
+                break;
+            }
+            builder.setMatchEntries(createMatchEntries(in, length - 2 * (EncodeConstants.SIZE_OF_SHORT_IN_BYTES)));
+            int paddingRemainder = length % EncodeConstants.PADDING;
+            if (paddingRemainder != 0) {
+                in.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.SIZE_OF_LONG_IN_BYTES);
+                }
+                break;
+            case 4:
+                matchEntriesBuilder.setOxmMatchField(EthSrc.class);
+                addMacAddressAugmentation(matchEntriesBuilder, in);
+                if (hasMask) {
+                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
+                }
+                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);
+                LOGGER.warn("IPV4address(ipv4src): received but possible wrong deserialization");
+                addIpv4AddressAugmentation(matchEntriesBuilder, in);
+                if (hasMask) {
+                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+                }
+                break;
+            case 12:
+                matchEntriesBuilder.setOxmMatchField(Ipv4Dst.class);
+                LOGGER.warn("IPV4address(ipv4dst): received but possible wrong deserialization");
+                addIpv4AddressAugmentation(matchEntriesBuilder, in);
+                if (hasMask) {
+                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+                }
+                break;
+            case 13:
+                matchEntriesBuilder.setOxmMatchField(TcpSrc.class);
+                addPortAugmentation(null, in);
+                break;
+            case 14:
+                matchEntriesBuilder.setOxmMatchField(TcpDst.class);
+                addPortAugmentation(null, in);
+                break;
+            case 15:
+                matchEntriesBuilder.setOxmMatchField(UdpSrc.class);
+                addPortAugmentation(null, in);
+                break;
+            case 16:
+                matchEntriesBuilder.setOxmMatchField(UdpDst.class);
+                addPortAugmentation(null, in);
+                break;
+            case 17:
+                matchEntriesBuilder.setOxmMatchField(SctpSrc.class);
+                addPortAugmentation(null, in);
+                break;
+            case 18:
+                matchEntriesBuilder.setOxmMatchField(SctpDst.class);
+                addPortAugmentation(null, 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);
+                LOGGER.warn("IPV4address(arpspa): received but possible wrong deserialization");
+                addIpv4AddressAugmentation(matchEntriesBuilder, in);
+                if (hasMask) {
+                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+                }
+                break;
+            case 23:
+                matchEntriesBuilder.setOxmMatchField(ArpTpa.class);
+                LOGGER.warn("IPV4address(arptpa): received but possible wrong deserialization");
+                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.SIZE_OF_LONG_IN_BYTES);
+                }
+                break;
+            case 25:
+                matchEntriesBuilder.setOxmMatchField(ArpTha.class);
+                addMacAddressAugmentation(matchEntriesBuilder, in);
+                if (hasMask) {
+                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
+                }
+                break;
+            case 26:
+                matchEntriesBuilder.setOxmMatchField(Ipv6Src.class);
+                // TODO - ipv6address - check format with tests
+                LOGGER.warn("IPV6address(Ipv6Src): received but possible wrong deserialization");
+                addIpv6AddressAugmentation(matchEntriesBuilder, in);
+                if (hasMask) {
+                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
+                }
+                break;
+            case 27:
+                matchEntriesBuilder.setOxmMatchField(Ipv6Dst.class);
+                // TODO - ipv6address - check format with tests
+                LOGGER.warn("IPV6address(Ipv6Dst): received but possible wrong deserialization");
+                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);
+                // TODO - ipv6address - check format with tests
+                LOGGER.warn("IPV6address(Ipv6NdTarget): received but possible wrong deserialization");
+                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();
+                isidBuilder.setIsid(in.readUnsignedInt());
+                matchEntriesBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build());
+                if (hasMask) {
+                    addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_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 PseudoField(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;
+    }
+
+    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("X", 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[Long.SIZE/Byte.SIZE];
+        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());
+    }
+}
index 557ff7bca2b8cef9aff540badd36acdc6b5f1e5c..5ba7a187971baf453dfdb15034c42116a6f58f99 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.Arrays;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry;\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.Icmpv4TypeMatchEntry;\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.Icmpv6TypeMatchEntry;\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.Ipv6AddressMatchEntry;\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.IsidMatchEntry;\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.MaskMatchEntry;\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.MplsLabelMatchEntry;\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.PortMatchEntry;\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.ProtocolNumberMatchEntry;\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.PseudoFieldMatchEntry.PseudoField;\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.VlanPcpMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType;\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.ArpSha;\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.ArpTha;\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.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
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;\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.InPort;\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.IpEcn;\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.Ipv4Dst;\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.Ipv6Dst;\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.Ipv6Flabel;\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.Ipv6NdTarget;\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.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.Metadata;\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.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
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;\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.VlanVid;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * Serializes ofp_match (OpenFlow v1.3) and its oxm_fields structures\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class MatchSerializer {\r
-    private static final Logger LOGGER = LoggerFactory.getLogger(MatchSerializer.class);\r
-    private static final byte STANDARD_MATCH_TYPE_CODE = 0;\r
-    private static final byte OXM_MATCH_TYPE_CODE = 1;\r
-    private static final int NXM0_CLASS_CODE = 0x0000;\r
-    private static final int NXM1_CLASS_CODE = 0x0001;\r
-    private static final int OPENFLOW_BASIC_CLASS_CODE = 0x8000;\r
-    private static final int EXPERIMENTER_CLASS_CODE = 0xFFFF;\r
-    private static final byte MATCH_TYPE_AND_LENGTH_SIZE = 4;\r
-    private static final byte MATCH_ENTRY_HEADER_LENGTH = 4;\r
-\r
-    /**\r
-     * Encodes match (OpenFlow v1.3)\r
-     * @param match ofp_match object\r
-     * @param out output ByteBuf\r
-     */\r
-    public static void encodeMatch(Match match, ByteBuf out) {\r
-        if (match == null) {\r
-            LOGGER.debug("Match is null");\r
-            return;\r
-        }\r
-        encodeType(match, out);\r
-        // Length of ofp_match (excluding padding)\r
-        int length = computeMatchLengthInternal(match);\r
-        out.writeShort(length);\r
-        encodeMatchEntries(match.getMatchEntries(), out);\r
-        int paddingRemainder = length % EncodeConstants.PADDING;\r
-        if (paddingRemainder != 0) {\r
-            ByteBufUtils.padBuffer(EncodeConstants.PADDING - paddingRemainder, out);\r
-        }\r
-    }\r
-\r
-    private static void encodeType(Match match, ByteBuf out) {\r
-        if (match.getType().isAssignableFrom(StandardMatchType.class)) {\r
-            out.writeShort(STANDARD_MATCH_TYPE_CODE);\r
-        } else if (match.getType().isAssignableFrom(OxmMatchType.class)) {\r
-            out.writeShort(OXM_MATCH_TYPE_CODE);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Encodes MatchEntries\r
-     * @param matchEntries list of match entries (oxm_fields)\r
-     * @param out output ByteBuf\r
-     */\r
-    public static void encodeMatchEntries(List<MatchEntries> matchEntries, ByteBuf out) {\r
-        if (matchEntries == null) {\r
-            LOGGER.warn("Match entries are null");\r
-            return;\r
-        }\r
-        for (MatchEntries entry : matchEntries) {\r
-            encodeClass(entry.getOxmClass(), out);\r
-            encodeRest(entry, out);\r
-        }\r
-    }\r
-\r
-    private static void encodeClass(Class<? extends Clazz> clazz, ByteBuf out) {\r
-        if (clazz.isAssignableFrom(Nxm0Class.class)) {\r
-            out.writeShort(NXM0_CLASS_CODE);\r
-        } else if (clazz.isAssignableFrom(Nxm1Class.class)) {\r
-            out.writeShort(NXM1_CLASS_CODE);\r
-        } else if (clazz.isAssignableFrom(OpenflowBasicClass.class)) {\r
-            out.writeShort(OPENFLOW_BASIC_CLASS_CODE);\r
-        } else if (clazz.isAssignableFrom(ExperimenterClass.class)) {\r
-            out.writeShort(EXPERIMENTER_CLASS_CODE);\r
-        }\r
-    }\r
-\r
-    private static void encodeRest(MatchEntries entry, ByteBuf out) {\r
-        int fieldValue = 0;\r
-        Class<? extends MatchField> field = entry.getOxmMatchField();\r
-        if (field.isAssignableFrom(InPort.class)) {\r
-            fieldValue = 0;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-            out.writeInt(entry.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
-        } else if (field.isAssignableFrom(InPhyPort.class)) {\r
-            fieldValue = 1;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-            out.writeInt(entry.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
-        } else if (field.isAssignableFrom(Metadata.class)) {\r
-            fieldValue = 2;\r
-            writeMetadataRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(EthDst.class)) {\r
-            fieldValue = 3;\r
-            writeMacAddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(EthSrc.class)) {\r
-            fieldValue = 4;\r
-            writeMacAddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(EthType.class)) {\r
-            fieldValue = 5;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-            out.writeShort(entry.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().shortValue());\r
-        } else if (field.isAssignableFrom(VlanVid.class)) {\r
-            fieldValue = 6;\r
-            fieldValue = fieldValue << 1;\r
-            VlanVidMatchEntry vlanVid = entry.getAugmentation(VlanVidMatchEntry.class);\r
-            int vlanVidValue = vlanVid.getVlanVid();\r
-            if (vlanVid.isCfiBit()) {\r
-                short cfi = 1 << 12; // 13-th bit\r
-                vlanVidValue = vlanVidValue | cfi;\r
-            }\r
-            if (entry.isHasMask()) {\r
-                fieldValue = fieldValue | 1;\r
-                out.writeByte(fieldValue);\r
-                byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();\r
-                out.writeByte(EncodeConstants.SIZE_OF_SHORT_IN_BYTES + mask.length);\r
-                out.writeShort(vlanVidValue);\r
-                out.writeBytes(mask);\r
-            } else {\r
-                writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-                out.writeShort(vlanVidValue);\r
-            }\r
-        } else if (field.isAssignableFrom(VlanPcp.class)) {\r
-            fieldValue = 7;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-            out.writeByte(entry.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().byteValue());\r
-        } else if (field.isAssignableFrom(IpDscp.class)) {\r
-            fieldValue = 8;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-            out.writeByte(entry.getAugmentation(DscpMatchEntry.class).getDscp().getValue());\r
-        } else if (field.isAssignableFrom(IpEcn.class)) {\r
-            fieldValue = 9;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-            out.writeByte(entry.getAugmentation(EcnMatchEntry.class).getEcn());\r
-        } else if (field.isAssignableFrom(IpProto.class)) {\r
-            fieldValue = 10;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-            out.writeByte(entry.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber());\r
-        } else if (field.isAssignableFrom(Ipv4Src.class)) {\r
-            fieldValue = 11;\r
-            writeIpv4AddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(Ipv4Dst.class)) {\r
-            fieldValue = 12;\r
-            writeIpv4AddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(TcpSrc.class)) {\r
-            fieldValue = 13;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
-        } else if (field.isAssignableFrom(TcpDst.class)) {\r
-            fieldValue = 14;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
-        } else if (field.isAssignableFrom(UdpSrc.class)) {\r
-            fieldValue = 15;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
-        } else if (field.isAssignableFrom(UdpDst.class)) {\r
-            fieldValue = 16;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
-        } else if (field.isAssignableFrom(SctpSrc.class)) {\r
-            fieldValue = 17;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
-        } else if (field.isAssignableFrom(SctpDst.class)) {\r
-            fieldValue = 18;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
-        } else if (field.isAssignableFrom(Icmpv4Type.class)) {\r
-            fieldValue = 19;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-            out.writeByte(entry.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type());\r
-        } else if (field.isAssignableFrom(Icmpv4Code.class)) {\r
-            fieldValue = 20;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-            out.writeByte(entry.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code());\r
-        } else if (field.isAssignableFrom(ArpOp.class)) {\r
-            fieldValue = 21;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-            out.writeShort(entry.getAugmentation(OpCodeMatchEntry.class).getOpCode());\r
-        } else if (field.isAssignableFrom(ArpSpa.class)) {\r
-            fieldValue = 22;\r
-            writeIpv4AddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(ArpTpa.class)) {\r
-            fieldValue = 23;\r
-            writeIpv4AddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(ArpSha.class)) {\r
-            fieldValue = 24;\r
-            writeMacAddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(ArpTha.class)) {\r
-            fieldValue = 25;\r
-            writeMacAddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(Ipv6Src.class)) {\r
-            fieldValue = 26;\r
-            writeIpv6AddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(Ipv6Dst.class)) {\r
-            fieldValue = 27;\r
-            writeIpv6AddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(Ipv6Flabel.class)) {\r
-            fieldValue = 28;\r
-            fieldValue = fieldValue << 1;\r
-            if (entry.isHasMask()) {\r
-                fieldValue = fieldValue | 1;\r
-                out.writeByte(fieldValue);\r
-                byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();\r
-                out.writeByte(EncodeConstants.SIZE_OF_INT_IN_BYTES + mask.length); // 20 b + mask [OF 1.3.2 spec]\r
-                LOGGER.warn("Ipv6Flabel match entry: possible wrong length written (wrote 4 - maybe must be 3)");\r
-                out.writeInt(entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue());\r
-                out.writeBytes(entry.getAugmentation(MaskMatchEntry.class).getMask());\r
-            } else {\r
-                out.writeByte(fieldValue);\r
-                out.writeByte(EncodeConstants.SIZE_OF_INT_IN_BYTES); // 20 b [OF 1.3.2 spec]\r
-                LOGGER.warn("Ipv6Flabel match entry: possible wrong length written (wrote 4 - maybe must be 3)");\r
-                out.writeInt(entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue());\r
-            }\r
-        } else if (field.isAssignableFrom(Icmpv6Type.class)) {\r
-            fieldValue = 29;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-            out.writeByte(entry.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type());\r
-        } else if (field.isAssignableFrom(Icmpv6Code.class)) {\r
-            fieldValue = 30;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-            out.writeByte(entry.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code());\r
-        } else if (field.isAssignableFrom(Ipv6NdTarget.class)) {\r
-            fieldValue = 31;\r
-            writeIpv6AddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(Ipv6NdSll.class)) {\r
-            fieldValue = 32;\r
-            writeMacAddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(Ipv6NdTll.class)) {\r
-            fieldValue = 33;\r
-            writeMacAddressRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(MplsLabel.class)) {\r
-            fieldValue = 34;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-            LOGGER.warn("MplsLabel match entry: possible wrong length written (wrote 4 - maybe must be 3)");\r
-            out.writeInt(entry.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue());\r
-        } else if (field.isAssignableFrom(MplsTc.class)) {\r
-            fieldValue = 35;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-            out.writeByte(entry.getAugmentation(TcMatchEntry.class).getTc());\r
-        } else if (field.isAssignableFrom(MplsBos.class)) {\r
-            fieldValue = 36;\r
-            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-            out.writeBoolean(entry.getAugmentation(BosMatchEntry.class).isBos().booleanValue());\r
-        } else if (field.isAssignableFrom(PbbIsid.class)) {\r
-            fieldValue = 37;\r
-            fieldValue = fieldValue << 1;\r
-            if (entry.isHasMask()) {\r
-                fieldValue = fieldValue | 1;\r
-                out.writeByte(fieldValue);\r
-                byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();\r
-                out.writeByte(EncodeConstants.SIZE_OF_LONG_IN_BYTES + mask.length);\r
-                LOGGER.warn("PbbIsid match entry: possible wrong length written (wrote 4 - maybe must be 3)");\r
-                out.writeInt(entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue());\r
-                out.writeBytes(mask);\r
-            } else {\r
-                out.writeByte(fieldValue);\r
-                out.writeByte(EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
-                LOGGER.warn("PbbIsid match entry: possible wrong length written (wrote 4 - maybe must be 3)");\r
-                out.writeInt(entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue());\r
-            }\r
-        } else if (field.isAssignableFrom(TunnelId.class)) {\r
-            fieldValue = 38;\r
-            writeMetadataRelatedEntry(entry, out, fieldValue);\r
-        } else if (field.isAssignableFrom(Ipv6Exthdr.class)) {\r
-            fieldValue = 39;\r
-            fieldValue = fieldValue << 1;\r
-            PseudoField pseudoField = entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField();\r
-            Map<Integer, Boolean> map = new HashMap<>();\r
-            map.put(0, pseudoField.isNonext());\r
-            map.put(1, pseudoField.isEsp());\r
-            map.put(2, pseudoField.isAuth());\r
-            map.put(3, pseudoField.isDest());\r
-            map.put(4, pseudoField.isFrag());\r
-            map.put(5, pseudoField.isRouter());\r
-            map.put(6, pseudoField.isHop());\r
-            map.put(7, pseudoField.isUnrep());\r
-            map.put(8, pseudoField.isUnseq());\r
-            int bitmap = ByteBufUtils.fillBitMaskFromMap(map);\r
-            if (entry.isHasMask()) {\r
-                fieldValue = fieldValue | 1;\r
-                out.writeByte(fieldValue);\r
-                byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();\r
-                out.writeByte(EncodeConstants.SIZE_OF_SHORT_IN_BYTES + mask.length);\r
-                out.writeShort(bitmap);\r
-                out.writeBytes(mask);\r
-            } else {\r
-                out.writeByte(fieldValue);\r
-                out.writeByte(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-                out.writeShort(bitmap);\r
-            }\r
-        }\r
-    }\r
-\r
-    private static void writeOxmFieldAndLength(ByteBuf out, int fieldValue, int length) {\r
-        int fieldAndMask = fieldValue << 1;\r
-        out.writeByte(fieldAndMask);\r
-        out.writeByte(length);\r
-    }\r
-\r
-    private static void writeMetadataRelatedEntry(MatchEntries entry, ByteBuf out, int value) {\r
-        int fieldValue = value << 1;\r
-        if (entry.isHasMask()) {\r
-            fieldValue = fieldValue | 1;\r
-            out.writeByte(fieldValue);\r
-            byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();\r
-            out.writeByte(EncodeConstants.SIZE_OF_LONG_IN_BYTES + mask.length);\r
-            out.writeBytes(entry.getAugmentation(MetadataMatchEntry.class).getMetadata());\r
-            out.writeBytes(mask);\r
-        } else {\r
-            out.writeByte(fieldValue);\r
-            out.writeByte(EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
-            out.writeBytes(entry.getAugmentation(MetadataMatchEntry.class).getMetadata());\r
-        }\r
-    }\r
-\r
-    private static void writeMacAddressRelatedEntry(MatchEntries entry, ByteBuf out, int value) {\r
-        int fieldValue = value << 1;\r
-        if (entry.isHasMask()) {\r
-            fieldValue = fieldValue | 1;\r
-            out.writeByte(fieldValue);\r
-            byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();\r
-            out.writeByte(EncodeConstants.MAC_ADDRESS_LENGTH + mask.length); // 48 b + mask [OF 1.3.2 spec]\r
-            String macAddress = entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue();\r
-            out.writeBytes(ByteBufUtils.macAddressToBytes(macAddress));\r
-            out.writeBytes(mask);\r
-        } else {\r
-            out.writeByte(fieldValue);\r
-            out.writeByte(EncodeConstants.MAC_ADDRESS_LENGTH); // 48 b [OF 1.3.2 spec]\r
-            String macAddress = entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue();\r
-            out.writeBytes(ByteBufUtils.macAddressToBytes(macAddress));\r
-        }\r
-    }\r
-\r
-    private static void writeIpv4AddressRelatedEntry(MatchEntries entry, ByteBuf out, int value) {\r
-        int fieldValue = value << 1;\r
-        if (entry.isHasMask()) {\r
-            fieldValue = fieldValue | 1;\r
-            out.writeByte(fieldValue);\r
-            byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();\r
-            out.writeByte(EncodeConstants.SIZE_OF_INT_IN_BYTES + mask.length);\r
-            writeIpv4Address(entry, out);\r
-            out.writeBytes(mask);\r
-        } else {\r
-            out.writeByte(fieldValue);\r
-            out.writeByte(EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-            writeIpv4Address(entry, out);\r
-        }\r
-    }\r
-\r
-    private static void writeIpv4Address(MatchEntries entry, ByteBuf out) {\r
-        String[] addressGroups = entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address().getValue().split("\\.");\r
-        for (int i = 0; i < addressGroups.length; i++) {\r
-            out.writeByte(Integer.parseInt(addressGroups[i]));\r
-        }\r
-    }\r
-\r
-    private static void writeIpv6AddressRelatedEntry(MatchEntries entry, ByteBuf out, int value) {\r
-        int fieldValue = value << 1;\r
-        String textAddress = entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue();\r
-        String[] address;\r
-        if (textAddress.equals("::")) {\r
-            address = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS];\r
-            Arrays.fill(address, "0");\r
-        } else {\r
-            address = parseIpv6Address(textAddress.split(":"));\r
-        }\r
-        if (entry.isHasMask()) {\r
-            fieldValue = fieldValue | 1;\r
-            out.writeByte(fieldValue);\r
-            byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();\r
-            out.writeByte(EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES + mask.length);\r
-            for (int i = 0; i < address.length; i++) {\r
-                out.writeShort(Integer.parseInt(address[i], 16));\r
-            }\r
-            out.writeBytes(mask);\r
-        } else {\r
-            out.writeByte(fieldValue);\r
-            out.writeByte(EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);\r
-            for (int i = 0; i < address.length; i++) {\r
-                out.writeShort(Integer.parseInt(address[i], 16));\r
-            }\r
-        }\r
-    }\r
-\r
-    private static String[] parseIpv6Address(String[] addressGroups) {\r
-        int countEmpty = 0;\r
-        for (int i = 0; i < addressGroups.length; i++) {\r
-            if (addressGroups[i].equals("")){\r
-                countEmpty++;\r
-            }\r
-        }\r
-        String[] ready = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS];\r
-        switch (countEmpty) {\r
-        case 0:\r
-            ready = addressGroups;\r
-            break;\r
-        case 1:\r
-            int zerosToBePushed = EncodeConstants.GROUPS_IN_IPV6_ADDRESS - addressGroups.length + 1;\r
-            int index = 0;\r
-            for (int i = 0; i < addressGroups.length; i++) {\r
-                if (addressGroups[i].equals("")) {\r
-                    for (int j = 0; j < zerosToBePushed; j++) {\r
-                        ready[index] = "0";\r
-                        index++;\r
-                    }\r
-                } else {\r
-                    ready[index] = addressGroups[i];\r
-                    index++;\r
-                }\r
-            }\r
-            break;\r
-        case 2:\r
-            Arrays.fill(ready, "0");\r
-            ready[ready.length - 1] = addressGroups[addressGroups.length - 1];\r
-            break;\r
-        default:\r
-            throw new IllegalStateException("Incorrect ipv6 address");\r
-        }\r
-        return ready;\r
-    }\r
-\r
-    /**\r
-     * Computes length of match (in bytes)\r
-     * @param match\r
-     * @return length of ofp_match (excluding padding)\r
-     */\r
-    public static int computeMatchLengthInternal(Match match) {\r
-        int length = 0;\r
-        if (match != null) {\r
-            length += MATCH_TYPE_AND_LENGTH_SIZE + computeMatchEntriesLength(match.getMatchEntries());\r
-        }\r
-        return length;\r
-    }\r
-\r
-    /**\r
-     * Computes length of match (in bytes)\r
-     * @param match\r
-     * @return length of ofp_match (excluding padding)\r
-     */\r
-    public static int computeMatchLength(Match match) {\r
-        int length = computeMatchLengthInternal(match);\r
-        int paddingRemainder = length % EncodeConstants.PADDING;\r
-        if (paddingRemainder != 0) {\r
-            length += EncodeConstants.PADDING - paddingRemainder;\r
-        }\r
-        return length;\r
-    }\r
-\r
-    /**\r
-     * Computes length of MatchEntries (in bytes)\r
-     * @param matchEntries list of match entries (oxm_fields)\r
-     * @return length of MatchEntries\r
-     */\r
-    public static int computeMatchEntriesLength(List<MatchEntries> matchEntries) {\r
-        int length = 0;\r
-        if (matchEntries != null) {\r
-            for (MatchEntries entry : matchEntries) {\r
-                length += MATCH_ENTRY_HEADER_LENGTH;\r
-                Class<? extends MatchField> field = entry.getOxmMatchField();\r
-                if (field.isAssignableFrom(InPort.class)) {\r
-                    length += EncodeConstants.SIZE_OF_INT_IN_BYTES;\r
-                } else if (field.isAssignableFrom(InPhyPort.class)) {\r
-                    length += EncodeConstants.SIZE_OF_INT_IN_BYTES;\r
-                } else if (field.isAssignableFrom(Metadata.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
-                } else if (field.isAssignableFrom(EthDst.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);\r
-                } else if (field.isAssignableFrom(EthSrc.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);\r
-                } else if (field.isAssignableFrom(EthType.class)) {\r
-                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;\r
-                } else if (field.isAssignableFrom(VlanVid.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-                } else if (field.isAssignableFrom(VlanPcp.class)) {\r
-                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;\r
-                } else if (field.isAssignableFrom(IpDscp.class)) {\r
-                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;\r
-                } else if (field.isAssignableFrom(IpEcn.class)) {\r
-                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;\r
-                } else if (field.isAssignableFrom(IpProto.class)) {\r
-                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;\r
-                } else if (field.isAssignableFrom(Ipv4Src.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                } else if (field.isAssignableFrom(Ipv4Dst.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                } else if (field.isAssignableFrom(TcpSrc.class)) {\r
-                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;\r
-                } else if (field.isAssignableFrom(TcpDst.class)) {\r
-                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;\r
-                } else if (field.isAssignableFrom(UdpSrc.class)) {\r
-                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;\r
-                } else if (field.isAssignableFrom(UdpDst.class)) {\r
-                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;\r
-                } else if (field.isAssignableFrom(SctpSrc.class)) {\r
-                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;\r
-                } else if (field.isAssignableFrom(SctpDst.class)) {\r
-                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;\r
-                } else if (field.isAssignableFrom(Icmpv4Type.class)) {\r
-                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;\r
-                } else if (field.isAssignableFrom(Icmpv4Code.class)) {\r
-                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;\r
-                } else if (field.isAssignableFrom(ArpOp.class)) {\r
-                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;\r
-                } else if (field.isAssignableFrom(ArpSpa.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                } else if (field.isAssignableFrom(ArpTpa.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                } else if (field.isAssignableFrom(ArpSha.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);\r
-                } else if (field.isAssignableFrom(ArpTha.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);\r
-                } else if (field.isAssignableFrom(Ipv6Src.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);\r
-                } else if (field.isAssignableFrom(Ipv6Dst.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);\r
-                } else if (field.isAssignableFrom(Ipv6Flabel.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                } else if (field.isAssignableFrom(Icmpv6Type.class)) {\r
-                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;\r
-                } else if (field.isAssignableFrom(Icmpv6Code.class)) {\r
-                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;\r
-                } else if (field.isAssignableFrom(Ipv6NdTarget.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);\r
-                } else if (field.isAssignableFrom(Ipv6NdSll.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);\r
-                } else if (field.isAssignableFrom(Ipv6NdTll.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);\r
-                } else if (field.isAssignableFrom(MplsLabel.class)) {\r
-                    length += EncodeConstants.SIZE_OF_INT_IN_BYTES;\r
-                } else if (field.isAssignableFrom(MplsTc.class)) {\r
-                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;\r
-                } else if (field.isAssignableFrom(MplsBos.class)) {\r
-                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;\r
-                } else if (field.isAssignableFrom(PbbIsid.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-                } else if (field.isAssignableFrom(TunnelId.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
-                } else if (field.isAssignableFrom(Ipv6Exthdr.class)) {\r
-                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-                }\r
-            }\r
-        }\r
-        return length;\r
-    }\r
-\r
-    private static int computePossibleMaskEntryLength(MatchEntries entry, int length) {\r
-        int entryLength = length;\r
-        if (entry.isHasMask()) {\r
-            entryLength *= 2;\r
-        }\r
-        return entryLength;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry.PseudoField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
+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.Clazz;
+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.MatchField;
+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.oxm.fields.MatchEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Serializes ofp_match (OpenFlow v1.3) and its oxm_fields structures
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class MatchSerializer {
+    private static final Logger LOGGER = LoggerFactory.getLogger(MatchSerializer.class);
+    private static final byte STANDARD_MATCH_TYPE_CODE = 0;
+    private static final byte OXM_MATCH_TYPE_CODE = 1;
+    private static final int NXM0_CLASS_CODE = 0x0000;
+    private static final int NXM1_CLASS_CODE = 0x0001;
+    private static final int OPENFLOW_BASIC_CLASS_CODE = 0x8000;
+    private static final int EXPERIMENTER_CLASS_CODE = 0xFFFF;
+    private static final byte MATCH_TYPE_AND_LENGTH_SIZE = 4;
+    private static final byte MATCH_ENTRY_HEADER_LENGTH = 4;
+
+    /**
+     * Encodes match (OpenFlow v1.3)
+     * @param match ofp_match object
+     * @param out output ByteBuf
+     */
+    public static void encodeMatch(Match match, ByteBuf out) {
+        if (match == null) {
+            LOGGER.debug("Match is null");
+            return;
+        }
+        encodeType(match, out);
+        // Length of ofp_match (excluding padding)
+        int length = computeMatchLengthInternal(match);
+        out.writeShort(length);
+        encodeMatchEntries(match.getMatchEntries(), out);
+        int paddingRemainder = length % EncodeConstants.PADDING;
+        if (paddingRemainder != 0) {
+            ByteBufUtils.padBuffer(EncodeConstants.PADDING - paddingRemainder, out);
+        }
+    }
+
+    private static void encodeType(Match match, ByteBuf out) {
+        if (match.getType().isAssignableFrom(StandardMatchType.class)) {
+            out.writeShort(STANDARD_MATCH_TYPE_CODE);
+        } else if (match.getType().isAssignableFrom(OxmMatchType.class)) {
+            out.writeShort(OXM_MATCH_TYPE_CODE);
+        }
+    }
+
+    /**
+     * Encodes MatchEntries
+     * @param matchEntries list of match entries (oxm_fields)
+     * @param out output ByteBuf
+     */
+    public static void encodeMatchEntries(List<MatchEntries> matchEntries, ByteBuf out) {
+        if (matchEntries == null) {
+            LOGGER.warn("Match entries are null");
+            return;
+        }
+        for (MatchEntries entry : matchEntries) {
+            encodeClass(entry.getOxmClass(), out);
+            encodeRest(entry, out);
+        }
+    }
+
+    private static void encodeClass(Class<? extends Clazz> clazz, ByteBuf out) {
+        if (clazz.isAssignableFrom(Nxm0Class.class)) {
+            out.writeShort(NXM0_CLASS_CODE);
+        } else if (clazz.isAssignableFrom(Nxm1Class.class)) {
+            out.writeShort(NXM1_CLASS_CODE);
+        } else if (clazz.isAssignableFrom(OpenflowBasicClass.class)) {
+            out.writeShort(OPENFLOW_BASIC_CLASS_CODE);
+        } else if (clazz.isAssignableFrom(ExperimenterClass.class)) {
+            out.writeShort(EXPERIMENTER_CLASS_CODE);
+        }
+    }
+
+    private static void encodeRest(MatchEntries entry, ByteBuf out) {
+        int fieldValue = 0;
+        Class<? extends MatchField> field = entry.getOxmMatchField();
+        if (field.isAssignableFrom(InPort.class)) {
+            fieldValue = 0;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+            out.writeInt(entry.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());
+        } else if (field.isAssignableFrom(InPhyPort.class)) {
+            fieldValue = 1;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+            out.writeInt(entry.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());
+        } else if (field.isAssignableFrom(Metadata.class)) {
+            fieldValue = 2;
+            writeMetadataRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(EthDst.class)) {
+            fieldValue = 3;
+            writeMacAddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(EthSrc.class)) {
+            fieldValue = 4;
+            writeMacAddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(EthType.class)) {
+            fieldValue = 5;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            out.writeShort(entry.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().shortValue());
+        } else if (field.isAssignableFrom(VlanVid.class)) {
+            fieldValue = 6;
+            fieldValue = fieldValue << 1;
+            VlanVidMatchEntry vlanVid = entry.getAugmentation(VlanVidMatchEntry.class);
+            int vlanVidValue = vlanVid.getVlanVid();
+            if (vlanVid.isCfiBit()) {
+                short cfi = 1 << 12; // 13-th bit
+                vlanVidValue = vlanVidValue | cfi;
+            }
+            if (entry.isHasMask()) {
+                fieldValue = fieldValue | 1;
+                out.writeByte(fieldValue);
+                byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();
+                out.writeByte(EncodeConstants.SIZE_OF_SHORT_IN_BYTES + mask.length);
+                out.writeShort(vlanVidValue);
+                out.writeBytes(mask);
+            } else {
+                writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+                out.writeShort(vlanVidValue);
+            }
+        } else if (field.isAssignableFrom(VlanPcp.class)) {
+            fieldValue = 7;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+            out.writeByte(entry.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().byteValue());
+        } else if (field.isAssignableFrom(IpDscp.class)) {
+            fieldValue = 8;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+            out.writeByte(entry.getAugmentation(DscpMatchEntry.class).getDscp().getValue());
+        } else if (field.isAssignableFrom(IpEcn.class)) {
+            fieldValue = 9;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+            out.writeByte(entry.getAugmentation(EcnMatchEntry.class).getEcn());
+        } else if (field.isAssignableFrom(IpProto.class)) {
+            fieldValue = 10;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+            out.writeByte(entry.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber());
+        } else if (field.isAssignableFrom(Ipv4Src.class)) {
+            fieldValue = 11;
+            writeIpv4AddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(Ipv4Dst.class)) {
+            fieldValue = 12;
+            writeIpv4AddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(TcpSrc.class)) {
+            fieldValue = 13;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());
+        } else if (field.isAssignableFrom(TcpDst.class)) {
+            fieldValue = 14;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());
+        } else if (field.isAssignableFrom(UdpSrc.class)) {
+            fieldValue = 15;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());
+        } else if (field.isAssignableFrom(UdpDst.class)) {
+            fieldValue = 16;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());
+        } else if (field.isAssignableFrom(SctpSrc.class)) {
+            fieldValue = 17;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());
+        } else if (field.isAssignableFrom(SctpDst.class)) {
+            fieldValue = 18;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            out.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());
+        } else if (field.isAssignableFrom(Icmpv4Type.class)) {
+            fieldValue = 19;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+            out.writeByte(entry.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type());
+        } else if (field.isAssignableFrom(Icmpv4Code.class)) {
+            fieldValue = 20;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+            out.writeByte(entry.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code());
+        } else if (field.isAssignableFrom(ArpOp.class)) {
+            fieldValue = 21;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            out.writeShort(entry.getAugmentation(OpCodeMatchEntry.class).getOpCode());
+        } else if (field.isAssignableFrom(ArpSpa.class)) {
+            fieldValue = 22;
+            writeIpv4AddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(ArpTpa.class)) {
+            fieldValue = 23;
+            writeIpv4AddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(ArpSha.class)) {
+            fieldValue = 24;
+            writeMacAddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(ArpTha.class)) {
+            fieldValue = 25;
+            writeMacAddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(Ipv6Src.class)) {
+            fieldValue = 26;
+            writeIpv6AddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(Ipv6Dst.class)) {
+            fieldValue = 27;
+            writeIpv6AddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(Ipv6Flabel.class)) {
+            fieldValue = 28;
+            fieldValue = fieldValue << 1;
+            if (entry.isHasMask()) {
+                fieldValue = fieldValue | 1;
+                out.writeByte(fieldValue);
+                byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();
+                out.writeByte(EncodeConstants.SIZE_OF_INT_IN_BYTES + mask.length); // 20 b + mask [OF 1.3.2 spec]
+                LOGGER.warn("Ipv6Flabel match entry: possible wrong length written (wrote 4 - maybe must be 3)");
+                out.writeInt(entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue());
+                out.writeBytes(entry.getAugmentation(MaskMatchEntry.class).getMask());
+            } else {
+                out.writeByte(fieldValue);
+                out.writeByte(EncodeConstants.SIZE_OF_INT_IN_BYTES); // 20 b [OF 1.3.2 spec]
+                LOGGER.warn("Ipv6Flabel match entry: possible wrong length written (wrote 4 - maybe must be 3)");
+                out.writeInt(entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue());
+            }
+        } else if (field.isAssignableFrom(Icmpv6Type.class)) {
+            fieldValue = 29;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+            out.writeByte(entry.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type());
+        } else if (field.isAssignableFrom(Icmpv6Code.class)) {
+            fieldValue = 30;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+            out.writeByte(entry.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code());
+        } else if (field.isAssignableFrom(Ipv6NdTarget.class)) {
+            fieldValue = 31;
+            writeIpv6AddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(Ipv6NdSll.class)) {
+            fieldValue = 32;
+            writeMacAddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(Ipv6NdTll.class)) {
+            fieldValue = 33;
+            writeMacAddressRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(MplsLabel.class)) {
+            fieldValue = 34;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+            LOGGER.warn("MplsLabel match entry: possible wrong length written (wrote 4 - maybe must be 3)");
+            out.writeInt(entry.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue());
+        } else if (field.isAssignableFrom(MplsTc.class)) {
+            fieldValue = 35;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+            out.writeByte(entry.getAugmentation(TcMatchEntry.class).getTc());
+        } else if (field.isAssignableFrom(MplsBos.class)) {
+            fieldValue = 36;
+            writeOxmFieldAndLength(out, fieldValue, EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+            out.writeBoolean(entry.getAugmentation(BosMatchEntry.class).isBos().booleanValue());
+        } else if (field.isAssignableFrom(PbbIsid.class)) {
+            fieldValue = 37;
+            fieldValue = fieldValue << 1;
+            if (entry.isHasMask()) {
+                fieldValue = fieldValue | 1;
+                out.writeByte(fieldValue);
+                byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();
+                out.writeByte(EncodeConstants.SIZE_OF_LONG_IN_BYTES + mask.length);
+                LOGGER.warn("PbbIsid match entry: possible wrong length written (wrote 4 - maybe must be 3)");
+                out.writeInt(entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue());
+                out.writeBytes(mask);
+            } else {
+                out.writeByte(fieldValue);
+                out.writeByte(EncodeConstants.SIZE_OF_LONG_IN_BYTES);
+                LOGGER.warn("PbbIsid match entry: possible wrong length written (wrote 4 - maybe must be 3)");
+                out.writeInt(entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue());
+            }
+        } else if (field.isAssignableFrom(TunnelId.class)) {
+            fieldValue = 38;
+            writeMetadataRelatedEntry(entry, out, fieldValue);
+        } else if (field.isAssignableFrom(Ipv6Exthdr.class)) {
+            fieldValue = 39;
+            fieldValue = fieldValue << 1;
+            PseudoField pseudoField = entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField();
+            Map<Integer, Boolean> map = new HashMap<>();
+            map.put(0, pseudoField.isNonext());
+            map.put(1, pseudoField.isEsp());
+            map.put(2, pseudoField.isAuth());
+            map.put(3, pseudoField.isDest());
+            map.put(4, pseudoField.isFrag());
+            map.put(5, pseudoField.isRouter());
+            map.put(6, pseudoField.isHop());
+            map.put(7, pseudoField.isUnrep());
+            map.put(8, pseudoField.isUnseq());
+            int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
+            if (entry.isHasMask()) {
+                fieldValue = fieldValue | 1;
+                out.writeByte(fieldValue);
+                byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();
+                out.writeByte(EncodeConstants.SIZE_OF_SHORT_IN_BYTES + mask.length);
+                out.writeShort(bitmap);
+                out.writeBytes(mask);
+            } else {
+                out.writeByte(fieldValue);
+                out.writeByte(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+                out.writeShort(bitmap);
+            }
+        }
+    }
+
+    private static void writeOxmFieldAndLength(ByteBuf out, int fieldValue, int length) {
+        int fieldAndMask = fieldValue << 1;
+        out.writeByte(fieldAndMask);
+        out.writeByte(length);
+    }
+
+    private static void writeMetadataRelatedEntry(MatchEntries entry, ByteBuf out, int value) {
+        int fieldValue = value << 1;
+        if (entry.isHasMask()) {
+            fieldValue = fieldValue | 1;
+            out.writeByte(fieldValue);
+            byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();
+            out.writeByte(EncodeConstants.SIZE_OF_LONG_IN_BYTES + mask.length);
+            out.writeBytes(entry.getAugmentation(MetadataMatchEntry.class).getMetadata());
+            out.writeBytes(mask);
+        } else {
+            out.writeByte(fieldValue);
+            out.writeByte(EncodeConstants.SIZE_OF_LONG_IN_BYTES);
+            out.writeBytes(entry.getAugmentation(MetadataMatchEntry.class).getMetadata());
+        }
+    }
+
+    private static void writeMacAddressRelatedEntry(MatchEntries entry, ByteBuf out, int value) {
+        int fieldValue = value << 1;
+        if (entry.isHasMask()) {
+            fieldValue = fieldValue | 1;
+            out.writeByte(fieldValue);
+            byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();
+            out.writeByte(EncodeConstants.MAC_ADDRESS_LENGTH + mask.length); // 48 b + mask [OF 1.3.2 spec]
+            String macAddress = entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue();
+            out.writeBytes(ByteBufUtils.macAddressToBytes(macAddress));
+            out.writeBytes(mask);
+        } else {
+            out.writeByte(fieldValue);
+            out.writeByte(EncodeConstants.MAC_ADDRESS_LENGTH); // 48 b [OF 1.3.2 spec]
+            String macAddress = entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue();
+            out.writeBytes(ByteBufUtils.macAddressToBytes(macAddress));
+        }
+    }
+
+    private static void writeIpv4AddressRelatedEntry(MatchEntries entry, ByteBuf out, int value) {
+        int fieldValue = value << 1;
+        if (entry.isHasMask()) {
+            fieldValue = fieldValue | 1;
+            out.writeByte(fieldValue);
+            byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();
+            out.writeByte(EncodeConstants.SIZE_OF_INT_IN_BYTES + mask.length);
+            writeIpv4Address(entry, out);
+            out.writeBytes(mask);
+        } else {
+            out.writeByte(fieldValue);
+            out.writeByte(EncodeConstants.SIZE_OF_INT_IN_BYTES);
+            writeIpv4Address(entry, out);
+        }
+    }
+
+    private static void writeIpv4Address(MatchEntries entry, ByteBuf out) {
+        String[] addressGroups = entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address().getValue().split("\\.");
+        for (int i = 0; i < addressGroups.length; i++) {
+            out.writeByte(Integer.parseInt(addressGroups[i]));
+        }
+    }
+
+    private static void writeIpv6AddressRelatedEntry(MatchEntries entry, ByteBuf out, int value) {
+        int fieldValue = value << 1;
+        String textAddress = entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue();
+        String[] address;
+        if (textAddress.equals("::")) {
+            address = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS];
+            Arrays.fill(address, "0");
+        } else {
+            address = parseIpv6Address(textAddress.split(":"));
+        }
+        if (entry.isHasMask()) {
+            fieldValue = fieldValue | 1;
+            out.writeByte(fieldValue);
+            byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();
+            out.writeByte(EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES + mask.length);
+            for (int i = 0; i < address.length; i++) {
+                out.writeShort(Integer.parseInt(address[i], 16));
+            }
+            out.writeBytes(mask);
+        } else {
+            out.writeByte(fieldValue);
+            out.writeByte(EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
+            for (int i = 0; i < address.length; i++) {
+                out.writeShort(Integer.parseInt(address[i], 16));
+            }
+        }
+    }
+
+    private static String[] parseIpv6Address(String[] addressGroups) {
+        int countEmpty = 0;
+        for (int i = 0; i < addressGroups.length; i++) {
+            if (addressGroups[i].equals("")){
+                countEmpty++;
+            }
+        }
+        String[] ready = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS];
+        switch (countEmpty) {
+        case 0:
+            ready = addressGroups;
+            break;
+        case 1:
+            int zerosToBePushed = EncodeConstants.GROUPS_IN_IPV6_ADDRESS - addressGroups.length + 1;
+            int index = 0;
+            for (int i = 0; i < addressGroups.length; i++) {
+                if (addressGroups[i].equals("")) {
+                    for (int j = 0; j < zerosToBePushed; j++) {
+                        ready[index] = "0";
+                        index++;
+                    }
+                } else {
+                    ready[index] = addressGroups[i];
+                    index++;
+                }
+            }
+            break;
+        case 2:
+            Arrays.fill(ready, "0");
+            ready[ready.length - 1] = addressGroups[addressGroups.length - 1];
+            break;
+        default:
+            throw new IllegalStateException("Incorrect ipv6 address");
+        }
+        return ready;
+    }
+
+    /**
+     * Computes length of match (in bytes)
+     * @param match
+     * @return length of ofp_match (excluding padding)
+     */
+    public static int computeMatchLengthInternal(Match match) {
+        int length = 0;
+        if (match != null) {
+            length += MATCH_TYPE_AND_LENGTH_SIZE + computeMatchEntriesLength(match.getMatchEntries());
+        }
+        return length;
+    }
+
+    /**
+     * Computes length of match (in bytes)
+     * @param match
+     * @return length of ofp_match (excluding padding)
+     */
+    public static int computeMatchLength(Match match) {
+        int length = computeMatchLengthInternal(match);
+        int paddingRemainder = length % EncodeConstants.PADDING;
+        if (paddingRemainder != 0) {
+            length += EncodeConstants.PADDING - paddingRemainder;
+        }
+        return length;
+    }
+
+    /**
+     * Computes length of MatchEntries (in bytes)
+     * @param matchEntries list of match entries (oxm_fields)
+     * @return length of MatchEntries
+     */
+    public static int computeMatchEntriesLength(List<MatchEntries> matchEntries) {
+        int length = 0;
+        if (matchEntries != null) {
+            for (MatchEntries entry : matchEntries) {
+                length += MATCH_ENTRY_HEADER_LENGTH;
+                Class<? extends MatchField> field = entry.getOxmMatchField();
+                if (field.isAssignableFrom(InPort.class)) {
+                    length += EncodeConstants.SIZE_OF_INT_IN_BYTES;
+                } else if (field.isAssignableFrom(InPhyPort.class)) {
+                    length += EncodeConstants.SIZE_OF_INT_IN_BYTES;
+                } else if (field.isAssignableFrom(Metadata.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
+                } else if (field.isAssignableFrom(EthDst.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);
+                } else if (field.isAssignableFrom(EthSrc.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);
+                } else if (field.isAssignableFrom(EthType.class)) {
+                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+                } else if (field.isAssignableFrom(VlanVid.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+                } else if (field.isAssignableFrom(VlanPcp.class)) {
+                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+                } else if (field.isAssignableFrom(IpDscp.class)) {
+                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+                } else if (field.isAssignableFrom(IpEcn.class)) {
+                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+                } else if (field.isAssignableFrom(IpProto.class)) {
+                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+                } else if (field.isAssignableFrom(Ipv4Src.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+                } else if (field.isAssignableFrom(Ipv4Dst.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+                } else if (field.isAssignableFrom(TcpSrc.class)) {
+                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+                } else if (field.isAssignableFrom(TcpDst.class)) {
+                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+                } else if (field.isAssignableFrom(UdpSrc.class)) {
+                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+                } else if (field.isAssignableFrom(UdpDst.class)) {
+                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+                } else if (field.isAssignableFrom(SctpSrc.class)) {
+                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+                } else if (field.isAssignableFrom(SctpDst.class)) {
+                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+                } else if (field.isAssignableFrom(Icmpv4Type.class)) {
+                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+                } else if (field.isAssignableFrom(Icmpv4Code.class)) {
+                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+                } else if (field.isAssignableFrom(ArpOp.class)) {
+                    length += EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+                } else if (field.isAssignableFrom(ArpSpa.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+                } else if (field.isAssignableFrom(ArpTpa.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+                } else if (field.isAssignableFrom(ArpSha.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);
+                } else if (field.isAssignableFrom(ArpTha.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);
+                } else if (field.isAssignableFrom(Ipv6Src.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
+                } else if (field.isAssignableFrom(Ipv6Dst.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
+                } else if (field.isAssignableFrom(Ipv6Flabel.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+                } else if (field.isAssignableFrom(Icmpv6Type.class)) {
+                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+                } else if (field.isAssignableFrom(Icmpv6Code.class)) {
+                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+                } else if (field.isAssignableFrom(Ipv6NdTarget.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
+                } else if (field.isAssignableFrom(Ipv6NdSll.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);
+                } else if (field.isAssignableFrom(Ipv6NdTll.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.MAC_ADDRESS_LENGTH);
+                } else if (field.isAssignableFrom(MplsLabel.class)) {
+                    length += EncodeConstants.SIZE_OF_INT_IN_BYTES;
+                } else if (field.isAssignableFrom(MplsTc.class)) {
+                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+                } else if (field.isAssignableFrom(MplsBos.class)) {
+                    length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+                } else if (field.isAssignableFrom(PbbIsid.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+                } else if (field.isAssignableFrom(TunnelId.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
+                } else if (field.isAssignableFrom(Ipv6Exthdr.class)) {
+                    length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+                }
+            }
+        }
+        return length;
+    }
+
+    private static int computePossibleMaskEntryLength(MatchEntries entry, int length) {
+        int entryLength = length;
+        if (entry.isHasMask()) {
+            entryLength *= 2;
+        }
+        return entryLength;
+    }
+
+}
index bef27a1c17152541cee6276d7fc7a519ad5739ec..96d74567d6e12fc6aeb1dd8678f97e42519c2032 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\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.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.yang.types.rev100924.MacAddress;\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.DlAddressActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;\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.IpAddressActionBuilder;\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.MaxLengthActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder;\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.PortActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yangtools.yang.binding.Augmentation;\r
-\r
-import com.google.common.base.Joiner;\r
-\r
-/**\r
- * Deserializes ofp_action (OpenFlow v1.0) structures\r
- * @author michal.polkorab\r
- */\r
-public class OF10ActionsDeserializer {\r
-    \r
-    private static final byte PADDING_IN_SET_VLAN_VID_ACTION = 2;\r
-    private static final byte PADDING_IN_SET_VLAN_PCP_ACTION = 3;\r
-    private static final byte PADDING_IN_STRIP_VLAN_ACTION = 4;\r
-    private static final byte PADDING_IN_SET_DL_ACTION = 6;\r
-    private static final byte PADDING_IN_NW_TOS_ACTION = 3;\r
-    private static final byte PADDING_IN_TP_ACTION = 2;\r
-    private static final byte PADDING_IN_ENQUEUE_ACTION = 6;\r
-\r
-    /**\r
-     * Creates list of actions (OpenFlow v1.0) from ofp_action structures\r
-     * @param input input ByteBuf\r
-     * @return ActionsList list of actions\r
-     */\r
-    public static List<ActionsList> createActionsList(ByteBuf input) {\r
-        List<ActionsList> actions = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            ActionsListBuilder actionsBuilder = new ActionsListBuilder();\r
-            int type = input.readUnsignedShort();\r
-            input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-            switch(type) {\r
-            case 0:  \r
-                actions.add(createOutputAction(input, actionsBuilder));\r
-                break;\r
-            case 1: \r
-                actions.add(createSetVlanVidAction(input, actionsBuilder));\r
-                break;\r
-            case 2: \r
-                actions.add(createVlanPcpAction(input, actionsBuilder));\r
-                break;\r
-            case 3: \r
-                actions.add(createStripVlanAction(input, actionsBuilder));\r
-                break;\r
-            case 4:                              \r
-                actions.add(createSetDlSrcAction(input, actionsBuilder));\r
-                break;\r
-            case 5: \r
-                actions.add(createSetDlDstAction(input, actionsBuilder));\r
-                break;\r
-            case 6:                              \r
-                actions.add(createSetNwSrcAction(input, actionsBuilder));\r
-                break;\r
-            case 7: \r
-                actions.add(createSetNwDstAction(input, actionsBuilder));\r
-                break;\r
-            case 8: \r
-                actions.add(createSetNwTosAction(input, actionsBuilder));\r
-                break;\r
-            case 9: \r
-                actions.add(createSetTpSrcAction(input, actionsBuilder));\r
-                break;\r
-            case 10: \r
-                actions.add(createSetTpDstAction(input, actionsBuilder));\r
-                break;\r
-            case 11: \r
-                actions.add(createEnqueueAction(input, actionsBuilder));\r
-                break;\r
-            case 0xFFFF:\r
-                actions.add(createExperimenterAction(input, actionsBuilder));\r
-                break;\r
-            default: \r
-                break;\r
-            }\r
-        } \r
-        return actions;\r
-    }\r
-\r
-    /**\r
-     * @param in input ByteBuf\r
-     * @param builder \r
-     * @return ActionList\r
-     */\r
-    public static ActionsList createOutputAction(ByteBuf in, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(Output.class);\r
-        createPortAugmentation(in, actionBuilder);\r
-        MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder();\r
-        maxLen.setMaxLength(in.readUnsignedShort());\r
-        actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build());\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-\r
-    private static ActionsList createSetVlanVidAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetVlanVid.class);\r
-        VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder();\r
-        vlanBuilder.setVlanVid(input.readUnsignedShort());\r
-        input.skipBytes(PADDING_IN_SET_VLAN_VID_ACTION);\r
-        actionBuilder.addAugmentation(VlanVidAction.class, vlanBuilder.build());\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-\r
-    private static ActionsList createVlanPcpAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetVlanPcp.class);\r
-        VlanPcpActionBuilder vlanBuilder = new VlanPcpActionBuilder();\r
-        vlanBuilder.setVlanPcp(input.readUnsignedByte());\r
-        input.skipBytes(PADDING_IN_SET_VLAN_PCP_ACTION);\r
-        actionBuilder.addAugmentation(VlanVidAction.class, vlanBuilder.build());\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-\r
-    private static ActionsList createStripVlanAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(StripVlan.class);\r
-        input.skipBytes(PADDING_IN_STRIP_VLAN_ACTION);\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-\r
-    private static ActionsList createSetDlSrcAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetDlSrc.class);\r
-        actionBuilder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input));\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-\r
-    private static ActionsList createSetDlDstAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetDlDst.class);\r
-        actionBuilder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input));\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-    \r
-    private static DlAddressAction createDlAugmentationAndPad(ByteBuf input) {\r
-        DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder();\r
-        byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];\r
-        input.readBytes(address);\r
-        dlBuilder.setDlAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));\r
-        input.skipBytes(PADDING_IN_SET_DL_ACTION);\r
-        return dlBuilder.build();\r
-    }\r
-\r
-    private static ActionsList createSetNwSrcAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetNwSrc.class);\r
-        actionBuilder.addAugmentation(IpAddressAction.class, createNwAddressAugmentationAndPad(input));\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-\r
-    private static ActionsList createSetNwDstAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetNwDst.class);\r
-        actionBuilder.addAugmentation(IpAddressAction.class, createNwAddressAugmentationAndPad(input));\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-    \r
-    private static Augmentation<Action> createNwAddressAugmentationAndPad(ByteBuf input) {\r
-        IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder();\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
-        ipBuilder.setIpAddress(new Ipv4Address(joiner.join(groups)));\r
-        return ipBuilder.build();\r
-    }\r
-\r
-    private static ActionsList createSetNwTosAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetNwTos.class);\r
-        NwTosActionBuilder tosBuilder = new NwTosActionBuilder();\r
-        tosBuilder.setNwTos(input.readUnsignedByte());\r
-        actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build());\r
-        input.skipBytes(PADDING_IN_NW_TOS_ACTION);\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-\r
-    private static ActionsList createSetTpSrcAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetTpSrc.class);\r
-        createPortAugmentation(input, actionBuilder);\r
-        input.skipBytes(PADDING_IN_TP_ACTION);\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-\r
-    private static ActionsList createSetTpDstAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetTpDst.class);\r
-        createPortAugmentation(input, actionBuilder);\r
-        input.skipBytes(PADDING_IN_TP_ACTION);\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-    \r
-    private static void createPortAugmentation(ByteBuf input, ActionBuilder actionBuilder) {\r
-        PortActionBuilder portBuilder = new PortActionBuilder();\r
-        portBuilder.setPort(new PortNumber((long) input.readUnsignedShort()));\r
-        actionBuilder.addAugmentation(PortAction.class, portBuilder.build());\r
-    }\r
-\r
-    private static ActionsList createEnqueueAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(Enqueue.class);\r
-        createPortAugmentation(input, actionBuilder);\r
-        input.skipBytes(PADDING_IN_ENQUEUE_ACTION);\r
-        QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder();\r
-        queueBuilder.setQueueId(input.readUnsignedInt());\r
-        actionBuilder.addAugmentation(QueueIdAction.class, queueBuilder.build());\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-\r
-    private static ActionsList createExperimenterAction(ByteBuf input, ActionsListBuilder builder) {\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(Enqueue.class);\r
-        ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder();\r
-        expBuilder.setExperimenter(input.readUnsignedInt());\r
-        actionBuilder.addAugmentation(QueueIdAction.class, expBuilder.build());\r
-        builder.setAction(actionBuilder.build());\r
-        return builder.build();\r
-    }\r
-    \r
-    \r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder;
+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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+import com.google.common.base.Joiner;
+
+/**
+ * Deserializes ofp_action (OpenFlow v1.0) structures
+ * @author michal.polkorab
+ */
+public class OF10ActionsDeserializer {
+    
+    private static final byte PADDING_IN_SET_VLAN_VID_ACTION = 2;
+    private static final byte PADDING_IN_SET_VLAN_PCP_ACTION = 3;
+    private static final byte PADDING_IN_STRIP_VLAN_ACTION = 4;
+    private static final byte PADDING_IN_SET_DL_ACTION = 6;
+    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;
+
+    /**
+     * Creates list of actions (OpenFlow v1.0) from ofp_action structures
+     * @param input input ByteBuf
+     * @return ActionsList list of actions
+     */
+    public static List<ActionsList> createActionsList(ByteBuf input) {
+        List<ActionsList> actions = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            ActionsListBuilder actionsBuilder = new ActionsListBuilder();
+            int type = input.readUnsignedShort();
+            input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            switch(type) {
+            case 0:  
+                actions.add(createOutputAction(input, actionsBuilder));
+                break;
+            case 1: 
+                actions.add(createSetVlanVidAction(input, actionsBuilder));
+                break;
+            case 2: 
+                actions.add(createVlanPcpAction(input, actionsBuilder));
+                break;
+            case 3: 
+                actions.add(createStripVlanAction(input, actionsBuilder));
+                break;
+            case 4:                              
+                actions.add(createSetDlSrcAction(input, actionsBuilder));
+                break;
+            case 5: 
+                actions.add(createSetDlDstAction(input, actionsBuilder));
+                break;
+            case 6:                              
+                actions.add(createSetNwSrcAction(input, actionsBuilder));
+                break;
+            case 7: 
+                actions.add(createSetNwDstAction(input, actionsBuilder));
+                break;
+            case 8: 
+                actions.add(createSetNwTosAction(input, actionsBuilder));
+                break;
+            case 9: 
+                actions.add(createSetTpSrcAction(input, actionsBuilder));
+                break;
+            case 10: 
+                actions.add(createSetTpDstAction(input, actionsBuilder));
+                break;
+            case 11: 
+                actions.add(createEnqueueAction(input, actionsBuilder));
+                break;
+            case 0xFFFF:
+                actions.add(createExperimenterAction(input, actionsBuilder));
+                break;
+            default: 
+                break;
+            }
+        } 
+        return actions;
+    }
+
+    /**
+     * @param in input ByteBuf
+     * @param builder 
+     * @return ActionList
+     */
+    public static ActionsList createOutputAction(ByteBuf in, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(Output.class);
+        createPortAugmentation(in, actionBuilder);
+        MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder();
+        maxLen.setMaxLength(in.readUnsignedShort());
+        actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build());
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+
+    private static ActionsList createSetVlanVidAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetVlanVid.class);
+        VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder();
+        vlanBuilder.setVlanVid(input.readUnsignedShort());
+        input.skipBytes(PADDING_IN_SET_VLAN_VID_ACTION);
+        actionBuilder.addAugmentation(VlanVidAction.class, vlanBuilder.build());
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+
+    private static ActionsList createVlanPcpAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetVlanPcp.class);
+        VlanPcpActionBuilder vlanBuilder = new VlanPcpActionBuilder();
+        vlanBuilder.setVlanPcp(input.readUnsignedByte());
+        input.skipBytes(PADDING_IN_SET_VLAN_PCP_ACTION);
+        actionBuilder.addAugmentation(VlanVidAction.class, vlanBuilder.build());
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+
+    private static ActionsList createStripVlanAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(StripVlan.class);
+        input.skipBytes(PADDING_IN_STRIP_VLAN_ACTION);
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+
+    private static ActionsList createSetDlSrcAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetDlSrc.class);
+        actionBuilder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input));
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+
+    private static ActionsList createSetDlDstAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetDlDst.class);
+        actionBuilder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input));
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+    
+    private static DlAddressAction createDlAugmentationAndPad(ByteBuf input) {
+        DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder();
+        byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
+        input.readBytes(address);
+        dlBuilder.setDlAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));
+        input.skipBytes(PADDING_IN_SET_DL_ACTION);
+        return dlBuilder.build();
+    }
+
+    private static ActionsList createSetNwSrcAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetNwSrc.class);
+        actionBuilder.addAugmentation(IpAddressAction.class, createNwAddressAugmentationAndPad(input));
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+
+    private static ActionsList createSetNwDstAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetNwDst.class);
+        actionBuilder.addAugmentation(IpAddressAction.class, createNwAddressAugmentationAndPad(input));
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+    
+    private static Augmentation<Action> createNwAddressAugmentationAndPad(ByteBuf input) {
+        IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder();
+        List<String> groups = new ArrayList<>();
+        for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {
+            groups.add(Short.toString(input.readUnsignedByte()));
+        }
+        Joiner joiner = Joiner.on(".");
+        ipBuilder.setIpAddress(new Ipv4Address(joiner.join(groups)));
+        return ipBuilder.build();
+    }
+
+    private static ActionsList createSetNwTosAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetNwTos.class);
+        NwTosActionBuilder tosBuilder = new NwTosActionBuilder();
+        tosBuilder.setNwTos(input.readUnsignedByte());
+        actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build());
+        input.skipBytes(PADDING_IN_NW_TOS_ACTION);
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+
+    private static ActionsList createSetTpSrcAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetTpSrc.class);
+        createPortAugmentation(input, actionBuilder);
+        input.skipBytes(PADDING_IN_TP_ACTION);
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+
+    private static ActionsList createSetTpDstAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetTpDst.class);
+        createPortAugmentation(input, actionBuilder);
+        input.skipBytes(PADDING_IN_TP_ACTION);
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+    
+    private static void createPortAugmentation(ByteBuf input, ActionBuilder actionBuilder) {
+        PortActionBuilder portBuilder = new PortActionBuilder();
+        portBuilder.setPort(new PortNumber((long) input.readUnsignedShort()));
+        actionBuilder.addAugmentation(PortAction.class, portBuilder.build());
+    }
+
+    private static ActionsList createEnqueueAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(Enqueue.class);
+        createPortAugmentation(input, actionBuilder);
+        input.skipBytes(PADDING_IN_ENQUEUE_ACTION);
+        QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder();
+        queueBuilder.setQueueId(input.readUnsignedInt());
+        actionBuilder.addAugmentation(QueueIdAction.class, queueBuilder.build());
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+
+    private static ActionsList createExperimenterAction(ByteBuf input, ActionsListBuilder builder) {
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(Enqueue.class);
+        ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder();
+        expBuilder.setExperimenter(input.readUnsignedInt());
+        actionBuilder.addAugmentation(QueueIdAction.class, expBuilder.build());
+        builder.setAction(actionBuilder.build());
+        return builder.build();
+    }
+    
+    
+}
index 34cfa31b3ed44e77e019953c5f5fd08a09699012..29f42d86c3eab9366fb3e4ba1dbc1e53d7cc7fb3 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.List;\r
-\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
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action;\r
-\r
-/**\r
- * Serializes ofp_action (OpenFlow v1.0) structures\r
- * @author michal.polkorab\r
- */\r
-public abstract class OF10ActionsSerializer {\r
-    \r
-    private static final byte OUTPUT_CODE = 0;\r
-    private static final byte SET_VLAN_VID_CODE = 1;\r
-    private static final byte SET_VLAN_PCP_CODE = 2;\r
-    private static final byte STRIP_VLAN_CODE = 3;\r
-    private static final byte SET_DL_SRC_CODE = 4;\r
-    private static final byte SET_DL_DST_CODE = 5;\r
-    private static final byte SET_NW_SRC_CODE = 6;\r
-    private static final byte SET_NW_DST_CODE = 7;\r
-    private static final byte SET_NW_TOS_CODE = 8;\r
-    private static final byte SET_TP_SRC_CODE = 9;\r
-    private static final byte SET_TP_DST_CODE = 10;\r
-    private static final byte ENQUEUE_CODE = 11;\r
-    private static final int EXPERIMENTER_CODE = 65535; // 0xFFFF\r
-    private static final byte GENERIC_ACTION_LENGTH = 8;\r
-    private static final byte PADDING_IN_GENERIC_ACTION = 4;\r
-    private static final byte OUTPUT_LENGTH = 8;\r
-    private static final byte SET_VLAN_VID_LENGTH = 8;\r
-    private static final byte PADDING_IN_SET_VLAN_VID_ACTION = 2;\r
-    private static final byte SET_VLAN_PCP_LENGTH = 8;\r
-    private static final byte PADDING_IN_SET_VLAN_PCP_ACTION = 3;\r
-    private static final byte DL_ADDRESS_ACTION_LENGTH = 16;\r
-    private static final byte PADDING_IN_DL_ADDRESS_ACTION = 6;\r
-    private static final byte SET_NW_TOS_LENGTH = 8;\r
-    private static final byte PADDING_IN_SET_NW_TOS_ACTION = 3;\r
-    private static final byte IP_ADDRESS_ACTION_LENGTH = 8;\r
-    private static final byte TP_PORT_ACTION_LENGTH = 8;\r
-    private static final byte PADDING_IN_TP_PORT_ACTION = 2;\r
-    private static final byte ENQUEUE_LENGTH = 16;\r
-    private static final byte PADDING_IN_ENQUEUE_ACTION = 6;\r
-    private static final byte EXPERIMENTER_LENGTH = 8;\r
-\r
-    \r
-    /**\r
-     * Encodes ofp_action (OpenFlow v1.0) structures\r
-     * @param out output ByteBuf that actions will be written into\r
-     * @param actionsList actions to be encoded\r
-     */\r
-    public static void encodeActionsV10(ByteBuf out, List<ActionsList> actionsList) {\r
-        if (actionsList == null) {\r
-            return;\r
-        }\r
-        for (ActionsList list : actionsList) {\r
-            Action action = list.getAction();\r
-            if (action.getType().equals(Output.class)) {\r
-                encodeOutputAction(action, out);\r
-            } else if (action.getType().equals(SetVlanVid.class)) {\r
-                encodeSetVlanVidAction(action, out);\r
-            } else if (action.getType().equals(SetVlanPcp.class)) {\r
-                encodeSetVlanPcpAction(action, out);\r
-            } else if (action.getType().equals(StripVlan.class)) {\r
-                encodeGenericAction(STRIP_VLAN_CODE, out);\r
-            } else if (action.getType().equals(SetDlSrc.class)) {\r
-                encodeDlAddressAction(action, out, SET_DL_SRC_CODE);\r
-            } else if (action.getType().equals(SetDlDst.class)) {\r
-                encodeDlAddressAction(action, out, SET_DL_DST_CODE);\r
-            } else if (action.getType().equals(SetNwSrc.class)) {\r
-                encodeIpAddressAction(action, out, SET_NW_SRC_CODE);\r
-            } else if (action.getType().equals(SetNwDst.class)) {\r
-                encodeIpAddressAction(action, out, SET_NW_DST_CODE);\r
-            } else if (action.getType().equals(SetNwTos.class)) {\r
-                encodeNwTosAction(action, out);\r
-            } else if (action.getType().equals(SetTpSrc.class)) {\r
-                encodeTpPortAction(action, out, SET_TP_SRC_CODE);\r
-            } else if (action.getType().equals(SetTpDst.class)) {\r
-                encodeTpPortAction(action, out, SET_TP_DST_CODE);\r
-            } else if (action.getType().equals(Enqueue.class)) {\r
-                encodeEnqueueAction(action, out);\r
-            } else if (action.getType().equals(Experimenter.class)) {\r
-                encodeExperimenterAction(action, out);\r
-            }\r
-        }\r
-    }\r
-    \r
-    private static void encodeGenericAction(byte code, ByteBuf out) {\r
-        out.writeShort(code);\r
-        out.writeShort(GENERIC_ACTION_LENGTH);\r
-        ByteBufUtils.padBuffer(PADDING_IN_GENERIC_ACTION, out);\r
-    }\r
-    \r
-    private static void encodeOutputAction(Action action, ByteBuf out) {\r
-        out.writeShort(OUTPUT_CODE);\r
-        out.writeShort(OUTPUT_LENGTH);\r
-        PortAction port = action.getAugmentation(PortAction.class);\r
-        out.writeShort(port.getPort().getValue().intValue());\r
-        MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class);\r
-        out.writeShort(maxlength.getMaxLength());\r
-    }\r
-    \r
-    private static void encodeSetVlanVidAction(Action action, ByteBuf out) {\r
-        out.writeShort(SET_VLAN_VID_CODE);\r
-        out.writeShort(SET_VLAN_VID_LENGTH);\r
-        out.writeShort(action.getAugmentation(VlanVidAction.class).getVlanVid());\r
-        ByteBufUtils.padBuffer(PADDING_IN_SET_VLAN_VID_ACTION, out);\r
-    }\r
-    \r
-    private static void encodeSetVlanPcpAction(Action action, ByteBuf out) {\r
-        out.writeShort(SET_VLAN_PCP_CODE);\r
-        out.writeShort(SET_VLAN_PCP_LENGTH);\r
-        out.writeByte(action.getAugmentation(VlanPcpAction.class).getVlanPcp());\r
-        ByteBufUtils.padBuffer(PADDING_IN_SET_VLAN_PCP_ACTION, out);\r
-    }\r
-    \r
-    private static void encodeDlAddressAction(Action action, ByteBuf out, byte code) {\r
-        out.writeShort(code);\r
-        out.writeShort(DL_ADDRESS_ACTION_LENGTH);\r
-        out.writeBytes(action.getAugmentation(DlAddressAction.class)\r
-                .getDlAddress().getValue().getBytes());\r
-        ByteBufUtils.padBuffer(PADDING_IN_DL_ADDRESS_ACTION, out);\r
-    }\r
-    \r
-    private static void encodeNwTosAction(Action action, ByteBuf out) {\r
-        out.writeShort(SET_NW_TOS_CODE);\r
-        out.writeShort(SET_NW_TOS_LENGTH);\r
-        out.writeByte(action.getAugmentation(NwTosAction.class).getNwTos());\r
-        ByteBufUtils.padBuffer(PADDING_IN_SET_NW_TOS_ACTION, out);\r
-    }\r
-    \r
-    private static void encodeIpAddressAction(Action action, ByteBuf out, byte code) {\r
-        out.writeShort(code);\r
-        out.writeShort(IP_ADDRESS_ACTION_LENGTH);\r
-        String[] addressGroups = action.\r
-                getAugmentation(IpAddressAction.class).getIpAddress().getValue().split("\\.");\r
-        for (int i = 0; i < addressGroups.length; i++) {\r
-            out.writeByte(Integer.parseInt(addressGroups[i]));\r
-        }\r
-    }\r
-    \r
-    private static void encodeTpPortAction(Action action, ByteBuf out, byte code) {\r
-        out.writeShort(code);\r
-        out.writeShort(TP_PORT_ACTION_LENGTH);\r
-        PortAction port = action.getAugmentation(PortAction.class);\r
-        out.writeShort(port.getPort().getValue().intValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_TP_PORT_ACTION, out);\r
-    }\r
-    \r
-    private static void encodeEnqueueAction(Action action, ByteBuf out) {\r
-        out.writeShort(ENQUEUE_CODE);\r
-        out.writeShort(ENQUEUE_LENGTH);\r
-        PortAction port = action.getAugmentation(PortAction.class);\r
-        out.writeShort(port.getPort().getValue().intValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_ENQUEUE_ACTION, out);\r
-        QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);\r
-        out.writeShort(queueId.getQueueId().intValue());\r
-    }\r
-    \r
-    private static void encodeExperimenterAction(Action action, ByteBuf outBuffer) {\r
-        outBuffer.writeShort(EXPERIMENTER_CODE);\r
-        outBuffer.writeShort(EXPERIMENTER_LENGTH);\r
-        ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class);\r
-        outBuffer.writeInt(experimenter.getExperimenter().intValue());\r
-    }\r
-    \r
-    /**\r
-     * Computes length of actions\r
-     * @param actionsList\r
-     * @return length of actions (OpenFlow v1.0)\r
-     */\r
-    public static int computeActionsLength(List<ActionsList> actionsList) {\r
-        int length = 0;\r
-        if (actionsList != null) {\r
-            for (ActionsList list : actionsList) {\r
-                Action action = list.getAction();\r
-                if (action.getType().equals(Output.class)) {\r
-                    length += 8;\r
-                } else if (action.getType().equals(SetVlanVid.class)) {\r
-                    length += 8;\r
-                } else if (action.getType().equals(SetVlanPcp.class)) {\r
-                    length += 8;\r
-                } else if (action.getType().equals(StripVlan.class)) {\r
-                    length += 8;\r
-                } else if (action.getType().equals(SetDlSrc.class)) {\r
-                    length += 16;\r
-                } else if (action.getType().equals(SetDlDst.class)) {\r
-                    length += 16;\r
-                } else if (action.getType().equals(SetNwSrc.class)) {\r
-                    length += 8;\r
-                } else if (action.getType().equals(SetNwDst.class)) {\r
-                    length += 8;\r
-                } else if (action.getType().equals(SetNwTos.class)) {\r
-                    length += 8;\r
-                } else if (action.getType().equals(SetTpSrc.class)) {\r
-                    length += 8;\r
-                } else if (action.getType().equals(SetTpDst.class)) {\r
-                    length += 8;\r
-                } else if (action.getType().equals(Enqueue.class)) {\r
-                    length += 16;\r
-                } else if (action.getType().equals(Experimenter.class)) {\r
-                    length += 8;\r
-                }\r
-            }\r
-        }\r
-        return length;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action;
+
+/**
+ * Serializes ofp_action (OpenFlow v1.0) structures
+ * @author michal.polkorab
+ */
+public abstract class OF10ActionsSerializer {
+    
+    private static final byte OUTPUT_CODE = 0;
+    private static final byte SET_VLAN_VID_CODE = 1;
+    private static final byte SET_VLAN_PCP_CODE = 2;
+    private static final byte STRIP_VLAN_CODE = 3;
+    private static final byte SET_DL_SRC_CODE = 4;
+    private static final byte SET_DL_DST_CODE = 5;
+    private static final byte SET_NW_SRC_CODE = 6;
+    private static final byte SET_NW_DST_CODE = 7;
+    private static final byte SET_NW_TOS_CODE = 8;
+    private static final byte SET_TP_SRC_CODE = 9;
+    private static final byte SET_TP_DST_CODE = 10;
+    private static final byte ENQUEUE_CODE = 11;
+    private static final int EXPERIMENTER_CODE = 65535; // 0xFFFF
+    private static final byte GENERIC_ACTION_LENGTH = 8;
+    private static final byte PADDING_IN_GENERIC_ACTION = 4;
+    private static final byte OUTPUT_LENGTH = 8;
+    private static final byte SET_VLAN_VID_LENGTH = 8;
+    private static final byte PADDING_IN_SET_VLAN_VID_ACTION = 2;
+    private static final byte SET_VLAN_PCP_LENGTH = 8;
+    private static final byte PADDING_IN_SET_VLAN_PCP_ACTION = 3;
+    private static final byte DL_ADDRESS_ACTION_LENGTH = 16;
+    private static final byte PADDING_IN_DL_ADDRESS_ACTION = 6;
+    private static final byte SET_NW_TOS_LENGTH = 8;
+    private static final byte PADDING_IN_SET_NW_TOS_ACTION = 3;
+    private static final byte IP_ADDRESS_ACTION_LENGTH = 8;
+    private static final byte TP_PORT_ACTION_LENGTH = 8;
+    private static final byte PADDING_IN_TP_PORT_ACTION = 2;
+    private static final byte ENQUEUE_LENGTH = 16;
+    private static final byte PADDING_IN_ENQUEUE_ACTION = 6;
+    private static final byte EXPERIMENTER_LENGTH = 8;
+
+    
+    /**
+     * Encodes ofp_action (OpenFlow v1.0) structures
+     * @param out output ByteBuf that actions will be written into
+     * @param actionsList actions to be encoded
+     */
+    public static void encodeActionsV10(ByteBuf out, List<ActionsList> actionsList) {
+        if (actionsList == null) {
+            return;
+        }
+        for (ActionsList list : actionsList) {
+            Action action = list.getAction();
+            if (action.getType().equals(Output.class)) {
+                encodeOutputAction(action, out);
+            } else if (action.getType().equals(SetVlanVid.class)) {
+                encodeSetVlanVidAction(action, out);
+            } else if (action.getType().equals(SetVlanPcp.class)) {
+                encodeSetVlanPcpAction(action, out);
+            } else if (action.getType().equals(StripVlan.class)) {
+                encodeGenericAction(STRIP_VLAN_CODE, out);
+            } else if (action.getType().equals(SetDlSrc.class)) {
+                encodeDlAddressAction(action, out, SET_DL_SRC_CODE);
+            } else if (action.getType().equals(SetDlDst.class)) {
+                encodeDlAddressAction(action, out, SET_DL_DST_CODE);
+            } else if (action.getType().equals(SetNwSrc.class)) {
+                encodeIpAddressAction(action, out, SET_NW_SRC_CODE);
+            } else if (action.getType().equals(SetNwDst.class)) {
+                encodeIpAddressAction(action, out, SET_NW_DST_CODE);
+            } else if (action.getType().equals(SetNwTos.class)) {
+                encodeNwTosAction(action, out);
+            } else if (action.getType().equals(SetTpSrc.class)) {
+                encodeTpPortAction(action, out, SET_TP_SRC_CODE);
+            } else if (action.getType().equals(SetTpDst.class)) {
+                encodeTpPortAction(action, out, SET_TP_DST_CODE);
+            } else if (action.getType().equals(Enqueue.class)) {
+                encodeEnqueueAction(action, out);
+            } else if (action.getType().equals(Experimenter.class)) {
+                encodeExperimenterAction(action, out);
+            }
+        }
+    }
+    
+    private static void encodeGenericAction(byte code, ByteBuf out) {
+        out.writeShort(code);
+        out.writeShort(GENERIC_ACTION_LENGTH);
+        ByteBufUtils.padBuffer(PADDING_IN_GENERIC_ACTION, out);
+    }
+    
+    private static void encodeOutputAction(Action action, ByteBuf out) {
+        out.writeShort(OUTPUT_CODE);
+        out.writeShort(OUTPUT_LENGTH);
+        PortAction port = action.getAugmentation(PortAction.class);
+        out.writeShort(port.getPort().getValue().intValue());
+        MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class);
+        out.writeShort(maxlength.getMaxLength());
+    }
+    
+    private static void encodeSetVlanVidAction(Action action, ByteBuf out) {
+        out.writeShort(SET_VLAN_VID_CODE);
+        out.writeShort(SET_VLAN_VID_LENGTH);
+        out.writeShort(action.getAugmentation(VlanVidAction.class).getVlanVid());
+        ByteBufUtils.padBuffer(PADDING_IN_SET_VLAN_VID_ACTION, out);
+    }
+    
+    private static void encodeSetVlanPcpAction(Action action, ByteBuf out) {
+        out.writeShort(SET_VLAN_PCP_CODE);
+        out.writeShort(SET_VLAN_PCP_LENGTH);
+        out.writeByte(action.getAugmentation(VlanPcpAction.class).getVlanPcp());
+        ByteBufUtils.padBuffer(PADDING_IN_SET_VLAN_PCP_ACTION, out);
+    }
+    
+    private static void encodeDlAddressAction(Action action, ByteBuf out, byte code) {
+        out.writeShort(code);
+        out.writeShort(DL_ADDRESS_ACTION_LENGTH);
+        out.writeBytes(action.getAugmentation(DlAddressAction.class)
+                .getDlAddress().getValue().getBytes());
+        ByteBufUtils.padBuffer(PADDING_IN_DL_ADDRESS_ACTION, out);
+    }
+    
+    private static void encodeNwTosAction(Action action, ByteBuf out) {
+        out.writeShort(SET_NW_TOS_CODE);
+        out.writeShort(SET_NW_TOS_LENGTH);
+        out.writeByte(action.getAugmentation(NwTosAction.class).getNwTos());
+        ByteBufUtils.padBuffer(PADDING_IN_SET_NW_TOS_ACTION, out);
+    }
+    
+    private static void encodeIpAddressAction(Action action, ByteBuf out, byte code) {
+        out.writeShort(code);
+        out.writeShort(IP_ADDRESS_ACTION_LENGTH);
+        String[] addressGroups = action.
+                getAugmentation(IpAddressAction.class).getIpAddress().getValue().split("\\.");
+        for (int i = 0; i < addressGroups.length; i++) {
+            out.writeByte(Integer.parseInt(addressGroups[i]));
+        }
+    }
+    
+    private static void encodeTpPortAction(Action action, ByteBuf out, byte code) {
+        out.writeShort(code);
+        out.writeShort(TP_PORT_ACTION_LENGTH);
+        PortAction port = action.getAugmentation(PortAction.class);
+        out.writeShort(port.getPort().getValue().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_TP_PORT_ACTION, out);
+    }
+    
+    private static void encodeEnqueueAction(Action action, ByteBuf out) {
+        out.writeShort(ENQUEUE_CODE);
+        out.writeShort(ENQUEUE_LENGTH);
+        PortAction port = action.getAugmentation(PortAction.class);
+        out.writeShort(port.getPort().getValue().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_ENQUEUE_ACTION, out);
+        QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);
+        out.writeShort(queueId.getQueueId().intValue());
+    }
+    
+    private static void encodeExperimenterAction(Action action, ByteBuf outBuffer) {
+        outBuffer.writeShort(EXPERIMENTER_CODE);
+        outBuffer.writeShort(EXPERIMENTER_LENGTH);
+        ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class);
+        outBuffer.writeInt(experimenter.getExperimenter().intValue());
+    }
+    
+    /**
+     * Computes length of actions
+     * @param actionsList
+     * @return length of actions (OpenFlow v1.0)
+     */
+    public static int computeActionsLength(List<ActionsList> actionsList) {
+        int length = 0;
+        if (actionsList != null) {
+            for (ActionsList list : actionsList) {
+                Action action = list.getAction();
+                if (action.getType().equals(Output.class)) {
+                    length += 8;
+                } else if (action.getType().equals(SetVlanVid.class)) {
+                    length += 8;
+                } else if (action.getType().equals(SetVlanPcp.class)) {
+                    length += 8;
+                } else if (action.getType().equals(StripVlan.class)) {
+                    length += 8;
+                } else if (action.getType().equals(SetDlSrc.class)) {
+                    length += 16;
+                } else if (action.getType().equals(SetDlDst.class)) {
+                    length += 16;
+                } else if (action.getType().equals(SetNwSrc.class)) {
+                    length += 8;
+                } else if (action.getType().equals(SetNwDst.class)) {
+                    length += 8;
+                } else if (action.getType().equals(SetNwTos.class)) {
+                    length += 8;
+                } else if (action.getType().equals(SetTpSrc.class)) {
+                    length += 8;
+                } else if (action.getType().equals(SetTpDst.class)) {
+                    length += 8;
+                } else if (action.getType().equals(Enqueue.class)) {
+                    length += 16;
+                } else if (action.getType().equals(Experimenter.class)) {
+                    length += 8;
+                }
+            }
+        }
+        return length;
+    }
+
+}
index 026474cdb3eb885f2153f400ee396f96f8f62604..e601d95ad075f3a5fc681423151b617b4de27fca 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\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.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.yang.types.rev100924.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;\r
-\r
-import com.google.common.base.Joiner;\r
-\r
-/**\r
- * Deserializes ofp_match (OpenFlow v1.0) structure\r
- * @author michal.polkorab\r
- */\r
-public abstract class OF10MatchDeserializer {\r
-    \r
-    private static final byte PADDING_IN_MATCH = 1;\r
-    private static final byte PADDING_IN_MATCH_2 = 2;\r
-    private static final byte NW_SRC_BITS = 6;\r
-    private static final byte NW_SRC_SHIFT = 8;\r
-    private static final int NW_SRC_MASK = ((1 << NW_SRC_BITS) - 1) << NW_SRC_SHIFT;\r
-    private static final byte NW_DST_BITS = 6;\r
-    private static final byte NW_DST_SHIFT = 14;\r
-    private static final int NW_DST_MASK = ((1 << NW_DST_BITS) - 1) << NW_DST_SHIFT;\r
-\r
-    /**\r
-     * Creates ofp_match (OpenFlow v1.0) structure\r
-     * @param rawMessage ByteBuf with input data\r
-     * @return ofp_match (OpenFlow v1.0)\r
-     */\r
-    public static MatchV10 createMatchV10(ByteBuf rawMessage) {\r
-        MatchV10Builder builder = new MatchV10Builder();\r
-        long wildcards = rawMessage.readUnsignedInt();\r
-        builder.setWildcards(createWildcards(wildcards));\r
-        builder.setNwSrcMask(decodeNwSrcMask(wildcards));\r
-        builder.setNwDstMask(decodeNwDstMask(wildcards));\r
-        builder.setInPort(rawMessage.readUnsignedShort());\r
-        byte[] dlSrc = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];\r
-        rawMessage.readBytes(dlSrc);\r
-        builder.setDlSrc(new MacAddress(ByteBufUtils.macAddressToString(dlSrc)));\r
-        byte[] dlDst = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];\r
-        rawMessage.readBytes(dlDst);\r
-        builder.setDlDst(new MacAddress(ByteBufUtils.macAddressToString(dlDst)));\r
-\r
-        builder.setDlVlan(rawMessage.readUnsignedShort());\r
-        builder.setDlVlanPcp(rawMessage.readUnsignedByte());\r
-        rawMessage.skipBytes(PADDING_IN_MATCH);\r
-        builder.setDlType(rawMessage.readUnsignedShort());\r
-        builder.setNwTos(rawMessage.readUnsignedByte());\r
-        builder.setNwProto(rawMessage.readUnsignedByte());\r
-        rawMessage.skipBytes(PADDING_IN_MATCH_2);\r
-        List<String> srcGroups = new ArrayList<>();\r
-        for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {\r
-            srcGroups.add(Short.toString(rawMessage.readUnsignedByte()));\r
-        }\r
-        Joiner joiner = Joiner.on(".");\r
-        builder.setNwSrc(new Ipv4Address(joiner.join(srcGroups)));\r
-        List<String> dstGroups = new ArrayList<>();\r
-        for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {\r
-            dstGroups.add(Short.toString(rawMessage.readUnsignedByte()));\r
-        }\r
-        builder.setNwDst(new Ipv4Address(joiner.join(dstGroups)));\r
-        builder.setTpSrc(rawMessage.readUnsignedShort());\r
-        builder.setTpDst(rawMessage.readUnsignedShort());\r
-        return builder.build();\r
-    }\r
-    \r
-    private static FlowWildcardsV10 createWildcards(long input) {\r
-        boolean _iNPORT = (input & (1 << 0)) != 0;\r
-        boolean _dLVLAN = (input & (1 << 1)) != 0;\r
-        boolean _dLSRC = (input & (1 << 2)) != 0;\r
-        boolean _dLDST = (input & (1 << 3)) != 0;\r
-        boolean _dLTYPE = (input & (1 << 4)) != 0;\r
-        boolean _nWPROTO = (input & (1 << 5)) != 0;\r
-        boolean _tPSRC = (input & (1 << 6)) != 0;\r
-        boolean _tPDST = (input & (1 << 7)) != 0;\r
-        boolean _dLVLANPCP = (input & (1 << 20)) != 0;\r
-        boolean _nWTOS = (input & (1 << 21)) != 0;\r
-        int allBits = (1 << 22) - 1;\r
-        boolean _aLL = (input & allBits) == allBits;\r
-        return new FlowWildcardsV10(_aLL, _dLDST, _dLSRC, _dLTYPE, _dLVLAN,\r
-                _dLVLANPCP, _iNPORT, _nWPROTO, _nWTOS, _tPDST, _tPSRC);\r
-    }\r
-    \r
-    private static short decodeNwSrcMask(long input) {\r
-        return (short) Math.max(32 - ((input & NW_SRC_MASK) >> NW_SRC_SHIFT), 0);\r
-    }\r
-    \r
-    private static short decodeNwDstMask(long input) {\r
-        return (short) Math.max(32 - ((input & NW_DST_MASK) >> NW_DST_SHIFT), 0);\r
-    }\r
-    \r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;
+
+import com.google.common.base.Joiner;
+
+/**
+ * Deserializes ofp_match (OpenFlow v1.0) structure
+ * @author michal.polkorab
+ */
+public abstract class OF10MatchDeserializer {
+    
+    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;
+    private static final byte NW_SRC_SHIFT = 8;
+    private static final int NW_SRC_MASK = ((1 << NW_SRC_BITS) - 1) << NW_SRC_SHIFT;
+    private static final byte NW_DST_BITS = 6;
+    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) {
+        MatchV10Builder builder = new MatchV10Builder();
+        long wildcards = rawMessage.readUnsignedInt();
+        builder.setWildcards(createWildcards(wildcards));
+        builder.setNwSrcMask(decodeNwSrcMask(wildcards));
+        builder.setNwDstMask(decodeNwDstMask(wildcards));
+        builder.setInPort(rawMessage.readUnsignedShort());
+        byte[] dlSrc = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
+        rawMessage.readBytes(dlSrc);
+        builder.setDlSrc(new MacAddress(ByteBufUtils.macAddressToString(dlSrc)));
+        byte[] dlDst = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
+        rawMessage.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);
+        List<String> srcGroups = new ArrayList<>();
+        for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {
+            srcGroups.add(Short.toString(rawMessage.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()));
+        }
+        builder.setNwDst(new Ipv4Address(joiner.join(dstGroups)));
+        builder.setTpSrc(rawMessage.readUnsignedShort());
+        builder.setTpDst(rawMessage.readUnsignedShort());
+        return builder.build();
+    }
+    
+    private static FlowWildcardsV10 createWildcards(long input) {
+        boolean _iNPORT = (input & (1 << 0)) != 0;
+        boolean _dLVLAN = (input & (1 << 1)) != 0;
+        boolean _dLSRC = (input & (1 << 2)) != 0;
+        boolean _dLDST = (input & (1 << 3)) != 0;
+        boolean _dLTYPE = (input & (1 << 4)) != 0;
+        boolean _nWPROTO = (input & (1 << 5)) != 0;
+        boolean _tPSRC = (input & (1 << 6)) != 0;
+        boolean _tPDST = (input & (1 << 7)) != 0;
+        boolean _dLVLANPCP = (input & (1 << 20)) != 0;
+        boolean _nWTOS = (input & (1 << 21)) != 0;
+        int allBits = (1 << 22) - 1;
+        boolean _aLL = (input & allBits) == allBits;
+        return new FlowWildcardsV10(_aLL, _dLDST, _dLSRC, _dLTYPE, _dLVLAN,
+                _dLVLANPCP, _iNPORT, _nWPROTO, _nWTOS, _tPDST, _tPSRC);
+    }
+    
+    private static short decodeNwSrcMask(long input) {
+        return (short) Math.max(32 - ((input & NW_SRC_MASK) >> NW_SRC_SHIFT), 0);
+    }
+    
+    private static short decodeNwDstMask(long input) {
+        return (short) Math.max(32 - ((input & NW_DST_MASK) >> NW_DST_SHIFT), 0);
+    }
+    
+}
index 84023e24087659af25365e6a1ab38a2ae245f640..aac14a3fe4b8e4ef6bb2689bf4db2a8e9c16aa55 100644 (file)
@@ -1,76 +1,83 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;\r
-\r
-/**\r
- * Serializes ofp_match (OpenFlow v1.0) structure\r
- * @author michal.polkorab\r
- */\r
-public abstract class OF10MatchSerializer {\r
-\r
-    private static final byte PADDING_IN_MATCH = 1;\r
-    private static final byte PADDING_IN_MATCH_2 = 2;\r
-    private static final byte NW_SRC_SHIFT = 8;\r
-    private static final byte NW_DST_SHIFT = 14;\r
-    private static final int ALL = ((1 << 22) - 1);\r
-    \r
-    /**\r
-     * Encodes ofp_match (OpenFlow v1.0)\r
-     * @param out output ByteBuf that match will be written into\r
-     * @param match match to be encoded\r
-     */\r
-    public static void encodeMatchV10(ByteBuf out, MatchV10 match) {\r
-        out.writeInt(encodeWildcards(match.getWildcards(), match.getNwSrcMask(), match.getNwDstMask()));\r
-        out.writeShort(match.getInPort());\r
-        out.writeBytes(ByteBufUtils.macAddressToBytes(match.getDlSrc().getValue()));\r
-        out.writeBytes(ByteBufUtils.macAddressToBytes(match.getDlDst().getValue()));\r
-        out.writeShort(match.getDlVlan());\r
-        out.writeByte(match.getDlVlanPcp());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MATCH, out);\r
-        out.writeShort(match.getDlType());\r
-        out.writeByte(match.getNwTos());\r
-        out.writeByte(match.getNwProto());\r
-        ByteBufUtils.padBuffer(PADDING_IN_MATCH_2, out);\r
-        String[] srcGroups = match.getNwSrc().getValue().split("\\.");\r
-        for (int i = 0; i < srcGroups.length; i++) {\r
-            out.writeByte(Integer.parseInt(srcGroups[i]));\r
-        }\r
-        String[] dstGroups = match.getNwDst().getValue().split("\\.");\r
-        for (int i = 0; i < dstGroups.length; i++) {\r
-            out.writeByte(Integer.parseInt(dstGroups[i]));\r
-        }\r
-        out.writeShort(match.getTpSrc());\r
-        out.writeShort(match.getTpDst());\r
-    }\r
-    \r
-    private static int encodeWildcards(FlowWildcardsV10 wildcards, short srcMask, short dstMask) {\r
-        int bitmask = 0;\r
-        if (wildcards.isALL()) {\r
-            bitmask |= ALL;\r
-        } else {\r
-            Map<Integer, Boolean> wildcardsMap = new HashMap<>();\r
-            wildcardsMap.put(0, wildcards.isINPORT());\r
-            wildcardsMap.put(1, wildcards.isDLVLAN());\r
-            wildcardsMap.put(2, wildcards.isDLSRC());\r
-            wildcardsMap.put(3, wildcards.isDLDST());\r
-            wildcardsMap.put(4, wildcards.isDLTYPE());\r
-            wildcardsMap.put(5, wildcards.isNWPROTO());\r
-            wildcardsMap.put(6, wildcards.isTPSRC());\r
-            wildcardsMap.put(7, wildcards.isTPDST());\r
-            wildcardsMap.put(20, wildcards.isDLVLANPCP());\r
-            wildcardsMap.put(21, wildcards.isNWTOS());\r
-            bitmask = ByteBufUtils.fillBitMaskFromMap(wildcardsMap);\r
-            bitmask |= ((32 - srcMask) << NW_SRC_SHIFT);\r
-            bitmask |= ((32 - dstMask) << NW_DST_SHIFT);\r
-        }\r
-        return bitmask;\r
-    }\r
-    \r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
+
+/**
+ * Serializes ofp_match (OpenFlow v1.0) structure
+ * @author michal.polkorab
+ */
+public abstract class OF10MatchSerializer {
+
+    private static final byte PADDING_IN_MATCH = 1;
+    private static final byte PADDING_IN_MATCH_2 = 2;
+    private static final byte NW_SRC_SHIFT = 8;
+    private static final byte NW_DST_SHIFT = 14;
+    private static final int ALL = ((1 << 22) - 1);
+    
+    /**
+     * Encodes ofp_match (OpenFlow v1.0)
+     * @param out output ByteBuf that match will be written into
+     * @param match match to be encoded
+     */
+    public static void encodeMatchV10(ByteBuf out, MatchV10 match) {
+        out.writeInt(encodeWildcards(match.getWildcards(), match.getNwSrcMask(), match.getNwDstMask()));
+        out.writeShort(match.getInPort());
+        out.writeBytes(ByteBufUtils.macAddressToBytes(match.getDlSrc().getValue()));
+        out.writeBytes(ByteBufUtils.macAddressToBytes(match.getDlDst().getValue()));
+        out.writeShort(match.getDlVlan());
+        out.writeByte(match.getDlVlanPcp());
+        ByteBufUtils.padBuffer(PADDING_IN_MATCH, out);
+        out.writeShort(match.getDlType());
+        out.writeByte(match.getNwTos());
+        out.writeByte(match.getNwProto());
+        ByteBufUtils.padBuffer(PADDING_IN_MATCH_2, out);
+        String[] srcGroups = match.getNwSrc().getValue().split("\\.");
+        for (int i = 0; i < srcGroups.length; i++) {
+            out.writeByte(Integer.parseInt(srcGroups[i]));
+        }
+        String[] dstGroups = match.getNwDst().getValue().split("\\.");
+        for (int i = 0; i < dstGroups.length; i++) {
+            out.writeByte(Integer.parseInt(dstGroups[i]));
+        }
+        out.writeShort(match.getTpSrc());
+        out.writeShort(match.getTpDst());
+    }
+    
+    private static int encodeWildcards(FlowWildcardsV10 wildcards, short srcMask, short dstMask) {
+        int bitmask = 0;
+        if (wildcards.isALL()) {
+            bitmask |= ALL;
+        } else {
+            Map<Integer, Boolean> wildcardsMap = new HashMap<>();
+            wildcardsMap.put(0, wildcards.isINPORT());
+            wildcardsMap.put(1, wildcards.isDLVLAN());
+            wildcardsMap.put(2, wildcards.isDLSRC());
+            wildcardsMap.put(3, wildcards.isDLDST());
+            wildcardsMap.put(4, wildcards.isDLTYPE());
+            wildcardsMap.put(5, wildcards.isNWPROTO());
+            wildcardsMap.put(6, wildcards.isTPSRC());
+            wildcardsMap.put(7, wildcards.isTPDST());
+            wildcardsMap.put(20, wildcards.isDLVLANPCP());
+            wildcardsMap.put(21, wildcards.isNWTOS());
+            bitmask = ByteBufUtils.fillBitMaskFromMap(wildcardsMap);
+            bitmask |= ((32 - srcMask) << NW_SRC_SHIFT);
+            bitmask |= ((32 - dstMask) << NW_DST_SHIFT);
+        }
+        return bitmask;
+    }
+    
+}
index 73d5c235c0d6493cfb915e276f20258439ea640d..d22196a92e007dcc08a493cf4bdcc8c4fce0198a 100644 (file)
@@ -1,29 +1,36 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.core;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.channel.ChannelHandlerContext;\r
-import io.netty.handler.codec.ByteToMessageDecoder;\r
-\r
-import java.util.List;\r
-\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class DummyDecoder extends ByteToMessageDecoder {\r
-\r
-    private static final Logger LOGGER = LoggerFactory\r
-            .getLogger(DummyDecoder.class);\r
-    \r
-    @Override\r
-    protected void decode(ChannelHandlerContext ctx, ByteBuf in,\r
-            List<Object> out) throws Exception {\r
-        LOGGER.debug("decoding");\r
-        ctx.fireChannelReadComplete();\r
-    }\r
-\r
-}\r
+/*
+ * 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.core;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class DummyDecoder extends ByteToMessageDecoder {
+
+    private static final Logger LOGGER = LoggerFactory
+            .getLogger(DummyDecoder.class);
+    
+    @Override
+    protected void decode(ChannelHandlerContext ctx, ByteBuf in,
+            List<Object> out) throws Exception {
+        LOGGER.debug("decoding");
+        ctx.fireChannelReadComplete();
+    }
+
+}
index 723ce1c92efccaca14e9f55c71bce13a5f7eae82..d758ab8faceb5c3a416c52b67bf1ef54432bd58b 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.core;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.channel.ChannelHandlerContext;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-\r
-/**\r
- * Testing class of {@link OFFrameDecoder}\r
- * \r
- * @author michal.polkorab\r
- */\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class OFFrameDecoderTest {\r
-\r
-    @Mock\r
-    ChannelHandlerContext channelHandlerContext;\r
-\r
-    private OFFrameDecoder decoder;\r
-    private List<Object> list = new ArrayList<>();\r
-\r
-    /**\r
-     * Sets up tests\r
-     */\r
-    @Before\r
-    public void setUp() {\r
-        list.clear();\r
-        decoder = new OFFrameDecoder();\r
-    }\r
-\r
-    /**\r
-     * Test of decoding\r
-     * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)}\r
-     * \r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testDecode8BMessage() throws Exception {\r
-        decoder.decode(channelHandlerContext,\r
-                ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01"),\r
-                list);\r
-\r
-        Assert.assertEquals(8, ((ByteBuf) list.get(0)).readableBytes());\r
-    }\r
-\r
-    /**\r
-     * Test of decoding\r
-     * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)}\r
-     * \r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testDecode16BMessage() throws Exception {\r
-        decoder.decode(channelHandlerContext,\r
-                ByteBufUtils.hexStringToByteBuf("04 00 00 10 00 00 00 00 00 00 00 00 00 00 00 42"),\r
-                list);\r
-\r
-        Assert.assertEquals(16, ((ByteBuf) list.get(0)).readableBytes());\r
-    }\r
-\r
-    /**\r
-     * Test of decoding\r
-     * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)}\r
-     * \r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testDecodeIncompleteMessage() throws Exception {\r
-        decoder.decode(channelHandlerContext,\r
-                ByteBufUtils.hexStringToByteBuf("04 00 00 08 00"),\r
-                list);\r
-\r
-        Assert.assertEquals("List is not empty", 0, list.size());\r
-    }\r
-\r
-    /**\r
-     * Test of decoding\r
-     * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)}\r
-     * \r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testDecodeCompleteAndPartialMessage() throws Exception {\r
-        decoder.decode(channelHandlerContext,\r
-                ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01 04 00 00 08 00"),\r
-                list);\r
-\r
-        Assert.assertEquals(8, ((ByteBuf) list.get(0)).readableBytes());\r
-        Assert.assertEquals(1, list.size());\r
-    }\r
-    \r
+/*
+ * 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.core;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+
+/**
+ * Testing class of {@link OFFrameDecoder}
+ * 
+ * @author michal.polkorab
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class OFFrameDecoderTest {
+
+    @Mock
+    ChannelHandlerContext channelHandlerContext;
+
+    private OFFrameDecoder decoder;
+    private List<Object> list = new ArrayList<>();
+
+    /**
+     * Sets up tests
+     */
+    @Before
+    public void setUp() {
+        list.clear();
+        decoder = new OFFrameDecoder();
+    }
+
+    /**
+     * Test of decoding
+     * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)}
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testDecode8BMessage() throws Exception {
+        decoder.decode(channelHandlerContext,
+                ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01"),
+                list);
+
+        Assert.assertEquals(8, ((ByteBuf) list.get(0)).readableBytes());
+    }
+
+    /**
+     * Test of decoding
+     * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)}
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testDecode16BMessage() throws Exception {
+        decoder.decode(channelHandlerContext,
+                ByteBufUtils.hexStringToByteBuf("04 00 00 10 00 00 00 00 00 00 00 00 00 00 00 42"),
+                list);
+
+        Assert.assertEquals(16, ((ByteBuf) list.get(0)).readableBytes());
+    }
+
+    /**
+     * Test of decoding
+     * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)}
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testDecodeIncompleteMessage() throws Exception {
+        decoder.decode(channelHandlerContext,
+                ByteBufUtils.hexStringToByteBuf("04 00 00 08 00"),
+                list);
+
+        Assert.assertEquals("List is not empty", 0, list.size());
+    }
+
+    /**
+     * Test of decoding
+     * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)}
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testDecodeCompleteAndPartialMessage() throws Exception {
+        decoder.decode(channelHandlerContext,
+                ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01 04 00 00 08 00"),
+                list);
+
+        Assert.assertEquals(8, ((ByteBuf) list.get(0)).readableBytes());
+        Assert.assertEquals(1, list.size());
+    }
+    
 }
\ No newline at end of file
index bf862d1ba57463a939d9979f958df2d562a51fb6..fb3369bf47a07542a303f729af2afaa43509c236 100644 (file)
@@ -1,72 +1,79 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.core;\r
-\r
-import io.netty.channel.ChannelHandlerContext;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-\r
-/**\r
- * \r
- * @author michal.polkorab\r
- */\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class OFVersionDetectorTest {\r
-\r
-    @Mock\r
-    ChannelHandlerContext channelHandlerContext;\r
-\r
-    private OFVersionDetector detector;\r
-    private List<Object> list = new ArrayList<>();\r
-\r
-    /**\r
-     * Sets up test environment\r
-     */\r
-    @Before\r
-    public void setUp() {\r
-        list.clear();\r
-        detector = new OFVersionDetector();\r
-    }\r
-\r
-    /**\r
-     * Test of decode\r
-     * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)\r
-     * }\r
-     * \r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testDecode13ProtocolMessage() throws Exception {\r
-        detector.decode(channelHandlerContext,\r
-                ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01"),\r
-                list);\r
-\r
-        Assert.assertEquals(7, ((VersionMessageWrapper) list.get(0))\r
-                .getMessageBuffer().readableBytes());\r
-    }\r
-\r
-    /**\r
-     * Test of decode\r
-     * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)\r
-     * }\r
-     * \r
-     * @throws Exception\r
-     */\r
-    @Test\r
-    public void testDecodeNotSupportedVersionProtocolMessage() throws Exception {\r
-        detector.decode(channelHandlerContext,\r
-                ByteBufUtils.hexStringToByteBuf("02 00 00 08 00 00 00 01"),\r
-                list);\r
-\r
-        Assert.assertEquals("List is not empty", 0, list.size());\r
-    }\r
-\r
+/*
+ * 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.core;
+
+import io.netty.channel.ChannelHandlerContext;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+
+/**
+ * 
+ * @author michal.polkorab
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class OFVersionDetectorTest {
+
+    @Mock
+    ChannelHandlerContext channelHandlerContext;
+
+    private OFVersionDetector detector;
+    private List<Object> list = new ArrayList<>();
+
+    /**
+     * Sets up test environment
+     */
+    @Before
+    public void setUp() {
+        list.clear();
+        detector = new OFVersionDetector();
+    }
+
+    /**
+     * Test of decode
+     * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)
+     * }
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testDecode13ProtocolMessage() throws Exception {
+        detector.decode(channelHandlerContext,
+                ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01"),
+                list);
+
+        Assert.assertEquals(7, ((VersionMessageWrapper) list.get(0))
+                .getMessageBuffer().readableBytes());
+    }
+
+    /**
+     * Test of decode
+     * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)
+     * }
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testDecodeNotSupportedVersionProtocolMessage() throws Exception {
+        detector.decode(channelHandlerContext,
+                ByteBufUtils.hexStringToByteBuf("02 00 00 08 00 00 00 01"),
+                list);
+
+        Assert.assertEquals("List is not empty", 0, list.size());
+    }
+
 }
\ No newline at end of file
index f0d941160d408e8f3aa49d6207beedc944559548..32685846379c857d69a1967ec5eb3c163764b5e5 100644 (file)
@@ -1,44 +1,51 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.core;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.channel.embedded.EmbeddedChannel;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES;\r
-\r
-/**\r
- *\r
- * @author michal.polkorab\r
- */\r
-public class TlsDetectorTest {\r
-    \r
-    private EmbeddedChannel embch;\r
-\r
-    /**\r
-     * Sets up test environment\r
-     */\r
-    @Before\r
-    public void setUp() {\r
-        TlsDetector tlsDetector = new TlsDetector();\r
-        embch = new EmbeddedChannel(new DummyDecoder());\r
-        embch.pipeline().addFirst(TcpHandler.COMPONENT_NAMES.TLS_DETECTOR.name(), tlsDetector);\r
-    }\r
-\r
-    /**\r
-     * Test of decode {@link TlsDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) }\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testDecodeNotEncryptedMessage() throws Exception {\r
-        byte[] msgs = new byte[]{0x04, 0x0, 0x0, 0x08, 0x0, 0x0, 0x0, 0x01};\r
-        ByteBuf writeObj = embch.alloc().buffer(64);\r
-        writeObj.writeBytes(msgs);\r
-        embch.writeInbound(writeObj);\r
-\r
-        Assert.assertNull(embch.pipeline().get(COMPONENT_NAMES.TLS_DETECTOR.name()));\r
-        Assert.assertNull(embch.pipeline().get(COMPONENT_NAMES.SSL_HANDLER.name()));\r
-    }\r
+/*
+ * 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.core;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.embedded.EmbeddedChannel;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES;
+
+/**
+ *
+ * @author michal.polkorab
+ */
+public class TlsDetectorTest {
+    
+    private EmbeddedChannel embch;
+
+    /**
+     * Sets up test environment
+     */
+    @Before
+    public void setUp() {
+        TlsDetector tlsDetector = new TlsDetector();
+        embch = new EmbeddedChannel(new DummyDecoder());
+        embch.pipeline().addFirst(TcpHandler.COMPONENT_NAMES.TLS_DETECTOR.name(), tlsDetector);
+    }
+
+    /**
+     * Test of decode {@link TlsDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) }
+     * @throws Exception 
+     */
+    @Test
+    public void testDecodeNotEncryptedMessage() throws Exception {
+        byte[] msgs = new byte[]{0x04, 0x0, 0x0, 0x08, 0x0, 0x0, 0x0, 0x01};
+        ByteBuf writeObj = embch.alloc().buffer(64);
+        writeObj.writeBytes(msgs);
+        embch.writeInbound(writeObj);
+
+        Assert.assertNull(embch.pipeline().get(COMPONENT_NAMES.TLS_DETECTOR.name()));
+        Assert.assertNull(embch.pipeline().get(COMPONENT_NAMES.SSL_HANDLER.name()));
+    }
 }
\ No newline at end of file
index 714e23c5b1687e3f2018d2a090dbd2057cb00694..51c700e74a612f18f5bd9a847c8ad006f8815e8c 100644 (file)
@@ -1,39 +1,46 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class BarrierReplyMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing of {@link BarrierReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf bb = BufferHelper.buildBuffer();\r
-        BarrierOutput builtByFactory = BufferHelper.decodeV13(\r
-                BarrierReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-    }\r
-    \r
-    /**\r
-     * Testing of {@link BarrierReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testV10() {\r
-        ByteBuf bb = BufferHelper.buildBuffer();\r
-        BarrierOutput builtByFactory = BufferHelper.decodeV10(\r
-                BarrierReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-    }\r
-}\r
+/*
+ * 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.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class BarrierReplyMessageFactoryTest {
+
+    /**
+     * Testing of {@link BarrierReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        BarrierOutput builtByFactory = BufferHelper.decodeV13(
+                BarrierReplyMessageFactory.getInstance(), bb);
+
+        BufferHelper.checkHeaderV13(builtByFactory);
+    }
+    
+    /**
+     * Testing of {@link BarrierReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testV10() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        BarrierOutput builtByFactory = BufferHelper.decodeV10(
+                BarrierReplyMessageFactory.getInstance(), bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+    }
+}
index 0d648d012c15df84ac29cc298eb4060042db74c0..b257d9d74ddffa03aaaa52026dcad1ef77fb6774 100644 (file)
@@ -1,70 +1,77 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class EchoReplyMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing {@link EchoReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithEmptyDataField() {\r
-        ByteBuf bb = BufferHelper.buildBuffer();\r
-        EchoOutput builtByFactory = BufferHelper.decodeV13(\r
-                EchoReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link EchoReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithDataFieldSet() {\r
-        byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};\r
-        ByteBuf bb = BufferHelper.buildBuffer(data);\r
-        EchoOutput builtByFactory = BufferHelper.decodeV13(\r
-                EchoReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link EchoReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithEmptyDataFieldV10() {\r
-        ByteBuf bb = BufferHelper.buildBuffer();\r
-        EchoOutput builtByFactory = BufferHelper.decodeV10(\r
-                EchoReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link EchoReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithDataFieldSetV10() {\r
-        byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};\r
-        ByteBuf bb = BufferHelper.buildBuffer(data);\r
-        EchoOutput builtByFactory = BufferHelper.decodeV10(\r
-                EchoReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());\r
-    }\r
-\r
-}\r
+/*
+ * 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.deserialization.factories.EchoReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+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);
+
+        BufferHelper.checkHeaderV13(builtByFactory);
+    }
+    
+    /**
+     * Testing {@link EchoReplyMessageFactory} for correct translation into POJO
+     */
+    @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());
+    }
+    
+    /**
+     * Testing {@link EchoReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testWithEmptyDataFieldV10() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        EchoOutput builtByFactory = BufferHelper.decodeV10(
+                EchoReplyMessageFactory.getInstance(), bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+    }
+    
+    /**
+     * Testing {@link EchoReplyMessageFactory} 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.decodeV10(
+                EchoReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
+    }
+
+}
index da5f60e8960f552b6cde173af05851d2dd65b686..bcb125342b8867ebf49ae9072dbbcfb4f74629ef 100644 (file)
@@ -1,70 +1,77 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class EchoRequestMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing {@link EchoRequestMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithEmptyDataField() {\r
-        ByteBuf bb = BufferHelper.buildBuffer();\r
-        EchoRequestMessage builtByFactory = BufferHelper.decodeV13(\r
-                EchoRequestMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link EchoRequestMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithDataFieldSet() {\r
-        byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};\r
-        ByteBuf bb = BufferHelper.buildBuffer(data);\r
-        EchoRequestMessage builtByFactory = BufferHelper.decodeV13(\r
-                EchoRequestMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link EchoRequestMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithEmptyDataFieldV10() {\r
-        ByteBuf bb = BufferHelper.buildBuffer();\r
-        EchoRequestMessage builtByFactory = BufferHelper.decodeV10(\r
-                EchoRequestMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link EchoRequestMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithDataFieldSetV10() {\r
-        byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};\r
-        ByteBuf bb = BufferHelper.buildBuffer(data);\r
-        EchoRequestMessage builtByFactory = BufferHelper.decodeV10(\r
-                EchoRequestMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());\r
-    }\r
-\r
-}\r
+/*
+ * 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.deserialization.factories.EchoRequestMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+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);
+
+        BufferHelper.checkHeaderV13(builtByFactory);
+    }
+    
+    /**
+     * Testing {@link EchoRequestMessageFactory} for correct translation into POJO
+     */
+    @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());
+    }
+    
+    /**
+     * Testing {@link EchoRequestMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testWithEmptyDataFieldV10() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        EchoRequestMessage builtByFactory = BufferHelper.decodeV10(
+                EchoRequestMessageFactory.getInstance(), bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+    }
+    
+    /**
+     * Testing {@link EchoRequestMessageFactory} 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.decodeV10(
+                EchoRequestMessageFactory.getInstance(), bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
+    }
+
+}
index 70e4cb988f548b35861e78444b23f466780c890a..e139a77ad1ef912cceab1cce9d74cea76887eab4 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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;
index 0c080a135e5e155fbd9b20e31c19fd51ddd174eb..3f861bb964b9c158f3e376d880a45af7b05cf61e 100644 (file)
@@ -1,31 +1,38 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class ExperimenterMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing {@link ExperimenterMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("01 02 03 04 01 02 03 04");\r
-        ExperimenterMessage builtByFactory = BufferHelper.decodeV13(\r
-                ExperimenterMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong experimenter", 0x01020304L, builtByFactory.getExperimenter().longValue());\r
-        Assert.assertEquals("Wrong expType", 0x01020304L, builtByFactory.getExpType().longValue());\r
-    }\r
-\r
-}\r
+/*
+ * 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 bf2bc82fbcac7c5a4e086f2fdcfdb66148715080..be6dc48c98468a9f0f1e7b2231f23b149e442b3f 100644 (file)
@@ -1,36 +1,43 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class FeaturesReplyMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00"\r
-                + " 00 01 41 00 01 02 03");\r
-        GetFeaturesOutput builtByFactory = BufferHelper.decodeV13(\r
-                FeaturesReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());\r
-        Assert.assertEquals("Wrong buffers", 0x00010203L, builtByFactory.getBuffers().longValue());\r
-        Assert.assertEquals("Wrong number of tables", 0x01, builtByFactory.getTables().shortValue());\r
-        Assert.assertEquals("Wrong auxiliaryId", 0x01, builtByFactory.getAuxiliaryId().shortValue());\r
-        Assert.assertEquals("Wrong capabilities", new Capabilities(true, false, false, true, false, true, false), builtByFactory.getCapabilities());\r
-        Assert.assertEquals("Wrong reserved", 0x00010203L, builtByFactory.getReserved().longValue());\r
-    }\r
-}\r
+/*
+ * 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.common.types.rev130731.Capabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class FeaturesReplyMessageFactoryTest {
+
+    /**
+     * Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    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);
+
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
+        Assert.assertEquals("Wrong buffers", 0x00010203L, builtByFactory.getBuffers().longValue());
+        Assert.assertEquals("Wrong number of tables", 0x01, builtByFactory.getTables().shortValue());
+        Assert.assertEquals("Wrong auxiliaryId", 0x01, builtByFactory.getAuxiliaryId().shortValue());
+        Assert.assertEquals("Wrong capabilities", new Capabilities(true, false, false, true, false, true, false), builtByFactory.getCapabilities());
+        Assert.assertEquals("Wrong reserved", 0x00010203L, builtByFactory.getReserved().longValue());
+    }
+}
index 6e91cff972e5cb360037332a72d703d83e2916cd..4682c14760a817b6dc46b3dd60ea1c7a1876aac5 100644 (file)
@@ -1,41 +1,48 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class FlowRemovedMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing {@link FlowRemovedMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 03 02 04 00 00 00 02"\r
-                + " 00 00 00 05 00 01 00 03 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07");\r
-        FlowRemovedMessage builtByFactory = BufferHelper.decodeV13(FlowRemovedMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        \r
-        Assert.assertTrue(builtByFactory.getCookie().longValue() == 0x0001020304050607L);\r
-        Assert.assertTrue(builtByFactory.getPriority() == 0x03);\r
-        Assert.assertEquals("Wrong reason", 0x02, builtByFactory.getReason().getIntValue());\r
-        Assert.assertEquals("Wrong tableId", new TableId(4L), builtByFactory.getTableId());\r
-        Assert.assertEquals("Wrong durationSec", 0x02L, builtByFactory.getDurationSec().longValue());\r
-        Assert.assertEquals("Wrong durationNsec", 0x05L, builtByFactory.getDurationNsec().longValue());\r
-        Assert.assertEquals("Wrong idleTimeout", 0x01, builtByFactory.getIdleTimeout().intValue());\r
-        Assert.assertEquals("Wrong hardTimeout", 0x03, builtByFactory.getHardTimeout().intValue());\r
-        Assert.assertEquals("Wrong packetCount", 0x0001020304050607L, builtByFactory.getPacketCount().longValue());\r
-        Assert.assertEquals("Wrong byteCount", 0x0001020304050607L, builtByFactory.getByteCount().longValue());\r
-    }\r
-    \r
-}\r
+/*
+ * 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.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class FlowRemovedMessageFactoryTest {
+
+    /**
+     * Testing {@link FlowRemovedMessageFactory} for correct translation into POJO
+     */
+    @Test
+    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);
+
+        BufferHelper.checkHeaderV13(builtByFactory);
+        
+        Assert.assertTrue(builtByFactory.getCookie().longValue() == 0x0001020304050607L);
+        Assert.assertTrue(builtByFactory.getPriority() == 0x03);
+        Assert.assertEquals("Wrong reason", 0x02, builtByFactory.getReason().getIntValue());
+        Assert.assertEquals("Wrong tableId", new TableId(4L), builtByFactory.getTableId());
+        Assert.assertEquals("Wrong durationSec", 0x02L, builtByFactory.getDurationSec().longValue());
+        Assert.assertEquals("Wrong durationNsec", 0x05L, builtByFactory.getDurationNsec().longValue());
+        Assert.assertEquals("Wrong idleTimeout", 0x01, builtByFactory.getIdleTimeout().intValue());
+        Assert.assertEquals("Wrong hardTimeout", 0x03, builtByFactory.getHardTimeout().intValue());
+        Assert.assertEquals("Wrong packetCount", 0x0001020304050607L, builtByFactory.getPacketCount().longValue());
+        Assert.assertEquals("Wrong byteCount", 0x0001020304050607L, builtByFactory.getByteCount().longValue());
+    }
+    
+}
index 92a38f6137dfef377a71c009245f0c68731f5fba..0326720dac3c0b471bf4c60eb521e267b75f4823 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- *\r
- */\r
-public class GetAsyncReplyMessageFactoryTest {\r
-    \r
-\r
-    /**\r
-     * Testing {@link GetAsyncReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testGetAsyncReplyMessage() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 00 00 06 "+ \r
-                                              "00 00 00 05 "+\r
-                                              "00 00 00 07 "+\r
-                                              "00 00 00 00 "+\r
-                                              "00 00 00 03 "+\r
-                                              "00 00 00 0A");\r
-        GetAsyncOutput builtByFactory = BufferHelper.decodeV13(GetAsyncReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong packetInMask",createPacketInMask(), \r
-                                                 builtByFactory.getPacketInMask());\r
-        Assert.assertEquals("Wrong portStatusMask",createPortStatusMask(), \r
-                                                   builtByFactory.getPortStatusMask());\r
-        Assert.assertEquals("Wrong flowRemovedMask",createFlowRemovedMask(), \r
-                                                    builtByFactory.getFlowRemovedMask());\r
-    }\r
-    \r
-    private static List<PacketInMask> createPacketInMask() {\r
-        List<PacketInMask> inMasks = new ArrayList<>();\r
-        PacketInMaskBuilder maskBuilder;\r
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER\r
-        maskBuilder = new PacketInMaskBuilder();\r
-        List<PacketInReason> reasons = new ArrayList<>();\r
-        reasons.add(PacketInReason.OFPRACTION);\r
-        reasons.add(PacketInReason.OFPRINVALIDTTL);\r
-        maskBuilder.setMask(reasons);\r
-        inMasks.add(maskBuilder.build());\r
-        // OFPCR_ROLE_SLAVE\r
-        maskBuilder = new PacketInMaskBuilder();\r
-        reasons = new ArrayList<>();\r
-        reasons.add(PacketInReason.OFPRNOMATCH);\r
-        reasons.add(PacketInReason.OFPRINVALIDTTL);\r
-        maskBuilder.setMask(reasons);\r
-        inMasks.add(maskBuilder.build());\r
-        return inMasks;\r
-    }\r
-    \r
-    private static List<PortStatusMask> createPortStatusMask() {\r
-        List<PortStatusMask> inMasks = new ArrayList<>();\r
-        PortStatusMaskBuilder maskBuilder;\r
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER\r
-        maskBuilder = new PortStatusMaskBuilder();\r
-        List<PortReason> reasons = new ArrayList<>();\r
-        reasons.add(PortReason.OFPPRADD);\r
-        reasons.add(PortReason.OFPPRDELETE);\r
-        reasons.add(PortReason.OFPPRMODIFY);\r
-        inMasks.add(maskBuilder.setMask(reasons).build());\r
-        // OFPCR_ROLE_SLAVE\r
-        maskBuilder = new PortStatusMaskBuilder();\r
-        reasons = new ArrayList<>();\r
-        maskBuilder.setMask(reasons);\r
-        inMasks.add(maskBuilder.build());\r
-        return inMasks;\r
-    }\r
-    \r
-    private static List<FlowRemovedMask> createFlowRemovedMask() {\r
-        List<FlowRemovedMask> inMasks = new ArrayList<>();\r
-        FlowRemovedMaskBuilder maskBuilder;\r
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER\r
-        maskBuilder = new FlowRemovedMaskBuilder();\r
-        List<FlowRemovedReason> reasons = new ArrayList<>();\r
-        reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT);\r
-        reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);\r
-        maskBuilder.setMask(reasons);\r
-        inMasks.add(maskBuilder.build());\r
-        // OFPCR_ROLE_SLAVE\r
-        maskBuilder = new FlowRemovedMaskBuilder();\r
-        reasons = new ArrayList<>();\r
-        reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);\r
-        reasons.add(FlowRemovedReason.OFPRRGROUPDELETE);\r
-        maskBuilder.setMask(reasons);\r
-        inMasks.add(maskBuilder.build());\r
-        return inMasks;\r
-    }\r
-}\r
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+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.common.types.rev130731.FlowRemovedReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder;
+
+/**
+ * @author timotej.kubas
+ *
+ */
+public class GetAsyncReplyMessageFactoryTest {
+    
+
+    /**
+     * Testing {@link GetAsyncReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testGetAsyncReplyMessage() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 00 00 06 "+ 
+                                              "00 00 00 05 "+
+                                              "00 00 00 07 "+
+                                              "00 00 00 00 "+
+                                              "00 00 00 03 "+
+                                              "00 00 00 0A");
+        GetAsyncOutput builtByFactory = BufferHelper.decodeV13(GetAsyncReplyMessageFactory.getInstance(), bb);
+
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong packetInMask",createPacketInMask(), 
+                                                 builtByFactory.getPacketInMask());
+        Assert.assertEquals("Wrong portStatusMask",createPortStatusMask(), 
+                                                   builtByFactory.getPortStatusMask());
+        Assert.assertEquals("Wrong flowRemovedMask",createFlowRemovedMask(), 
+                                                    builtByFactory.getFlowRemovedMask());
+    }
+    
+    private static List<PacketInMask> createPacketInMask() {
+        List<PacketInMask> inMasks = new ArrayList<>();
+        PacketInMaskBuilder maskBuilder;
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        maskBuilder = new PacketInMaskBuilder();
+        List<PacketInReason> reasons = new ArrayList<>();
+        reasons.add(PacketInReason.OFPRACTION);
+        reasons.add(PacketInReason.OFPRINVALIDTTL);
+        maskBuilder.setMask(reasons);
+        inMasks.add(maskBuilder.build());
+        // OFPCR_ROLE_SLAVE
+        maskBuilder = new PacketInMaskBuilder();
+        reasons = new ArrayList<>();
+        reasons.add(PacketInReason.OFPRNOMATCH);
+        reasons.add(PacketInReason.OFPRINVALIDTTL);
+        maskBuilder.setMask(reasons);
+        inMasks.add(maskBuilder.build());
+        return inMasks;
+    }
+    
+    private static List<PortStatusMask> createPortStatusMask() {
+        List<PortStatusMask> inMasks = new ArrayList<>();
+        PortStatusMaskBuilder maskBuilder;
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        maskBuilder = new PortStatusMaskBuilder();
+        List<PortReason> reasons = new ArrayList<>();
+        reasons.add(PortReason.OFPPRADD);
+        reasons.add(PortReason.OFPPRDELETE);
+        reasons.add(PortReason.OFPPRMODIFY);
+        inMasks.add(maskBuilder.setMask(reasons).build());
+        // OFPCR_ROLE_SLAVE
+        maskBuilder = new PortStatusMaskBuilder();
+        reasons = new ArrayList<>();
+        maskBuilder.setMask(reasons);
+        inMasks.add(maskBuilder.build());
+        return inMasks;
+    }
+    
+    private static List<FlowRemovedMask> createFlowRemovedMask() {
+        List<FlowRemovedMask> inMasks = new ArrayList<>();
+        FlowRemovedMaskBuilder maskBuilder;
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        maskBuilder = new FlowRemovedMaskBuilder();
+        List<FlowRemovedReason> reasons = new ArrayList<>();
+        reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
+        reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
+        maskBuilder.setMask(reasons);
+        inMasks.add(maskBuilder.build());
+        // OFPCR_ROLE_SLAVE
+        maskBuilder = new FlowRemovedMaskBuilder();
+        reasons = new ArrayList<>();
+        reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
+        reasons.add(FlowRemovedReason.OFPRRGROUPDELETE);
+        maskBuilder.setMask(reasons);
+        inMasks.add(maskBuilder.build());
+        return inMasks;
+    }
+}
index 8a8717ddf85bd3dac3ca86c9e5ba4622ebfdda9a..3e39ecb742778aecf6b4bb37857f790de87fffa5 100644 (file)
@@ -1,31 +1,38 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class GetConfigReplyMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing {@link GetConfigReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03");\r
-        GetConfigOutput builtByFactory = BufferHelper.decodeV13(\r
-                GetConfigReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue()); \r
-        Assert.assertEquals("Wrong missSendLen", 0x03, builtByFactory.getMissSendLen().intValue());\r
-    }\r
-    \r
-}\r
+/*
+ * 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.GetConfigOutput;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class GetConfigReplyMessageFactoryTest {
+
+    /**
+     * 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);
+
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue()); 
+        Assert.assertEquals("Wrong missSendLen", 0x03, builtByFactory.getMissSendLen().intValue());
+    }
+    
+}
index b2433433328cdf06f4adbd5880170352cc1a9d18..0ab67a9ae871efd5cf5bcbd7648a4c5ae3d68c44 100644 (file)
@@ -1,64 +1,71 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class HelloMessageFactoryTest {\r
-\r
-    /** Number of currently supported version / codec */\r
-    public static final Short VERSION_YET_SUPPORTED = 0x04;\r
-\r
-    /**\r
-     * Testing {@link HelloMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 " // type\r
-                                            + "00 0c " // length\r
-                                            + "00 00 00 11 " // bitmap 1\r
-                                            + "00 00 00 00 " // bitmap 2\r
-                                            + "00 00 00 00"  // padding\r
-                );\r
-        HelloMessage builtByFactory = BufferHelper.decodeV13(\r
-                HelloMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        List<Elements> element = createElement();\r
-        Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType());\r
-        Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap());\r
-    }\r
-    \r
-    private static List<Elements> createElement() {\r
-        ElementsBuilder elementsBuilder = new ElementsBuilder();\r
-        List<Elements> elementsList = new ArrayList<>();\r
-        List<Boolean> booleanList = new ArrayList<>();\r
-        booleanList.add(true);\r
-        booleanList.add(false);\r
-        booleanList.add(false);\r
-        booleanList.add(false);\r
-        booleanList.add(true);\r
-        for (int i = 1; i < 60; i++) {\r
-            booleanList.add(false);\r
-        }\r
-        elementsBuilder.setType(HelloElementType.forValue(1));\r
-        elementsBuilder.setVersionBitmap(booleanList);\r
-        elementsList.add(elementsBuilder.build());\r
-        \r
-        return elementsList;\r
-    }\r
-}\r
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class HelloMessageFactoryTest {
+
+    /** Number of currently supported version / codec */
+    public static final Short VERSION_YET_SUPPORTED = 0x04;
+
+    /**
+     * Testing {@link HelloMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 " // type
+                                            + "00 0c " // length
+                                            + "00 00 00 11 " // bitmap 1
+                                            + "00 00 00 00 " // bitmap 2
+                                            + "00 00 00 00"  // padding
+                );
+        HelloMessage builtByFactory = BufferHelper.decodeV13(
+                HelloMessageFactory.getInstance(), bb);
+
+        BufferHelper.checkHeaderV13(builtByFactory);
+        List<Elements> element = createElement();
+        Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType());
+        Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap());
+    }
+    
+    private static List<Elements> createElement() {
+        ElementsBuilder elementsBuilder = new ElementsBuilder();
+        List<Elements> elementsList = new ArrayList<>();
+        List<Boolean> booleanList = new ArrayList<>();
+        booleanList.add(true);
+        booleanList.add(false);
+        booleanList.add(false);
+        booleanList.add(false);
+        booleanList.add(true);
+        for (int i = 1; i < 60; i++) {
+            booleanList.add(false);
+        }
+        elementsBuilder.setType(HelloElementType.forValue(1));
+        elementsBuilder.setVersionBitmap(booleanList);
+        elementsList.add(elementsBuilder.build());
+        
+        return elementsList;
+    }
+}
index 4bf030797cde68dd7c92f700aaf9a1939f1ab119..821da87ec2a899503be27fe5d7e43ead3aa3ec24 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.math.BigInteger;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\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.EthertypeAction;\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
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;\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.PortNumberMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;\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.OpenflowBasicClass;\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.meter.band.header.meter.band.MeterBandDrop;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemark;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregate;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlow;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroup;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTable;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class MultipartReplyMessageFactoryTest {\r
-\r
-    private static final Logger LOGGER = LoggerFactory\r
-            .getLogger(MultipartReplyMessageFactoryTest.class);\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     *//*\r
-    @Test\r
-    public void test(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 01 02 03 04");\r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        \r
-        Assert.assertEquals("Wrong type", 0x07, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        //Assert.assertArrayEquals("Wrong body", new byte[]{0x01, 0x02, 0x03, 0x04}, builtByFactory.getBody());\r
-    }*/\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyDescBody(){\r
-        final int DESC_STR_LEN = 256;\r
-        final int SERIAL_NUM_LEN = 32;\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00");\r
-        \r
-        String mfrDesc = "Manufacturer description";\r
-        byte[] mfrDescBytes = new byte[256];\r
-        mfrDescBytes = mfrDesc.getBytes();\r
-        bb.writeBytes(mfrDescBytes);\r
-        ByteBufUtils.padBuffer((DESC_STR_LEN - mfrDescBytes.length), bb);\r
-        \r
-        String hwDesc = "Hardware description";\r
-        byte[] hwDescBytes = new byte[256];\r
-        hwDescBytes = hwDesc.getBytes();\r
-        bb.writeBytes(hwDescBytes);\r
-        ByteBufUtils.padBuffer((DESC_STR_LEN - hwDescBytes.length), bb);\r
-        \r
-        String swDesc = "Software description";\r
-        byte[] swDescBytes = new byte[256];\r
-        swDescBytes = swDesc.getBytes();\r
-        bb.writeBytes(swDescBytes);\r
-        ByteBufUtils.padBuffer((DESC_STR_LEN - swDescBytes.length), bb);\r
-        \r
-        String serialNum = "SN0123456789";\r
-        byte[] serialNumBytes = new byte[32];\r
-        serialNumBytes = serialNum.getBytes();\r
-        bb.writeBytes(serialNumBytes);\r
-        ByteBufUtils.padBuffer((SERIAL_NUM_LEN - serialNumBytes.length), bb);\r
-        \r
-        String dpDesc = "switch3 in room 3120";\r
-        byte[] dpDescBytes = new byte[256];\r
-        dpDescBytes = dpDesc.getBytes();\r
-        bb.writeBytes(dpDescBytes);\r
-        ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb);\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        MultipartReplyDesc message = (MultipartReplyDesc) builtByFactory.getMultipartReplyBody();\r
-        Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc());\r
-        Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc());\r
-        Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc());\r
-        Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum());\r
-        Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyFlowBody(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+\r
-                                              "00 0C "+//length\r
-                                              "08 "+//tableId\r
-                                              "00 "+//pad_01\r
-                                              "00 00 00 09 "+//durationSec\r
-                                              "00 00 00 07 "+//durationNsec\r
-                                              "00 0C "+//priority\r
-                                              "00 0E "+//idleTimeout\r
-                                              "00 0F "+//hardTimeout\r
-                                              "00 0B "+//flags\r
-                                              "00 00 00 00 "+//pad_02\r
-                                              "00 01 01 01 01 01 01 01 "+//cookie\r
-                                              "00 01 01 01 01 01 01 01 "+//packetCount\r
-                                              "00 01 01 01 01 01 01 01"//byteCount\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        MultipartReplyFlow message = (MultipartReplyFlow) builtByFactory.getMultipartReplyBody();\r
-        Assert.assertEquals("Wrong tableId", 8, message.getFlowStats().get(0).getTableId().intValue());\r
-        Assert.assertEquals("Wrong durationSec", 9, message.getFlowStats().get(0).getDurationSec().intValue());\r
-        Assert.assertEquals("Wrong durationNsec", 7, message.getFlowStats().get(0).getDurationNsec().intValue());\r
-        Assert.assertEquals("Wrong priority", 12, message.getFlowStats().get(0).getPriority().intValue());\r
-        Assert.assertEquals("Wrong idleTimeOut", 14, message.getFlowStats().get(0).getIdleTimeout().intValue());\r
-        Assert.assertEquals("Wrong hardTimeOut", 15, message.getFlowStats().get(0).getHardTimeout().intValue());\r
-        Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true), \r
-                                           message.getFlowStats().get(0).getFlags());\r
-        Assert.assertEquals("Wrong cookie", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getFlowStats().get(0).getCookie());\r
-        Assert.assertEquals("Wrong packetCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getFlowStats().get(0).getPacketCount());\r
-        Assert.assertEquals("Wrong byteCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getFlowStats().get(0).getByteCount());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyAggregateBody(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 "+\r
-                                              "00 01 01 01 01 01 01 01 "+//packetCount\r
-                                              "00 01 01 01 01 01 01 01 "+//byteCount\r
-                                              "00 00 00 08 "+//flowCount\r
-                                              "00 00 00 00"//pad\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        MultipartReplyAggregate message = (MultipartReplyAggregate) builtByFactory.getMultipartReplyBody();\r
-        Assert.assertEquals("Wrong packetCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getPacketCount());\r
-        Assert.assertEquals("Wrong byteCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getByteCount());\r
-        Assert.assertEquals("Wrong flowCount", \r
-                8, \r
-                message.getFlowCount().intValue());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyTableBody(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 00 00 00 00 "+\r
-                                              "08 "+//tableId\r
-                                              "00 00 00 "+//pad\r
-                                              "00 00 00 10 "+//activeCount\r
-                                              "00 01 01 01 01 01 01 01 "+//lookupCount\r
-                                              "00 01 01 01 01 01 01 01"//matchedCount\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyTable message = (MultipartReplyTable) builtByFactory.getMultipartReplyBody();\r
-        Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());\r
-        Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());\r
-        Assert.assertEquals("Wrong lookupCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getTableStats().get(0).getLookupCount());\r
-        Assert.assertEquals("Wrong matchedCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getTableStats().get(0).getMatchedCount());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyPortStatsBody(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 "+\r
-                                              "00 00 00 FF "+//portNo\r
-                                              "00 00 00 00 "+//pad\r
-                                              "00 01 01 01 01 01 01 01 "+//rxPackets\r
-                                              "00 02 02 02 02 02 02 02 "+//txPackets\r
-                                              "00 02 03 02 03 02 03 02 "+//rxBytes\r
-                                              "00 02 03 02 03 02 03 02 "+//txBytes\r
-                                              "00 02 03 02 03 02 03 02 "+//rxDropped\r
-                                              "00 02 03 02 03 02 03 02 "+//txDropped\r
-                                              "00 02 03 02 03 02 03 02 "+//rxErrors\r
-                                              "00 02 03 02 03 02 03 02 "+//txErrors\r
-                                              "00 02 03 02 03 02 03 02 "+//rxFrameErr\r
-                                              "00 02 03 02 03 02 03 02 "+//rxOverErr\r
-                                              "00 02 03 02 03 02 03 02 "+//rxCrcErr\r
-                                              "00 02 03 02 03 02 03 02 "+//collisions\r
-                                              "00 00 00 02 "+//durationSec\r
-                                              "00 00 00 04"//durationNsec\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyPortStats message = (MultipartReplyPortStats) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue());\r
-        Assert.assertEquals("Wrong rxPackets", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getPortStats().get(0).getRxPackets());\r
-        Assert.assertEquals("Wrong txPackets", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getPortStats().get(0).getTxPackets());\r
-        Assert.assertEquals("Wrong rxBytes", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getPortStats().get(0).getRxBytes());\r
-        Assert.assertEquals("Wrong txBytes", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getPortStats().get(0).getTxBytes());\r
-        Assert.assertEquals("Wrong rxDropped", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getPortStats().get(0).getRxDropped());\r
-        Assert.assertEquals("Wrong txDropped", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getPortStats().get(0).getTxDropped());\r
-        Assert.assertEquals("Wrong rxErrors", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getPortStats().get(0).getRxErrors());\r
-        Assert.assertEquals("Wrong txErrors", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getPortStats().get(0).getTxErrors());\r
-        Assert.assertEquals("Wrong rxFrameErr", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getPortStats().get(0).getRxFrameErr());\r
-        Assert.assertEquals("Wrong rxOverErr", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getPortStats().get(0).getRxOverErr());\r
-        Assert.assertEquals("Wrong rxCrcErr", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getPortStats().get(0).getRxCrcErr());\r
-        Assert.assertEquals("Wrong collisions", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getPortStats().get(0).getCollisions());\r
-        Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue());\r
-        Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyQueueBody(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 "+\r
-                                              "00 00 00 FF "+//portNo\r
-                                              "00 00 00 10 "+//queueId\r
-                                              "00 02 03 02 03 02 03 02 "+//txBytes\r
-                                              "00 02 02 02 02 02 02 02 "+//txPackets\r
-                                              "00 02 03 02 03 02 03 02 "+//txErrors\r
-                                              "00 00 00 02 "+//durationSec\r
-                                              "00 00 00 04"//durationNsec\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyQueue message = (MultipartReplyQueue) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());\r
-        Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());\r
-        Assert.assertEquals("Wrong txBytes", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getQueueStats().get(0).getTxBytes());\r
-        Assert.assertEquals("Wrong txPackets", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getQueueStats().get(0).getTxPackets());\r
-        Assert.assertEquals("Wrong txErrors", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
-                message.getQueueStats().get(0).getTxErrors());\r
-        Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue());\r
-        Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyGroupBody(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 "+\r
-                                              "00 48 "+//length\r
-                                              "00 00 "+//pad1\r
-                                              "00 00 00 10 "+//groupId\r
-                                              "00 00 00 12 "+//refCount\r
-                                              "00 00 00 00 "+//pad2\r
-                                              "00 01 01 01 01 01 01 01 "+//packetCount\r
-                                              "00 01 01 01 01 01 01 01 "+//byteCount\r
-                                              "00 00 00 08 "+//durationSec\r
-                                              "00 00 00 09 "+//durationNsec\r
-                                              "00 01 01 01 01 01 01 01 "+//packetCountBucket\r
-                                              "00 01 01 01 01 01 01 01 "+//byteCountBucket\r
-                                              "00 02 02 02 02 02 02 02 "+//packetCountBucket_2\r
-                                              "00 02 02 02 02 02 02 02 "+//byteCountBucket_2\r
-                                              "00 48 "+//length_2\r
-                                              "00 00 "+//pad1.2\r
-                                              "00 00 00 10 "+//groupId_2\r
-                                              "00 00 00 12 "+//refCount_2\r
-                                              "00 00 00 00 "+//pad2.2\r
-                                              "00 01 01 01 01 01 01 01 "+//packetCount_2\r
-                                              "00 01 01 01 01 01 01 01 "+//byteCount_2\r
-                                              "00 00 00 08 "+//durationSec_2\r
-                                              "00 00 00 09 "+//durationNsec_2\r
-                                              "00 01 01 01 01 01 01 01 "+//packetCountBucket_1.2\r
-                                              "00 01 01 01 01 01 01 01 "+//byteCountBucket_1.2\r
-                                              "00 02 02 02 02 02 02 02 "+//packetCountBucket_2.2\r
-                                              "00 02 02 02 02 02 02 02"//byteCountBucket_2.2\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyGroup message = (MultipartReplyGroup) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());\r
-        Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());\r
-        Assert.assertEquals("Wrong packetCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getGroupStats().get(0).getPacketCount());\r
-        Assert.assertEquals("Wrong byteCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getGroupStats().get(0).getByteCount());\r
-        Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());\r
-        Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());\r
-        Assert.assertEquals("Wrong packetCountBucket", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());\r
-        Assert.assertEquals("Wrong byteCountBucket", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());\r
-        Assert.assertEquals("Wrong packetCountBucket_2", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());\r
-        Assert.assertEquals("Wrong byteCountBucket_2", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());\r
-        \r
-        Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());\r
-        Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());\r
-        Assert.assertEquals("Wrong packetCount_2", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getGroupStats().get(1).getPacketCount());\r
-        Assert.assertEquals("Wrong byteCount_2", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getGroupStats().get(1).getByteCount());\r
-        Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());\r
-        Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());\r
-        Assert.assertEquals("Wrong packetCountBucket_1.2", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());\r
-        Assert.assertEquals("Wrong byteCountBucket_1.2", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());\r
-        Assert.assertEquals("Wrong packetCountBucket_2.2", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());\r
-        Assert.assertEquals("Wrong byteCountBucket_2.2", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyMeterFeaturesBody(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+\r
-                                              "00 00 00 09 "+//maxMeter\r
-                                              "00 00 00 01 "+//bandTypes\r
-                                              "00 00 00 03 "+//capabilities\r
-                                              "03 "+//maxBands\r
-                                              "04 "+//maxColor\r
-                                              "00 00"//pad\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyMeterFeatures message = (MultipartReplyMeterFeatures) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue());\r
-        Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, false), message.getBandTypes());\r
-        Assert.assertEquals("Wrong capabilities", new MeterFlags(false, true, true, false), \r
-                                                      message.getCapabilities());\r
-        Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue());\r
-        Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyMeterBody(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+\r
-                                              "00 00 00 09 "+//meterId\r
-                                              "00 58 "+//len\r
-                                              "00 00 00 00 00 00 "+//pad\r
-                                              "00 00 00 07 "+//flowCount\r
-                                              "00 01 01 01 01 01 01 01 "+//packetInCount\r
-                                              "00 01 01 01 01 01 01 01 "+//byteInCount\r
-                                              "00 00 00 05 "+//durationSec\r
-                                              "00 00 00 05 "+//durationNsec\r
-                                              "00 01 01 01 01 01 01 01 "+//packetBandCount_01\r
-                                              "00 01 01 01 01 01 01 01 "+//byteBandCount_01\r
-                                              "00 02 02 02 02 02 02 02 "+//packetBandCount_02\r
-                                              "00 02 02 02 02 02 02 02 "+//byteBandCount_02\r
-                                              "00 03 03 03 03 03 03 03 "+//packetBandCount_03\r
-                                              "00 03 03 03 03 03 03 03"//byteBandCount_03\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyMeter message = (MultipartReplyMeter) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong meterId", 9, \r
-                             message.getMeterStats().get(0).getMeterId().getValue().intValue());\r
-        Assert.assertEquals("Wrong flowCount", 7, \r
-                            message.getMeterStats().get(0).getFlowCount().intValue());\r
-        Assert.assertEquals("Wrong packetInCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(0).getPacketInCount());\r
-        Assert.assertEquals("Wrong byteInCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(0).getByteInCount());\r
-        Assert.assertEquals("Wrong durationSec", 5, \r
-                message.getMeterStats().get(0).getDurationSec().intValue());\r
-        Assert.assertEquals("Wrong durationNsec", 5, \r
-                message.getMeterStats().get(0).getDurationNsec().intValue());\r
-        Assert.assertEquals("Wrong packetBandCount_01", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());\r
-        Assert.assertEquals("Wrong byteBandCount_01", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());\r
-        Assert.assertEquals("Wrong packetBandCount_02", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());\r
-        Assert.assertEquals("Wrong byteBandCount_02", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());\r
-        Assert.assertEquals("Wrong packetBandCount_03", \r
-                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());\r
-        Assert.assertEquals("Wrong byteBandCount_03", \r
-                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyMeterBodyMulti(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+\r
-                                              "00 00 00 09 "+//meterId_0\r
-                                              "00 58 "+//len_0\r
-                                              "00 00 00 00 00 00 "+//pad_0\r
-                                              "00 00 00 07 "+//flowCount_0\r
-                                              "00 01 01 01 01 01 01 01 "+//packetInCount_0\r
-                                              "00 01 01 01 01 01 01 01 "+//byteInCount_0\r
-                                              "00 00 00 05 "+//durationSec_0\r
-                                              "00 00 00 05 "+//durationNsec_0\r
-                                              "00 01 01 01 01 01 01 01 "+//packetBandCount_01\r
-                                              "00 01 01 01 01 01 01 01 "+//byteBandCount_01\r
-                                              "00 02 02 02 02 02 02 02 "+//packetBandCount_02\r
-                                              "00 02 02 02 02 02 02 02 "+//byteBandCount_02\r
-                                              "00 03 03 03 03 03 03 03 "+//packetBandCount_03\r
-                                              "00 03 03 03 03 03 03 03 "+//byteBandCount_03\r
-                                              "00 00 00 08 "+//meterId_1\r
-                                              "00 58 "+//len_1\r
-                                              "00 00 00 00 00 00 "+//pad_1\r
-                                              "00 00 00 07 "+//flowCount_1\r
-                                              "00 01 01 01 01 01 01 01 "+//packetInCount_1\r
-                                              "00 01 01 01 01 01 01 01 "+//byteInCount_1\r
-                                              "00 00 00 05 "+//durationSec_1\r
-                                              "00 00 00 05 "+//durationNsec_1\r
-                                              "00 01 01 01 01 01 01 01 "+//packetBandCount_11\r
-                                              "00 01 01 01 01 01 01 01 "+//byteBandCount_11\r
-                                              "00 02 02 02 02 02 02 02 "+//packetBandCount_12\r
-                                              "00 02 02 02 02 02 02 02 "+//byteBandCount_12\r
-                                              "00 03 03 03 03 03 03 03 "+//packetBandCount_13\r
-                                              "00 03 03 03 03 03 03 03"//byteBandCount_13\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyMeter message = (MultipartReplyMeter) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong meterId", 9, \r
-                             message.getMeterStats().get(0).getMeterId().getValue().intValue());\r
-        Assert.assertEquals("Wrong flowCount", 7, \r
-                            message.getMeterStats().get(0).getFlowCount().intValue());\r
-        Assert.assertEquals("Wrong packetInCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(0).getPacketInCount());\r
-        Assert.assertEquals("Wrong byteInCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(0).getByteInCount());\r
-        Assert.assertEquals("Wrong durationSec", 5, \r
-                message.getMeterStats().get(0).getDurationSec().intValue());\r
-        Assert.assertEquals("Wrong durationNsec", 5, \r
-                message.getMeterStats().get(0).getDurationNsec().intValue());\r
-        Assert.assertEquals("Wrong packetBandCount_01", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());\r
-        Assert.assertEquals("Wrong byteBandCount_01", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());\r
-        Assert.assertEquals("Wrong packetBandCount_02", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());\r
-        Assert.assertEquals("Wrong byteBandCount_02", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());\r
-        Assert.assertEquals("Wrong packetBandCount_03", \r
-                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());\r
-        Assert.assertEquals("Wrong byteBandCount_03", \r
-                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
-                message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());\r
-        \r
-        Assert.assertEquals("Wrong meterId", 8, \r
-                message.getMeterStats().get(1).getMeterId().getValue().intValue());\r
-        Assert.assertEquals("Wrong flowCount", 7, \r
-                message.getMeterStats().get(1).getFlowCount().intValue());\r
-        Assert.assertEquals("Wrong packetInCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(1).getPacketInCount());\r
-        Assert.assertEquals("Wrong byteInCount", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(1).getByteInCount());\r
-        Assert.assertEquals("Wrong durationSec", 5, \r
-                message.getMeterStats().get(1).getDurationSec().intValue());\r
-        Assert.assertEquals("Wrong durationNsec", 5, \r
-                message.getMeterStats().get(1).getDurationNsec().intValue());\r
-        Assert.assertEquals("Wrong packetBandCount_01", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(1).getMeterBandStats().get(0).getPacketBandCount());\r
-        Assert.assertEquals("Wrong byteBandCount_01", \r
-                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
-                message.getMeterStats().get(1).getMeterBandStats().get(0).getByteBandCount());\r
-        Assert.assertEquals("Wrong packetBandCount_02", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getMeterStats().get(1).getMeterBandStats().get(1).getPacketBandCount());\r
-        Assert.assertEquals("Wrong byteBandCount_02", \r
-                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
-                message.getMeterStats().get(1).getMeterBandStats().get(1).getByteBandCount());\r
-        Assert.assertEquals("Wrong packetBandCount_03", \r
-                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
-                message.getMeterStats().get(1).getMeterBandStats().get(2).getPacketBandCount());\r
-        Assert.assertEquals("Wrong byteBandCount_03", \r
-                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
-                message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyMeterConfigBody(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+\r
-                                              "00 38 "+//len\r
-                                              "00 0A "+//flags\r
-                                              "00 00 00 09 "+//meterId\r
-                                              "00 01 "+//meterBandDrop.type\r
-                                              "00 10 "+//meterBandDrop.len\r
-                                              "00 00 00 11 "+//meterBandDrop.rate\r
-                                              "00 00 00 20 "+//meterBandDrop.burstSize\r
-                                              "00 00 00 00 "+//meterBandDrop.pad\r
-                                              "00 02 "+//meterBandDscp.type\r
-                                              "00 10 "+//meterBandDscp.len\r
-                                              "00 00 00 11 "+//meterBandDscp.rate\r
-                                              "00 00 00 20 "+//meterBandDscp.burstSize\r
-                                              "04 "+//meterBandDscp.precLevel\r
-                                              "00 00 00 "+//meterBandDscp.pad\r
-                                              "FF FF "+//meterBandExperimenter.type\r
-                                              "00 10 "+//meterBandExperimenter.len\r
-                                              "00 00 00 11 "+//meterBandExperimenter.rate\r
-                                              "00 00 00 20 "+//meterBandExperimenter.burstSize\r
-                                              "00 00 00 04"//meterBandExperimenter.experimenter\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyMeterConfig message = (MultipartReplyMeterConfig) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true),\r
-                             message.getMeterConfig().get(0).getFlags());\r
-        Assert.assertEquals("Wrong meterId", 9, \r
-                             message.getMeterConfig().get(0).getMeterId().getValue().intValue());\r
-        \r
-        MeterBandDrop meterBandDrop = (MeterBandDrop) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); \r
-        Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); \r
-        Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());\r
-        Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());\r
-        \r
-        MeterBandDscpRemark meterBandDscp = (MeterBandDscpRemark) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); \r
-        Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); \r
-        Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());\r
-        Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());\r
-        Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());\r
-        \r
-        MeterBandExperimenter meterBandExperimenter = (MeterBandExperimenter) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); \r
-        Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue()); \r
-        Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue());\r
-        Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue());\r
-        Assert.assertEquals("Wrong meterBandExperimenter.experimenter", 4, meterBandExperimenter.getExperimenter().intValue());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyMeterConfigBodyMulti(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+\r
-                                              "00 38 "+//len\r
-                                              "00 06 "+//flags\r
-                                              "00 00 00 09 "+//meterId\r
-                                              "00 01 "+//meterBandDrop.type\r
-                                              "00 10 "+//meterBandDrop.len\r
-                                              "00 00 00 11 "+//meterBandDrop.rate\r
-                                              "00 00 00 20 "+//meterBandDrop.burstSize\r
-                                              "00 00 00 00 "+//meterBandDrop.pad\r
-                                              "00 02 "+//meterBandDscp.type\r
-                                              "00 10 "+//meterBandDscp.len\r
-                                              "00 00 00 11 "+//meterBandDscp.rate\r
-                                              "00 00 00 20 "+//meterBandDscp.burstSize\r
-                                              "04 "+//meterBandDscp.precLevel\r
-                                              "00 00 00 "+//meterBandDscp.pad\r
-                                              "FF FF "+//meterBandExperimenter.type\r
-                                              "00 10 "+//meterBandExperimenter.len\r
-                                              "00 00 00 11 "+//meterBandExperimenter.rate\r
-                                              "00 00 00 20 "+//meterBandExperimenter.burstSize\r
-                                              "00 00 00 04 "+//meterBandExperimenter.experimenter\r
-                                              \r
-                                              "00 18 "+//len01\r
-                                              "00 03 "+//flags01\r
-                                              "00 00 00 07 "+//meterId01\r
-                                              "00 02 "+//meterBandDscp01.type\r
-                                              "00 10 "+//meterBandDscp01.len\r
-                                              "00 00 00 11 "+//meterBandDscp01.rate\r
-                                              "00 00 00 20 "+//meterBandDscp01.burstSize\r
-                                              "04 "+//meterBandDscp01.precLevel\r
-                                              "00 00 00"//meterBandDscp01.pad\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyMeterConfig message = (MultipartReplyMeterConfig) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false), \r
-                             message.getMeterConfig().get(0).getFlags());\r
-        Assert.assertEquals("Wrong meterId", 9, \r
-                             message.getMeterConfig().get(0).getMeterId().getValue().intValue());\r
-        \r
-        MeterBandDrop meterBandDrop = (MeterBandDrop) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); \r
-        Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); \r
-        Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());\r
-        Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());\r
-        \r
-        MeterBandDscpRemark meterBandDscp = (MeterBandDscpRemark) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); \r
-        Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); \r
-        Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());\r
-        Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());\r
-        Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());\r
-        \r
-        MeterBandExperimenter meterBandExperimenter = (MeterBandExperimenter) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); \r
-        Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue()); \r
-        Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue());\r
-        Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue());\r
-        Assert.assertEquals("Wrong meterBandExperimenter.experimenter", 4, meterBandExperimenter.getExperimenter().intValue());\r
-        \r
-        LOGGER.info(message.getMeterConfig().get(0).getFlags().toString());\r
-        Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false),\r
-                             message.getMeterConfig().get(1).getFlags());\r
-        Assert.assertEquals("Wrong meterId01", 7, \r
-                             message.getMeterConfig().get(1).getMeterId().getValue().intValue());\r
-        \r
-        MeterBandDscpRemark meterBandDscp01 = (MeterBandDscpRemark) message.getMeterConfig().get(1).getBands().get(0).getMeterBand(); \r
-        Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue()); \r
-        Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue());\r
-        Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue());\r
-        Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue());\r
-        \r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyExperimenterBody(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "+\r
-                                              "00 00 00 0F "+//experimenterId\r
-                                              "00 00 00 FF "+//expType\r
-                                              "00 00 01 01 00 00 01 01"\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 0xFFFF, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyExperimenter message = (MultipartReplyExperimenter) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong experimenterId", 15, message.getExperimenter().intValue());\r
-        Assert.assertEquals("Wrong expType", 255, message.getExpType().intValue());\r
-        Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01}, \r
-                             message.getData());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testMultipartReplyPortDescBody(){\r
-        final byte MAX_PORT_NAME_LEN = 16;\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 01 00 00 00 00 "+\r
-                                              "00 01 02 03 "+ //portNo\r
-                                              "00 00 00 00 "+ //padding01\r
-                                              "08 00 27 00 B0 EB " + //mac address\r
-                                              "00 00 "); //padding02\r
-        //port name\r
-        String portName = "SampleText";\r
-        byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN];\r
-        portNameBytes = portName.getBytes();\r
-        bb.writeBytes(portNameBytes);\r
-        ByteBufUtils.padBuffer((MAX_PORT_NAME_LEN - portNameBytes.length), bb);\r
-        \r
-        ByteBuf bb2 =  BufferHelper.buildBuffer("00 00 00 41 " + //port config\r
-                                                "00 00 00 05 " + //port state\r
-                                                "00 00 00 81 " + //current features\r
-                                                "00 00 00 81 " + //advertised features\r
-                                                "00 00 00 81 " + //supported features\r
-                                                "00 00 00 81 " + //peer features\r
-                                                "00 00 00 81 " + //curr speed\r
-                                                "00 00 00 80" //max speed\r
-                                                );\r
-        bb.writeBytes(bb2.copy(4, bb2.readableBytes()-4));//excluding version and xid\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyPortDesc message = (MultipartReplyPortDesc) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong portNo", 66051L, message.getPorts().get(0).getPortNo().longValue());\r
-        Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), \r
-                                                message.getPorts().get(0).getHwAddr());\r
-        Assert.assertEquals("Wrong portName", "SampleText", \r
-                                                message.getPorts().get(0).getName());\r
-        Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), \r
-                message.getPorts().get(0).getConfig());\r
-        Assert.assertEquals("Wrong portState", new PortState(false, true, true),\r
-                                               message.getPorts().get(0).getState());\r
-        Assert.assertEquals("Wrong currentFeatures", new PortFeatures(true, false, false, false,\r
-                                                                      false, false, false, true, \r
-                                                                      false, false, false, false, \r
-                                                                      false, false, false, false), \r
-                                                  message.getPorts().get(0).getCurrentFeatures());\r
-        Assert.assertEquals("Wrong advertisedFeatures", \r
-                             new PortFeatures(true, false, false, false,\r
-                                              false, false, false, true, \r
-                                              false, false, false, false, \r
-                                              false, false, false, false), \r
-                                              message.getPorts().get(0).getAdvertisedFeatures());\r
-        Assert.assertEquals("Wrong supportedFeatures", \r
-                             new PortFeatures(true, false, false, false,\r
-                                              false, false, false, true, \r
-                                              false, false, false, false, \r
-                                              false, false, false, false), \r
-                                              message.getPorts().get(0).getSupportedFeatures());\r
-        Assert.assertEquals("Wrong peerFeatures", \r
-                             new PortFeatures(true, false, false, false,\r
-                                              false, false, false, true, \r
-                                              false, false, false, false, \r
-                                              false, false, false, false), \r
-                                              message.getPorts().get(0).getPeerFeatures());\r
-        Assert.assertEquals("Wrong currSpeed", 129L, message.getPorts().get(0).getCurrSpeed().longValue());\r
-        Assert.assertEquals("Wrong maxSpeed", 128L, message.getPorts().get(0).getMaxSpeed().longValue());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     * Test covers bodies of actions Output, Copy TTL Out, Copy TTL In\r
-     */\r
-    @Test\r
-    public void testMultipartReplyGroupDescBody01(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+\r
-                                              "00 38 "+//len\r
-                                              "01 "+//type\r
-                                              "00 "+//pad\r
-                                              "00 00 00 08 "+//groupId\r
-                                              "00 30 "+//bucketLen\r
-                                              "00 06 "+//bucketWeight\r
-                                              "00 00 00 05 "+//bucketWatchPort\r
-                                              "00 00 00 04 "+//bucketWatchGroup\r
-                                              "00 00 00 00 "+//bucketPad\r
-                                              "00 00 "+//outputType\r
-                                              "00 10 "+//outputLen\r
-                                              "00 00 10 FF "+//outputPort\r
-                                              "FF FF "+//outputMaxLen\r
-                                              "00 00 00 00 00 00 "+//outputPad\r
-                                              "00 0B "+//copyTTLOutType\r
-                                              "00 08 "+//copyTTLOutLen\r
-                                              "00 00 00 00 "+//copyTTLOutPad\r
-                                              "00 0C "+//copyTTLIntType\r
-                                              "00 08 "+//copyTTLIntLen\r
-                                              "00 00 00 00"//copyTTLInPad\r
-                                              );\r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong type", 1, \r
-                             message.getGroupDesc().get(0).getType().getIntValue());\r
-        Assert.assertEquals("Wrong groupId", 8, \r
-                             message.getGroupDesc().get(0).getGroupId().getValue().intValue());\r
-        Assert.assertEquals("Wrong bucketWeight", 6, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());\r
-        Assert.assertEquals("Wrong bucketWatchPort", 5, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().\r
-                                                                        getValue().intValue());\r
-        Assert.assertEquals("Wrong bucketWatchGroup", 4, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());\r
-        \r
-        Assert.assertEquals("Wrong outputType", Output.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong outputPort", 4351, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
-                getAction().getAugmentation(PortAction.class).\r
-                getPort().getValue().intValue());\r
-        \r
-        Assert.assertEquals("Wrong outputMaxLen", 65535, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
-                getAction().getAugmentation(MaxLengthAction.class).\r
-                getMaxLength().intValue());\r
-        \r
-        Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).\r
-                getAction().getType());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     * Test covers bodies of actions Set MPLS TTL , Dec MPLS TTL, Push VLAN. Push MPLS, Push PBB\r
-     */\r
-    @Test\r
-    public void testMultipartReplyGroupDescBody02(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+\r
-                                              "00 40 "+//len\r
-                                              "01 "+//type\r
-                                              "00 "+//pad\r
-                                              "00 00 00 08 "+//groupId\r
-                                              "00 38 "+//bucketLen\r
-                                              "00 06 "+//bucketWeight\r
-                                              "00 00 00 05 "+//bucketWatchPort\r
-                                              "00 00 00 04 "+//bucketWatchGroup\r
-                                              "00 00 00 00 "+//bucketPad\r
-                                              "00 0F "+//setMplsTtlType\r
-                                              "00 08 "+//setMplsTtlLen\r
-                                              "09 "+//setMplsTtlMPLS_TTL\r
-                                              "00 00 00 "+//setMplsTtlPad\r
-                                              "00 10 "+//decMplsTtlType\r
-                                              "00 08 "+//decMplsTtlLen\r
-                                              "00 00 00 00 "+//decMplsTtlPad\r
-                                              "00 11 "+//pushVlanType\r
-                                              "00 08 "+//pushVlanLen\r
-                                              "00 20 "+//pushVlanEthertype\r
-                                              "00 00 "+//pushVlanPad\r
-                                              "00 13 "+//pushMplsType\r
-                                              "00 08 "+//pushMplsLen\r
-                                              "00 FF "+//pushMplsEthertype\r
-                                              "00 00 "+//pushMplsPad\r
-                                              "00 1A "+//pushPbbType\r
-                                              "00 08 "+//pushPbbLen\r
-                                              "0F FF "+//pushPbbEthertype\r
-                                              "00 00"//pushPbbPad\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong type", 1, \r
-                             message.getGroupDesc().get(0).getType().getIntValue());\r
-        Assert.assertEquals("Wrong groupId", 8, \r
-                             message.getGroupDesc().get(0).getGroupId().getValue().intValue());\r
-        Assert.assertEquals("Wrong bucketWeight", 6, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());\r
-        Assert.assertEquals("Wrong bucketWatchPort", 5, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().\r
-                                                                        getValue().intValue());\r
-        Assert.assertEquals("Wrong bucketWatchGroup", 4, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());\r
-        \r
-        \r
-        Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
-                getAction().getAugmentation(MplsTtlAction.class).\r
-                getMplsTtl().intValue());\r
-        \r
-        Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong pushVlanType", PushVlan.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong pushVlanEthertype", 32, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).\r
-                getAction().getAugmentation(EthertypeAction.class).\r
-                getEthertype().getValue().intValue());\r
-        \r
-        Assert.assertEquals("Wrong pushMplsType", PushMpls.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong pushMplsEthertype", 255, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).\r
-                getAction().getAugmentation(EthertypeAction.class).\r
-                getEthertype().getValue().intValue());\r
-        \r
-        Assert.assertEquals("Wrong pushPbbType", PushPbb.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong pushPbbEthertype", 4095, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).\r
-                getAction().getAugmentation(EthertypeAction.class).\r
-                getEthertype().getValue().intValue());\r
-        \r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     * Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL\r
-     */\r
-    @Test\r
-    public void testMultipartReplyGroupDescBody03(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+\r
-                                              "00 48 "+//len\r
-                                              "01 "+//type\r
-                                              "00 "+//pad\r
-                                              "00 00 00 08 "+//groupId\r
-                                              "00 40 "+//bucketLen\r
-                                              "00 06 "+//bucketWeight\r
-                                              "00 00 00 05 "+//bucketWatchPort\r
-                                              "00 00 00 04 "+//bucketWatchGroup\r
-                                              "00 00 00 00 "+//bucketPad\r
-                                              "00 12 "+//popVlanType\r
-                                              "00 08 "+//popVlanLen\r
-                                              "00 00 00 00 "+//popVlanPad\r
-                                              "00 1B "+//popPbbType\r
-                                              "00 08 "+//popPbbLen\r
-                                              "00 00 00 00 "+//popPbbPad\r
-                                              "00 14 "+//popMplsType\r
-                                              "00 08 "+//popMplsLen\r
-                                              "00 CF "+//popMplsEthertype\r
-                                              "00 00 "+//popMplsPad\r
-                                              "00 15 "+//setQueueType\r
-                                              "00 08 "+//setQueueLen\r
-                                              "00 CF 00 00 "+//setQueueQueueId\r
-                                              "00 16 "+//groupType\r
-                                              "00 08 "+//groupLen\r
-                                              "00 CF 00 00 "+//groupGroupId\r
-                                              "00 18 "+//decNwTtlType\r
-                                              "00 08 "+//decNwTtlLen\r
-                                              "00 00 00 00"//decNwTtlPad\r
-                                              );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong type", 1, \r
-                             message.getGroupDesc().get(0).getType().getIntValue());\r
-        Assert.assertEquals("Wrong groupId", 8, \r
-                             message.getGroupDesc().get(0).getGroupId().getValue().intValue());\r
-        Assert.assertEquals("Wrong bucketWeight", 6, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());\r
-        Assert.assertEquals("Wrong bucketWatchPort", 5, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().\r
-                                                                        getValue().intValue());\r
-        Assert.assertEquals("Wrong bucketWatchGroup", 4, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());\r
-        \r
-        Assert.assertEquals("Wrong popVlanType", PopVlan.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong popPbbType", PopPbb.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong popMplsType", PopMpls.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong popMplsEthertype", 207, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).\r
-                getAction().getAugmentation(EthertypeAction.class).\r
-                getEthertype().getValue().intValue());\r
-        \r
-        Assert.assertEquals("Wrong setQueueType", SetQueue.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong setQueueQueueId", 13565952, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).\r
-                getAction().getAugmentation(QueueIdAction.class).\r
-                getQueueId().intValue());\r
-        \r
-        Assert.assertEquals("Wrong groupType", Group.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong groupGroupId", 13565952, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).\r
-                getAction().getAugmentation(GroupIdAction.class).\r
-                getGroupId().intValue());\r
-        \r
-        Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(5).\r
-                getAction().getType());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
-     * Test covers bodies of actions NW TTL, Experimenter\r
-     */\r
-    @Test\r
-    public void testMultipartReplyGroupDescBody04(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+\r
-                                              "00 30 "+//len\r
-                                              "01 "+//type\r
-                                              "00 "+//pad\r
-                                              "00 00 00 08 "+//groupId\r
-                                              "00 28 "+//bucketLen\r
-                                              "00 06 "+//bucketWeight\r
-                                              "00 00 00 05 "+//bucketWatchPort\r
-                                              "00 00 00 04 "+//bucketWatchGroup\r
-                                              "00 00 00 00 "+//bucketPad\r
-                                              "00 17 "+//nwTTlType\r
-                                              "00 08 "+//nwTTlLen\r
-                                              "0E "+//nwTTlnwTTL\r
-                                              "00 00 00 "+//nwTTlPad\r
-                                              "00 19 "+//setFieldType\r
-                                              "00 10 "+//setFieldLen\r
-                                              "80 00 "+//setFieldOXMClass\r
-                                              "00 "+//setFieldOXMField\r
-                                              "04 "+//setFieldOXMLength\r
-                                              "00 00 00 FF "+ //setFieldPort\r
-                                              "00 00 00 00"\r
-                );\r
-        \r
-        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());\r
-        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
-        \r
-        MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();\r
-        \r
-        Assert.assertEquals("Wrong type", 1, \r
-                             message.getGroupDesc().get(0).getType().getIntValue());\r
-        Assert.assertEquals("Wrong groupId", 8, \r
-                             message.getGroupDesc().get(0).getGroupId().getValue().intValue());\r
-        Assert.assertEquals("Wrong bucketWeight", 6, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());\r
-        Assert.assertEquals("Wrong bucketWatchPort", 5, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().\r
-                                                                        getValue().intValue());\r
-        Assert.assertEquals("Wrong bucketWatchGroup", 4, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());\r
-        \r
-        Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong nwTTlnwTTL", 14, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
-                getAction().getAugmentation(NwTtlAction.class).getNwTtl().intValue());\r
-        \r
-        Assert.assertEquals("Wrong setFieldType", SetField.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
-                getAction().getType());\r
-        \r
-        Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
-                getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmClass());\r
-        \r
-        Assert.assertEquals("Wrong setFieldOXMField", InPort.class, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
-                getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField());\r
-        \r
-        Assert.assertEquals("Wrong setFieldOXMValue", 255, \r
-                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
-                getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).\r
-                getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
-    }\r
-}\r
+/*
+ * 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 java.math.BigInteger;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
+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.PopMpls;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
+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.MeterBandTypeBitmap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDrop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemark;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class MultipartReplyMessageFactoryTest {
+
+    private static final Logger LOGGER = LoggerFactory
+            .getLogger(MultipartReplyMessageFactoryTest.class);
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     *//*
+    @Test
+    public void test(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 01 02 03 04");
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        
+        Assert.assertEquals("Wrong type", 0x07, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        //Assert.assertArrayEquals("Wrong body", new byte[]{0x01, 0x02, 0x03, 0x04}, builtByFactory.getBody());
+    }*/
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyDescBody(){
+        final int DESC_STR_LEN = 256;
+        final int SERIAL_NUM_LEN = 32;
+        ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00");
+        
+        String mfrDesc = "Manufacturer description";
+        byte[] mfrDescBytes = new byte[256];
+        mfrDescBytes = mfrDesc.getBytes();
+        bb.writeBytes(mfrDescBytes);
+        ByteBufUtils.padBuffer((DESC_STR_LEN - mfrDescBytes.length), bb);
+        
+        String hwDesc = "Hardware description";
+        byte[] hwDescBytes = new byte[256];
+        hwDescBytes = hwDesc.getBytes();
+        bb.writeBytes(hwDescBytes);
+        ByteBufUtils.padBuffer((DESC_STR_LEN - hwDescBytes.length), bb);
+        
+        String swDesc = "Software description";
+        byte[] swDescBytes = new byte[256];
+        swDescBytes = swDesc.getBytes();
+        bb.writeBytes(swDescBytes);
+        ByteBufUtils.padBuffer((DESC_STR_LEN - swDescBytes.length), bb);
+        
+        String serialNum = "SN0123456789";
+        byte[] serialNumBytes = new byte[32];
+        serialNumBytes = serialNum.getBytes();
+        bb.writeBytes(serialNumBytes);
+        ByteBufUtils.padBuffer((SERIAL_NUM_LEN - serialNumBytes.length), bb);
+        
+        String dpDesc = "switch3 in room 3120";
+        byte[] dpDescBytes = new byte[256];
+        dpDescBytes = dpDesc.getBytes();
+        bb.writeBytes(dpDescBytes);
+        ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb);
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        MultipartReplyDesc message = (MultipartReplyDesc) builtByFactory.getMultipartReplyBody();
+        Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc());
+        Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc());
+        Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc());
+        Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum());
+        Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyFlowBody(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+
+                                              "00 0C "+//length
+                                              "08 "+//tableId
+                                              "00 "+//pad_01
+                                              "00 00 00 09 "+//durationSec
+                                              "00 00 00 07 "+//durationNsec
+                                              "00 0C "+//priority
+                                              "00 0E "+//idleTimeout
+                                              "00 0F "+//hardTimeout
+                                              "00 0B "+//flags
+                                              "00 00 00 00 "+//pad_02
+                                              "00 01 01 01 01 01 01 01 "+//cookie
+                                              "00 01 01 01 01 01 01 01 "+//packetCount
+                                              "00 01 01 01 01 01 01 01"//byteCount
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        MultipartReplyFlow message = (MultipartReplyFlow) builtByFactory.getMultipartReplyBody();
+        Assert.assertEquals("Wrong tableId", 8, message.getFlowStats().get(0).getTableId().intValue());
+        Assert.assertEquals("Wrong durationSec", 9, message.getFlowStats().get(0).getDurationSec().intValue());
+        Assert.assertEquals("Wrong durationNsec", 7, message.getFlowStats().get(0).getDurationNsec().intValue());
+        Assert.assertEquals("Wrong priority", 12, message.getFlowStats().get(0).getPriority().intValue());
+        Assert.assertEquals("Wrong idleTimeOut", 14, message.getFlowStats().get(0).getIdleTimeout().intValue());
+        Assert.assertEquals("Wrong hardTimeOut", 15, message.getFlowStats().get(0).getHardTimeout().intValue());
+        Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true), 
+                                           message.getFlowStats().get(0).getFlags());
+        Assert.assertEquals("Wrong cookie", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getFlowStats().get(0).getCookie());
+        Assert.assertEquals("Wrong packetCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getFlowStats().get(0).getPacketCount());
+        Assert.assertEquals("Wrong byteCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getFlowStats().get(0).getByteCount());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyAggregateBody(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 "+
+                                              "00 01 01 01 01 01 01 01 "+//packetCount
+                                              "00 01 01 01 01 01 01 01 "+//byteCount
+                                              "00 00 00 08 "+//flowCount
+                                              "00 00 00 00"//pad
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        MultipartReplyAggregate message = (MultipartReplyAggregate) builtByFactory.getMultipartReplyBody();
+        Assert.assertEquals("Wrong packetCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getPacketCount());
+        Assert.assertEquals("Wrong byteCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getByteCount());
+        Assert.assertEquals("Wrong flowCount", 
+                8, 
+                message.getFlowCount().intValue());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyTableBody(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 00 00 00 00 "+
+                                              "08 "+//tableId
+                                              "00 00 00 "+//pad
+                                              "00 00 00 10 "+//activeCount
+                                              "00 01 01 01 01 01 01 01 "+//lookupCount
+                                              "00 01 01 01 01 01 01 01"//matchedCount
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyTable message = (MultipartReplyTable) builtByFactory.getMultipartReplyBody();
+        Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());
+        Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());
+        Assert.assertEquals("Wrong lookupCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getTableStats().get(0).getLookupCount());
+        Assert.assertEquals("Wrong matchedCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getTableStats().get(0).getMatchedCount());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyPortStatsBody(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 "+
+                                              "00 00 00 FF "+//portNo
+                                              "00 00 00 00 "+//pad
+                                              "00 01 01 01 01 01 01 01 "+//rxPackets
+                                              "00 02 02 02 02 02 02 02 "+//txPackets
+                                              "00 02 03 02 03 02 03 02 "+//rxBytes
+                                              "00 02 03 02 03 02 03 02 "+//txBytes
+                                              "00 02 03 02 03 02 03 02 "+//rxDropped
+                                              "00 02 03 02 03 02 03 02 "+//txDropped
+                                              "00 02 03 02 03 02 03 02 "+//rxErrors
+                                              "00 02 03 02 03 02 03 02 "+//txErrors
+                                              "00 02 03 02 03 02 03 02 "+//rxFrameErr
+                                              "00 02 03 02 03 02 03 02 "+//rxOverErr
+                                              "00 02 03 02 03 02 03 02 "+//rxCrcErr
+                                              "00 02 03 02 03 02 03 02 "+//collisions
+                                              "00 00 00 02 "+//durationSec
+                                              "00 00 00 04"//durationNsec
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyPortStats message = (MultipartReplyPortStats) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue());
+        Assert.assertEquals("Wrong rxPackets", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getPortStats().get(0).getRxPackets());
+        Assert.assertEquals("Wrong txPackets", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getPortStats().get(0).getTxPackets());
+        Assert.assertEquals("Wrong rxBytes", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getPortStats().get(0).getRxBytes());
+        Assert.assertEquals("Wrong txBytes", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getPortStats().get(0).getTxBytes());
+        Assert.assertEquals("Wrong rxDropped", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getPortStats().get(0).getRxDropped());
+        Assert.assertEquals("Wrong txDropped", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getPortStats().get(0).getTxDropped());
+        Assert.assertEquals("Wrong rxErrors", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getPortStats().get(0).getRxErrors());
+        Assert.assertEquals("Wrong txErrors", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getPortStats().get(0).getTxErrors());
+        Assert.assertEquals("Wrong rxFrameErr", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getPortStats().get(0).getRxFrameErr());
+        Assert.assertEquals("Wrong rxOverErr", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getPortStats().get(0).getRxOverErr());
+        Assert.assertEquals("Wrong rxCrcErr", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getPortStats().get(0).getRxCrcErr());
+        Assert.assertEquals("Wrong collisions", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getPortStats().get(0).getCollisions());
+        Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue());
+        Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyQueueBody(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 "+
+                                              "00 00 00 FF "+//portNo
+                                              "00 00 00 10 "+//queueId
+                                              "00 02 03 02 03 02 03 02 "+//txBytes
+                                              "00 02 02 02 02 02 02 02 "+//txPackets
+                                              "00 02 03 02 03 02 03 02 "+//txErrors
+                                              "00 00 00 02 "+//durationSec
+                                              "00 00 00 04"//durationNsec
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyQueue message = (MultipartReplyQueue) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());
+        Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());
+        Assert.assertEquals("Wrong txBytes", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getQueueStats().get(0).getTxBytes());
+        Assert.assertEquals("Wrong txPackets", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getQueueStats().get(0).getTxPackets());
+        Assert.assertEquals("Wrong txErrors", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), 
+                message.getQueueStats().get(0).getTxErrors());
+        Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue());
+        Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyGroupBody(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 "+
+                                              "00 48 "+//length
+                                              "00 00 "+//pad1
+                                              "00 00 00 10 "+//groupId
+                                              "00 00 00 12 "+//refCount
+                                              "00 00 00 00 "+//pad2
+                                              "00 01 01 01 01 01 01 01 "+//packetCount
+                                              "00 01 01 01 01 01 01 01 "+//byteCount
+                                              "00 00 00 08 "+//durationSec
+                                              "00 00 00 09 "+//durationNsec
+                                              "00 01 01 01 01 01 01 01 "+//packetCountBucket
+                                              "00 01 01 01 01 01 01 01 "+//byteCountBucket
+                                              "00 02 02 02 02 02 02 02 "+//packetCountBucket_2
+                                              "00 02 02 02 02 02 02 02 "+//byteCountBucket_2
+                                              "00 48 "+//length_2
+                                              "00 00 "+//pad1.2
+                                              "00 00 00 10 "+//groupId_2
+                                              "00 00 00 12 "+//refCount_2
+                                              "00 00 00 00 "+//pad2.2
+                                              "00 01 01 01 01 01 01 01 "+//packetCount_2
+                                              "00 01 01 01 01 01 01 01 "+//byteCount_2
+                                              "00 00 00 08 "+//durationSec_2
+                                              "00 00 00 09 "+//durationNsec_2
+                                              "00 01 01 01 01 01 01 01 "+//packetCountBucket_1.2
+                                              "00 01 01 01 01 01 01 01 "+//byteCountBucket_1.2
+                                              "00 02 02 02 02 02 02 02 "+//packetCountBucket_2.2
+                                              "00 02 02 02 02 02 02 02"//byteCountBucket_2.2
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyGroup message = (MultipartReplyGroup) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());
+        Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());
+        Assert.assertEquals("Wrong packetCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getGroupStats().get(0).getPacketCount());
+        Assert.assertEquals("Wrong byteCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getGroupStats().get(0).getByteCount());
+        Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());
+        Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());
+        Assert.assertEquals("Wrong packetCountBucket", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());
+        Assert.assertEquals("Wrong byteCountBucket", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());
+        Assert.assertEquals("Wrong packetCountBucket_2", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());
+        Assert.assertEquals("Wrong byteCountBucket_2", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());
+        
+        Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());
+        Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());
+        Assert.assertEquals("Wrong packetCount_2", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getGroupStats().get(1).getPacketCount());
+        Assert.assertEquals("Wrong byteCount_2", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getGroupStats().get(1).getByteCount());
+        Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());
+        Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());
+        Assert.assertEquals("Wrong packetCountBucket_1.2", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());
+        Assert.assertEquals("Wrong byteCountBucket_1.2", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());
+        Assert.assertEquals("Wrong packetCountBucket_2.2", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());
+        Assert.assertEquals("Wrong byteCountBucket_2.2", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyMeterFeaturesBody(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+
+                                              "00 00 00 09 "+//maxMeter
+                                              "00 00 00 01 "+//bandTypes
+                                              "00 00 00 03 "+//capabilities
+                                              "03 "+//maxBands
+                                              "04 "+//maxColor
+                                              "00 00"//pad
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyMeterFeatures message = (MultipartReplyMeterFeatures) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue());
+        Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, false), message.getBandTypes());
+        Assert.assertEquals("Wrong capabilities", new MeterFlags(false, true, true, false), 
+                                                      message.getCapabilities());
+        Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue());
+        Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyMeterBody(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+
+                                              "00 00 00 09 "+//meterId
+                                              "00 58 "+//len
+                                              "00 00 00 00 00 00 "+//pad
+                                              "00 00 00 07 "+//flowCount
+                                              "00 01 01 01 01 01 01 01 "+//packetInCount
+                                              "00 01 01 01 01 01 01 01 "+//byteInCount
+                                              "00 00 00 05 "+//durationSec
+                                              "00 00 00 05 "+//durationNsec
+                                              "00 01 01 01 01 01 01 01 "+//packetBandCount_01
+                                              "00 01 01 01 01 01 01 01 "+//byteBandCount_01
+                                              "00 02 02 02 02 02 02 02 "+//packetBandCount_02
+                                              "00 02 02 02 02 02 02 02 "+//byteBandCount_02
+                                              "00 03 03 03 03 03 03 03 "+//packetBandCount_03
+                                              "00 03 03 03 03 03 03 03"//byteBandCount_03
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyMeter message = (MultipartReplyMeter) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong meterId", 9, 
+                             message.getMeterStats().get(0).getMeterId().getValue().intValue());
+        Assert.assertEquals("Wrong flowCount", 7, 
+                            message.getMeterStats().get(0).getFlowCount().intValue());
+        Assert.assertEquals("Wrong packetInCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(0).getPacketInCount());
+        Assert.assertEquals("Wrong byteInCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(0).getByteInCount());
+        Assert.assertEquals("Wrong durationSec", 5, 
+                message.getMeterStats().get(0).getDurationSec().intValue());
+        Assert.assertEquals("Wrong durationNsec", 5, 
+                message.getMeterStats().get(0).getDurationNsec().intValue());
+        Assert.assertEquals("Wrong packetBandCount_01", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
+        Assert.assertEquals("Wrong byteBandCount_01", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
+        Assert.assertEquals("Wrong packetBandCount_02", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
+        Assert.assertEquals("Wrong byteBandCount_02", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
+        Assert.assertEquals("Wrong packetBandCount_03", 
+                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
+        Assert.assertEquals("Wrong byteBandCount_03", 
+                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyMeterBodyMulti(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+
+                                              "00 00 00 09 "+//meterId_0
+                                              "00 58 "+//len_0
+                                              "00 00 00 00 00 00 "+//pad_0
+                                              "00 00 00 07 "+//flowCount_0
+                                              "00 01 01 01 01 01 01 01 "+//packetInCount_0
+                                              "00 01 01 01 01 01 01 01 "+//byteInCount_0
+                                              "00 00 00 05 "+//durationSec_0
+                                              "00 00 00 05 "+//durationNsec_0
+                                              "00 01 01 01 01 01 01 01 "+//packetBandCount_01
+                                              "00 01 01 01 01 01 01 01 "+//byteBandCount_01
+                                              "00 02 02 02 02 02 02 02 "+//packetBandCount_02
+                                              "00 02 02 02 02 02 02 02 "+//byteBandCount_02
+                                              "00 03 03 03 03 03 03 03 "+//packetBandCount_03
+                                              "00 03 03 03 03 03 03 03 "+//byteBandCount_03
+                                              "00 00 00 08 "+//meterId_1
+                                              "00 58 "+//len_1
+                                              "00 00 00 00 00 00 "+//pad_1
+                                              "00 00 00 07 "+//flowCount_1
+                                              "00 01 01 01 01 01 01 01 "+//packetInCount_1
+                                              "00 01 01 01 01 01 01 01 "+//byteInCount_1
+                                              "00 00 00 05 "+//durationSec_1
+                                              "00 00 00 05 "+//durationNsec_1
+                                              "00 01 01 01 01 01 01 01 "+//packetBandCount_11
+                                              "00 01 01 01 01 01 01 01 "+//byteBandCount_11
+                                              "00 02 02 02 02 02 02 02 "+//packetBandCount_12
+                                              "00 02 02 02 02 02 02 02 "+//byteBandCount_12
+                                              "00 03 03 03 03 03 03 03 "+//packetBandCount_13
+                                              "00 03 03 03 03 03 03 03"//byteBandCount_13
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyMeter message = (MultipartReplyMeter) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong meterId", 9, 
+                             message.getMeterStats().get(0).getMeterId().getValue().intValue());
+        Assert.assertEquals("Wrong flowCount", 7, 
+                            message.getMeterStats().get(0).getFlowCount().intValue());
+        Assert.assertEquals("Wrong packetInCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(0).getPacketInCount());
+        Assert.assertEquals("Wrong byteInCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(0).getByteInCount());
+        Assert.assertEquals("Wrong durationSec", 5, 
+                message.getMeterStats().get(0).getDurationSec().intValue());
+        Assert.assertEquals("Wrong durationNsec", 5, 
+                message.getMeterStats().get(0).getDurationNsec().intValue());
+        Assert.assertEquals("Wrong packetBandCount_01", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
+        Assert.assertEquals("Wrong byteBandCount_01", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
+        Assert.assertEquals("Wrong packetBandCount_02", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
+        Assert.assertEquals("Wrong byteBandCount_02", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
+        Assert.assertEquals("Wrong packetBandCount_03", 
+                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
+        Assert.assertEquals("Wrong byteBandCount_03", 
+                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), 
+                message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
+        
+        Assert.assertEquals("Wrong meterId", 8, 
+                message.getMeterStats().get(1).getMeterId().getValue().intValue());
+        Assert.assertEquals("Wrong flowCount", 7, 
+                message.getMeterStats().get(1).getFlowCount().intValue());
+        Assert.assertEquals("Wrong packetInCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(1).getPacketInCount());
+        Assert.assertEquals("Wrong byteInCount", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(1).getByteInCount());
+        Assert.assertEquals("Wrong durationSec", 5, 
+                message.getMeterStats().get(1).getDurationSec().intValue());
+        Assert.assertEquals("Wrong durationNsec", 5, 
+                message.getMeterStats().get(1).getDurationNsec().intValue());
+        Assert.assertEquals("Wrong packetBandCount_01", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(1).getMeterBandStats().get(0).getPacketBandCount());
+        Assert.assertEquals("Wrong byteBandCount_01", 
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), 
+                message.getMeterStats().get(1).getMeterBandStats().get(0).getByteBandCount());
+        Assert.assertEquals("Wrong packetBandCount_02", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getMeterStats().get(1).getMeterBandStats().get(1).getPacketBandCount());
+        Assert.assertEquals("Wrong byteBandCount_02", 
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), 
+                message.getMeterStats().get(1).getMeterBandStats().get(1).getByteBandCount());
+        Assert.assertEquals("Wrong packetBandCount_03", 
+                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), 
+                message.getMeterStats().get(1).getMeterBandStats().get(2).getPacketBandCount());
+        Assert.assertEquals("Wrong byteBandCount_03", 
+                new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), 
+                message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyMeterConfigBody(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+
+                                              "00 38 "+//len
+                                              "00 0A "+//flags
+                                              "00 00 00 09 "+//meterId
+                                              "00 01 "+//meterBandDrop.type
+                                              "00 10 "+//meterBandDrop.len
+                                              "00 00 00 11 "+//meterBandDrop.rate
+                                              "00 00 00 20 "+//meterBandDrop.burstSize
+                                              "00 00 00 00 "+//meterBandDrop.pad
+                                              "00 02 "+//meterBandDscp.type
+                                              "00 10 "+//meterBandDscp.len
+                                              "00 00 00 11 "+//meterBandDscp.rate
+                                              "00 00 00 20 "+//meterBandDscp.burstSize
+                                              "04 "+//meterBandDscp.precLevel
+                                              "00 00 00 "+//meterBandDscp.pad
+                                              "FF FF "+//meterBandExperimenter.type
+                                              "00 10 "+//meterBandExperimenter.len
+                                              "00 00 00 11 "+//meterBandExperimenter.rate
+                                              "00 00 00 20 "+//meterBandExperimenter.burstSize
+                                              "00 00 00 04"//meterBandExperimenter.experimenter
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyMeterConfig message = (MultipartReplyMeterConfig) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true),
+                             message.getMeterConfig().get(0).getFlags());
+        Assert.assertEquals("Wrong meterId", 9, 
+                             message.getMeterConfig().get(0).getMeterId().getValue().intValue());
+        
+        MeterBandDrop meterBandDrop = (MeterBandDrop) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); 
+        Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); 
+        Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
+        Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
+        
+        MeterBandDscpRemark meterBandDscp = (MeterBandDscpRemark) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); 
+        Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); 
+        Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
+        Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
+        Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
+        
+        MeterBandExperimenter meterBandExperimenter = (MeterBandExperimenter) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); 
+        Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue()); 
+        Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue());
+        Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue());
+        Assert.assertEquals("Wrong meterBandExperimenter.experimenter", 4, meterBandExperimenter.getExperimenter().intValue());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyMeterConfigBodyMulti(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+
+                                              "00 38 "+//len
+                                              "00 06 "+//flags
+                                              "00 00 00 09 "+//meterId
+                                              "00 01 "+//meterBandDrop.type
+                                              "00 10 "+//meterBandDrop.len
+                                              "00 00 00 11 "+//meterBandDrop.rate
+                                              "00 00 00 20 "+//meterBandDrop.burstSize
+                                              "00 00 00 00 "+//meterBandDrop.pad
+                                              "00 02 "+//meterBandDscp.type
+                                              "00 10 "+//meterBandDscp.len
+                                              "00 00 00 11 "+//meterBandDscp.rate
+                                              "00 00 00 20 "+//meterBandDscp.burstSize
+                                              "04 "+//meterBandDscp.precLevel
+                                              "00 00 00 "+//meterBandDscp.pad
+                                              "FF FF "+//meterBandExperimenter.type
+                                              "00 10 "+//meterBandExperimenter.len
+                                              "00 00 00 11 "+//meterBandExperimenter.rate
+                                              "00 00 00 20 "+//meterBandExperimenter.burstSize
+                                              "00 00 00 04 "+//meterBandExperimenter.experimenter
+                                              
+                                              "00 18 "+//len01
+                                              "00 03 "+//flags01
+                                              "00 00 00 07 "+//meterId01
+                                              "00 02 "+//meterBandDscp01.type
+                                              "00 10 "+//meterBandDscp01.len
+                                              "00 00 00 11 "+//meterBandDscp01.rate
+                                              "00 00 00 20 "+//meterBandDscp01.burstSize
+                                              "04 "+//meterBandDscp01.precLevel
+                                              "00 00 00"//meterBandDscp01.pad
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyMeterConfig message = (MultipartReplyMeterConfig) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false), 
+                             message.getMeterConfig().get(0).getFlags());
+        Assert.assertEquals("Wrong meterId", 9, 
+                             message.getMeterConfig().get(0).getMeterId().getValue().intValue());
+        
+        MeterBandDrop meterBandDrop = (MeterBandDrop) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); 
+        Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); 
+        Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
+        Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
+        
+        MeterBandDscpRemark meterBandDscp = (MeterBandDscpRemark) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); 
+        Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); 
+        Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
+        Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
+        Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
+        
+        MeterBandExperimenter meterBandExperimenter = (MeterBandExperimenter) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); 
+        Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue()); 
+        Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue());
+        Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue());
+        Assert.assertEquals("Wrong meterBandExperimenter.experimenter", 4, meterBandExperimenter.getExperimenter().intValue());
+        
+        LOGGER.info(message.getMeterConfig().get(0).getFlags().toString());
+        Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false),
+                             message.getMeterConfig().get(1).getFlags());
+        Assert.assertEquals("Wrong meterId01", 7, 
+                             message.getMeterConfig().get(1).getMeterId().getValue().intValue());
+        
+        MeterBandDscpRemark meterBandDscp01 = (MeterBandDscpRemark) message.getMeterConfig().get(1).getBands().get(0).getMeterBand(); 
+        Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue()); 
+        Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue());
+        Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue());
+        Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue());
+        
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyExperimenterBody(){
+        ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "+
+                                              "00 00 00 0F "+//experimenterId
+                                              "00 00 00 FF "+//expType
+                                              "00 00 01 01 00 00 01 01"
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 0xFFFF, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyExperimenter message = (MultipartReplyExperimenter) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong experimenterId", 15, message.getExperimenter().intValue());
+        Assert.assertEquals("Wrong expType", 255, message.getExpType().intValue());
+        Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01}, 
+                             message.getData());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testMultipartReplyPortDescBody(){
+        final byte MAX_PORT_NAME_LEN = 16;
+        ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 01 00 00 00 00 "+
+                                              "00 01 02 03 "+ //portNo
+                                              "00 00 00 00 "+ //padding01
+                                              "08 00 27 00 B0 EB " + //mac address
+                                              "00 00 "); //padding02
+        //port name
+        String portName = "SampleText";
+        byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN];
+        portNameBytes = portName.getBytes();
+        bb.writeBytes(portNameBytes);
+        ByteBufUtils.padBuffer((MAX_PORT_NAME_LEN - portNameBytes.length), bb);
+        
+        ByteBuf bb2 =  BufferHelper.buildBuffer("00 00 00 41 " + //port config
+                                                "00 00 00 05 " + //port state
+                                                "00 00 00 81 " + //current features
+                                                "00 00 00 81 " + //advertised features
+                                                "00 00 00 81 " + //supported features
+                                                "00 00 00 81 " + //peer features
+                                                "00 00 00 81 " + //curr speed
+                                                "00 00 00 80" //max speed
+                                                );
+        bb.writeBytes(bb2.copy(4, bb2.readableBytes()-4));//excluding version and xid
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyPortDesc message = (MultipartReplyPortDesc) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong portNo", 66051L, message.getPorts().get(0).getPortNo().longValue());
+        Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), 
+                                                message.getPorts().get(0).getHwAddr());
+        Assert.assertEquals("Wrong portName", "SampleText", 
+                                                message.getPorts().get(0).getName());
+        Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), 
+                message.getPorts().get(0).getConfig());
+        Assert.assertEquals("Wrong portState", new PortState(false, true, true),
+                                               message.getPorts().get(0).getState());
+        Assert.assertEquals("Wrong currentFeatures", new PortFeatures(true, false, false, false,
+                                                                      false, false, false, true, 
+                                                                      false, false, false, false, 
+                                                                      false, false, false, false), 
+                                                  message.getPorts().get(0).getCurrentFeatures());
+        Assert.assertEquals("Wrong advertisedFeatures", 
+                             new PortFeatures(true, false, false, false,
+                                              false, false, false, true, 
+                                              false, false, false, false, 
+                                              false, false, false, false), 
+                                              message.getPorts().get(0).getAdvertisedFeatures());
+        Assert.assertEquals("Wrong supportedFeatures", 
+                             new PortFeatures(true, false, false, false,
+                                              false, false, false, true, 
+                                              false, false, false, false, 
+                                              false, false, false, false), 
+                                              message.getPorts().get(0).getSupportedFeatures());
+        Assert.assertEquals("Wrong peerFeatures", 
+                             new PortFeatures(true, false, false, false,
+                                              false, false, false, true, 
+                                              false, false, false, false, 
+                                              false, false, false, false), 
+                                              message.getPorts().get(0).getPeerFeatures());
+        Assert.assertEquals("Wrong currSpeed", 129L, message.getPorts().get(0).getCurrSpeed().longValue());
+        Assert.assertEquals("Wrong maxSpeed", 128L, message.getPorts().get(0).getMaxSpeed().longValue());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     * Test covers bodies of actions Output, Copy TTL Out, Copy TTL In
+     */
+    @Test
+    public void testMultipartReplyGroupDescBody01(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
+                                              "00 38 "+//len
+                                              "01 "+//type
+                                              "00 "+//pad
+                                              "00 00 00 08 "+//groupId
+                                              "00 30 "+//bucketLen
+                                              "00 06 "+//bucketWeight
+                                              "00 00 00 05 "+//bucketWatchPort
+                                              "00 00 00 04 "+//bucketWatchGroup
+                                              "00 00 00 00 "+//bucketPad
+                                              "00 00 "+//outputType
+                                              "00 10 "+//outputLen
+                                              "00 00 10 FF "+//outputPort
+                                              "FF FF "+//outputMaxLen
+                                              "00 00 00 00 00 00 "+//outputPad
+                                              "00 0B "+//copyTTLOutType
+                                              "00 08 "+//copyTTLOutLen
+                                              "00 00 00 00 "+//copyTTLOutPad
+                                              "00 0C "+//copyTTLIntType
+                                              "00 08 "+//copyTTLIntLen
+                                              "00 00 00 00"//copyTTLInPad
+                                              );
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong type", 1, 
+                             message.getGroupDesc().get(0).getType().getIntValue());
+        Assert.assertEquals("Wrong groupId", 8, 
+                             message.getGroupDesc().get(0).getGroupId().getValue().intValue());
+        Assert.assertEquals("Wrong bucketWeight", 6, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
+        Assert.assertEquals("Wrong bucketWatchPort", 5, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
+                                                                        getValue().intValue());
+        Assert.assertEquals("Wrong bucketWatchGroup", 4, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
+        
+        Assert.assertEquals("Wrong outputType", Output.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong outputPort", 4351, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
+                getAction().getAugmentation(PortAction.class).
+                getPort().getValue().intValue());
+        
+        Assert.assertEquals("Wrong outputMaxLen", 65535, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
+                getAction().getAugmentation(MaxLengthAction.class).
+                getMaxLength().intValue());
+        
+        Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).
+                getAction().getType());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     * Test covers bodies of actions Set MPLS TTL , Dec MPLS TTL, Push VLAN. Push MPLS, Push PBB
+     */
+    @Test
+    public void testMultipartReplyGroupDescBody02(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
+                                              "00 40 "+//len
+                                              "01 "+//type
+                                              "00 "+//pad
+                                              "00 00 00 08 "+//groupId
+                                              "00 38 "+//bucketLen
+                                              "00 06 "+//bucketWeight
+                                              "00 00 00 05 "+//bucketWatchPort
+                                              "00 00 00 04 "+//bucketWatchGroup
+                                              "00 00 00 00 "+//bucketPad
+                                              "00 0F "+//setMplsTtlType
+                                              "00 08 "+//setMplsTtlLen
+                                              "09 "+//setMplsTtlMPLS_TTL
+                                              "00 00 00 "+//setMplsTtlPad
+                                              "00 10 "+//decMplsTtlType
+                                              "00 08 "+//decMplsTtlLen
+                                              "00 00 00 00 "+//decMplsTtlPad
+                                              "00 11 "+//pushVlanType
+                                              "00 08 "+//pushVlanLen
+                                              "00 20 "+//pushVlanEthertype
+                                              "00 00 "+//pushVlanPad
+                                              "00 13 "+//pushMplsType
+                                              "00 08 "+//pushMplsLen
+                                              "00 FF "+//pushMplsEthertype
+                                              "00 00 "+//pushMplsPad
+                                              "00 1A "+//pushPbbType
+                                              "00 08 "+//pushPbbLen
+                                              "0F FF "+//pushPbbEthertype
+                                              "00 00"//pushPbbPad
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong type", 1, 
+                             message.getGroupDesc().get(0).getType().getIntValue());
+        Assert.assertEquals("Wrong groupId", 8, 
+                             message.getGroupDesc().get(0).getGroupId().getValue().intValue());
+        Assert.assertEquals("Wrong bucketWeight", 6, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
+        Assert.assertEquals("Wrong bucketWatchPort", 5, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
+                                                                        getValue().intValue());
+        Assert.assertEquals("Wrong bucketWatchGroup", 4, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
+        
+        
+        Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
+                getAction().getAugmentation(MplsTtlAction.class).
+                getMplsTtl().intValue());
+        
+        Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong pushVlanType", PushVlan.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong pushVlanEthertype", 32, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).
+                getAction().getAugmentation(EthertypeAction.class).
+                getEthertype().getValue().intValue());
+        
+        Assert.assertEquals("Wrong pushMplsType", PushMpls.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong pushMplsEthertype", 255, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).
+                getAction().getAugmentation(EthertypeAction.class).
+                getEthertype().getValue().intValue());
+        
+        Assert.assertEquals("Wrong pushPbbType", PushPbb.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong pushPbbEthertype", 4095, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).
+                getAction().getAugmentation(EthertypeAction.class).
+                getEthertype().getValue().intValue());
+        
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     * Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL
+     */
+    @Test
+    public void testMultipartReplyGroupDescBody03(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
+                                              "00 48 "+//len
+                                              "01 "+//type
+                                              "00 "+//pad
+                                              "00 00 00 08 "+//groupId
+                                              "00 40 "+//bucketLen
+                                              "00 06 "+//bucketWeight
+                                              "00 00 00 05 "+//bucketWatchPort
+                                              "00 00 00 04 "+//bucketWatchGroup
+                                              "00 00 00 00 "+//bucketPad
+                                              "00 12 "+//popVlanType
+                                              "00 08 "+//popVlanLen
+                                              "00 00 00 00 "+//popVlanPad
+                                              "00 1B "+//popPbbType
+                                              "00 08 "+//popPbbLen
+                                              "00 00 00 00 "+//popPbbPad
+                                              "00 14 "+//popMplsType
+                                              "00 08 "+//popMplsLen
+                                              "00 CF "+//popMplsEthertype
+                                              "00 00 "+//popMplsPad
+                                              "00 15 "+//setQueueType
+                                              "00 08 "+//setQueueLen
+                                              "00 CF 00 00 "+//setQueueQueueId
+                                              "00 16 "+//groupType
+                                              "00 08 "+//groupLen
+                                              "00 CF 00 00 "+//groupGroupId
+                                              "00 18 "+//decNwTtlType
+                                              "00 08 "+//decNwTtlLen
+                                              "00 00 00 00"//decNwTtlPad
+                                              );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong type", 1, 
+                             message.getGroupDesc().get(0).getType().getIntValue());
+        Assert.assertEquals("Wrong groupId", 8, 
+                             message.getGroupDesc().get(0).getGroupId().getValue().intValue());
+        Assert.assertEquals("Wrong bucketWeight", 6, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
+        Assert.assertEquals("Wrong bucketWatchPort", 5, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
+                                                                        getValue().intValue());
+        Assert.assertEquals("Wrong bucketWatchGroup", 4, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
+        
+        Assert.assertEquals("Wrong popVlanType", PopVlan.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong popPbbType", PopPbb.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong popMplsType", PopMpls.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong popMplsEthertype", 207, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).
+                getAction().getAugmentation(EthertypeAction.class).
+                getEthertype().getValue().intValue());
+        
+        Assert.assertEquals("Wrong setQueueType", SetQueue.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong setQueueQueueId", 13565952, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).
+                getAction().getAugmentation(QueueIdAction.class).
+                getQueueId().intValue());
+        
+        Assert.assertEquals("Wrong groupType", Group.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong groupGroupId", 13565952, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).
+                getAction().getAugmentation(GroupIdAction.class).
+                getGroupId().intValue());
+        
+        Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(5).
+                getAction().getType());
+    }
+    
+    /**
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+     * Test covers bodies of actions NW TTL, Experimenter
+     */
+    @Test
+    public void testMultipartReplyGroupDescBody04(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
+                                              "00 30 "+//len
+                                              "01 "+//type
+                                              "00 "+//pad
+                                              "00 00 00 08 "+//groupId
+                                              "00 28 "+//bucketLen
+                                              "00 06 "+//bucketWeight
+                                              "00 00 00 05 "+//bucketWatchPort
+                                              "00 00 00 04 "+//bucketWatchGroup
+                                              "00 00 00 00 "+//bucketPad
+                                              "00 17 "+//nwTTlType
+                                              "00 08 "+//nwTTlLen
+                                              "0E "+//nwTTlnwTTL
+                                              "00 00 00 "+//nwTTlPad
+                                              "00 19 "+//setFieldType
+                                              "00 10 "+//setFieldLen
+                                              "80 00 "+//setFieldOXMClass
+                                              "00 "+//setFieldOXMField
+                                              "04 "+//setFieldOXMLength
+                                              "00 00 00 FF "+ //setFieldPort
+                                              "00 00 00 00"
+                );
+        
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+        
+        MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();
+        
+        Assert.assertEquals("Wrong type", 1, 
+                             message.getGroupDesc().get(0).getType().getIntValue());
+        Assert.assertEquals("Wrong groupId", 8, 
+                             message.getGroupDesc().get(0).getGroupId().getValue().intValue());
+        Assert.assertEquals("Wrong bucketWeight", 6, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
+        Assert.assertEquals("Wrong bucketWatchPort", 5, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
+                                                                        getValue().intValue());
+        Assert.assertEquals("Wrong bucketWatchGroup", 4, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
+        
+        Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong nwTTlnwTTL", 14, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
+                getAction().getAugmentation(NwTtlAction.class).getNwTtl().intValue());
+        
+        Assert.assertEquals("Wrong setFieldType", SetField.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
+                getAction().getType());
+        
+        Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
+                getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmClass());
+        
+        Assert.assertEquals("Wrong setFieldOXMField", InPort.class, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
+                getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField());
+        
+        Assert.assertEquals("Wrong setFieldOXMValue", 255, 
+                message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
+                getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).
+                getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());
+    }
+}
index 31c73743cb0d9b93b032d1587e70dad5c499f871..43e6d37df2e9753878e21d1ff8f0a2c8b662cd8b 100644 (file)
@@ -1,84 +1,91 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
-\r
-/**\r
- * @author michal.polkorab\r
- */\r
-public class OF10ErrorMessageFactoryTest {\r
-\r
-       /**\r
-     * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO\r
-     */\r
-       @Test\r
-       public void testWithoutData() {\r
-               ByteBuf bb = BufferHelper.buildBuffer("00 01 00 02");\r
-               ErrorMessage builtByFactory = BufferHelper.decodeV10(\r
-                               OF10ErrorMessageFactory.getInstance(), bb);\r
-\r
-               BufferHelper.checkHeaderV10(builtByFactory);\r
-               Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue());\r
-               Assert.assertEquals("Wrong code", 2, builtByFactory.getCode().intValue());\r
-               Assert.assertEquals("Wrong type string", "BADREQUEST", builtByFactory.getTypeString());\r
-               Assert.assertEquals("Wrong code string", "BADSTAT", builtByFactory.getCodeString());\r
-               Assert.assertNull("Data is not null", builtByFactory.getData());\r
-       }\r
-       \r
-       /**\r
-     * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO\r
-     */\r
-       @Test\r
-       public void testWithData() {\r
-               ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 01 02 03");\r
-               ErrorMessage builtByFactory = BufferHelper.decodeV10(\r
-                               OF10ErrorMessageFactory.getInstance(), bb);\r
-\r
-               BufferHelper.checkHeaderV10(builtByFactory);\r
-               Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue());\r
-               Assert.assertEquals("Wrong code", 1, builtByFactory.getCode().intValue());\r
-               Assert.assertEquals("Wrong type string", "HELLOFAILED", builtByFactory.getTypeString());\r
-               Assert.assertEquals("Wrong code string", "EPERM", builtByFactory.getCodeString());\r
-               Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x01, 0x02, 0x03}, builtByFactory.getData());\r
-       }\r
-       \r
-       /**\r
-     * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO\r
-     */\r
-       @Test\r
-       public void testWithIncorrectTypeEnum() {\r
-               ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 05 00 01 02 03");\r
-               ErrorMessage builtByFactory = BufferHelper.decodeV10(\r
-                               OF10ErrorMessageFactory.getInstance(), bb);\r
-\r
-               BufferHelper.checkHeaderV10(builtByFactory);\r
-               Assert.assertEquals("Wrong type", 10, builtByFactory.getType().intValue());\r
-               Assert.assertEquals("Wrong code", 5, builtByFactory.getCode().intValue());\r
-               Assert.assertEquals("Wrong type string", "UNKNOWN_TYPE", builtByFactory.getTypeString());\r
-               Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());\r
-               Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x01, 0x02, 0x03}, builtByFactory.getData());\r
-       }\r
-       \r
-       /**\r
-     * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO\r
-     */\r
-       @Test\r
-       public void testWithIncorrectCodeEnum() {\r
-               ByteBuf bb = BufferHelper.buildBuffer("00 03 00 06 00 01 02 03");\r
-               ErrorMessage builtByFactory = BufferHelper.decodeV10(\r
-                               OF10ErrorMessageFactory.getInstance(), bb);\r
-\r
-               BufferHelper.checkHeaderV10(builtByFactory);\r
-               Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());\r
-               Assert.assertEquals("Wrong code", 6, builtByFactory.getCode().intValue());\r
-               Assert.assertEquals("Wrong type string", "FLOWMODFAILED", builtByFactory.getTypeString());\r
-               Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());\r
-               Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x01, 0x02, 0x03}, builtByFactory.getData());\r
-       }\r
-\r
-}\r
+/*
+ * 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.ErrorMessage;
+
+/**
+ * @author michal.polkorab
+ */
+public class OF10ErrorMessageFactoryTest {
+
+       /**
+     * 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);
+
+               BufferHelper.checkHeaderV10(builtByFactory);
+               Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue());
+               Assert.assertEquals("Wrong code", 2, builtByFactory.getCode().intValue());
+               Assert.assertEquals("Wrong type string", "BADREQUEST", builtByFactory.getTypeString());
+               Assert.assertEquals("Wrong code string", "BADSTAT", builtByFactory.getCodeString());
+               Assert.assertNull("Data is not null", builtByFactory.getData());
+       }
+       
+       /**
+     * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO
+     */
+       @Test
+       public void testWithData() {
+               ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 01 02 03");
+               ErrorMessage builtByFactory = BufferHelper.decodeV10(
+                               OF10ErrorMessageFactory.getInstance(), bb);
+
+               BufferHelper.checkHeaderV10(builtByFactory);
+               Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue());
+               Assert.assertEquals("Wrong code", 1, builtByFactory.getCode().intValue());
+               Assert.assertEquals("Wrong type string", "HELLOFAILED", builtByFactory.getTypeString());
+               Assert.assertEquals("Wrong code string", "EPERM", builtByFactory.getCodeString());
+               Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x01, 0x02, 0x03}, builtByFactory.getData());
+       }
+       
+       /**
+     * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO
+     */
+       @Test
+       public void testWithIncorrectTypeEnum() {
+               ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 05 00 01 02 03");
+               ErrorMessage builtByFactory = BufferHelper.decodeV10(
+                               OF10ErrorMessageFactory.getInstance(), bb);
+
+               BufferHelper.checkHeaderV10(builtByFactory);
+               Assert.assertEquals("Wrong type", 10, builtByFactory.getType().intValue());
+               Assert.assertEquals("Wrong code", 5, builtByFactory.getCode().intValue());
+               Assert.assertEquals("Wrong type string", "UNKNOWN_TYPE", builtByFactory.getTypeString());
+               Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
+               Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x01, 0x02, 0x03}, builtByFactory.getData());
+       }
+       
+       /**
+     * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO
+     */
+       @Test
+       public void testWithIncorrectCodeEnum() {
+               ByteBuf bb = BufferHelper.buildBuffer("00 03 00 06 00 01 02 03");
+               ErrorMessage builtByFactory = BufferHelper.decodeV10(
+                               OF10ErrorMessageFactory.getInstance(), bb);
+
+               BufferHelper.checkHeaderV10(builtByFactory);
+               Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());
+               Assert.assertEquals("Wrong code", 6, builtByFactory.getCode().intValue());
+               Assert.assertEquals("Wrong type string", "FLOWMODFAILED", builtByFactory.getTypeString());
+               Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
+               Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x01, 0x02, 0x03}, builtByFactory.getData());
+       }
+
+}
index 57f24eb8d945019a2312f96e7c3fbc416cd5a1cb..bb955efdd6fbeb378e3021e27ec9388db262de9f 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;\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.features.reply.PhyPort;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10FeaturesReplyMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 "\r
-                + "00 00 00 8B 00 00 03 B5 "\r
-                + "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 "\r
-                + "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88");\r
-        GetFeaturesOutput builtByFactory = BufferHelper.decodeV10(\r
-                OF10FeaturesReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());\r
-        Assert.assertEquals("Wrong n-buffers", 0x00010203L, builtByFactory.getBuffers().longValue());\r
-        Assert.assertEquals("Wrong n-tables", 0x01, builtByFactory.getTables().shortValue());\r
-        Assert.assertEquals("Wrong capabilities", new CapabilitiesV10(true, true, false, false, false, false, true, true),\r
-                builtByFactory.getCapabilitiesV10());\r
-        Assert.assertEquals("Wrong actions", new ActionTypeV10(false, true, true, true, true, false, true,\r
-                false, true, true, false, false, false), builtByFactory.getActionsV10());\r
-        PhyPort port = builtByFactory.getPhyPort().get(0);\r
-        Assert.assertEquals("Wrong port - port-no", 16, port.getPortNo().intValue());\r
-        Assert.assertEquals("Wrong port - hw-addr", new MacAddress("01:01:05:01:04:02"), port.getHwAddr());\r
-        Assert.assertEquals("Wrong port - name", new String("ALOHA"), port.getName());\r
-        Assert.assertEquals("Wrong port - config", new PortConfigV10(true, false, false, true, false, false, true),\r
-                port.getConfigV10());\r
-        Assert.assertEquals("Wrong port - state", new PortStateV10(false, true, false, false, false, true, false, false),\r
-                port.getStateV10());\r
-        Assert.assertEquals("Wrong port - curr", new PortFeaturesV10(false, false, false, false, true, true, true,\r
-                false, false, false, false, false), port.getCurrentFeaturesV10());\r
-        Assert.assertEquals("Wrong port - advertised", new PortFeaturesV10(false, false, true, true, false, false,\r
-                false, false, false, false, true, false), port.getAdvertisedFeaturesV10());\r
-        Assert.assertEquals("Wrong port - supported", new PortFeaturesV10(true, true, false, false, false, false,\r
-                false, true, false, true, false, false), port.getSupportedFeaturesV10());\r
-        Assert.assertEquals("Wrong port - peer", new PortFeaturesV10(true, false, false, false, false, false, false,\r
-                false, true, false, false, true), port.getPeerFeaturesV10());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithNoPortsSet() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 "\r
-                + "00 00 00 8B 00 00 03 B5 "\r
-                + "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 "\r
-                + "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88 "\r
-                + "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 "\r
-                + "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88 ");\r
-        GetFeaturesOutput builtByFactory = BufferHelper.decodeV10(\r
-                OF10FeaturesReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertEquals("Wrong ports size", 2, builtByFactory.getPhyPort().size());\r
-    }\r
-    \r
-    /**\r
-     * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithTwoPortsSet() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 "\r
-                + "00 00 00 8B 00 00 03 B5");\r
-        GetFeaturesOutput builtByFactory = BufferHelper.decodeV10(\r
-                OF10FeaturesReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertEquals("Wrong ports size", 0, builtByFactory.getPhyPort().size());\r
-    }\r
-\r
-}\r
+/*
+ * 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.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10FeaturesReplyMessageFactoryTest {
+
+    /**
+     * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void test() {
+        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 "
+                + "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);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
+        Assert.assertEquals("Wrong n-buffers", 0x00010203L, builtByFactory.getBuffers().longValue());
+        Assert.assertEquals("Wrong n-tables", 0x01, builtByFactory.getTables().shortValue());
+        Assert.assertEquals("Wrong capabilities", new CapabilitiesV10(true, true, false, false, false, false, true, true),
+                builtByFactory.getCapabilitiesV10());
+        Assert.assertEquals("Wrong actions", new ActionTypeV10(false, true, true, true, true, false, true,
+                false, true, true, false, false, false), builtByFactory.getActionsV10());
+        PhyPort port = builtByFactory.getPhyPort().get(0);
+        Assert.assertEquals("Wrong port - port-no", 16, port.getPortNo().intValue());
+        Assert.assertEquals("Wrong port - hw-addr", new MacAddress("01:01:05:01:04:02"), port.getHwAddr());
+        Assert.assertEquals("Wrong port - name", new String("ALOHA"), port.getName());
+        Assert.assertEquals("Wrong port - config", new PortConfigV10(true, false, false, true, false, false, true),
+                port.getConfigV10());
+        Assert.assertEquals("Wrong port - state", new PortStateV10(false, true, false, false, false, true, false, false),
+                port.getStateV10());
+        Assert.assertEquals("Wrong port - curr", new PortFeaturesV10(false, false, false, false, true, true, true,
+                false, false, false, false, false), port.getCurrentFeaturesV10());
+        Assert.assertEquals("Wrong port - advertised", new PortFeaturesV10(false, false, true, true, false, false,
+                false, false, false, false, true, false), port.getAdvertisedFeaturesV10());
+        Assert.assertEquals("Wrong port - supported", new PortFeaturesV10(true, true, false, false, false, false,
+                false, true, false, true, false, false), port.getSupportedFeaturesV10());
+        Assert.assertEquals("Wrong port - peer", new PortFeaturesV10(true, false, false, false, false, false, false,
+                false, true, false, false, true), port.getPeerFeaturesV10());
+    }
+    
+    /**
+     * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testWithNoPortsSet() {
+        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 "
+                + "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 "
+                + "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);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertEquals("Wrong ports size", 2, builtByFactory.getPhyPort().size());
+    }
+    
+    /**
+     * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO
+     */
+    @Test
+    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);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertEquals("Wrong ports size", 0, builtByFactory.getPhyPort().size());
+    }
+
+}
index ba41f51254dab781910be7cdb247a05c0296c086..3a9ec1a690caf2cbfddf3d57ecd773d8884594af 100644 (file)
@@ -1,38 +1,45 @@
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;\r
-\r
-/**\r
- * @author michal.polkorab\r
- */\r
-public class OF10FlowRemovedMessageFactoryTest {\r
-\r
-       /**\r
-     * Testing {@link OF10FlowRemovedMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 24 08 D1 00 20 AA BB CC DD EE FF "\r
-                + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 "//36\r
-                + "50 50 20 20 "// match\r
-                + "00 01 02 03 04 05 06 07 00 03 01 00 00 00 00 02 "\r
-                + "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\r
-        FlowRemovedMessage builtByFactory = BufferHelper.decodeV10(OF10FlowRemovedMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertEquals("Wrong cookie", 0x0001020304050607L, builtByFactory.getCookie().longValue());\r
-        Assert.assertEquals("Wrong priority", 0x03, builtByFactory.getPriority().intValue());\r
-        Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());\r
-        Assert.assertEquals("Wrong durationSec", 0x00000002L, builtByFactory.getDurationSec().longValue());\r
-        Assert.assertEquals("Wrong durationNsec", 0x00000005L, builtByFactory.getDurationNsec().longValue());\r
-        Assert.assertEquals("Wrong idleTimeout", 0x08, builtByFactory.getIdleTimeout().intValue());\r
-        Assert.assertEquals("Wrong packetCount", 0x0001020304050607L, builtByFactory.getPacketCount().longValue());\r
-        Assert.assertEquals("Wrong byteCount", 0x0001020304050607L, builtByFactory.getByteCount().longValue());\r
-    }\r
-\r
-}\r
+/*
+ * 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.FlowRemovedMessage;
+
+/**
+ * @author michal.polkorab
+ */
+public class OF10FlowRemovedMessageFactoryTest {
+
+       /**
+     * Testing {@link OF10FlowRemovedMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void test(){
+        ByteBuf bb = BufferHelper.buildBuffer("00 24 08 D1 00 20 AA BB CC DD EE FF "
+                + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 "//36
+                + "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);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertEquals("Wrong cookie", 0x0001020304050607L, builtByFactory.getCookie().longValue());
+        Assert.assertEquals("Wrong priority", 0x03, builtByFactory.getPriority().intValue());
+        Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());
+        Assert.assertEquals("Wrong durationSec", 0x00000002L, builtByFactory.getDurationSec().longValue());
+        Assert.assertEquals("Wrong durationNsec", 0x00000005L, builtByFactory.getDurationNsec().longValue());
+        Assert.assertEquals("Wrong idleTimeout", 0x08, builtByFactory.getIdleTimeout().intValue());
+        Assert.assertEquals("Wrong packetCount", 0x0001020304050607L, builtByFactory.getPacketCount().longValue());
+        Assert.assertEquals("Wrong byteCount", 0x0001020304050607L, builtByFactory.getByteCount().longValue());
+    }
+
+}
index d06b37017aba3001cdff50aadc0cbff919b12054..5c08bf4d70cf7ef4230001a9d102e61ddaca402d 100644 (file)
@@ -1,47 +1,54 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
-\r
-/**\r
- * @author michal.polkorab\r
- */\r
-public class OF10HelloMessageFactoryTest {\r
-\r
-       /**\r
-     * Testing {@link OF10HelloMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithoutElements() {\r
-        ByteBuf bb = BufferHelper.buildBuffer();\r
-        HelloMessage builtByFactory = BufferHelper.decodeV10(\r
-                OF10HelloMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertNull("Wrong elements", builtByFactory.getElements());\r
-    }\r
-       \r
-       /**\r
-     * Testing {@link OF10HelloMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void testWithElements() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 " // type\r
-                                            + "00 0c " // length\r
-                                            + "00 00 00 11 " // bitmap 1\r
-                                            + "00 00 00 00 " // bitmap 2\r
-                                            + "00 00 00 00"  // padding\r
-                );\r
-        HelloMessage builtByFactory = BufferHelper.decodeV10(\r
-                OF10HelloMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertNull("Wrong elements", builtByFactory.getElements());\r
-    }\r
-\r
-}\r
+/*
+ * 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.HelloMessage;
+
+/**
+ * @author michal.polkorab
+ */
+public class OF10HelloMessageFactoryTest {
+
+       /**
+     * Testing {@link OF10HelloMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testWithoutElements() {
+        ByteBuf bb = BufferHelper.buildBuffer();
+        HelloMessage builtByFactory = BufferHelper.decodeV10(
+                OF10HelloMessageFactory.getInstance(), bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertNull("Wrong elements", builtByFactory.getElements());
+    }
+       
+       /**
+     * Testing {@link OF10HelloMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void testWithElements() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 " // type
+                                            + "00 0c " // length
+                                            + "00 00 00 11 " // bitmap 1
+                                            + "00 00 00 00 " // bitmap 2
+                                            + "00 00 00 00"  // padding
+                );
+        HelloMessage builtByFactory = BufferHelper.decodeV10(
+                OF10HelloMessageFactory.getInstance(), bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertNull("Wrong elements", builtByFactory.getElements());
+    }
+
+}
index 11ec46b3f452184a4636bed1b3c5443debc9d874..51f5cdcfc047108dcaf81f0f0a6107e6afe50c48 100644 (file)
@@ -1,30 +1,37 @@
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;\r
-\r
-public class OF10PacketInMessageFactoryTest {\r
-\r
-       /**\r
-     * Testing {@link OF10PacketInMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 02 00 00 01 02 03 04");\r
-        PacketInMessage builtByFactory = BufferHelper.decodeV10(OF10PacketInMessageFactory.getInstance(), bb); \r
-        \r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());\r
-        Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue());\r
-        Assert.assertEquals("Wrong inPort", 0x0102, builtByFactory.getInPort().intValue());\r
-        Assert.assertEquals("Wrong reason", PacketInReason.OFPRNOMATCH, builtByFactory.getReason());\r
-        Assert.assertArrayEquals("Wrong data", ByteBufUtils.hexStringToBytes("01 02 03 04"), builtByFactory.getData());\r
-    }\r
-\r
-}\r
+/*
+ * 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.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+
+public class OF10PacketInMessageFactoryTest {
+
+       /**
+     * 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); 
+        
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());
+        Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue());
+        Assert.assertEquals("Wrong inPort", 0x0102, builtByFactory.getInPort().intValue());
+        Assert.assertEquals("Wrong reason", PacketInReason.OFPRNOMATCH, builtByFactory.getReason());
+        Assert.assertArrayEquals("Wrong data", ByteBufUtils.hexStringToBytes("01 02 03 04"), builtByFactory.getData());
+    }
+
+}
index 0e3ed52d443e49673427e541f2a3535e19cf29ae..d4fa28bf711f89fa9155dce96babbd6fddaa0b0c 100644 (file)
@@ -1,51 +1,58 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10PortStatusMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing {@link OF10PortStatusMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00 00 00 00 00 "\r
-                + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 "\r
-                + "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");\r
-        PortStatusMessage builtByFactory = BufferHelper.decodeV10(OF10PortStatusMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertEquals("Wrong reason", PortReason.OFPPRADD, builtByFactory.getReason());\r
-        Assert.assertEquals("Wrong port - port-no", 16, builtByFactory.getPortNo().intValue());\r
-        Assert.assertEquals("Wrong builtByFactory - hw-addr", new MacAddress("01:01:05:01:04:02"), builtByFactory.getHwAddr());\r
-        Assert.assertEquals("Wrong builtByFactory - name", new String("ALOHA"), builtByFactory.getName());\r
-        Assert.assertEquals("Wrong builtByFactory - config", new PortConfigV10(true, false, false, true, false, false, true),\r
-                builtByFactory.getConfigV10());\r
-        Assert.assertEquals("Wrong builtByFactory - state", new PortStateV10(false, true, false, false, false, true, false, false),\r
-                builtByFactory.getStateV10());\r
-        Assert.assertEquals("Wrong builtByFactory - curr", new PortFeaturesV10(false, false, false, false, true, true, true,\r
-                false, false, false, false, false), builtByFactory.getCurrentFeaturesV10());\r
-        Assert.assertEquals("Wrong builtByFactory - advertised", new PortFeaturesV10(false, false, true, true, false, false,\r
-                false, false, false, false, true, false), builtByFactory.getAdvertisedFeaturesV10());\r
-        Assert.assertEquals("Wrong builtByFactory - supbuiltByFactoryed", new PortFeaturesV10(true, true, false, false, false, false,\r
-                false, true, false, true, false, false), builtByFactory.getSupportedFeaturesV10());\r
-        Assert.assertEquals("Wrong builtByFactory - peer", new PortFeaturesV10(true, false, false, false, false, false, false,\r
-                false, true, false, false, true), builtByFactory.getPeerFeaturesV10());\r
-    }\r
-\r
-}\r
+/*
+ * 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.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10PortStatusMessageFactoryTest {
+
+    /**
+     * Testing {@link OF10PortStatusMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void test(){
+        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);
+        
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertEquals("Wrong reason", PortReason.OFPPRADD, builtByFactory.getReason());
+        Assert.assertEquals("Wrong port - port-no", 16, builtByFactory.getPortNo().intValue());
+        Assert.assertEquals("Wrong builtByFactory - hw-addr", new MacAddress("01:01:05:01:04:02"), builtByFactory.getHwAddr());
+        Assert.assertEquals("Wrong builtByFactory - name", new String("ALOHA"), builtByFactory.getName());
+        Assert.assertEquals("Wrong builtByFactory - config", new PortConfigV10(true, false, false, true, false, false, true),
+                builtByFactory.getConfigV10());
+        Assert.assertEquals("Wrong builtByFactory - state", new PortStateV10(false, true, false, false, false, true, false, false),
+                builtByFactory.getStateV10());
+        Assert.assertEquals("Wrong builtByFactory - curr", new PortFeaturesV10(false, false, false, false, true, true, true,
+                false, false, false, false, false), builtByFactory.getCurrentFeaturesV10());
+        Assert.assertEquals("Wrong builtByFactory - advertised", new PortFeaturesV10(false, false, true, true, false, false,
+                false, false, false, false, true, false), builtByFactory.getAdvertisedFeaturesV10());
+        Assert.assertEquals("Wrong builtByFactory - supbuiltByFactoryed", new PortFeaturesV10(true, true, false, false, false, false,
+                false, true, false, true, false, false), builtByFactory.getSupportedFeaturesV10());
+        Assert.assertEquals("Wrong builtByFactory - peer", new PortFeaturesV10(true, false, false, false, false, false, false,
+                false, true, false, false, true), builtByFactory.getPeerFeaturesV10());
+    }
+
+}
index 3ce772de911d81dff43f5fc05825ad0fa42ef139..216e5d37f7f5042b41304b4a27024b38ea64b3bc 100644 (file)
@@ -1,53 +1,60 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;\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.queue.get.config.reply.Queues;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10QueueGetConfigReplyMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing of {@link OF10QueueGetConfigReplyMessageFactory} for correct\r
-     * translation into POJO\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 00 00 00 "\r
-                + "00 00 00 08 00 10 00 00 00 00 00 08 00 00 00 00 "\r
-                + "00 00 00 02 00 28 00 00 00 01 00 10 00 00 00 00 00 20 00 00 00 00 00 00 "\r
-                + "00 01 00 10 00 00 00 00 00 30 00 00 00 00 00 00");\r
-        GetQueueConfigOutput builtByFactory = BufferHelper.decodeV10(\r
-                OF10QueueGetConfigReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertEquals("Wrong port", 1, builtByFactory.getPort().getValue().intValue());\r
-        Assert.assertEquals("Wrong queues size", 2, builtByFactory.getQueues().size());\r
-        Queues queue1 = builtByFactory.getQueues().get(0);\r
-        Queues queue2 = builtByFactory.getQueues().get(1);\r
-        Assert.assertEquals("Wrong queueId", 8, queue1.getQueueId().getValue().intValue());\r
-        Assert.assertEquals("Wrong queue - # properties", 1, queue1.getQueueProperty().size());\r
-        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTNONE,\r
-                queue1.getQueueProperty().get(0).getProperty());\r
-        Assert.assertEquals("Wrong queueId", 2, queue2.getQueueId().getValue().intValue());\r
-        Assert.assertEquals("Wrong queue - # properties", 2, queue2.getQueueProperty().size());\r
-        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,\r
-                queue2.getQueueProperty().get(0).getProperty());\r
-        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,\r
-                queue2.getQueueProperty().get(1).getProperty());\r
-        RateQueueProperty rate1 = queue2.getQueueProperty().get(0).getAugmentation(RateQueueProperty.class);\r
-        RateQueueProperty rate2 = queue2.getQueueProperty().get(1).getAugmentation(RateQueueProperty.class);\r
-        Assert.assertEquals("Wrong queue - wrong property rate", 32, rate1.getRate().intValue());\r
-        Assert.assertEquals("Wrong queue - wrong property rate", 48, rate2.getRate().intValue());\r
-    }\r
-}\r
+/*
+ * 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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10QueueGetConfigReplyMessageFactoryTest {
+
+    /**
+     * Testing of {@link OF10QueueGetConfigReplyMessageFactory} for correct
+     * translation into POJO
+     */
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 00 00 00 "
+                + "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);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertEquals("Wrong port", 1, builtByFactory.getPort().getValue().intValue());
+        Assert.assertEquals("Wrong queues size", 2, builtByFactory.getQueues().size());
+        Queues queue1 = builtByFactory.getQueues().get(0);
+        Queues queue2 = builtByFactory.getQueues().get(1);
+        Assert.assertEquals("Wrong queueId", 8, queue1.getQueueId().getValue().intValue());
+        Assert.assertEquals("Wrong queue - # properties", 1, queue1.getQueueProperty().size());
+        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTNONE,
+                queue1.getQueueProperty().get(0).getProperty());
+        Assert.assertEquals("Wrong queueId", 2, queue2.getQueueId().getValue().intValue());
+        Assert.assertEquals("Wrong queue - # properties", 2, queue2.getQueueProperty().size());
+        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,
+                queue2.getQueueProperty().get(0).getProperty());
+        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,
+                queue2.getQueueProperty().get(1).getProperty());
+        RateQueueProperty rate1 = queue2.getQueueProperty().get(0).getAugmentation(RateQueueProperty.class);
+        RateQueueProperty rate2 = queue2.getQueueProperty().get(1).getAugmentation(RateQueueProperty.class);
+        Assert.assertEquals("Wrong queue - wrong property rate", 32, rate1.getRate().intValue());
+        Assert.assertEquals("Wrong queue - wrong property rate", 48, rate2.getRate().intValue());
+    }
+}
index c68d896212baa2ef9b51b83293f91f9dc4fe5ae8..7dc2e8631f094ecc9d754d343d0083cc615867dd 100644 (file)
@@ -1,28 +1,35 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;\r
-\r
-/**\r
- * @author michal.polkorab\r
- */\r
-public class OF10VendorMessageFactoryTest {\r
-\r
-       /**\r
-     * Testing {@link OF10VendorMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("01 02 03 04");\r
-        ExperimenterMessage builtByFactory = BufferHelper.decodeV10(\r
-                OF10VendorMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertEquals("Wrong experimenter", 0x01020304L, builtByFactory.getExperimenter().longValue());\r
-    }\r
-}\r
+/*
+ * 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 63b813faa870dfd59a5d534364f22c7293c1f4f3..6a3a35f07f8306c2b842c6767e9b7e7c62ddd41f 100644 (file)
@@ -1,43 +1,50 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * @author timotej.kubas\r
- *\r
- */\r
-public class PacketInMessageFactoryTest {\r
-\r
-    private static final Logger LOGGER = LoggerFactory\r
-            .getLogger(PacketInMessageFactoryTest.class);\r
-    \r
-    /**\r
-     * Testing {@link PacketInMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 04 00 01 02 03 04 05 06 07 00 01 00 0C"\r
-                + " 80 00 02 04 00 00 00 01 00 00 00 00 00 00 01 02 03 04");\r
-        PacketInMessage builtByFactory = BufferHelper.decodeV13(PacketInMessageFactory.getInstance(), bb); \r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        \r
-        Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());\r
-        Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue());\r
-        Assert.assertEquals("Wrong reason", PacketInReason.OFPRACTION, builtByFactory.getReason());\r
-        Assert.assertEquals("Wrong tableID", new TableId(4L), builtByFactory.getTableId());\r
-        Assert.assertEquals("Wrong cookie", 0x0001020304050607L, builtByFactory.getCookie().longValue());\r
-        Assert.assertArrayEquals("Wrong data", ByteBufUtils.hexStringToBytes("01 02 03 04"), builtByFactory.getData());\r
-    }\r
-}\r
+/*
+ * 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.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author timotej.kubas
+ *
+ */
+public class PacketInMessageFactoryTest {
+
+    private static final Logger LOGGER = LoggerFactory
+            .getLogger(PacketInMessageFactoryTest.class);
+    
+    /**
+     * Testing {@link PacketInMessageFactory} for correct translation into POJO
+     */
+    @Test
+    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); 
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        
+        Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());
+        Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue());
+        Assert.assertEquals("Wrong reason", PacketInReason.OFPRACTION, builtByFactory.getReason());
+        Assert.assertEquals("Wrong tableID", new TableId(4L), builtByFactory.getTableId());
+        Assert.assertEquals("Wrong cookie", 0x0001020304050607L, builtByFactory.getCookie().longValue());
+        Assert.assertArrayEquals("Wrong data", ByteBufUtils.hexStringToBytes("01 02 03 04"), builtByFactory.getData());
+    }
+}
index 967c9fd5502c7e28ec3e73d69b06fbf3ce5a3f48..9d427381250ec19a6f6095159b619a8e65842abe 100644 (file)
@@ -1,66 +1,73 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class PortStatusMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing {@link PortStatusMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("01 " + //reason \r
-                                              "00 00 00 00 00 00 00 " + //padding\r
-                                              "00 01 02 03 " + //port no\r
-                                              "00 00 00 00 " + //padding in ofp_port1\r
-                                              "08 00 27 00 B0 EB " + //mac address\r
-                                              "00 00 " + //padding in ofp_port2\r
-                                              "00 00 00 41 " + //port config\r
-                                              "00 00 00 05 " + //port state\r
-                                              "00 00 00 81 " + //current features\r
-                                              "00 00 00 81 " + //advertised features\r
-                                              "00 00 00 81 " + //supported features\r
-                                              "00 00 00 81 " + //peer features\r
-                                              "00 00 00 81 " + //curr speed\r
-                                              "00 00 00 80" //max speed\r
-                                              );\r
-        \r
-        PortStatusMessage builtByFactory = BufferHelper.decodeV13(PortStatusMessageFactory.getInstance(), bb);\r
-        \r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());\r
-        Assert.assertEquals("Wrong portNumber", 66051L, builtByFactory.getPortNo().longValue());\r
-        Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), builtByFactory.getHwAddr());\r
-        Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), builtByFactory.getConfig());\r
-        Assert.assertEquals("Wrong portState", new PortState(false, true, true), builtByFactory.getState());\r
-        Assert.assertEquals("Wrong currentFeatures", new PortFeatures(true, false, false, false,\r
-                                             false, false, false, true, false, false, false, false, \r
-                                             false, false, false, false), builtByFactory.getCurrentFeatures());\r
-        Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, false, false, false,\r
-                                             false, false, false, true, false, false, false, false, \r
-                                             false, false, false, false), builtByFactory.getAdvertisedFeatures());\r
-        Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, false, false, false,\r
-                                             false, false, false, true, false, false, false, false, \r
-                                             false, false, false, false), builtByFactory.getSupportedFeatures());\r
-        Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, false, false, false,\r
-                                             false, false, false, true, false, false, false, false, \r
-                                             false, false, false, false), builtByFactory.getSupportedFeatures());\r
-        Assert.assertEquals("Wrong currSpeed", 129L, builtByFactory.getCurrSpeed().longValue());\r
-        Assert.assertEquals("Wrong maxSpeed", 128L, builtByFactory.getMaxSpeed().longValue());\r
-    }\r
-}\r
+/*
+ * 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.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class PortStatusMessageFactoryTest {
+
+    /**
+     * Testing {@link PortStatusMessageFactory} for correct translation into POJO
+     */
+    @Test
+    public void test(){
+        ByteBuf bb = BufferHelper.buildBuffer("01 " + //reason 
+                                              "00 00 00 00 00 00 00 " + //padding
+                                              "00 01 02 03 " + //port no
+                                              "00 00 00 00 " + //padding in ofp_port1
+                                              "08 00 27 00 B0 EB " + //mac address
+                                              "00 00 " + //padding in ofp_port2
+                                              "00 00 00 41 " + //port config
+                                              "00 00 00 05 " + //port state
+                                              "00 00 00 81 " + //current features
+                                              "00 00 00 81 " + //advertised features
+                                              "00 00 00 81 " + //supported features
+                                              "00 00 00 81 " + //peer features
+                                              "00 00 00 81 " + //curr speed
+                                              "00 00 00 80" //max speed
+                                              );
+        
+        PortStatusMessage builtByFactory = BufferHelper.decodeV13(PortStatusMessageFactory.getInstance(), bb);
+        
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());
+        Assert.assertEquals("Wrong portNumber", 66051L, builtByFactory.getPortNo().longValue());
+        Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), builtByFactory.getHwAddr());
+        Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), builtByFactory.getConfig());
+        Assert.assertEquals("Wrong portState", new PortState(false, true, true), builtByFactory.getState());
+        Assert.assertEquals("Wrong currentFeatures", new PortFeatures(true, false, false, false,
+                                             false, false, false, true, false, false, false, false, 
+                                             false, false, false, false), builtByFactory.getCurrentFeatures());
+        Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, false, false, false,
+                                             false, false, false, true, false, false, false, false, 
+                                             false, false, false, false), builtByFactory.getAdvertisedFeatures());
+        Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, false, false, false,
+                                             false, false, false, true, false, false, false, false, 
+                                             false, false, false, false), builtByFactory.getSupportedFeatures());
+        Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, false, false, false,
+                                             false, false, false, true, false, false, false, false, 
+                                             false, false, false, false), builtByFactory.getSupportedFeatures());
+        Assert.assertEquals("Wrong currSpeed", 129L, builtByFactory.getCurrSpeed().longValue());
+        Assert.assertEquals("Wrong maxSpeed", 128L, builtByFactory.getMaxSpeed().longValue());
+    }
+}
index eb2cdc7c7c42c3c209490b5ca49d11032516a221..4d8cb22849121be8f444f090989ce2408368a1f2 100644 (file)
@@ -1,88 +1,95 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;\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.queue.get.config.reply.Queues;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class QueueGetConfigReplyMessageFactoryMultiTest {\r
-\r
-    /**\r
-     * Testing of {@link QueueGetConfigReplyMessageFactory} for correct\r
-     * translation into POJO\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 " + // port\r
-                "00 00 00 00 " + // padding\r
-                "00 00 00 01 " + // queueId\r
-                "00 00 00 01 " + // port\r
-                "00 20 " + // length\r
-                "00 00 00 00 00 00 " + // pad\r
-                "00 02 " + // property\r
-                "00 10 " + // length\r
-                "00 00 00 00 " + // pad\r
-                "00 05 " + // rate\r
-                "00 00 00 00 00 00 " + // pad\r
-                "00 00 00 02 " + // queueId\r
-                "00 00 00 02 " + // port\r
-                "00 20 " + // length\r
-                "00 00 00 00 00 00 " + // pad\r
-                "00 02 " + // property\r
-                "00 10 " + // length\r
-                "00 00 00 00 " + // pad\r
-                "00 05 " + // rate\r
-                "00 00 00 00 00 00 " // pad\r
-        );\r
-\r
-        GetQueueConfigOutput builtByFactory = BufferHelper.decodeV13(\r
-                QueueGetConfigReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong port", 66051L, builtByFactory.getPort().getValue().longValue());\r
-        Assert.assertEquals("Wrong queues", createQueuesList(), builtByFactory.getQueues());\r
-    }\r
-\r
-    private static List<Queues> createQueuesList() {\r
-        List<Queues> queuesList = new ArrayList<>();\r
-        for (int i = 1; i < 3; i++) {\r
-            QueuesBuilder qb = new QueuesBuilder();\r
-            qb.setQueueId(new QueueId((long) i));\r
-            qb.setPort(new PortNumber((long) i));\r
-            qb.setQueueProperty(createPropertiesList());\r
-            queuesList.add(qb.build());\r
-        }\r
-        return queuesList;\r
-    }\r
-\r
-    private static List<QueueProperty> createPropertiesList() {\r
-        List<QueueProperty> propertiesList = new ArrayList<>();\r
-        QueuePropertyBuilder pb = new QueuePropertyBuilder();\r
-        pb.setProperty(QueueProperties.forValue(2));\r
-        RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();\r
-        rateBuilder.setRate(5);\r
-        pb.addAugmentation(RateQueueProperty.class, rateBuilder.build());\r
-        propertiesList.add(pb.build());\r
-        return propertiesList;\r
-    }\r
-\r
-}\r
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class QueueGetConfigReplyMessageFactoryMultiTest {
+
+    /**
+     * Testing of {@link QueueGetConfigReplyMessageFactory} for correct
+     * translation into POJO
+     */
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 " + // port
+                "00 00 00 00 " + // padding
+                "00 00 00 01 " + // queueId
+                "00 00 00 01 " + // port
+                "00 20 " + // length
+                "00 00 00 00 00 00 " + // pad
+                "00 02 " + // property
+                "00 10 " + // length
+                "00 00 00 00 " + // pad
+                "00 05 " + // rate
+                "00 00 00 00 00 00 " + // pad
+                "00 00 00 02 " + // queueId
+                "00 00 00 02 " + // port
+                "00 20 " + // length
+                "00 00 00 00 00 00 " + // pad
+                "00 02 " + // property
+                "00 10 " + // length
+                "00 00 00 00 " + // pad
+                "00 05 " + // rate
+                "00 00 00 00 00 00 " // pad
+        );
+
+        GetQueueConfigOutput builtByFactory = BufferHelper.decodeV13(
+                QueueGetConfigReplyMessageFactory.getInstance(), bb);
+
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong port", 66051L, builtByFactory.getPort().getValue().longValue());
+        Assert.assertEquals("Wrong queues", createQueuesList(), builtByFactory.getQueues());
+    }
+
+    private static List<Queues> createQueuesList() {
+        List<Queues> queuesList = new ArrayList<>();
+        for (int i = 1; i < 3; i++) {
+            QueuesBuilder qb = new QueuesBuilder();
+            qb.setQueueId(new QueueId((long) i));
+            qb.setPort(new PortNumber((long) i));
+            qb.setQueueProperty(createPropertiesList());
+            queuesList.add(qb.build());
+        }
+        return queuesList;
+    }
+
+    private static List<QueueProperty> createPropertiesList() {
+        List<QueueProperty> propertiesList = new ArrayList<>();
+        QueuePropertyBuilder pb = new QueuePropertyBuilder();
+        pb.setProperty(QueueProperties.forValue(2));
+        RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();
+        rateBuilder.setRate(5);
+        pb.addAugmentation(RateQueueProperty.class, rateBuilder.build());
+        propertiesList.add(pb.build());
+        return propertiesList;
+    }
+
+}
index cf50b27717ac714cefa4f4968755a79588f96beb..157e8d7fa402ca203354927c61447f057de68a03 100644 (file)
@@ -1,62 +1,69 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;\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.queue.get.config.reply.Queues;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class QueueGetConfigReplyMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing {@link QueueGetConfigReplyMessageFactory} for correct translation into POJO\r
-     */\r
-    @Test\r
-    public void test(){\r
-        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");\r
-        GetQueueConfigOutput builtByFactory = BufferHelper.decodeV13(QueueGetConfigReplyMessageFactory.getInstance(), bb);\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-        Assert.assertEquals("Wrong port", 3L, builtByFactory.getPort().getValue().longValue());\r
-        Assert.assertEquals("Wrong queues", builtByFactory.getQueues(), createQueuesList());\r
-    }\r
-    \r
-    private static List<Queues> createQueuesList(){\r
-        List<Queues> queuesList = new ArrayList<>();\r
-        QueuesBuilder qb = new QueuesBuilder();\r
-        qb.setQueueId(new QueueId(1L));\r
-        qb.setPort(new PortNumber(3L));\r
-        qb.setQueueProperty(createPropertiesList());\r
-        queuesList.add(qb.build());\r
-        \r
-        return queuesList;\r
-    }\r
-    \r
-    private static List<QueueProperty> createPropertiesList(){\r
-        List<QueueProperty> propertiesList = new ArrayList<>();\r
-        QueuePropertyBuilder pb = new QueuePropertyBuilder();\r
-        pb.setProperty(QueueProperties.forValue(2));\r
-        RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();\r
-        rateBuilder.setRate(5);\r
-        pb.addAugmentation(RateQueueProperty.class, rateBuilder.build());\r
-        propertiesList.add(pb.build());\r
-        return propertiesList;\r
-    }\r
-}\r
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class QueueGetConfigReplyMessageFactoryTest {
+
+    /**
+     * 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);
+        BufferHelper.checkHeaderV13(builtByFactory);
+        Assert.assertEquals("Wrong port", 3L, builtByFactory.getPort().getValue().longValue());
+        Assert.assertEquals("Wrong queues", builtByFactory.getQueues(), createQueuesList());
+    }
+    
+    private static List<Queues> createQueuesList(){
+        List<Queues> queuesList = new ArrayList<>();
+        QueuesBuilder qb = new QueuesBuilder();
+        qb.setQueueId(new QueueId(1L));
+        qb.setPort(new PortNumber(3L));
+        qb.setQueueProperty(createPropertiesList());
+        queuesList.add(qb.build());
+        
+        return queuesList;
+    }
+    
+    private static List<QueueProperty> createPropertiesList(){
+        List<QueueProperty> propertiesList = new ArrayList<>();
+        QueuePropertyBuilder pb = new QueuePropertyBuilder();
+        pb.setProperty(QueueProperties.forValue(2));
+        RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();
+        rateBuilder.setRate(5);
+        pb.addAugmentation(RateQueueProperty.class, rateBuilder.build());
+        propertiesList.add(pb.build());
+        return propertiesList;
+    }
+}
index e24af65201ae0a7ddd3c0325cb5a7d68bb901a26..2d7ff94e6c31f6f4857d9c4c53c89d5bc723881e 100644 (file)
@@ -1,30 +1,37 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class RoleReplyMessageFactoryTest {\r
-\r
-   /**\r
-    * Testing of {@link RoleReplyMessageFactory} for correct translation into POJO\r
-    */\r
-    @Test\r
-    public void test(){\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 00 00 02 00 00 00 00 00 01 02 03 04 05 06 07");\r
-        RoleRequestOutput builtByFactory = BufferHelper.decodeV13(RoleReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV13(builtByFactory);\r
-       \r
-        Assert.assertEquals("Wrong role", 0x02, builtByFactory.getRole().getIntValue());\r
-        Assert.assertEquals("Wrong generationId", 0x01020304050607L, builtByFactory.getGenerationId().longValue());\r
-    }\r
-}\r
+/*
+ * 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.RoleRequestOutput;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class RoleReplyMessageFactoryTest {
+
+   /**
+    * 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);
+
+        BufferHelper.checkHeaderV13(builtByFactory);
+       
+        Assert.assertEquals("Wrong role", 0x02, builtByFactory.getRole().getIntValue());
+        Assert.assertEquals("Wrong generationId", 0x01020304050607L, builtByFactory.getGenerationId().longValue());
+    }
+}
index 7f1908e15ecbdc989293f2176b7b83e77e97e380..6f119eb3a7e9b77632e022826bd1bf18163e11c8 100644 (file)
@@ -1,39 +1,46 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class BarrierInputMessageFactoryTest {\r
-\r
-    private static final byte BARRIER_REQUEST_MESSAGE_CODE_TYPE = BarrierInputMessageFactory.MESSAGE_TYPE;\r
-    \r
-    /**\r
-     * Testing of {@link BarrierInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void test() throws Exception {\r
-        BarrierInputBuilder bib = new BarrierInputBuilder();\r
-        BufferHelper.setupHeader(bib, EncodeConstants.OF13_VERSION_ID);\r
-        BarrierInput bi = bib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        BarrierInputMessageFactory bimf = BarrierInputMessageFactory.getInstance();\r
-        bimf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, bi);\r
-        \r
-        BufferHelper.checkHeaderV13(out, BARRIER_REQUEST_MESSAGE_CODE_TYPE, 8);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class BarrierInputMessageFactoryTest {
+
+    private static final byte BARRIER_REQUEST_MESSAGE_CODE_TYPE = BarrierInputMessageFactory.MESSAGE_TYPE;
+    
+    /**
+     * Testing of {@link BarrierInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void test() throws Exception {
+        BarrierInputBuilder bib = new BarrierInputBuilder();
+        BufferHelper.setupHeader(bib, EncodeConstants.OF13_VERSION_ID);
+        BarrierInput bi = bib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        BarrierInputMessageFactory bimf = BarrierInputMessageFactory.getInstance();
+        bimf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, bi);
+        
+        BufferHelper.checkHeaderV13(out, BARRIER_REQUEST_MESSAGE_CODE_TYPE, 8);
+    }
+
+}
index 3c2faa64356be13e9ea150192cba6dd0ae59dacd..bb2ee8e33bb1638162a61a71d419d59df59ab562 100644 (file)
@@ -1,55 +1,62 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class EchoInputMessageFactoryTest {\r
-\r
-    private static final byte ECHO_REQUEST_MESSAGE_CODE_TYPE = EchoInputMessageFactory.MESSAGE_TYPE;\r
-    \r
-    /**\r
-     * Testing of {@link EchoInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testV13() throws Exception {\r
-        EchoInputBuilder eib = new EchoInputBuilder();\r
-        BufferHelper.setupHeader(eib, EncodeConstants.OF13_VERSION_ID);\r
-        EchoInput ei = eib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        EchoInputMessageFactory eimf = EchoInputMessageFactory.getInstance();\r
-        eimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, ei);\r
-        \r
-        BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8);\r
-    }\r
-    \r
-    /**\r
-     * Testing of {@link EchoInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testV10() throws Exception {\r
-        EchoInputBuilder eib = new EchoInputBuilder();\r
-        BufferHelper.setupHeader(eib, EncodeConstants.OF10_VERSION_ID);\r
-        EchoInput ei = eib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        EchoInputMessageFactory eimf = EchoInputMessageFactory.getInstance();\r
-        eimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, ei);\r
-        \r
-        BufferHelper.checkHeaderV10(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Test;
+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.EchoInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class EchoInputMessageFactoryTest {
+
+    private static final byte ECHO_REQUEST_MESSAGE_CODE_TYPE = EchoInputMessageFactory.MESSAGE_TYPE;
+    
+    /**
+     * Testing of {@link EchoInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testV13() throws Exception {
+        EchoInputBuilder eib = new EchoInputBuilder();
+        BufferHelper.setupHeader(eib, EncodeConstants.OF13_VERSION_ID);
+        EchoInput ei = eib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        EchoInputMessageFactory eimf = EchoInputMessageFactory.getInstance();
+        eimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, ei);
+        
+        BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8);
+    }
+    
+    /**
+     * Testing of {@link EchoInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testV10() throws Exception {
+        EchoInputBuilder eib = new EchoInputBuilder();
+        BufferHelper.setupHeader(eib, EncodeConstants.OF10_VERSION_ID);
+        EchoInput ei = eib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        EchoInputMessageFactory eimf = EchoInputMessageFactory.getInstance();
+        eimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, ei);
+        
+        BufferHelper.checkHeaderV10(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8);
+    }
+
+}
index 0052488f184114a8f5f4da317f3b0ef9682c4464..a5a504e1e6cb013bdc7b14a71eeebccfc69d666f 100644 (file)
@@ -1,55 +1,62 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class EchoReplyInputMessageFactoryTest {\r
-\r
-    private static final byte ECHO_REPLY_MESSAGE_CODE_TYPE = EchoReplyInputMessageFactory.MESSAGE_TYPE;\r
-    \r
-    /**\r
-     * Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testV13() throws Exception {\r
-        EchoReplyInputBuilder erib = new EchoReplyInputBuilder();\r
-        BufferHelper.setupHeader(erib, EncodeConstants.OF13_VERSION_ID);\r
-        EchoReplyInput eri = erib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        EchoReplyInputMessageFactory eimf = EchoReplyInputMessageFactory.getInstance();\r
-        eimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, eri);\r
-        \r
-        BufferHelper.checkHeaderV13(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8);\r
-    }\r
-    \r
-    /**\r
-     * Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testV10() throws Exception {\r
-        EchoReplyInputBuilder erib = new EchoReplyInputBuilder();\r
-        BufferHelper.setupHeader(erib, EncodeConstants.OF10_VERSION_ID);\r
-        EchoReplyInput eri = erib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        EchoReplyInputMessageFactory eimf = EchoReplyInputMessageFactory.getInstance();\r
-        eimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, eri);\r
-        \r
-        BufferHelper.checkHeaderV10(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Test;
+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.EchoReplyInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class EchoReplyInputMessageFactoryTest {
+
+    private static final byte ECHO_REPLY_MESSAGE_CODE_TYPE = EchoReplyInputMessageFactory.MESSAGE_TYPE;
+    
+    /**
+     * Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testV13() throws Exception {
+        EchoReplyInputBuilder erib = new EchoReplyInputBuilder();
+        BufferHelper.setupHeader(erib, EncodeConstants.OF13_VERSION_ID);
+        EchoReplyInput eri = erib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        EchoReplyInputMessageFactory eimf = EchoReplyInputMessageFactory.getInstance();
+        eimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, eri);
+        
+        BufferHelper.checkHeaderV13(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8);
+    }
+    
+    /**
+     * Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testV10() throws Exception {
+        EchoReplyInputBuilder erib = new EchoReplyInputBuilder();
+        BufferHelper.setupHeader(erib, EncodeConstants.OF10_VERSION_ID);
+        EchoReplyInput eri = erib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        EchoReplyInputMessageFactory eimf = EchoReplyInputMessageFactory.getInstance();
+        eimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, eri);
+        
+        BufferHelper.checkHeaderV10(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8);
+    }
+
+}
index b75c1c9326544478325aa5cce495bd8a8eddbaeb..ebea19483508b1349b17dee7f657d632e33be695 100644 (file)
@@ -1,51 +1,58 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class ExperimenterInputMessageFactoryTest {\r
-\r
-    private static final byte EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE = ExperimenterInputMessageFactory.MESSAGE_TYPE;\r
-    \r
-    /**\r
-     * Testing of {@link ExperimenterInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void test() throws Exception {\r
-        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setExperimenter(0x0001020304L);\r
-        builder.setExpType(0x0001020304L);\r
-        builder.setData(new byte[] {0x01, 0x02, 0x03});\r
-        ExperimenterInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        ExperimenterInputMessageFactory factory = ExperimenterInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        \r
-        BufferHelper.checkHeaderV13(out, EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE, factory.computeLength(message));\r
-        Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong expType", 0x0001020304L, out.readUnsignedInt());\r
-        Assert.assertArrayEquals("Wrong data", message.getData(), readData(out));\r
-    }\r
-    \r
-    private static byte[] readData(ByteBuf input) {\r
-        byte[] data = new byte[input.readableBytes()]; \r
-        input.readBytes(data);\r
-        return data;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class ExperimenterInputMessageFactoryTest {
+
+    private static final byte EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE = ExperimenterInputMessageFactory.MESSAGE_TYPE;
+    
+    /**
+     * Testing of {@link ExperimenterInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void test() throws Exception {
+        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setExperimenter(0x0001020304L);
+        builder.setExpType(0x0001020304L);
+        builder.setData(new byte[] {0x01, 0x02, 0x03});
+        ExperimenterInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        ExperimenterInputMessageFactory factory = ExperimenterInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        
+        BufferHelper.checkHeaderV13(out, EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE, factory.computeLength(message));
+        Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt());
+        Assert.assertEquals("Wrong expType", 0x0001020304L, out.readUnsignedInt());
+        Assert.assertArrayEquals("Wrong data", message.getData(), readData(out));
+    }
+    
+    private static byte[] readData(ByteBuf input) {
+        byte[] data = new byte[input.readableBytes()]; 
+        input.readBytes(data);
+        return data;
+    }
+}
index 83cb7d285787453091debb94000be810e4004b49..6a9ee5623f1e317d50c563a8f16a8860fff6b0b0 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder;\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.augments.rev131002.TableIdInstruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.InstructionsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;\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.IpEcn;\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.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.oxm.fields.MatchEntries;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntriesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.MatchBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class FlowModInputMessageFactoryTest {\r
-    private static final byte PADDING_IN_FLOW_MOD_MESSAGE = 2;\r
-    \r
-    /**\r
-     * @throws Exception \r
-     * Testing of {@link FlowModInputMessageFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testFlowModInputMessageFactory() throws Exception {\r
-        FlowModInputBuilder builder = new FlowModInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        byte[] cookie = new byte[]{0x00, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01};\r
-        builder.setCookie(new BigInteger(cookie));\r
-        byte[] cookieMask = new byte[]{0x01, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30};\r
-        builder.setCookieMask(new BigInteger(cookieMask));\r
-        builder.setTableId(new TableId(65L));\r
-        builder.setCommand(FlowModCommand.forValue(2));\r
-        builder.setIdleTimeout(12);\r
-        builder.setHardTimeout(0);\r
-        builder.setPriority(126);\r
-        builder.setBufferId(2L);\r
-        builder.setOutPort(new PortNumber(4422L));\r
-        builder.setOutGroup(98L);\r
-        builder.setFlags(new FlowModFlags(true, false, true, false, true));\r
-        MatchBuilder matchBuilder = new MatchBuilder();\r
-        matchBuilder.setType(OxmMatchType.class);\r
-        List<MatchEntries> entries = new ArrayList<>();\r
-        MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder();\r
-        entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
-        entriesBuilder.setOxmMatchField(InPhyPort.class);\r
-        entriesBuilder.setHasMask(false);\r
-        PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder();\r
-        portNumberBuilder.setPortNumber(new PortNumber(42L));\r
-        entriesBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build());\r
-        entries.add(entriesBuilder.build());\r
-        entriesBuilder.setOxmClass(Nxm0Class.class);\r
-        entriesBuilder.setOxmMatchField(IpEcn.class);\r
-        entriesBuilder.setHasMask(false);\r
-        EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder();\r
-        ecnBuilder.setEcn((short) 4);\r
-        entriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build());\r
-        entries.add(entriesBuilder.build());\r
-        matchBuilder.setMatchEntries(entries);\r
-        builder.setMatch(matchBuilder.build());\r
-        List<Instructions> instructions = new ArrayList<>();\r
-        InstructionsBuilder insBuilder = new InstructionsBuilder();\r
-        insBuilder.setType(GotoTable.class);\r
-        TableIdInstructionBuilder idBuilder = new TableIdInstructionBuilder();\r
-        idBuilder.setTableId((short) 43);\r
-        insBuilder.addAugmentation(TableIdInstruction.class, idBuilder.build());\r
-        instructions.add(insBuilder.build());\r
-        insBuilder.setType(WriteMetadata.class);\r
-        MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder();\r
-        metaBuilder.setMetadata(cookie);\r
-        metaBuilder.setMetadataMask(cookieMask);\r
-        insBuilder.addAugmentation(MetadataInstruction.class, metaBuilder.build());\r
-        instructions.add(insBuilder.build());\r
-        builder.setInstructions(instructions);\r
-        FlowModInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        FlowModInputMessageFactory factory = FlowModInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        \r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong cookie", message.getCookie().longValue(), out.readLong());\r
-        Assert.assertEquals("Wrong cookieMask", message.getCookieMask().longValue(), out.readLong());\r
-        Assert.assertEquals("Wrong tableId", message.getTableId().getValue().intValue(), out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong idleTimeOut", message.getIdleTimeout().intValue(), out.readShort());\r
-        Assert.assertEquals("Wrong hardTimeOut", message.getHardTimeout().intValue(), out.readShort());\r
-        Assert.assertEquals("Wrong priority", message.getPriority().intValue(), out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong bufferId", message.getBufferId().intValue(), out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong outPort", message.getOutPort().getValue().intValue(), out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong outGroup", message.getOutGroup().intValue(), out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), createFlowModFlagsFromBitmap(out.readUnsignedShort()));\r
-        out.skipBytes(PADDING_IN_FLOW_MOD_MESSAGE);\r
-        Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort());\r
-        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-        Assert.assertEquals("Wrong oxm class", 0x8000, out.readUnsignedShort());\r
-        short fieldAndMask = out.readUnsignedByte();\r
-        Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);\r
-        Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);\r
-        out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-        Assert.assertEquals("Wrong oxm value", 42, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong oxm class", 0, out.readUnsignedShort());\r
-        fieldAndMask = out.readUnsignedByte();\r
-        Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);\r
-        Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);\r
-        out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-        Assert.assertEquals("Wrong oxm value", 4, out.readUnsignedByte());\r
-        out.skipBytes(7);\r
-        Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort());\r
-        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-        Assert.assertEquals("Wrong instruction value", 43, out.readUnsignedByte());\r
-        out.skipBytes(3);\r
-        Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort());\r
-        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-        out.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
-        byte[] cookieRead = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
-        out.readBytes(cookieRead);\r
-        byte[] cookieMaskRead = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
-        out.readBytes(cookieMaskRead);\r
-        Assert.assertArrayEquals("Wrong metadata", cookie, cookieRead);\r
-        Assert.assertArrayEquals("Wrong metadata mask", cookieMask, cookieMaskRead); \r
-    }\r
-    \r
-    private static FlowModFlags createFlowModFlagsFromBitmap(int input){\r
-        final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) > 0;\r
-        final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0;\r
-        final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0; \r
-        final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) > 0;\r
-        final Boolean _oFPFFNOBYTCOUNTS = (input & (1 << 4)) > 0;\r
-        return new FlowModFlags(_oFPFFCHECKOVERLAP, _oFPFFNOBYTCOUNTS, _oFPFFNOPKTCOUNTS, _oFPFFRESETCOUNTS, _oFPFFSENDFLOWREM);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.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.MetadataInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder;
+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.TableIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;
+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.oxm.fields.MatchEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntriesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.MatchBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class FlowModInputMessageFactoryTest {
+    private static final byte PADDING_IN_FLOW_MOD_MESSAGE = 2;
+    
+    /**
+     * @throws Exception 
+     * Testing of {@link FlowModInputMessageFactory} for correct translation from POJO
+     */
+    @Test
+    public void testFlowModInputMessageFactory() throws Exception {
+        FlowModInputBuilder builder = new FlowModInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        byte[] cookie = new byte[]{0x00, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01};
+        builder.setCookie(new BigInteger(cookie));
+        byte[] cookieMask = new byte[]{0x01, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30};
+        builder.setCookieMask(new BigInteger(cookieMask));
+        builder.setTableId(new TableId(65L));
+        builder.setCommand(FlowModCommand.forValue(2));
+        builder.setIdleTimeout(12);
+        builder.setHardTimeout(0);
+        builder.setPriority(126);
+        builder.setBufferId(2L);
+        builder.setOutPort(new PortNumber(4422L));
+        builder.setOutGroup(98L);
+        builder.setFlags(new FlowModFlags(true, false, true, false, true));
+        MatchBuilder matchBuilder = new MatchBuilder();
+        matchBuilder.setType(OxmMatchType.class);
+        List<MatchEntries> entries = new ArrayList<>();
+        MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(InPhyPort.class);
+        entriesBuilder.setHasMask(false);
+        PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder();
+        portNumberBuilder.setPortNumber(new PortNumber(42L));
+        entriesBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build());
+        entries.add(entriesBuilder.build());
+        entriesBuilder.setOxmClass(Nxm0Class.class);
+        entriesBuilder.setOxmMatchField(IpEcn.class);
+        entriesBuilder.setHasMask(false);
+        EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder();
+        ecnBuilder.setEcn((short) 4);
+        entriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build());
+        entries.add(entriesBuilder.build());
+        matchBuilder.setMatchEntries(entries);
+        builder.setMatch(matchBuilder.build());
+        List<Instructions> instructions = new ArrayList<>();
+        InstructionsBuilder insBuilder = new InstructionsBuilder();
+        insBuilder.setType(GotoTable.class);
+        TableIdInstructionBuilder idBuilder = new TableIdInstructionBuilder();
+        idBuilder.setTableId((short) 43);
+        insBuilder.addAugmentation(TableIdInstruction.class, idBuilder.build());
+        instructions.add(insBuilder.build());
+        insBuilder.setType(WriteMetadata.class);
+        MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder();
+        metaBuilder.setMetadata(cookie);
+        metaBuilder.setMetadataMask(cookieMask);
+        insBuilder.addAugmentation(MetadataInstruction.class, metaBuilder.build());
+        instructions.add(insBuilder.build());
+        builder.setInstructions(instructions);
+        FlowModInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        FlowModInputMessageFactory factory = FlowModInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong cookie", message.getCookie().longValue(), out.readLong());
+        Assert.assertEquals("Wrong cookieMask", message.getCookieMask().longValue(), out.readLong());
+        Assert.assertEquals("Wrong tableId", message.getTableId().getValue().intValue(), out.readUnsignedByte());
+        Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedByte());
+        Assert.assertEquals("Wrong idleTimeOut", message.getIdleTimeout().intValue(), out.readShort());
+        Assert.assertEquals("Wrong hardTimeOut", message.getHardTimeout().intValue(), out.readShort());
+        Assert.assertEquals("Wrong priority", message.getPriority().intValue(), out.readUnsignedShort());
+        Assert.assertEquals("Wrong bufferId", message.getBufferId().intValue(), out.readUnsignedInt());
+        Assert.assertEquals("Wrong outPort", message.getOutPort().getValue().intValue(), out.readUnsignedInt());
+        Assert.assertEquals("Wrong outGroup", message.getOutGroup().intValue(), out.readUnsignedInt());
+        Assert.assertEquals("Wrong flags", message.getFlags(), createFlowModFlagsFromBitmap(out.readUnsignedShort()));
+        out.skipBytes(PADDING_IN_FLOW_MOD_MESSAGE);
+        Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort());
+        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        Assert.assertEquals("Wrong oxm class", 0x8000, out.readUnsignedShort());
+        short fieldAndMask = out.readUnsignedByte();
+        Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
+        Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);
+        out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+        Assert.assertEquals("Wrong oxm value", 42, out.readUnsignedInt());
+        Assert.assertEquals("Wrong oxm class", 0, out.readUnsignedShort());
+        fieldAndMask = out.readUnsignedByte();
+        Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
+        Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);
+        out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+        Assert.assertEquals("Wrong oxm value", 4, out.readUnsignedByte());
+        out.skipBytes(7);
+        Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort());
+        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        Assert.assertEquals("Wrong instruction value", 43, out.readUnsignedByte());
+        out.skipBytes(3);
+        Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort());
+        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        out.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES);
+        byte[] cookieRead = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        out.readBytes(cookieRead);
+        byte[] cookieMaskRead = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        out.readBytes(cookieMaskRead);
+        Assert.assertArrayEquals("Wrong metadata", cookie, cookieRead);
+        Assert.assertArrayEquals("Wrong metadata mask", cookieMask, cookieMaskRead); 
+    }
+    
+    private static FlowModFlags createFlowModFlagsFromBitmap(int input){
+        final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) > 0;
+        final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0;
+        final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0; 
+        final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) > 0;
+        final Boolean _oFPFFNOBYTCOUNTS = (input & (1 << 4)) > 0;
+        return new FlowModFlags(_oFPFFCHECKOVERLAP, _oFPFFNOBYTCOUNTS, _oFPFFNOPKTCOUNTS, _oFPFFRESETCOUNTS, _oFPFFSENDFLOWREM);
+    }
+
+}
index 44bbe557e300a56ba1110fdb784d59624372d387..0c3c5a62667f547afab0b6482689fc9779c9ff8f 100644 (file)
@@ -1,55 +1,62 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class GetConfigInputMessageFactoryTest {\r
-\r
-    private static final byte GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE = GetConfigInputMessageFactory.MESSAGE_TYPE;\r
-    \r
-    /**\r
-     * Testing of {@link GetConfigInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testV13() throws Exception {\r
-        GetConfigInputBuilder gcib = new GetConfigInputBuilder();\r
-        BufferHelper.setupHeader(gcib, EncodeConstants.OF13_VERSION_ID);\r
-        GetConfigInput gci = gcib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        GetConfigInputMessageFactory gcimf = GetConfigInputMessageFactory.getInstance();\r
-        gcimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, gci);\r
-        \r
-        BufferHelper.checkHeaderV13(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8);\r
-    }\r
-    \r
-    /**\r
-     * Testing of {@link GetConfigInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testV10() throws Exception {\r
-        GetConfigInputBuilder gcib = new GetConfigInputBuilder();\r
-        BufferHelper.setupHeader(gcib, EncodeConstants.OF10_VERSION_ID);\r
-        GetConfigInput gci = gcib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        GetConfigInputMessageFactory gcimf = GetConfigInputMessageFactory.getInstance();\r
-        gcimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, gci);\r
-        \r
-        BufferHelper.checkHeaderV10(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Test;
+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.GetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class GetConfigInputMessageFactoryTest {
+
+    private static final byte GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE = GetConfigInputMessageFactory.MESSAGE_TYPE;
+    
+    /**
+     * Testing of {@link GetConfigInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testV13() throws Exception {
+        GetConfigInputBuilder gcib = new GetConfigInputBuilder();
+        BufferHelper.setupHeader(gcib, EncodeConstants.OF13_VERSION_ID);
+        GetConfigInput gci = gcib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        GetConfigInputMessageFactory gcimf = GetConfigInputMessageFactory.getInstance();
+        gcimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, gci);
+        
+        BufferHelper.checkHeaderV13(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8);
+    }
+    
+    /**
+     * Testing of {@link GetConfigInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testV10() throws Exception {
+        GetConfigInputBuilder gcib = new GetConfigInputBuilder();
+        BufferHelper.setupHeader(gcib, EncodeConstants.OF10_VERSION_ID);
+        GetConfigInput gci = gcib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        GetConfigInputMessageFactory gcimf = GetConfigInputMessageFactory.getInstance();
+        gcimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, gci);
+        
+        BufferHelper.checkHeaderV10(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8);
+    }
+
+}
index 7ebf90812d9e35e0326c56fdfab62889e8240531..a99dab67b64cfda8e3e73c1afbded1208a9b5e8a 100644 (file)
@@ -1,54 +1,61 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class GetFeaturesInputMessageFactoryTest {\r
-\r
-    private static final byte FEATURES_REQUEST_MESSAGE_CODE_TYPE = GetFeaturesInputMessageFactory.MESSAGE_TYPE;\r
-    \r
-    /**\r
-     * Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testV13() throws Exception {\r
-        GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();\r
-        BufferHelper.setupHeader(gfib, EncodeConstants.OF13_VERSION_ID);\r
-        GetFeaturesInput gfi = gfib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        GetFeaturesInputMessageFactory gfimf = GetFeaturesInputMessageFactory.getInstance();\r
-        gfimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, gfi);\r
-        \r
-        BufferHelper.checkHeaderV13(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);\r
-    }\r
-\r
-    /**\r
-     * Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testV10() throws Exception {\r
-        GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();\r
-        BufferHelper.setupHeader(gfib, EncodeConstants.OF10_VERSION_ID);\r
-        GetFeaturesInput gfi = gfib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        GetFeaturesInputMessageFactory gfimf = GetFeaturesInputMessageFactory.getInstance();\r
-        gfimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, gfi);\r
-        \r
-        BufferHelper.checkHeaderV10(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Test;
+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.GetFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class GetFeaturesInputMessageFactoryTest {
+
+    private static final byte FEATURES_REQUEST_MESSAGE_CODE_TYPE = GetFeaturesInputMessageFactory.MESSAGE_TYPE;
+    
+    /**
+     * Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testV13() throws Exception {
+        GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();
+        BufferHelper.setupHeader(gfib, EncodeConstants.OF13_VERSION_ID);
+        GetFeaturesInput gfi = gfib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        GetFeaturesInputMessageFactory gfimf = GetFeaturesInputMessageFactory.getInstance();
+        gfimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, gfi);
+        
+        BufferHelper.checkHeaderV13(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);
+    }
+
+    /**
+     * Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testV10() throws Exception {
+        GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder();
+        BufferHelper.setupHeader(gfib, EncodeConstants.OF10_VERSION_ID);
+        GetFeaturesInput gfi = gfib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        GetFeaturesInputMessageFactory gfimf = GetFeaturesInputMessageFactory.getInstance();
+        gfimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, gfi);
+        
+        BufferHelper.checkHeaderV10(out, FEATURES_REQUEST_MESSAGE_CODE_TYPE, 8);
+    }
+}
index 974934fa3d40a6f31246e15b731099acd8805317..77ab3af65b3faa005284a5101965f636db95d5aa 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.serialization.factories;
 
 import io.netty.buffer.ByteBuf;
index ddc5ebd42695b375ccd2f139c9f1ee39165425eb..0f4fb9f48fd99065ed6fa60f3774fb9e38359b10 100644 (file)
@@ -1,38 +1,45 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInputBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class GetaAsyncRequestMessageFactoryTest {\r
-    private static final byte MESSAGE_TYPE = 26;\r
-    private static final int MESSAGE_LENGTH = 8;\r
-    \r
-    /**\r
-     * Testing of {@link GetAsyncRequestMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testGetAsyncReques() throws Exception {\r
-        GetAsyncInputBuilder builder = new GetAsyncInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        GetAsyncInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        GetAsyncRequestMessageFactory factory = GetAsyncRequestMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        \r
-        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInputBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class GetaAsyncRequestMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 26;
+    private static final int MESSAGE_LENGTH = 8;
+    
+    /**
+     * Testing of {@link GetAsyncRequestMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testGetAsyncReques() throws Exception {
+        GetAsyncInputBuilder builder = new GetAsyncInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        GetAsyncInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        GetAsyncRequestMessageFactory factory = GetAsyncRequestMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
+    }
+}
index dbfada40b455d3af66eca6c4d1f9c8d287cb6993..2e51815c5f84ef9d47053f0be6edc98d3b462859 100644 (file)
@@ -1,84 +1,91 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsListBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- *\r
- */\r
-public class GroupModInputMessageFactoryTest {\r
-    private static final byte PADDING_IN_GROUP_MOD_MESSAGE = 1;\r
-    \r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link GroupModInputMessageFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testGroupModInputMessage() throws Exception {\r
-        GroupModInputBuilder builder = new GroupModInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setCommand(GroupModCommand.forValue(2));\r
-        builder.setType(GroupType.forValue(3));\r
-        builder.setGroupId(new GroupId(256L));\r
-        List<BucketsList> exp = createBucketsList();\r
-        builder.setBucketsList(exp);\r
-        GroupModInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        GroupModInputMessageFactory factory = GroupModInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        \r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedByte());\r
-        out.skipBytes(PADDING_IN_GROUP_MOD_MESSAGE);\r
-        Assert.assertEquals("Wrong groupId", message.getGroupId().getValue().intValue(), out.readUnsignedInt());\r
-        List<BucketsList> rec = createBucketsListFromBufer(out);\r
-        Assert.assertArrayEquals("Wrong bucketList", exp.toArray(), rec.toArray());\r
-    }\r
-    \r
-    private static List<BucketsList> createBucketsList(){\r
-        List<BucketsList> bucketsList = new ArrayList<>();\r
-        BucketsListBuilder bucketsBuilder = new BucketsListBuilder();\r
-        BucketsList bucket;\r
-        bucketsBuilder.setWeight(10);\r
-        bucketsBuilder.setWatchPort(new PortNumber(65L));\r
-        bucketsBuilder.setWatchGroup(22L);\r
-        bucket = bucketsBuilder.build();\r
-        bucketsList.add(bucket);\r
-        return bucketsList;\r
-    }\r
-    \r
-    private static List<BucketsList> createBucketsListFromBufer(ByteBuf out){\r
-        List<BucketsList> bucketsList = new ArrayList<>();\r
-        BucketsListBuilder bucketsBuilder = new BucketsListBuilder();\r
-        BucketsList bucket;\r
-        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-        bucketsBuilder.setWeight(out.readUnsignedShort());\r
-        bucketsBuilder.setWatchPort(new PortNumber(out.readUnsignedInt()));\r
-        bucketsBuilder.setWatchGroup(out.readUnsignedInt());\r
-        out.skipBytes(4);\r
-        bucket = bucketsBuilder.build();\r
-        bucketsList.add(bucket);\r
-        return bucketsList;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsListBuilder;
+
+/**
+ * @author timotej.kubas
+ *
+ */
+public class GroupModInputMessageFactoryTest {
+    private static final byte PADDING_IN_GROUP_MOD_MESSAGE = 1;
+    
+    /**
+     * @throws Exception
+     * Testing of {@link GroupModInputMessageFactory} for correct translation from POJO
+     */
+    @Test
+    public void testGroupModInputMessage() throws Exception {
+        GroupModInputBuilder builder = new GroupModInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setCommand(GroupModCommand.forValue(2));
+        builder.setType(GroupType.forValue(3));
+        builder.setGroupId(new GroupId(256L));
+        List<BucketsList> exp = createBucketsList();
+        builder.setBucketsList(exp);
+        GroupModInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        GroupModInputMessageFactory factory = GroupModInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedShort());
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedByte());
+        out.skipBytes(PADDING_IN_GROUP_MOD_MESSAGE);
+        Assert.assertEquals("Wrong groupId", message.getGroupId().getValue().intValue(), out.readUnsignedInt());
+        List<BucketsList> rec = createBucketsListFromBufer(out);
+        Assert.assertArrayEquals("Wrong bucketList", exp.toArray(), rec.toArray());
+    }
+    
+    private static List<BucketsList> createBucketsList(){
+        List<BucketsList> bucketsList = new ArrayList<>();
+        BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
+        BucketsList bucket;
+        bucketsBuilder.setWeight(10);
+        bucketsBuilder.setWatchPort(new PortNumber(65L));
+        bucketsBuilder.setWatchGroup(22L);
+        bucket = bucketsBuilder.build();
+        bucketsList.add(bucket);
+        return bucketsList;
+    }
+    
+    private static List<BucketsList> createBucketsListFromBufer(ByteBuf out){
+        List<BucketsList> bucketsList = new ArrayList<>();
+        BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
+        BucketsList bucket;
+        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        bucketsBuilder.setWeight(out.readUnsignedShort());
+        bucketsBuilder.setWatchPort(new PortNumber(out.readUnsignedInt()));
+        bucketsBuilder.setWatchGroup(out.readUnsignedInt());
+        out.skipBytes(4);
+        bucket = bucketsBuilder.build();
+        bucketsList.add(bucket);
+        return bucketsList;
+    }
+}
index aa2712b67cc753fb06a82e7ff2ede02c724ee105..888476d4df9c90ff61f4ee622210a1c3a69294a1 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class HelloInputMessageFactoryTest {\r
-\r
-    private static final Logger LOGGER = LoggerFactory.getLogger(HelloInputMessageFactoryTest.class);\r
-    \r
-    /**\r
-     * Testing of {@link HelloInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testWithoutElementsSet() throws Exception {\r
-        HelloInputBuilder hib = new HelloInputBuilder();\r
-        BufferHelper.setupHeader(hib, EncodeConstants.OF13_VERSION_ID);\r
-        HelloInput hi = hib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        HelloInputMessageFactory himf = HelloInputMessageFactory.getInstance();\r
-        himf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, hi);\r
-        \r
-        BufferHelper.checkHeaderV13(out, himf.getMessageType(), himf.computeLength(hi));\r
-    }\r
-    \r
-    /**\r
-     * Testing of {@link HelloInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testWith4BitVersionBitmap() throws Exception {\r
-        int lengthOfBitmap = 4;\r
-        HelloInputBuilder builder = new HelloInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        List<Elements> expectedElement = createElement(lengthOfBitmap);\r
-        builder.setElements(expectedElement);\r
-        HelloInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        HelloInputMessageFactory factory = HelloInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out));\r
-        \r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Elements element = readElement(out).get(0);\r
-        Assert.assertEquals("Wrong element type", expectedElement.get(0).getType(), element.getType());\r
-        Elements comparation = createComparationElement(lengthOfBitmap).get(0);\r
-        Assert.assertArrayEquals("Wrong element bitmap", comparation.getVersionBitmap().toArray(), element.getVersionBitmap().toArray());\r
-    }\r
-    \r
-    /**\r
-     * Testing of {@link HelloInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testWith64BitVersionBitmap() throws Exception {\r
-        int lengthOfBitmap = 64;\r
-        HelloInputBuilder builder = new HelloInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        List<Elements> expectedElement = createElement(lengthOfBitmap);\r
-        builder.setElements(expectedElement);\r
-        HelloInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        HelloInputMessageFactory factory = HelloInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out));\r
-        \r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Elements element = readElement(out).get(0);\r
-        Assert.assertEquals("Wrong element type", expectedElement.get(0).getType(), element.getType());\r
-        Elements comparation = createComparationElement(lengthOfBitmap).get(0);\r
-        Assert.assertArrayEquals("Wrong element bitmap", comparation.getVersionBitmap().toArray(), element.getVersionBitmap().toArray());\r
-    }\r
-    \r
-    private static List<Elements> createElement(int lengthOfBitmap) {\r
-        ElementsBuilder elementsBuilder = new ElementsBuilder();\r
-        List<Elements> elementsList = new ArrayList<>();\r
-        List<Boolean> booleanList = new ArrayList<>();\r
-        for (int i = 0; i < lengthOfBitmap; i++) {\r
-            booleanList.add(true);\r
-        }\r
-        elementsBuilder.setType(HelloElementType.forValue(1));\r
-        elementsBuilder.setVersionBitmap(booleanList);\r
-        elementsList.add(elementsBuilder.build());\r
-        return elementsList;\r
-    }\r
-    \r
-    private static List<Elements> createComparationElement(int lengthOfBitmap) {\r
-        ElementsBuilder elementsBuilder = new ElementsBuilder();\r
-        List<Elements> elementsList = new ArrayList<>();\r
-        List<Boolean> booleanList = new ArrayList<>();\r
-        for (int i = 0; i < lengthOfBitmap; i++) {\r
-            booleanList.add(true);\r
-        }\r
-        if ((lengthOfBitmap % Integer.SIZE) != 0) {\r
-            for (int i = 0; i < (Integer.SIZE - (lengthOfBitmap % Integer.SIZE)); i++) {\r
-                booleanList.add(false);\r
-            }\r
-        }\r
-        LOGGER.debug("boolsize " + booleanList.size());\r
-        elementsBuilder.setType(HelloElementType.forValue(1));\r
-        elementsBuilder.setVersionBitmap(booleanList);\r
-        elementsList.add(elementsBuilder.build());\r
-        return elementsList;\r
-    }\r
-    \r
-    private static List<Elements> readElement(ByteBuf input) {\r
-        List<Elements> elementsList = new ArrayList<>();\r
-        while (input.readableBytes() > 0) {\r
-            ElementsBuilder elementsBuilder = new ElementsBuilder();\r
-            int type = input.readUnsignedShort();\r
-            int elementLength = input.readUnsignedShort();\r
-            if (type == HelloElementType.VERSIONBITMAP.getIntValue()) {\r
-                elementsBuilder.setType(HelloElementType.forValue(type));\r
-                int[] versionBitmap = new int[(elementLength - HelloInputMessageFactory.HELLO_ELEMENT_HEADER_SIZE) / 4];\r
-                for (int i = 0; i < versionBitmap.length; i++) {\r
-                    versionBitmap[i] = (int) input.readUnsignedInt();\r
-                }\r
-                elementsBuilder.setVersionBitmap(readVersionBitmap(versionBitmap));\r
-                int paddingRemainder = elementLength % EncodeConstants.PADDING;\r
-                if (paddingRemainder != 0) {\r
-                    input.readBytes(EncodeConstants.PADDING - paddingRemainder);\r
-                }\r
-            }\r
-            elementsList.add(elementsBuilder.build());\r
-        }\r
-        return elementsList;\r
-    }\r
-    \r
-    private static List<Boolean> readVersionBitmap(int[] input){\r
-        List<Boolean> versionBitmapList = new ArrayList<>();\r
-        for (int i = 0; i < input.length; i++) {\r
-            int mask = input[i];\r
-            for (int j = 0; j < Integer.SIZE; j++) {\r
-                    versionBitmapList.add((mask & (1<<j)) != 0);\r
-            }\r
-        }\r
-        return versionBitmapList;\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+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.HelloInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class HelloInputMessageFactoryTest {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(HelloInputMessageFactoryTest.class);
+    
+    /**
+     * Testing of {@link HelloInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testWithoutElementsSet() throws Exception {
+        HelloInputBuilder hib = new HelloInputBuilder();
+        BufferHelper.setupHeader(hib, EncodeConstants.OF13_VERSION_ID);
+        HelloInput hi = hib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        HelloInputMessageFactory himf = HelloInputMessageFactory.getInstance();
+        himf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, hi);
+        
+        BufferHelper.checkHeaderV13(out, himf.getMessageType(), himf.computeLength(hi));
+    }
+    
+    /**
+     * Testing of {@link HelloInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testWith4BitVersionBitmap() throws Exception {
+        int lengthOfBitmap = 4;
+        HelloInputBuilder builder = new HelloInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        List<Elements> expectedElement = createElement(lengthOfBitmap);
+        builder.setElements(expectedElement);
+        HelloInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        HelloInputMessageFactory factory = HelloInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out));
+        
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Elements element = readElement(out).get(0);
+        Assert.assertEquals("Wrong element type", expectedElement.get(0).getType(), element.getType());
+        Elements comparation = createComparationElement(lengthOfBitmap).get(0);
+        Assert.assertArrayEquals("Wrong element bitmap", comparation.getVersionBitmap().toArray(), element.getVersionBitmap().toArray());
+    }
+    
+    /**
+     * Testing of {@link HelloInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testWith64BitVersionBitmap() throws Exception {
+        int lengthOfBitmap = 64;
+        HelloInputBuilder builder = new HelloInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        List<Elements> expectedElement = createElement(lengthOfBitmap);
+        builder.setElements(expectedElement);
+        HelloInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        HelloInputMessageFactory factory = HelloInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out));
+        
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Elements element = readElement(out).get(0);
+        Assert.assertEquals("Wrong element type", expectedElement.get(0).getType(), element.getType());
+        Elements comparation = createComparationElement(lengthOfBitmap).get(0);
+        Assert.assertArrayEquals("Wrong element bitmap", comparation.getVersionBitmap().toArray(), element.getVersionBitmap().toArray());
+    }
+    
+    private static List<Elements> createElement(int lengthOfBitmap) {
+        ElementsBuilder elementsBuilder = new ElementsBuilder();
+        List<Elements> elementsList = new ArrayList<>();
+        List<Boolean> booleanList = new ArrayList<>();
+        for (int i = 0; i < lengthOfBitmap; i++) {
+            booleanList.add(true);
+        }
+        elementsBuilder.setType(HelloElementType.forValue(1));
+        elementsBuilder.setVersionBitmap(booleanList);
+        elementsList.add(elementsBuilder.build());
+        return elementsList;
+    }
+    
+    private static List<Elements> createComparationElement(int lengthOfBitmap) {
+        ElementsBuilder elementsBuilder = new ElementsBuilder();
+        List<Elements> elementsList = new ArrayList<>();
+        List<Boolean> booleanList = new ArrayList<>();
+        for (int i = 0; i < lengthOfBitmap; i++) {
+            booleanList.add(true);
+        }
+        if ((lengthOfBitmap % Integer.SIZE) != 0) {
+            for (int i = 0; i < (Integer.SIZE - (lengthOfBitmap % Integer.SIZE)); i++) {
+                booleanList.add(false);
+            }
+        }
+        LOGGER.debug("boolsize " + booleanList.size());
+        elementsBuilder.setType(HelloElementType.forValue(1));
+        elementsBuilder.setVersionBitmap(booleanList);
+        elementsList.add(elementsBuilder.build());
+        return elementsList;
+    }
+    
+    private static List<Elements> readElement(ByteBuf input) {
+        List<Elements> elementsList = new ArrayList<>();
+        while (input.readableBytes() > 0) {
+            ElementsBuilder elementsBuilder = new ElementsBuilder();
+            int type = input.readUnsignedShort();
+            int elementLength = input.readUnsignedShort();
+            if (type == HelloElementType.VERSIONBITMAP.getIntValue()) {
+                elementsBuilder.setType(HelloElementType.forValue(type));
+                int[] versionBitmap = new int[(elementLength - HelloInputMessageFactory.HELLO_ELEMENT_HEADER_SIZE) / 4];
+                for (int i = 0; i < versionBitmap.length; i++) {
+                    versionBitmap[i] = (int) input.readUnsignedInt();
+                }
+                elementsBuilder.setVersionBitmap(readVersionBitmap(versionBitmap));
+                int paddingRemainder = elementLength % EncodeConstants.PADDING;
+                if (paddingRemainder != 0) {
+                    input.readBytes(EncodeConstants.PADDING - paddingRemainder);
+                }
+            }
+            elementsList.add(elementsBuilder.build());
+        }
+        return elementsList;
+    }
+    
+    private static List<Boolean> readVersionBitmap(int[] input){
+        List<Boolean> versionBitmapList = new ArrayList<>();
+        for (int i = 0; i < input.length; i++) {
+            int mask = input[i];
+            for (int j = 0; j < Integer.SIZE; j++) {
+                    versionBitmapList.add((mask & (1<<j)) != 0);
+            }
+        }
+        return versionBitmapList;
+    }
+
+}
index 16a1e1bb8bfd0af62633c75484cf55142fa7db77..15cbab1aacf263962f0882b146a05dfcbb96d7d3 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import junit.framework.Assert;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class MeterModInputMessageFactoryTest {\r
-\r
-    /**\r
-     * @throws Exception \r
-     * Testing of {@link MeterModInputMessageFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMeterModInputMessage() throws Exception {\r
-        MeterModInputBuilder builder = new MeterModInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setCommand(MeterModCommand.forValue(1));\r
-        builder.setFlags(new MeterFlags(false, true, true, false));\r
-        builder.setMeterId(new MeterId(2248L));\r
-        builder.setBands(createBandsList());\r
-        MeterModInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MeterModInputMessageFactory factory = MeterModInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        \r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), 64);\r
-        Assert.assertEquals("Wrong meterModCommand", message.getCommand().getIntValue(), out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong meterFlags", message.getFlags(), decodeMeterModFlags(out.readShort()));\r
-        Assert.assertEquals("Wrong meterId", message.getMeterId().getValue().intValue(), out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong bands", message.getBands(), decodeBandsList(out));\r
-    }\r
-    \r
-    private static MeterFlags decodeMeterModFlags(short input){\r
-        final Boolean _oFPMFKBPS = (input & (1 << 0)) > 0;\r
-        final Boolean _oFPMFPKTPS = (input & (1 << 1)) > 0;\r
-        final Boolean _oFPMFBURST = (input & (1 << 2)) > 0; \r
-        final Boolean _oFPMFSTATS = (input & (1 << 3)) > 0;\r
-        return new MeterFlags(_oFPMFBURST, _oFPMFKBPS, _oFPMFPKTPS, _oFPMFSTATS);\r
-    }\r
-    \r
-    private static List<Bands> createBandsList(){\r
-        List<Bands> bandsList = new ArrayList<>();\r
-        BandsBuilder bandsBuilder = new BandsBuilder();\r
-        MeterBandDropBuilder dropBand = new MeterBandDropBuilder();\r
-        dropBand.setType(MeterBandType.OFPMBTDROP);\r
-        dropBand.setRate(1L);\r
-        dropBand.setBurstSize(2L);\r
-        bandsList.add(bandsBuilder.setMeterBand(dropBand.build()).build());\r
-        MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();\r
-        dscpRemarkBand.setType(MeterBandType.OFPMBTDSCPREMARK);\r
-        dscpRemarkBand.setRate(1L);\r
-        dscpRemarkBand.setBurstSize(2L);\r
-        dscpRemarkBand.setPrecLevel((short) 3);\r
-        bandsList.add(bandsBuilder.setMeterBand(dscpRemarkBand.build()).build());\r
-        MeterBandExperimenterBuilder experimenterBand = new MeterBandExperimenterBuilder();\r
-        experimenterBand.setType(MeterBandType.OFPMBTEXPERIMENTER);\r
-        experimenterBand.setRate(1L);\r
-        experimenterBand.setBurstSize(2L);\r
-        experimenterBand.setExperimenter(4L);\r
-        bandsList.add(bandsBuilder.setMeterBand(experimenterBand.build()).build());\r
-        return bandsList;\r
-    }\r
-    \r
-    private static List<Bands> decodeBandsList(ByteBuf input){\r
-        List<Bands> bandsList = new ArrayList<>();\r
-        BandsBuilder bandsBuilder = new BandsBuilder();\r
-        MeterBandDropBuilder dropBand = new MeterBandDropBuilder();\r
-        dropBand.setType(MeterBandType.forValue(input.readUnsignedShort()));\r
-        input.skipBytes(Short.SIZE/Byte.SIZE);\r
-        dropBand.setRate(input.readUnsignedInt());\r
-        dropBand.setBurstSize(input.readUnsignedInt());\r
-        input.skipBytes(4);\r
-        bandsList.add(bandsBuilder.setMeterBand(dropBand.build()).build());\r
-        MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();\r
-        dscpRemarkBand.setType(MeterBandType.forValue(input.readUnsignedShort()));\r
-        input.skipBytes(Short.SIZE/Byte.SIZE);\r
-        dscpRemarkBand.setRate(input.readUnsignedInt());\r
-        dscpRemarkBand.setBurstSize(input.readUnsignedInt());\r
-        dscpRemarkBand.setPrecLevel(input.readUnsignedByte());\r
-        input.skipBytes(3);\r
-        bandsList.add(bandsBuilder.setMeterBand(dscpRemarkBand.build()).build());\r
-        MeterBandExperimenterBuilder experimenterBand = new MeterBandExperimenterBuilder();\r
-        experimenterBand.setType(MeterBandType.forValue(input.readUnsignedShort()));\r
-        input.skipBytes(Short.SIZE/Byte.SIZE);\r
-        experimenterBand.setRate(input.readUnsignedInt());\r
-        experimenterBand.setBurstSize(input.readUnsignedInt());\r
-        experimenterBand.setExperimenter(input.readUnsignedInt());\r
-        bandsList.add(bandsBuilder.setMeterBand(experimenterBand.build()).build());\r
-        return bandsList;\r
-    }\r
-    \r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class MeterModInputMessageFactoryTest {
+
+    /**
+     * @throws Exception 
+     * Testing of {@link MeterModInputMessageFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMeterModInputMessage() throws Exception {
+        MeterModInputBuilder builder = new MeterModInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setCommand(MeterModCommand.forValue(1));
+        builder.setFlags(new MeterFlags(false, true, true, false));
+        builder.setMeterId(new MeterId(2248L));
+        builder.setBands(createBandsList());
+        MeterModInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MeterModInputMessageFactory factory = MeterModInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), 64);
+        Assert.assertEquals("Wrong meterModCommand", message.getCommand().getIntValue(), out.readUnsignedShort());
+        Assert.assertEquals("Wrong meterFlags", message.getFlags(), decodeMeterModFlags(out.readShort()));
+        Assert.assertEquals("Wrong meterId", message.getMeterId().getValue().intValue(), out.readUnsignedInt());
+        Assert.assertEquals("Wrong bands", message.getBands(), decodeBandsList(out));
+    }
+    
+    private static MeterFlags decodeMeterModFlags(short input){
+        final Boolean _oFPMFKBPS = (input & (1 << 0)) > 0;
+        final Boolean _oFPMFPKTPS = (input & (1 << 1)) > 0;
+        final Boolean _oFPMFBURST = (input & (1 << 2)) > 0; 
+        final Boolean _oFPMFSTATS = (input & (1 << 3)) > 0;
+        return new MeterFlags(_oFPMFBURST, _oFPMFKBPS, _oFPMFPKTPS, _oFPMFSTATS);
+    }
+    
+    private static List<Bands> createBandsList(){
+        List<Bands> bandsList = new ArrayList<>();
+        BandsBuilder bandsBuilder = new BandsBuilder();
+        MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
+        dropBand.setType(MeterBandType.OFPMBTDROP);
+        dropBand.setRate(1L);
+        dropBand.setBurstSize(2L);
+        bandsList.add(bandsBuilder.setMeterBand(dropBand.build()).build());
+        MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
+        dscpRemarkBand.setType(MeterBandType.OFPMBTDSCPREMARK);
+        dscpRemarkBand.setRate(1L);
+        dscpRemarkBand.setBurstSize(2L);
+        dscpRemarkBand.setPrecLevel((short) 3);
+        bandsList.add(bandsBuilder.setMeterBand(dscpRemarkBand.build()).build());
+        MeterBandExperimenterBuilder experimenterBand = new MeterBandExperimenterBuilder();
+        experimenterBand.setType(MeterBandType.OFPMBTEXPERIMENTER);
+        experimenterBand.setRate(1L);
+        experimenterBand.setBurstSize(2L);
+        experimenterBand.setExperimenter(4L);
+        bandsList.add(bandsBuilder.setMeterBand(experimenterBand.build()).build());
+        return bandsList;
+    }
+    
+    private static List<Bands> decodeBandsList(ByteBuf input){
+        List<Bands> bandsList = new ArrayList<>();
+        BandsBuilder bandsBuilder = new BandsBuilder();
+        MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
+        dropBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
+        input.skipBytes(Short.SIZE/Byte.SIZE);
+        dropBand.setRate(input.readUnsignedInt());
+        dropBand.setBurstSize(input.readUnsignedInt());
+        input.skipBytes(4);
+        bandsList.add(bandsBuilder.setMeterBand(dropBand.build()).build());
+        MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
+        dscpRemarkBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
+        input.skipBytes(Short.SIZE/Byte.SIZE);
+        dscpRemarkBand.setRate(input.readUnsignedInt());
+        dscpRemarkBand.setBurstSize(input.readUnsignedInt());
+        dscpRemarkBand.setPrecLevel(input.readUnsignedByte());
+        input.skipBytes(3);
+        bandsList.add(bandsBuilder.setMeterBand(dscpRemarkBand.build()).build());
+        MeterBandExperimenterBuilder experimenterBand = new MeterBandExperimenterBuilder();
+        experimenterBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
+        input.skipBytes(Short.SIZE/Byte.SIZE);
+        experimenterBand.setRate(input.readUnsignedInt());
+        experimenterBand.setBurstSize(input.readUnsignedInt());
+        experimenterBand.setExperimenter(input.readUnsignedInt());
+        bandsList.add(bandsBuilder.setMeterBand(experimenterBand.build()).build());
+        return bandsList;
+    }
+    
+}
index e725e64b35c3bc47f40d0d859cd06a05cee72455..3b949bc3703596add1b78872953ff926f28ac70c 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import junit.framework.Assert;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregate;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlow;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroup;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features.TableFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features.TableFeaturesBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class MultipartRequestInputFactoryTest {\r
-    private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = 4;\r
-\r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMultipartRequestInputFactory() throws Exception {\r
-        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setType(MultipartType.forValue(1));\r
-        builder.setFlags(new MultipartRequestFlags(true));\r
-        builder.setMultipartRequestBody(createRequestFlow());\r
-        MultipartRequestInput message = builder.build();\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));\r
-        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);\r
-        Assert.assertEquals("Wrong flow", message.getMultipartRequestBody(), decodeRequestFlow(out));\r
-    }\r
-\r
-    private static MultipartRequestFlow createRequestFlow() {\r
-        MultipartRequestFlowBuilder builder = new MultipartRequestFlowBuilder();\r
-        builder.setTableId((short) 8);\r
-        builder.setOutPort(85L);\r
-        builder.setOutGroup(95L);\r
-        byte[] cookie = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};\r
-        builder.setCookie(new BigInteger(cookie));\r
-        byte[] cookieMask = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};\r
-        builder.setCookieMask(new BigInteger(cookieMask));\r
-        MultipartRequestFlow flow = builder.build();\r
-        //TODO match field\r
-        return flow;\r
-    }\r
-\r
-    private static MultipartRequestFlow decodeRequestFlow(ByteBuf output) {\r
-        final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01 = 3;\r
-        final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02 = 4;\r
-        MultipartRequestFlowBuilder builder = new MultipartRequestFlowBuilder();\r
-        builder.setTableId(output.readUnsignedByte());\r
-        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01);\r
-        builder.setOutPort(output.readUnsignedInt());\r
-        builder.setOutGroup(output.readUnsignedInt());\r
-        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02);\r
-        byte[] cookie = new byte[Long.SIZE/Byte.SIZE];\r
-        output.readBytes(cookie);\r
-        builder.setCookie(new BigInteger(cookie));\r
-        byte[] cookieMask = new byte[Long.SIZE/Byte.SIZE];\r
-        output.readBytes(cookieMask);\r
-        builder.setCookieMask(new BigInteger(cookieMask));\r
-        MultipartRequestFlow flow = builder.build();\r
-        return flow;\r
-    }\r
-\r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMultipartRequestInputAggregateBodyFactory() throws Exception {\r
-        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setType(MultipartType.forValue(2));\r
-        builder.setFlags(new MultipartRequestFlags(true));\r
-        builder.setMultipartRequestBody(createRequestAggregate());\r
-        MultipartRequestInput message = builder.build();\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));\r
-        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);\r
-        Assert.assertEquals("Wrong aggregate", message.getMultipartRequestBody(), decodeRequestAggregate(out));\r
-    }\r
-\r
-    private static MultipartRequestFlags decodeMultipartRequestFlags(short input){\r
-        final Boolean _oFPMPFREQMORE = (input & (1 << 0)) > 0;\r
-        return new MultipartRequestFlags(_oFPMPFREQMORE);\r
-    }\r
-\r
-\r
-    private static MultipartRequestAggregate createRequestAggregate() {\r
-        MultipartRequestAggregateBuilder builder = new MultipartRequestAggregateBuilder();\r
-        builder.setTableId((short) 8);\r
-        builder.setOutPort(85L);\r
-        builder.setOutGroup(95L);\r
-        byte[] cookie = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};\r
-        builder.setCookie(new BigInteger(cookie));\r
-        byte[] cookieMask = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};\r
-        builder.setCookieMask(new BigInteger(cookieMask));\r
-        MultipartRequestAggregate aggregate = builder.build();\r
-      //TODO match field\r
-        return aggregate;\r
-    }\r
-\r
-    private static MultipartRequestAggregate decodeRequestAggregate(ByteBuf output) {\r
-        final byte PADDING_IN_MULTIPART_REQUEST_AGGREGATE_BODY_01 = 3;\r
-        final byte PADDING_IN_MULTIPART_REQUEST_AGGREGATE_BODY_02 = 4;\r
-        MultipartRequestAggregateBuilder builder = new MultipartRequestAggregateBuilder();\r
-        builder.setTableId(output.readUnsignedByte());\r
-        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_AGGREGATE_BODY_01);\r
-        builder.setOutPort(output.readUnsignedInt());\r
-        builder.setOutGroup(output.readUnsignedInt());\r
-        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_AGGREGATE_BODY_02);\r
-        byte[] cookie = new byte[Long.SIZE/Byte.SIZE];\r
-        output.readBytes(cookie);\r
-        builder.setCookie(new BigInteger(cookie));\r
-        byte[] cookieMask = new byte[Long.SIZE/Byte.SIZE];\r
-        output.readBytes(cookieMask);\r
-        builder.setCookieMask(new BigInteger(cookieMask));\r
-        MultipartRequestAggregate flow = builder.build();\r
-        return flow;\r
-    }\r
-\r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMultipartRequestInputTableFactory() throws Exception {\r
-        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setType(MultipartType.forValue(3));\r
-        builder.setFlags(new MultipartRequestFlags(true));\r
-        //multipart request for table does not have body\r
-        MultipartRequestInput message = builder.build();\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));\r
-        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);\r
-    }\r
-\r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMultipartRequestPortStatsMessageFactory() throws Exception {\r
-        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setType(MultipartType.forValue(4));\r
-        builder.setFlags(new MultipartRequestFlags(true));\r
-        builder.setMultipartRequestBody(createRequestPortStats());\r
-        MultipartRequestInput message = builder.build();\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));\r
-        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);\r
-        Assert.assertEquals("Wrong portStatsBody", message.getMultipartRequestBody(), decodeRequestPortStats(out));\r
-    }\r
-\r
-    private static MultipartRequestPortStats createRequestPortStats() {\r
-        MultipartRequestPortStatsBuilder builder = new MultipartRequestPortStatsBuilder();\r
-        builder.setPortNo(2251L);\r
-        MultipartRequestPortStats portStats = builder.build();\r
-        return portStats;\r
-    }\r
-\r
-    private static MultipartRequestPortStats decodeRequestPortStats(ByteBuf output) {\r
-        final byte PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY = 4;\r
-        MultipartRequestPortStatsBuilder builder = new MultipartRequestPortStatsBuilder();\r
-        builder.setPortNo(output.readUnsignedInt());\r
-        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY);\r
-        MultipartRequestPortStats portRequest = builder.build();\r
-        return portRequest;\r
-    }\r
-\r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMultipartRequestQueueMessageFactory() throws Exception {\r
-        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setType(MultipartType.forValue(5));\r
-        builder.setFlags(new MultipartRequestFlags(true));\r
-        builder.setMultipartRequestBody(createRequestQueue());\r
-        MultipartRequestInput message = builder.build();\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));\r
-        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);\r
-        Assert.assertEquals("Wrong queueBody", message.getMultipartRequestBody(), decodeRequestQueue(out));\r
-    }\r
-\r
-    private static MultipartRequestQueue createRequestQueue() {\r
-        MultipartRequestQueueBuilder builder = new MultipartRequestQueueBuilder();\r
-        builder.setPortNo(2256L);\r
-        builder.setQueueId(2211L);\r
-        MultipartRequestQueue queue = builder.build();\r
-        return queue;\r
-    }\r
-\r
-    private static MultipartRequestQueue decodeRequestQueue(ByteBuf output) {\r
-        MultipartRequestQueueBuilder builder = new MultipartRequestQueueBuilder();\r
-        builder.setPortNo(output.readUnsignedInt());\r
-        builder.setQueueId(output.readUnsignedInt());\r
-        MultipartRequestQueue queue = builder.build();\r
-        return queue;\r
-    }\r
-\r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMultipartRequestGroupMessageFactory() throws Exception {\r
-        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setType(MultipartType.forValue(6));\r
-        builder.setFlags(new MultipartRequestFlags(true));\r
-        builder.setMultipartRequestBody(createRequestGroup());\r
-        MultipartRequestInput message = builder.build();\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));\r
-        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);\r
-        Assert.assertEquals("Wrong groupBody", message.getMultipartRequestBody(), decodeRequestGroup(out));\r
-    }\r
-\r
-    private static MultipartRequestGroup createRequestGroup() {\r
-        MultipartRequestGroupBuilder builder = new MultipartRequestGroupBuilder();\r
-        builder.setGroupId(new GroupId(2258L));\r
-        MultipartRequestGroup group = builder.build();\r
-        return group;\r
-    }\r
-\r
-    private static MultipartRequestGroup decodeRequestGroup(ByteBuf output) {\r
-        final byte PADDING_IN_MULTIPART_REQUEST_GROUP_BODY = 4;\r
-        MultipartRequestGroupBuilder builder = new MultipartRequestGroupBuilder();\r
-        builder.setGroupId(new GroupId(output.readUnsignedInt()));\r
-        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_GROUP_BODY);\r
-        MultipartRequestGroup group = builder.build();\r
-        return group;\r
-    }\r
-\r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMultipartRequestMeterMessageFactory() throws Exception {\r
-        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setType(MultipartType.forValue(9));\r
-        builder.setFlags(new MultipartRequestFlags(true));\r
-        builder.setMultipartRequestBody(createRequestMeter());\r
-        MultipartRequestInput message = builder.build();\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));\r
-        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);\r
-        Assert.assertEquals("Wrong meterBody", message.getMultipartRequestBody(), decodeRequestMeter(out));\r
-    }\r
-\r
-    private static MultipartRequestMeter createRequestMeter() {\r
-        MultipartRequestMeterBuilder builder = new MultipartRequestMeterBuilder();\r
-        builder.setMeterId(new MeterId(1121L));\r
-        MultipartRequestMeter meter = builder.build();\r
-        return meter;\r
-    }\r
-\r
-    private static MultipartRequestMeter decodeRequestMeter(ByteBuf output) {\r
-        final byte PADDING_IN_MULTIPART_REQUEST_METER_BODY = 4;\r
-        MultipartRequestMeterBuilder builder = new MultipartRequestMeterBuilder();\r
-        builder.setMeterId(new MeterId(output.readUnsignedInt()));\r
-        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_METER_BODY);\r
-        MultipartRequestMeter meter = builder.build();\r
-        return meter;\r
-    }\r
-\r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMultipartRequestMeterConfigMessageFactory() throws Exception {\r
-        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setType(MultipartType.forValue(10));\r
-        builder.setFlags(new MultipartRequestFlags(true));\r
-        builder.setMultipartRequestBody(createRequestMeterConfig());\r
-        MultipartRequestInput message = builder.build();\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));\r
-        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);\r
-        Assert.assertEquals("Wrong meterConfigBody", message.getMultipartRequestBody(), decodeRequestMeterConfig(out));\r
-    }\r
-\r
-    private static MultipartRequestMeterConfig createRequestMeterConfig() {\r
-        MultipartRequestMeterConfigBuilder builder = new MultipartRequestMeterConfigBuilder();\r
-        builder.setMeterId(new MeterId(1133L));\r
-        MultipartRequestMeterConfig meterConfig = builder.build();\r
-        return meterConfig;\r
-    }\r
-\r
-    private static MultipartRequestMeterConfig decodeRequestMeterConfig(ByteBuf output) {\r
-        final byte PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY = 4;\r
-        MultipartRequestMeterConfigBuilder builder = new MultipartRequestMeterConfigBuilder();\r
-        builder.setMeterId(new MeterId(output.readUnsignedInt()));\r
-        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY);\r
-        MultipartRequestMeterConfig meterConfig = builder.build();\r
-        return meterConfig;\r
-    }\r
-\r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMultipartRequestExperimenterMessageFactory() throws Exception {\r
-        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setType(MultipartType.forValue(0xffff));\r
-        builder.setFlags(new MultipartRequestFlags(true));\r
-        builder.setMultipartRequestBody(createRequestExperimenter());\r
-        MultipartRequestInput message = builder.build();\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));\r
-        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);\r
-        Assert.assertEquals("Wrong experimenterBody", message.getMultipartRequestBody(), decodeRequestExperimenter(out));\r
-    }\r
-\r
-    private static MultipartRequestExperimenter createRequestExperimenter() {\r
-        MultipartRequestExperimenterBuilder builder = new MultipartRequestExperimenterBuilder();\r
-        builder.setExperimenter(1133L);\r
-        builder.setExpType(1135L);\r
-        MultipartRequestExperimenter experimenter = builder.build();\r
-        return experimenter;\r
-    }\r
-\r
-    private static MultipartRequestExperimenter decodeRequestExperimenter(ByteBuf output) {\r
-        MultipartRequestExperimenterBuilder builder = new MultipartRequestExperimenterBuilder();\r
-        builder.setExperimenter(output.readUnsignedInt());\r
-        builder.setExpType(output.readUnsignedInt());\r
-        MultipartRequestExperimenter experimenter = builder.build();\r
-        return experimenter;\r
-    }\r
-\r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMultipartRequestDescMessageFactory() throws Exception {\r
-        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setType(MultipartType.forValue(0));\r
-        builder.setFlags(new MultipartRequestFlags(true));\r
-        builder.setMultipartRequestBody(createRequestDesc());\r
-        MultipartRequestInput message = builder.build();\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));\r
-    }\r
-\r
-    private static MultipartRequestBody createRequestDesc() {\r
-        MultipartRequestDescBuilder builder = new MultipartRequestDescBuilder();\r
-        return builder.build();\r
-    }\r
-\r
-    /**\r
-     * @throws Exception\r
-     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testMultipartRequestTableFeaturesMessageFactory() throws Exception {\r
-        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setType(MultipartType.forValue(12));\r
-        builder.setFlags(new MultipartRequestFlags(true));\r
-        builder.setMultipartRequestBody(createRequestTableFeatures());\r
-        MultipartRequestInput message = builder.build();\r
-\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));\r
-        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);\r
-\r
-        MultipartRequestTableFeatures messageTableFeatures = (MultipartRequestTableFeatures) message.getMultipartRequestBody();\r
-        Assert.assertEquals("Wrong tableFeaturesBody", messageTableFeatures.getTableFeatures(), decodeRequestTableFeatures(out).getTableFeatures());\r
-    }\r
-\r
-    private static MultipartRequestTableFeatures createRequestTableFeatures() {\r
-        MultipartRequestTableFeaturesBuilder builder = new MultipartRequestTableFeaturesBuilder();\r
-        List<TableFeatures> tableFeaturesList = new ArrayList<>();\r
-        TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();\r
-        tableFeaturesBuilder.setTableId((short) 8);\r
-        tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");\r
-        tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}));\r
-        tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}));\r
-        tableFeaturesBuilder.setConfig(new TableConfig(true));\r
-        tableFeaturesBuilder.setMaxEntries(65L);\r
-        TableFeatures tableFeature = tableFeaturesBuilder.build();\r
-        tableFeaturesList.add(tableFeature);\r
-        builder.setTableFeatures(tableFeaturesList);\r
-        MultipartRequestTableFeatures tableFeaturesRequest = builder.build();\r
-        return tableFeaturesRequest;\r
-    }\r
-\r
-    private static MultipartRequestTableFeatures decodeRequestTableFeatures(ByteBuf output) {\r
-        final byte PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY = 5;\r
-        final byte OFP_MAX_TABLE_NAME_LEN = 32;\r
-        MultipartRequestTableFeaturesBuilder builder = new MultipartRequestTableFeaturesBuilder();\r
-        List<TableFeatures> tableFeaturesList = new ArrayList<>();\r
-        TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();\r
-        tableFeaturesBuilder.setTableId(output.readUnsignedByte());\r
-        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY);\r
-        byte[] tableNameBytes = new byte[OFP_MAX_TABLE_NAME_LEN];\r
-        output.readBytes(tableNameBytes);\r
-        String tableName = new String(tableNameBytes);\r
-        tableFeaturesBuilder.setName(tableName.trim());\r
-        byte[] metadataMatch = new byte[Long.SIZE/Byte.SIZE];\r
-        output.readBytes(metadataMatch);\r
-        tableFeaturesBuilder.setMetadataMatch(new BigInteger(metadataMatch));\r
-        byte[] metadataWrite = new byte[Long.SIZE/Byte.SIZE];\r
-        output.readBytes(metadataWrite);\r
-        tableFeaturesBuilder.setMetadataWrite(new BigInteger(metadataWrite));\r
-        tableFeaturesBuilder.setConfig(decodeTableConfig(output.readInt()));\r
-        tableFeaturesBuilder.setMaxEntries(output.readUnsignedInt());\r
-        TableFeatures tableFeature = tableFeaturesBuilder.build();\r
-        tableFeaturesList.add(tableFeature);\r
-        builder.setTableFeatures(tableFeaturesList);\r
-        MultipartRequestTableFeatures tableFeaturesRequest = builder.build();\r
-        return tableFeaturesRequest;\r
-    }\r
-\r
-    private static TableConfig decodeTableConfig(int input) {\r
-        final Boolean _oFPTCDEPRECATEDMASK = (input & (1 << 3)) > 0;\r
-        return new TableConfig(_oFPTCDEPRECATEDMASK);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features.TableFeaturesBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class MultipartRequestInputFactoryTest {
+    private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = 4;
+
+    /**
+     * @throws Exception
+     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMultipartRequestInputFactory() throws Exception {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(MultipartType.forValue(1));
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setMultipartRequestBody(createRequestFlow());
+        MultipartRequestInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
+        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
+        Assert.assertEquals("Wrong flow", message.getMultipartRequestBody(), decodeRequestFlow(out));
+    }
+
+    private static MultipartRequestFlow createRequestFlow() {
+        MultipartRequestFlowBuilder builder = new MultipartRequestFlowBuilder();
+        builder.setTableId((short) 8);
+        builder.setOutPort(85L);
+        builder.setOutGroup(95L);
+        byte[] cookie = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
+        builder.setCookie(new BigInteger(cookie));
+        byte[] cookieMask = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
+        builder.setCookieMask(new BigInteger(cookieMask));
+        MultipartRequestFlow flow = builder.build();
+        //TODO match field
+        return flow;
+    }
+
+    private static MultipartRequestFlow decodeRequestFlow(ByteBuf output) {
+        final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01 = 3;
+        final byte PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02 = 4;
+        MultipartRequestFlowBuilder builder = new MultipartRequestFlowBuilder();
+        builder.setTableId(output.readUnsignedByte());
+        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01);
+        builder.setOutPort(output.readUnsignedInt());
+        builder.setOutGroup(output.readUnsignedInt());
+        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02);
+        byte[] cookie = new byte[Long.SIZE/Byte.SIZE];
+        output.readBytes(cookie);
+        builder.setCookie(new BigInteger(cookie));
+        byte[] cookieMask = new byte[Long.SIZE/Byte.SIZE];
+        output.readBytes(cookieMask);
+        builder.setCookieMask(new BigInteger(cookieMask));
+        MultipartRequestFlow flow = builder.build();
+        return flow;
+    }
+
+    /**
+     * @throws Exception
+     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMultipartRequestInputAggregateBodyFactory() throws Exception {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(MultipartType.forValue(2));
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setMultipartRequestBody(createRequestAggregate());
+        MultipartRequestInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
+        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
+        Assert.assertEquals("Wrong aggregate", message.getMultipartRequestBody(), decodeRequestAggregate(out));
+    }
+
+    private static MultipartRequestFlags decodeMultipartRequestFlags(short input){
+        final Boolean _oFPMPFREQMORE = (input & (1 << 0)) > 0;
+        return new MultipartRequestFlags(_oFPMPFREQMORE);
+    }
+
+
+    private static MultipartRequestAggregate createRequestAggregate() {
+        MultipartRequestAggregateBuilder builder = new MultipartRequestAggregateBuilder();
+        builder.setTableId((short) 8);
+        builder.setOutPort(85L);
+        builder.setOutGroup(95L);
+        byte[] cookie = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
+        builder.setCookie(new BigInteger(cookie));
+        byte[] cookieMask = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
+        builder.setCookieMask(new BigInteger(cookieMask));
+        MultipartRequestAggregate aggregate = builder.build();
+      //TODO match field
+        return aggregate;
+    }
+
+    private static MultipartRequestAggregate decodeRequestAggregate(ByteBuf output) {
+        final byte PADDING_IN_MULTIPART_REQUEST_AGGREGATE_BODY_01 = 3;
+        final byte PADDING_IN_MULTIPART_REQUEST_AGGREGATE_BODY_02 = 4;
+        MultipartRequestAggregateBuilder builder = new MultipartRequestAggregateBuilder();
+        builder.setTableId(output.readUnsignedByte());
+        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_AGGREGATE_BODY_01);
+        builder.setOutPort(output.readUnsignedInt());
+        builder.setOutGroup(output.readUnsignedInt());
+        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_AGGREGATE_BODY_02);
+        byte[] cookie = new byte[Long.SIZE/Byte.SIZE];
+        output.readBytes(cookie);
+        builder.setCookie(new BigInteger(cookie));
+        byte[] cookieMask = new byte[Long.SIZE/Byte.SIZE];
+        output.readBytes(cookieMask);
+        builder.setCookieMask(new BigInteger(cookieMask));
+        MultipartRequestAggregate flow = builder.build();
+        return flow;
+    }
+
+    /**
+     * @throws Exception
+     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMultipartRequestInputTableFactory() throws Exception {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(MultipartType.forValue(3));
+        builder.setFlags(new MultipartRequestFlags(true));
+        //multipart request for table does not have body
+        MultipartRequestInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
+        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
+    }
+
+    /**
+     * @throws Exception
+     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMultipartRequestPortStatsMessageFactory() throws Exception {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(MultipartType.forValue(4));
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setMultipartRequestBody(createRequestPortStats());
+        MultipartRequestInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
+        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
+        Assert.assertEquals("Wrong portStatsBody", message.getMultipartRequestBody(), decodeRequestPortStats(out));
+    }
+
+    private static MultipartRequestPortStats createRequestPortStats() {
+        MultipartRequestPortStatsBuilder builder = new MultipartRequestPortStatsBuilder();
+        builder.setPortNo(2251L);
+        MultipartRequestPortStats portStats = builder.build();
+        return portStats;
+    }
+
+    private static MultipartRequestPortStats decodeRequestPortStats(ByteBuf output) {
+        final byte PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY = 4;
+        MultipartRequestPortStatsBuilder builder = new MultipartRequestPortStatsBuilder();
+        builder.setPortNo(output.readUnsignedInt());
+        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY);
+        MultipartRequestPortStats portRequest = builder.build();
+        return portRequest;
+    }
+
+    /**
+     * @throws Exception
+     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMultipartRequestQueueMessageFactory() throws Exception {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(MultipartType.forValue(5));
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setMultipartRequestBody(createRequestQueue());
+        MultipartRequestInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
+        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
+        Assert.assertEquals("Wrong queueBody", message.getMultipartRequestBody(), decodeRequestQueue(out));
+    }
+
+    private static MultipartRequestQueue createRequestQueue() {
+        MultipartRequestQueueBuilder builder = new MultipartRequestQueueBuilder();
+        builder.setPortNo(2256L);
+        builder.setQueueId(2211L);
+        MultipartRequestQueue queue = builder.build();
+        return queue;
+    }
+
+    private static MultipartRequestQueue decodeRequestQueue(ByteBuf output) {
+        MultipartRequestQueueBuilder builder = new MultipartRequestQueueBuilder();
+        builder.setPortNo(output.readUnsignedInt());
+        builder.setQueueId(output.readUnsignedInt());
+        MultipartRequestQueue queue = builder.build();
+        return queue;
+    }
+
+    /**
+     * @throws Exception
+     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMultipartRequestGroupMessageFactory() throws Exception {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(MultipartType.forValue(6));
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setMultipartRequestBody(createRequestGroup());
+        MultipartRequestInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
+        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
+        Assert.assertEquals("Wrong groupBody", message.getMultipartRequestBody(), decodeRequestGroup(out));
+    }
+
+    private static MultipartRequestGroup createRequestGroup() {
+        MultipartRequestGroupBuilder builder = new MultipartRequestGroupBuilder();
+        builder.setGroupId(new GroupId(2258L));
+        MultipartRequestGroup group = builder.build();
+        return group;
+    }
+
+    private static MultipartRequestGroup decodeRequestGroup(ByteBuf output) {
+        final byte PADDING_IN_MULTIPART_REQUEST_GROUP_BODY = 4;
+        MultipartRequestGroupBuilder builder = new MultipartRequestGroupBuilder();
+        builder.setGroupId(new GroupId(output.readUnsignedInt()));
+        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_GROUP_BODY);
+        MultipartRequestGroup group = builder.build();
+        return group;
+    }
+
+    /**
+     * @throws Exception
+     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMultipartRequestMeterMessageFactory() throws Exception {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(MultipartType.forValue(9));
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setMultipartRequestBody(createRequestMeter());
+        MultipartRequestInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
+        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
+        Assert.assertEquals("Wrong meterBody", message.getMultipartRequestBody(), decodeRequestMeter(out));
+    }
+
+    private static MultipartRequestMeter createRequestMeter() {
+        MultipartRequestMeterBuilder builder = new MultipartRequestMeterBuilder();
+        builder.setMeterId(new MeterId(1121L));
+        MultipartRequestMeter meter = builder.build();
+        return meter;
+    }
+
+    private static MultipartRequestMeter decodeRequestMeter(ByteBuf output) {
+        final byte PADDING_IN_MULTIPART_REQUEST_METER_BODY = 4;
+        MultipartRequestMeterBuilder builder = new MultipartRequestMeterBuilder();
+        builder.setMeterId(new MeterId(output.readUnsignedInt()));
+        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_METER_BODY);
+        MultipartRequestMeter meter = builder.build();
+        return meter;
+    }
+
+    /**
+     * @throws Exception
+     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMultipartRequestMeterConfigMessageFactory() throws Exception {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(MultipartType.forValue(10));
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setMultipartRequestBody(createRequestMeterConfig());
+        MultipartRequestInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
+        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
+        Assert.assertEquals("Wrong meterConfigBody", message.getMultipartRequestBody(), decodeRequestMeterConfig(out));
+    }
+
+    private static MultipartRequestMeterConfig createRequestMeterConfig() {
+        MultipartRequestMeterConfigBuilder builder = new MultipartRequestMeterConfigBuilder();
+        builder.setMeterId(new MeterId(1133L));
+        MultipartRequestMeterConfig meterConfig = builder.build();
+        return meterConfig;
+    }
+
+    private static MultipartRequestMeterConfig decodeRequestMeterConfig(ByteBuf output) {
+        final byte PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY = 4;
+        MultipartRequestMeterConfigBuilder builder = new MultipartRequestMeterConfigBuilder();
+        builder.setMeterId(new MeterId(output.readUnsignedInt()));
+        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY);
+        MultipartRequestMeterConfig meterConfig = builder.build();
+        return meterConfig;
+    }
+
+    /**
+     * @throws Exception
+     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMultipartRequestExperimenterMessageFactory() throws Exception {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(MultipartType.forValue(0xffff));
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setMultipartRequestBody(createRequestExperimenter());
+        MultipartRequestInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
+        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
+        Assert.assertEquals("Wrong experimenterBody", message.getMultipartRequestBody(), decodeRequestExperimenter(out));
+    }
+
+    private static MultipartRequestExperimenter createRequestExperimenter() {
+        MultipartRequestExperimenterBuilder builder = new MultipartRequestExperimenterBuilder();
+        builder.setExperimenter(1133L);
+        builder.setExpType(1135L);
+        MultipartRequestExperimenter experimenter = builder.build();
+        return experimenter;
+    }
+
+    private static MultipartRequestExperimenter decodeRequestExperimenter(ByteBuf output) {
+        MultipartRequestExperimenterBuilder builder = new MultipartRequestExperimenterBuilder();
+        builder.setExperimenter(output.readUnsignedInt());
+        builder.setExpType(output.readUnsignedInt());
+        MultipartRequestExperimenter experimenter = builder.build();
+        return experimenter;
+    }
+
+    /**
+     * @throws Exception
+     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMultipartRequestDescMessageFactory() throws Exception {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(MultipartType.forValue(0));
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setMultipartRequestBody(createRequestDesc());
+        MultipartRequestInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
+    }
+
+    private static MultipartRequestBody createRequestDesc() {
+        MultipartRequestDescBuilder builder = new MultipartRequestDescBuilder();
+        return builder.build();
+    }
+
+    /**
+     * @throws Exception
+     * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+     */
+    @Test
+    public void testMultipartRequestTableFeaturesMessageFactory() throws Exception {
+        MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setType(MultipartType.forValue(12));
+        builder.setFlags(new MultipartRequestFlags(true));
+        builder.setMultipartRequestBody(createRequestTableFeatures());
+        MultipartRequestInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedShort());
+        Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
+        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
+
+        MultipartRequestTableFeatures messageTableFeatures = (MultipartRequestTableFeatures) message.getMultipartRequestBody();
+        Assert.assertEquals("Wrong tableFeaturesBody", messageTableFeatures.getTableFeatures(), decodeRequestTableFeatures(out).getTableFeatures());
+    }
+
+    private static MultipartRequestTableFeatures createRequestTableFeatures() {
+        MultipartRequestTableFeaturesBuilder builder = new MultipartRequestTableFeaturesBuilder();
+        List<TableFeatures> tableFeaturesList = new ArrayList<>();
+        TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
+        tableFeaturesBuilder.setTableId((short) 8);
+        tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
+        tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}));
+        tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}));
+        tableFeaturesBuilder.setConfig(new TableConfig(true));
+        tableFeaturesBuilder.setMaxEntries(65L);
+        TableFeatures tableFeature = tableFeaturesBuilder.build();
+        tableFeaturesList.add(tableFeature);
+        builder.setTableFeatures(tableFeaturesList);
+        MultipartRequestTableFeatures tableFeaturesRequest = builder.build();
+        return tableFeaturesRequest;
+    }
+
+    private static MultipartRequestTableFeatures decodeRequestTableFeatures(ByteBuf output) {
+        final byte PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY = 5;
+        final byte OFP_MAX_TABLE_NAME_LEN = 32;
+        MultipartRequestTableFeaturesBuilder builder = new MultipartRequestTableFeaturesBuilder();
+        List<TableFeatures> tableFeaturesList = new ArrayList<>();
+        TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
+        tableFeaturesBuilder.setTableId(output.readUnsignedByte());
+        output.skipBytes(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY);
+        byte[] tableNameBytes = new byte[OFP_MAX_TABLE_NAME_LEN];
+        output.readBytes(tableNameBytes);
+        String tableName = new String(tableNameBytes);
+        tableFeaturesBuilder.setName(tableName.trim());
+        byte[] metadataMatch = new byte[Long.SIZE/Byte.SIZE];
+        output.readBytes(metadataMatch);
+        tableFeaturesBuilder.setMetadataMatch(new BigInteger(metadataMatch));
+        byte[] metadataWrite = new byte[Long.SIZE/Byte.SIZE];
+        output.readBytes(metadataWrite);
+        tableFeaturesBuilder.setMetadataWrite(new BigInteger(metadataWrite));
+        tableFeaturesBuilder.setConfig(decodeTableConfig(output.readInt()));
+        tableFeaturesBuilder.setMaxEntries(output.readUnsignedInt());
+        TableFeatures tableFeature = tableFeaturesBuilder.build();
+        tableFeaturesList.add(tableFeature);
+        builder.setTableFeatures(tableFeaturesList);
+        MultipartRequestTableFeatures tableFeaturesRequest = builder.build();
+        return tableFeaturesRequest;
+    }
+
+    private static TableConfig decodeTableConfig(int input) {
+        final Boolean _oFPTCDEPRECATEDMASK = (input & (1 << 3)) > 0;
+        return new TableConfig(_oFPTCDEPRECATEDMASK);
+    }
+
+}
index 93ba0b0615aae639e21ca5fe550a2b6d46d71c26..7e50fa8bbbd270b9dcf49e7a3b482726c4782c47 100644 (file)
@@ -1,36 +1,43 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10BarrierInputMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing of {@link OF10BarrierInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void test() throws Exception {\r
-        BarrierInputBuilder bib = new BarrierInputBuilder();\r
-        BufferHelper.setupHeader(bib, EncodeConstants.OF10_VERSION_ID);\r
-        BarrierInput bi = bib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        OF10BarrierInputMessageFactory bimf = OF10BarrierInputMessageFactory.getInstance();\r
-        bimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, bi);\r
-        \r
-        BufferHelper.checkHeaderV10(out, (byte) 18, 8);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Test;
+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.BarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10BarrierInputMessageFactoryTest {
+
+    /**
+     * Testing of {@link OF10BarrierInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void test() throws Exception {
+        BarrierInputBuilder bib = new BarrierInputBuilder();
+        BufferHelper.setupHeader(bib, EncodeConstants.OF10_VERSION_ID);
+        BarrierInput bi = bib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        OF10BarrierInputMessageFactory bimf = OF10BarrierInputMessageFactory.getInstance();
+        bimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, bi);
+        
+        BufferHelper.checkHeaderV10(out, (byte) 18, 8);
+    }
+
+}
index 1c2d53f8676b5f5dee996eb6c79063a60e6a4f3e..fbb007575f283dbc78821880a9cde034b279fe86 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\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.IpAddressAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder;\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.PortActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;\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.match.v10.grouping.MatchV10Builder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10FlowModInputMessageFactoryTest {\r
-\r
-    /**\r
-     * @throws Exception \r
-     * Testing of {@link OF10FlowModInputMessageFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testFlowModInputMessageFactory() throws Exception {\r
-        FlowModInputBuilder builder = new FlowModInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);\r
-        MatchV10Builder matchBuilder = new MatchV10Builder();\r
-        matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true, true));\r
-        matchBuilder.setNwSrcMask((short) 0);\r
-        matchBuilder.setNwDstMask((short) 0);\r
-        matchBuilder.setInPort(58);\r
-        matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));\r
-        matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff"));\r
-        matchBuilder.setDlVlan(18);\r
-        matchBuilder.setDlVlanPcp((short) 5);\r
-        matchBuilder.setDlType(42);\r
-        matchBuilder.setNwTos((short) 4);\r
-        matchBuilder.setNwProto((short) 7);\r
-        matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));\r
-        matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));\r
-        matchBuilder.setTpSrc(6653);\r
-        matchBuilder.setTpDst(6633);\r
-        builder.setMatchV10(matchBuilder.build());\r
-        byte[] cookie = new byte[]{0x00, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01};\r
-        builder.setCookie(new BigInteger(cookie));\r
-        builder.setCommand(FlowModCommand.forValue(0));\r
-        builder.setIdleTimeout(12);\r
-        builder.setHardTimeout(16);\r
-        builder.setPriority(1);\r
-        builder.setBufferId(2L);\r
-        builder.setOutPort(new PortNumber(4422L));\r
-        builder.setFlagsV10(new FlowModFlagsV10(true, false, true));\r
-        List<ActionsList> actions = new ArrayList<>();\r
-        ActionsListBuilder actionsListBuilder = new ActionsListBuilder();\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetNwDst.class);\r
-        IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder();\r
-        ipBuilder.setIpAddress(new Ipv4Address("2.2.2.2"));\r
-        actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        actions.add(actionsListBuilder.build());\r
-        actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(SetTpSrc.class);\r
-        PortActionBuilder portBuilder = new PortActionBuilder();\r
-        portBuilder.setPort(new PortNumber(42L));\r
-        actionBuilder.addAugmentation(PortAction.class, portBuilder.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        actions.add(actionsListBuilder.build());\r
-        builder.setActionsList(actions);\r
-        FlowModInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        OF10FlowModInputMessageFactory factory = OF10FlowModInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);\r
-        \r
-        BufferHelper.checkHeaderV10(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong wildcards", 4194303, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong inPort", 58, out.readUnsignedShort());\r
-        byte[] dlSrc = new byte[6];\r
-        out.readBytes(dlSrc);\r
-        Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));\r
-        byte[] dlDst = new byte[6];\r
-        out.readBytes(dlDst);\r
-        Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst));\r
-        Assert.assertEquals("Wrong dlVlan", 18, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong dlVlanPcp", 5, out.readUnsignedByte());\r
-        out.skipBytes(1);\r
-        Assert.assertEquals("Wrong dlType", 42, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong nwTos", 4, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong nwProto", 7, out.readUnsignedByte());\r
-        out.skipBytes(2);\r
-        Assert.assertEquals("Wrong nwSrc", 134744072, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong nwDst", 269488144, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong tpSrc", 6653, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong tpDst", 6633, out.readUnsignedShort());\r
-        byte[] cookieRead = new byte[8];\r
-        out.readBytes(cookieRead);\r
-        Assert.assertArrayEquals("Wrong cookie", cookie, cookieRead);\r
-        Assert.assertEquals("Wrong command", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong idleTimeOut", 12, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong hardTimeOut", 16, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong priority", 1, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong bufferId", 2, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong outPort", 4422, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong flags", 3, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong action - type", 7, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong action - length", 8, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong flags", 33686018, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong action - type", 9, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong action - length", 8, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong flags", 42, out.readUnsignedShort());\r
-        out.skipBytes(2);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+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.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.IpAddressAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10FlowModInputMessageFactoryTest {
+
+    /**
+     * @throws Exception 
+     * Testing of {@link OF10FlowModInputMessageFactory} for correct translation from POJO
+     */
+    @Test
+    public void testFlowModInputMessageFactory() throws Exception {
+        FlowModInputBuilder builder = new FlowModInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        MatchV10Builder matchBuilder = new MatchV10Builder();
+        matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true, true));
+        matchBuilder.setNwSrcMask((short) 0);
+        matchBuilder.setNwDstMask((short) 0);
+        matchBuilder.setInPort(58);
+        matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
+        matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff"));
+        matchBuilder.setDlVlan(18);
+        matchBuilder.setDlVlanPcp((short) 5);
+        matchBuilder.setDlType(42);
+        matchBuilder.setNwTos((short) 4);
+        matchBuilder.setNwProto((short) 7);
+        matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));
+        matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));
+        matchBuilder.setTpSrc(6653);
+        matchBuilder.setTpDst(6633);
+        builder.setMatchV10(matchBuilder.build());
+        byte[] cookie = new byte[]{0x00, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01};
+        builder.setCookie(new BigInteger(cookie));
+        builder.setCommand(FlowModCommand.forValue(0));
+        builder.setIdleTimeout(12);
+        builder.setHardTimeout(16);
+        builder.setPriority(1);
+        builder.setBufferId(2L);
+        builder.setOutPort(new PortNumber(4422L));
+        builder.setFlagsV10(new FlowModFlagsV10(true, false, true));
+        List<ActionsList> actions = new ArrayList<>();
+        ActionsListBuilder actionsListBuilder = new ActionsListBuilder();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetNwDst.class);
+        IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder();
+        ipBuilder.setIpAddress(new Ipv4Address("2.2.2.2"));
+        actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        actions.add(actionsListBuilder.build());
+        actionBuilder = new ActionBuilder();
+        actionBuilder.setType(SetTpSrc.class);
+        PortActionBuilder portBuilder = new PortActionBuilder();
+        portBuilder.setPort(new PortNumber(42L));
+        actionBuilder.addAugmentation(PortAction.class, portBuilder.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        actions.add(actionsListBuilder.build());
+        builder.setActionsList(actions);
+        FlowModInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        OF10FlowModInputMessageFactory factory = OF10FlowModInputMessageFactory.getInstance();
+        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);
+        
+        BufferHelper.checkHeaderV10(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong wildcards", 4194303, out.readUnsignedInt());
+        Assert.assertEquals("Wrong inPort", 58, out.readUnsignedShort());
+        byte[] dlSrc = new byte[6];
+        out.readBytes(dlSrc);
+        Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
+        byte[] dlDst = new byte[6];
+        out.readBytes(dlDst);
+        Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst));
+        Assert.assertEquals("Wrong dlVlan", 18, out.readUnsignedShort());
+        Assert.assertEquals("Wrong dlVlanPcp", 5, out.readUnsignedByte());
+        out.skipBytes(1);
+        Assert.assertEquals("Wrong dlType", 42, out.readUnsignedShort());
+        Assert.assertEquals("Wrong nwTos", 4, out.readUnsignedByte());
+        Assert.assertEquals("Wrong nwProto", 7, out.readUnsignedByte());
+        out.skipBytes(2);
+        Assert.assertEquals("Wrong nwSrc", 134744072, out.readUnsignedInt());
+        Assert.assertEquals("Wrong nwDst", 269488144, out.readUnsignedInt());
+        Assert.assertEquals("Wrong tpSrc", 6653, out.readUnsignedShort());
+        Assert.assertEquals("Wrong tpDst", 6633, out.readUnsignedShort());
+        byte[] cookieRead = new byte[8];
+        out.readBytes(cookieRead);
+        Assert.assertArrayEquals("Wrong cookie", cookie, cookieRead);
+        Assert.assertEquals("Wrong command", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong idleTimeOut", 12, out.readUnsignedShort());
+        Assert.assertEquals("Wrong hardTimeOut", 16, out.readUnsignedShort());
+        Assert.assertEquals("Wrong priority", 1, out.readUnsignedShort());
+        Assert.assertEquals("Wrong bufferId", 2, out.readUnsignedInt());
+        Assert.assertEquals("Wrong outPort", 4422, out.readUnsignedShort());
+        Assert.assertEquals("Wrong flags", 3, out.readUnsignedShort());
+        Assert.assertEquals("Wrong action - type", 7, out.readUnsignedShort());
+        Assert.assertEquals("Wrong action - length", 8, out.readUnsignedShort());
+        Assert.assertEquals("Wrong flags", 33686018, out.readUnsignedInt());
+        Assert.assertEquals("Wrong action - type", 9, out.readUnsignedShort());
+        Assert.assertEquals("Wrong action - length", 8, out.readUnsignedShort());
+        Assert.assertEquals("Wrong flags", 42, out.readUnsignedShort());
+        out.skipBytes(2);
+    }
+
+}
index 8a715aa76efca4a19ac1d89bff0a5896b0e0cad6..7575be116b38476f389a1f8889f1bd52f07c80d3 100644 (file)
@@ -1,36 +1,43 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10HelloInputMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing of {@link OF10HelloInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testWithoutElementsSet() throws Exception {\r
-        HelloInputBuilder hib = new HelloInputBuilder();\r
-        BufferHelper.setupHeader(hib, EncodeConstants.OF10_VERSION_ID);\r
-        HelloInput hi = hib.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        OF10HelloInputMessageFactory himf = OF10HelloInputMessageFactory.getInstance();\r
-        himf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, hi);\r
-        \r
-        BufferHelper.checkHeaderV10(out, (byte) 0, 8);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Test;
+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.HelloInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10HelloInputMessageFactoryTest {
+
+    /**
+     * Testing of {@link OF10HelloInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testWithoutElementsSet() throws Exception {
+        HelloInputBuilder hib = new HelloInputBuilder();
+        BufferHelper.setupHeader(hib, EncodeConstants.OF10_VERSION_ID);
+        HelloInput hi = hib.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        OF10HelloInputMessageFactory himf = OF10HelloInputMessageFactory.getInstance();
+        himf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, hi);
+        
+        BufferHelper.checkHeaderV10(out, (byte) 0, 8);
+    }
+
+}
index bc3fa472bd40f2f36784ff32279c59d8c46c500c..899b34d105678287e118a9fe20369e1b83192f8c 100644 (file)
@@ -1,86 +1,93 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.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.MaxLengthActionBuilder;\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.PortActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10PacketOutInputMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing of {@link OF10PacketOutInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testPacketOutInputMessage() throws Exception {\r
-        PacketOutInputBuilder builder = new PacketOutInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);\r
-        builder.setBufferId(256L);\r
-        builder.setInPort(new PortNumber(257L));\r
-        List<ActionsList> actions = new ArrayList<>();\r
-        ActionsListBuilder actionsListBuilder = new ActionsListBuilder();\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(Output.class);\r
-        PortActionBuilder portBuilder = new PortActionBuilder();\r
-        portBuilder.setPort(new PortNumber((long) 42));\r
-        actionBuilder.addAugmentation(PortAction.class, portBuilder.build());\r
-        MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder();\r
-        maxLen.setMaxLength(50);\r
-        actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        actions.add(actionsListBuilder.build());\r
-        actionsListBuilder = new ActionsListBuilder();\r
-        actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(StripVlan.class);\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        builder.setActionsList(actions);\r
-        actions.add(actionsListBuilder.build());\r
-        builder.setActionsList(actions);\r
-        builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"));\r
-        PacketOutInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        OF10PacketOutInputMessageFactory factory = OF10PacketOutInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        \r
-        BufferHelper.checkHeaderV10(out, (byte) 13, 48);\r
-        Assert.assertEquals("Wrong BufferId", 256, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong PortNumber", 257, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong actions length", 16, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong port", 42, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong maxlength", 50, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());\r
-        out.skipBytes(4);\r
-        Assert.assertArrayEquals("Wrong data", message.getData(), out.readBytes(out.readableBytes()).array());\r
-        Assert.assertTrue("Unread data", out.readableBytes() == 0);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
+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.StripVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10PacketOutInputMessageFactoryTest {
+
+    /**
+     * Testing of {@link OF10PacketOutInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testPacketOutInputMessage() throws Exception {
+        PacketOutInputBuilder builder = new PacketOutInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setBufferId(256L);
+        builder.setInPort(new PortNumber(257L));
+        List<ActionsList> actions = new ArrayList<>();
+        ActionsListBuilder actionsListBuilder = new ActionsListBuilder();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(Output.class);
+        PortActionBuilder portBuilder = new PortActionBuilder();
+        portBuilder.setPort(new PortNumber((long) 42));
+        actionBuilder.addAugmentation(PortAction.class, portBuilder.build());
+        MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder();
+        maxLen.setMaxLength(50);
+        actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        actions.add(actionsListBuilder.build());
+        actionsListBuilder = new ActionsListBuilder();
+        actionBuilder = new ActionBuilder();
+        actionBuilder.setType(StripVlan.class);
+        actionsListBuilder.setAction(actionBuilder.build());
+        builder.setActionsList(actions);
+        actions.add(actionsListBuilder.build());
+        builder.setActionsList(actions);
+        builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"));
+        PacketOutInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        OF10PacketOutInputMessageFactory factory = OF10PacketOutInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        
+        BufferHelper.checkHeaderV10(out, (byte) 13, 48);
+        Assert.assertEquals("Wrong BufferId", 256, out.readUnsignedInt());
+        Assert.assertEquals("Wrong PortNumber", 257, out.readUnsignedShort());
+        Assert.assertEquals("Wrong actions length", 16, out.readUnsignedShort());
+        Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
+        Assert.assertEquals("Wrong port", 42, out.readUnsignedShort());
+        Assert.assertEquals("Wrong maxlength", 50, out.readUnsignedShort());
+        Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
+        out.skipBytes(4);
+        Assert.assertArrayEquals("Wrong data", message.getData(), out.readBytes(out.readableBytes()).array());
+        Assert.assertTrue("Unread data", out.readableBytes() == 0);
+    }
+
+}
index 407c2fef8f338cfb7f92d88e59da116141e18635..c49b7b26228cff71fa947256f932f1754d8defc2 100644 (file)
@@ -1,57 +1,64 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-import junit.framework.Assert;\r
-\r
-import org.junit.Test;\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.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10PortModInputMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing of {@link OF10PortModInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testPortModInput() throws Exception {\r
-        PortModInputBuilder builder = new PortModInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);\r
-        builder.setPortNo(new PortNumber(6633L));\r
-        builder.setHwAddress(new MacAddress("08:00:27:00:B0:EB"));\r
-        builder.setConfigV10(new PortConfigV10(true, false, false, true, false, false, true));\r
-        builder.setMaskV10(new PortConfigV10(false, true, true, false, false, true, false));\r
-        builder.setAdvertiseV10(new PortFeaturesV10(true, true, false, false, false, false,\r
-                false, true, true, false, false, false));\r
-        PortModInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        OF10PortModInputMessageFactory factory = OF10PortModInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);\r
-        \r
-        BufferHelper.checkHeaderV10(out, (byte) 15, 32);\r
-        Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedShort());\r
-        byte[] address = new byte[6];\r
-        out.readBytes(address);\r
-        Assert.assertEquals("Wrong MacAddress", message.getHwAddress(),\r
-                new MacAddress(ByteBufUtils.macAddressToString(address)));\r
-        Assert.assertEquals("Wrong config", 21, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong mask", 98, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong advertise", 652, out.readUnsignedInt());\r
-        out.skipBytes(4);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import junit.framework.Assert;
+
+import org.junit.Test;
+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.common.types.rev130731.PortConfigV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10PortModInputMessageFactoryTest {
+
+    /**
+     * Testing of {@link OF10PortModInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testPortModInput() throws Exception {
+        PortModInputBuilder builder = new PortModInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setPortNo(new PortNumber(6633L));
+        builder.setHwAddress(new MacAddress("08:00:27:00:B0:EB"));
+        builder.setConfigV10(new PortConfigV10(true, false, false, true, false, false, true));
+        builder.setMaskV10(new PortConfigV10(false, true, true, false, false, true, false));
+        builder.setAdvertiseV10(new PortFeaturesV10(true, true, false, false, false, false,
+                false, true, true, false, false, false));
+        PortModInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        OF10PortModInputMessageFactory factory = OF10PortModInputMessageFactory.getInstance();
+        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);
+        
+        BufferHelper.checkHeaderV10(out, (byte) 15, 32);
+        Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedShort());
+        byte[] address = new byte[6];
+        out.readBytes(address);
+        Assert.assertEquals("Wrong MacAddress", message.getHwAddress(),
+                new MacAddress(ByteBufUtils.macAddressToString(address)));
+        Assert.assertEquals("Wrong config", 21, out.readUnsignedInt());
+        Assert.assertEquals("Wrong mask", 98, out.readUnsignedInt());
+        Assert.assertEquals("Wrong advertise", 652, out.readUnsignedInt());
+        out.skipBytes(4);
+    }
+
+}
index af6d2a907b22cd07ee25e5c7cf98886dcb1d832f..5b78232ec00dea70776e23c524f63b4a8b0cde9a 100644 (file)
@@ -1,41 +1,48 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-import junit.framework.Assert;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10QueueGetConfigInputMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing of {@link OF10QueueGetConfigInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void test() throws Exception {\r
-        GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);\r
-        builder.setPort(new PortNumber(6653L));\r
-        GetQueueConfigInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        OF10QueueGetConfigInputMessageFactory factory = OF10QueueGetConfigInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);\r
-        \r
-        BufferHelper.checkHeaderV10(out, (byte) 20, 12);\r
-        Assert.assertEquals("Wrong port", 6653L, out.readUnsignedShort());\r
-        out.skipBytes(2);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10QueueGetConfigInputMessageFactoryTest {
+
+    /**
+     * Testing of {@link OF10QueueGetConfigInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void test() throws Exception {
+        GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setPort(new PortNumber(6653L));
+        GetQueueConfigInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        OF10QueueGetConfigInputMessageFactory factory = OF10QueueGetConfigInputMessageFactory.getInstance();
+        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);
+        
+        BufferHelper.checkHeaderV10(out, (byte) 20, 12);
+        Assert.assertEquals("Wrong port", 6653L, out.readUnsignedShort());
+        out.skipBytes(2);
+    }
+
+}
index 360b33e27de844814e9f1678e476aa08fe435c0c..540801a9748c7063793333b8463277b649ad14d3 100644 (file)
@@ -1,43 +1,50 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10VendorInputMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing of {@link OF10VendorInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void test() throws Exception {\r
-        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);\r
-        builder.setExperimenter(0x0001020304L);\r
-        builder.setData(new byte[] {0x01, 0x02, 0x03, 0x04});\r
-        ExperimenterInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        OF10VendorInputMessageFactory factory = OF10VendorInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);\r
-        \r
-        BufferHelper.checkHeaderV10(out, (byte) 4, factory.computeLength(message));\r
-        Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt());\r
-        byte[] data = new byte[4];\r
-        out.readBytes(data);\r
-        Assert.assertArrayEquals("Wrong data", message.getData(), data);\r
-    }\r
-\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Assert;
+import org.junit.Test;
+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.ExperimenterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10VendorInputMessageFactoryTest {
+
+    /**
+     * Testing of {@link OF10VendorInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void test() throws Exception {
+        ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        builder.setExperimenter(0x0001020304L);
+        builder.setData(new byte[] {0x01, 0x02, 0x03, 0x04});
+        ExperimenterInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        OF10VendorInputMessageFactory factory = OF10VendorInputMessageFactory.getInstance();
+        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);
+        
+        BufferHelper.checkHeaderV10(out, (byte) 4, factory.computeLength(message));
+        Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt());
+        byte[] data = new byte[4];
+        out.readBytes(data);
+        Assert.assertArrayEquals("Wrong data", message.getData(), data);
+    }
+
+}
index a975c4a902827413258773084bcafa9c82524f0f..d845336daefa1af088a29ebbca2cb7640269a04e 100644 (file)
@@ -1,82 +1,89 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- *\r
- */\r
-public class PacketOutInputMessageFactoryTest {\r
-    private static final byte MESSAGE_TYPE = 13;\r
-    private static final byte PADDING_IN_PACKET_OUT_MESSAGE = 6;\r
-    private static final int PADDING_IN_ACTION_HEADER = 4;\r
-       \r
-    /**\r
-     * Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testPacketOutInputMessage() throws Exception {\r
-        PacketOutInputBuilder builder = new PacketOutInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setBufferId(256L);\r
-        builder.setInPort(new PortNumber(256L));\r
-        List<ActionsList> actions = new ArrayList<>();\r
-        ActionsListBuilder actionsListBuilder = new ActionsListBuilder();\r
-        ActionBuilder actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(PushVlan.class);\r
-        EthertypeActionBuilder ethertypeBuilder = new EthertypeActionBuilder();\r
-        ethertypeBuilder.setEthertype(new EtherType(25));\r
-        actionBuilder.addAugmentation(EthertypeAction.class, ethertypeBuilder.build());\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        actions.add(actionsListBuilder.build());\r
-        actionBuilder = new ActionBuilder();\r
-        actionBuilder.setType(PopVlan.class);\r
-        actionsListBuilder.setAction(actionBuilder.build());\r
-        actions.add(actionsListBuilder.build());\r
-        builder.setActionsList(actions);\r
-        builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"));\r
-        PacketOutInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        PacketOutInputMessageFactory factory = PacketOutInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        \r
-        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 56);\r
-        Assert.assertEquals("Wrong BufferId", message.getBufferId().longValue(), out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong PortNumber", message.getInPort().getValue().longValue(), out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong ActionsLength", 16, out.readUnsignedShort());\r
-        out.skipBytes(PADDING_IN_PACKET_OUT_MESSAGE);\r
-        Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ethertype", 25, out.readUnsignedShort());\r
-        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-        Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());\r
-        out.skipBytes(PADDING_IN_ACTION_HEADER);\r
-        Assert.assertArrayEquals("Wrong data", message.getData(), out.readBytes(out.readableBytes()).array());\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+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.common.action.rev130731.PopVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;
+
+/**
+ * @author timotej.kubas
+ *
+ */
+public class PacketOutInputMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 13;
+    private static final byte PADDING_IN_PACKET_OUT_MESSAGE = 6;
+    private static final int PADDING_IN_ACTION_HEADER = 4;
+       
+    /**
+     * Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testPacketOutInputMessage() throws Exception {
+        PacketOutInputBuilder builder = new PacketOutInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setBufferId(256L);
+        builder.setInPort(new PortNumber(256L));
+        List<ActionsList> actions = new ArrayList<>();
+        ActionsListBuilder actionsListBuilder = new ActionsListBuilder();
+        ActionBuilder actionBuilder = new ActionBuilder();
+        actionBuilder.setType(PushVlan.class);
+        EthertypeActionBuilder ethertypeBuilder = new EthertypeActionBuilder();
+        ethertypeBuilder.setEthertype(new EtherType(25));
+        actionBuilder.addAugmentation(EthertypeAction.class, ethertypeBuilder.build());
+        actionsListBuilder.setAction(actionBuilder.build());
+        actions.add(actionsListBuilder.build());
+        actionBuilder = new ActionBuilder();
+        actionBuilder.setType(PopVlan.class);
+        actionsListBuilder.setAction(actionBuilder.build());
+        actions.add(actionsListBuilder.build());
+        builder.setActionsList(actions);
+        builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"));
+        PacketOutInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        PacketOutInputMessageFactory factory = PacketOutInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 56);
+        Assert.assertEquals("Wrong BufferId", message.getBufferId().longValue(), out.readUnsignedInt());
+        Assert.assertEquals("Wrong PortNumber", message.getInPort().getValue().longValue(), out.readUnsignedInt());
+        Assert.assertEquals("Wrong ActionsLength", 16, out.readUnsignedShort());
+        out.skipBytes(PADDING_IN_PACKET_OUT_MESSAGE);
+        Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ethertype", 25, out.readUnsignedShort());
+        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort());
+        Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
+        out.skipBytes(PADDING_IN_ACTION_HEADER);
+        Assert.assertArrayEquals("Wrong data", message.getData(), out.readBytes(out.readableBytes()).array());
+    }
+}
index b5469e22229e4684646108385b1f3dd804d562c9..f55be957fb0bad937f615e6c664b8efaab40d838 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-import junit.framework.Assert;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.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.common.types.rev130731.PortConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class PortModInputMessageFactoryTest {\r
-    private static final byte MESSAGE_TYPE = 16;\r
-    private static final byte PADDING_IN_PORT_MOD_MESSAGE_01 = 4;\r
-    private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2;\r
-    private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4;\r
-    private static final int MESSAGE_LENGTH = 40;\r
-    \r
-    /**\r
-     * Testing of {@link PortModInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testPortModInput() throws Exception {\r
-        PortModInputBuilder builder = new PortModInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setPortNo(new PortNumber(9L));\r
-        builder.setHwAddress(new MacAddress("08:00:27:00:B0:EB"));\r
-        builder.setConfig(new PortConfig(true, false, true, false));\r
-        builder.setMask(new PortConfig(false, true, false, true));\r
-        builder.setAdvertise(new PortFeatures(true, false, false, false,\r
-                                              false, false, false, true, \r
-                                              false, false, false, false, \r
-                                              false, false, false, false));\r
-        PortModInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        PortModInputMessageFactory factory = PortModInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        \r
-        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
-        Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt());\r
-        out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01);\r
-        byte[] address = new byte[6];\r
-        out.readBytes(address);\r
-        Assert.assertEquals("Wrong MacAddress", message.getHwAddress().getValue(),\r
-                new MacAddress(ByteBufUtils.macAddressToString(address)).getValue());\r
-        out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_02);\r
-        Assert.assertEquals("Wrong config", message.getConfig(), createPortConfig(out.readInt()));\r
-        Assert.assertEquals("Wrong mask", message.getMask(), createPortConfig(out.readInt()));\r
-        Assert.assertEquals("Wrong advertise", message.getAdvertise(), createPortFeatures(out.readInt()));\r
-        out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_03);\r
-    }\r
-\r
-    private static PortConfig createPortConfig(long input){\r
-        final Boolean _portDown   = ((input) & (1<<0)) > 0;\r
-        final Boolean _noRecv    = ((input) & (1<<2)) > 0;\r
-        final Boolean _noFwd       = ((input) & (1<<5)) > 0;\r
-        final Boolean _noPacketIn = ((input) & (1<<6)) > 0;\r
-        return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);\r
-    }\r
-    \r
-    private static PortFeatures createPortFeatures(long input){\r
-        final Boolean _10mbHd = ((input) & (1<<0)) > 0;\r
-        final Boolean _10mbFd = ((input) & (1<<1)) > 0;\r
-        final Boolean _100mbHd = ((input) & (1<<2)) > 0;\r
-        final Boolean _100mbFd = ((input) & (1<<3)) > 0;\r
-        final Boolean _1gbHd = ((input) & (1<<4)) > 0;\r
-        final Boolean _1gbFd = ((input) & (1<<5)) > 0;\r
-        final Boolean _10gbFd = ((input) & (1<<6)) > 0;\r
-        final Boolean _40gbFd = ((input) & (1<<7)) > 0;\r
-        final Boolean _100gbFd = ((input) & (1<<8)) > 0;\r
-        final Boolean _1tbFd = ((input) & (1<<9)) > 0;\r
-        final Boolean _other = ((input) & (1<<10)) > 0;\r
-        final Boolean _copper = ((input) & (1<<11)) > 0;\r
-        final Boolean _fiber = ((input) & (1<<12)) > 0;\r
-        final Boolean _autoneg = ((input) & (1<<13)) > 0;\r
-        final Boolean _pause = ((input) & (1<<14)) > 0;\r
-        final Boolean _pauseAsym = ((input) & (1<<15)) > 0;\r
-        return new PortFeatures(_100gbFd, _100mbFd,  _100mbHd, _10gbFd, _10mbFd, _10mbHd, \r
-                _1gbFd, _1gbHd, _1tbFd, _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym);\r
-    }\r
-    \r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.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.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class PortModInputMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 16;
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_01 = 4;
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2;
+    private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4;
+    private static final int MESSAGE_LENGTH = 40;
+    
+    /**
+     * Testing of {@link PortModInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testPortModInput() throws Exception {
+        PortModInputBuilder builder = new PortModInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setPortNo(new PortNumber(9L));
+        builder.setHwAddress(new MacAddress("08:00:27:00:B0:EB"));
+        builder.setConfig(new PortConfig(true, false, true, false));
+        builder.setMask(new PortConfig(false, true, false, true));
+        builder.setAdvertise(new PortFeatures(true, false, false, false,
+                                              false, false, false, true, 
+                                              false, false, false, false, 
+                                              false, false, false, false));
+        PortModInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        PortModInputMessageFactory factory = PortModInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
+        Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt());
+        out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01);
+        byte[] address = new byte[6];
+        out.readBytes(address);
+        Assert.assertEquals("Wrong MacAddress", message.getHwAddress().getValue(),
+                new MacAddress(ByteBufUtils.macAddressToString(address)).getValue());
+        out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_02);
+        Assert.assertEquals("Wrong config", message.getConfig(), createPortConfig(out.readInt()));
+        Assert.assertEquals("Wrong mask", message.getMask(), createPortConfig(out.readInt()));
+        Assert.assertEquals("Wrong advertise", message.getAdvertise(), createPortFeatures(out.readInt()));
+        out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_03);
+    }
+
+    private static PortConfig createPortConfig(long input){
+        final Boolean _portDown   = ((input) & (1<<0)) > 0;
+        final Boolean _noRecv    = ((input) & (1<<2)) > 0;
+        final Boolean _noFwd       = ((input) & (1<<5)) > 0;
+        final Boolean _noPacketIn = ((input) & (1<<6)) > 0;
+        return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);
+    }
+    
+    private static PortFeatures createPortFeatures(long input){
+        final Boolean _10mbHd = ((input) & (1<<0)) > 0;
+        final Boolean _10mbFd = ((input) & (1<<1)) > 0;
+        final Boolean _100mbHd = ((input) & (1<<2)) > 0;
+        final Boolean _100mbFd = ((input) & (1<<3)) > 0;
+        final Boolean _1gbHd = ((input) & (1<<4)) > 0;
+        final Boolean _1gbFd = ((input) & (1<<5)) > 0;
+        final Boolean _10gbFd = ((input) & (1<<6)) > 0;
+        final Boolean _40gbFd = ((input) & (1<<7)) > 0;
+        final Boolean _100gbFd = ((input) & (1<<8)) > 0;
+        final Boolean _1tbFd = ((input) & (1<<9)) > 0;
+        final Boolean _other = ((input) & (1<<10)) > 0;
+        final Boolean _copper = ((input) & (1<<11)) > 0;
+        final Boolean _fiber = ((input) & (1<<12)) > 0;
+        final Boolean _autoneg = ((input) & (1<<13)) > 0;
+        final Boolean _pause = ((input) & (1<<14)) > 0;
+        final Boolean _pauseAsym = ((input) & (1<<15)) > 0;
+        return new PortFeatures(_100gbFd, _100mbFd,  _100mbHd, _10gbFd, _10mbFd, _10mbHd, 
+                _1gbFd, _1gbHd, _1tbFd, _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym);
+    }
+    
+}
index 27274aadb34ed6d403eb95a5ea8130b630f302a7..9baa8553beac1988a38fc0cf2654cd05f07816c9 100644 (file)
@@ -1,50 +1,57 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.math.BigInteger;\r
-\r
-import junit.framework.Assert;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class RoleRequestInputMessageFactoryTest {\r
-    private static final byte MESSAGE_TYPE = 24;\r
-    private static final int MESSAGE_LENGTH = 24;\r
-    private static final byte PADDING_IN_ROLE_REQUEST_MESSAGE = 4;\r
-    \r
-    /**\r
-     * Testing of {@link RoleRequestInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testRoleRequestInputMessage() throws Exception {\r
-        RoleRequestInputBuilder builder = new RoleRequestInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setRole(ControllerRole.forValue(2));\r
-        byte[] generationId = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};\r
-        builder.setGenerationId(new BigInteger(generationId));\r
-        RoleRequestInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        RoleRequestInputMessageFactory factory = RoleRequestInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        \r
-        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
-        Assert.assertEquals("Wrong role", message.getRole().getIntValue(), ControllerRole.forValue((int) out.readUnsignedInt()).getIntValue());\r
-        out.skipBytes(PADDING_IN_ROLE_REQUEST_MESSAGE);\r
-        Assert.assertEquals("Wrong generation ID", message.getGenerationId().longValue(), out.readLong());\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.math.BigInteger;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class RoleRequestInputMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 24;
+    private static final int MESSAGE_LENGTH = 24;
+    private static final byte PADDING_IN_ROLE_REQUEST_MESSAGE = 4;
+    
+    /**
+     * Testing of {@link RoleRequestInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testRoleRequestInputMessage() throws Exception {
+        RoleRequestInputBuilder builder = new RoleRequestInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setRole(ControllerRole.forValue(2));
+        byte[] generationId = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
+        builder.setGenerationId(new BigInteger(generationId));
+        RoleRequestInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        RoleRequestInputMessageFactory factory = RoleRequestInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
+        Assert.assertEquals("Wrong role", message.getRole().getIntValue(), ControllerRole.forValue((int) out.readUnsignedInt()).getIntValue());
+        out.skipBytes(PADDING_IN_ROLE_REQUEST_MESSAGE);
+        Assert.assertEquals("Wrong generation ID", message.getGenerationId().longValue(), out.readLong());
+    }
+}
index 217177cc471c54b25d4f57dcc2f62913decad1ea..1de6dc122deb30fb963e130841614294b3cc7f3d 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class SetAsyncInputMessageFactoryTest {\r
-    private static final Logger LOGGER = LoggerFactory\r
-            .getLogger(SetAsyncInputMessageFactoryTest.class);\r
-    /**\r
-     * @throws Exception \r
-     * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO\r
-     */\r
-    @Test\r
-    public void testSetAsyncInputMessage() throws Exception {\r
-        SetAsyncInputBuilder builder = new SetAsyncInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setPacketInMask(createPacketInMask());\r
-        builder.setPortStatusMask(createPortStatusMask());\r
-        builder.setFlowRemovedMask(createFlowRemowedMask());\r
-        SetAsyncInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        SetAsyncInputMessageFactory factory = SetAsyncInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(out));\r
-        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
-        Assert.assertEquals("Wrong packetInMask", 5, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong packetInMask", 7, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong portStatusMask", 6, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong portStatusMask", 0, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong flowRemovedMask", 10, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong flowRemovedMask", 5, out.readUnsignedInt());\r
-        \r
-    }\r
-    \r
-    private static List<PacketInMask> createPacketInMask() {\r
-        List<PacketInMask> masks = new ArrayList<>();\r
-        PacketInMaskBuilder builder;\r
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER\r
-        builder = new PacketInMaskBuilder();\r
-        List<PacketInReason> packetInReasonList = new ArrayList<>();\r
-        packetInReasonList.add(PacketInReason.OFPRNOMATCH);\r
-        packetInReasonList.add(PacketInReason.OFPRINVALIDTTL);\r
-        builder.setMask(packetInReasonList);\r
-        masks.add(builder.build());\r
-        // OFPCR_ROLE_SLAVE\r
-        builder = new PacketInMaskBuilder();\r
-        packetInReasonList = new ArrayList<>();\r
-        packetInReasonList.add(PacketInReason.OFPRNOMATCH);\r
-        packetInReasonList.add(PacketInReason.OFPRACTION);\r
-        packetInReasonList.add(PacketInReason.OFPRINVALIDTTL);\r
-        builder.setMask(packetInReasonList);\r
-        masks.add(builder.build());\r
-        System.out.println(masks.size());\r
-        return masks;\r
-    }\r
-    \r
-    private static List<PortStatusMask> createPortStatusMask() {\r
-        List<PortStatusMask> masks = new ArrayList<>();\r
-        PortStatusMaskBuilder builder;\r
-        builder = new PortStatusMaskBuilder();\r
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER\r
-        List<PortReason> portReasonList = new ArrayList<>();\r
-        portReasonList.add(PortReason.OFPPRDELETE);\r
-        portReasonList.add(PortReason.OFPPRMODIFY);\r
-        builder.setMask(portReasonList);\r
-        masks.add(builder.build());\r
-        // OFPCR_ROLE_SLAVE\r
-        builder = new PortStatusMaskBuilder();\r
-        portReasonList = new ArrayList<>();\r
-        builder.setMask(portReasonList);\r
-        masks.add(builder.build());\r
-        return masks;\r
-    }\r
-    \r
-    private static List<FlowRemovedMask> createFlowRemowedMask() {\r
-        List<FlowRemovedMask> masks = new ArrayList<>();\r
-        FlowRemovedMaskBuilder builder;\r
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER\r
-        builder = new FlowRemovedMaskBuilder();\r
-        List<FlowRemovedReason> flowRemovedReasonList = new ArrayList<>();\r
-        flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT);\r
-        flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE);\r
-        builder.setMask(flowRemovedReasonList);\r
-        masks.add(builder.build());\r
-        // OFPCR_ROLE_SLAVE\r
-        builder = new FlowRemovedMaskBuilder();\r
-        flowRemovedReasonList = new ArrayList<>();\r
-        flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT);\r
-        flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE);\r
-        builder.setMask(flowRemovedReasonList);\r
-        masks.add(builder.build());\r
-        return masks;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class SetAsyncInputMessageFactoryTest {
+    private static final Logger LOGGER = LoggerFactory
+            .getLogger(SetAsyncInputMessageFactoryTest.class);
+    /**
+     * @throws Exception 
+     * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO
+     */
+    @Test
+    public void testSetAsyncInputMessage() throws Exception {
+        SetAsyncInputBuilder builder = new SetAsyncInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setPacketInMask(createPacketInMask());
+        builder.setPortStatusMask(createPortStatusMask());
+        builder.setFlowRemovedMask(createFlowRemowedMask());
+        SetAsyncInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        SetAsyncInputMessageFactory factory = SetAsyncInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(out));
+        BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
+        Assert.assertEquals("Wrong packetInMask", 5, out.readUnsignedInt());
+        Assert.assertEquals("Wrong packetInMask", 7, out.readUnsignedInt());
+        Assert.assertEquals("Wrong portStatusMask", 6, out.readUnsignedInt());
+        Assert.assertEquals("Wrong portStatusMask", 0, out.readUnsignedInt());
+        Assert.assertEquals("Wrong flowRemovedMask", 10, out.readUnsignedInt());
+        Assert.assertEquals("Wrong flowRemovedMask", 5, out.readUnsignedInt());
+        
+    }
+    
+    private static List<PacketInMask> createPacketInMask() {
+        List<PacketInMask> masks = new ArrayList<>();
+        PacketInMaskBuilder builder;
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        builder = new PacketInMaskBuilder();
+        List<PacketInReason> packetInReasonList = new ArrayList<>();
+        packetInReasonList.add(PacketInReason.OFPRNOMATCH);
+        packetInReasonList.add(PacketInReason.OFPRINVALIDTTL);
+        builder.setMask(packetInReasonList);
+        masks.add(builder.build());
+        // OFPCR_ROLE_SLAVE
+        builder = new PacketInMaskBuilder();
+        packetInReasonList = new ArrayList<>();
+        packetInReasonList.add(PacketInReason.OFPRNOMATCH);
+        packetInReasonList.add(PacketInReason.OFPRACTION);
+        packetInReasonList.add(PacketInReason.OFPRINVALIDTTL);
+        builder.setMask(packetInReasonList);
+        masks.add(builder.build());
+        System.out.println(masks.size());
+        return masks;
+    }
+    
+    private static List<PortStatusMask> createPortStatusMask() {
+        List<PortStatusMask> masks = new ArrayList<>();
+        PortStatusMaskBuilder builder;
+        builder = new PortStatusMaskBuilder();
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        List<PortReason> portReasonList = new ArrayList<>();
+        portReasonList.add(PortReason.OFPPRDELETE);
+        portReasonList.add(PortReason.OFPPRMODIFY);
+        builder.setMask(portReasonList);
+        masks.add(builder.build());
+        // OFPCR_ROLE_SLAVE
+        builder = new PortStatusMaskBuilder();
+        portReasonList = new ArrayList<>();
+        builder.setMask(portReasonList);
+        masks.add(builder.build());
+        return masks;
+    }
+    
+    private static List<FlowRemovedMask> createFlowRemowedMask() {
+        List<FlowRemovedMask> masks = new ArrayList<>();
+        FlowRemovedMaskBuilder builder;
+        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+        builder = new FlowRemovedMaskBuilder();
+        List<FlowRemovedReason> flowRemovedReasonList = new ArrayList<>();
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE);
+        builder.setMask(flowRemovedReasonList);
+        masks.add(builder.build());
+        // OFPCR_ROLE_SLAVE
+        builder = new FlowRemovedMaskBuilder();
+        flowRemovedReasonList = new ArrayList<>();
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
+        flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE);
+        builder.setMask(flowRemovedReasonList);
+        masks.add(builder.build());
+        return masks;
+    }
+}
index 5f54df8aa982250d011c0157d0aee271bbdd8e00..2d5de55b467b5f45ca4c6ae484bc866831e85679 100644 (file)
@@ -1,66 +1,73 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class SetConfigMessageFactoryTest {\r
-    private static final byte MESSAGE_TYPE = 9;\r
-    private static final int MESSAGE_LENGTH = 12;\r
-    \r
-    /**\r
-     * Testing of {@link SetConfigMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testSetConfigMessageV13() throws Exception {\r
-        SetConfigInputBuilder builder = new SetConfigInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        SwitchConfigFlag flag = SwitchConfigFlag.FRAGNORMAL;\r
-        builder.setFlags(flag);\r
-        builder.setMissSendLen(10);\r
-        SetConfigInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        SetConfigMessageFactory factory = SetConfigMessageFactory.getInstance();\r
-        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);\r
-        \r
-        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
-        Assert.assertEquals("Wrong flags", SwitchConfigFlag.FRAGNORMAL.getIntValue(), out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong missSendLen", 10, out.readUnsignedShort());\r
-    }\r
-    \r
-    /**\r
-     * Testing of {@link SetConfigMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testSetConfigMessageV10() throws Exception {\r
-        SetConfigInputBuilder builder = new SetConfigInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);\r
-        SwitchConfigFlag flag = SwitchConfigFlag.OFPCFRAGDROP;\r
-        builder.setFlags(flag);\r
-        builder.setMissSendLen(85);\r
-        SetConfigInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        SetConfigMessageFactory factory = SetConfigMessageFactory.getInstance();\r
-        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);\r
-        \r
-        BufferHelper.checkHeaderV10(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
-        Assert.assertEquals("Wrong flags", SwitchConfigFlag.OFPCFRAGDROP.getIntValue(), out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong missSendLen", 85, out.readUnsignedShort());\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Assert;
+import org.junit.Test;
+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.SwitchConfigFlag;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class SetConfigMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 9;
+    private static final int MESSAGE_LENGTH = 12;
+    
+    /**
+     * Testing of {@link SetConfigMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testSetConfigMessageV13() throws Exception {
+        SetConfigInputBuilder builder = new SetConfigInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        SwitchConfigFlag flag = SwitchConfigFlag.FRAGNORMAL;
+        builder.setFlags(flag);
+        builder.setMissSendLen(10);
+        SetConfigInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        SetConfigMessageFactory factory = SetConfigMessageFactory.getInstance();
+        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);
+        
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
+        Assert.assertEquals("Wrong flags", SwitchConfigFlag.FRAGNORMAL.getIntValue(), out.readUnsignedShort());
+        Assert.assertEquals("Wrong missSendLen", 10, out.readUnsignedShort());
+    }
+    
+    /**
+     * Testing of {@link SetConfigMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testSetConfigMessageV10() throws Exception {
+        SetConfigInputBuilder builder = new SetConfigInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
+        SwitchConfigFlag flag = SwitchConfigFlag.OFPCFRAGDROP;
+        builder.setFlags(flag);
+        builder.setMissSendLen(85);
+        SetConfigInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        SetConfigMessageFactory factory = SetConfigMessageFactory.getInstance();
+        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);
+        
+        BufferHelper.checkHeaderV10(out, MESSAGE_TYPE, MESSAGE_LENGTH);
+        Assert.assertEquals("Wrong flags", SwitchConfigFlag.OFPCFRAGDROP.getIntValue(), out.readUnsignedShort());
+        Assert.assertEquals("Wrong missSendLen", 85, out.readUnsignedShort());
+    }
+}
index e0e3d78c4e552007c51a992418851cee60a50778..1daa581ab71ffdca0df6b314053d623bc8984606 100644 (file)
@@ -1,47 +1,54 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-import junit.framework.Assert;\r
-\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class TableModInputMessageFactoryTest {\r
-    private static final byte MESSAGE_TYPE = 17;\r
-    private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;\r
-    \r
-    /**\r
-     * Testing of {@link TableModInputMessageFactory} for correct translation from POJO\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testTableModInput() throws Exception {\r
-        TableModInputBuilder builder = new TableModInputBuilder();\r
-        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);\r
-        builder.setTableId(new TableId(9L));\r
-        builder.setConfig(new TableConfig(true));\r
-        TableModInput message = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        TableModInputMessageFactory factory = TableModInputMessageFactory.getInstance();\r
-        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
-        \r
-        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16);\r
-        Assert.assertEquals("Wrong TableID", message.getTableId().getValue().intValue(), out.readUnsignedByte());\r
-        out.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE);\r
-        Assert.assertEquals("Wrong TableConfig", 8, out.readUnsignedInt());\r
-    }\r
-    \r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class TableModInputMessageFactoryTest {
+    private static final byte MESSAGE_TYPE = 17;
+    private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;
+    
+    /**
+     * Testing of {@link TableModInputMessageFactory} for correct translation from POJO
+     * @throws Exception 
+     */
+    @Test
+    public void testTableModInput() throws Exception {
+        TableModInputBuilder builder = new TableModInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setTableId(new TableId(9L));
+        builder.setConfig(new TableConfig(true));
+        TableModInput message = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        TableModInputMessageFactory factory = TableModInputMessageFactory.getInstance();
+        factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+        
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16);
+        Assert.assertEquals("Wrong TableID", message.getTableId().getValue().intValue(), out.readUnsignedByte());
+        out.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE);
+        Assert.assertEquals("Wrong TableConfig", 8, out.readUnsignedInt());
+    }
+    
+}
index aac10dab7fb5705aa7526884e54c3c0548fd37f0..787c1d7e35165628c32ec3eb317c68cd8eddbe89 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.lang.reflect.InvocationTargetException;\r
-import java.lang.reflect.Method;\r
-\r
-import org.junit.Assert;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * \r
- */\r
-public abstract class BufferHelper {\r
-\r
-    /**\r
-     * \r
-     */\r
-    public static final Long DEFAULT_XID = 0x01020304L;\r
-    private static final byte[] XID = new byte[] { 0x01, 0x02, 0x03, 0x04 };\r
-\r
-    /**\r
-     * @param payload\r
-     * @return ByteBuf filled with OpenFlow protocol message without first 4\r
-     *         bytes\r
-     */\r
-    public static ByteBuf buildBuffer(byte[] payload) {\r
-        ByteBuf bb = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        bb.writeBytes(XID);\r
-        bb.writeBytes(payload);\r
-        return bb;\r
-    }\r
-    \r
-    /**\r
-     * @param payload String in hex format\r
-     * @return ByteBuf filled with OpenFlow protocol message without first 4\r
-     *         bytes\r
-     */\r
-    public static ByteBuf buildBuffer(String payload) {\r
-        return buildBuffer(ByteBufUtils.hexStringToBytes(payload));\r
-    }\r
-    \r
-    /**\r
-     * @return ByteBuf filled with OpenFlow protocol header message without first 4\r
-     *         bytes\r
-     */\r
-    public static ByteBuf buildBuffer() {\r
-        ByteBuf bb = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        bb.writeBytes(XID);\r
-        bb.writeBytes(new byte[0]);\r
-        return bb;\r
-    }\r
-\r
-    /**\r
-     * Use version 1.3 for encoded message\r
-     * @param input ByteBuf to be checked for correct OpenFlow Protocol header\r
-     * @param msgType type of received message\r
-     * @param length expected length of message in header\r
-     */\r
-    public static void checkHeaderV13(ByteBuf input, byte msgType, int length) {\r
-        checkHeader(input, msgType, length, (short) EncodeConstants.OF13_VERSION_ID);\r
-    }\r
-    \r
-    /**\r
-     * Use version 1.0 for encoded message\r
-     * @param input ByteBuf to be checked for correct OpenFlow Protocol header\r
-     * @param msgType type of received message\r
-     * @param length expected length of message in header\r
-     */\r
-    public static void checkHeaderV10(ByteBuf input, byte msgType, int length) {\r
-        checkHeader(input, msgType, length, (short) EncodeConstants.OF10_VERSION_ID);\r
-    }\r
-    \r
-    private static void checkHeader(ByteBuf input, byte msgType, int length, Short version) {\r
-        Assert.assertEquals("Wrong version", version, Short.valueOf(input.readByte()));\r
-        Assert.assertEquals("Wrong type", msgType, input.readByte());\r
-        Assert.assertEquals("Wrong length", length, input.readUnsignedShort());\r
-        Assert.assertEquals("Wrong Xid", DEFAULT_XID, Long.valueOf(input.readUnsignedInt()));\r
-    }\r
-    \r
-\r
-    /**\r
-     * @param ofHeader OpenFlow protocol header\r
-     */\r
-    public static void checkHeaderV13(OfHeader ofHeader) {\r
-        checkHeader(ofHeader, (short) EncodeConstants.OF13_VERSION_ID);\r
-    }\r
-    \r
-    /**\r
-     * @param ofHeader OpenFlow protocol header\r
-     */\r
-    public static void checkHeaderV10(OfHeader ofHeader) {\r
-        checkHeader(ofHeader, (short) EncodeConstants.OF10_VERSION_ID);\r
-    }\r
-    \r
-    private static void checkHeader(OfHeader ofHeader, Short version) {\r
-        Assert.assertEquals("Wrong version", version, ofHeader.getVersion());\r
-        Assert.assertEquals("Wrong Xid", DEFAULT_XID, ofHeader.getXid());\r
-    }\r
-    \r
-    /**\r
-     * @param builder\r
-     * @param version wire protocol number used\r
-     * @throws NoSuchMethodException\r
-     * @throws SecurityException\r
-     * @throws IllegalAccessException\r
-     * @throws IllegalArgumentException\r
-     * @throws InvocationTargetException\r
-     */\r
-    public static void setupHeader(Object builder, int version) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {\r
-        Method m = builder.getClass().getMethod("setVersion", Short.class);\r
-        m.invoke(builder, (short) version);\r
-        Method m2 = builder.getClass().getMethod("setXid", Long.class);\r
-        m2.invoke(builder, BufferHelper.DEFAULT_XID);\r
-    }\r
-    \r
-    /**\r
-     * Use version 1.3 for decoding message\r
-     * @param decoder decoder instance\r
-     * @param bb data input buffer\r
-     * @return message decoded pojo\r
-     */\r
-    public static <E extends DataObject> E decodeV13(OFDeserializer<E> decoder, ByteBuf bb) {\r
-        return bufferToMessage(decoder, EncodeConstants.OF13_VERSION_ID, bb);\r
-    }\r
-    \r
-    /**\r
-     * Use version 1.0 for decoding message\r
-     * @param decoder decoder instance\r
-     * @param bb data input buffer\r
-     * @return message decoded pojo\r
-     */\r
-    public static <E extends DataObject> E decodeV10(OFDeserializer<E> decoder, ByteBuf bb) {\r
-        return bufferToMessage(decoder, EncodeConstants.OF10_VERSION_ID, bb);\r
-    }\r
-    \r
-    private static <E extends DataObject> E bufferToMessage(OFDeserializer<E> decoder, short version, ByteBuf bb) {\r
-        return decoder.bufferToMessage(bb, version);\r
-    }\r
-    \r
-    /**\r
-     * Use OF-protocol version 1.3\r
-     * @param encoder serialize factory\r
-     * @param out buffer the result will be written into\r
-     * @param pojo input message\r
-     */\r
-    public static <E extends DataObject> void encodeV13(OFSerializer<E> encoder, ByteBuf out, E pojo) {\r
-        messageToBuffer(encoder, out, pojo, HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
-    }\r
-    \r
-    private static <E extends DataObject> void messageToBuffer(\r
-            OFSerializer<E> encoder, ByteBuf out, E pojo, Short version) {\r
-        encoder.messageToBuffer(version, out, pojo);\r
-    }\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+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.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+/**
+ * @author michal.polkorab
+ * 
+ */
+public abstract class BufferHelper {
+
+    /**
+     * 
+     */
+    public static final Long DEFAULT_XID = 0x01020304L;
+    private static final byte[] XID = new byte[] { 0x01, 0x02, 0x03, 0x04 };
+
+    /**
+     * @param payload
+     * @return ByteBuf filled with OpenFlow protocol message without first 4
+     *         bytes
+     */
+    public static ByteBuf buildBuffer(byte[] payload) {
+        ByteBuf bb = UnpooledByteBufAllocator.DEFAULT.buffer();
+        bb.writeBytes(XID);
+        bb.writeBytes(payload);
+        return bb;
+    }
+    
+    /**
+     * @param payload String in hex format
+     * @return ByteBuf filled with OpenFlow protocol message without first 4
+     *         bytes
+     */
+    public static ByteBuf buildBuffer(String payload) {
+        return buildBuffer(ByteBufUtils.hexStringToBytes(payload));
+    }
+    
+    /**
+     * @return ByteBuf filled with OpenFlow protocol header message without first 4
+     *         bytes
+     */
+    public static ByteBuf buildBuffer() {
+        ByteBuf bb = UnpooledByteBufAllocator.DEFAULT.buffer();
+        bb.writeBytes(XID);
+        bb.writeBytes(new byte[0]);
+        return bb;
+    }
+
+    /**
+     * Use version 1.3 for encoded message
+     * @param input ByteBuf to be checked for correct OpenFlow Protocol header
+     * @param msgType type of received message
+     * @param length expected length of message in header
+     */
+    public static void checkHeaderV13(ByteBuf input, byte msgType, int length) {
+        checkHeader(input, msgType, length, (short) EncodeConstants.OF13_VERSION_ID);
+    }
+    
+    /**
+     * Use version 1.0 for encoded message
+     * @param input ByteBuf to be checked for correct OpenFlow Protocol header
+     * @param msgType type of received message
+     * @param length expected length of message in header
+     */
+    public static void checkHeaderV10(ByteBuf input, byte msgType, int length) {
+        checkHeader(input, msgType, length, (short) EncodeConstants.OF10_VERSION_ID);
+    }
+    
+    private static void checkHeader(ByteBuf input, byte msgType, int length, Short version) {
+        Assert.assertEquals("Wrong version", version, Short.valueOf(input.readByte()));
+        Assert.assertEquals("Wrong type", msgType, input.readByte());
+        Assert.assertEquals("Wrong length", length, input.readUnsignedShort());
+        Assert.assertEquals("Wrong Xid", DEFAULT_XID, Long.valueOf(input.readUnsignedInt()));
+    }
+    
+
+    /**
+     * @param ofHeader OpenFlow protocol header
+     */
+    public static void checkHeaderV13(OfHeader ofHeader) {
+        checkHeader(ofHeader, (short) EncodeConstants.OF13_VERSION_ID);
+    }
+    
+    /**
+     * @param ofHeader OpenFlow protocol header
+     */
+    public static void checkHeaderV10(OfHeader ofHeader) {
+        checkHeader(ofHeader, (short) EncodeConstants.OF10_VERSION_ID);
+    }
+    
+    private static void checkHeader(OfHeader ofHeader, Short version) {
+        Assert.assertEquals("Wrong version", version, ofHeader.getVersion());
+        Assert.assertEquals("Wrong Xid", DEFAULT_XID, ofHeader.getXid());
+    }
+    
+    /**
+     * @param builder
+     * @param version wire protocol number used
+     * @throws NoSuchMethodException
+     * @throws SecurityException
+     * @throws IllegalAccessException
+     * @throws IllegalArgumentException
+     * @throws InvocationTargetException
+     */
+    public static void setupHeader(Object builder, int version) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+        Method m = builder.getClass().getMethod("setVersion", Short.class);
+        m.invoke(builder, (short) version);
+        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
+     * @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);
+    }
+    
+    /**
+     * Use OF-protocol version 1.3
+     * @param encoder serialize factory
+     * @param out buffer the result will be written into
+     * @param pojo input message
+     */
+    public static <E extends DataObject> void encodeV13(OFSerializer<E> encoder, ByteBuf out, E pojo) {
+        messageToBuffer(encoder, out, pojo, HelloMessageFactoryTest.VERSION_YET_SUPPORTED);
+    }
+    
+    private static <E extends DataObject> void messageToBuffer(
+            OFSerializer<E> encoder, ByteBuf out, E pojo, Short version) {
+        encoder.messageToBuffer(version, out, pojo);
+    }
+}
index 5596917a5831a1e0239d259129261db4519852ed..ce4b5301965fe939845b2fe5361c04eb397a75a1 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class ByteBufUtilsTest {\r
-\r
-    private byte[] expected = new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, (byte) 0xff};\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#hexStringToBytes(String)}\r
-     */\r
-    @Test\r
-    public void testHexStringToBytes() {\r
-        byte[] data = ByteBufUtils.hexStringToBytes("01 02 03 04 05 ff");\r
-\r
-        Assert.assertArrayEquals(expected, data);\r
-    }\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#hexStringToBytes(String, boolean)}\r
-     */\r
-    @Test\r
-    public void testHexStringToBytes2() {\r
-        byte[] data = ByteBufUtils.hexStringToBytes("0102030405ff", false);\r
-\r
-        Assert.assertArrayEquals(expected, data);\r
-    }\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#hexStringToByteBuf(String)}\r
-     */\r
-    @Test\r
-    public void testHexStringToByteBuf() {\r
-        ByteBuf bb = ByteBufUtils.hexStringToByteBuf("01 02 03 04 05 ff");\r
-        \r
-        Assert.assertArrayEquals(expected, byteBufToByteArray(bb));\r
-    }\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#hexStringToByteBuf(String, ByteBuf)}\r
-     */\r
-    @Test\r
-    public void testHexStringToGivenByteBuf() {\r
-        ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        ByteBufUtils.hexStringToByteBuf("01 02 03 04 05 ff", buffer);\r
-\r
-        Assert.assertArrayEquals(expected, byteBufToByteArray(buffer));\r
-    }\r
-    \r
-    private static byte[] byteBufToByteArray(ByteBuf bb) {\r
-        byte[] result = new byte[bb.readableBytes()];\r
-        bb.readBytes(result);\r
-        return result;\r
-    }\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}\r
-     */\r
-    @Test\r
-    public void testFillBitmaskByEmptyMap() {\r
-        Map<Integer, Boolean> emptyMap = new HashMap<>();\r
-        String expectedBinaryString = "00000000000000000000000000000000";\r
-        String bitmaskInBinaryString = toBinaryString(emptyMap, 32);\r
-        \r
-        Assert.assertEquals("Not null string", expectedBinaryString, bitmaskInBinaryString);\r
-    }\r
-\r
-    private static String toBinaryString(Map<Integer, Boolean> emptyMap, int length) {\r
-        String binaryString = Integer.toBinaryString(ByteBufUtils.fillBitMaskFromMap(emptyMap)); \r
-        return String.format("%"+length+"s", binaryString).replaceAll(" ", "0");\r
-    }\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}\r
-     */\r
-    @Test\r
-    public void testFillBitmaskByFullMap() {\r
-        Map<Integer, Boolean> fullMap = new HashMap<>();\r
-        String expectedBinaryString = "11111111111111111111111111111111";\r
-        String bitmaskValueInBinarySytring;\r
-        for(Integer i=0;i<=31;i++) {\r
-            fullMap.put(i, true);\r
-        }\r
-        bitmaskValueInBinarySytring = toBinaryString(fullMap, 32);\r
-        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);\r
-    }\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}\r
-     */\r
-    @Test\r
-    public void testFillBitmaskByZeroMap() {\r
-        Map<Integer, Boolean> zeroMap = new HashMap<>();\r
-        String expectedBinaryString = "00000000000000000000000000000000";\r
-        String bitmaskValueInBinarySytring;\r
-        for(Integer i=0;i<=31;i++) {\r
-            zeroMap.put(i, false);\r
-        }\r
-        bitmaskValueInBinarySytring = toBinaryString(zeroMap, 32);\r
-        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);\r
-    }\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}\r
-     */\r
-    @Test\r
-    public void testFillBitmaskByRandomSet() {\r
-        Map<Integer, Boolean> randomMap = new HashMap<>();\r
-        String expectedBinaryString = "00000000000000000111100000000000";\r
-        String bitmaskValueInBinarySytring;\r
-        Boolean mapValue;\r
-        for(Integer i=0;i<=31;i++) {\r
-            mapValue = false;\r
-            if(i>=11 && i<=14) {\r
-                mapValue = true;\r
-            }\r
-            randomMap.put(i, mapValue);\r
-        }\r
-        bitmaskValueInBinarySytring = toBinaryString(randomMap, 32);\r
-        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);\r
-    }\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}\r
-     */\r
-    @Test\r
-    public void testFillBitmaskByEmptyList() {\r
-        List<Boolean> emptyList = new ArrayList<>();\r
-        emptyList.add(null);\r
-        String expectedBinaryString = "00000000000000000000000000000000";\r
-        String bitmaskInBinaryString = listToBinaryString(emptyList, 32);\r
-        \r
-        Assert.assertEquals("Not null string", expectedBinaryString, bitmaskInBinaryString);\r
-    }\r
-\r
-    private static String listToBinaryString(List<Boolean> emptyList, int length) {\r
-        int[] bitMaskArray;\r
-        bitMaskArray = ByteBufUtils.fillBitMaskFromList(emptyList);\r
-        String binaryString = Integer.toBinaryString(bitMaskArray[0]); \r
-        return String.format("%"+length+"s", binaryString).replaceAll(" ", "0");\r
-    }\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}\r
-     */\r
-    @Test\r
-    public void testFillBitmaskByFullList() {\r
-        List<Boolean> fullList = new ArrayList<>();\r
-        String expectedBinaryString = "11111111111111111111111111111111";\r
-        String bitmaskValueInBinarySytring;\r
-        for(Integer i=0;i<=31;i++) {\r
-            fullList.add(true);\r
-        }\r
-        bitmaskValueInBinarySytring = listToBinaryString(fullList, 32);\r
-        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);\r
-    }\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}\r
-     */\r
-    @Test\r
-    public void testFillBitmaskByZeroList() {\r
-        List<Boolean> zeroList = new ArrayList<>();\r
-        String expectedBinaryString = "00000000000000000000000000000000";\r
-        String bitmaskValueInBinarySytring;\r
-        for(Integer i=0;i<=31;i++) {\r
-            zeroList.add(false);\r
-        }\r
-        bitmaskValueInBinarySytring = listToBinaryString(zeroList, 32);\r
-        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);\r
-    }\r
-    \r
-    /**\r
-     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}\r
-     */\r
-    @Test\r
-    public void testFillBitmaskFromRandomList() {\r
-        List<Boolean> randomList = new ArrayList<>();\r
-        String expectedBinaryString = "00000000000000000111100000000000";\r
-        String bitmaskValueInBinarySytring;\r
-        Boolean listValue;\r
-        for(Integer i=0;i<=31;i++) {\r
-            listValue = false;\r
-            if(i>=11 && i<=14) {\r
-                listValue = true;\r
-            }\r
-            randomList.add(listValue);\r
-        }\r
-        bitmaskValueInBinarySytring = listToBinaryString(randomList, 32);\r
-        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class ByteBufUtilsTest {
+
+    private byte[] expected = new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, (byte) 0xff};
+    
+    /**
+     * Test of {@link ByteBufUtils#hexStringToBytes(String)}
+     */
+    @Test
+    public void testHexStringToBytes() {
+        byte[] data = ByteBufUtils.hexStringToBytes("01 02 03 04 05 ff");
+
+        Assert.assertArrayEquals(expected, data);
+    }
+    
+    /**
+     * Test of {@link ByteBufUtils#hexStringToBytes(String, boolean)}
+     */
+    @Test
+    public void testHexStringToBytes2() {
+        byte[] data = ByteBufUtils.hexStringToBytes("0102030405ff", false);
+
+        Assert.assertArrayEquals(expected, data);
+    }
+    
+    /**
+     * Test of {@link ByteBufUtils#hexStringToByteBuf(String)}
+     */
+    @Test
+    public void testHexStringToByteBuf() {
+        ByteBuf bb = ByteBufUtils.hexStringToByteBuf("01 02 03 04 05 ff");
+        
+        Assert.assertArrayEquals(expected, byteBufToByteArray(bb));
+    }
+    
+    /**
+     * Test of {@link ByteBufUtils#hexStringToByteBuf(String, ByteBuf)}
+     */
+    @Test
+    public void testHexStringToGivenByteBuf() {
+        ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
+        ByteBufUtils.hexStringToByteBuf("01 02 03 04 05 ff", buffer);
+
+        Assert.assertArrayEquals(expected, byteBufToByteArray(buffer));
+    }
+    
+    private static byte[] byteBufToByteArray(ByteBuf bb) {
+        byte[] result = new byte[bb.readableBytes()];
+        bb.readBytes(result);
+        return result;
+    }
+    
+    /**
+     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}
+     */
+    @Test
+    public void testFillBitmaskByEmptyMap() {
+        Map<Integer, Boolean> emptyMap = new HashMap<>();
+        String expectedBinaryString = "00000000000000000000000000000000";
+        String bitmaskInBinaryString = toBinaryString(emptyMap, 32);
+        
+        Assert.assertEquals("Not null string", expectedBinaryString, bitmaskInBinaryString);
+    }
+
+    private static String toBinaryString(Map<Integer, Boolean> emptyMap, int length) {
+        String binaryString = Integer.toBinaryString(ByteBufUtils.fillBitMaskFromMap(emptyMap)); 
+        return String.format("%"+length+"s", binaryString).replaceAll(" ", "0");
+    }
+    
+    /**
+     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}
+     */
+    @Test
+    public void testFillBitmaskByFullMap() {
+        Map<Integer, Boolean> fullMap = new HashMap<>();
+        String expectedBinaryString = "11111111111111111111111111111111";
+        String bitmaskValueInBinarySytring;
+        for(Integer i=0;i<=31;i++) {
+            fullMap.put(i, true);
+        }
+        bitmaskValueInBinarySytring = toBinaryString(fullMap, 32);
+        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);
+    }
+    
+    /**
+     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}
+     */
+    @Test
+    public void testFillBitmaskByZeroMap() {
+        Map<Integer, Boolean> zeroMap = new HashMap<>();
+        String expectedBinaryString = "00000000000000000000000000000000";
+        String bitmaskValueInBinarySytring;
+        for(Integer i=0;i<=31;i++) {
+            zeroMap.put(i, false);
+        }
+        bitmaskValueInBinarySytring = toBinaryString(zeroMap, 32);
+        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);
+    }
+    
+    /**
+     * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)}
+     */
+    @Test
+    public void testFillBitmaskByRandomSet() {
+        Map<Integer, Boolean> randomMap = new HashMap<>();
+        String expectedBinaryString = "00000000000000000111100000000000";
+        String bitmaskValueInBinarySytring;
+        Boolean mapValue;
+        for(Integer i=0;i<=31;i++) {
+            mapValue = false;
+            if(i>=11 && i<=14) {
+                mapValue = true;
+            }
+            randomMap.put(i, mapValue);
+        }
+        bitmaskValueInBinarySytring = toBinaryString(randomMap, 32);
+        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);
+    }
+    
+    /**
+     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+     */
+    @Test
+    public void testFillBitmaskByEmptyList() {
+        List<Boolean> emptyList = new ArrayList<>();
+        emptyList.add(null);
+        String expectedBinaryString = "00000000000000000000000000000000";
+        String bitmaskInBinaryString = listToBinaryString(emptyList, 32);
+        
+        Assert.assertEquals("Not null string", expectedBinaryString, bitmaskInBinaryString);
+    }
+
+    private static String listToBinaryString(List<Boolean> emptyList, int length) {
+        int[] bitMaskArray;
+        bitMaskArray = ByteBufUtils.fillBitMaskFromList(emptyList);
+        String binaryString = Integer.toBinaryString(bitMaskArray[0]); 
+        return String.format("%"+length+"s", binaryString).replaceAll(" ", "0");
+    }
+    
+    /**
+     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+     */
+    @Test
+    public void testFillBitmaskByFullList() {
+        List<Boolean> fullList = new ArrayList<>();
+        String expectedBinaryString = "11111111111111111111111111111111";
+        String bitmaskValueInBinarySytring;
+        for(Integer i=0;i<=31;i++) {
+            fullList.add(true);
+        }
+        bitmaskValueInBinarySytring = listToBinaryString(fullList, 32);
+        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);
+    }
+    
+    /**
+     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+     */
+    @Test
+    public void testFillBitmaskByZeroList() {
+        List<Boolean> zeroList = new ArrayList<>();
+        String expectedBinaryString = "00000000000000000000000000000000";
+        String bitmaskValueInBinarySytring;
+        for(Integer i=0;i<=31;i++) {
+            zeroList.add(false);
+        }
+        bitmaskValueInBinarySytring = listToBinaryString(zeroList, 32);
+        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);
+    }
+    
+    /**
+     * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+     */
+    @Test
+    public void testFillBitmaskFromRandomList() {
+        List<Boolean> randomList = new ArrayList<>();
+        String expectedBinaryString = "00000000000000000111100000000000";
+        String bitmaskValueInBinarySytring;
+        Boolean listValue;
+        for(Integer i=0;i<=31;i++) {
+            listValue = false;
+            if(i>=11 && i<=14) {
+                listValue = true;
+            }
+            randomList.add(listValue);
+        }
+        bitmaskValueInBinarySytring = listToBinaryString(randomList, 32);
+        Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring);
+    }
+
+}
index 67d148fb935006f5d998739f1639b533fa67fe58..220e7bcefb92a2da0252b2af477c07448e4c7393 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\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.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.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.Ipv4Src;\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.Ipv6NdTarget;\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.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.oxm.fields.MatchEntries;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntriesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.MatchBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class MatchSerializerTest {\r
-\r
-    /**\r
-     * Test for correct serialization of Ipv4Address match entry\r
-     */\r
-    @Test\r
-    public void test() {\r
-        MatchBuilder builder = new MatchBuilder();\r
-        builder.setType(OxmMatchType.class);\r
-        List<MatchEntries> entries = new ArrayList<>();\r
-        MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder();\r
-        entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
-        entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
-        entriesBuilder.setHasMask(false);\r
-        Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder();\r
-        addressBuilder.setIpv4Address(new Ipv4Address("1.2.3.4"));\r
-        entriesBuilder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build());\r
-        entries.add(entriesBuilder.build());\r
-        builder.setMatchEntries(entries);\r
-        Match match = builder.build();\r
-        \r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MatchSerializer.encodeMatch(match, out);\r
-        \r
-        Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());\r
-        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-        Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong field and mask", 22, out.readUnsignedByte());\r
-        out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
-        Assert.assertEquals("Wrong ip address (first number)", 1, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong ip address (second number)", 2, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong ip address (third number)", 3, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong ip address (fourth number)", 4, out.readUnsignedByte());\r
-    }\r
-    \r
-    /**\r
-     * Test for correct serialization of Ipv6Address match entry\r
-     */\r
-    @Test\r
-    public void test2() {\r
-        MatchBuilder builder = new MatchBuilder();\r
-        builder.setType(OxmMatchType.class);\r
-        List<MatchEntries> entries = new ArrayList<>();\r
-        // ipv6 match entry with correct Ipv6 address\r
-        MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder();\r
-        entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
-        entriesBuilder.setOxmMatchField(Ipv6Src.class);\r
-        entriesBuilder.setHasMask(false);\r
-        Ipv6AddressMatchEntryBuilder addressBuilder = new Ipv6AddressMatchEntryBuilder();\r
-        addressBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8"));\r
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());\r
-        entries.add(entriesBuilder.build());\r
-        // ipv6 match entry with abbreviated Ipv6 address\r
-        entriesBuilder = new MatchEntriesBuilder();\r
-        entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
-        entriesBuilder.setOxmMatchField(Ipv6NdTarget.class);\r
-        entriesBuilder.setHasMask(false);\r
-        addressBuilder = new Ipv6AddressMatchEntryBuilder();\r
-        addressBuilder.setIpv6Address(new Ipv6Address("1:2::6:7:8"));\r
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());\r
-        entries.add(entriesBuilder.build());\r
-        // ipv6 match entry with abbreviated Ipv6 address\r
-        entriesBuilder = new MatchEntriesBuilder();\r
-        entriesBuilder.setOxmClass(Nxm1Class.class);\r
-        entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
-        entriesBuilder.setHasMask(false);\r
-        addressBuilder = new Ipv6AddressMatchEntryBuilder();\r
-        addressBuilder.setIpv6Address(new Ipv6Address("1::8"));\r
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());\r
-        entries.add(entriesBuilder.build());\r
-        // ipv6 match entry with abbreviated Ipv6 address\r
-        entriesBuilder = new MatchEntriesBuilder();\r
-        entriesBuilder.setOxmClass(Nxm1Class.class);\r
-        entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
-        entriesBuilder.setHasMask(false);\r
-        addressBuilder = new Ipv6AddressMatchEntryBuilder();\r
-        addressBuilder.setIpv6Address(new Ipv6Address("::1"));\r
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());\r
-        entries.add(entriesBuilder.build());\r
-        // ipv6 match entry with abbreviated Ipv6 address\r
-        entriesBuilder = new MatchEntriesBuilder();\r
-        entriesBuilder.setOxmClass(Nxm0Class.class);\r
-        entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
-        entriesBuilder.setHasMask(false);\r
-        addressBuilder = new Ipv6AddressMatchEntryBuilder();\r
-        addressBuilder.setIpv6Address(new Ipv6Address("::"));\r
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());\r
-        entries.add(entriesBuilder.build());\r
-        // ipv6 match entry with incorrect Ipv6 address (longer)\r
-        entriesBuilder = new MatchEntriesBuilder();\r
-        entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
-        entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
-        entriesBuilder.setHasMask(false);\r
-        addressBuilder = new Ipv6AddressMatchEntryBuilder();\r
-        addressBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8:9"));\r
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());\r
-        entries.add(entriesBuilder.build());\r
-        builder.setMatchEntries(entries);\r
-        Match match = builder.build();\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MatchSerializer.encodeMatch(match, out);\r
-        \r
-        Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());\r
-        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
-        Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong field and mask", 52, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 2, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 3, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 4, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 5, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 6, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 7, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong field and mask", 62, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 2, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 6, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 7, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong class", 0x0001, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong class", 0x0001, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong class", 0x0000, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 2, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 3, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 4, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 5, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 6, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 7, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+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.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.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.Ipv6NdTarget;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;
+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.oxm.fields.MatchEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntriesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.MatchBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class MatchSerializerTest {
+
+    /**
+     * Test for correct serialization of Ipv4Address match entry
+     */
+    @Test
+    public void test() {
+        MatchBuilder builder = new MatchBuilder();
+        builder.setType(OxmMatchType.class);
+        List<MatchEntries> entries = new ArrayList<>();
+        MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(Ipv4Src.class);
+        entriesBuilder.setHasMask(false);
+        Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder();
+        addressBuilder.setIpv4Address(new Ipv4Address("1.2.3.4"));
+        entriesBuilder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build());
+        entries.add(entriesBuilder.build());
+        builder.setMatchEntries(entries);
+        Match match = builder.build();
+        
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MatchSerializer.encodeMatch(match, out);
+        
+        Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
+        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
+        Assert.assertEquals("Wrong field and mask", 22, out.readUnsignedByte());
+        out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
+        Assert.assertEquals("Wrong ip address (first number)", 1, out.readUnsignedByte());
+        Assert.assertEquals("Wrong ip address (second number)", 2, out.readUnsignedByte());
+        Assert.assertEquals("Wrong ip address (third number)", 3, out.readUnsignedByte());
+        Assert.assertEquals("Wrong ip address (fourth number)", 4, out.readUnsignedByte());
+    }
+    
+    /**
+     * Test for correct serialization of Ipv6Address match entry
+     */
+    @Test
+    public void test2() {
+        MatchBuilder builder = new MatchBuilder();
+        builder.setType(OxmMatchType.class);
+        List<MatchEntries> entries = new ArrayList<>();
+        // ipv6 match entry with correct Ipv6 address
+        MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(Ipv6Src.class);
+        entriesBuilder.setHasMask(false);
+        Ipv6AddressMatchEntryBuilder addressBuilder = new Ipv6AddressMatchEntryBuilder();
+        addressBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8"));
+        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
+        entries.add(entriesBuilder.build());
+        // ipv6 match entry with abbreviated Ipv6 address
+        entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(Ipv6NdTarget.class);
+        entriesBuilder.setHasMask(false);
+        addressBuilder = new Ipv6AddressMatchEntryBuilder();
+        addressBuilder.setIpv6Address(new Ipv6Address("1:2::6:7:8"));
+        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
+        entries.add(entriesBuilder.build());
+        // ipv6 match entry with abbreviated Ipv6 address
+        entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder.setOxmClass(Nxm1Class.class);
+        entriesBuilder.setOxmMatchField(Ipv6Dst.class);
+        entriesBuilder.setHasMask(false);
+        addressBuilder = new Ipv6AddressMatchEntryBuilder();
+        addressBuilder.setIpv6Address(new Ipv6Address("1::8"));
+        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
+        entries.add(entriesBuilder.build());
+        // ipv6 match entry with abbreviated Ipv6 address
+        entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder.setOxmClass(Nxm1Class.class);
+        entriesBuilder.setOxmMatchField(Ipv6Dst.class);
+        entriesBuilder.setHasMask(false);
+        addressBuilder = new Ipv6AddressMatchEntryBuilder();
+        addressBuilder.setIpv6Address(new Ipv6Address("::1"));
+        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
+        entries.add(entriesBuilder.build());
+        // ipv6 match entry with abbreviated Ipv6 address
+        entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder.setOxmClass(Nxm0Class.class);
+        entriesBuilder.setOxmMatchField(Ipv6Dst.class);
+        entriesBuilder.setHasMask(false);
+        addressBuilder = new Ipv6AddressMatchEntryBuilder();
+        addressBuilder.setIpv6Address(new Ipv6Address("::"));
+        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
+        entries.add(entriesBuilder.build());
+        // ipv6 match entry with incorrect Ipv6 address (longer)
+        entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(Ipv6Dst.class);
+        entriesBuilder.setHasMask(false);
+        addressBuilder = new Ipv6AddressMatchEntryBuilder();
+        addressBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8:9"));
+        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
+        entries.add(entriesBuilder.build());
+        builder.setMatchEntries(entries);
+        Match match = builder.build();
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MatchSerializer.encodeMatch(match, out);
+        
+        Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
+        out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
+        Assert.assertEquals("Wrong field and mask", 52, out.readUnsignedByte());
+        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
+        Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 2, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 3, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 4, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 5, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 6, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 7, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());
+        Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
+        Assert.assertEquals("Wrong field and mask", 62, out.readUnsignedByte());
+        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
+        Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 2, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 6, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 7, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());
+        Assert.assertEquals("Wrong class", 0x0001, out.readUnsignedShort());
+        Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());
+        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
+        Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());
+        Assert.assertEquals("Wrong class", 0x0001, out.readUnsignedShort());
+        Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());
+        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());
+        Assert.assertEquals("Wrong class", 0x0000, out.readUnsignedShort());
+        Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());
+        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
+        Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());
+        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
+        Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 2, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 3, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 4, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 5, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 6, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 7, out.readUnsignedShort());
+        Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());
+    }
+
+}
index 06b78e3487455d00ee5c8bb127d579fd6a98b51a..30c2c3f9265040fb1f5f8dc8adf73e1003296fa6 100644 (file)
@@ -1,75 +1,82 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\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.yang.types.rev100924.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10MatchDeserializerTest {\r
-\r
-    /**\r
-     * Testing correct deserialization of ofp_match\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf message = BufferHelper.buildBuffer("00 24 08 91 00 20 AA BB CC DD EE FF "\r
-                + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 "\r
-                + "50 50 20 20");\r
-        message.skipBytes(4); // skip XID\r
-        MatchV10 match = OF10MatchDeserializer.createMatchV10(message);\r
-        Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, false, true, false,\r
-                false, true, false, true, true, false), match.getWildcards());\r
-        Assert.assertEquals("Wrong srcMask", 24, match.getNwSrcMask().shortValue());\r
-        Assert.assertEquals("Wrong dstMask", 16, match.getNwDstMask().shortValue());\r
-        Assert.assertEquals("Wrong in-port", 32, match.getInPort().intValue());\r
-        Assert.assertEquals("Wrong dl-src", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlSrc());\r
-        Assert.assertEquals("Wrong dl-dst", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlDst());\r
-        Assert.assertEquals("Wrong dl-vlan", 5, match.getDlVlan().intValue());\r
-        Assert.assertEquals("Wrong dl-vlan-pcp", 16, match.getDlVlanPcp().shortValue());\r
-        Assert.assertEquals("Wrong dl-type", 8, match.getDlType().intValue());\r
-        Assert.assertEquals("Wrong nw-tos", 7, match.getNwTos().shortValue());\r
-        Assert.assertEquals("Wrong nw-proto", 6, match.getNwProto().shortValue());\r
-        Assert.assertEquals("Wrong nw-src", new Ipv4Address("16.17.18.19"), match.getNwSrc());\r
-        Assert.assertEquals("Wrong nw-dst", new Ipv4Address("1.2.3.4"), match.getNwDst());\r
-        Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue());\r
-        Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue());\r
-    }\r
-    \r
-    /**\r
-     * Testing correct deserialization of ofp_match\r
-     */\r
-    @Test\r
-    public void test2() {\r
-        ByteBuf message = BufferHelper.buildBuffer("00 3F FF FF 00 20 AA BB CC DD EE FF "\r
-                + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 "\r
-                + "50 50 20 20");\r
-        message.skipBytes(4); // skip XID\r
-        MatchV10 match = OF10MatchDeserializer.createMatchV10(message);\r
-        Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(true, true, true, true, true,\r
-                true, true, true, true, true, true), match.getWildcards());\r
-        Assert.assertEquals("Wrong srcMask", 0, match.getNwSrcMask().shortValue());\r
-        Assert.assertEquals("Wrong dstMask", 0, match.getNwDstMask().shortValue());\r
-        Assert.assertEquals("Wrong in-port", 32, match.getInPort().intValue());\r
-        Assert.assertEquals("Wrong dl-src", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlSrc());\r
-        Assert.assertEquals("Wrong dl-dst", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlDst());\r
-        Assert.assertEquals("Wrong dl-vlan", 5, match.getDlVlan().intValue());\r
-        Assert.assertEquals("Wrong dl-vlan-pcp", 16, match.getDlVlanPcp().shortValue());\r
-        Assert.assertEquals("Wrong dl-type", 8, match.getDlType().intValue());\r
-        Assert.assertEquals("Wrong nw-tos", 7, match.getNwTos().shortValue());\r
-        Assert.assertEquals("Wrong nw-proto", 6, match.getNwProto().shortValue());\r
-        Assert.assertEquals("Wrong nw-src", new Ipv4Address("16.17.18.19"), match.getNwSrc());\r
-        Assert.assertEquals("Wrong nw-dst", new Ipv4Address("1.2.3.4"), match.getNwDst());\r
-        Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue());\r
-        Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue());\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import io.netty.buffer.ByteBuf;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10MatchDeserializerTest {
+
+    /**
+     * Testing correct deserialization of ofp_match
+     */
+    @Test
+    public void test() {
+        ByteBuf message = BufferHelper.buildBuffer("00 24 08 91 00 20 AA BB CC DD EE FF "
+                + "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);
+        Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, false, true, false,
+                false, true, false, true, true, false), match.getWildcards());
+        Assert.assertEquals("Wrong srcMask", 24, match.getNwSrcMask().shortValue());
+        Assert.assertEquals("Wrong dstMask", 16, match.getNwDstMask().shortValue());
+        Assert.assertEquals("Wrong in-port", 32, match.getInPort().intValue());
+        Assert.assertEquals("Wrong dl-src", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlSrc());
+        Assert.assertEquals("Wrong dl-dst", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlDst());
+        Assert.assertEquals("Wrong dl-vlan", 5, match.getDlVlan().intValue());
+        Assert.assertEquals("Wrong dl-vlan-pcp", 16, match.getDlVlanPcp().shortValue());
+        Assert.assertEquals("Wrong dl-type", 8, match.getDlType().intValue());
+        Assert.assertEquals("Wrong nw-tos", 7, match.getNwTos().shortValue());
+        Assert.assertEquals("Wrong nw-proto", 6, match.getNwProto().shortValue());
+        Assert.assertEquals("Wrong nw-src", new Ipv4Address("16.17.18.19"), match.getNwSrc());
+        Assert.assertEquals("Wrong nw-dst", new Ipv4Address("1.2.3.4"), match.getNwDst());
+        Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue());
+        Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue());
+    }
+    
+    /**
+     * Testing correct deserialization of ofp_match
+     */
+    @Test
+    public void test2() {
+        ByteBuf message = BufferHelper.buildBuffer("00 3F FF FF 00 20 AA BB CC DD EE FF "
+                + "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);
+        Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(true, true, true, true, true,
+                true, true, true, true, true, true), match.getWildcards());
+        Assert.assertEquals("Wrong srcMask", 0, match.getNwSrcMask().shortValue());
+        Assert.assertEquals("Wrong dstMask", 0, match.getNwDstMask().shortValue());
+        Assert.assertEquals("Wrong in-port", 32, match.getInPort().intValue());
+        Assert.assertEquals("Wrong dl-src", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlSrc());
+        Assert.assertEquals("Wrong dl-dst", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlDst());
+        Assert.assertEquals("Wrong dl-vlan", 5, match.getDlVlan().intValue());
+        Assert.assertEquals("Wrong dl-vlan-pcp", 16, match.getDlVlanPcp().shortValue());
+        Assert.assertEquals("Wrong dl-type", 8, match.getDlType().intValue());
+        Assert.assertEquals("Wrong nw-tos", 7, match.getNwTos().shortValue());
+        Assert.assertEquals("Wrong nw-proto", 6, match.getNwProto().shortValue());
+        Assert.assertEquals("Wrong nw-src", new Ipv4Address("16.17.18.19"), match.getNwSrc());
+        Assert.assertEquals("Wrong nw-dst", new Ipv4Address("1.2.3.4"), match.getNwDst());
+        Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue());
+        Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue());
+    }
+
+}
index c077cf8336ab63f875003cd63cd174f8f1d80346..240d64cad79b1988fc050b9db17481618e8edd96 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.util;\r
-\r
-import junit.framework.Assert;\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.UnpooledByteBufAllocator;\r
-\r
-import org.junit.Test;\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.yang.types.rev100924.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10MatchSerializerTest {\r
-\r
-    /**\r
-     * Testing correct serialization of ofp_match\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MatchV10Builder builder = new MatchV10Builder();\r
-        builder.setWildcards(new FlowWildcardsV10(false, false, false, true, false,\r
-                false, true, false, true, true, true));\r
-        builder.setNwSrcMask((short) 24);\r
-        builder.setNwDstMask((short) 16);\r
-        builder.setInPort(6653);\r
-        builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));\r
-        builder.setDlDst(new MacAddress("02:02:02:02:02:02"));\r
-        builder.setDlVlan(128);\r
-        builder.setDlVlanPcp((short) 2);\r
-        builder.setDlType(15);\r
-        builder.setNwTos((short) 14);\r
-        builder.setNwProto((short) 85);\r
-        builder.setNwSrc(new Ipv4Address("1.1.1.2"));\r
-        builder.setNwDst(new Ipv4Address("32.16.8.1"));\r
-        builder.setTpSrc(2048);\r
-        builder.setTpDst(4096);\r
-        MatchV10 match = builder.build();\r
-        OF10MatchSerializer.encodeMatchV10(out, match);\r
-        \r
-        Assert.assertEquals("Wrong wildcards", 2361553, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());\r
-        byte[] dlSrc = new byte[6];\r
-        out.readBytes(dlSrc);\r
-        Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));\r
-        byte[] dlDst = new byte[6];\r
-        out.readBytes(dlDst);\r
-        Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));\r
-        Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());\r
-        out.skipBytes(1);\r
-        Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());\r
-        out.skipBytes(2);\r
-        Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());\r
-    }\r
-    \r
-    /**\r
-     * Testing correct serialization of ofp_match\r
-     */\r
-    @Test\r
-    public void test2() {\r
-        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
-        MatchV10Builder builder = new MatchV10Builder();\r
-        builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true,\r
-                true, true, true, true, true, true));\r
-        builder.setNwSrcMask((short) 0);\r
-        builder.setNwDstMask((short) 0);\r
-        builder.setInPort(6653);\r
-        builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));\r
-        builder.setDlDst(new MacAddress("02:02:02:02:02:02"));\r
-        builder.setDlVlan(128);\r
-        builder.setDlVlanPcp((short) 2);\r
-        builder.setDlType(15);\r
-        builder.setNwTos((short) 14);\r
-        builder.setNwProto((short) 85);\r
-        builder.setNwSrc(new Ipv4Address("1.1.1.2"));\r
-        builder.setNwDst(new Ipv4Address("32.16.8.1"));\r
-        builder.setTpSrc(2048);\r
-        builder.setTpDst(4096);\r
-        MatchV10 match = builder.build();\r
-        OF10MatchSerializer.encodeMatchV10(out, match);\r
-        \r
-        Assert.assertEquals("Wrong wildcards", 4194303, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());\r
-        byte[] dlSrc = new byte[6];\r
-        out.readBytes(dlSrc);\r
-        Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));\r
-        byte[] dlDst = new byte[6];\r
-        out.readBytes(dlDst);\r
-        Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));\r
-        Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());\r
-        out.skipBytes(1);\r
-        Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());\r
-        Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());\r
-        out.skipBytes(2);\r
-        Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());\r
-        Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());\r
-        Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());\r
-    }\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import junit.framework.Assert;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10MatchSerializerTest {
+
+    /**
+     * Testing correct serialization of ofp_match
+     */
+    @Test
+    public void test() {
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MatchV10Builder builder = new MatchV10Builder();
+        builder.setWildcards(new FlowWildcardsV10(false, false, false, true, false,
+                false, true, false, true, true, true));
+        builder.setNwSrcMask((short) 24);
+        builder.setNwDstMask((short) 16);
+        builder.setInPort(6653);
+        builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
+        builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
+        builder.setDlVlan(128);
+        builder.setDlVlanPcp((short) 2);
+        builder.setDlType(15);
+        builder.setNwTos((short) 14);
+        builder.setNwProto((short) 85);
+        builder.setNwSrc(new Ipv4Address("1.1.1.2"));
+        builder.setNwDst(new Ipv4Address("32.16.8.1"));
+        builder.setTpSrc(2048);
+        builder.setTpDst(4096);
+        MatchV10 match = builder.build();
+        OF10MatchSerializer.encodeMatchV10(out, match);
+        
+        Assert.assertEquals("Wrong wildcards", 2361553, out.readUnsignedInt());
+        Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
+        byte[] dlSrc = new byte[6];
+        out.readBytes(dlSrc);
+        Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
+        byte[] dlDst = new byte[6];
+        out.readBytes(dlDst);
+        Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));
+        Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());
+        Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());
+        out.skipBytes(1);
+        Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());
+        Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());
+        Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());
+        out.skipBytes(2);
+        Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());
+        Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());
+        Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
+        Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
+    }
+    
+    /**
+     * Testing correct serialization of ofp_match
+     */
+    @Test
+    public void test2() {
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        MatchV10Builder builder = new MatchV10Builder();
+        builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true,
+                true, true, true, true, true, true));
+        builder.setNwSrcMask((short) 0);
+        builder.setNwDstMask((short) 0);
+        builder.setInPort(6653);
+        builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
+        builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
+        builder.setDlVlan(128);
+        builder.setDlVlanPcp((short) 2);
+        builder.setDlType(15);
+        builder.setNwTos((short) 14);
+        builder.setNwProto((short) 85);
+        builder.setNwSrc(new Ipv4Address("1.1.1.2"));
+        builder.setNwDst(new Ipv4Address("32.16.8.1"));
+        builder.setTpSrc(2048);
+        builder.setTpDst(4096);
+        MatchV10 match = builder.build();
+        OF10MatchSerializer.encodeMatchV10(out, match);
+        
+        Assert.assertEquals("Wrong wildcards", 4194303, out.readUnsignedInt());
+        Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
+        byte[] dlSrc = new byte[6];
+        out.readBytes(dlSrc);
+        Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
+        byte[] dlDst = new byte[6];
+        out.readBytes(dlDst);
+        Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));
+        Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());
+        Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());
+        out.skipBytes(1);
+        Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());
+        Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());
+        Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());
+        out.skipBytes(2);
+        Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());
+        Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());
+        Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
+        Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
+    }
+}
index d7d3ccf17f623111488894b80cfcacb953a97373..2627d61fbe760870b475a3f9cd74cc43dea0a641 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.integration;\r
-\r
-import java.net.InetAddress;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Stack;\r
-import java.util.concurrent.ExecutionException;\r
-import java.util.concurrent.TimeUnit;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;\r
-import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration.FEATURE_SUPPORT;\r
-import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent;\r
-import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioFactory;\r
-import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler;\r
-import org.opendaylight.openflowjava.protocol.impl.clients.SendEvent;\r
-import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient;\r
-import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent;\r
-import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent;\r
-import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl;\r
-import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @author timotej.kubas\r
- */\r
-public class IntegrationTest {\r
-\r
-    private static final Logger LOGGER = LoggerFactory\r
-            .getLogger(IntegrationTest.class);\r
-    private static int port;\r
-    private static final FEATURE_SUPPORT DEFAULT_TLS_SUPPORT = FEATURE_SUPPORT.NOT_SUPPORTED;\r
-    private static final int SWITCH_IDLE_TIMEOUT = 2000;\r
-    private static final long CONNECTION_TIMEOUT = 2000;\r
-    private InetAddress startupAddress;\r
-    private MockPlugin mockPlugin;\r
-    private SwitchConnectionProviderImpl scpimpl;\r
-    private List<ConnectionConfiguration> configs;\r
-\r
-    /**\r
-     * @throws Exception\r
-     */\r
-    @Before\r
-    public void setUp() throws Exception {\r
-        LOGGER.debug("\n\nstarting test -------------------------------");\r
-        startupAddress = InetAddress.getLocalHost();\r
-        mockPlugin = new MockPlugin();\r
-        scpimpl = new SwitchConnectionProviderImpl();\r
-        scpimpl.setSwitchConnectionHandler(mockPlugin);\r
-        configs = new ArrayList<>();\r
-        configs.add(new TestingConnConfigImpl(startupAddress, 0, DEFAULT_TLS_SUPPORT, SWITCH_IDLE_TIMEOUT));\r
-        scpimpl.configure(configs);\r
-        scpimpl.startup().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);\r
-        TcpHandler server = (TcpHandler) scpimpl.getServerLot().iterator().next();\r
-        port = server.getPort();\r
-    }\r
-\r
-    /**\r
-     * @throws Exception\r
-     */\r
-    @After\r
-    public void tearDown() throws Exception {\r
-        Thread.sleep(500);\r
-    }\r
-\r
-    /**\r
-     * Library integration and communication test with handshake\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testHandshake() throws Exception {\r
-        int amountOfCLients = 1;\r
-        Stack<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();\r
-        ScenarioHandler handler = new ScenarioHandler(scenario);\r
-        List<SimpleClient> clients = createAndStartClient(amountOfCLients, handler);\r
-        SimpleClient firstClient = clients.get(0);\r
-        firstClient.getScenarioDone().get();\r
-        mockPlugin.shutdown();\r
-        mockPlugin.getFinishedFuture().get();\r
-    }\r
-\r
-    /**\r
-     * Library integration and communication test with handshake + echo exchange\r
-     * @throws Exception \r
-     */\r
-    @Test\r
-    public void testHandshakeAndEcho() throws Exception {\r
-        int amountOfCLients = 1;\r
-        Stack<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();\r
-        scenario.add(0, new SleepEvent(100));\r
-        scenario.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04")));\r
-        scenario.add(0, new SleepEvent(100));\r
-        scenario.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));\r
-        ScenarioHandler handler = new ScenarioHandler(scenario);\r
-        List<SimpleClient> clients = createAndStartClient(amountOfCLients, handler);\r
-        SimpleClient firstClient = clients.get(0);\r
-        firstClient.getScenarioDone().get();\r
-        mockPlugin.shutdown();\r
-        mockPlugin.getFinishedFuture().get();\r
-    }\r
-\r
-    /**\r
-     * Library integration and communication test (with virtual machine)\r
-     * @throws Exception\r
-     */\r
-    //@Test\r
-    public void testCommunicationWithVM() throws Exception {\r
-        mockPlugin.getFinishedFuture().get();\r
-    }\r
-    \r
-    /**\r
-     * @param amountOfCLients \r
-     * @return new clients up and running\r
-     * @throws ExecutionException if some client could not start\r
-     */\r
-    private List<SimpleClient> createAndStartClient(int amountOfCLients, ScenarioHandler scenarioHandler)\r
-            throws ExecutionException {\r
-        List<SimpleClient> clientsHorde = new ArrayList<>();\r
-        for (int i = 0; i < amountOfCLients; i++) {\r
-            LOGGER.debug("startup address in createclient: " + startupAddress.getHostAddress());\r
-            SimpleClient sc = new SimpleClient(startupAddress.getHostAddress(), port);\r
-            sc.setSecuredClient(false);\r
-            sc.setScenarioHandler(scenarioHandler);\r
-            clientsHorde.add(sc);\r
-            sc.start();\r
-        }\r
-        for (SimpleClient sc : clientsHorde) {\r
-            try {\r
-                sc.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);\r
-            } catch (Exception e) {\r
-                LOGGER.error(e.getMessage(), e);\r
-                throw new ExecutionException(e);\r
-            }\r
-        }\r
-        return clientsHorde;\r
-    }\r
-\r
-}\r
+/*
+ * 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.integration;
+
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+import java.util.concurrent.ExecutionException;
+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;
+import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler;
+import org.opendaylight.openflowjava.protocol.impl.clients.SendEvent;
+import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient;
+import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent;
+import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent;
+import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl;
+import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class IntegrationTest {
+
+    private static final Logger LOGGER = LoggerFactory
+            .getLogger(IntegrationTest.class);
+    private static int port;
+    private static final FEATURE_SUPPORT DEFAULT_TLS_SUPPORT = FEATURE_SUPPORT.NOT_SUPPORTED;
+    private static final int SWITCH_IDLE_TIMEOUT = 2000;
+    private static final long CONNECTION_TIMEOUT = 2000;
+    private InetAddress startupAddress;
+    private MockPlugin mockPlugin;
+    private SwitchConnectionProviderImpl scpimpl;
+    private List<ConnectionConfiguration> configs;
+
+    /**
+     * @throws Exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        LOGGER.debug("\n\nstarting test -------------------------------");
+        startupAddress = InetAddress.getLocalHost();
+        mockPlugin = new MockPlugin();
+        scpimpl = new SwitchConnectionProviderImpl();
+        scpimpl.setSwitchConnectionHandler(mockPlugin);
+        configs = new ArrayList<>();
+        configs.add(new TestingConnConfigImpl(startupAddress, 0, DEFAULT_TLS_SUPPORT, SWITCH_IDLE_TIMEOUT));
+        scpimpl.configure(configs);
+        scpimpl.startup().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
+        TcpHandler server = (TcpHandler) scpimpl.getServerLot().iterator().next();
+        port = server.getPort();
+    }
+
+    /**
+     * @throws Exception
+     */
+    @After
+    public void tearDown() throws Exception {
+        Thread.sleep(500);
+    }
+
+    /**
+     * Library integration and communication test with handshake
+     * @throws Exception 
+     */
+    @Test
+    public void testHandshake() throws Exception {
+        int amountOfCLients = 1;
+        Stack<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
+        ScenarioHandler handler = new ScenarioHandler(scenario);
+        List<SimpleClient> clients = createAndStartClient(amountOfCLients, handler);
+        SimpleClient firstClient = clients.get(0);
+        firstClient.getScenarioDone().get();
+        mockPlugin.shutdown();
+        mockPlugin.getFinishedFuture().get();
+    }
+
+    /**
+     * Library integration and communication test with handshake + echo exchange
+     * @throws Exception 
+     */
+    @Test
+    public void testHandshakeAndEcho() throws Exception {
+        int amountOfCLients = 1;
+        Stack<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
+        scenario.add(0, new SleepEvent(100));
+        scenario.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04")));
+        scenario.add(0, new SleepEvent(100));
+        scenario.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
+        ScenarioHandler handler = new ScenarioHandler(scenario);
+        List<SimpleClient> clients = createAndStartClient(amountOfCLients, handler);
+        SimpleClient firstClient = clients.get(0);
+        firstClient.getScenarioDone().get();
+        mockPlugin.shutdown();
+        mockPlugin.getFinishedFuture().get();
+    }
+
+    /**
+     * Library integration and communication test (with virtual machine)
+     * @throws Exception
+     */
+    //@Test
+    public void testCommunicationWithVM() throws Exception {
+        mockPlugin.getFinishedFuture().get();
+    }
+    
+    /**
+     * @param amountOfCLients 
+     * @return new clients up and running
+     * @throws ExecutionException if some client could not start
+     */
+    private List<SimpleClient> createAndStartClient(int amountOfCLients, ScenarioHandler scenarioHandler)
+            throws ExecutionException {
+        List<SimpleClient> clientsHorde = new ArrayList<>();
+        for (int i = 0; i < amountOfCLients; i++) {
+            LOGGER.debug("startup address in createclient: " + startupAddress.getHostAddress());
+            SimpleClient sc = new SimpleClient(startupAddress.getHostAddress(), port);
+            sc.setSecuredClient(false);
+            sc.setScenarioHandler(scenarioHandler);
+            clientsHorde.add(sc);
+            sc.start();
+        }
+        for (SimpleClient sc : clientsHorde) {
+            try {
+                sc.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
+            } catch (Exception e) {
+                LOGGER.error(e.getMessage(), e);
+                throw new ExecutionException(e);
+            }
+        }
+        return clientsHorde;
+    }
+
+}
index 7ca6ddd8b7589e311f52f3d17cdc4b3feb98ca89..f31ed029e40ba3d3416eec9bca03ee1333fb64b3 100644 (file)
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.integration;\r
-\r
-import java.net.InetAddress;\r
-import java.util.Arrays;\r
-import java.util.concurrent.ExecutionException;\r
-import java.util.concurrent.Future;\r
-import java.util.concurrent.TimeUnit;\r
-import java.util.concurrent.TimeoutException;\r
-\r
-import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;\r
-import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;\r
-import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder;\r
-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.GetFeaturesInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder;\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.HelloInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;\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.OpenflowProtocolListener;\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.system.rev130927.DisconnectEvent;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;\r
-import org.opendaylight.yangtools.yang.common.RpcError;\r
-import org.opendaylight.yangtools.yang.common.RpcResult;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.google.common.util.concurrent.SettableFuture;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHandler, \r
-        SystemNotificationsListener, ConnectionReadyListener {\r
-\r
-    protected static final Logger LOGGER = LoggerFactory.getLogger(MockPlugin.class);\r
-    protected ConnectionAdapter adapter;\r
-    private SettableFuture<Void> finishedFuture;\r
-    private int idleCounter = 0;\r
-\r
-    /** Creates MockPlugin */\r
-    public MockPlugin() {\r
-        LOGGER.info("Creating MockPlugin");\r
-        finishedFuture = SettableFuture.create();\r
-        LOGGER.info("mockPlugin: "+System.identityHashCode(this));\r
-    }\r
-    \r
-    @Override\r
-    public void onSwitchConnected(ConnectionAdapter connection) {\r
-        LOGGER.info("onSwitchConnected: " + connection);\r
-        this.adapter = connection;\r
-        connection.setMessageListener(this);\r
-        connection.setSystemListener(this);\r
-        connection.setConnectionReadyListener(this);\r
-    }\r
-\r
-    @Override\r
-    public boolean accept(InetAddress switchAddress) {\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public void onEchoRequestMessage(final EchoRequestMessage notification) {\r
-        new Thread(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                LOGGER.debug("EchoRequest message received");\r
-                EchoReplyInputBuilder replyBuilder = new EchoReplyInputBuilder();\r
-                replyBuilder.setVersion((short) 4);\r
-                replyBuilder.setXid(notification.getXid());\r
-                EchoReplyInput echoReplyInput = replyBuilder.build();\r
-                adapter.echoReply(echoReplyInput);\r
-                LOGGER.debug("EchoReplyInput sent");\r
-                LOGGER.debug("adapter: "+adapter);\r
-            }\r
-        }).start();\r
-    }\r
-\r
-    @Override\r
-    public void onErrorMessage(ErrorMessage notification) {\r
-        LOGGER.debug("Error message received");\r
-        \r
-    }\r
-\r
-    @Override\r
-    public void onExperimenterMessage(ExperimenterMessage notification) {\r
-        LOGGER.debug("Experimenter message received");\r
-        \r
-    }\r
-\r
-    @Override\r
-    public void onFlowRemovedMessage(FlowRemovedMessage notification) {\r
-        LOGGER.debug("FlowRemoved message received");\r
-        \r
-    }\r
-\r
-    @Override\r
-    public void onHelloMessage(HelloMessage notification) {\r
-        new Thread(new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                LOGGER.debug("Hello message received");\r
-                HelloInputBuilder hib = new HelloInputBuilder();\r
-                hib.setVersion((short) 4);\r
-                hib.setXid(2L);\r
-                HelloInput hi = hib.build();\r
-                adapter.hello(hi);\r
-                LOGGER.debug("hello msg sent");\r
-                new Thread(new Runnable() {\r
-                    @Override\r
-                    public void run() {\r
-                        sendFeaturesReply();\r
-                    }\r
-                }).start();\r
-                LOGGER.debug("adapter: "+adapter);\r
-            }\r
-        }).start();\r
-    }\r
-    \r
-    protected void sendFeaturesReply() {\r
-        GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder();\r
-        featuresBuilder.setVersion((short) 4);\r
-        featuresBuilder.setXid(3L);\r
-        GetFeaturesInput featuresInput = featuresBuilder.build();\r
-        try {\r
-            LOGGER.debug("Going to send featuresRequest");\r
-            RpcResult<GetFeaturesOutput> rpcResult = adapter.getFeatures(\r
-                    featuresInput).get(2500, TimeUnit.MILLISECONDS);\r
-            if (rpcResult.isSuccessful()) {\r
-                byte[] byteArray = rpcResult.getResult().getDatapathId()\r
-                        .toByteArray();\r
-                LOGGER.info("DatapathId: " + Arrays.toString(byteArray));\r
-            } else {\r
-                RpcError rpcError = rpcResult.getErrors().iterator().next();\r
-                LOGGER.warn("rpcResult failed: "\r
-                        + rpcError.getCause().getMessage(), rpcError.getCause());\r
-            }\r
-        } catch (InterruptedException | ExecutionException | TimeoutException e) {\r
-            LOGGER.error(e.getMessage(), e);\r
-        }\r
-        LOGGER.info("After FeaturesReply message");\r
-    }\r
-\r
-    protected void shutdown() {\r
-        LOGGER.debug("adapter: "+adapter);\r
-        try {\r
-            LOGGER.info("mockPlugin: "+System.identityHashCode(this));\r
-            Thread.sleep(500);\r
-            if (adapter != null) {\r
-                Future<Boolean> disconnect = adapter.disconnect();\r
-                disconnect.get();\r
-                LOGGER.info("Disconnected");\r
-            } \r
-        } catch (Exception e) {\r
-            LOGGER.error(e.getMessage(), e);\r
-        }\r
-        finishedFuture.set(null);\r
-    }\r
-\r
-    @Override\r
-    public void onMultipartReplyMessage(MultipartReplyMessage notification) {\r
-        LOGGER.debug("MultipartReply message received");\r
-        \r
-    }\r
-\r
-    @Override\r
-    public void onPacketInMessage(PacketInMessage notification) {\r
-        LOGGER.debug("PacketIn message received");\r
-        LOGGER.debug("BufferId: " + notification.getBufferId());\r
-        LOGGER.debug("TotalLength: " + notification.getTotalLen());\r
-        LOGGER.debug("Reason: " + notification.getReason());\r
-        LOGGER.debug("TableId: " + notification.getTableId());\r
-        LOGGER.debug("Cookie: " + notification.getCookie());\r
-        LOGGER.debug("Class: " + notification.getMatch().getMatchEntries().get(0).getOxmClass());\r
-        LOGGER.debug("Field: " + notification.getMatch().getMatchEntries().get(0).getOxmMatchField());\r
-        LOGGER.debug("Datasize: " + notification.getData().length);\r
-    }\r
-\r
-    @Override\r
-    public void onPortStatusMessage(PortStatusMessage notification) {\r
-        LOGGER.debug("PortStatus message received");\r
-        \r
-    }\r
-\r
-    @Override\r
-    public void onDisconnectEvent(DisconnectEvent notification) {\r
-        LOGGER.debug("disconnection ocured: "+notification.getInfo());\r
-        LOGGER.debug("adapter: "+adapter);\r
-    }\r
-\r
-    /**\r
-     * @return finishedFuture object\r
-     */\r
-    public SettableFuture<Void> getFinishedFuture() {\r
-        return finishedFuture;\r
-    }\r
-\r
-    @Override\r
-    public void onSwitchIdleEvent(SwitchIdleEvent notification) {\r
-        LOGGER.debug("switch status: "+notification.getInfo());\r
-        idleCounter ++;\r
-    }\r
-\r
-    /**\r
-     * @return number of occured idleEvents\r
-     */\r
-    public int getIdleCounter() {\r
-        return idleCounter;\r
-    }\r
-    \r
-    @Override\r
-    public void onConnectionReady() {\r
-        LOGGER.debug("connection ready notification arrived");\r
-    }\r
-\r
-\r
-}\r
+/*
+ * 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.integration;
+
+import java.net.InetAddress;
+import java.util.Arrays;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
+import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
+import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.SettableFuture;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHandler, 
+        SystemNotificationsListener, ConnectionReadyListener {
+
+    protected static final Logger LOGGER = LoggerFactory.getLogger(MockPlugin.class);
+    protected ConnectionAdapter adapter;
+    private SettableFuture<Void> finishedFuture;
+    private int idleCounter = 0;
+
+    /** Creates MockPlugin */
+    public MockPlugin() {
+        LOGGER.info("Creating MockPlugin");
+        finishedFuture = SettableFuture.create();
+        LOGGER.info("mockPlugin: "+System.identityHashCode(this));
+    }
+    
+    @Override
+    public void onSwitchConnected(ConnectionAdapter connection) {
+        LOGGER.info("onSwitchConnected: " + connection);
+        this.adapter = connection;
+        connection.setMessageListener(this);
+        connection.setSystemListener(this);
+        connection.setConnectionReadyListener(this);
+    }
+
+    @Override
+    public boolean accept(InetAddress switchAddress) {
+        return true;
+    }
+
+    @Override
+    public void onEchoRequestMessage(final EchoRequestMessage notification) {
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                LOGGER.debug("EchoRequest message received");
+                EchoReplyInputBuilder replyBuilder = new EchoReplyInputBuilder();
+                replyBuilder.setVersion((short) 4);
+                replyBuilder.setXid(notification.getXid());
+                EchoReplyInput echoReplyInput = replyBuilder.build();
+                adapter.echoReply(echoReplyInput);
+                LOGGER.debug("EchoReplyInput sent");
+                LOGGER.debug("adapter: "+adapter);
+            }
+        }).start();
+    }
+
+    @Override
+    public void onErrorMessage(ErrorMessage notification) {
+        LOGGER.debug("Error message received");
+        
+    }
+
+    @Override
+    public void onExperimenterMessage(ExperimenterMessage notification) {
+        LOGGER.debug("Experimenter message received");
+        
+    }
+
+    @Override
+    public void onFlowRemovedMessage(FlowRemovedMessage notification) {
+        LOGGER.debug("FlowRemoved message received");
+        
+    }
+
+    @Override
+    public void onHelloMessage(HelloMessage notification) {
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                LOGGER.debug("Hello message received");
+                HelloInputBuilder hib = new HelloInputBuilder();
+                hib.setVersion((short) 4);
+                hib.setXid(2L);
+                HelloInput hi = hib.build();
+                adapter.hello(hi);
+                LOGGER.debug("hello msg sent");
+                new Thread(new Runnable() {
+                    @Override
+                    public void run() {
+                        sendFeaturesReply();
+                    }
+                }).start();
+                LOGGER.debug("adapter: "+adapter);
+            }
+        }).start();
+    }
+    
+    protected void sendFeaturesReply() {
+        GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder();
+        featuresBuilder.setVersion((short) 4);
+        featuresBuilder.setXid(3L);
+        GetFeaturesInput featuresInput = featuresBuilder.build();
+        try {
+            LOGGER.debug("Going to send featuresRequest");
+            RpcResult<GetFeaturesOutput> rpcResult = adapter.getFeatures(
+                    featuresInput).get(2500, TimeUnit.MILLISECONDS);
+            if (rpcResult.isSuccessful()) {
+                byte[] byteArray = rpcResult.getResult().getDatapathId()
+                        .toByteArray();
+                LOGGER.info("DatapathId: " + Arrays.toString(byteArray));
+            } else {
+                RpcError rpcError = rpcResult.getErrors().iterator().next();
+                LOGGER.warn("rpcResult failed: "
+                        + rpcError.getCause().getMessage(), rpcError.getCause());
+            }
+        } catch (InterruptedException | ExecutionException | TimeoutException e) {
+            LOGGER.error(e.getMessage(), e);
+        }
+        LOGGER.info("After FeaturesReply message");
+    }
+
+    protected void shutdown() {
+        LOGGER.debug("adapter: "+adapter);
+        try {
+            LOGGER.info("mockPlugin: "+System.identityHashCode(this));
+            Thread.sleep(500);
+            if (adapter != null) {
+                Future<Boolean> disconnect = adapter.disconnect();
+                disconnect.get();
+                LOGGER.info("Disconnected");
+            } 
+        } catch (Exception e) {
+            LOGGER.error(e.getMessage(), e);
+        }
+        finishedFuture.set(null);
+    }
+
+    @Override
+    public void onMultipartReplyMessage(MultipartReplyMessage notification) {
+        LOGGER.debug("MultipartReply message received");
+        
+    }
+
+    @Override
+    public void onPacketInMessage(PacketInMessage notification) {
+        LOGGER.debug("PacketIn message received");
+        LOGGER.debug("BufferId: " + notification.getBufferId());
+        LOGGER.debug("TotalLength: " + notification.getTotalLen());
+        LOGGER.debug("Reason: " + notification.getReason());
+        LOGGER.debug("TableId: " + notification.getTableId());
+        LOGGER.debug("Cookie: " + notification.getCookie());
+        LOGGER.debug("Class: " + notification.getMatch().getMatchEntries().get(0).getOxmClass());
+        LOGGER.debug("Field: " + notification.getMatch().getMatchEntries().get(0).getOxmMatchField());
+        LOGGER.debug("Datasize: " + notification.getData().length);
+    }
+
+    @Override
+    public void onPortStatusMessage(PortStatusMessage notification) {
+        LOGGER.debug("PortStatus message received");
+        
+    }
+
+    @Override
+    public void onDisconnectEvent(DisconnectEvent notification) {
+        LOGGER.debug("disconnection ocured: "+notification.getInfo());
+        LOGGER.debug("adapter: "+adapter);
+    }
+
+    /**
+     * @return finishedFuture object
+     */
+    public SettableFuture<Void> getFinishedFuture() {
+        return finishedFuture;
+    }
+
+    @Override
+    public void onSwitchIdleEvent(SwitchIdleEvent notification) {
+        LOGGER.debug("switch status: "+notification.getInfo());
+        idleCounter ++;
+    }
+
+    /**
+     * @return number of occured idleEvents
+     */
+    public int getIdleCounter() {
+        return idleCounter;
+    }
+    
+    @Override
+    public void onConnectionReady() {
+        LOGGER.debug("connection ready notification arrived");
+    }
+
+
+}
index 3a9bd55b2ef75125863d6f2c93f1e95e78416f9a..578001d4a2605eace93abc42cdab575397a3a1cc 100644 (file)
@@ -1,65 +1,72 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.integration;\r
-\r
-import java.net.InetAddress;\r
-\r
-import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class TestingConnConfigImpl implements ConnectionConfiguration {\r
-\r
-    private InetAddress address;\r
-    private int port;\r
-    private Object transferProtocol;\r
-    private FEATURE_SUPPORT tlsSupport;\r
-    private long switchIdleTimeout;\r
-\r
-    /**\r
-     * Creates {@link TestingConnConfigImpl}\r
-     * @param address \r
-     * @param port\r
-     * @param tlsSupport\r
-     * @param switchIdleTimeout\r
-     */\r
-    public TestingConnConfigImpl(InetAddress address, int port, FEATURE_SUPPORT tlsSupport, long switchIdleTimeout) {\r
-        this.address = address;\r
-        this.port = port;\r
-        this.tlsSupport = tlsSupport;\r
-        this.switchIdleTimeout = switchIdleTimeout;\r
-    }\r
-\r
-    @Override\r
-    public InetAddress getAddress() {\r
-        return address;\r
-    }\r
-\r
-    @Override\r
-    public int getPort() {\r
-        return port;\r
-    }\r
-\r
-    @Override\r
-    public Object getTransferProtocol() {\r
-        return transferProtocol;\r
-    }\r
-\r
-    @Override\r
-    public FEATURE_SUPPORT getTlsSupport() {\r
-        return tlsSupport;\r
-    }\r
-\r
-    @Override\r
-    public long getSwitchIdleTimeout() {\r
-        return switchIdleTimeout;\r
-    }\r
-\r
-    @Override\r
-    public Object getSslContext() {\r
-        // TODO Auto-generated method stub\r
-        return null;\r
-    }\r
-\r
-}\r
+/*
+ * 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.integration;
+
+import java.net.InetAddress;
+
+import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class TestingConnConfigImpl implements ConnectionConfiguration {
+
+    private InetAddress address;
+    private int port;
+    private Object transferProtocol;
+    private FEATURE_SUPPORT tlsSupport;
+    private long switchIdleTimeout;
+
+    /**
+     * Creates {@link TestingConnConfigImpl}
+     * @param address 
+     * @param port
+     * @param tlsSupport
+     * @param switchIdleTimeout
+     */
+    public TestingConnConfigImpl(InetAddress address, int port, FEATURE_SUPPORT tlsSupport, long switchIdleTimeout) {
+        this.address = address;
+        this.port = port;
+        this.tlsSupport = tlsSupport;
+        this.switchIdleTimeout = switchIdleTimeout;
+    }
+
+    @Override
+    public InetAddress getAddress() {
+        return address;
+    }
+
+    @Override
+    public int getPort() {
+        return port;
+    }
+
+    @Override
+    public Object getTransferProtocol() {
+        return transferProtocol;
+    }
+
+    @Override
+    public FEATURE_SUPPORT getTlsSupport() {
+        return tlsSupport;
+    }
+
+    @Override
+    public long getSwitchIdleTimeout() {
+        return switchIdleTimeout;
+    }
+
+    @Override
+    public Object getSslContext() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}
index 9cf1b736c17dfd3f79f59cfa58d069aa77d47037..0465ab4ebbfa64a38dd90155e533574db6bf4aa2 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.spi.connection;
 
index 2f2d80ba4fdee71db457f3b2efaf3c2d73413575..39b86460e446ffbf74183c482fad25f3926e520b 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.clients;
 
 /**
index 2d2ddcf8f3cffa54366d9de08cdd7e7d06a9a1c0..71d0396814e855bb2d8353ed99af92c1f8b1763f 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.clients;
 
 import java.util.Stack;
index 29244dba6484d8b34ae9d564f9010d05d6711d86..24f90c9df6f54ed465bd2a7567c75ebbd993d5eb 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.clients;
 
 import io.netty.channel.ChannelHandlerContext;
index e59bce0775eb5d6a3734ce53e2e5bd3b80983887..bd664b805cf2667904f94ff31dd3303536f008df 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.clients;
 
 import io.netty.buffer.ByteBuf;
index b85b6b0e8a5ff8bca0d85e1a56e522f02518684d..159471ceb34a4d9c348ff3150aa765b0ff73c447 100644 (file)
@@ -1,4 +1,11 @@
- /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.clients;
 
 import io.netty.bootstrap.Bootstrap;
index 95eb08c00a607d0c8b6318fd2d1beb25d3efcf9c..48d7e475ef01044b5cffc633e034c35bd6a8230d 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.clients;
 
index e9453b58437ada987f4763909aee3742c7881f81..9c7ae5dbad8da936a1620e9cbb145c3cd795ad50 100644 (file)
@@ -1,68 +1,75 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-\r
-package org.opendaylight.openflowjava.protocol.impl.clients;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.channel.ChannelHandlerContext;\r
-import io.netty.channel.ChannelInboundHandlerAdapter;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.google.common.util.concurrent.SettableFuture;\r
-\r
-/**\r
- *\r
- * @author michal.polkorab\r
- */\r
-public class SimpleClientHandler extends ChannelInboundHandlerAdapter {\r
-\r
-    protected static final Logger LOGGER = LoggerFactory.getLogger(SimpleClientHandler.class);\r
-    private static final int LENGTH_INDEX_IN_HEADER = 2;\r
-    private SettableFuture<Boolean> isOnlineFuture;\r
-    protected ScenarioHandler scenarioHandler;\r
-\r
-    /**\r
-     * @param isOnlineFuture future notifier of connected channel\r
-     * @param scenarioHandler handler of scenario events\r
-     */\r
-    public SimpleClientHandler(SettableFuture<Boolean> isOnlineFuture, ScenarioHandler scenarioHandler) {\r
-        this.isOnlineFuture = isOnlineFuture;\r
-        this.scenarioHandler = scenarioHandler;\r
-    }\r
-\r
-    @Override\r
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {\r
-        ByteBuf bb = (ByteBuf) msg;\r
-        if (LOGGER.isDebugEnabled()) {\r
-            LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(bb));\r
-        }\r
-        int length = bb.getUnsignedShort(LENGTH_INDEX_IN_HEADER);\r
-        LOGGER.info("SimpleClientHandler - start of read");\r
-        byte[] message = new byte[length];\r
-        bb.readBytes(message);\r
-        scenarioHandler.addOfMsg(message);\r
-        LOGGER.info("end of read");\r
-    }\r
-\r
-    @Override\r
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {\r
-        LOGGER.info("Client is active");\r
-        if (isOnlineFuture != null) {\r
-            isOnlineFuture.set(true);\r
-            isOnlineFuture = null;\r
-        }\r
-        scenarioHandler.setCtx(ctx);\r
-        scenarioHandler.start();\r
-        \r
-    }\r
-\r
-    /**\r
-     * @param scenarioHandler handler of scenario events\r
-     */\r
-    public void setScenario(ScenarioHandler scenarioHandler) {\r
-        this.scenarioHandler = scenarioHandler;\r
-    }\r
-\r
-}\r
+/*
+ * 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.clients;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.SettableFuture;
+
+/**
+ *
+ * @author michal.polkorab
+ */
+public class SimpleClientHandler extends ChannelInboundHandlerAdapter {
+
+    protected static final Logger LOGGER = LoggerFactory.getLogger(SimpleClientHandler.class);
+    private static final int LENGTH_INDEX_IN_HEADER = 2;
+    private SettableFuture<Boolean> isOnlineFuture;
+    protected ScenarioHandler scenarioHandler;
+
+    /**
+     * @param isOnlineFuture future notifier of connected channel
+     * @param scenarioHandler handler of scenario events
+     */
+    public SimpleClientHandler(SettableFuture<Boolean> isOnlineFuture, ScenarioHandler scenarioHandler) {
+        this.isOnlineFuture = isOnlineFuture;
+        this.scenarioHandler = scenarioHandler;
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf bb = (ByteBuf) msg;
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(bb));
+        }
+        int length = bb.getUnsignedShort(LENGTH_INDEX_IN_HEADER);
+        LOGGER.info("SimpleClientHandler - start of read");
+        byte[] message = new byte[length];
+        bb.readBytes(message);
+        scenarioHandler.addOfMsg(message);
+        LOGGER.info("end of read");
+    }
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        LOGGER.info("Client is active");
+        if (isOnlineFuture != null) {
+            isOnlineFuture.set(true);
+            isOnlineFuture = null;
+        }
+        scenarioHandler.setCtx(ctx);
+        scenarioHandler.start();
+        
+    }
+
+    /**
+     * @param scenarioHandler handler of scenario events
+     */
+    public void setScenario(ScenarioHandler scenarioHandler) {
+        this.scenarioHandler = scenarioHandler;
+    }
+
+}
index eed609702309530310c59568dab1175305911b52..bd9a911bb02ad593ebad354bbf1a3c576867f8b7 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.clients;
 
index 490a094b14b52704785ba2fdcdde02b33c5156c5..25ed0d460a7f46fea3deebae8e61b612aed17824 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.clients;
 
 import org.slf4j.Logger;
index 1ad9b9441cfffdca618e7acc3425a247aee94049..688a128e4ec616f206423cde15040dbbd7020fd4 100644 (file)
@@ -1,4 +1,11 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * 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.clients;
 
 import java.util.Arrays;